@next-core/brick-kit 2.118.3 → 2.118.4
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/CHANGELOG.md +11 -0
- package/dist/index.bundle.js +255 -256
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +256 -257
- package/dist/index.esm.js.map +1 -1
- package/dist/types/BrickAsComponent.d.ts +0 -2
- package/dist/types/BrickAsComponent.d.ts.map +1 -1
- package/dist/types/core/CustomTemplates/constants.d.ts +2 -1
- package/dist/types/core/CustomTemplates/constants.d.ts.map +1 -1
- package/dist/types/core/CustomTemplates/expandCustomTemplate.d.ts +18 -1
- package/dist/types/core/CustomTemplates/expandCustomTemplate.d.ts.map +1 -1
- package/dist/types/core/CustomTemplates/setupTemplateProxy.d.ts +5 -0
- package/dist/types/core/CustomTemplates/setupTemplateProxy.d.ts.map +1 -0
- package/dist/types/core/CustomTemplates/setupUseBrickInTemplate.d.ts +2 -1
- package/dist/types/core/CustomTemplates/setupUseBrickInTemplate.d.ts.map +1 -1
- package/dist/types/internal/setProperties.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.esm.js
CHANGED
|
@@ -5,7 +5,7 @@ import _asyncToGenerator$4 from '@babel/runtime/helpers/asyncToGenerator';
|
|
|
5
5
|
import _defineProperty$1 from '@babel/runtime/helpers/defineProperty';
|
|
6
6
|
import React, { useState, useEffect, useRef, forwardRef, useImperativeHandle, useMemo, useContext, createContext, useReducer, useCallback } from 'react';
|
|
7
7
|
import { JsonStorage, toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable, transformAndInject, transform, trackContext, trackState, scanPermissionActionsInStoryboard, precookFunction, cook, resolveContextConcurrently, syncResolveContextConcurrently, shouldAllowRecursiveEvaluations, preevaluate, inject, deepFreeze, createProviderClass, loadScript, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, getDllAndDepsByResource, scanRouteAliasInStoryboard, prefetchScript, scanBricksInBrickConf, scanProcessorsInAny, matchPath, scanAppGetMenuInAny, asyncProcessBrick, restoreDynamicTemplates, mapCustomApisToNameAndNamespace, scanCustomApisInStoryboard } from '@next-core/brick-utils';
|
|
8
|
-
import lodash, { set, get, difference, identity, uniqueId, cloneDeep, isNil, sortBy, merge, pick, orderBy, omit, findLastIndex,
|
|
8
|
+
import lodash, { set, get, difference, identity, uniqueId, cloneDeep, clamp, isNil, sortBy, merge, pick, orderBy, omit, findLastIndex, noop, isObject as isObject$1, isString } from 'lodash';
|
|
9
9
|
import { http, HttpResponseError, HttpFetchError } from '@next-core/brick-http';
|
|
10
10
|
import moment from 'moment';
|
|
11
11
|
import { pipes } from '@next-core/pipes';
|
|
@@ -2540,13 +2540,224 @@ function evaluate(raw) {
|
|
|
2540
2540
|
}
|
|
2541
2541
|
}
|
|
2542
2542
|
|
|
2543
|
+
function isBasicProperty(propRef) {
|
|
2544
|
+
return !!propRef.refProperty;
|
|
2545
|
+
}
|
|
2546
|
+
function isTransformableProperty(propRef) {
|
|
2547
|
+
return !!propRef.refTransform;
|
|
2548
|
+
}
|
|
2549
|
+
function isMergeableProperty(propRef) {
|
|
2550
|
+
return !!propRef.mergeProperty;
|
|
2551
|
+
}
|
|
2552
|
+
function isRefProperty(propRef) {
|
|
2553
|
+
return !!propRef.ref;
|
|
2554
|
+
}
|
|
2555
|
+
function isVariableProperty(propRef) {
|
|
2556
|
+
return !!propRef.asVariable;
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2543
2559
|
var customTemplateRegistry = new Map();
|
|
2544
2560
|
var appRegistered = new Set();
|
|
2545
2561
|
var symbolForComputedPropsFromProxy = Symbol.for("tpl.computedPropsFromProxy");
|
|
2546
2562
|
var symbolForRefForProxy = Symbol.for("tpl.refForProxy");
|
|
2547
2563
|
var symbolForTplContextId = Symbol.for("tpl.contextId");
|
|
2548
2564
|
|
|
2549
|
-
function
|
|
2565
|
+
function propertyMerge(conf, value, object) {
|
|
2566
|
+
return propertyMergeAll(conf.$$mergeBase, Object.fromEntries(conf.$$mergeBase.proxies.map(proxy => [proxy.$$reversedRef, proxy === conf ? value : object[proxy.$$reversedRef]])));
|
|
2567
|
+
}
|
|
2568
|
+
function propertyMergeAll(mergeBase, object) {
|
|
2569
|
+
if (mergeBase.mergeType === "array") {
|
|
2570
|
+
return propertyMergeAllOfArray(mergeBase, object);
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2573
|
+
if (mergeBase.mergeType === "object") {
|
|
2574
|
+
return propertyMergeAllOfObject(mergeBase, object);
|
|
2575
|
+
} // istanbul ignore next: should never reach
|
|
2576
|
+
|
|
2577
|
+
|
|
2578
|
+
throw new TypeError("unsupported mergeType: \"".concat(mergeBase.mergeType, "\""));
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2581
|
+
function propertyMergeAllOfArray(_ref, object) {
|
|
2582
|
+
var _, _proxy$mergeArgs;
|
|
2583
|
+
|
|
2584
|
+
var {
|
|
2585
|
+
baseValue,
|
|
2586
|
+
context,
|
|
2587
|
+
proxies
|
|
2588
|
+
} = _ref;
|
|
2589
|
+
// Use an approach like template-literal's quasis:
|
|
2590
|
+
// `quasi0${0}quais1${1}quasi2...`
|
|
2591
|
+
// Every quasi can be merged with multiple items.
|
|
2592
|
+
var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true, {
|
|
2593
|
+
$$lazyForUseBrick: true
|
|
2594
|
+
}) : [];
|
|
2595
|
+
var quasis = [];
|
|
2596
|
+
var size = computedBaseValue.length + 1;
|
|
2597
|
+
|
|
2598
|
+
for (var i = 0; i < size; i += 1) {
|
|
2599
|
+
quasis.push([]);
|
|
2600
|
+
}
|
|
2601
|
+
|
|
2602
|
+
for (var proxy of proxies) {
|
|
2603
|
+
var position = void 0;
|
|
2604
|
+
|
|
2605
|
+
switch (proxy.mergeMethod) {
|
|
2606
|
+
case "append":
|
|
2607
|
+
position = computedBaseValue.length;
|
|
2608
|
+
break;
|
|
2609
|
+
|
|
2610
|
+
case "prepend":
|
|
2611
|
+
position = 0;
|
|
2612
|
+
break;
|
|
2613
|
+
|
|
2614
|
+
case "insertAt":
|
|
2615
|
+
// Defaults to `-1`.
|
|
2616
|
+
position = (_ = (_proxy$mergeArgs = proxy.mergeArgs) === null || _proxy$mergeArgs === void 0 ? void 0 : _proxy$mergeArgs[0]) !== null && _ !== void 0 ? _ : -1;
|
|
2617
|
+
|
|
2618
|
+
if (position < 0) {
|
|
2619
|
+
// It's counted from the end if position is negative.
|
|
2620
|
+
position += quasis.length;
|
|
2621
|
+
}
|
|
2622
|
+
|
|
2623
|
+
position = clamp(position, 0, computedBaseValue.length);
|
|
2624
|
+
break;
|
|
2625
|
+
// istanbul ignore next: should never reach
|
|
2626
|
+
|
|
2627
|
+
default:
|
|
2628
|
+
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
2629
|
+
}
|
|
2630
|
+
|
|
2631
|
+
var patchValue = object[proxy.$$reversedRef];
|
|
2632
|
+
|
|
2633
|
+
if (!Array.isArray(patchValue)) {
|
|
2634
|
+
patchValue = [];
|
|
2635
|
+
}
|
|
2636
|
+
|
|
2637
|
+
quasis[position].push(...patchValue);
|
|
2638
|
+
}
|
|
2639
|
+
|
|
2640
|
+
return quasis.flatMap((item, index) => index < computedBaseValue.length ? item.concat(computedBaseValue[index]) : item);
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2643
|
+
function propertyMergeAllOfObject(_ref2, object) {
|
|
2644
|
+
var {
|
|
2645
|
+
baseValue,
|
|
2646
|
+
proxies,
|
|
2647
|
+
context
|
|
2648
|
+
} = _ref2;
|
|
2649
|
+
var computedBaseValue = isObject(baseValue) ? computeRealValue(baseValue, context, true) : {};
|
|
2650
|
+
return proxies.reduce((acc, proxy) => {
|
|
2651
|
+
switch (proxy.mergeMethod) {
|
|
2652
|
+
case "extend":
|
|
2653
|
+
return _objectSpread(_objectSpread({}, acc), object[proxy.$$reversedRef]);
|
|
2654
|
+
// istanbul ignore next: should never reach
|
|
2655
|
+
|
|
2656
|
+
default:
|
|
2657
|
+
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
2658
|
+
}
|
|
2659
|
+
}, computedBaseValue);
|
|
2660
|
+
}
|
|
2661
|
+
|
|
2662
|
+
function setupTemplateProxy(proxyContext, ref, slots) {
|
|
2663
|
+
var computedPropsFromProxy = {};
|
|
2664
|
+
var refForProxy;
|
|
2665
|
+
var {
|
|
2666
|
+
reversedProxies,
|
|
2667
|
+
templateProperties,
|
|
2668
|
+
externalSlots,
|
|
2669
|
+
templateContextId,
|
|
2670
|
+
proxyBrick
|
|
2671
|
+
} = proxyContext;
|
|
2672
|
+
|
|
2673
|
+
if (ref && reversedProxies) {
|
|
2674
|
+
refForProxy = {};
|
|
2675
|
+
proxyBrick.proxyRefs.set(ref, refForProxy); // Reversed proxies are used for expand storyboard before rendering page.
|
|
2676
|
+
|
|
2677
|
+
if (reversedProxies.properties.has(ref)) {
|
|
2678
|
+
Object.assign(computedPropsFromProxy, Object.fromEntries(reversedProxies.properties.get(ref).flatMap(propRef => {
|
|
2679
|
+
// `propValue` is computed.
|
|
2680
|
+
var propValue = templateProperties === null || templateProperties === void 0 ? void 0 : templateProperties[propRef.$$reversedRef];
|
|
2681
|
+
|
|
2682
|
+
if (isTransformableProperty(propRef)) {
|
|
2683
|
+
return Object.entries(preprocessTransformProperties({
|
|
2684
|
+
[propRef.$$reversedRef]: propValue
|
|
2685
|
+
}, propRef.refTransform));
|
|
2686
|
+
}
|
|
2687
|
+
|
|
2688
|
+
if (isBasicProperty(propRef)) {
|
|
2689
|
+
return [[propRef.refProperty, propValue]];
|
|
2690
|
+
} // Ignore Variable properties.
|
|
2691
|
+
// And mergeable properties are processed later.
|
|
2692
|
+
|
|
2693
|
+
|
|
2694
|
+
return [];
|
|
2695
|
+
}).filter(propRef => propRef[1] !== undefined))); // Brick properties can be merged multiple times.
|
|
2696
|
+
|
|
2697
|
+
if (reversedProxies.mergeBases.has(ref)) {
|
|
2698
|
+
Object.assign(computedPropsFromProxy, Object.fromEntries(Array.from(reversedProxies.mergeBases.get(ref).entries()).map(_ref => {
|
|
2699
|
+
var [mergeProperty, mergeBase] = _ref;
|
|
2700
|
+
return [mergeProperty, propertyMergeAll(mergeBase, templateProperties !== null && templateProperties !== void 0 ? templateProperties : {})];
|
|
2701
|
+
}).filter(item => item[1] !== undefined)));
|
|
2702
|
+
}
|
|
2703
|
+
} // Use an approach like template-literal's quasis:
|
|
2704
|
+
// `quasi0${0}quais1${1}quasi2...`
|
|
2705
|
+
// Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.
|
|
2706
|
+
|
|
2707
|
+
|
|
2708
|
+
var quasisMap = new Map();
|
|
2709
|
+
|
|
2710
|
+
if (reversedProxies.slots.has(ref)) {
|
|
2711
|
+
for (var item of reversedProxies.slots.get(ref)) {
|
|
2712
|
+
var _item$refPosition, _externalSlots$item$$, _externalSlots$item$$2;
|
|
2713
|
+
|
|
2714
|
+
if (!quasisMap.has(item.refSlot)) {
|
|
2715
|
+
var quasis = []; // The size of quasis should be the existed slotted bricks' size plus one.
|
|
2716
|
+
|
|
2717
|
+
var size = hasOwnProperty(slots, item.refSlot) ? slots[item.refSlot].bricks.length + 1 : 1;
|
|
2718
|
+
|
|
2719
|
+
for (var i = 0; i < size; i += 1) {
|
|
2720
|
+
quasis.push([]);
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2723
|
+
quasisMap.set(item.refSlot, quasis);
|
|
2724
|
+
}
|
|
2725
|
+
|
|
2726
|
+
var expandableSlot = quasisMap.get(item.refSlot);
|
|
2727
|
+
var refPosition = (_item$refPosition = item.refPosition) !== null && _item$refPosition !== void 0 ? _item$refPosition : -1;
|
|
2728
|
+
expandableSlot[clamp(refPosition < 0 ? expandableSlot.length + refPosition : refPosition, 0, expandableSlot.length - 1)].push(...((_externalSlots$item$$ = externalSlots === null || externalSlots === void 0 ? void 0 : (_externalSlots$item$$2 = externalSlots[item.$$reversedRef]) === null || _externalSlots$item$$2 === void 0 ? void 0 : _externalSlots$item$$2.bricks) !== null && _externalSlots$item$$ !== void 0 ? _externalSlots$item$$ : []));
|
|
2729
|
+
}
|
|
2730
|
+
}
|
|
2731
|
+
|
|
2732
|
+
var _loop = function (slotName, _quasis) {
|
|
2733
|
+
if (!hasOwnProperty(slots, slotName)) {
|
|
2734
|
+
slots[slotName] = {
|
|
2735
|
+
type: "bricks",
|
|
2736
|
+
bricks: []
|
|
2737
|
+
};
|
|
2738
|
+
}
|
|
2739
|
+
|
|
2740
|
+
var slotConf = slots[slotName];
|
|
2741
|
+
slotConf.bricks = _quasis.flatMap((bricks, index) => index < slotConf.bricks.length ? bricks.concat(slotConf.bricks[index]) : bricks);
|
|
2742
|
+
|
|
2743
|
+
if (slotConf.bricks.length === 0) {
|
|
2744
|
+
delete slots[slotName];
|
|
2745
|
+
}
|
|
2746
|
+
};
|
|
2747
|
+
|
|
2748
|
+
for (var [slotName, _quasis] of quasisMap.entries()) {
|
|
2749
|
+
_loop(slotName, _quasis);
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
|
|
2753
|
+
return {
|
|
2754
|
+
[symbolForComputedPropsFromProxy]: computedPropsFromProxy,
|
|
2755
|
+
[symbolForRefForProxy]: refForProxy,
|
|
2756
|
+
[symbolForTplContextId]: templateContextId
|
|
2757
|
+
};
|
|
2758
|
+
}
|
|
2759
|
+
|
|
2760
|
+
function setupUseBrickInTemplate(props, proxyContext) {
|
|
2550
2761
|
function walk(props) {
|
|
2551
2762
|
if (!props) {
|
|
2552
2763
|
return;
|
|
@@ -2568,16 +2779,22 @@ function setupUseBrickInTemplate(props, tplContextId) {
|
|
|
2568
2779
|
}
|
|
2569
2780
|
|
|
2570
2781
|
function setup(item) {
|
|
2571
|
-
|
|
2782
|
+
var {
|
|
2783
|
+
ref,
|
|
2784
|
+
slots: slotsInTemplate
|
|
2785
|
+
} = item;
|
|
2786
|
+
item.slots = Object.fromEntries(Object.entries(slotsInTemplate !== null && slotsInTemplate !== void 0 ? slotsInTemplate : {}).map(_ref => {
|
|
2787
|
+
var _slotConf$bricks;
|
|
2788
|
+
|
|
2789
|
+
var [slotName, slotConf] = _ref;
|
|
2790
|
+
return [slotName, {
|
|
2791
|
+
type: "bricks",
|
|
2792
|
+
bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(setup)
|
|
2793
|
+
}];
|
|
2794
|
+
}));
|
|
2795
|
+
Object.assign(item, setupTemplateProxy(proxyContext, ref, item.slots));
|
|
2572
2796
|
walk(item.properties);
|
|
2573
|
-
|
|
2574
|
-
if (item.slots) {
|
|
2575
|
-
Object.values(item.slots).forEach(slot => {
|
|
2576
|
-
if (Array.isArray(slot.bricks)) {
|
|
2577
|
-
slot.bricks.forEach(setup);
|
|
2578
|
-
}
|
|
2579
|
-
});
|
|
2580
|
-
}
|
|
2797
|
+
return item;
|
|
2581
2798
|
}
|
|
2582
2799
|
|
|
2583
2800
|
walk(props);
|
|
@@ -2637,7 +2854,9 @@ function setProperties(bricks, properties, context, injectDeep) {
|
|
|
2637
2854
|
var realProps = computeRealProperties(properties, context, injectDeep);
|
|
2638
2855
|
|
|
2639
2856
|
if (context.tplContextId) {
|
|
2640
|
-
setupUseBrickInTemplate(realProps,
|
|
2857
|
+
setupUseBrickInTemplate(realProps, {
|
|
2858
|
+
templateContextId: context.tplContextId
|
|
2859
|
+
});
|
|
2641
2860
|
}
|
|
2642
2861
|
|
|
2643
2862
|
if (!Array.isArray(bricks)) {
|
|
@@ -10519,22 +10738,6 @@ class Router {
|
|
|
10519
10738
|
|
|
10520
10739
|
}
|
|
10521
10740
|
|
|
10522
|
-
function isBasicProperty(propRef) {
|
|
10523
|
-
return !!propRef.refProperty;
|
|
10524
|
-
}
|
|
10525
|
-
function isTransformableProperty(propRef) {
|
|
10526
|
-
return !!propRef.refTransform;
|
|
10527
|
-
}
|
|
10528
|
-
function isMergeableProperty(propRef) {
|
|
10529
|
-
return !!propRef.mergeProperty;
|
|
10530
|
-
}
|
|
10531
|
-
function isRefProperty(propRef) {
|
|
10532
|
-
return !!propRef.ref;
|
|
10533
|
-
}
|
|
10534
|
-
function isVariableProperty(propRef) {
|
|
10535
|
-
return !!propRef.asVariable;
|
|
10536
|
-
}
|
|
10537
|
-
|
|
10538
10741
|
function collectRefsInTemplate(template) {
|
|
10539
10742
|
var refMap = new Map();
|
|
10540
10743
|
collectRefsInBrickConfs(template.bricks, refMap);
|
|
@@ -10566,103 +10769,6 @@ function collectRefsInBrickConf(brickConf, refMap) {
|
|
|
10566
10769
|
}
|
|
10567
10770
|
}
|
|
10568
10771
|
|
|
10569
|
-
function propertyMerge(conf, value, object) {
|
|
10570
|
-
return propertyMergeAll(conf.$$mergeBase, Object.fromEntries(conf.$$mergeBase.proxies.map(proxy => [proxy.$$reversedRef, proxy === conf ? value : object[proxy.$$reversedRef]])));
|
|
10571
|
-
}
|
|
10572
|
-
function propertyMergeAll(mergeBase, object) {
|
|
10573
|
-
if (mergeBase.mergeType === "array") {
|
|
10574
|
-
return propertyMergeAllOfArray(mergeBase, object);
|
|
10575
|
-
}
|
|
10576
|
-
|
|
10577
|
-
if (mergeBase.mergeType === "object") {
|
|
10578
|
-
return propertyMergeAllOfObject(mergeBase, object);
|
|
10579
|
-
} // istanbul ignore next: should never reach
|
|
10580
|
-
|
|
10581
|
-
|
|
10582
|
-
throw new TypeError("unsupported mergeType: \"".concat(mergeBase.mergeType, "\""));
|
|
10583
|
-
}
|
|
10584
|
-
|
|
10585
|
-
function propertyMergeAllOfArray(_ref, object) {
|
|
10586
|
-
var _, _proxy$mergeArgs;
|
|
10587
|
-
|
|
10588
|
-
var {
|
|
10589
|
-
baseValue,
|
|
10590
|
-
context,
|
|
10591
|
-
proxies
|
|
10592
|
-
} = _ref;
|
|
10593
|
-
// Use an approach like template-literal's quasis:
|
|
10594
|
-
// `quasi0${0}quais1${1}quasi2...`
|
|
10595
|
-
// Every quasi can be merged with multiple items.
|
|
10596
|
-
var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true, {
|
|
10597
|
-
$$lazyForUseBrick: true
|
|
10598
|
-
}) : [];
|
|
10599
|
-
var quasis = [];
|
|
10600
|
-
var size = computedBaseValue.length + 1;
|
|
10601
|
-
|
|
10602
|
-
for (var i = 0; i < size; i += 1) {
|
|
10603
|
-
quasis.push([]);
|
|
10604
|
-
}
|
|
10605
|
-
|
|
10606
|
-
for (var proxy of proxies) {
|
|
10607
|
-
var position = void 0;
|
|
10608
|
-
|
|
10609
|
-
switch (proxy.mergeMethod) {
|
|
10610
|
-
case "append":
|
|
10611
|
-
position = computedBaseValue.length;
|
|
10612
|
-
break;
|
|
10613
|
-
|
|
10614
|
-
case "prepend":
|
|
10615
|
-
position = 0;
|
|
10616
|
-
break;
|
|
10617
|
-
|
|
10618
|
-
case "insertAt":
|
|
10619
|
-
// Defaults to `-1`.
|
|
10620
|
-
position = (_ = (_proxy$mergeArgs = proxy.mergeArgs) === null || _proxy$mergeArgs === void 0 ? void 0 : _proxy$mergeArgs[0]) !== null && _ !== void 0 ? _ : -1;
|
|
10621
|
-
|
|
10622
|
-
if (position < 0) {
|
|
10623
|
-
// It's counted from the end if position is negative.
|
|
10624
|
-
position += quasis.length;
|
|
10625
|
-
}
|
|
10626
|
-
|
|
10627
|
-
position = clamp(position, 0, computedBaseValue.length);
|
|
10628
|
-
break;
|
|
10629
|
-
// istanbul ignore next: should never reach
|
|
10630
|
-
|
|
10631
|
-
default:
|
|
10632
|
-
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
10633
|
-
}
|
|
10634
|
-
|
|
10635
|
-
var patchValue = object[proxy.$$reversedRef];
|
|
10636
|
-
|
|
10637
|
-
if (!Array.isArray(patchValue)) {
|
|
10638
|
-
patchValue = [];
|
|
10639
|
-
}
|
|
10640
|
-
|
|
10641
|
-
quasis[position].push(...patchValue);
|
|
10642
|
-
}
|
|
10643
|
-
|
|
10644
|
-
return quasis.flatMap((item, index) => index < computedBaseValue.length ? item.concat(computedBaseValue[index]) : item);
|
|
10645
|
-
}
|
|
10646
|
-
|
|
10647
|
-
function propertyMergeAllOfObject(_ref2, object) {
|
|
10648
|
-
var {
|
|
10649
|
-
baseValue,
|
|
10650
|
-
proxies,
|
|
10651
|
-
context
|
|
10652
|
-
} = _ref2;
|
|
10653
|
-
var computedBaseValue = isObject(baseValue) ? computeRealValue(baseValue, context, true) : {};
|
|
10654
|
-
return proxies.reduce((acc, proxy) => {
|
|
10655
|
-
switch (proxy.mergeMethod) {
|
|
10656
|
-
case "extend":
|
|
10657
|
-
return _objectSpread(_objectSpread({}, acc), object[proxy.$$reversedRef]);
|
|
10658
|
-
// istanbul ignore next: should never reach
|
|
10659
|
-
|
|
10660
|
-
default:
|
|
10661
|
-
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
10662
|
-
}
|
|
10663
|
-
}, computedBaseValue);
|
|
10664
|
-
}
|
|
10665
|
-
|
|
10666
10772
|
function collectMergeBases(conf, mergeBases, contextInTemplate, refToBrickConf) {
|
|
10667
10773
|
var mergeBaseMap;
|
|
10668
10774
|
|
|
@@ -10857,15 +10963,6 @@ function expandBrickInTemplate(brickConfInTemplate, proxyContext) {
|
|
|
10857
10963
|
} = brickConfInTemplate,
|
|
10858
10964
|
restBrickConfInTemplate = _objectWithoutProperties(brickConfInTemplate, _excluded2);
|
|
10859
10965
|
|
|
10860
|
-
var {
|
|
10861
|
-
reversedProxies,
|
|
10862
|
-
templateProperties,
|
|
10863
|
-
externalSlots,
|
|
10864
|
-
templateContextId,
|
|
10865
|
-
proxyBrick
|
|
10866
|
-
} = proxyContext;
|
|
10867
|
-
var computedPropsFromProxy = {};
|
|
10868
|
-
var refForProxy;
|
|
10869
10966
|
var slots = Object.fromEntries(Object.entries(slotsInTemplate !== null && slotsInTemplate !== void 0 ? slotsInTemplate : {}).map(_ref => {
|
|
10870
10967
|
var _slotConf$bricks;
|
|
10871
10968
|
|
|
@@ -10875,95 +10972,10 @@ function expandBrickInTemplate(brickConfInTemplate, proxyContext) {
|
|
|
10875
10972
|
bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(item => expandBrickInTemplate(item, proxyContext))
|
|
10876
10973
|
}];
|
|
10877
10974
|
}));
|
|
10878
|
-
setupUseBrickInTemplate(brickConfInTemplate.properties,
|
|
10879
|
-
|
|
10880
|
-
if (ref) {
|
|
10881
|
-
refForProxy = {};
|
|
10882
|
-
proxyBrick.proxyRefs.set(ref, refForProxy); // Reversed proxies are used for expand storyboard before rendering page.
|
|
10883
|
-
|
|
10884
|
-
if (reversedProxies.properties.has(ref)) {
|
|
10885
|
-
Object.assign(computedPropsFromProxy, Object.fromEntries(reversedProxies.properties.get(ref).flatMap(item => {
|
|
10886
|
-
// `propValue` is computed.
|
|
10887
|
-
var propValue = templateProperties === null || templateProperties === void 0 ? void 0 : templateProperties[item.$$reversedRef];
|
|
10888
|
-
|
|
10889
|
-
if (isTransformableProperty(item)) {
|
|
10890
|
-
return Object.entries(preprocessTransformProperties({
|
|
10891
|
-
[item.$$reversedRef]: propValue
|
|
10892
|
-
}, item.refTransform));
|
|
10893
|
-
}
|
|
10894
|
-
|
|
10895
|
-
if (isBasicProperty(item)) {
|
|
10896
|
-
return [[item.refProperty, propValue]];
|
|
10897
|
-
} // Ignore Variable properties.
|
|
10898
|
-
// And mergeable properties are processed later.
|
|
10899
|
-
|
|
10900
|
-
|
|
10901
|
-
return [];
|
|
10902
|
-
}).filter(item => item[1] !== undefined)));
|
|
10903
|
-
} // Brick properties can be merged multiple times.
|
|
10904
|
-
|
|
10905
|
-
|
|
10906
|
-
if (reversedProxies.mergeBases.has(ref)) {
|
|
10907
|
-
Object.assign(computedPropsFromProxy, Object.fromEntries(Array.from(reversedProxies.mergeBases.get(ref).entries()).map(_ref2 => {
|
|
10908
|
-
var [mergeProperty, mergeBase] = _ref2;
|
|
10909
|
-
return [mergeProperty, propertyMergeAll(mergeBase, templateProperties !== null && templateProperties !== void 0 ? templateProperties : {})];
|
|
10910
|
-
}).filter(item => item[1] !== undefined)));
|
|
10911
|
-
} // Use an approach like template-literal's quasis:
|
|
10912
|
-
// `quasi0${0}quais1${1}quasi2...`
|
|
10913
|
-
// Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.
|
|
10914
|
-
|
|
10915
|
-
|
|
10916
|
-
var quasisMap = new Map();
|
|
10917
|
-
|
|
10918
|
-
if (reversedProxies.slots.has(ref)) {
|
|
10919
|
-
for (var item of reversedProxies.slots.get(ref)) {
|
|
10920
|
-
var _item$refPosition, _externalSlots$item$$, _externalSlots$item$$2;
|
|
10921
|
-
|
|
10922
|
-
if (!quasisMap.has(item.refSlot)) {
|
|
10923
|
-
var quasis = []; // The size of quasis should be the existed slotted bricks' size plus one.
|
|
10924
|
-
|
|
10925
|
-
var size = hasOwnProperty(slots, item.refSlot) ? slots[item.refSlot].bricks.length + 1 : 1;
|
|
10926
|
-
|
|
10927
|
-
for (var i = 0; i < size; i += 1) {
|
|
10928
|
-
quasis.push([]);
|
|
10929
|
-
}
|
|
10930
|
-
|
|
10931
|
-
quasisMap.set(item.refSlot, quasis);
|
|
10932
|
-
}
|
|
10933
|
-
|
|
10934
|
-
var expandableSlot = quasisMap.get(item.refSlot);
|
|
10935
|
-
var refPosition = (_item$refPosition = item.refPosition) !== null && _item$refPosition !== void 0 ? _item$refPosition : -1;
|
|
10936
|
-
expandableSlot[clamp(refPosition < 0 ? expandableSlot.length + refPosition : refPosition, 0, expandableSlot.length - 1)].push(...((_externalSlots$item$$ = externalSlots === null || externalSlots === void 0 ? void 0 : (_externalSlots$item$$2 = externalSlots[item.$$reversedRef]) === null || _externalSlots$item$$2 === void 0 ? void 0 : _externalSlots$item$$2.bricks) !== null && _externalSlots$item$$ !== void 0 ? _externalSlots$item$$ : []));
|
|
10937
|
-
}
|
|
10938
|
-
}
|
|
10939
|
-
|
|
10940
|
-
var _loop = function (slotName, _quasis) {
|
|
10941
|
-
if (!hasOwnProperty(slots, slotName)) {
|
|
10942
|
-
slots[slotName] = {
|
|
10943
|
-
type: "bricks",
|
|
10944
|
-
bricks: []
|
|
10945
|
-
};
|
|
10946
|
-
}
|
|
10947
|
-
|
|
10948
|
-
var slotConf = slots[slotName];
|
|
10949
|
-
slotConf.bricks = _quasis.flatMap((bricks, index) => index < slotConf.bricks.length ? bricks.concat(slotConf.bricks[index]) : bricks);
|
|
10950
|
-
|
|
10951
|
-
if (slotConf.bricks.length === 0) {
|
|
10952
|
-
delete slots[slotName];
|
|
10953
|
-
}
|
|
10954
|
-
};
|
|
10955
|
-
|
|
10956
|
-
for (var [slotName, _quasis] of quasisMap.entries()) {
|
|
10957
|
-
_loop(slotName, _quasis);
|
|
10958
|
-
}
|
|
10959
|
-
}
|
|
10960
|
-
|
|
10975
|
+
setupUseBrickInTemplate(brickConfInTemplate.properties, proxyContext);
|
|
10961
10976
|
return _objectSpread(_objectSpread({}, restBrickConfInTemplate), {}, {
|
|
10962
|
-
slots
|
|
10963
|
-
|
|
10964
|
-
[symbolForRefForProxy]: refForProxy,
|
|
10965
|
-
[symbolForTplContextId]: templateContextId
|
|
10966
|
-
});
|
|
10977
|
+
slots
|
|
10978
|
+
}, setupTemplateProxy(proxyContext, ref, slots));
|
|
10967
10979
|
}
|
|
10968
10980
|
|
|
10969
10981
|
// Otherwise, return false.
|
|
@@ -11570,19 +11582,7 @@ function useLocation() {
|
|
|
11570
11582
|
return location;
|
|
11571
11583
|
}
|
|
11572
11584
|
|
|
11573
|
-
var
|
|
11574
|
-
slotsToChildren(slots).forEach(item => {
|
|
11575
|
-
if (item[symbolForRefForProxy] !== undefined) {
|
|
11576
|
-
item[symbolForRefForProxy].brick = item;
|
|
11577
|
-
}
|
|
11578
|
-
|
|
11579
|
-
if (!isEmpty(item.slots)) {
|
|
11580
|
-
setProxyRefForSlots(item.slots);
|
|
11581
|
-
}
|
|
11582
|
-
});
|
|
11583
|
-
};
|
|
11584
|
-
|
|
11585
|
-
var setProxyRef = (useBrick, tplTagName, brick) => {
|
|
11585
|
+
var expandTemplateInUseBrick = (useBrick, tplTagName, brick) => {
|
|
11586
11586
|
var template;
|
|
11587
11587
|
|
|
11588
11588
|
if (tplTagName) {
|
|
@@ -11596,10 +11596,8 @@ var setProxyRef = (useBrick, tplTagName, brick) => {
|
|
|
11596
11596
|
slots: useBrick.slots
|
|
11597
11597
|
};
|
|
11598
11598
|
template = expandCustomTemplate(tplConf, brick, _internalApiGetCurrentContext());
|
|
11599
|
-
setProxyRefForSlots(template.slots);
|
|
11600
11599
|
} else if (useBrick[symbolForRefForProxy]) {
|
|
11601
11600
|
useBrick[symbolForRefForProxy].brick = brick;
|
|
11602
|
-
setProxyRefForSlots(useBrick.slots);
|
|
11603
11601
|
}
|
|
11604
11602
|
|
|
11605
11603
|
return template;
|
|
@@ -11648,7 +11646,8 @@ var getCurrentRunTimeBrick = (useBrick, tplTagName, data) => {
|
|
|
11648
11646
|
* @param props - 属性。
|
|
11649
11647
|
*/
|
|
11650
11648
|
|
|
11651
|
-
|
|
11649
|
+
|
|
11650
|
+
var SingleBrickAsComponent = /*#__PURE__*/React.memo(function SingleBrickAsComponent(_ref) {
|
|
11652
11651
|
var _internalApiGetCurren, _templateRef$current$, _templateRef$current, _templateRef$current2;
|
|
11653
11652
|
|
|
11654
11653
|
var {
|
|
@@ -11656,7 +11655,7 @@ var SingleBrickAsComponent = /*#__PURE__*/React.memo(function SingleBrickAsCompo
|
|
|
11656
11655
|
data,
|
|
11657
11656
|
refCallback,
|
|
11658
11657
|
immediatelyRefCallback
|
|
11659
|
-
} =
|
|
11658
|
+
} = _ref;
|
|
11660
11659
|
var templateRef = useRef();
|
|
11661
11660
|
var tplTagName = getTagNameOfCustomTemplate(useBrick.brick, (_internalApiGetCurren = _internalApiGetCurrentContext().app) === null || _internalApiGetCurren === void 0 ? void 0 : _internalApiGetCurren.id);
|
|
11662
11661
|
var isBrickAvailable = React.useMemo(() => {
|
|
@@ -11686,15 +11685,15 @@ var SingleBrickAsComponent = /*#__PURE__*/React.memo(function SingleBrickAsCompo
|
|
|
11686
11685
|
_internalApiLoadDynamicBricksInBrickConf(useBrick).catch(handleHttpError);
|
|
11687
11686
|
|
|
11688
11687
|
var brick = getCurrentRunTimeBrick(useBrick, tplTagName, data);
|
|
11689
|
-
templateRef.current =
|
|
11688
|
+
templateRef.current = expandTemplateInUseBrick(useBrick, tplTagName, brick); // Let `transform` works still.
|
|
11690
11689
|
|
|
11691
11690
|
transformProperties(brick.properties, data, useBrick.transform, useBrick.transformFrom, undefined, {
|
|
11692
11691
|
allowInject: true
|
|
11693
11692
|
}); // 设置 properties refProperty值
|
|
11694
11693
|
|
|
11695
11694
|
if (useBrick[symbolForComputedPropsFromProxy]) {
|
|
11696
|
-
Object.entries(useBrick[symbolForComputedPropsFromProxy]).forEach(
|
|
11697
|
-
var [propName, propValue] =
|
|
11695
|
+
Object.entries(useBrick[symbolForComputedPropsFromProxy]).forEach(_ref3 => {
|
|
11696
|
+
var [propName, propValue] = _ref3;
|
|
11698
11697
|
set(brick.properties, propName, propValue);
|
|
11699
11698
|
});
|
|
11700
11699
|
}
|
|
@@ -11713,7 +11712,7 @@ var SingleBrickAsComponent = /*#__PURE__*/React.memo(function SingleBrickAsCompo
|
|
|
11713
11712
|
return brick;
|
|
11714
11713
|
}), [useBrick, data, isBrickAvailable]);
|
|
11715
11714
|
var innerRefCallback = React.useCallback( /*#__PURE__*/function () {
|
|
11716
|
-
var
|
|
11715
|
+
var _ref4 = _asyncToGenerator$4(function* (element) {
|
|
11717
11716
|
immediatelyRefCallback === null || immediatelyRefCallback === void 0 ? void 0 : immediatelyRefCallback(element);
|
|
11718
11717
|
|
|
11719
11718
|
if (element) {
|
|
@@ -11749,7 +11748,7 @@ var SingleBrickAsComponent = /*#__PURE__*/React.memo(function SingleBrickAsCompo
|
|
|
11749
11748
|
} // 设置proxyEvent
|
|
11750
11749
|
|
|
11751
11750
|
|
|
11752
|
-
handleProxyOfCustomTemplate(brick);
|
|
11751
|
+
handleProxyOfCustomTemplate(brick);
|
|
11753
11752
|
|
|
11754
11753
|
if (element.$$typeof !== "custom-template") {
|
|
11755
11754
|
if (!useBrick.brick.includes("-")) {
|
|
@@ -11764,7 +11763,7 @@ var SingleBrickAsComponent = /*#__PURE__*/React.memo(function SingleBrickAsCompo
|
|
|
11764
11763
|
});
|
|
11765
11764
|
|
|
11766
11765
|
return function (_x) {
|
|
11767
|
-
return
|
|
11766
|
+
return _ref4.apply(this, arguments);
|
|
11768
11767
|
};
|
|
11769
11768
|
}(), [runtimeBrick, useBrick, data, refCallback, immediatelyRefCallback]);
|
|
11770
11769
|
|
|
@@ -11799,11 +11798,11 @@ var SingleBrickAsComponent = /*#__PURE__*/React.memo(function SingleBrickAsCompo
|
|
|
11799
11798
|
* @param props - 属性。
|
|
11800
11799
|
*/
|
|
11801
11800
|
|
|
11802
|
-
function BrickAsComponent(
|
|
11801
|
+
function BrickAsComponent(_ref5) {
|
|
11803
11802
|
var {
|
|
11804
11803
|
useBrick,
|
|
11805
11804
|
data
|
|
11806
|
-
} =
|
|
11805
|
+
} = _ref5;
|
|
11807
11806
|
|
|
11808
11807
|
if (Array.isArray(useBrick)) {
|
|
11809
11808
|
return /*#__PURE__*/React.createElement(React.Fragment, null, useBrick.map((item, index) => /*#__PURE__*/React.createElement(SingleBrickAsComponent, {
|
|
@@ -11824,8 +11823,8 @@ function slotsToChildren(slots) {
|
|
|
11824
11823
|
return [];
|
|
11825
11824
|
}
|
|
11826
11825
|
|
|
11827
|
-
return Object.entries(slots).flatMap(
|
|
11828
|
-
var [slot, slotConf] =
|
|
11826
|
+
return Object.entries(slots).flatMap(_ref6 => {
|
|
11827
|
+
var [slot, slotConf] = _ref6;
|
|
11829
11828
|
return Array.isArray(slotConf.bricks) ? slotConf.bricks.map(child => _objectSpread(_objectSpread({}, child), {}, {
|
|
11830
11829
|
properties: _objectSpread(_objectSpread({}, child.properties), {}, {
|
|
11831
11830
|
slot
|
|
@@ -11845,14 +11844,14 @@ function transformEvents(data, events) {
|
|
|
11845
11844
|
// eslint-disable-next-line react/display-name
|
|
11846
11845
|
|
|
11847
11846
|
|
|
11848
|
-
var ForwardRefSingleBrickAsComponent = /*#__PURE__*/React.memo( /*#__PURE__*/forwardRef(function LegacySingleBrickAsComponent(
|
|
11847
|
+
var ForwardRefSingleBrickAsComponent = /*#__PURE__*/React.memo( /*#__PURE__*/forwardRef(function LegacySingleBrickAsComponent(_ref7, ref) {
|
|
11849
11848
|
var _internalApiGetCurren2, _templateRef$current$2, _templateRef$current3, _templateRef$current4;
|
|
11850
11849
|
|
|
11851
11850
|
var {
|
|
11852
11851
|
useBrick,
|
|
11853
11852
|
data,
|
|
11854
11853
|
refCallback
|
|
11855
|
-
} =
|
|
11854
|
+
} = _ref7;
|
|
11856
11855
|
var brickRef = useRef();
|
|
11857
11856
|
var templateRef = useRef();
|
|
11858
11857
|
var tplTagName = getTagNameOfCustomTemplate(useBrick.brick, (_internalApiGetCurren2 = _internalApiGetCurrentContext().app) === null || _internalApiGetCurren2 === void 0 ? void 0 : _internalApiGetCurren2.id);
|
|
@@ -11888,15 +11887,15 @@ var ForwardRefSingleBrickAsComponent = /*#__PURE__*/React.memo( /*#__PURE__*/for
|
|
|
11888
11887
|
_internalApiLoadDynamicBricksInBrickConf(useBrick).catch(handleHttpError);
|
|
11889
11888
|
|
|
11890
11889
|
var brick = getCurrentRunTimeBrick(useBrick, tplTagName, data);
|
|
11891
|
-
templateRef.current =
|
|
11890
|
+
templateRef.current = expandTemplateInUseBrick(useBrick, tplTagName, brick); // Let `transform` works still.
|
|
11892
11891
|
|
|
11893
11892
|
transformProperties(brick.properties, data, useBrick.transform, useBrick.transformFrom, undefined, {
|
|
11894
11893
|
allowInject: true
|
|
11895
11894
|
}); // 设置 properties refProperty值
|
|
11896
11895
|
|
|
11897
11896
|
if (useBrick[symbolForComputedPropsFromProxy]) {
|
|
11898
|
-
Object.entries(useBrick[symbolForComputedPropsFromProxy]).forEach(
|
|
11899
|
-
var [propName, propValue] =
|
|
11897
|
+
Object.entries(useBrick[symbolForComputedPropsFromProxy]).forEach(_ref9 => {
|
|
11898
|
+
var [propName, propValue] = _ref9;
|
|
11900
11899
|
set(brick.properties, propName, propValue);
|
|
11901
11900
|
});
|
|
11902
11901
|
}
|
|
@@ -11915,7 +11914,7 @@ var ForwardRefSingleBrickAsComponent = /*#__PURE__*/React.memo( /*#__PURE__*/for
|
|
|
11915
11914
|
return brick;
|
|
11916
11915
|
}), [useBrick, data, isBrickAvailable]);
|
|
11917
11916
|
var innerRefCallback = React.useCallback( /*#__PURE__*/function () {
|
|
11918
|
-
var
|
|
11917
|
+
var _ref10 = _asyncToGenerator$4(function* (element) {
|
|
11919
11918
|
brickRef.current = element;
|
|
11920
11919
|
|
|
11921
11920
|
if (element) {
|
|
@@ -11951,7 +11950,7 @@ var ForwardRefSingleBrickAsComponent = /*#__PURE__*/React.memo( /*#__PURE__*/for
|
|
|
11951
11950
|
} // 设置proxyEvent
|
|
11952
11951
|
|
|
11953
11952
|
|
|
11954
|
-
handleProxyOfCustomTemplate(brick);
|
|
11953
|
+
handleProxyOfCustomTemplate(brick);
|
|
11955
11954
|
|
|
11956
11955
|
if (element.$$typeof !== "custom-template") {
|
|
11957
11956
|
if (!useBrick.brick.includes("-")) {
|
|
@@ -11966,7 +11965,7 @@ var ForwardRefSingleBrickAsComponent = /*#__PURE__*/React.memo( /*#__PURE__*/for
|
|
|
11966
11965
|
});
|
|
11967
11966
|
|
|
11968
11967
|
return function (_x2) {
|
|
11969
|
-
return
|
|
11968
|
+
return _ref10.apply(this, arguments);
|
|
11970
11969
|
};
|
|
11971
11970
|
}(), [runtimeBrick, useBrick, data, refCallback]);
|
|
11972
11971
|
|