@easy-editor/react-renderer 0.0.17 → 0.0.18
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/cjs/index.development.js +1377 -98
- package/dist/cjs/index.development.js.map +1 -1
- package/dist/cjs/index.js +1377 -98
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.production.js +1377 -98
- package/dist/cjs/index.production.js.map +1 -1
- package/dist/esm/index.development.js +1378 -100
- package/dist/esm/index.development.js.map +1 -1
- package/dist/esm/index.js +1378 -100
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.production.js +1378 -100
- package/dist/esm/index.production.js.map +1 -1
- package/dist/index.js +1378 -100
- package/dist/renderer-core/types.d.ts +35 -20
- package/dist/renderer-core/utils/common.d.ts +6 -0
- package/dist/renderer-core/utils/data-helper.d.ts +83 -0
- package/dist/renderer-core/utils/request.d.ts +43 -0
- package/package.json +6 -6
|
@@ -286,12 +286,12 @@ var root = freeGlobal || freeSelf || Function('return this')();
|
|
|
286
286
|
|
|
287
287
|
var Symbol = root.Symbol;
|
|
288
288
|
|
|
289
|
-
var objectProto$
|
|
290
|
-
var hasOwnProperty$
|
|
291
|
-
var nativeObjectToString$1 = objectProto$
|
|
289
|
+
var objectProto$c = Object.prototype;
|
|
290
|
+
var hasOwnProperty$a = objectProto$c.hasOwnProperty;
|
|
291
|
+
var nativeObjectToString$1 = objectProto$c.toString;
|
|
292
292
|
var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined;
|
|
293
293
|
function getRawTag(value) {
|
|
294
|
-
var isOwn = hasOwnProperty$
|
|
294
|
+
var isOwn = hasOwnProperty$a.call(value, symToStringTag$1),
|
|
295
295
|
tag = value[symToStringTag$1];
|
|
296
296
|
try {
|
|
297
297
|
value[symToStringTag$1] = undefined;
|
|
@@ -308,8 +308,8 @@ function getRawTag(value) {
|
|
|
308
308
|
return result;
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
-
var objectProto$
|
|
312
|
-
var nativeObjectToString = objectProto$
|
|
311
|
+
var objectProto$b = Object.prototype;
|
|
312
|
+
var nativeObjectToString = objectProto$b.toString;
|
|
313
313
|
function objectToString(value) {
|
|
314
314
|
return nativeObjectToString.call(value);
|
|
315
315
|
}
|
|
@@ -347,7 +347,7 @@ function baseTrim(string) {
|
|
|
347
347
|
return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') : string;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
function isObject(value) {
|
|
350
|
+
function isObject$1(value) {
|
|
351
351
|
var type = typeof value;
|
|
352
352
|
return value != null && (type == 'object' || type == 'function');
|
|
353
353
|
}
|
|
@@ -364,9 +364,9 @@ function toNumber(value) {
|
|
|
364
364
|
if (isSymbol(value)) {
|
|
365
365
|
return NAN;
|
|
366
366
|
}
|
|
367
|
-
if (isObject(value)) {
|
|
367
|
+
if (isObject$1(value)) {
|
|
368
368
|
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
|
|
369
|
-
value = isObject(other) ? other + '' : other;
|
|
369
|
+
value = isObject$1(other) ? other + '' : other;
|
|
370
370
|
}
|
|
371
371
|
if (typeof value != 'string') {
|
|
372
372
|
return value === 0 ? value : +value;
|
|
@@ -385,7 +385,7 @@ var asyncTag = '[object AsyncFunction]',
|
|
|
385
385
|
genTag = '[object GeneratorFunction]',
|
|
386
386
|
proxyTag = '[object Proxy]';
|
|
387
387
|
function isFunction(value) {
|
|
388
|
-
if (!isObject(value)) {
|
|
388
|
+
if (!isObject$1(value)) {
|
|
389
389
|
return false;
|
|
390
390
|
}
|
|
391
391
|
var tag = baseGetTag(value);
|
|
@@ -402,12 +402,12 @@ function isMasked(func) {
|
|
|
402
402
|
return !!maskSrcKey && maskSrcKey in func;
|
|
403
403
|
}
|
|
404
404
|
|
|
405
|
-
var funcProto$
|
|
406
|
-
var funcToString$
|
|
405
|
+
var funcProto$2 = Function.prototype;
|
|
406
|
+
var funcToString$2 = funcProto$2.toString;
|
|
407
407
|
function toSource(func) {
|
|
408
408
|
if (func != null) {
|
|
409
409
|
try {
|
|
410
|
-
return funcToString$
|
|
410
|
+
return funcToString$2.call(func);
|
|
411
411
|
} catch (e) {}
|
|
412
412
|
try {
|
|
413
413
|
return func + '';
|
|
@@ -418,13 +418,13 @@ function toSource(func) {
|
|
|
418
418
|
|
|
419
419
|
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
420
420
|
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
421
|
-
var funcProto = Function.prototype,
|
|
422
|
-
objectProto$
|
|
423
|
-
var funcToString = funcProto.toString;
|
|
424
|
-
var hasOwnProperty$
|
|
425
|
-
var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty$
|
|
421
|
+
var funcProto$1 = Function.prototype,
|
|
422
|
+
objectProto$a = Object.prototype;
|
|
423
|
+
var funcToString$1 = funcProto$1.toString;
|
|
424
|
+
var hasOwnProperty$9 = objectProto$a.hasOwnProperty;
|
|
425
|
+
var reIsNative = RegExp('^' + funcToString$1.call(hasOwnProperty$9).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
|
|
426
426
|
function baseIsNative(value) {
|
|
427
|
-
if (!isObject(value) || isMasked(value)) {
|
|
427
|
+
if (!isObject$1(value) || isMasked(value)) {
|
|
428
428
|
return false;
|
|
429
429
|
}
|
|
430
430
|
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
@@ -442,6 +442,93 @@ function getNative(object, key) {
|
|
|
442
442
|
|
|
443
443
|
var WeakMap = getNative(root, 'WeakMap');
|
|
444
444
|
|
|
445
|
+
var objectCreate = Object.create;
|
|
446
|
+
var baseCreate = function () {
|
|
447
|
+
function object() {}
|
|
448
|
+
return function (proto) {
|
|
449
|
+
if (!isObject$1(proto)) {
|
|
450
|
+
return {};
|
|
451
|
+
}
|
|
452
|
+
if (objectCreate) {
|
|
453
|
+
return objectCreate(proto);
|
|
454
|
+
}
|
|
455
|
+
object.prototype = proto;
|
|
456
|
+
var result = new object();
|
|
457
|
+
object.prototype = undefined;
|
|
458
|
+
return result;
|
|
459
|
+
};
|
|
460
|
+
}();
|
|
461
|
+
|
|
462
|
+
function apply(func, thisArg, args) {
|
|
463
|
+
switch (args.length) {
|
|
464
|
+
case 0:
|
|
465
|
+
return func.call(thisArg);
|
|
466
|
+
case 1:
|
|
467
|
+
return func.call(thisArg, args[0]);
|
|
468
|
+
case 2:
|
|
469
|
+
return func.call(thisArg, args[0], args[1]);
|
|
470
|
+
case 3:
|
|
471
|
+
return func.call(thisArg, args[0], args[1], args[2]);
|
|
472
|
+
}
|
|
473
|
+
return func.apply(thisArg, args);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function copyArray(source, array) {
|
|
477
|
+
var index = -1,
|
|
478
|
+
length = source.length;
|
|
479
|
+
array || (array = Array(length));
|
|
480
|
+
while (++index < length) {
|
|
481
|
+
array[index] = source[index];
|
|
482
|
+
}
|
|
483
|
+
return array;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
var HOT_COUNT = 800,
|
|
487
|
+
HOT_SPAN = 16;
|
|
488
|
+
var nativeNow = Date.now;
|
|
489
|
+
function shortOut(func) {
|
|
490
|
+
var count = 0,
|
|
491
|
+
lastCalled = 0;
|
|
492
|
+
return function () {
|
|
493
|
+
var stamp = nativeNow(),
|
|
494
|
+
remaining = HOT_SPAN - (stamp - lastCalled);
|
|
495
|
+
lastCalled = stamp;
|
|
496
|
+
if (remaining > 0) {
|
|
497
|
+
if (++count >= HOT_COUNT) {
|
|
498
|
+
return arguments[0];
|
|
499
|
+
}
|
|
500
|
+
} else {
|
|
501
|
+
count = 0;
|
|
502
|
+
}
|
|
503
|
+
return func.apply(undefined, arguments);
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function constant(value) {
|
|
508
|
+
return function () {
|
|
509
|
+
return value;
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
var defineProperty = function () {
|
|
514
|
+
try {
|
|
515
|
+
var func = getNative(Object, 'defineProperty');
|
|
516
|
+
func({}, '', {});
|
|
517
|
+
return func;
|
|
518
|
+
} catch (e) {}
|
|
519
|
+
}();
|
|
520
|
+
|
|
521
|
+
var baseSetToString = !defineProperty ? identity : function (func, string) {
|
|
522
|
+
return defineProperty(func, 'toString', {
|
|
523
|
+
'configurable': true,
|
|
524
|
+
'enumerable': false,
|
|
525
|
+
'value': constant(string),
|
|
526
|
+
'writable': true
|
|
527
|
+
});
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
var setToString = shortOut(baseSetToString);
|
|
531
|
+
|
|
445
532
|
function arrayEach(array, iteratee) {
|
|
446
533
|
var index = -1,
|
|
447
534
|
length = array == null ? 0 : array.length;
|
|
@@ -461,6 +548,77 @@ function isIndex(value, length) {
|
|
|
461
548
|
return !!length && (type == 'number' || type != 'symbol' && reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
|
|
462
549
|
}
|
|
463
550
|
|
|
551
|
+
function baseAssignValue(object, key, value) {
|
|
552
|
+
if (key == '__proto__' && defineProperty) {
|
|
553
|
+
defineProperty(object, key, {
|
|
554
|
+
'configurable': true,
|
|
555
|
+
'enumerable': true,
|
|
556
|
+
'value': value,
|
|
557
|
+
'writable': true
|
|
558
|
+
});
|
|
559
|
+
} else {
|
|
560
|
+
object[key] = value;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
function eq(value, other) {
|
|
565
|
+
return value === other || value !== value && other !== other;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
var objectProto$9 = Object.prototype;
|
|
569
|
+
var hasOwnProperty$8 = objectProto$9.hasOwnProperty;
|
|
570
|
+
function assignValue(object, key, value) {
|
|
571
|
+
var objValue = object[key];
|
|
572
|
+
if (!(hasOwnProperty$8.call(object, key) && eq(objValue, value)) || value === undefined && !(key in object)) {
|
|
573
|
+
baseAssignValue(object, key, value);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
function copyObject(source, props, object, customizer) {
|
|
578
|
+
var isNew = !object;
|
|
579
|
+
object || (object = {});
|
|
580
|
+
var index = -1,
|
|
581
|
+
length = props.length;
|
|
582
|
+
while (++index < length) {
|
|
583
|
+
var key = props[index];
|
|
584
|
+
var newValue = undefined;
|
|
585
|
+
if (newValue === undefined) {
|
|
586
|
+
newValue = source[key];
|
|
587
|
+
}
|
|
588
|
+
if (isNew) {
|
|
589
|
+
baseAssignValue(object, key, newValue);
|
|
590
|
+
} else {
|
|
591
|
+
assignValue(object, key, newValue);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return object;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
var nativeMax$1 = Math.max;
|
|
598
|
+
function overRest(func, start, transform) {
|
|
599
|
+
start = nativeMax$1(start === undefined ? func.length - 1 : start, 0);
|
|
600
|
+
return function () {
|
|
601
|
+
var args = arguments,
|
|
602
|
+
index = -1,
|
|
603
|
+
length = nativeMax$1(args.length - start, 0),
|
|
604
|
+
array = Array(length);
|
|
605
|
+
while (++index < length) {
|
|
606
|
+
array[index] = args[start + index];
|
|
607
|
+
}
|
|
608
|
+
index = -1;
|
|
609
|
+
var otherArgs = Array(start + 1);
|
|
610
|
+
while (++index < start) {
|
|
611
|
+
otherArgs[index] = args[index];
|
|
612
|
+
}
|
|
613
|
+
otherArgs[start] = transform(array);
|
|
614
|
+
return apply(func, this, otherArgs);
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
function baseRest(func, start) {
|
|
619
|
+
return setToString(overRest(func, start, identity), func + '');
|
|
620
|
+
}
|
|
621
|
+
|
|
464
622
|
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
465
623
|
function isLength(value) {
|
|
466
624
|
return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
@@ -470,10 +628,43 @@ function isArrayLike(value) {
|
|
|
470
628
|
return value != null && isLength(value.length) && !isFunction(value);
|
|
471
629
|
}
|
|
472
630
|
|
|
473
|
-
|
|
631
|
+
function isIterateeCall(value, index, object) {
|
|
632
|
+
if (!isObject$1(object)) {
|
|
633
|
+
return false;
|
|
634
|
+
}
|
|
635
|
+
var type = typeof index;
|
|
636
|
+
if (type == 'number' ? isArrayLike(object) && isIndex(index, object.length) : type == 'string' && index in object) {
|
|
637
|
+
return eq(object[index], value);
|
|
638
|
+
}
|
|
639
|
+
return false;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
function createAssigner(assigner) {
|
|
643
|
+
return baseRest(function (object, sources) {
|
|
644
|
+
var index = -1,
|
|
645
|
+
length = sources.length,
|
|
646
|
+
customizer = length > 1 ? sources[length - 1] : undefined,
|
|
647
|
+
guard = length > 2 ? sources[2] : undefined;
|
|
648
|
+
customizer = assigner.length > 3 && typeof customizer == 'function' ? (length--, customizer) : undefined;
|
|
649
|
+
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
|
650
|
+
customizer = length < 3 ? undefined : customizer;
|
|
651
|
+
length = 1;
|
|
652
|
+
}
|
|
653
|
+
object = Object(object);
|
|
654
|
+
while (++index < length) {
|
|
655
|
+
var source = sources[index];
|
|
656
|
+
if (source) {
|
|
657
|
+
assigner(object, source, index, customizer);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
return object;
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
var objectProto$8 = Object.prototype;
|
|
474
665
|
function isPrototype(value) {
|
|
475
666
|
var Ctor = value && value.constructor,
|
|
476
|
-
proto = typeof Ctor == 'function' && Ctor.prototype || objectProto$
|
|
667
|
+
proto = typeof Ctor == 'function' && Ctor.prototype || objectProto$8;
|
|
477
668
|
return value === proto;
|
|
478
669
|
}
|
|
479
670
|
|
|
@@ -491,24 +682,24 @@ function baseIsArguments(value) {
|
|
|
491
682
|
return isObjectLike(value) && baseGetTag(value) == argsTag$1;
|
|
492
683
|
}
|
|
493
684
|
|
|
494
|
-
var objectProto$
|
|
495
|
-
var hasOwnProperty$
|
|
496
|
-
var propertyIsEnumerable = objectProto$
|
|
685
|
+
var objectProto$7 = Object.prototype;
|
|
686
|
+
var hasOwnProperty$7 = objectProto$7.hasOwnProperty;
|
|
687
|
+
var propertyIsEnumerable = objectProto$7.propertyIsEnumerable;
|
|
497
688
|
var isArguments = baseIsArguments(function () {
|
|
498
689
|
return arguments;
|
|
499
690
|
}()) ? baseIsArguments : function (value) {
|
|
500
|
-
return isObjectLike(value) && hasOwnProperty$
|
|
691
|
+
return isObjectLike(value) && hasOwnProperty$7.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
|
|
501
692
|
};
|
|
502
693
|
|
|
503
694
|
function stubFalse() {
|
|
504
695
|
return false;
|
|
505
696
|
}
|
|
506
697
|
|
|
507
|
-
var freeExports$
|
|
508
|
-
var freeModule$
|
|
509
|
-
var moduleExports$
|
|
510
|
-
var Buffer = moduleExports$
|
|
511
|
-
var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
|
|
698
|
+
var freeExports$2 = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
|
699
|
+
var freeModule$2 = freeExports$2 && typeof module == 'object' && module && !module.nodeType && module;
|
|
700
|
+
var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2;
|
|
701
|
+
var Buffer$1 = moduleExports$2 ? root.Buffer : undefined;
|
|
702
|
+
var nativeIsBuffer = Buffer$1 ? Buffer$1.isBuffer : undefined;
|
|
512
703
|
var isBuffer = nativeIsBuffer || stubFalse;
|
|
513
704
|
|
|
514
705
|
var argsTag = '[object Arguments]',
|
|
@@ -519,7 +710,7 @@ var argsTag = '[object Arguments]',
|
|
|
519
710
|
funcTag = '[object Function]',
|
|
520
711
|
mapTag$2 = '[object Map]',
|
|
521
712
|
numberTag = '[object Number]',
|
|
522
|
-
objectTag$
|
|
713
|
+
objectTag$2 = '[object Object]',
|
|
523
714
|
regexpTag = '[object RegExp]',
|
|
524
715
|
setTag$2 = '[object Set]',
|
|
525
716
|
stringTag = '[object String]',
|
|
@@ -537,7 +728,7 @@ var arrayBufferTag = '[object ArrayBuffer]',
|
|
|
537
728
|
uint32Tag = '[object Uint32Array]';
|
|
538
729
|
var typedArrayTags = {};
|
|
539
730
|
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
|
|
540
|
-
typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag$1] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag$2] = typedArrayTags[numberTag] = typedArrayTags[objectTag$
|
|
731
|
+
typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag$1] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag$2] = typedArrayTags[numberTag] = typedArrayTags[objectTag$2] = typedArrayTags[regexpTag] = typedArrayTags[setTag$2] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag$1] = false;
|
|
541
732
|
function baseIsTypedArray(value) {
|
|
542
733
|
return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
|
|
543
734
|
}
|
|
@@ -548,13 +739,13 @@ function baseUnary(func) {
|
|
|
548
739
|
};
|
|
549
740
|
}
|
|
550
741
|
|
|
551
|
-
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
|
552
|
-
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
|
|
553
|
-
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
554
|
-
var freeProcess = moduleExports && freeGlobal.process;
|
|
742
|
+
var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
|
743
|
+
var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
|
|
744
|
+
var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
|
|
745
|
+
var freeProcess = moduleExports$1 && freeGlobal.process;
|
|
555
746
|
var nodeUtil = function () {
|
|
556
747
|
try {
|
|
557
|
-
var types = freeModule && freeModule.require && freeModule.require('util').types;
|
|
748
|
+
var types = freeModule$1 && freeModule$1.require && freeModule$1.require('util').types;
|
|
558
749
|
if (types) {
|
|
559
750
|
return types;
|
|
560
751
|
}
|
|
@@ -565,8 +756,8 @@ var nodeUtil = function () {
|
|
|
565
756
|
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
|
566
757
|
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
|
|
567
758
|
|
|
568
|
-
var objectProto$
|
|
569
|
-
var hasOwnProperty$
|
|
759
|
+
var objectProto$6 = Object.prototype;
|
|
760
|
+
var hasOwnProperty$6 = objectProto$6.hasOwnProperty;
|
|
570
761
|
function arrayLikeKeys(value, inherited) {
|
|
571
762
|
var isArr = isArray(value),
|
|
572
763
|
isArg = !isArr && isArguments(value),
|
|
@@ -576,7 +767,7 @@ function arrayLikeKeys(value, inherited) {
|
|
|
576
767
|
result = skipIndexes ? baseTimes(value.length, String) : [],
|
|
577
768
|
length = result.length;
|
|
578
769
|
for (var key in value) {
|
|
579
|
-
if ((hasOwnProperty$
|
|
770
|
+
if ((inherited || hasOwnProperty$6.call(value, key)) && !(skipIndexes && (
|
|
580
771
|
key == 'length' ||
|
|
581
772
|
isBuff && (key == 'offset' || key == 'parent') ||
|
|
582
773
|
isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset') ||
|
|
@@ -595,15 +786,15 @@ function overArg(func, transform) {
|
|
|
595
786
|
|
|
596
787
|
var nativeKeys = overArg(Object.keys, Object);
|
|
597
788
|
|
|
598
|
-
var objectProto$
|
|
599
|
-
var hasOwnProperty$
|
|
789
|
+
var objectProto$5 = Object.prototype;
|
|
790
|
+
var hasOwnProperty$5 = objectProto$5.hasOwnProperty;
|
|
600
791
|
function baseKeys(object) {
|
|
601
792
|
if (!isPrototype(object)) {
|
|
602
793
|
return nativeKeys(object);
|
|
603
794
|
}
|
|
604
795
|
var result = [];
|
|
605
796
|
for (var key in Object(object)) {
|
|
606
|
-
if (hasOwnProperty$
|
|
797
|
+
if (hasOwnProperty$5.call(object, key) && key != 'constructor') {
|
|
607
798
|
result.push(key);
|
|
608
799
|
}
|
|
609
800
|
}
|
|
@@ -614,8 +805,297 @@ function keys(object) {
|
|
|
614
805
|
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
|
|
615
806
|
}
|
|
616
807
|
|
|
808
|
+
function nativeKeysIn(object) {
|
|
809
|
+
var result = [];
|
|
810
|
+
if (object != null) {
|
|
811
|
+
for (var key in Object(object)) {
|
|
812
|
+
result.push(key);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
return result;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
var objectProto$4 = Object.prototype;
|
|
819
|
+
var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
|
|
820
|
+
function baseKeysIn(object) {
|
|
821
|
+
if (!isObject$1(object)) {
|
|
822
|
+
return nativeKeysIn(object);
|
|
823
|
+
}
|
|
824
|
+
var isProto = isPrototype(object),
|
|
825
|
+
result = [];
|
|
826
|
+
for (var key in object) {
|
|
827
|
+
if (!(key == 'constructor' && (isProto || !hasOwnProperty$4.call(object, key)))) {
|
|
828
|
+
result.push(key);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
return result;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
function keysIn(object) {
|
|
835
|
+
return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
var nativeCreate = getNative(Object, 'create');
|
|
839
|
+
|
|
840
|
+
function hashClear() {
|
|
841
|
+
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
|
842
|
+
this.size = 0;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
function hashDelete(key) {
|
|
846
|
+
var result = this.has(key) && delete this.__data__[key];
|
|
847
|
+
this.size -= result ? 1 : 0;
|
|
848
|
+
return result;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
|
|
852
|
+
var objectProto$3 = Object.prototype;
|
|
853
|
+
var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
|
|
854
|
+
function hashGet(key) {
|
|
855
|
+
var data = this.__data__;
|
|
856
|
+
if (nativeCreate) {
|
|
857
|
+
var result = data[key];
|
|
858
|
+
return result === HASH_UNDEFINED$1 ? undefined : result;
|
|
859
|
+
}
|
|
860
|
+
return hasOwnProperty$3.call(data, key) ? data[key] : undefined;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
var objectProto$2 = Object.prototype;
|
|
864
|
+
var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
|
|
865
|
+
function hashHas(key) {
|
|
866
|
+
var data = this.__data__;
|
|
867
|
+
return nativeCreate ? data[key] !== undefined : hasOwnProperty$2.call(data, key);
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
|
871
|
+
function hashSet(key, value) {
|
|
872
|
+
var data = this.__data__;
|
|
873
|
+
this.size += this.has(key) ? 0 : 1;
|
|
874
|
+
data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
|
|
875
|
+
return this;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
function Hash(entries) {
|
|
879
|
+
var index = -1,
|
|
880
|
+
length = entries == null ? 0 : entries.length;
|
|
881
|
+
this.clear();
|
|
882
|
+
while (++index < length) {
|
|
883
|
+
var entry = entries[index];
|
|
884
|
+
this.set(entry[0], entry[1]);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
Hash.prototype.clear = hashClear;
|
|
888
|
+
Hash.prototype['delete'] = hashDelete;
|
|
889
|
+
Hash.prototype.get = hashGet;
|
|
890
|
+
Hash.prototype.has = hashHas;
|
|
891
|
+
Hash.prototype.set = hashSet;
|
|
892
|
+
|
|
893
|
+
function listCacheClear() {
|
|
894
|
+
this.__data__ = [];
|
|
895
|
+
this.size = 0;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
function assocIndexOf(array, key) {
|
|
899
|
+
var length = array.length;
|
|
900
|
+
while (length--) {
|
|
901
|
+
if (eq(array[length][0], key)) {
|
|
902
|
+
return length;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
return -1;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
var arrayProto = Array.prototype;
|
|
909
|
+
var splice = arrayProto.splice;
|
|
910
|
+
function listCacheDelete(key) {
|
|
911
|
+
var data = this.__data__,
|
|
912
|
+
index = assocIndexOf(data, key);
|
|
913
|
+
if (index < 0) {
|
|
914
|
+
return false;
|
|
915
|
+
}
|
|
916
|
+
var lastIndex = data.length - 1;
|
|
917
|
+
if (index == lastIndex) {
|
|
918
|
+
data.pop();
|
|
919
|
+
} else {
|
|
920
|
+
splice.call(data, index, 1);
|
|
921
|
+
}
|
|
922
|
+
--this.size;
|
|
923
|
+
return true;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
function listCacheGet(key) {
|
|
927
|
+
var data = this.__data__,
|
|
928
|
+
index = assocIndexOf(data, key);
|
|
929
|
+
return index < 0 ? undefined : data[index][1];
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
function listCacheHas(key) {
|
|
933
|
+
return assocIndexOf(this.__data__, key) > -1;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
function listCacheSet(key, value) {
|
|
937
|
+
var data = this.__data__,
|
|
938
|
+
index = assocIndexOf(data, key);
|
|
939
|
+
if (index < 0) {
|
|
940
|
+
++this.size;
|
|
941
|
+
data.push([key, value]);
|
|
942
|
+
} else {
|
|
943
|
+
data[index][1] = value;
|
|
944
|
+
}
|
|
945
|
+
return this;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
function ListCache(entries) {
|
|
949
|
+
var index = -1,
|
|
950
|
+
length = entries == null ? 0 : entries.length;
|
|
951
|
+
this.clear();
|
|
952
|
+
while (++index < length) {
|
|
953
|
+
var entry = entries[index];
|
|
954
|
+
this.set(entry[0], entry[1]);
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
ListCache.prototype.clear = listCacheClear;
|
|
958
|
+
ListCache.prototype['delete'] = listCacheDelete;
|
|
959
|
+
ListCache.prototype.get = listCacheGet;
|
|
960
|
+
ListCache.prototype.has = listCacheHas;
|
|
961
|
+
ListCache.prototype.set = listCacheSet;
|
|
962
|
+
|
|
617
963
|
var Map$1 = getNative(root, 'Map');
|
|
618
964
|
|
|
965
|
+
function mapCacheClear() {
|
|
966
|
+
this.size = 0;
|
|
967
|
+
this.__data__ = {
|
|
968
|
+
'hash': new Hash(),
|
|
969
|
+
'map': new (Map$1 || ListCache)(),
|
|
970
|
+
'string': new Hash()
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
function isKeyable(value) {
|
|
975
|
+
var type = typeof value;
|
|
976
|
+
return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
function getMapData(map, key) {
|
|
980
|
+
var data = map.__data__;
|
|
981
|
+
return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
function mapCacheDelete(key) {
|
|
985
|
+
var result = getMapData(this, key)['delete'](key);
|
|
986
|
+
this.size -= result ? 1 : 0;
|
|
987
|
+
return result;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
function mapCacheGet(key) {
|
|
991
|
+
return getMapData(this, key).get(key);
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
function mapCacheHas(key) {
|
|
995
|
+
return getMapData(this, key).has(key);
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
function mapCacheSet(key, value) {
|
|
999
|
+
var data = getMapData(this, key),
|
|
1000
|
+
size = data.size;
|
|
1001
|
+
data.set(key, value);
|
|
1002
|
+
this.size += data.size == size ? 0 : 1;
|
|
1003
|
+
return this;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
function MapCache(entries) {
|
|
1007
|
+
var index = -1,
|
|
1008
|
+
length = entries == null ? 0 : entries.length;
|
|
1009
|
+
this.clear();
|
|
1010
|
+
while (++index < length) {
|
|
1011
|
+
var entry = entries[index];
|
|
1012
|
+
this.set(entry[0], entry[1]);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
MapCache.prototype.clear = mapCacheClear;
|
|
1016
|
+
MapCache.prototype['delete'] = mapCacheDelete;
|
|
1017
|
+
MapCache.prototype.get = mapCacheGet;
|
|
1018
|
+
MapCache.prototype.has = mapCacheHas;
|
|
1019
|
+
MapCache.prototype.set = mapCacheSet;
|
|
1020
|
+
|
|
1021
|
+
var getPrototype = overArg(Object.getPrototypeOf, Object);
|
|
1022
|
+
|
|
1023
|
+
var objectTag$1 = '[object Object]';
|
|
1024
|
+
var funcProto = Function.prototype,
|
|
1025
|
+
objectProto$1 = Object.prototype;
|
|
1026
|
+
var funcToString = funcProto.toString;
|
|
1027
|
+
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
|
1028
|
+
var objectCtorString = funcToString.call(Object);
|
|
1029
|
+
function isPlainObject(value) {
|
|
1030
|
+
if (!isObjectLike(value) || baseGetTag(value) != objectTag$1) {
|
|
1031
|
+
return false;
|
|
1032
|
+
}
|
|
1033
|
+
var proto = getPrototype(value);
|
|
1034
|
+
if (proto === null) {
|
|
1035
|
+
return true;
|
|
1036
|
+
}
|
|
1037
|
+
var Ctor = hasOwnProperty$1.call(proto, 'constructor') && proto.constructor;
|
|
1038
|
+
return typeof Ctor == 'function' && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
function stackClear() {
|
|
1042
|
+
this.__data__ = new ListCache();
|
|
1043
|
+
this.size = 0;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
function stackDelete(key) {
|
|
1047
|
+
var data = this.__data__,
|
|
1048
|
+
result = data['delete'](key);
|
|
1049
|
+
this.size = data.size;
|
|
1050
|
+
return result;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
function stackGet(key) {
|
|
1054
|
+
return this.__data__.get(key);
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
function stackHas(key) {
|
|
1058
|
+
return this.__data__.has(key);
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
var LARGE_ARRAY_SIZE = 200;
|
|
1062
|
+
function stackSet(key, value) {
|
|
1063
|
+
var data = this.__data__;
|
|
1064
|
+
if (data instanceof ListCache) {
|
|
1065
|
+
var pairs = data.__data__;
|
|
1066
|
+
if (!Map$1 || pairs.length < LARGE_ARRAY_SIZE - 1) {
|
|
1067
|
+
pairs.push([key, value]);
|
|
1068
|
+
this.size = ++data.size;
|
|
1069
|
+
return this;
|
|
1070
|
+
}
|
|
1071
|
+
data = this.__data__ = new MapCache(pairs);
|
|
1072
|
+
}
|
|
1073
|
+
data.set(key, value);
|
|
1074
|
+
this.size = data.size;
|
|
1075
|
+
return this;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
function Stack(entries) {
|
|
1079
|
+
var data = this.__data__ = new ListCache(entries);
|
|
1080
|
+
this.size = data.size;
|
|
1081
|
+
}
|
|
1082
|
+
Stack.prototype.clear = stackClear;
|
|
1083
|
+
Stack.prototype['delete'] = stackDelete;
|
|
1084
|
+
Stack.prototype.get = stackGet;
|
|
1085
|
+
Stack.prototype.has = stackHas;
|
|
1086
|
+
Stack.prototype.set = stackSet;
|
|
1087
|
+
|
|
1088
|
+
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
|
1089
|
+
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
|
|
1090
|
+
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
1091
|
+
var Buffer = moduleExports ? root.Buffer : undefined;
|
|
1092
|
+
Buffer ? Buffer.allocUnsafe : undefined;
|
|
1093
|
+
function cloneBuffer(buffer, isDeep) {
|
|
1094
|
+
{
|
|
1095
|
+
return buffer.slice();
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
|
|
619
1099
|
var DataView = getNative(root, 'DataView');
|
|
620
1100
|
|
|
621
1101
|
var Promise$1 = getNative(root, 'Promise');
|
|
@@ -657,6 +1137,23 @@ if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map$1
|
|
|
657
1137
|
};
|
|
658
1138
|
}
|
|
659
1139
|
|
|
1140
|
+
var Uint8Array = root.Uint8Array;
|
|
1141
|
+
|
|
1142
|
+
function cloneArrayBuffer(arrayBuffer) {
|
|
1143
|
+
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
|
|
1144
|
+
new Uint8Array(result).set(new Uint8Array(arrayBuffer));
|
|
1145
|
+
return result;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
function cloneTypedArray(typedArray, isDeep) {
|
|
1149
|
+
var buffer = cloneArrayBuffer(typedArray.buffer) ;
|
|
1150
|
+
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
function initCloneObject(object) {
|
|
1154
|
+
return typeof object.constructor == 'function' && !isPrototype(object) ? baseCreate(getPrototype(object)) : {};
|
|
1155
|
+
}
|
|
1156
|
+
|
|
660
1157
|
function createBaseFor(fromRight) {
|
|
661
1158
|
return function (object, iteratee, keysFunc) {
|
|
662
1159
|
var index = -1,
|
|
@@ -723,7 +1220,7 @@ function debounce(func, wait, options) {
|
|
|
723
1220
|
throw new TypeError(FUNC_ERROR_TEXT);
|
|
724
1221
|
}
|
|
725
1222
|
wait = toNumber(wait) || 0;
|
|
726
|
-
if (isObject(options)) {
|
|
1223
|
+
if (isObject$1(options)) {
|
|
727
1224
|
leading = !!options.leading;
|
|
728
1225
|
maxing = 'maxWait' in options;
|
|
729
1226
|
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
@@ -804,6 +1301,96 @@ function debounce(func, wait, options) {
|
|
|
804
1301
|
return debounced;
|
|
805
1302
|
}
|
|
806
1303
|
|
|
1304
|
+
function assignMergeValue(object, key, value) {
|
|
1305
|
+
if (value !== undefined && !eq(object[key], value) || value === undefined && !(key in object)) {
|
|
1306
|
+
baseAssignValue(object, key, value);
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
function isArrayLikeObject(value) {
|
|
1311
|
+
return isObjectLike(value) && isArrayLike(value);
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
function safeGet(object, key) {
|
|
1315
|
+
if (key === 'constructor' && typeof object[key] === 'function') {
|
|
1316
|
+
return;
|
|
1317
|
+
}
|
|
1318
|
+
if (key == '__proto__') {
|
|
1319
|
+
return;
|
|
1320
|
+
}
|
|
1321
|
+
return object[key];
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
function toPlainObject(value) {
|
|
1325
|
+
return copyObject(value, keysIn(value));
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
|
|
1329
|
+
var objValue = safeGet(object, key),
|
|
1330
|
+
srcValue = safeGet(source, key),
|
|
1331
|
+
stacked = stack.get(srcValue);
|
|
1332
|
+
if (stacked) {
|
|
1333
|
+
assignMergeValue(object, key, stacked);
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
var newValue = customizer ? customizer(objValue, srcValue, key + '', object, source, stack) : undefined;
|
|
1337
|
+
var isCommon = newValue === undefined;
|
|
1338
|
+
if (isCommon) {
|
|
1339
|
+
var isArr = isArray(srcValue),
|
|
1340
|
+
isBuff = !isArr && isBuffer(srcValue),
|
|
1341
|
+
isTyped = !isArr && !isBuff && isTypedArray(srcValue);
|
|
1342
|
+
newValue = srcValue;
|
|
1343
|
+
if (isArr || isBuff || isTyped) {
|
|
1344
|
+
if (isArray(objValue)) {
|
|
1345
|
+
newValue = objValue;
|
|
1346
|
+
} else if (isArrayLikeObject(objValue)) {
|
|
1347
|
+
newValue = copyArray(objValue);
|
|
1348
|
+
} else if (isBuff) {
|
|
1349
|
+
isCommon = false;
|
|
1350
|
+
newValue = cloneBuffer(srcValue);
|
|
1351
|
+
} else if (isTyped) {
|
|
1352
|
+
isCommon = false;
|
|
1353
|
+
newValue = cloneTypedArray(srcValue);
|
|
1354
|
+
} else {
|
|
1355
|
+
newValue = [];
|
|
1356
|
+
}
|
|
1357
|
+
} else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
|
1358
|
+
newValue = objValue;
|
|
1359
|
+
if (isArguments(objValue)) {
|
|
1360
|
+
newValue = toPlainObject(objValue);
|
|
1361
|
+
} else if (!isObject$1(objValue) || isFunction(objValue)) {
|
|
1362
|
+
newValue = initCloneObject(srcValue);
|
|
1363
|
+
}
|
|
1364
|
+
} else {
|
|
1365
|
+
isCommon = false;
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
if (isCommon) {
|
|
1369
|
+
stack.set(srcValue, newValue);
|
|
1370
|
+
mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
|
|
1371
|
+
stack['delete'](srcValue);
|
|
1372
|
+
}
|
|
1373
|
+
assignMergeValue(object, key, newValue);
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
function baseMerge(object, source, srcIndex, customizer, stack) {
|
|
1377
|
+
if (object === source) {
|
|
1378
|
+
return;
|
|
1379
|
+
}
|
|
1380
|
+
baseFor(source, function (srcValue, key) {
|
|
1381
|
+
stack || (stack = new Stack());
|
|
1382
|
+
if (isObject$1(srcValue)) {
|
|
1383
|
+
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
|
1384
|
+
} else {
|
|
1385
|
+
var newValue = customizer ? customizer(safeGet(object, key), srcValue, key + '', object, source, stack) : undefined;
|
|
1386
|
+
if (newValue === undefined) {
|
|
1387
|
+
newValue = srcValue;
|
|
1388
|
+
}
|
|
1389
|
+
assignMergeValue(object, key, newValue);
|
|
1390
|
+
}
|
|
1391
|
+
}, keysIn);
|
|
1392
|
+
}
|
|
1393
|
+
|
|
807
1394
|
function castFunction(value) {
|
|
808
1395
|
return typeof value == 'function' ? value : identity;
|
|
809
1396
|
}
|
|
@@ -839,6 +1426,367 @@ function isEmpty(value) {
|
|
|
839
1426
|
return true;
|
|
840
1427
|
}
|
|
841
1428
|
|
|
1429
|
+
var merge = createAssigner(function (object, source, srcIndex) {
|
|
1430
|
+
baseMerge(object, source, srcIndex);
|
|
1431
|
+
});
|
|
1432
|
+
|
|
1433
|
+
let RuntimeDataSourceStatus = /*#__PURE__*/function (RuntimeDataSourceStatus) {
|
|
1434
|
+
RuntimeDataSourceStatus["Initial"] = "init";
|
|
1435
|
+
RuntimeDataSourceStatus["Loading"] = "loading";
|
|
1436
|
+
RuntimeDataSourceStatus["Loaded"] = "loaded";
|
|
1437
|
+
RuntimeDataSourceStatus["Error"] = "error";
|
|
1438
|
+
return RuntimeDataSourceStatus;
|
|
1439
|
+
}({});
|
|
1440
|
+
|
|
1441
|
+
class RuntimeDataSourceItem {
|
|
1442
|
+
_data;
|
|
1443
|
+
_error;
|
|
1444
|
+
_status = RuntimeDataSourceStatus.Initial;
|
|
1445
|
+
_dataSourceConfig;
|
|
1446
|
+
_request;
|
|
1447
|
+
_context;
|
|
1448
|
+
_options;
|
|
1449
|
+
constructor(dataSourceConfig, request, context) {
|
|
1450
|
+
this._dataSourceConfig = dataSourceConfig;
|
|
1451
|
+
this._request = request;
|
|
1452
|
+
this._context = context;
|
|
1453
|
+
}
|
|
1454
|
+
get data() {
|
|
1455
|
+
return this._data;
|
|
1456
|
+
}
|
|
1457
|
+
get error() {
|
|
1458
|
+
return this._error;
|
|
1459
|
+
}
|
|
1460
|
+
get status() {
|
|
1461
|
+
return this._status;
|
|
1462
|
+
}
|
|
1463
|
+
get isLoading() {
|
|
1464
|
+
return this._status === RuntimeDataSourceStatus.Loading;
|
|
1465
|
+
}
|
|
1466
|
+
async load(params) {
|
|
1467
|
+
if (!this._dataSourceConfig) return;
|
|
1468
|
+
if (!this._request) {
|
|
1469
|
+
this._error = new Error(`no ${this._dataSourceConfig.type} handler provide`);
|
|
1470
|
+
this._status = RuntimeDataSourceStatus.Error;
|
|
1471
|
+
throw this._error;
|
|
1472
|
+
}
|
|
1473
|
+
if (this._dataSourceConfig.type === 'urlParams') {
|
|
1474
|
+
const response = await this._request(this._context);
|
|
1475
|
+
this._context.setState({
|
|
1476
|
+
[this._dataSourceConfig.id]: response
|
|
1477
|
+
});
|
|
1478
|
+
this._data = response;
|
|
1479
|
+
this._status = RuntimeDataSourceStatus.Loaded;
|
|
1480
|
+
return response;
|
|
1481
|
+
}
|
|
1482
|
+
if (!this._dataSourceConfig.options) {
|
|
1483
|
+
throw new Error(`${this._dataSourceConfig.id} has no options`);
|
|
1484
|
+
}
|
|
1485
|
+
if (typeof this._dataSourceConfig.options === 'function') {
|
|
1486
|
+
this._options = this._dataSourceConfig.options();
|
|
1487
|
+
}
|
|
1488
|
+
if (!this._options) {
|
|
1489
|
+
throw new Error(`${this._dataSourceConfig.id} options transform error`);
|
|
1490
|
+
}
|
|
1491
|
+
let shouldFetch = true;
|
|
1492
|
+
let fetchOptions = this._options;
|
|
1493
|
+
if (params) {
|
|
1494
|
+
fetchOptions.params = merge(fetchOptions.params, params);
|
|
1495
|
+
}
|
|
1496
|
+
if (this._dataSourceConfig.shouldFetch) {
|
|
1497
|
+
if (typeof this._dataSourceConfig.shouldFetch === 'function') {
|
|
1498
|
+
shouldFetch = this._dataSourceConfig.shouldFetch(fetchOptions);
|
|
1499
|
+
} else if (typeof this._dataSourceConfig.shouldFetch === 'boolean') {
|
|
1500
|
+
shouldFetch = this._dataSourceConfig.shouldFetch;
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
if (!shouldFetch) {
|
|
1504
|
+
this._status = RuntimeDataSourceStatus.Error;
|
|
1505
|
+
this._error = new Error(`the ${this._dataSourceConfig.id} request should not fetch, please check the condition`);
|
|
1506
|
+
console.warn(this.error);
|
|
1507
|
+
return;
|
|
1508
|
+
}
|
|
1509
|
+
if (this._dataSourceConfig.willFetch) {
|
|
1510
|
+
try {
|
|
1511
|
+
fetchOptions = await this._dataSourceConfig.willFetch(this._options);
|
|
1512
|
+
} catch (error) {
|
|
1513
|
+
console.error(error);
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
const dataHandler = this._dataSourceConfig.dataHandler;
|
|
1517
|
+
const {
|
|
1518
|
+
errorHandler
|
|
1519
|
+
} = this._dataSourceConfig;
|
|
1520
|
+
try {
|
|
1521
|
+
this._status = RuntimeDataSourceStatus.Loading;
|
|
1522
|
+
const result = await this._request(fetchOptions, this._context).then(dataHandler, errorHandler);
|
|
1523
|
+
this._data = result;
|
|
1524
|
+
this._status = RuntimeDataSourceStatus.Loaded;
|
|
1525
|
+
this._context.setState({
|
|
1526
|
+
UNSTABLE_dataSourceUpdatedAt: Date.now(),
|
|
1527
|
+
[this._dataSourceConfig.id]: result
|
|
1528
|
+
});
|
|
1529
|
+
return this._data;
|
|
1530
|
+
} catch (error) {
|
|
1531
|
+
this._error = error;
|
|
1532
|
+
this._status = RuntimeDataSourceStatus.Error;
|
|
1533
|
+
this._context.setState({
|
|
1534
|
+
UNSTABLE_dataSourceUpdatedAt: Date.now(),
|
|
1535
|
+
[`UNSTABLE_${this._dataSourceConfig.id}_error`]: error
|
|
1536
|
+
});
|
|
1537
|
+
throw error;
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
const defaultDataHandler = async response => response.data;
|
|
1543
|
+
const defaultWillFetch = options => options;
|
|
1544
|
+
const getRequestHandler = (ds, requestHandlersMap) => {
|
|
1545
|
+
if (ds.type === 'custom') {
|
|
1546
|
+
return ds.requestHandler;
|
|
1547
|
+
}
|
|
1548
|
+
return requestHandlersMap[ds.type || 'fetch'];
|
|
1549
|
+
};
|
|
1550
|
+
const promiseSettled = (Promise.allSettled ? Promise.allSettled.bind(Promise) : null) || (promises => {
|
|
1551
|
+
return Promise.all(promises.map(p => {
|
|
1552
|
+
return p.then(v => ({
|
|
1553
|
+
status: 'fulfilled',
|
|
1554
|
+
value: v
|
|
1555
|
+
})).catch(e => ({
|
|
1556
|
+
status: 'rejected',
|
|
1557
|
+
reason: e
|
|
1558
|
+
}));
|
|
1559
|
+
}));
|
|
1560
|
+
});
|
|
1561
|
+
|
|
1562
|
+
function isObject(obj) {
|
|
1563
|
+
return Object.prototype.toString.call(obj).indexOf('Object') !== -1;
|
|
1564
|
+
}
|
|
1565
|
+
const transformExpression = (code, context) => {
|
|
1566
|
+
if (code === undefined) {
|
|
1567
|
+
return () => {};
|
|
1568
|
+
}
|
|
1569
|
+
if (code === '') {
|
|
1570
|
+
return () => '';
|
|
1571
|
+
}
|
|
1572
|
+
try {
|
|
1573
|
+
return new Function(`return (${code})`).call(context);
|
|
1574
|
+
} catch (error) {
|
|
1575
|
+
console.error(`transformExpression error, code is ${code}, context is ${context}, error is ${error}`);
|
|
1576
|
+
}
|
|
1577
|
+
};
|
|
1578
|
+
const transformFunction = (code, context) => {
|
|
1579
|
+
if (code === undefined) {
|
|
1580
|
+
return () => {};
|
|
1581
|
+
}
|
|
1582
|
+
if (code === '') {
|
|
1583
|
+
return () => '';
|
|
1584
|
+
}
|
|
1585
|
+
try {
|
|
1586
|
+
return new Function(`return (${code})`).call(context).bind(context);
|
|
1587
|
+
} catch (error) {
|
|
1588
|
+
console.error(`transformFunction error, code is ${code}, context is ${context}, error is ${error}`);
|
|
1589
|
+
}
|
|
1590
|
+
};
|
|
1591
|
+
const transformBoolStr = str => {
|
|
1592
|
+
return str !== 'false';
|
|
1593
|
+
};
|
|
1594
|
+
const getRuntimeJsValue = (value, context) => {
|
|
1595
|
+
if (!['JSExpression', 'JSFunction'].includes(value.type)) {
|
|
1596
|
+
console.error(`translate error, value is ${JSON.stringify(value)}`);
|
|
1597
|
+
return '';
|
|
1598
|
+
}
|
|
1599
|
+
const code = value.compiled || value.value;
|
|
1600
|
+
return value.type === 'JSFunction' ? transformFunction(code, context) : transformExpression(code, context);
|
|
1601
|
+
};
|
|
1602
|
+
const getRuntimeBaseValue = (type, value) => {
|
|
1603
|
+
switch (type) {
|
|
1604
|
+
case 'string':
|
|
1605
|
+
return `${value}`;
|
|
1606
|
+
case 'boolean':
|
|
1607
|
+
return typeof value === 'string' ? transformBoolStr(value) : !!value;
|
|
1608
|
+
case 'number':
|
|
1609
|
+
return Number(value);
|
|
1610
|
+
default:
|
|
1611
|
+
return value;
|
|
1612
|
+
}
|
|
1613
|
+
};
|
|
1614
|
+
const getRuntimeValueFromConfig = (type, value, context) => {
|
|
1615
|
+
if (value === undefined) {
|
|
1616
|
+
return undefined;
|
|
1617
|
+
}
|
|
1618
|
+
if (core.isJSExpression(value) || core.isJSFunction(value)) {
|
|
1619
|
+
return getRuntimeBaseValue(type, getRuntimeJsValue(value, context));
|
|
1620
|
+
}
|
|
1621
|
+
return value;
|
|
1622
|
+
};
|
|
1623
|
+
const buildJsonObj = (params, context) => {
|
|
1624
|
+
if (core.isJSExpression(params)) {
|
|
1625
|
+
return transformExpression(params.value, context);
|
|
1626
|
+
} else if (isObject(params)) {
|
|
1627
|
+
const newParams = {};
|
|
1628
|
+
for (const [name, param] of Object.entries(params)) {
|
|
1629
|
+
if (core.isJSExpression(param)) {
|
|
1630
|
+
newParams[name] = transformExpression(param?.value, context);
|
|
1631
|
+
} else if (isObject(param)) {
|
|
1632
|
+
newParams[name] = buildJsonObj(param, context);
|
|
1633
|
+
} else {
|
|
1634
|
+
newParams[name] = param;
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
return newParams;
|
|
1638
|
+
}
|
|
1639
|
+
return params;
|
|
1640
|
+
};
|
|
1641
|
+
const buildShouldFetch = (ds, context) => {
|
|
1642
|
+
if (!ds.options || !ds.shouldFetch) {
|
|
1643
|
+
return true;
|
|
1644
|
+
}
|
|
1645
|
+
if (core.isJSExpression(ds.shouldFetch) || core.isJSFunction(ds.shouldFetch)) {
|
|
1646
|
+
return getRuntimeJsValue(ds.shouldFetch, context);
|
|
1647
|
+
}
|
|
1648
|
+
return getRuntimeBaseValue('boolean', ds.shouldFetch);
|
|
1649
|
+
};
|
|
1650
|
+
const buildOptions = (ds, context) => {
|
|
1651
|
+
const {
|
|
1652
|
+
options
|
|
1653
|
+
} = ds;
|
|
1654
|
+
if (!options) return undefined;
|
|
1655
|
+
return () => {
|
|
1656
|
+
const fetchOptions = {
|
|
1657
|
+
uri: '',
|
|
1658
|
+
params: {},
|
|
1659
|
+
method: 'GET',
|
|
1660
|
+
isCors: true,
|
|
1661
|
+
timeout: 5000,
|
|
1662
|
+
headers: undefined,
|
|
1663
|
+
v: '1.0'
|
|
1664
|
+
};
|
|
1665
|
+
Object.keys(options).forEach(key => {
|
|
1666
|
+
switch (key) {
|
|
1667
|
+
case 'uri':
|
|
1668
|
+
fetchOptions.uri = getRuntimeValueFromConfig('string', options.uri, context);
|
|
1669
|
+
break;
|
|
1670
|
+
case 'params':
|
|
1671
|
+
fetchOptions.params = buildJsonObj(options.params, context);
|
|
1672
|
+
break;
|
|
1673
|
+
case 'method':
|
|
1674
|
+
fetchOptions.method = getRuntimeValueFromConfig('string', options.method, context);
|
|
1675
|
+
break;
|
|
1676
|
+
case 'isCors':
|
|
1677
|
+
fetchOptions.isCors = getRuntimeValueFromConfig('boolean', options.isCors, context);
|
|
1678
|
+
break;
|
|
1679
|
+
case 'timeout':
|
|
1680
|
+
fetchOptions.timeout = getRuntimeValueFromConfig('number', options.timeout, context);
|
|
1681
|
+
break;
|
|
1682
|
+
case 'headers':
|
|
1683
|
+
fetchOptions.headers = buildJsonObj(options.headers, context);
|
|
1684
|
+
break;
|
|
1685
|
+
case 'v':
|
|
1686
|
+
fetchOptions.v = getRuntimeValueFromConfig('string', options.v, context);
|
|
1687
|
+
break;
|
|
1688
|
+
default:
|
|
1689
|
+
fetchOptions[key] = getRuntimeValueFromConfig('unknown', options[key], context);
|
|
1690
|
+
}
|
|
1691
|
+
});
|
|
1692
|
+
return fetchOptions;
|
|
1693
|
+
};
|
|
1694
|
+
};
|
|
1695
|
+
|
|
1696
|
+
const adapt2Runtime = (dataSource, context, extraConfig) => {
|
|
1697
|
+
const {
|
|
1698
|
+
list: interpretConfigList,
|
|
1699
|
+
dataHandler: interpretDataHandler
|
|
1700
|
+
} = dataSource;
|
|
1701
|
+
const dataHandler = interpretDataHandler ? getRuntimeJsValue(interpretDataHandler, context) : undefined;
|
|
1702
|
+
if (!interpretConfigList || !interpretConfigList.length) {
|
|
1703
|
+
return {
|
|
1704
|
+
list: [],
|
|
1705
|
+
dataHandler
|
|
1706
|
+
};
|
|
1707
|
+
}
|
|
1708
|
+
const list = interpretConfigList.map(el => {
|
|
1709
|
+
const {
|
|
1710
|
+
defaultDataHandler: customDataHandler
|
|
1711
|
+
} = extraConfig;
|
|
1712
|
+
const finalDataHandler = customDataHandler || defaultDataHandler;
|
|
1713
|
+
return {
|
|
1714
|
+
id: el.id,
|
|
1715
|
+
isInit: getRuntimeValueFromConfig('boolean', el.isInit, context),
|
|
1716
|
+
isSync: getRuntimeValueFromConfig('boolean', el.isSync, context),
|
|
1717
|
+
type: el.type || 'fetch',
|
|
1718
|
+
willFetch: el.willFetch ? getRuntimeJsValue(el.willFetch, context) : defaultWillFetch,
|
|
1719
|
+
shouldFetch: buildShouldFetch(el, context),
|
|
1720
|
+
dataHandler: el.dataHandler ? getRuntimeJsValue(el.dataHandler, context) : finalDataHandler,
|
|
1721
|
+
errorHandler: el.errorHandler ? getRuntimeJsValue(el.errorHandler, context) : undefined,
|
|
1722
|
+
requestHandler: el.requestHandler ? getRuntimeJsValue(el.requestHandler, context) : undefined,
|
|
1723
|
+
options: buildOptions(el, context)
|
|
1724
|
+
};
|
|
1725
|
+
});
|
|
1726
|
+
return {
|
|
1727
|
+
list,
|
|
1728
|
+
dataHandler
|
|
1729
|
+
};
|
|
1730
|
+
};
|
|
1731
|
+
|
|
1732
|
+
const reloadDataSourceFactory = (dataSource, dataSourceMap, dataHandler) => {
|
|
1733
|
+
return async () => {
|
|
1734
|
+
const allAsyncLoadings = [];
|
|
1735
|
+
dataSource.list.filter(el => el.type === 'urlParams' && isInit(el)).forEach(el => {
|
|
1736
|
+
dataSourceMap[el.id].load();
|
|
1737
|
+
});
|
|
1738
|
+
const remainRuntimeDataSourceList = dataSource.list.filter(el => el.type !== 'urlParams');
|
|
1739
|
+
for (const ds of remainRuntimeDataSourceList) {
|
|
1740
|
+
if (!ds.options) {
|
|
1741
|
+
continue;
|
|
1742
|
+
}
|
|
1743
|
+
if (
|
|
1744
|
+
isInit(ds) && !ds.isSync) {
|
|
1745
|
+
allAsyncLoadings.push(dataSourceMap[ds.id].load());
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
for (const ds of remainRuntimeDataSourceList) {
|
|
1749
|
+
if (!ds.options) {
|
|
1750
|
+
continue;
|
|
1751
|
+
}
|
|
1752
|
+
if (
|
|
1753
|
+
isInit(ds) && ds.isSync) {
|
|
1754
|
+
try {
|
|
1755
|
+
await dataSourceMap[ds.id].load();
|
|
1756
|
+
} catch (e) {
|
|
1757
|
+
console.error(e);
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
await promiseSettled(allAsyncLoadings);
|
|
1762
|
+
if (dataHandler) {
|
|
1763
|
+
dataHandler(dataSourceMap);
|
|
1764
|
+
}
|
|
1765
|
+
};
|
|
1766
|
+
};
|
|
1767
|
+
function isInit(ds) {
|
|
1768
|
+
return typeof ds.isInit === 'function' ? ds.isInit() : ds.isInit ?? true;
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
var createDataSourceEngine = (dataSource, context, extraConfig = {
|
|
1772
|
+
requestHandlersMap: {}
|
|
1773
|
+
}) => {
|
|
1774
|
+
const {
|
|
1775
|
+
requestHandlersMap
|
|
1776
|
+
} = extraConfig;
|
|
1777
|
+
const runtimeDataSource = adapt2Runtime(dataSource, context, {
|
|
1778
|
+
defaultDataHandler: extraConfig.defaultDataHandler
|
|
1779
|
+
});
|
|
1780
|
+
const dataSourceMap = runtimeDataSource.list.reduce((prev, current) => {
|
|
1781
|
+
prev[current.id] = new RuntimeDataSourceItem(current, getRequestHandler(current, requestHandlersMap), context);
|
|
1782
|
+
return prev;
|
|
1783
|
+
}, {});
|
|
1784
|
+
return {
|
|
1785
|
+
dataSourceMap,
|
|
1786
|
+
reloadDataSource: reloadDataSourceFactory(runtimeDataSource, dataSourceMap, runtimeDataSource.dataHandler)
|
|
1787
|
+
};
|
|
1788
|
+
};
|
|
1789
|
+
|
|
842
1790
|
const RendererContext = /*#__PURE__*/react.createContext({});
|
|
843
1791
|
const useRendererContext = () => {
|
|
844
1792
|
try {
|
|
@@ -1045,6 +1993,20 @@ const isReactClass = obj => {
|
|
|
1045
1993
|
function isReactComponent(obj) {
|
|
1046
1994
|
return obj && (isReactClass(obj) || typeof obj === 'function');
|
|
1047
1995
|
}
|
|
1996
|
+
function serializeParams(obj) {
|
|
1997
|
+
const result = [];
|
|
1998
|
+
forEach(obj, (val, key) => {
|
|
1999
|
+
if (val === null || val === undefined || val === '') {
|
|
2000
|
+
return;
|
|
2001
|
+
}
|
|
2002
|
+
if (typeof val === 'object') {
|
|
2003
|
+
result.push(`${key}=${encodeURIComponent(JSON.stringify(val))}`);
|
|
2004
|
+
} else {
|
|
2005
|
+
result.push(`${key}=${encodeURIComponent(val)}`);
|
|
2006
|
+
}
|
|
2007
|
+
});
|
|
2008
|
+
return result.join('&');
|
|
2009
|
+
}
|
|
1048
2010
|
|
|
1049
2011
|
const excludePropertyNames = ['$$typeof', 'render', 'defaultProps', 'props', 'length', 'prototype', 'name', 'caller', 'callee', 'arguments'];
|
|
1050
2012
|
const cloneEnumerableProperty = (target, origin, excludes = excludePropertyNames) => {
|
|
@@ -1609,6 +2571,338 @@ const leafWrapper = (Comp, {
|
|
|
1609
2571
|
return LeafWrapper;
|
|
1610
2572
|
};
|
|
1611
2573
|
|
|
2574
|
+
function buildUrl(dataAPI, params) {
|
|
2575
|
+
const paramStr = serializeParams(params);
|
|
2576
|
+
if (paramStr) {
|
|
2577
|
+
return dataAPI.indexOf('?') > 0 ? `${dataAPI}&${paramStr}` : `${dataAPI}?${paramStr}`;
|
|
2578
|
+
}
|
|
2579
|
+
return dataAPI;
|
|
2580
|
+
}
|
|
2581
|
+
function get(dataAPI, params = {}, headers = {}, otherProps = {}) {
|
|
2582
|
+
const processedHeaders = {
|
|
2583
|
+
Accept: 'application/json',
|
|
2584
|
+
...headers
|
|
2585
|
+
};
|
|
2586
|
+
const url = buildUrl(dataAPI, params);
|
|
2587
|
+
return request(url, 'GET', null, processedHeaders, otherProps);
|
|
2588
|
+
}
|
|
2589
|
+
function post(dataAPI, params = {}, headers = {}, otherProps = {}) {
|
|
2590
|
+
const processedHeaders = {
|
|
2591
|
+
Accept: 'application/json',
|
|
2592
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
2593
|
+
...headers
|
|
2594
|
+
};
|
|
2595
|
+
const body = processedHeaders['Content-Type'].indexOf('application/json') > -1 || Array.isArray(params) ? JSON.stringify(params) : serializeParams(params);
|
|
2596
|
+
return request(dataAPI, 'POST', body, processedHeaders, otherProps);
|
|
2597
|
+
}
|
|
2598
|
+
function request(dataAPI, method = 'GET', data, headers = {}, otherProps = {}) {
|
|
2599
|
+
let processedHeaders = headers || {};
|
|
2600
|
+
let payload = data;
|
|
2601
|
+
if (method === 'PUT' || method === 'DELETE') {
|
|
2602
|
+
processedHeaders = {
|
|
2603
|
+
Accept: 'application/json',
|
|
2604
|
+
'Content-Type': 'application/json',
|
|
2605
|
+
...processedHeaders
|
|
2606
|
+
};
|
|
2607
|
+
payload = JSON.stringify(payload || {});
|
|
2608
|
+
}
|
|
2609
|
+
return new Promise((resolve, reject) => {
|
|
2610
|
+
if (otherProps.timeout) {
|
|
2611
|
+
setTimeout(() => {
|
|
2612
|
+
reject(new Error('timeout'));
|
|
2613
|
+
}, otherProps.timeout);
|
|
2614
|
+
}
|
|
2615
|
+
fetch(dataAPI, {
|
|
2616
|
+
method,
|
|
2617
|
+
credentials: 'include',
|
|
2618
|
+
headers: processedHeaders,
|
|
2619
|
+
body: payload,
|
|
2620
|
+
...otherProps
|
|
2621
|
+
}).then(response => {
|
|
2622
|
+
switch (response.status) {
|
|
2623
|
+
case 200:
|
|
2624
|
+
case 201:
|
|
2625
|
+
case 202:
|
|
2626
|
+
return response.json();
|
|
2627
|
+
case 204:
|
|
2628
|
+
if (method === 'DELETE') {
|
|
2629
|
+
return {
|
|
2630
|
+
success: true
|
|
2631
|
+
};
|
|
2632
|
+
} else {
|
|
2633
|
+
return {
|
|
2634
|
+
__success: false,
|
|
2635
|
+
code: response.status
|
|
2636
|
+
};
|
|
2637
|
+
}
|
|
2638
|
+
case 400:
|
|
2639
|
+
case 401:
|
|
2640
|
+
case 403:
|
|
2641
|
+
case 404:
|
|
2642
|
+
case 406:
|
|
2643
|
+
case 410:
|
|
2644
|
+
case 422:
|
|
2645
|
+
case 500:
|
|
2646
|
+
return response.json().then(res => {
|
|
2647
|
+
return {
|
|
2648
|
+
__success: false,
|
|
2649
|
+
code: response.status,
|
|
2650
|
+
data: res
|
|
2651
|
+
};
|
|
2652
|
+
}).catch(() => {
|
|
2653
|
+
return {
|
|
2654
|
+
__success: false,
|
|
2655
|
+
code: response.status
|
|
2656
|
+
};
|
|
2657
|
+
});
|
|
2658
|
+
}
|
|
2659
|
+
return null;
|
|
2660
|
+
}).then(json => {
|
|
2661
|
+
if (!json) {
|
|
2662
|
+
reject(json);
|
|
2663
|
+
return;
|
|
2664
|
+
}
|
|
2665
|
+
if (json.__success !== false) {
|
|
2666
|
+
resolve(json);
|
|
2667
|
+
} else {
|
|
2668
|
+
delete json.__success;
|
|
2669
|
+
reject(json);
|
|
2670
|
+
}
|
|
2671
|
+
}).catch(err => {
|
|
2672
|
+
reject(err);
|
|
2673
|
+
});
|
|
2674
|
+
});
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2677
|
+
const DS_STATUS = {
|
|
2678
|
+
INIT: 'init',
|
|
2679
|
+
LOADING: 'loading',
|
|
2680
|
+
LOADED: 'loaded',
|
|
2681
|
+
ERROR: 'error'
|
|
2682
|
+
};
|
|
2683
|
+
function doRequest(type, options) {
|
|
2684
|
+
let {
|
|
2685
|
+
uri,
|
|
2686
|
+
url,
|
|
2687
|
+
method = 'GET',
|
|
2688
|
+
headers,
|
|
2689
|
+
params,
|
|
2690
|
+
...otherProps
|
|
2691
|
+
} = options;
|
|
2692
|
+
otherProps = otherProps || {};
|
|
2693
|
+
if (type === 'fetch') {
|
|
2694
|
+
switch (method.toUpperCase()) {
|
|
2695
|
+
case 'GET':
|
|
2696
|
+
return get(uri, params, headers, otherProps);
|
|
2697
|
+
case 'POST':
|
|
2698
|
+
return post(uri, params, headers, otherProps);
|
|
2699
|
+
default:
|
|
2700
|
+
return request(uri, method, params, headers, otherProps);
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2703
|
+
logger.log(`Engine default dataSource does not support type:[${type}] dataSource request!`, options);
|
|
2704
|
+
}
|
|
2705
|
+
class DataHelper {
|
|
2706
|
+
host;
|
|
2707
|
+
config;
|
|
2708
|
+
parser;
|
|
2709
|
+
ajaxList;
|
|
2710
|
+
dataHandler;
|
|
2711
|
+
ajaxMap;
|
|
2712
|
+
dataSourceMap;
|
|
2713
|
+
appHelper;
|
|
2714
|
+
constructor(comp, config, appHelper, parser) {
|
|
2715
|
+
this.host = comp;
|
|
2716
|
+
this.config = config || {};
|
|
2717
|
+
this.parser = parser;
|
|
2718
|
+
this.ajaxList = config?.list || [];
|
|
2719
|
+
this.ajaxMap = transformArrayToMap(this.ajaxList, 'id');
|
|
2720
|
+
this.dataSourceMap = this.generateDataSourceMap();
|
|
2721
|
+
this.appHelper = appHelper;
|
|
2722
|
+
this.dataHandler = config?.dataHandler ? parseExpression(config?.dataHandler, comp, true) : undefined;
|
|
2723
|
+
}
|
|
2724
|
+
updateConfig(config = {}) {
|
|
2725
|
+
this.config = config;
|
|
2726
|
+
this.ajaxList = config?.list || [];
|
|
2727
|
+
const ajaxMap = transformArrayToMap(this.ajaxList, 'id');
|
|
2728
|
+
Object.keys(this.ajaxMap).forEach(key => {
|
|
2729
|
+
if (!ajaxMap[key]) {
|
|
2730
|
+
delete this.dataSourceMap[key];
|
|
2731
|
+
}
|
|
2732
|
+
});
|
|
2733
|
+
this.ajaxMap = ajaxMap;
|
|
2734
|
+
this.ajaxList.forEach(item => {
|
|
2735
|
+
if (!this.dataSourceMap[item.id]) {
|
|
2736
|
+
this.dataSourceMap[item.id] = {
|
|
2737
|
+
status: DS_STATUS.INIT,
|
|
2738
|
+
load: (...args) => {
|
|
2739
|
+
return this.getDataSource(item.id, ...args);
|
|
2740
|
+
}
|
|
2741
|
+
};
|
|
2742
|
+
}
|
|
2743
|
+
});
|
|
2744
|
+
return this.dataSourceMap;
|
|
2745
|
+
}
|
|
2746
|
+
generateDataSourceMap() {
|
|
2747
|
+
const res = {};
|
|
2748
|
+
this.ajaxList.forEach(item => {
|
|
2749
|
+
res[item.id] = {
|
|
2750
|
+
status: DS_STATUS.INIT,
|
|
2751
|
+
load: (...args) => {
|
|
2752
|
+
return this.getDataSource(item.id, ...args);
|
|
2753
|
+
}
|
|
2754
|
+
};
|
|
2755
|
+
});
|
|
2756
|
+
return res;
|
|
2757
|
+
}
|
|
2758
|
+
updateDataSourceMap(id, data, error) {
|
|
2759
|
+
this.dataSourceMap[id].error = error || undefined;
|
|
2760
|
+
this.dataSourceMap[id].data = data;
|
|
2761
|
+
this.dataSourceMap[id].status = error ? DS_STATUS.ERROR : DS_STATUS.LOADED;
|
|
2762
|
+
}
|
|
2763
|
+
getInitDataSourseConfigs() {
|
|
2764
|
+
const initConfigs = this.parser(this.ajaxList).filter(item => {
|
|
2765
|
+
if (item.isInit === true) {
|
|
2766
|
+
this.dataSourceMap[item.id].status = DS_STATUS.LOADING;
|
|
2767
|
+
return true;
|
|
2768
|
+
}
|
|
2769
|
+
return false;
|
|
2770
|
+
});
|
|
2771
|
+
return initConfigs;
|
|
2772
|
+
}
|
|
2773
|
+
getInitData() {
|
|
2774
|
+
const initSyncData = this.getInitDataSourseConfigs();
|
|
2775
|
+
return this.asyncDataHandler(initSyncData).then(res => {
|
|
2776
|
+
const {
|
|
2777
|
+
dataHandler
|
|
2778
|
+
} = this.config;
|
|
2779
|
+
return this.handleData(null, dataHandler, res, null);
|
|
2780
|
+
});
|
|
2781
|
+
}
|
|
2782
|
+
async reloadDataSource() {
|
|
2783
|
+
const dataSourceMap = await this.getInitData();
|
|
2784
|
+
if (isEmpty(dataSourceMap)) {
|
|
2785
|
+
return;
|
|
2786
|
+
}
|
|
2787
|
+
this.host.setState(dataSourceMap);
|
|
2788
|
+
if (this.dataHandler) {
|
|
2789
|
+
this.dataHandler(dataSourceMap);
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
getDataSource(id, params, otherOptions, callback) {
|
|
2793
|
+
const req = this.parser(this.ajaxMap[id]);
|
|
2794
|
+
const options = req.options || {};
|
|
2795
|
+
let callbackFn = callback;
|
|
2796
|
+
let otherOptionsObj = otherOptions;
|
|
2797
|
+
if (typeof otherOptions === 'function') {
|
|
2798
|
+
callbackFn = otherOptions;
|
|
2799
|
+
otherOptionsObj = {};
|
|
2800
|
+
}
|
|
2801
|
+
const {
|
|
2802
|
+
headers,
|
|
2803
|
+
...otherProps
|
|
2804
|
+
} = otherOptionsObj || {};
|
|
2805
|
+
if (!req) {
|
|
2806
|
+
logger.warn(`getDataSource API named ${id} not exist`);
|
|
2807
|
+
return;
|
|
2808
|
+
}
|
|
2809
|
+
return this.asyncDataHandler([{
|
|
2810
|
+
...req,
|
|
2811
|
+
options: {
|
|
2812
|
+
...options,
|
|
2813
|
+
params: Array.isArray(options.params) || Array.isArray(params) ? params || options.params : {
|
|
2814
|
+
...options.params,
|
|
2815
|
+
...params
|
|
2816
|
+
},
|
|
2817
|
+
headers: {
|
|
2818
|
+
...options.headers,
|
|
2819
|
+
...headers
|
|
2820
|
+
},
|
|
2821
|
+
...otherProps
|
|
2822
|
+
}
|
|
2823
|
+
}]).then(res => {
|
|
2824
|
+
try {
|
|
2825
|
+
callbackFn && callbackFn(res && res[id]);
|
|
2826
|
+
} catch (e) {
|
|
2827
|
+
logger.error('load请求回调函数报错', e);
|
|
2828
|
+
}
|
|
2829
|
+
return res && res[id];
|
|
2830
|
+
}).catch(err => {
|
|
2831
|
+
try {
|
|
2832
|
+
callbackFn && callbackFn(null, err);
|
|
2833
|
+
} catch (e) {
|
|
2834
|
+
logger.error('load请求回调函数报错', e);
|
|
2835
|
+
}
|
|
2836
|
+
return err;
|
|
2837
|
+
});
|
|
2838
|
+
}
|
|
2839
|
+
asyncDataHandler(asyncDataList) {
|
|
2840
|
+
return new Promise((resolve, reject) => {
|
|
2841
|
+
const allReq = [];
|
|
2842
|
+
asyncDataList.forEach(req => {
|
|
2843
|
+
const {
|
|
2844
|
+
id,
|
|
2845
|
+
type
|
|
2846
|
+
} = req;
|
|
2847
|
+
if (!id || !type || type === 'legao') {
|
|
2848
|
+
return;
|
|
2849
|
+
}
|
|
2850
|
+
allReq.push(req);
|
|
2851
|
+
});
|
|
2852
|
+
if (allReq.length === 0) {
|
|
2853
|
+
resolve({});
|
|
2854
|
+
}
|
|
2855
|
+
const res = {};
|
|
2856
|
+
Promise.all(allReq.map(item => {
|
|
2857
|
+
return new Promise(innerResolve => {
|
|
2858
|
+
const {
|
|
2859
|
+
type,
|
|
2860
|
+
id,
|
|
2861
|
+
dataHandler,
|
|
2862
|
+
options
|
|
2863
|
+
} = item;
|
|
2864
|
+
const fetchHandler = (data, error) => {
|
|
2865
|
+
res[id] = this.handleData(id, dataHandler, data, error);
|
|
2866
|
+
this.updateDataSourceMap(id, res[id], error);
|
|
2867
|
+
innerResolve({});
|
|
2868
|
+
};
|
|
2869
|
+
const doFetch = (innerType, innerOptions) => {
|
|
2870
|
+
doRequest(innerType, innerOptions)?.then(data => {
|
|
2871
|
+
fetchHandler(data, undefined);
|
|
2872
|
+
}).catch(err => {
|
|
2873
|
+
fetchHandler(undefined, err);
|
|
2874
|
+
});
|
|
2875
|
+
};
|
|
2876
|
+
this.dataSourceMap[id].status = DS_STATUS.LOADING;
|
|
2877
|
+
doFetch(type, options);
|
|
2878
|
+
});
|
|
2879
|
+
})).then(() => {
|
|
2880
|
+
resolve(res);
|
|
2881
|
+
}).catch(e => {
|
|
2882
|
+
reject(e);
|
|
2883
|
+
});
|
|
2884
|
+
});
|
|
2885
|
+
}
|
|
2886
|
+
handleData(id, dataHandler, data, error) {
|
|
2887
|
+
let dataHandlerFun = dataHandler;
|
|
2888
|
+
if (core.isJSFunction(dataHandler)) {
|
|
2889
|
+
dataHandlerFun = transformStringToFunction(dataHandler.value);
|
|
2890
|
+
}
|
|
2891
|
+
if (!dataHandlerFun || typeof dataHandlerFun !== 'function') {
|
|
2892
|
+
return data;
|
|
2893
|
+
}
|
|
2894
|
+
try {
|
|
2895
|
+
return dataHandlerFun.call(this.host, data, error);
|
|
2896
|
+
} catch (e) {
|
|
2897
|
+
if (id) {
|
|
2898
|
+
logger.error(`[${id}]单个请求数据处理函数运行出错`, e);
|
|
2899
|
+
} else {
|
|
2900
|
+
logger.error('请求数据处理函数运行出错', e);
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2905
|
+
|
|
1612
2906
|
function executeLifeCycleMethod(context, schema, method, args) {
|
|
1613
2907
|
if (!context || !isSchema(schema) || !method) {
|
|
1614
2908
|
return;
|
|
@@ -1834,60 +3128,44 @@ function baseRendererFactory() {
|
|
|
1834
3128
|
if (!props) {
|
|
1835
3129
|
return;
|
|
1836
3130
|
}
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
//
|
|
1843
|
-
//
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
// if (!this.__dataHelper) {
|
|
1876
|
-
// return resolve({})
|
|
1877
|
-
// }
|
|
1878
|
-
// this.__dataHelper
|
|
1879
|
-
// .getInitData()
|
|
1880
|
-
// .then((res: any) => {
|
|
1881
|
-
// if (isEmpty(res)) {
|
|
1882
|
-
// return resolve({})
|
|
1883
|
-
// }
|
|
1884
|
-
// this.setState(res, resolve as () => void)
|
|
1885
|
-
// })
|
|
1886
|
-
// .catch((err: Error) => {
|
|
1887
|
-
// reject(err)
|
|
1888
|
-
// })
|
|
1889
|
-
// })
|
|
1890
|
-
// }
|
|
3131
|
+
const schema = props.__schema || {};
|
|
3132
|
+
const defaultDataSource = {
|
|
3133
|
+
list: []
|
|
3134
|
+
};
|
|
3135
|
+
const dataSource = schema.dataSource || defaultDataSource;
|
|
3136
|
+
// requestHandlersMap 存在才走数据源引擎方案
|
|
3137
|
+
// TODO: 下面if else 抽成独立函数
|
|
3138
|
+
const useDataSourceEngine = !!props.__appHelper?.requestHandlersMap;
|
|
3139
|
+
if (useDataSourceEngine) {
|
|
3140
|
+
this.__dataHelper = {
|
|
3141
|
+
updateConfig: updateDataSource => {
|
|
3142
|
+
const {
|
|
3143
|
+
dataSourceMap,
|
|
3144
|
+
reloadDataSource
|
|
3145
|
+
} = createDataSourceEngine(updateDataSource ?? {}, this, props.__appHelper?.requestHandlersMap ? {
|
|
3146
|
+
requestHandlersMap: props.__appHelper.requestHandlersMap
|
|
3147
|
+
} : undefined);
|
|
3148
|
+
this.reloadDataSource = () => new Promise(resolve => {
|
|
3149
|
+
logger.log('reload data source');
|
|
3150
|
+
reloadDataSource().then(() => {
|
|
3151
|
+
resolve({});
|
|
3152
|
+
});
|
|
3153
|
+
});
|
|
3154
|
+
return dataSourceMap;
|
|
3155
|
+
}
|
|
3156
|
+
};
|
|
3157
|
+
this.dataSourceMap = this.__dataHelper.updateConfig(dataSource);
|
|
3158
|
+
} else {
|
|
3159
|
+
const appHelper = props.__appHelper || {};
|
|
3160
|
+
this.__dataHelper = new DataHelper(this, dataSource, appHelper, config => this.__parseData(config));
|
|
3161
|
+
this.dataSourceMap = this.__dataHelper.dataSourceMap;
|
|
3162
|
+
this.reloadDataSource = () => new Promise(resolve => {
|
|
3163
|
+
logger.log('reload data source');
|
|
3164
|
+
this.__dataHelper.reloadDataSource().then(() => {
|
|
3165
|
+
resolve({});
|
|
3166
|
+
});
|
|
3167
|
+
});
|
|
3168
|
+
}
|
|
1891
3169
|
};
|
|
1892
3170
|
|
|
1893
3171
|
/**
|
|
@@ -2728,6 +4006,7 @@ exports.parseData = parseData;
|
|
|
2728
4006
|
exports.parseExpression = parseExpression;
|
|
2729
4007
|
exports.parseThisRequiredExpression = parseThisRequiredExpression;
|
|
2730
4008
|
exports.rendererFactory = rendererFactory;
|
|
4009
|
+
exports.serializeParams = serializeParams;
|
|
2731
4010
|
exports.transformArrayToMap = transformArrayToMap;
|
|
2732
4011
|
exports.transformStringToFunction = transformStringToFunction;
|
|
2733
4012
|
exports.useRendererContext = useRendererContext;
|