@next-core/brick-kit 2.118.2 → 2.118.5

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.
@@ -2539,13 +2539,224 @@
2539
2539
  }
2540
2540
  }
2541
2541
 
2542
+ function isBasicProperty(propRef) {
2543
+ return !!propRef.refProperty;
2544
+ }
2545
+ function isTransformableProperty(propRef) {
2546
+ return !!propRef.refTransform;
2547
+ }
2548
+ function isMergeableProperty(propRef) {
2549
+ return !!propRef.mergeProperty;
2550
+ }
2551
+ function isRefProperty(propRef) {
2552
+ return !!propRef.ref;
2553
+ }
2554
+ function isVariableProperty(propRef) {
2555
+ return !!propRef.asVariable;
2556
+ }
2557
+
2542
2558
  var customTemplateRegistry = new Map();
2543
2559
  var appRegistered = new Set();
2544
2560
  var symbolForComputedPropsFromProxy = Symbol.for("tpl.computedPropsFromProxy");
2545
2561
  var symbolForRefForProxy = Symbol.for("tpl.refForProxy");
2546
2562
  var symbolForTplContextId = Symbol.for("tpl.contextId");
2547
2563
 
2548
- function setupUseBrickInTemplate(props, tplContextId) {
2564
+ function propertyMerge(conf, value, object) {
2565
+ return propertyMergeAll(conf.$$mergeBase, Object.fromEntries(conf.$$mergeBase.proxies.map(proxy => [proxy.$$reversedRef, proxy === conf ? value : object[proxy.$$reversedRef]])));
2566
+ }
2567
+ function propertyMergeAll(mergeBase, object) {
2568
+ if (mergeBase.mergeType === "array") {
2569
+ return propertyMergeAllOfArray(mergeBase, object);
2570
+ }
2571
+
2572
+ if (mergeBase.mergeType === "object") {
2573
+ return propertyMergeAllOfObject(mergeBase, object);
2574
+ } // istanbul ignore next: should never reach
2575
+
2576
+
2577
+ throw new TypeError("unsupported mergeType: \"".concat(mergeBase.mergeType, "\""));
2578
+ }
2579
+
2580
+ function propertyMergeAllOfArray(_ref, object) {
2581
+ var _, _proxy$mergeArgs;
2582
+
2583
+ var {
2584
+ baseValue,
2585
+ context,
2586
+ proxies
2587
+ } = _ref;
2588
+ // Use an approach like template-literal's quasis:
2589
+ // `quasi0${0}quais1${1}quasi2...`
2590
+ // Every quasi can be merged with multiple items.
2591
+ var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true, {
2592
+ $$lazyForUseBrick: true
2593
+ }) : [];
2594
+ var quasis = [];
2595
+ var size = computedBaseValue.length + 1;
2596
+
2597
+ for (var i = 0; i < size; i += 1) {
2598
+ quasis.push([]);
2599
+ }
2600
+
2601
+ for (var proxy of proxies) {
2602
+ var position = void 0;
2603
+
2604
+ switch (proxy.mergeMethod) {
2605
+ case "append":
2606
+ position = computedBaseValue.length;
2607
+ break;
2608
+
2609
+ case "prepend":
2610
+ position = 0;
2611
+ break;
2612
+
2613
+ case "insertAt":
2614
+ // Defaults to `-1`.
2615
+ position = (_ = (_proxy$mergeArgs = proxy.mergeArgs) === null || _proxy$mergeArgs === void 0 ? void 0 : _proxy$mergeArgs[0]) !== null && _ !== void 0 ? _ : -1;
2616
+
2617
+ if (position < 0) {
2618
+ // It's counted from the end if position is negative.
2619
+ position += quasis.length;
2620
+ }
2621
+
2622
+ position = lodash.clamp(position, 0, computedBaseValue.length);
2623
+ break;
2624
+ // istanbul ignore next: should never reach
2625
+
2626
+ default:
2627
+ throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
2628
+ }
2629
+
2630
+ var patchValue = object[proxy.$$reversedRef];
2631
+
2632
+ if (!Array.isArray(patchValue)) {
2633
+ patchValue = [];
2634
+ }
2635
+
2636
+ quasis[position].push(...patchValue);
2637
+ }
2638
+
2639
+ return quasis.flatMap((item, index) => index < computedBaseValue.length ? item.concat(computedBaseValue[index]) : item);
2640
+ }
2641
+
2642
+ function propertyMergeAllOfObject(_ref2, object) {
2643
+ var {
2644
+ baseValue,
2645
+ proxies,
2646
+ context
2647
+ } = _ref2;
2648
+ var computedBaseValue = brickUtils.isObject(baseValue) ? computeRealValue(baseValue, context, true) : {};
2649
+ return proxies.reduce((acc, proxy) => {
2650
+ switch (proxy.mergeMethod) {
2651
+ case "extend":
2652
+ return _objectSpread__default["default"](_objectSpread__default["default"]({}, acc), object[proxy.$$reversedRef]);
2653
+ // istanbul ignore next: should never reach
2654
+
2655
+ default:
2656
+ throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
2657
+ }
2658
+ }, computedBaseValue);
2659
+ }
2660
+
2661
+ function setupTemplateProxy(proxyContext, ref, slots) {
2662
+ var computedPropsFromProxy = {};
2663
+ var refForProxy;
2664
+ var {
2665
+ reversedProxies,
2666
+ templateProperties,
2667
+ externalSlots,
2668
+ templateContextId,
2669
+ proxyBrick
2670
+ } = proxyContext;
2671
+
2672
+ if (ref && reversedProxies) {
2673
+ refForProxy = {};
2674
+ proxyBrick.proxyRefs.set(ref, refForProxy); // Reversed proxies are used for expand storyboard before rendering page.
2675
+
2676
+ if (reversedProxies.properties.has(ref)) {
2677
+ Object.assign(computedPropsFromProxy, Object.fromEntries(reversedProxies.properties.get(ref).flatMap(propRef => {
2678
+ // `propValue` is computed.
2679
+ var propValue = templateProperties === null || templateProperties === void 0 ? void 0 : templateProperties[propRef.$$reversedRef];
2680
+
2681
+ if (isTransformableProperty(propRef)) {
2682
+ return Object.entries(preprocessTransformProperties({
2683
+ [propRef.$$reversedRef]: propValue
2684
+ }, propRef.refTransform));
2685
+ }
2686
+
2687
+ if (isBasicProperty(propRef)) {
2688
+ return [[propRef.refProperty, propValue]];
2689
+ } // Ignore Variable properties.
2690
+ // And mergeable properties are processed later.
2691
+
2692
+
2693
+ return [];
2694
+ }).filter(propRef => propRef[1] !== undefined))); // Brick properties can be merged multiple times.
2695
+
2696
+ if (reversedProxies.mergeBases.has(ref)) {
2697
+ Object.assign(computedPropsFromProxy, Object.fromEntries(Array.from(reversedProxies.mergeBases.get(ref).entries()).map(_ref => {
2698
+ var [mergeProperty, mergeBase] = _ref;
2699
+ return [mergeProperty, propertyMergeAll(mergeBase, templateProperties !== null && templateProperties !== void 0 ? templateProperties : {})];
2700
+ }).filter(item => item[1] !== undefined)));
2701
+ }
2702
+ } // Use an approach like template-literal's quasis:
2703
+ // `quasi0${0}quais1${1}quasi2...`
2704
+ // Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.
2705
+
2706
+
2707
+ var quasisMap = new Map();
2708
+
2709
+ if (reversedProxies.slots.has(ref)) {
2710
+ for (var item of reversedProxies.slots.get(ref)) {
2711
+ var _item$refPosition, _externalSlots$item$$, _externalSlots$item$$2;
2712
+
2713
+ if (!quasisMap.has(item.refSlot)) {
2714
+ var quasis = []; // The size of quasis should be the existed slotted bricks' size plus one.
2715
+
2716
+ var size = brickUtils.hasOwnProperty(slots, item.refSlot) ? slots[item.refSlot].bricks.length + 1 : 1;
2717
+
2718
+ for (var i = 0; i < size; i += 1) {
2719
+ quasis.push([]);
2720
+ }
2721
+
2722
+ quasisMap.set(item.refSlot, quasis);
2723
+ }
2724
+
2725
+ var expandableSlot = quasisMap.get(item.refSlot);
2726
+ var refPosition = (_item$refPosition = item.refPosition) !== null && _item$refPosition !== void 0 ? _item$refPosition : -1;
2727
+ expandableSlot[lodash.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$$ : []));
2728
+ }
2729
+ }
2730
+
2731
+ var _loop = function (slotName, _quasis) {
2732
+ if (!brickUtils.hasOwnProperty(slots, slotName)) {
2733
+ slots[slotName] = {
2734
+ type: "bricks",
2735
+ bricks: []
2736
+ };
2737
+ }
2738
+
2739
+ var slotConf = slots[slotName];
2740
+ slotConf.bricks = _quasis.flatMap((bricks, index) => index < slotConf.bricks.length ? bricks.concat(slotConf.bricks[index]) : bricks);
2741
+
2742
+ if (slotConf.bricks.length === 0) {
2743
+ delete slots[slotName];
2744
+ }
2745
+ };
2746
+
2747
+ for (var [slotName, _quasis] of quasisMap.entries()) {
2748
+ _loop(slotName, _quasis);
2749
+ }
2750
+ }
2751
+
2752
+ return {
2753
+ [symbolForComputedPropsFromProxy]: computedPropsFromProxy,
2754
+ [symbolForRefForProxy]: refForProxy,
2755
+ [symbolForTplContextId]: templateContextId
2756
+ };
2757
+ }
2758
+
2759
+ function setupUseBrickInTemplate(props, proxyContext) {
2549
2760
  function walk(props) {
2550
2761
  if (!props) {
2551
2762
  return;
@@ -2567,16 +2778,22 @@
2567
2778
  }
2568
2779
 
2569
2780
  function setup(item) {
2570
- item[symbolForTplContextId] = tplContextId;
2781
+ var {
2782
+ ref,
2783
+ slots: slotsInTemplate
2784
+ } = item;
2785
+ item.slots = Object.fromEntries(Object.entries(slotsInTemplate !== null && slotsInTemplate !== void 0 ? slotsInTemplate : {}).map(_ref => {
2786
+ var _slotConf$bricks;
2787
+
2788
+ var [slotName, slotConf] = _ref;
2789
+ return [slotName, {
2790
+ type: "bricks",
2791
+ bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(setup)
2792
+ }];
2793
+ }));
2794
+ Object.assign(item, setupTemplateProxy(proxyContext, ref, item.slots));
2571
2795
  walk(item.properties);
2572
-
2573
- if (item.slots) {
2574
- Object.values(item.slots).forEach(slot => {
2575
- if (Array.isArray(slot.bricks)) {
2576
- slot.bricks.forEach(setup);
2577
- }
2578
- });
2579
- }
2796
+ return item;
2580
2797
  }
2581
2798
 
2582
2799
  walk(props);
@@ -2636,7 +2853,9 @@
2636
2853
  var realProps = computeRealProperties(properties, context, injectDeep);
2637
2854
 
2638
2855
  if (context.tplContextId) {
2639
- setupUseBrickInTemplate(realProps, context.tplContextId);
2856
+ setupUseBrickInTemplate(realProps, {
2857
+ templateContextId: context.tplContextId
2858
+ });
2640
2859
  }
2641
2860
 
2642
2861
  if (!Array.isArray(bricks)) {
@@ -10518,22 +10737,6 @@
10518
10737
 
10519
10738
  }
10520
10739
 
10521
- function isBasicProperty(propRef) {
10522
- return !!propRef.refProperty;
10523
- }
10524
- function isTransformableProperty(propRef) {
10525
- return !!propRef.refTransform;
10526
- }
10527
- function isMergeableProperty(propRef) {
10528
- return !!propRef.mergeProperty;
10529
- }
10530
- function isRefProperty(propRef) {
10531
- return !!propRef.ref;
10532
- }
10533
- function isVariableProperty(propRef) {
10534
- return !!propRef.asVariable;
10535
- }
10536
-
10537
10740
  function collectRefsInTemplate(template) {
10538
10741
  var refMap = new Map();
10539
10742
  collectRefsInBrickConfs(template.bricks, refMap);
@@ -10565,103 +10768,6 @@
10565
10768
  }
10566
10769
  }
10567
10770
 
10568
- function propertyMerge(conf, value, object) {
10569
- return propertyMergeAll(conf.$$mergeBase, Object.fromEntries(conf.$$mergeBase.proxies.map(proxy => [proxy.$$reversedRef, proxy === conf ? value : object[proxy.$$reversedRef]])));
10570
- }
10571
- function propertyMergeAll(mergeBase, object) {
10572
- if (mergeBase.mergeType === "array") {
10573
- return propertyMergeAllOfArray(mergeBase, object);
10574
- }
10575
-
10576
- if (mergeBase.mergeType === "object") {
10577
- return propertyMergeAllOfObject(mergeBase, object);
10578
- } // istanbul ignore next: should never reach
10579
-
10580
-
10581
- throw new TypeError("unsupported mergeType: \"".concat(mergeBase.mergeType, "\""));
10582
- }
10583
-
10584
- function propertyMergeAllOfArray(_ref, object) {
10585
- var _, _proxy$mergeArgs;
10586
-
10587
- var {
10588
- baseValue,
10589
- context,
10590
- proxies
10591
- } = _ref;
10592
- // Use an approach like template-literal's quasis:
10593
- // `quasi0${0}quais1${1}quasi2...`
10594
- // Every quasi can be merged with multiple items.
10595
- var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true, {
10596
- $$lazyForUseBrick: true
10597
- }) : [];
10598
- var quasis = [];
10599
- var size = computedBaseValue.length + 1;
10600
-
10601
- for (var i = 0; i < size; i += 1) {
10602
- quasis.push([]);
10603
- }
10604
-
10605
- for (var proxy of proxies) {
10606
- var position = void 0;
10607
-
10608
- switch (proxy.mergeMethod) {
10609
- case "append":
10610
- position = computedBaseValue.length;
10611
- break;
10612
-
10613
- case "prepend":
10614
- position = 0;
10615
- break;
10616
-
10617
- case "insertAt":
10618
- // Defaults to `-1`.
10619
- position = (_ = (_proxy$mergeArgs = proxy.mergeArgs) === null || _proxy$mergeArgs === void 0 ? void 0 : _proxy$mergeArgs[0]) !== null && _ !== void 0 ? _ : -1;
10620
-
10621
- if (position < 0) {
10622
- // It's counted from the end if position is negative.
10623
- position += quasis.length;
10624
- }
10625
-
10626
- position = lodash.clamp(position, 0, computedBaseValue.length);
10627
- break;
10628
- // istanbul ignore next: should never reach
10629
-
10630
- default:
10631
- throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
10632
- }
10633
-
10634
- var patchValue = object[proxy.$$reversedRef];
10635
-
10636
- if (!Array.isArray(patchValue)) {
10637
- patchValue = [];
10638
- }
10639
-
10640
- quasis[position].push(...patchValue);
10641
- }
10642
-
10643
- return quasis.flatMap((item, index) => index < computedBaseValue.length ? item.concat(computedBaseValue[index]) : item);
10644
- }
10645
-
10646
- function propertyMergeAllOfObject(_ref2, object) {
10647
- var {
10648
- baseValue,
10649
- proxies,
10650
- context
10651
- } = _ref2;
10652
- var computedBaseValue = brickUtils.isObject(baseValue) ? computeRealValue(baseValue, context, true) : {};
10653
- return proxies.reduce((acc, proxy) => {
10654
- switch (proxy.mergeMethod) {
10655
- case "extend":
10656
- return _objectSpread__default["default"](_objectSpread__default["default"]({}, acc), object[proxy.$$reversedRef]);
10657
- // istanbul ignore next: should never reach
10658
-
10659
- default:
10660
- throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
10661
- }
10662
- }, computedBaseValue);
10663
- }
10664
-
10665
10771
  function collectMergeBases(conf, mergeBases, contextInTemplate, refToBrickConf) {
10666
10772
  var mergeBaseMap;
10667
10773
 
@@ -10856,15 +10962,6 @@
10856
10962
  } = brickConfInTemplate,
10857
10963
  restBrickConfInTemplate = _objectWithoutProperties__default["default"](brickConfInTemplate, _excluded2);
10858
10964
 
10859
- var {
10860
- reversedProxies,
10861
- templateProperties,
10862
- externalSlots,
10863
- templateContextId,
10864
- proxyBrick
10865
- } = proxyContext;
10866
- var computedPropsFromProxy = {};
10867
- var refForProxy;
10868
10965
  var slots = Object.fromEntries(Object.entries(slotsInTemplate !== null && slotsInTemplate !== void 0 ? slotsInTemplate : {}).map(_ref => {
10869
10966
  var _slotConf$bricks;
10870
10967
 
@@ -10874,95 +10971,10 @@
10874
10971
  bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(item => expandBrickInTemplate(item, proxyContext))
10875
10972
  }];
10876
10973
  }));
10877
- setupUseBrickInTemplate(brickConfInTemplate.properties, templateContextId);
10878
-
10879
- if (ref) {
10880
- refForProxy = {};
10881
- proxyBrick.proxyRefs.set(ref, refForProxy); // Reversed proxies are used for expand storyboard before rendering page.
10882
-
10883
- if (reversedProxies.properties.has(ref)) {
10884
- Object.assign(computedPropsFromProxy, Object.fromEntries(reversedProxies.properties.get(ref).flatMap(item => {
10885
- // `propValue` is computed.
10886
- var propValue = templateProperties === null || templateProperties === void 0 ? void 0 : templateProperties[item.$$reversedRef];
10887
-
10888
- if (isTransformableProperty(item)) {
10889
- return Object.entries(preprocessTransformProperties({
10890
- [item.$$reversedRef]: propValue
10891
- }, item.refTransform));
10892
- }
10893
-
10894
- if (isBasicProperty(item)) {
10895
- return [[item.refProperty, propValue]];
10896
- } // Ignore Variable properties.
10897
- // And mergeable properties are processed later.
10898
-
10899
-
10900
- return [];
10901
- }).filter(item => item[1] !== undefined)));
10902
- } // Brick properties can be merged multiple times.
10903
-
10904
-
10905
- if (reversedProxies.mergeBases.has(ref)) {
10906
- Object.assign(computedPropsFromProxy, Object.fromEntries(Array.from(reversedProxies.mergeBases.get(ref).entries()).map(_ref2 => {
10907
- var [mergeProperty, mergeBase] = _ref2;
10908
- return [mergeProperty, propertyMergeAll(mergeBase, templateProperties !== null && templateProperties !== void 0 ? templateProperties : {})];
10909
- }).filter(item => item[1] !== undefined)));
10910
- } // Use an approach like template-literal's quasis:
10911
- // `quasi0${0}quais1${1}quasi2...`
10912
- // Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.
10913
-
10914
-
10915
- var quasisMap = new Map();
10916
-
10917
- if (reversedProxies.slots.has(ref)) {
10918
- for (var item of reversedProxies.slots.get(ref)) {
10919
- var _item$refPosition, _externalSlots$item$$, _externalSlots$item$$2;
10920
-
10921
- if (!quasisMap.has(item.refSlot)) {
10922
- var quasis = []; // The size of quasis should be the existed slotted bricks' size plus one.
10923
-
10924
- var size = brickUtils.hasOwnProperty(slots, item.refSlot) ? slots[item.refSlot].bricks.length + 1 : 1;
10925
-
10926
- for (var i = 0; i < size; i += 1) {
10927
- quasis.push([]);
10928
- }
10929
-
10930
- quasisMap.set(item.refSlot, quasis);
10931
- }
10932
-
10933
- var expandableSlot = quasisMap.get(item.refSlot);
10934
- var refPosition = (_item$refPosition = item.refPosition) !== null && _item$refPosition !== void 0 ? _item$refPosition : -1;
10935
- expandableSlot[lodash.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$$ : []));
10936
- }
10937
- }
10938
-
10939
- var _loop = function (slotName, _quasis) {
10940
- if (!brickUtils.hasOwnProperty(slots, slotName)) {
10941
- slots[slotName] = {
10942
- type: "bricks",
10943
- bricks: []
10944
- };
10945
- }
10946
-
10947
- var slotConf = slots[slotName];
10948
- slotConf.bricks = _quasis.flatMap((bricks, index) => index < slotConf.bricks.length ? bricks.concat(slotConf.bricks[index]) : bricks);
10949
-
10950
- if (slotConf.bricks.length === 0) {
10951
- delete slots[slotName];
10952
- }
10953
- };
10954
-
10955
- for (var [slotName, _quasis] of quasisMap.entries()) {
10956
- _loop(slotName, _quasis);
10957
- }
10958
- }
10959
-
10974
+ setupUseBrickInTemplate(brickConfInTemplate.properties, proxyContext);
10960
10975
  return _objectSpread__default["default"](_objectSpread__default["default"]({}, restBrickConfInTemplate), {}, {
10961
- slots,
10962
- [symbolForComputedPropsFromProxy]: computedPropsFromProxy,
10963
- [symbolForRefForProxy]: refForProxy,
10964
- [symbolForTplContextId]: templateContextId
10965
- });
10976
+ slots
10977
+ }, setupTemplateProxy(proxyContext, ref, slots));
10966
10978
  }
10967
10979
 
10968
10980
  // Otherwise, return false.
@@ -11569,19 +11581,7 @@
11569
11581
  return location;
11570
11582
  }
11571
11583
 
11572
- var setProxyRefForSlots = slots => {
11573
- slotsToChildren(slots).forEach(item => {
11574
- if (item[symbolForRefForProxy] !== undefined) {
11575
- item[symbolForRefForProxy].brick = item;
11576
- }
11577
-
11578
- if (!lodash.isEmpty(item.slots)) {
11579
- setProxyRefForSlots(item.slots);
11580
- }
11581
- });
11582
- };
11583
-
11584
- var setProxyRef = (useBrick, tplTagName, brick) => {
11584
+ var expandTemplateInUseBrick = (useBrick, tplTagName, brick) => {
11585
11585
  var template;
11586
11586
 
11587
11587
  if (tplTagName) {
@@ -11595,10 +11595,8 @@
11595
11595
  slots: useBrick.slots
11596
11596
  };
11597
11597
  template = expandCustomTemplate(tplConf, brick, _internalApiGetCurrentContext());
11598
- setProxyRefForSlots(template.slots);
11599
11598
  } else if (useBrick[symbolForRefForProxy]) {
11600
11599
  useBrick[symbolForRefForProxy].brick = brick;
11601
- setProxyRefForSlots(useBrick.slots);
11602
11600
  }
11603
11601
 
11604
11602
  return template;
@@ -11630,64 +11628,6 @@
11630
11628
  }));
11631
11629
  return brick;
11632
11630
  };
11633
-
11634
- var handleProxyOfParentTemplate = (brick, tplContextId) => {
11635
- if (tplContextId) {
11636
- var tplBrick = getCustomTemplateContext(tplContextId).getBrick();
11637
- /**
11638
- * 如果存在brick.ref, 表明当前brick为custom-template对外暴露的插槽部分
11639
- * 此部分构件不被 expandCustomTemplate 方法正常解析, 需要额外处理
11640
- * 保证父构件上proxyRefs指向的准确性, 并执行其代理方法属性
11641
- */
11642
-
11643
- if (brick.ref && tplBrick) {
11644
- var getFilterProxy = function () {
11645
- var proxy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
11646
- var ref = arguments.length > 1 ? arguments[1] : undefined;
11647
-
11648
- var getFilterByRef = (obj, ref) => {
11649
- if (!obj) return;
11650
- return Object.fromEntries(Object.entries(obj).filter(_ref => {
11651
- var [k, v] = _ref;
11652
-
11653
- if (v.ref === ref) {
11654
- return [k, v];
11655
- }
11656
- }));
11657
- };
11658
-
11659
- var events = getFilterByRef(proxy.events, ref);
11660
- var properties = getFilterByRef(proxy.properties, ref);
11661
- var methods = getFilterByRef(proxy.methods, ref);
11662
- var $$properties = getFilterByRef(proxy.$$properties, ref);
11663
- return {
11664
- $$properties,
11665
- events,
11666
- properties,
11667
- methods
11668
- };
11669
- };
11670
-
11671
- var proxyBrick = _objectSpread__default["default"](_objectSpread__default["default"]({}, tplBrick), {}, {
11672
- element: brick.element
11673
- });
11674
-
11675
- tplBrick.proxyRefs.set(brick.ref, {
11676
- brick: proxyBrick
11677
- }); // 对单独ref brick进行proxy赋值
11678
-
11679
- var singleRefBrickProxyMap = new Map();
11680
- singleRefBrickProxyMap.set(brick.ref, {
11681
- brick: proxyBrick
11682
- });
11683
- handleProxyOfCustomTemplate(_objectSpread__default["default"](_objectSpread__default["default"]({}, tplBrick), {}, {
11684
- proxyRefs: singleRefBrickProxyMap,
11685
- proxy: getFilterProxy(tplBrick.proxy, brick.ref)
11686
- }));
11687
- setRealProperties(tplBrick.element, tplBrick.properties || {});
11688
- }
11689
- }
11690
- };
11691
11631
  /**
11692
11632
  * 可以渲染单个 `useBrick` 的 React 组件。
11693
11633
  *
@@ -11705,7 +11645,8 @@
11705
11645
  * @param props - 属性。
11706
11646
  */
11707
11647
 
11708
- var SingleBrickAsComponent = /*#__PURE__*/React__default["default"].memo(function SingleBrickAsComponent(_ref2) {
11648
+
11649
+ var SingleBrickAsComponent = /*#__PURE__*/React__default["default"].memo(function SingleBrickAsComponent(_ref) {
11709
11650
  var _internalApiGetCurren, _templateRef$current$, _templateRef$current, _templateRef$current2;
11710
11651
 
11711
11652
  var {
@@ -11713,7 +11654,7 @@
11713
11654
  data,
11714
11655
  refCallback,
11715
11656
  immediatelyRefCallback
11716
- } = _ref2;
11657
+ } = _ref;
11717
11658
  var templateRef = React.useRef();
11718
11659
  var tplTagName = getTagNameOfCustomTemplate(useBrick.brick, (_internalApiGetCurren = _internalApiGetCurrentContext().app) === null || _internalApiGetCurren === void 0 ? void 0 : _internalApiGetCurren.id);
11719
11660
  var isBrickAvailable = React__default["default"].useMemo(() => {
@@ -11743,15 +11684,15 @@
11743
11684
  _internalApiLoadDynamicBricksInBrickConf(useBrick).catch(handleHttpError);
11744
11685
 
11745
11686
  var brick = getCurrentRunTimeBrick(useBrick, tplTagName, data);
11746
- templateRef.current = setProxyRef(useBrick, tplTagName, brick); // Let `transform` works still.
11687
+ templateRef.current = expandTemplateInUseBrick(useBrick, tplTagName, brick); // Let `transform` works still.
11747
11688
 
11748
11689
  transformProperties(brick.properties, data, useBrick.transform, useBrick.transformFrom, undefined, {
11749
11690
  allowInject: true
11750
11691
  }); // 设置 properties refProperty值
11751
11692
 
11752
11693
  if (useBrick[symbolForComputedPropsFromProxy]) {
11753
- Object.entries(useBrick[symbolForComputedPropsFromProxy]).forEach(_ref4 => {
11754
- var [propName, propValue] = _ref4;
11694
+ Object.entries(useBrick[symbolForComputedPropsFromProxy]).forEach(_ref3 => {
11695
+ var [propName, propValue] = _ref3;
11755
11696
  lodash.set(brick.properties, propName, propValue);
11756
11697
  });
11757
11698
  }
@@ -11770,7 +11711,7 @@
11770
11711
  return brick;
11771
11712
  }), [useBrick, data, isBrickAvailable]);
11772
11713
  var innerRefCallback = React__default["default"].useCallback( /*#__PURE__*/function () {
11773
- var _ref5 = _asyncToGenerator__default["default"](function* (element) {
11714
+ var _ref4 = _asyncToGenerator__default["default"](function* (element) {
11774
11715
  immediatelyRefCallback === null || immediatelyRefCallback === void 0 ? void 0 : immediatelyRefCallback(element);
11775
11716
 
11776
11717
  if (element) {
@@ -11807,7 +11748,6 @@
11807
11748
 
11808
11749
 
11809
11750
  handleProxyOfCustomTemplate(brick);
11810
- handleProxyOfParentTemplate(brick, tplContextId);
11811
11751
 
11812
11752
  if (element.$$typeof !== "custom-template") {
11813
11753
  if (!useBrick.brick.includes("-")) {
@@ -11822,7 +11762,7 @@
11822
11762
  });
11823
11763
 
11824
11764
  return function (_x) {
11825
- return _ref5.apply(this, arguments);
11765
+ return _ref4.apply(this, arguments);
11826
11766
  };
11827
11767
  }(), [runtimeBrick, useBrick, data, refCallback, immediatelyRefCallback]);
11828
11768
 
@@ -11857,11 +11797,11 @@
11857
11797
  * @param props - 属性。
11858
11798
  */
11859
11799
 
11860
- function BrickAsComponent(_ref6) {
11800
+ function BrickAsComponent(_ref5) {
11861
11801
  var {
11862
11802
  useBrick,
11863
11803
  data
11864
- } = _ref6;
11804
+ } = _ref5;
11865
11805
 
11866
11806
  if (Array.isArray(useBrick)) {
11867
11807
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, useBrick.map((item, index) => /*#__PURE__*/React__default["default"].createElement(SingleBrickAsComponent, {
@@ -11882,8 +11822,8 @@
11882
11822
  return [];
11883
11823
  }
11884
11824
 
11885
- return Object.entries(slots).flatMap(_ref7 => {
11886
- var [slot, slotConf] = _ref7;
11825
+ return Object.entries(slots).flatMap(_ref6 => {
11826
+ var [slot, slotConf] = _ref6;
11887
11827
  return Array.isArray(slotConf.bricks) ? slotConf.bricks.map(child => _objectSpread__default["default"](_objectSpread__default["default"]({}, child), {}, {
11888
11828
  properties: _objectSpread__default["default"](_objectSpread__default["default"]({}, child.properties), {}, {
11889
11829
  slot
@@ -11903,14 +11843,14 @@
11903
11843
  // eslint-disable-next-line react/display-name
11904
11844
 
11905
11845
 
11906
- var ForwardRefSingleBrickAsComponent = /*#__PURE__*/React__default["default"].memo( /*#__PURE__*/React.forwardRef(function LegacySingleBrickAsComponent(_ref8, ref) {
11846
+ var ForwardRefSingleBrickAsComponent = /*#__PURE__*/React__default["default"].memo( /*#__PURE__*/React.forwardRef(function LegacySingleBrickAsComponent(_ref7, ref) {
11907
11847
  var _internalApiGetCurren2, _templateRef$current$2, _templateRef$current3, _templateRef$current4;
11908
11848
 
11909
11849
  var {
11910
11850
  useBrick,
11911
11851
  data,
11912
11852
  refCallback
11913
- } = _ref8;
11853
+ } = _ref7;
11914
11854
  var brickRef = React.useRef();
11915
11855
  var templateRef = React.useRef();
11916
11856
  var tplTagName = getTagNameOfCustomTemplate(useBrick.brick, (_internalApiGetCurren2 = _internalApiGetCurrentContext().app) === null || _internalApiGetCurren2 === void 0 ? void 0 : _internalApiGetCurren2.id);
@@ -11946,15 +11886,15 @@
11946
11886
  _internalApiLoadDynamicBricksInBrickConf(useBrick).catch(handleHttpError);
11947
11887
 
11948
11888
  var brick = getCurrentRunTimeBrick(useBrick, tplTagName, data);
11949
- templateRef.current = setProxyRef(useBrick, tplTagName, brick); // Let `transform` works still.
11889
+ templateRef.current = expandTemplateInUseBrick(useBrick, tplTagName, brick); // Let `transform` works still.
11950
11890
 
11951
11891
  transformProperties(brick.properties, data, useBrick.transform, useBrick.transformFrom, undefined, {
11952
11892
  allowInject: true
11953
11893
  }); // 设置 properties refProperty值
11954
11894
 
11955
11895
  if (useBrick[symbolForComputedPropsFromProxy]) {
11956
- Object.entries(useBrick[symbolForComputedPropsFromProxy]).forEach(_ref10 => {
11957
- var [propName, propValue] = _ref10;
11896
+ Object.entries(useBrick[symbolForComputedPropsFromProxy]).forEach(_ref9 => {
11897
+ var [propName, propValue] = _ref9;
11958
11898
  lodash.set(brick.properties, propName, propValue);
11959
11899
  });
11960
11900
  }
@@ -11973,7 +11913,7 @@
11973
11913
  return brick;
11974
11914
  }), [useBrick, data, isBrickAvailable]);
11975
11915
  var innerRefCallback = React__default["default"].useCallback( /*#__PURE__*/function () {
11976
- var _ref11 = _asyncToGenerator__default["default"](function* (element) {
11916
+ var _ref10 = _asyncToGenerator__default["default"](function* (element) {
11977
11917
  brickRef.current = element;
11978
11918
 
11979
11919
  if (element) {
@@ -12010,7 +11950,6 @@
12010
11950
 
12011
11951
 
12012
11952
  handleProxyOfCustomTemplate(brick);
12013
- handleProxyOfParentTemplate(brick, tplContextId);
12014
11953
 
12015
11954
  if (element.$$typeof !== "custom-template") {
12016
11955
  if (!useBrick.brick.includes("-")) {
@@ -12025,7 +11964,7 @@
12025
11964
  });
12026
11965
 
12027
11966
  return function (_x2) {
12028
- return _ref11.apply(this, arguments);
11967
+ return _ref10.apply(this, arguments);
12029
11968
  };
12030
11969
  }(), [runtimeBrick, useBrick, data, refCallback]);
12031
11970