@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.
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, clamp, isEmpty, noop, isObject as isObject$1, isString } from 'lodash';
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 setupUseBrickInTemplate(props, tplContextId) {
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
- item[symbolForTplContextId] = tplContextId;
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, context.tplContextId);
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, templateContextId);
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
- [symbolForComputedPropsFromProxy]: computedPropsFromProxy,
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 setProxyRefForSlots = slots => {
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;
@@ -11631,64 +11629,6 @@ var getCurrentRunTimeBrick = (useBrick, tplTagName, data) => {
11631
11629
  }));
11632
11630
  return brick;
11633
11631
  };
11634
-
11635
- var handleProxyOfParentTemplate = (brick, tplContextId) => {
11636
- if (tplContextId) {
11637
- var tplBrick = getCustomTemplateContext(tplContextId).getBrick();
11638
- /**
11639
- * 如果存在brick.ref, 表明当前brick为custom-template对外暴露的插槽部分
11640
- * 此部分构件不被 expandCustomTemplate 方法正常解析, 需要额外处理
11641
- * 保证父构件上proxyRefs指向的准确性, 并执行其代理方法属性
11642
- */
11643
-
11644
- if (brick.ref && tplBrick) {
11645
- var getFilterProxy = function () {
11646
- var proxy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
11647
- var ref = arguments.length > 1 ? arguments[1] : undefined;
11648
-
11649
- var getFilterByRef = (obj, ref) => {
11650
- if (!obj) return;
11651
- return Object.fromEntries(Object.entries(obj).filter(_ref => {
11652
- var [k, v] = _ref;
11653
-
11654
- if (v.ref === ref) {
11655
- return [k, v];
11656
- }
11657
- }));
11658
- };
11659
-
11660
- var events = getFilterByRef(proxy.events, ref);
11661
- var properties = getFilterByRef(proxy.properties, ref);
11662
- var methods = getFilterByRef(proxy.methods, ref);
11663
- var $$properties = getFilterByRef(proxy.$$properties, ref);
11664
- return {
11665
- $$properties,
11666
- events,
11667
- properties,
11668
- methods
11669
- };
11670
- };
11671
-
11672
- var proxyBrick = _objectSpread(_objectSpread({}, tplBrick), {}, {
11673
- element: brick.element
11674
- });
11675
-
11676
- tplBrick.proxyRefs.set(brick.ref, {
11677
- brick: proxyBrick
11678
- }); // 对单独ref brick进行proxy赋值
11679
-
11680
- var singleRefBrickProxyMap = new Map();
11681
- singleRefBrickProxyMap.set(brick.ref, {
11682
- brick: proxyBrick
11683
- });
11684
- handleProxyOfCustomTemplate(_objectSpread(_objectSpread({}, tplBrick), {}, {
11685
- proxyRefs: singleRefBrickProxyMap,
11686
- proxy: getFilterProxy(tplBrick.proxy, brick.ref)
11687
- }));
11688
- setRealProperties(tplBrick.element, tplBrick.properties || {});
11689
- }
11690
- }
11691
- };
11692
11632
  /**
11693
11633
  * 可以渲染单个 `useBrick` 的 React 组件。
11694
11634
  *
@@ -11706,7 +11646,8 @@ var handleProxyOfParentTemplate = (brick, tplContextId) => {
11706
11646
  * @param props - 属性。
11707
11647
  */
11708
11648
 
11709
- var SingleBrickAsComponent = /*#__PURE__*/React.memo(function SingleBrickAsComponent(_ref2) {
11649
+
11650
+ var SingleBrickAsComponent = /*#__PURE__*/React.memo(function SingleBrickAsComponent(_ref) {
11710
11651
  var _internalApiGetCurren, _templateRef$current$, _templateRef$current, _templateRef$current2;
11711
11652
 
11712
11653
  var {
@@ -11714,7 +11655,7 @@ var SingleBrickAsComponent = /*#__PURE__*/React.memo(function SingleBrickAsCompo
11714
11655
  data,
11715
11656
  refCallback,
11716
11657
  immediatelyRefCallback
11717
- } = _ref2;
11658
+ } = _ref;
11718
11659
  var templateRef = useRef();
11719
11660
  var tplTagName = getTagNameOfCustomTemplate(useBrick.brick, (_internalApiGetCurren = _internalApiGetCurrentContext().app) === null || _internalApiGetCurren === void 0 ? void 0 : _internalApiGetCurren.id);
11720
11661
  var isBrickAvailable = React.useMemo(() => {
@@ -11744,15 +11685,15 @@ var SingleBrickAsComponent = /*#__PURE__*/React.memo(function SingleBrickAsCompo
11744
11685
  _internalApiLoadDynamicBricksInBrickConf(useBrick).catch(handleHttpError);
11745
11686
 
11746
11687
  var brick = getCurrentRunTimeBrick(useBrick, tplTagName, data);
11747
- templateRef.current = setProxyRef(useBrick, tplTagName, brick); // Let `transform` works still.
11688
+ templateRef.current = expandTemplateInUseBrick(useBrick, tplTagName, brick); // Let `transform` works still.
11748
11689
 
11749
11690
  transformProperties(brick.properties, data, useBrick.transform, useBrick.transformFrom, undefined, {
11750
11691
  allowInject: true
11751
11692
  }); // 设置 properties refProperty值
11752
11693
 
11753
11694
  if (useBrick[symbolForComputedPropsFromProxy]) {
11754
- Object.entries(useBrick[symbolForComputedPropsFromProxy]).forEach(_ref4 => {
11755
- var [propName, propValue] = _ref4;
11695
+ Object.entries(useBrick[symbolForComputedPropsFromProxy]).forEach(_ref3 => {
11696
+ var [propName, propValue] = _ref3;
11756
11697
  set(brick.properties, propName, propValue);
11757
11698
  });
11758
11699
  }
@@ -11771,7 +11712,7 @@ var SingleBrickAsComponent = /*#__PURE__*/React.memo(function SingleBrickAsCompo
11771
11712
  return brick;
11772
11713
  }), [useBrick, data, isBrickAvailable]);
11773
11714
  var innerRefCallback = React.useCallback( /*#__PURE__*/function () {
11774
- var _ref5 = _asyncToGenerator$4(function* (element) {
11715
+ var _ref4 = _asyncToGenerator$4(function* (element) {
11775
11716
  immediatelyRefCallback === null || immediatelyRefCallback === void 0 ? void 0 : immediatelyRefCallback(element);
11776
11717
 
11777
11718
  if (element) {
@@ -11808,7 +11749,6 @@ var SingleBrickAsComponent = /*#__PURE__*/React.memo(function SingleBrickAsCompo
11808
11749
 
11809
11750
 
11810
11751
  handleProxyOfCustomTemplate(brick);
11811
- handleProxyOfParentTemplate(brick, tplContextId);
11812
11752
 
11813
11753
  if (element.$$typeof !== "custom-template") {
11814
11754
  if (!useBrick.brick.includes("-")) {
@@ -11823,7 +11763,7 @@ var SingleBrickAsComponent = /*#__PURE__*/React.memo(function SingleBrickAsCompo
11823
11763
  });
11824
11764
 
11825
11765
  return function (_x) {
11826
- return _ref5.apply(this, arguments);
11766
+ return _ref4.apply(this, arguments);
11827
11767
  };
11828
11768
  }(), [runtimeBrick, useBrick, data, refCallback, immediatelyRefCallback]);
11829
11769
 
@@ -11858,11 +11798,11 @@ var SingleBrickAsComponent = /*#__PURE__*/React.memo(function SingleBrickAsCompo
11858
11798
  * @param props - 属性。
11859
11799
  */
11860
11800
 
11861
- function BrickAsComponent(_ref6) {
11801
+ function BrickAsComponent(_ref5) {
11862
11802
  var {
11863
11803
  useBrick,
11864
11804
  data
11865
- } = _ref6;
11805
+ } = _ref5;
11866
11806
 
11867
11807
  if (Array.isArray(useBrick)) {
11868
11808
  return /*#__PURE__*/React.createElement(React.Fragment, null, useBrick.map((item, index) => /*#__PURE__*/React.createElement(SingleBrickAsComponent, {
@@ -11883,8 +11823,8 @@ function slotsToChildren(slots) {
11883
11823
  return [];
11884
11824
  }
11885
11825
 
11886
- return Object.entries(slots).flatMap(_ref7 => {
11887
- var [slot, slotConf] = _ref7;
11826
+ return Object.entries(slots).flatMap(_ref6 => {
11827
+ var [slot, slotConf] = _ref6;
11888
11828
  return Array.isArray(slotConf.bricks) ? slotConf.bricks.map(child => _objectSpread(_objectSpread({}, child), {}, {
11889
11829
  properties: _objectSpread(_objectSpread({}, child.properties), {}, {
11890
11830
  slot
@@ -11904,14 +11844,14 @@ function transformEvents(data, events) {
11904
11844
  // eslint-disable-next-line react/display-name
11905
11845
 
11906
11846
 
11907
- var ForwardRefSingleBrickAsComponent = /*#__PURE__*/React.memo( /*#__PURE__*/forwardRef(function LegacySingleBrickAsComponent(_ref8, ref) {
11847
+ var ForwardRefSingleBrickAsComponent = /*#__PURE__*/React.memo( /*#__PURE__*/forwardRef(function LegacySingleBrickAsComponent(_ref7, ref) {
11908
11848
  var _internalApiGetCurren2, _templateRef$current$2, _templateRef$current3, _templateRef$current4;
11909
11849
 
11910
11850
  var {
11911
11851
  useBrick,
11912
11852
  data,
11913
11853
  refCallback
11914
- } = _ref8;
11854
+ } = _ref7;
11915
11855
  var brickRef = useRef();
11916
11856
  var templateRef = useRef();
11917
11857
  var tplTagName = getTagNameOfCustomTemplate(useBrick.brick, (_internalApiGetCurren2 = _internalApiGetCurrentContext().app) === null || _internalApiGetCurren2 === void 0 ? void 0 : _internalApiGetCurren2.id);
@@ -11947,15 +11887,15 @@ var ForwardRefSingleBrickAsComponent = /*#__PURE__*/React.memo( /*#__PURE__*/for
11947
11887
  _internalApiLoadDynamicBricksInBrickConf(useBrick).catch(handleHttpError);
11948
11888
 
11949
11889
  var brick = getCurrentRunTimeBrick(useBrick, tplTagName, data);
11950
- templateRef.current = setProxyRef(useBrick, tplTagName, brick); // Let `transform` works still.
11890
+ templateRef.current = expandTemplateInUseBrick(useBrick, tplTagName, brick); // Let `transform` works still.
11951
11891
 
11952
11892
  transformProperties(brick.properties, data, useBrick.transform, useBrick.transformFrom, undefined, {
11953
11893
  allowInject: true
11954
11894
  }); // 设置 properties refProperty值
11955
11895
 
11956
11896
  if (useBrick[symbolForComputedPropsFromProxy]) {
11957
- Object.entries(useBrick[symbolForComputedPropsFromProxy]).forEach(_ref10 => {
11958
- var [propName, propValue] = _ref10;
11897
+ Object.entries(useBrick[symbolForComputedPropsFromProxy]).forEach(_ref9 => {
11898
+ var [propName, propValue] = _ref9;
11959
11899
  set(brick.properties, propName, propValue);
11960
11900
  });
11961
11901
  }
@@ -11974,7 +11914,7 @@ var ForwardRefSingleBrickAsComponent = /*#__PURE__*/React.memo( /*#__PURE__*/for
11974
11914
  return brick;
11975
11915
  }), [useBrick, data, isBrickAvailable]);
11976
11916
  var innerRefCallback = React.useCallback( /*#__PURE__*/function () {
11977
- var _ref11 = _asyncToGenerator$4(function* (element) {
11917
+ var _ref10 = _asyncToGenerator$4(function* (element) {
11978
11918
  brickRef.current = element;
11979
11919
 
11980
11920
  if (element) {
@@ -12011,7 +11951,6 @@ var ForwardRefSingleBrickAsComponent = /*#__PURE__*/React.memo( /*#__PURE__*/for
12011
11951
 
12012
11952
 
12013
11953
  handleProxyOfCustomTemplate(brick);
12014
- handleProxyOfParentTemplate(brick, tplContextId);
12015
11954
 
12016
11955
  if (element.$$typeof !== "custom-template") {
12017
11956
  if (!useBrick.brick.includes("-")) {
@@ -12026,7 +11965,7 @@ var ForwardRefSingleBrickAsComponent = /*#__PURE__*/React.memo( /*#__PURE__*/for
12026
11965
  });
12027
11966
 
12028
11967
  return function (_x2) {
12029
- return _ref11.apply(this, arguments);
11968
+ return _ref10.apply(this, arguments);
12030
11969
  };
12031
11970
  }(), [runtimeBrick, useBrick, data, refCallback]);
12032
11971