@next-core/brick-kit 2.165.7 → 2.166.1

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.
@@ -644,10 +644,25 @@
644
644
  };
645
645
  }
646
646
 
647
- function imagesFactory(appId, isBuildPush) {
647
+ function imagesFactory(appId, isBuildPush, version) {
648
648
  return {
649
649
  get(name) {
650
- return isBuildPush ? "api/gateway/object_store.object_store.GetObject/api/v1/objectStore/bucket/next-builder/object/".concat(name) : "".concat(window.APP_ROOT ? "".concat(window.APP_ROOT, "-/") : "", "micro-apps/").concat(appId, "/images/").concat(name);
650
+ var getSuffix = () => {
651
+ var suffix = window.APP_ROOT ? "".concat(window.APP_ROOT, "-/") : "";
652
+ if (!suffix.startsWith("/")) {
653
+ suffix = getBasePath() + suffix;
654
+ }
655
+ if (window.APP_ID && window.APP_ID !== appId) {
656
+ return suffix.replace(new RegExp("/(".concat(window.APP_ID, "|\\d+.\\d+.\\d+)/"), "g"), (_, p1) => {
657
+ if (p1 === window.APP_ID) {
658
+ return "/".concat(appId, "/");
659
+ }
660
+ return "/".concat(version, "/");
661
+ });
662
+ }
663
+ return suffix;
664
+ };
665
+ return isBuildPush ? "".concat(getBasePath(), "api/gateway/object_store.object_store.GetObject/api/v1/objectStore/bucket/next-builder/object/").concat(name) : "".concat(getSuffix(), "micro-apps/").concat(appId, "/images/").concat(name);
651
666
  }
652
667
  };
653
668
  }
@@ -1402,7 +1417,7 @@
1402
1417
  case "FN":
1403
1418
  return storyboardFunctions;
1404
1419
  case "IMG":
1405
- return collectCoverage ? fakeImageFactory() : widgetId ? widgetImagesFactory(widgetId, widgetVersion) : imagesFactory(app.id, app.isBuildPush);
1420
+ return collectCoverage ? fakeImageFactory() : widgetId ? widgetImagesFactory(widgetId, widgetVersion) : imagesFactory(app.id, app.isBuildPush, app.currentVersion);
1406
1421
  case "I18N":
1407
1422
  return collectCoverage ? _.identity : widgetId ? widgetI18nFactory(widgetId) : i18next.getFixedT(null, [appendI18nNamespace, getI18nNamespace("app", app.id)].filter(Boolean));
1408
1423
  case "I18N_TEXT":
@@ -2415,6 +2430,229 @@
2415
2430
  }
2416
2431
  }
2417
2432
 
2433
+ function isBasicProperty(propRef) {
2434
+ return !!propRef.refProperty;
2435
+ }
2436
+ function isTransformableProperty(propRef) {
2437
+ return !!propRef.refTransform;
2438
+ }
2439
+ function isMergeableProperty(propRef) {
2440
+ return !!propRef.mergeProperty;
2441
+ }
2442
+ function isRefProperty(propRef) {
2443
+ return !!propRef.ref;
2444
+ }
2445
+ function isVariableProperty(propRef) {
2446
+ return !!propRef.asVariable;
2447
+ }
2448
+
2449
+ var customTemplateRegistry = new Map();
2450
+ var appRegistered = new Set();
2451
+ var symbolForComputedPropsFromProxy = Symbol.for("tpl.computedPropsFromProxy");
2452
+ var symbolForRefForProxy = Symbol.for("tpl.refForProxy");
2453
+ var symbolForTplContextId = Symbol.for("tpl.contextId");
2454
+
2455
+ function propertyMerge(conf, value, object) {
2456
+ return propertyMergeAll(conf.$$mergeBase, Object.fromEntries(conf.$$mergeBase.proxies.map(proxy => [proxy.$$reversedRef, proxy === conf ? value : object[proxy.$$reversedRef]])));
2457
+ }
2458
+ function propertyMergeAll(mergeBase, object) {
2459
+ if (mergeBase.mergeType === "array") {
2460
+ return propertyMergeAllOfArray(mergeBase, object);
2461
+ }
2462
+ if (mergeBase.mergeType === "object") {
2463
+ return propertyMergeAllOfObject(mergeBase, object);
2464
+ }
2465
+ // istanbul ignore next: should never reach
2466
+ throw new TypeError("unsupported mergeType: \"".concat(mergeBase.mergeType, "\""));
2467
+ }
2468
+ function propertyMergeAllOfArray(_ref, object) {
2469
+ var _$1, _proxy$mergeArgs;
2470
+ var {
2471
+ baseValue,
2472
+ context,
2473
+ proxies
2474
+ } = _ref;
2475
+ // Use an approach like template-literal's quasis:
2476
+ // `quasi0${0}quais1${1}quasi2...`
2477
+ // Every quasi can be merged with multiple items.
2478
+ var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true, {
2479
+ $$lazyForUseBrick: true
2480
+ }) : [];
2481
+ var quasis = [];
2482
+ var size = computedBaseValue.length + 1;
2483
+ for (var i = 0; i < size; i += 1) {
2484
+ quasis.push([]);
2485
+ }
2486
+ for (var proxy of proxies) {
2487
+ var position = void 0;
2488
+ switch (proxy.mergeMethod) {
2489
+ case "append":
2490
+ position = computedBaseValue.length;
2491
+ break;
2492
+ case "prepend":
2493
+ position = 0;
2494
+ break;
2495
+ case "insertAt":
2496
+ // Defaults to `-1`.
2497
+ position = (_$1 = (_proxy$mergeArgs = proxy.mergeArgs) === null || _proxy$mergeArgs === void 0 ? void 0 : _proxy$mergeArgs[0]) !== null && _$1 !== void 0 ? _$1 : -1;
2498
+ if (position < 0) {
2499
+ // It's counted from the end if position is negative.
2500
+ position += quasis.length;
2501
+ }
2502
+ position = _.clamp(position, 0, computedBaseValue.length);
2503
+ break;
2504
+ // istanbul ignore next: should never reach
2505
+ default:
2506
+ throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
2507
+ }
2508
+ var patchValue = object[proxy.$$reversedRef];
2509
+ if (!Array.isArray(patchValue)) {
2510
+ patchValue = [];
2511
+ }
2512
+ quasis[position].push(...patchValue);
2513
+ }
2514
+ return quasis.flatMap((item, index) => index < computedBaseValue.length ? item.concat(computedBaseValue[index]) : item);
2515
+ }
2516
+ function propertyMergeAllOfObject(_ref2, object) {
2517
+ var {
2518
+ baseValue,
2519
+ proxies,
2520
+ context
2521
+ } = _ref2;
2522
+ var computedBaseValue = brickUtils.isObject(baseValue) ? computeRealValue(baseValue, context, true) : {};
2523
+ return proxies.reduce((acc, proxy) => {
2524
+ switch (proxy.mergeMethod) {
2525
+ case "extend":
2526
+ return _objectSpread__default["default"](_objectSpread__default["default"]({}, acc), object[proxy.$$reversedRef]);
2527
+ // istanbul ignore next: should never reach
2528
+ default:
2529
+ throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
2530
+ }
2531
+ }, computedBaseValue);
2532
+ }
2533
+
2534
+ function setupTemplateProxy(proxyContext, ref, slots) {
2535
+ var computedPropsFromProxy = {};
2536
+ var refForProxy;
2537
+ var {
2538
+ reversedProxies,
2539
+ templateProperties,
2540
+ externalSlots,
2541
+ templateContextId,
2542
+ proxyBrick
2543
+ } = proxyContext;
2544
+ if (ref && reversedProxies) {
2545
+ refForProxy = {};
2546
+ proxyBrick.proxyRefs.set(ref, refForProxy);
2547
+
2548
+ // Reversed proxies are used for expand storyboard before rendering page.
2549
+ if (reversedProxies.properties.has(ref)) {
2550
+ Object.assign(computedPropsFromProxy, Object.fromEntries(reversedProxies.properties.get(ref).flatMap(propRef => {
2551
+ // `propValue` is computed.
2552
+ var propValue = templateProperties === null || templateProperties === void 0 ? void 0 : templateProperties[propRef.$$reversedRef];
2553
+ if (isTransformableProperty(propRef)) {
2554
+ return Object.entries(preprocessTransformProperties({
2555
+ [propRef.$$reversedRef]: propValue
2556
+ }, propRef.refTransform));
2557
+ }
2558
+ if (isBasicProperty(propRef)) {
2559
+ return [[propRef.refProperty, propValue]];
2560
+ }
2561
+ // Ignore Variable properties.
2562
+ // And mergeable properties are processed later.
2563
+ return [];
2564
+ }).filter(propRef => propRef[1] !== undefined)));
2565
+
2566
+ // Brick properties can be merged multiple times.
2567
+ if (reversedProxies.mergeBases.has(ref)) {
2568
+ Object.assign(computedPropsFromProxy, Object.fromEntries(Array.from(reversedProxies.mergeBases.get(ref).entries()).map(_ref => {
2569
+ var [mergeProperty, mergeBase] = _ref;
2570
+ return [mergeProperty, propertyMergeAll(mergeBase, templateProperties !== null && templateProperties !== void 0 ? templateProperties : {})];
2571
+ }).filter(item => item[1] !== undefined)));
2572
+ }
2573
+ }
2574
+
2575
+ // Use an approach like template-literal's quasis:
2576
+ // `quasi0${0}quais1${1}quasi2...`
2577
+ // Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.
2578
+ var quasisMap = new Map();
2579
+ if (reversedProxies.slots.has(ref)) {
2580
+ for (var item of reversedProxies.slots.get(ref)) {
2581
+ var _item$refPosition, _externalSlots$item$$, _externalSlots$item$$2;
2582
+ if (!quasisMap.has(item.refSlot)) {
2583
+ var quasis = [];
2584
+ // The size of quasis should be the existed slotted bricks' size plus one.
2585
+ var size = brickUtils.hasOwnProperty(slots, item.refSlot) ? slots[item.refSlot].bricks.length + 1 : 1;
2586
+ for (var i = 0; i < size; i += 1) {
2587
+ quasis.push([]);
2588
+ }
2589
+ quasisMap.set(item.refSlot, quasis);
2590
+ }
2591
+ var expandableSlot = quasisMap.get(item.refSlot);
2592
+ var refPosition = (_item$refPosition = item.refPosition) !== null && _item$refPosition !== void 0 ? _item$refPosition : -1;
2593
+ 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$$ : []));
2594
+ }
2595
+ }
2596
+ var _loop = function (slotName, _quasis) {
2597
+ if (!brickUtils.hasOwnProperty(slots, slotName)) {
2598
+ slots[slotName] = {
2599
+ type: "bricks",
2600
+ bricks: []
2601
+ };
2602
+ }
2603
+ var slotConf = slots[slotName];
2604
+ slotConf.bricks = _quasis.flatMap((bricks, index) => index < slotConf.bricks.length ? bricks.concat(slotConf.bricks[index]) : bricks);
2605
+ if (slotConf.bricks.length === 0) {
2606
+ delete slots[slotName];
2607
+ }
2608
+ };
2609
+ for (var [slotName, _quasis] of quasisMap.entries()) {
2610
+ _loop(slotName, _quasis);
2611
+ }
2612
+ }
2613
+ return {
2614
+ [symbolForComputedPropsFromProxy]: computedPropsFromProxy,
2615
+ [symbolForRefForProxy]: refForProxy,
2616
+ [symbolForTplContextId]: templateContextId
2617
+ };
2618
+ }
2619
+
2620
+ var _excluded$7 = ["properties", "slots"];
2621
+ function setupUseBrickInTemplate(props, proxyContext) {
2622
+ function walk(props) {
2623
+ if (!brickUtils.isObject(props)) {
2624
+ return props;
2625
+ }
2626
+ if (Array.isArray(props)) {
2627
+ return props.map(walk);
2628
+ }
2629
+ return Object.fromEntries(Object.entries(props).map(_ref => {
2630
+ var [key, value] = _ref;
2631
+ return brickUtils.isObject(value) && key === "useBrick" ? Array.isArray(value) ? [key, value.map(setup)] : [key, setup(value)] : [key, walk(value)];
2632
+ }).concat(Object.getOwnPropertySymbols(props).map(k => [k, props[k]])));
2633
+ }
2634
+ function setup(item) {
2635
+ var {
2636
+ properties,
2637
+ slots: originalSlots
2638
+ } = item,
2639
+ restConf = _objectWithoutProperties__default["default"](item, _excluded$7);
2640
+ var slots = Object.fromEntries(Object.entries(originalSlots !== null && originalSlots !== void 0 ? originalSlots : {}).map(_ref2 => {
2641
+ var _slotConf$bricks;
2642
+ var [slotName, slotConf] = _ref2;
2643
+ return [slotName, {
2644
+ type: "bricks",
2645
+ bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(setup)
2646
+ }];
2647
+ }));
2648
+ return _objectSpread__default["default"](_objectSpread__default["default"]({}, restConf), {}, {
2649
+ properties: walk(properties),
2650
+ slots
2651
+ }, setupTemplateProxy(proxyContext, restConf.ref, slots));
2652
+ }
2653
+ return walk(props);
2654
+ }
2655
+
2418
2656
  var computeRealValue = (value, context, injectDeep, internalOptions) => {
2419
2657
  var preEvaluated = isPreEvaluated(value);
2420
2658
  if (preEvaluated || typeof value === "string") {
@@ -2466,6 +2704,11 @@
2466
2704
  };
2467
2705
  function setProperties(bricks, properties, context, injectDeep) {
2468
2706
  var realProps = computeRealProperties(properties, context, injectDeep);
2707
+ if (context.tplContextId) {
2708
+ realProps = setupUseBrickInTemplate(realProps, {
2709
+ templateContextId: context.tplContextId
2710
+ });
2711
+ }
2469
2712
  if (!Array.isArray(bricks)) {
2470
2713
  bricks = [bricks];
2471
2714
  }
@@ -2533,7 +2776,7 @@
2533
2776
  }) : internalOptions;
2534
2777
  }
2535
2778
 
2536
- var _excluded$7 = ["children"],
2779
+ var _excluded$6 = ["children"],
2537
2780
  _excluded2$2 = ["children"],
2538
2781
  _excluded3 = ["items", "app"];
2539
2782
  var symbolAppId = Symbol("appId");
@@ -2796,7 +3039,7 @@
2796
3039
  var {
2797
3040
  children
2798
3041
  } = _ref,
2799
- rest = _objectWithoutProperties__default["default"](_ref, _excluded$7);
3042
+ rest = _objectWithoutProperties__default["default"](_ref, _excluded$6);
2800
3043
  var overrideAppId = rest[symbolAppId];
2801
3044
  if (!rest[symbolMenuI18nNamespace] && overrideAppId !== contextAppId && !appIds.has(overrideAppId) && attemptToVisit(rest, ["I18N"])) {
2802
3045
  appIds.add(overrideAppId);
@@ -2907,7 +3150,7 @@
2907
3150
  function _computeRealValueWithOverrideApp() {
2908
3151
  _computeRealValueWithOverrideApp = _asyncToGenerator__default["default"](function* (data, overrideAppId, context, kernel) {
2909
3152
  var newContext = context;
2910
- if (overrideAppId !== context.app.id && attemptToVisit(data, ["APP", "I18N"])) {
3153
+ if (overrideAppId !== context.app.id && attemptToVisit(data, ["APP", "I18N", "IMG"])) {
2911
3154
  if (window.STANDALONE_MICRO_APPS) {
2912
3155
  if (data[symbolOverrideApp]) {
2913
3156
  data[symbolOverrideApp].config = brickUtils.deepFreeze(_.merge({}, data[symbolOverrideApp].defaultConfig, data[symbolOverrideApp].userConfig));
@@ -3418,7 +3661,7 @@
3418
3661
  return kernel.loadDynamicBricksInBrickConf(brickConf);
3419
3662
  }
3420
3663
 
3421
- var _excluded$6 = ["extraQuery", "clear", "keepHash"];
3664
+ var _excluded$5 = ["extraQuery", "clear", "keepHash"];
3422
3665
  var blocked = false;
3423
3666
  function getUserConfirmation(message, callback) {
3424
3667
  blocked = !confirm(message);
@@ -3448,7 +3691,7 @@
3448
3691
  clear,
3449
3692
  keepHash
3450
3693
  } = options,
3451
- state = _objectWithoutProperties__default["default"](options, _excluded$6);
3694
+ state = _objectWithoutProperties__default["default"](options, _excluded$5);
3452
3695
  var urlSearchParams = new URLSearchParams(clear ? "" : browserHistory.location.search);
3453
3696
  var params = {};
3454
3697
  Object.assign(params, query, extraQuery);
@@ -6519,7 +6762,7 @@
6519
6762
  };
6520
6763
  }();
6521
6764
 
6522
- var _excluded$5 = ["feature_flags"],
6765
+ var _excluded$4 = ["feature_flags"],
6523
6766
  _excluded2$1 = ["featureFlags", "misc"];
6524
6767
  function standaloneBootstrap() {
6525
6768
  return _standaloneBootstrap.apply(this, arguments);
@@ -6565,7 +6808,7 @@
6565
6808
  var {
6566
6809
  feature_flags: featureFlags
6567
6810
  } = sys_settings,
6568
- rest = _objectWithoutProperties__default["default"](sys_settings, _excluded$5);
6811
+ rest = _objectWithoutProperties__default["default"](sys_settings, _excluded$4);
6569
6812
  settings = _objectSpread__default["default"]({
6570
6813
  featureFlags
6571
6814
  }, rest);
@@ -7523,28 +7766,6 @@
7523
7766
  var filterProperties = ["instanceId", "brick", "slots", "properties", "events", "if", "context", "bricks", "mountPoint"];
7524
7767
  var symbolForFormContextId = Symbol.for("form.contextId");
7525
7768
 
7526
- var customTemplateRegistry = new Map();
7527
- var appRegistered = new Set();
7528
- var symbolForComputedPropsFromProxy = Symbol.for("tpl.computedPropsFromProxy");
7529
- var symbolForRefForProxy = Symbol.for("tpl.refForProxy");
7530
- var symbolForTplContextId = Symbol.for("tpl.contextId");
7531
-
7532
- function isBasicProperty(propRef) {
7533
- return !!propRef.refProperty;
7534
- }
7535
- function isTransformableProperty(propRef) {
7536
- return !!propRef.refTransform;
7537
- }
7538
- function isMergeableProperty(propRef) {
7539
- return !!propRef.mergeProperty;
7540
- }
7541
- function isRefProperty(propRef) {
7542
- return !!propRef.ref;
7543
- }
7544
- function isVariableProperty(propRef) {
7545
- return !!propRef.asVariable;
7546
- }
7547
-
7548
7769
  function collectRefsInTemplate(template) {
7549
7770
  var refMap = new Map();
7550
7771
  collectRefsInBrickConfs(template.bricks, refMap);
@@ -7600,207 +7821,6 @@
7600
7821
  }
7601
7822
  }
7602
7823
 
7603
- function propertyMerge(conf, value, object) {
7604
- return propertyMergeAll(conf.$$mergeBase, Object.fromEntries(conf.$$mergeBase.proxies.map(proxy => [proxy.$$reversedRef, proxy === conf ? value : object[proxy.$$reversedRef]])));
7605
- }
7606
- function propertyMergeAll(mergeBase, object) {
7607
- if (mergeBase.mergeType === "array") {
7608
- return propertyMergeAllOfArray(mergeBase, object);
7609
- }
7610
- if (mergeBase.mergeType === "object") {
7611
- return propertyMergeAllOfObject(mergeBase, object);
7612
- }
7613
- // istanbul ignore next: should never reach
7614
- throw new TypeError("unsupported mergeType: \"".concat(mergeBase.mergeType, "\""));
7615
- }
7616
- function propertyMergeAllOfArray(_ref, object) {
7617
- var _$1, _proxy$mergeArgs;
7618
- var {
7619
- baseValue,
7620
- context,
7621
- proxies
7622
- } = _ref;
7623
- // Use an approach like template-literal's quasis:
7624
- // `quasi0${0}quais1${1}quasi2...`
7625
- // Every quasi can be merged with multiple items.
7626
- var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true, {
7627
- $$lazyForUseBrick: true
7628
- }) : [];
7629
- var quasis = [];
7630
- var size = computedBaseValue.length + 1;
7631
- for (var i = 0; i < size; i += 1) {
7632
- quasis.push([]);
7633
- }
7634
- for (var proxy of proxies) {
7635
- var position = void 0;
7636
- switch (proxy.mergeMethod) {
7637
- case "append":
7638
- position = computedBaseValue.length;
7639
- break;
7640
- case "prepend":
7641
- position = 0;
7642
- break;
7643
- case "insertAt":
7644
- // Defaults to `-1`.
7645
- position = (_$1 = (_proxy$mergeArgs = proxy.mergeArgs) === null || _proxy$mergeArgs === void 0 ? void 0 : _proxy$mergeArgs[0]) !== null && _$1 !== void 0 ? _$1 : -1;
7646
- if (position < 0) {
7647
- // It's counted from the end if position is negative.
7648
- position += quasis.length;
7649
- }
7650
- position = _.clamp(position, 0, computedBaseValue.length);
7651
- break;
7652
- // istanbul ignore next: should never reach
7653
- default:
7654
- throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
7655
- }
7656
- var patchValue = object[proxy.$$reversedRef];
7657
- if (!Array.isArray(patchValue)) {
7658
- patchValue = [];
7659
- }
7660
- quasis[position].push(...patchValue);
7661
- }
7662
- return quasis.flatMap((item, index) => index < computedBaseValue.length ? item.concat(computedBaseValue[index]) : item);
7663
- }
7664
- function propertyMergeAllOfObject(_ref2, object) {
7665
- var {
7666
- baseValue,
7667
- proxies,
7668
- context
7669
- } = _ref2;
7670
- var computedBaseValue = brickUtils.isObject(baseValue) ? computeRealValue(baseValue, context, true) : {};
7671
- return proxies.reduce((acc, proxy) => {
7672
- switch (proxy.mergeMethod) {
7673
- case "extend":
7674
- return _objectSpread__default["default"](_objectSpread__default["default"]({}, acc), object[proxy.$$reversedRef]);
7675
- // istanbul ignore next: should never reach
7676
- default:
7677
- throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
7678
- }
7679
- }, computedBaseValue);
7680
- }
7681
-
7682
- function setupTemplateProxy(proxyContext, ref, slots) {
7683
- var computedPropsFromProxy = {};
7684
- var refForProxy;
7685
- var {
7686
- reversedProxies,
7687
- templateProperties,
7688
- externalSlots,
7689
- templateContextId,
7690
- proxyBrick
7691
- } = proxyContext;
7692
- if (ref && reversedProxies) {
7693
- refForProxy = {};
7694
- proxyBrick.proxyRefs.set(ref, refForProxy);
7695
-
7696
- // Reversed proxies are used for expand storyboard before rendering page.
7697
- if (reversedProxies.properties.has(ref)) {
7698
- Object.assign(computedPropsFromProxy, Object.fromEntries(reversedProxies.properties.get(ref).flatMap(propRef => {
7699
- // `propValue` is computed.
7700
- var propValue = templateProperties === null || templateProperties === void 0 ? void 0 : templateProperties[propRef.$$reversedRef];
7701
- if (isTransformableProperty(propRef)) {
7702
- return Object.entries(preprocessTransformProperties({
7703
- [propRef.$$reversedRef]: propValue
7704
- }, propRef.refTransform));
7705
- }
7706
- if (isBasicProperty(propRef)) {
7707
- return [[propRef.refProperty, propValue]];
7708
- }
7709
- // Ignore Variable properties.
7710
- // And mergeable properties are processed later.
7711
- return [];
7712
- }).filter(propRef => propRef[1] !== undefined)));
7713
-
7714
- // Brick properties can be merged multiple times.
7715
- if (reversedProxies.mergeBases.has(ref)) {
7716
- Object.assign(computedPropsFromProxy, Object.fromEntries(Array.from(reversedProxies.mergeBases.get(ref).entries()).map(_ref => {
7717
- var [mergeProperty, mergeBase] = _ref;
7718
- return [mergeProperty, propertyMergeAll(mergeBase, templateProperties !== null && templateProperties !== void 0 ? templateProperties : {})];
7719
- }).filter(item => item[1] !== undefined)));
7720
- }
7721
- }
7722
-
7723
- // Use an approach like template-literal's quasis:
7724
- // `quasi0${0}quais1${1}quasi2...`
7725
- // Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.
7726
- var quasisMap = new Map();
7727
- if (reversedProxies.slots.has(ref)) {
7728
- for (var item of reversedProxies.slots.get(ref)) {
7729
- var _item$refPosition, _externalSlots$item$$, _externalSlots$item$$2;
7730
- if (!quasisMap.has(item.refSlot)) {
7731
- var quasis = [];
7732
- // The size of quasis should be the existed slotted bricks' size plus one.
7733
- var size = brickUtils.hasOwnProperty(slots, item.refSlot) ? slots[item.refSlot].bricks.length + 1 : 1;
7734
- for (var i = 0; i < size; i += 1) {
7735
- quasis.push([]);
7736
- }
7737
- quasisMap.set(item.refSlot, quasis);
7738
- }
7739
- var expandableSlot = quasisMap.get(item.refSlot);
7740
- var refPosition = (_item$refPosition = item.refPosition) !== null && _item$refPosition !== void 0 ? _item$refPosition : -1;
7741
- 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$$ : []));
7742
- }
7743
- }
7744
- var _loop = function (slotName, _quasis) {
7745
- if (!brickUtils.hasOwnProperty(slots, slotName)) {
7746
- slots[slotName] = {
7747
- type: "bricks",
7748
- bricks: []
7749
- };
7750
- }
7751
- var slotConf = slots[slotName];
7752
- slotConf.bricks = _quasis.flatMap((bricks, index) => index < slotConf.bricks.length ? bricks.concat(slotConf.bricks[index]) : bricks);
7753
- if (slotConf.bricks.length === 0) {
7754
- delete slots[slotName];
7755
- }
7756
- };
7757
- for (var [slotName, _quasis] of quasisMap.entries()) {
7758
- _loop(slotName, _quasis);
7759
- }
7760
- }
7761
- return {
7762
- [symbolForComputedPropsFromProxy]: computedPropsFromProxy,
7763
- [symbolForRefForProxy]: refForProxy,
7764
- [symbolForTplContextId]: templateContextId
7765
- };
7766
- }
7767
-
7768
- var _excluded$4 = ["properties", "slots"];
7769
- function setupUseBrickInTemplate(props, proxyContext) {
7770
- function walk(props) {
7771
- if (!brickUtils.isObject(props)) {
7772
- return props;
7773
- }
7774
- if (Array.isArray(props)) {
7775
- return props.map(walk);
7776
- }
7777
- return Object.fromEntries(Object.entries(props).map(_ref => {
7778
- var [key, value] = _ref;
7779
- return brickUtils.isObject(value) && key === "useBrick" ? Array.isArray(value) ? [key, value.map(setup)] : [key, setup(value)] : [key, walk(value)];
7780
- }).concat(Object.getOwnPropertySymbols(props).map(k => [k, props[k]])));
7781
- }
7782
- function setup(item) {
7783
- var {
7784
- properties,
7785
- slots: originalSlots
7786
- } = item,
7787
- restConf = _objectWithoutProperties__default["default"](item, _excluded$4);
7788
- var slots = Object.fromEntries(Object.entries(originalSlots !== null && originalSlots !== void 0 ? originalSlots : {}).map(_ref2 => {
7789
- var _slotConf$bricks;
7790
- var [slotName, slotConf] = _ref2;
7791
- return [slotName, {
7792
- type: "bricks",
7793
- bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(setup)
7794
- }];
7795
- }));
7796
- return _objectSpread__default["default"](_objectSpread__default["default"]({}, restConf), {}, {
7797
- properties: walk(properties),
7798
- slots
7799
- }, setupTemplateProxy(proxyContext, restConf.ref, slots));
7800
- }
7801
- return walk(props);
7802
- }
7803
-
7804
7824
  var _excluded$3 = ["properties", "slots"],
7805
7825
  _excluded2 = ["ref", "slots"];
7806
7826
  function expandCustomTemplate(brickConf, proxyBrick, context) {