@next-core/brick-kit 2.165.6 → 2.165.7

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
@@ -3,7 +3,7 @@ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
3
3
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
4
4
  import _defineProperty$1 from '@babel/runtime/helpers/defineProperty';
5
5
  import _asyncToGenerator$3 from '@babel/runtime/helpers/asyncToGenerator';
6
- import _, { set, get, difference, identity, uniqueId, cloneDeep, clamp, isNil, isEmpty, merge, sortBy, orderBy, isObject as isObject$1, uniq, pick, omit, findLastIndex, noop, isString as isString$1 } from 'lodash';
6
+ import _, { set, get, difference, identity, uniqueId, cloneDeep, isNil, isEmpty, merge, sortBy, orderBy, isObject as isObject$1, clamp, uniq, pick, omit, findLastIndex, noop, isString as isString$1 } from 'lodash';
7
7
  import { JsonStorage, toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable, transformAndInject, transform, trackContext, trackState, trackFormState, scanPermissionActionsInStoryboard, precookFunction, cook, collectContextUsage, deferResolveContextConcurrently, resolveContextConcurrently, syncResolveContextConcurrently, trackUsedFormState, trackUsedState, trackUsedContext, shouldAllowRecursiveEvaluations, preevaluate, inject, scanPermissionActionsInAny, deepFreeze, matchPath, asyncProcessBrick, createProviderClass, removeDeadConditionsInTpl, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, getDllAndDepsByResource, scanRouteAliasInStoryboard, prefetchScript, scanBricksInBrickConf, scanProcessorsInAny, loadScript, scanAppGetMenuInAny, scanInstalledAppsInStoryboard, removeDeadConditions, restoreDynamicTemplates, scanStoryboard, mapCustomApisToNameAndNamespace } from '@next-core/brick-utils';
8
8
  import React, { useState, useEffect, useRef, useMemo, useCallback, forwardRef, useImperativeHandle, useContext, createContext, useReducer } from 'react';
9
9
  import { http, HttpResponseError, HttpAbortError, HttpFetchError } from '@next-core/brick-http';
@@ -2416,232 +2416,6 @@ function evaluate(raw) {
2416
2416
  }
2417
2417
  }
2418
2418
 
2419
- function isBasicProperty(propRef) {
2420
- return !!propRef.refProperty;
2421
- }
2422
- function isTransformableProperty(propRef) {
2423
- return !!propRef.refTransform;
2424
- }
2425
- function isMergeableProperty(propRef) {
2426
- return !!propRef.mergeProperty;
2427
- }
2428
- function isRefProperty(propRef) {
2429
- return !!propRef.ref;
2430
- }
2431
- function isVariableProperty(propRef) {
2432
- return !!propRef.asVariable;
2433
- }
2434
-
2435
- var customTemplateRegistry = new Map();
2436
- var appRegistered = new Set();
2437
- var symbolForComputedPropsFromProxy = Symbol.for("tpl.computedPropsFromProxy");
2438
- var symbolForRefForProxy = Symbol.for("tpl.refForProxy");
2439
- var symbolForTplContextId = Symbol.for("tpl.contextId");
2440
-
2441
- function propertyMerge(conf, value, object) {
2442
- return propertyMergeAll(conf.$$mergeBase, Object.fromEntries(conf.$$mergeBase.proxies.map(proxy => [proxy.$$reversedRef, proxy === conf ? value : object[proxy.$$reversedRef]])));
2443
- }
2444
- function propertyMergeAll(mergeBase, object) {
2445
- if (mergeBase.mergeType === "array") {
2446
- return propertyMergeAllOfArray(mergeBase, object);
2447
- }
2448
- if (mergeBase.mergeType === "object") {
2449
- return propertyMergeAllOfObject(mergeBase, object);
2450
- }
2451
- // istanbul ignore next: should never reach
2452
- throw new TypeError("unsupported mergeType: \"".concat(mergeBase.mergeType, "\""));
2453
- }
2454
- function propertyMergeAllOfArray(_ref, object) {
2455
- var _, _proxy$mergeArgs;
2456
- var {
2457
- baseValue,
2458
- context,
2459
- proxies
2460
- } = _ref;
2461
- // Use an approach like template-literal's quasis:
2462
- // `quasi0${0}quais1${1}quasi2...`
2463
- // Every quasi can be merged with multiple items.
2464
- var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true, {
2465
- $$lazyForUseBrick: true
2466
- }) : [];
2467
- var quasis = [];
2468
- var size = computedBaseValue.length + 1;
2469
- for (var i = 0; i < size; i += 1) {
2470
- quasis.push([]);
2471
- }
2472
- for (var proxy of proxies) {
2473
- var position = void 0;
2474
- switch (proxy.mergeMethod) {
2475
- case "append":
2476
- position = computedBaseValue.length;
2477
- break;
2478
- case "prepend":
2479
- position = 0;
2480
- break;
2481
- case "insertAt":
2482
- // Defaults to `-1`.
2483
- position = (_ = (_proxy$mergeArgs = proxy.mergeArgs) === null || _proxy$mergeArgs === void 0 ? void 0 : _proxy$mergeArgs[0]) !== null && _ !== void 0 ? _ : -1;
2484
- if (position < 0) {
2485
- // It's counted from the end if position is negative.
2486
- position += quasis.length;
2487
- }
2488
- position = clamp(position, 0, computedBaseValue.length);
2489
- break;
2490
- // istanbul ignore next: should never reach
2491
- default:
2492
- throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
2493
- }
2494
- var patchValue = object[proxy.$$reversedRef];
2495
- if (!Array.isArray(patchValue)) {
2496
- patchValue = [];
2497
- }
2498
- quasis[position].push(...patchValue);
2499
- }
2500
- return quasis.flatMap((item, index) => index < computedBaseValue.length ? item.concat(computedBaseValue[index]) : item);
2501
- }
2502
- function propertyMergeAllOfObject(_ref2, object) {
2503
- var {
2504
- baseValue,
2505
- proxies,
2506
- context
2507
- } = _ref2;
2508
- var computedBaseValue = isObject(baseValue) ? computeRealValue(baseValue, context, true) : {};
2509
- return proxies.reduce((acc, proxy) => {
2510
- switch (proxy.mergeMethod) {
2511
- case "extend":
2512
- return _objectSpread(_objectSpread({}, acc), object[proxy.$$reversedRef]);
2513
- // istanbul ignore next: should never reach
2514
- default:
2515
- throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
2516
- }
2517
- }, computedBaseValue);
2518
- }
2519
-
2520
- function setupTemplateProxy(proxyContext, ref, slots) {
2521
- var computedPropsFromProxy = {};
2522
- var refForProxy;
2523
- var {
2524
- reversedProxies,
2525
- templateProperties,
2526
- externalSlots,
2527
- templateContextId,
2528
- proxyBrick
2529
- } = proxyContext;
2530
- if (ref && reversedProxies) {
2531
- refForProxy = {};
2532
- proxyBrick.proxyRefs.set(ref, refForProxy);
2533
-
2534
- // Reversed proxies are used for expand storyboard before rendering page.
2535
- if (reversedProxies.properties.has(ref)) {
2536
- Object.assign(computedPropsFromProxy, Object.fromEntries(reversedProxies.properties.get(ref).flatMap(propRef => {
2537
- // `propValue` is computed.
2538
- var propValue = templateProperties === null || templateProperties === void 0 ? void 0 : templateProperties[propRef.$$reversedRef];
2539
- if (isTransformableProperty(propRef)) {
2540
- return Object.entries(preprocessTransformProperties({
2541
- [propRef.$$reversedRef]: propValue
2542
- }, propRef.refTransform));
2543
- }
2544
- if (isBasicProperty(propRef)) {
2545
- return [[propRef.refProperty, propValue]];
2546
- }
2547
- // Ignore Variable properties.
2548
- // And mergeable properties are processed later.
2549
- return [];
2550
- }).filter(propRef => propRef[1] !== undefined)));
2551
-
2552
- // Brick properties can be merged multiple times.
2553
- if (reversedProxies.mergeBases.has(ref)) {
2554
- Object.assign(computedPropsFromProxy, Object.fromEntries(Array.from(reversedProxies.mergeBases.get(ref).entries()).map(_ref => {
2555
- var [mergeProperty, mergeBase] = _ref;
2556
- return [mergeProperty, propertyMergeAll(mergeBase, templateProperties !== null && templateProperties !== void 0 ? templateProperties : {})];
2557
- }).filter(item => item[1] !== undefined)));
2558
- }
2559
- }
2560
-
2561
- // Use an approach like template-literal's quasis:
2562
- // `quasi0${0}quais1${1}quasi2...`
2563
- // Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.
2564
- var quasisMap = new Map();
2565
- if (reversedProxies.slots.has(ref)) {
2566
- for (var item of reversedProxies.slots.get(ref)) {
2567
- var _item$refPosition, _externalSlots$item$$, _externalSlots$item$$2;
2568
- if (!quasisMap.has(item.refSlot)) {
2569
- var quasis = [];
2570
- // The size of quasis should be the existed slotted bricks' size plus one.
2571
- var size = hasOwnProperty(slots, item.refSlot) ? slots[item.refSlot].bricks.length + 1 : 1;
2572
- for (var i = 0; i < size; i += 1) {
2573
- quasis.push([]);
2574
- }
2575
- quasisMap.set(item.refSlot, quasis);
2576
- }
2577
- var expandableSlot = quasisMap.get(item.refSlot);
2578
- var refPosition = (_item$refPosition = item.refPosition) !== null && _item$refPosition !== void 0 ? _item$refPosition : -1;
2579
- 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$$ : []));
2580
- }
2581
- }
2582
- var _loop = function (slotName, _quasis) {
2583
- if (!hasOwnProperty(slots, slotName)) {
2584
- slots[slotName] = {
2585
- type: "bricks",
2586
- bricks: []
2587
- };
2588
- }
2589
- var slotConf = slots[slotName];
2590
- slotConf.bricks = _quasis.flatMap((bricks, index) => index < slotConf.bricks.length ? bricks.concat(slotConf.bricks[index]) : bricks);
2591
- if (slotConf.bricks.length === 0) {
2592
- delete slots[slotName];
2593
- }
2594
- };
2595
- for (var [slotName, _quasis] of quasisMap.entries()) {
2596
- _loop(slotName, _quasis);
2597
- }
2598
- }
2599
- return {
2600
- [symbolForComputedPropsFromProxy]: computedPropsFromProxy,
2601
- [symbolForRefForProxy]: refForProxy,
2602
- [symbolForTplContextId]: templateContextId
2603
- };
2604
- }
2605
-
2606
- function setupUseBrickInTemplate(props, proxyContext) {
2607
- function walk(props) {
2608
- if (!props) {
2609
- return;
2610
- }
2611
- for (var [key, value] of Object.entries(props)) {
2612
- if (isObject(value)) {
2613
- if (key === "useBrick") {
2614
- if (Array.isArray(value)) {
2615
- value.forEach(setup);
2616
- } else {
2617
- setup(value);
2618
- }
2619
- } else {
2620
- walk(value);
2621
- }
2622
- }
2623
- }
2624
- }
2625
- function setup(item) {
2626
- var {
2627
- ref,
2628
- slots: slotsInTemplate
2629
- } = item;
2630
- item.slots = Object.fromEntries(Object.entries(slotsInTemplate !== null && slotsInTemplate !== void 0 ? slotsInTemplate : {}).map(_ref => {
2631
- var _slotConf$bricks;
2632
- var [slotName, slotConf] = _ref;
2633
- return [slotName, {
2634
- type: "bricks",
2635
- bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(setup)
2636
- }];
2637
- }));
2638
- Object.assign(item, setupTemplateProxy(proxyContext, ref, item.slots));
2639
- walk(item.properties);
2640
- return item;
2641
- }
2642
- walk(props);
2643
- }
2644
-
2645
2419
  var computeRealValue = (value, context, injectDeep, internalOptions) => {
2646
2420
  var preEvaluated = isPreEvaluated(value);
2647
2421
  if (preEvaluated || typeof value === "string") {
@@ -2693,11 +2467,6 @@ var computeRealValue = (value, context, injectDeep, internalOptions) => {
2693
2467
  };
2694
2468
  function setProperties(bricks, properties, context, injectDeep) {
2695
2469
  var realProps = computeRealProperties(properties, context, injectDeep);
2696
- if (context.tplContextId) {
2697
- setupUseBrickInTemplate(realProps, {
2698
- templateContextId: context.tplContextId
2699
- });
2700
- }
2701
2470
  if (!Array.isArray(bricks)) {
2702
2471
  bricks = [bricks];
2703
2472
  }
@@ -2765,7 +2534,7 @@ function getNextInternalOptions(internalOptions, isArray, key) {
2765
2534
  }) : internalOptions;
2766
2535
  }
2767
2536
 
2768
- var _excluded$6 = ["children"],
2537
+ var _excluded$7 = ["children"],
2769
2538
  _excluded2$2 = ["children"],
2770
2539
  _excluded3 = ["items", "app"];
2771
2540
  var symbolAppId = Symbol("appId");
@@ -3028,7 +2797,7 @@ function collectAppsRequireI18nFulfilled(items, contextAppId, appIds) {
3028
2797
  var {
3029
2798
  children
3030
2799
  } = _ref,
3031
- rest = _objectWithoutProperties(_ref, _excluded$6);
2800
+ rest = _objectWithoutProperties(_ref, _excluded$7);
3032
2801
  var overrideAppId = rest[symbolAppId];
3033
2802
  if (!rest[symbolMenuI18nNamespace] && overrideAppId !== contextAppId && !appIds.has(overrideAppId) && attemptToVisit(rest, ["I18N"])) {
3034
2803
  appIds.add(overrideAppId);
@@ -3650,7 +3419,7 @@ function _internalApiLoadDynamicBricksInBrickConf(brickConf) {
3650
3419
  return kernel.loadDynamicBricksInBrickConf(brickConf);
3651
3420
  }
3652
3421
 
3653
- var _excluded$5 = ["extraQuery", "clear", "keepHash"];
3422
+ var _excluded$6 = ["extraQuery", "clear", "keepHash"];
3654
3423
  var blocked = false;
3655
3424
  function getUserConfirmation(message, callback) {
3656
3425
  blocked = !confirm(message);
@@ -3680,7 +3449,7 @@ function historyExtended(browserHistory) {
3680
3449
  clear,
3681
3450
  keepHash
3682
3451
  } = options,
3683
- state = _objectWithoutProperties(options, _excluded$5);
3452
+ state = _objectWithoutProperties(options, _excluded$6);
3684
3453
  var urlSearchParams = new URLSearchParams(clear ? "" : browserHistory.location.search);
3685
3454
  var params = {};
3686
3455
  Object.assign(params, query, extraQuery);
@@ -6751,7 +6520,7 @@ var RuntimeApi_searchMicroAppStandalone = /*#__PURE__*/function () {
6751
6520
  };
6752
6521
  }();
6753
6522
 
6754
- var _excluded$4 = ["feature_flags"],
6523
+ var _excluded$5 = ["feature_flags"],
6755
6524
  _excluded2$1 = ["featureFlags", "misc"];
6756
6525
  function standaloneBootstrap() {
6757
6526
  return _standaloneBootstrap.apply(this, arguments);
@@ -6797,7 +6566,7 @@ function _standaloneBootstrap() {
6797
6566
  var {
6798
6567
  feature_flags: featureFlags
6799
6568
  } = sys_settings,
6800
- rest = _objectWithoutProperties(sys_settings, _excluded$4);
6569
+ rest = _objectWithoutProperties(sys_settings, _excluded$5);
6801
6570
  settings = _objectSpread({
6802
6571
  featureFlags
6803
6572
  }, rest);
@@ -7755,6 +7524,28 @@ var formRenderer = "form-renderer.form-renderer";
7755
7524
  var filterProperties = ["instanceId", "brick", "slots", "properties", "events", "if", "context", "bricks", "mountPoint"];
7756
7525
  var symbolForFormContextId = Symbol.for("form.contextId");
7757
7526
 
7527
+ var customTemplateRegistry = new Map();
7528
+ var appRegistered = new Set();
7529
+ var symbolForComputedPropsFromProxy = Symbol.for("tpl.computedPropsFromProxy");
7530
+ var symbolForRefForProxy = Symbol.for("tpl.refForProxy");
7531
+ var symbolForTplContextId = Symbol.for("tpl.contextId");
7532
+
7533
+ function isBasicProperty(propRef) {
7534
+ return !!propRef.refProperty;
7535
+ }
7536
+ function isTransformableProperty(propRef) {
7537
+ return !!propRef.refTransform;
7538
+ }
7539
+ function isMergeableProperty(propRef) {
7540
+ return !!propRef.mergeProperty;
7541
+ }
7542
+ function isRefProperty(propRef) {
7543
+ return !!propRef.ref;
7544
+ }
7545
+ function isVariableProperty(propRef) {
7546
+ return !!propRef.asVariable;
7547
+ }
7548
+
7758
7549
  function collectRefsInTemplate(template) {
7759
7550
  var refMap = new Map();
7760
7551
  collectRefsInBrickConfs(template.bricks, refMap);
@@ -7810,6 +7601,207 @@ function collectMergeBases(conf, mergeBases, contextInTemplate, refToBrickConf)
7810
7601
  }
7811
7602
  }
7812
7603
 
7604
+ function propertyMerge(conf, value, object) {
7605
+ return propertyMergeAll(conf.$$mergeBase, Object.fromEntries(conf.$$mergeBase.proxies.map(proxy => [proxy.$$reversedRef, proxy === conf ? value : object[proxy.$$reversedRef]])));
7606
+ }
7607
+ function propertyMergeAll(mergeBase, object) {
7608
+ if (mergeBase.mergeType === "array") {
7609
+ return propertyMergeAllOfArray(mergeBase, object);
7610
+ }
7611
+ if (mergeBase.mergeType === "object") {
7612
+ return propertyMergeAllOfObject(mergeBase, object);
7613
+ }
7614
+ // istanbul ignore next: should never reach
7615
+ throw new TypeError("unsupported mergeType: \"".concat(mergeBase.mergeType, "\""));
7616
+ }
7617
+ function propertyMergeAllOfArray(_ref, object) {
7618
+ var _, _proxy$mergeArgs;
7619
+ var {
7620
+ baseValue,
7621
+ context,
7622
+ proxies
7623
+ } = _ref;
7624
+ // Use an approach like template-literal's quasis:
7625
+ // `quasi0${0}quais1${1}quasi2...`
7626
+ // Every quasi can be merged with multiple items.
7627
+ var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true, {
7628
+ $$lazyForUseBrick: true
7629
+ }) : [];
7630
+ var quasis = [];
7631
+ var size = computedBaseValue.length + 1;
7632
+ for (var i = 0; i < size; i += 1) {
7633
+ quasis.push([]);
7634
+ }
7635
+ for (var proxy of proxies) {
7636
+ var position = void 0;
7637
+ switch (proxy.mergeMethod) {
7638
+ case "append":
7639
+ position = computedBaseValue.length;
7640
+ break;
7641
+ case "prepend":
7642
+ position = 0;
7643
+ break;
7644
+ case "insertAt":
7645
+ // Defaults to `-1`.
7646
+ position = (_ = (_proxy$mergeArgs = proxy.mergeArgs) === null || _proxy$mergeArgs === void 0 ? void 0 : _proxy$mergeArgs[0]) !== null && _ !== void 0 ? _ : -1;
7647
+ if (position < 0) {
7648
+ // It's counted from the end if position is negative.
7649
+ position += quasis.length;
7650
+ }
7651
+ position = clamp(position, 0, computedBaseValue.length);
7652
+ break;
7653
+ // istanbul ignore next: should never reach
7654
+ default:
7655
+ throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
7656
+ }
7657
+ var patchValue = object[proxy.$$reversedRef];
7658
+ if (!Array.isArray(patchValue)) {
7659
+ patchValue = [];
7660
+ }
7661
+ quasis[position].push(...patchValue);
7662
+ }
7663
+ return quasis.flatMap((item, index) => index < computedBaseValue.length ? item.concat(computedBaseValue[index]) : item);
7664
+ }
7665
+ function propertyMergeAllOfObject(_ref2, object) {
7666
+ var {
7667
+ baseValue,
7668
+ proxies,
7669
+ context
7670
+ } = _ref2;
7671
+ var computedBaseValue = isObject(baseValue) ? computeRealValue(baseValue, context, true) : {};
7672
+ return proxies.reduce((acc, proxy) => {
7673
+ switch (proxy.mergeMethod) {
7674
+ case "extend":
7675
+ return _objectSpread(_objectSpread({}, acc), object[proxy.$$reversedRef]);
7676
+ // istanbul ignore next: should never reach
7677
+ default:
7678
+ throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
7679
+ }
7680
+ }, computedBaseValue);
7681
+ }
7682
+
7683
+ function setupTemplateProxy(proxyContext, ref, slots) {
7684
+ var computedPropsFromProxy = {};
7685
+ var refForProxy;
7686
+ var {
7687
+ reversedProxies,
7688
+ templateProperties,
7689
+ externalSlots,
7690
+ templateContextId,
7691
+ proxyBrick
7692
+ } = proxyContext;
7693
+ if (ref && reversedProxies) {
7694
+ refForProxy = {};
7695
+ proxyBrick.proxyRefs.set(ref, refForProxy);
7696
+
7697
+ // Reversed proxies are used for expand storyboard before rendering page.
7698
+ if (reversedProxies.properties.has(ref)) {
7699
+ Object.assign(computedPropsFromProxy, Object.fromEntries(reversedProxies.properties.get(ref).flatMap(propRef => {
7700
+ // `propValue` is computed.
7701
+ var propValue = templateProperties === null || templateProperties === void 0 ? void 0 : templateProperties[propRef.$$reversedRef];
7702
+ if (isTransformableProperty(propRef)) {
7703
+ return Object.entries(preprocessTransformProperties({
7704
+ [propRef.$$reversedRef]: propValue
7705
+ }, propRef.refTransform));
7706
+ }
7707
+ if (isBasicProperty(propRef)) {
7708
+ return [[propRef.refProperty, propValue]];
7709
+ }
7710
+ // Ignore Variable properties.
7711
+ // And mergeable properties are processed later.
7712
+ return [];
7713
+ }).filter(propRef => propRef[1] !== undefined)));
7714
+
7715
+ // Brick properties can be merged multiple times.
7716
+ if (reversedProxies.mergeBases.has(ref)) {
7717
+ Object.assign(computedPropsFromProxy, Object.fromEntries(Array.from(reversedProxies.mergeBases.get(ref).entries()).map(_ref => {
7718
+ var [mergeProperty, mergeBase] = _ref;
7719
+ return [mergeProperty, propertyMergeAll(mergeBase, templateProperties !== null && templateProperties !== void 0 ? templateProperties : {})];
7720
+ }).filter(item => item[1] !== undefined)));
7721
+ }
7722
+ }
7723
+
7724
+ // Use an approach like template-literal's quasis:
7725
+ // `quasi0${0}quais1${1}quasi2...`
7726
+ // Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.
7727
+ var quasisMap = new Map();
7728
+ if (reversedProxies.slots.has(ref)) {
7729
+ for (var item of reversedProxies.slots.get(ref)) {
7730
+ var _item$refPosition, _externalSlots$item$$, _externalSlots$item$$2;
7731
+ if (!quasisMap.has(item.refSlot)) {
7732
+ var quasis = [];
7733
+ // The size of quasis should be the existed slotted bricks' size plus one.
7734
+ var size = hasOwnProperty(slots, item.refSlot) ? slots[item.refSlot].bricks.length + 1 : 1;
7735
+ for (var i = 0; i < size; i += 1) {
7736
+ quasis.push([]);
7737
+ }
7738
+ quasisMap.set(item.refSlot, quasis);
7739
+ }
7740
+ var expandableSlot = quasisMap.get(item.refSlot);
7741
+ var refPosition = (_item$refPosition = item.refPosition) !== null && _item$refPosition !== void 0 ? _item$refPosition : -1;
7742
+ 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$$ : []));
7743
+ }
7744
+ }
7745
+ var _loop = function (slotName, _quasis) {
7746
+ if (!hasOwnProperty(slots, slotName)) {
7747
+ slots[slotName] = {
7748
+ type: "bricks",
7749
+ bricks: []
7750
+ };
7751
+ }
7752
+ var slotConf = slots[slotName];
7753
+ slotConf.bricks = _quasis.flatMap((bricks, index) => index < slotConf.bricks.length ? bricks.concat(slotConf.bricks[index]) : bricks);
7754
+ if (slotConf.bricks.length === 0) {
7755
+ delete slots[slotName];
7756
+ }
7757
+ };
7758
+ for (var [slotName, _quasis] of quasisMap.entries()) {
7759
+ _loop(slotName, _quasis);
7760
+ }
7761
+ }
7762
+ return {
7763
+ [symbolForComputedPropsFromProxy]: computedPropsFromProxy,
7764
+ [symbolForRefForProxy]: refForProxy,
7765
+ [symbolForTplContextId]: templateContextId
7766
+ };
7767
+ }
7768
+
7769
+ var _excluded$4 = ["properties", "slots"];
7770
+ function setupUseBrickInTemplate(props, proxyContext) {
7771
+ function walk(props) {
7772
+ if (!isObject(props)) {
7773
+ return props;
7774
+ }
7775
+ if (Array.isArray(props)) {
7776
+ return props.map(walk);
7777
+ }
7778
+ return Object.fromEntries(Object.entries(props).map(_ref => {
7779
+ var [key, value] = _ref;
7780
+ return isObject(value) && key === "useBrick" ? Array.isArray(value) ? [key, value.map(setup)] : [key, setup(value)] : [key, walk(value)];
7781
+ }).concat(Object.getOwnPropertySymbols(props).map(k => [k, props[k]])));
7782
+ }
7783
+ function setup(item) {
7784
+ var {
7785
+ properties,
7786
+ slots: originalSlots
7787
+ } = item,
7788
+ restConf = _objectWithoutProperties(item, _excluded$4);
7789
+ var slots = Object.fromEntries(Object.entries(originalSlots !== null && originalSlots !== void 0 ? originalSlots : {}).map(_ref2 => {
7790
+ var _slotConf$bricks;
7791
+ var [slotName, slotConf] = _ref2;
7792
+ return [slotName, {
7793
+ type: "bricks",
7794
+ bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(setup)
7795
+ }];
7796
+ }));
7797
+ return _objectSpread(_objectSpread({}, restConf), {}, {
7798
+ properties: walk(properties),
7799
+ slots
7800
+ }, setupTemplateProxy(proxyContext, restConf.ref, slots));
7801
+ }
7802
+ return walk(props);
7803
+ }
7804
+
7813
7805
  var _excluded$3 = ["properties", "slots"],
7814
7806
  _excluded2 = ["ref", "slots"];
7815
7807
  function expandCustomTemplate(brickConf, proxyBrick, context) {
@@ -7966,8 +7958,8 @@ function expandBrickInTemplate(brickConfInTemplate, proxyContext) {
7966
7958
  bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(item => expandBrickInTemplate(item, proxyContext))
7967
7959
  }];
7968
7960
  }));
7969
- setupUseBrickInTemplate(brickConfInTemplate.properties, proxyContext);
7970
7961
  return _objectSpread(_objectSpread({}, restBrickConfInTemplate), {}, {
7962
+ properties: setupUseBrickInTemplate(brickConfInTemplate.properties, proxyContext),
7971
7963
  slots
7972
7964
  }, setupTemplateProxy(proxyContext, ref, slots));
7973
7965
  }