@next-core/brick-kit 2.165.5 → 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.bundle.js +235 -239
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +236 -240
- package/dist/index.esm.js.map +1 -1
- package/dist/types/core/CustomTemplates/setupUseBrickInTemplate.d.ts +1 -1
- package/dist/types/core/CustomTemplates/setupUseBrickInTemplate.d.ts.map +1 -1
- package/dist/types/core/matchStoryboard.d.ts +1 -0
- package/dist/types/core/matchStoryboard.d.ts.map +1 -1
- package/dist/types/internal/setProperties.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.bundle.js
CHANGED
|
@@ -2415,232 +2415,6 @@
|
|
|
2415
2415
|
}
|
|
2416
2416
|
}
|
|
2417
2417
|
|
|
2418
|
-
function isBasicProperty(propRef) {
|
|
2419
|
-
return !!propRef.refProperty;
|
|
2420
|
-
}
|
|
2421
|
-
function isTransformableProperty(propRef) {
|
|
2422
|
-
return !!propRef.refTransform;
|
|
2423
|
-
}
|
|
2424
|
-
function isMergeableProperty(propRef) {
|
|
2425
|
-
return !!propRef.mergeProperty;
|
|
2426
|
-
}
|
|
2427
|
-
function isRefProperty(propRef) {
|
|
2428
|
-
return !!propRef.ref;
|
|
2429
|
-
}
|
|
2430
|
-
function isVariableProperty(propRef) {
|
|
2431
|
-
return !!propRef.asVariable;
|
|
2432
|
-
}
|
|
2433
|
-
|
|
2434
|
-
var customTemplateRegistry = new Map();
|
|
2435
|
-
var appRegistered = new Set();
|
|
2436
|
-
var symbolForComputedPropsFromProxy = Symbol.for("tpl.computedPropsFromProxy");
|
|
2437
|
-
var symbolForRefForProxy = Symbol.for("tpl.refForProxy");
|
|
2438
|
-
var symbolForTplContextId = Symbol.for("tpl.contextId");
|
|
2439
|
-
|
|
2440
|
-
function propertyMerge(conf, value, object) {
|
|
2441
|
-
return propertyMergeAll(conf.$$mergeBase, Object.fromEntries(conf.$$mergeBase.proxies.map(proxy => [proxy.$$reversedRef, proxy === conf ? value : object[proxy.$$reversedRef]])));
|
|
2442
|
-
}
|
|
2443
|
-
function propertyMergeAll(mergeBase, object) {
|
|
2444
|
-
if (mergeBase.mergeType === "array") {
|
|
2445
|
-
return propertyMergeAllOfArray(mergeBase, object);
|
|
2446
|
-
}
|
|
2447
|
-
if (mergeBase.mergeType === "object") {
|
|
2448
|
-
return propertyMergeAllOfObject(mergeBase, object);
|
|
2449
|
-
}
|
|
2450
|
-
// istanbul ignore next: should never reach
|
|
2451
|
-
throw new TypeError("unsupported mergeType: \"".concat(mergeBase.mergeType, "\""));
|
|
2452
|
-
}
|
|
2453
|
-
function propertyMergeAllOfArray(_ref, object) {
|
|
2454
|
-
var _$1, _proxy$mergeArgs;
|
|
2455
|
-
var {
|
|
2456
|
-
baseValue,
|
|
2457
|
-
context,
|
|
2458
|
-
proxies
|
|
2459
|
-
} = _ref;
|
|
2460
|
-
// Use an approach like template-literal's quasis:
|
|
2461
|
-
// `quasi0${0}quais1${1}quasi2...`
|
|
2462
|
-
// Every quasi can be merged with multiple items.
|
|
2463
|
-
var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true, {
|
|
2464
|
-
$$lazyForUseBrick: true
|
|
2465
|
-
}) : [];
|
|
2466
|
-
var quasis = [];
|
|
2467
|
-
var size = computedBaseValue.length + 1;
|
|
2468
|
-
for (var i = 0; i < size; i += 1) {
|
|
2469
|
-
quasis.push([]);
|
|
2470
|
-
}
|
|
2471
|
-
for (var proxy of proxies) {
|
|
2472
|
-
var position = void 0;
|
|
2473
|
-
switch (proxy.mergeMethod) {
|
|
2474
|
-
case "append":
|
|
2475
|
-
position = computedBaseValue.length;
|
|
2476
|
-
break;
|
|
2477
|
-
case "prepend":
|
|
2478
|
-
position = 0;
|
|
2479
|
-
break;
|
|
2480
|
-
case "insertAt":
|
|
2481
|
-
// Defaults to `-1`.
|
|
2482
|
-
position = (_$1 = (_proxy$mergeArgs = proxy.mergeArgs) === null || _proxy$mergeArgs === void 0 ? void 0 : _proxy$mergeArgs[0]) !== null && _$1 !== void 0 ? _$1 : -1;
|
|
2483
|
-
if (position < 0) {
|
|
2484
|
-
// It's counted from the end if position is negative.
|
|
2485
|
-
position += quasis.length;
|
|
2486
|
-
}
|
|
2487
|
-
position = _.clamp(position, 0, computedBaseValue.length);
|
|
2488
|
-
break;
|
|
2489
|
-
// istanbul ignore next: should never reach
|
|
2490
|
-
default:
|
|
2491
|
-
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
2492
|
-
}
|
|
2493
|
-
var patchValue = object[proxy.$$reversedRef];
|
|
2494
|
-
if (!Array.isArray(patchValue)) {
|
|
2495
|
-
patchValue = [];
|
|
2496
|
-
}
|
|
2497
|
-
quasis[position].push(...patchValue);
|
|
2498
|
-
}
|
|
2499
|
-
return quasis.flatMap((item, index) => index < computedBaseValue.length ? item.concat(computedBaseValue[index]) : item);
|
|
2500
|
-
}
|
|
2501
|
-
function propertyMergeAllOfObject(_ref2, object) {
|
|
2502
|
-
var {
|
|
2503
|
-
baseValue,
|
|
2504
|
-
proxies,
|
|
2505
|
-
context
|
|
2506
|
-
} = _ref2;
|
|
2507
|
-
var computedBaseValue = brickUtils.isObject(baseValue) ? computeRealValue(baseValue, context, true) : {};
|
|
2508
|
-
return proxies.reduce((acc, proxy) => {
|
|
2509
|
-
switch (proxy.mergeMethod) {
|
|
2510
|
-
case "extend":
|
|
2511
|
-
return _objectSpread__default["default"](_objectSpread__default["default"]({}, acc), object[proxy.$$reversedRef]);
|
|
2512
|
-
// istanbul ignore next: should never reach
|
|
2513
|
-
default:
|
|
2514
|
-
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
2515
|
-
}
|
|
2516
|
-
}, computedBaseValue);
|
|
2517
|
-
}
|
|
2518
|
-
|
|
2519
|
-
function setupTemplateProxy(proxyContext, ref, slots) {
|
|
2520
|
-
var computedPropsFromProxy = {};
|
|
2521
|
-
var refForProxy;
|
|
2522
|
-
var {
|
|
2523
|
-
reversedProxies,
|
|
2524
|
-
templateProperties,
|
|
2525
|
-
externalSlots,
|
|
2526
|
-
templateContextId,
|
|
2527
|
-
proxyBrick
|
|
2528
|
-
} = proxyContext;
|
|
2529
|
-
if (ref && reversedProxies) {
|
|
2530
|
-
refForProxy = {};
|
|
2531
|
-
proxyBrick.proxyRefs.set(ref, refForProxy);
|
|
2532
|
-
|
|
2533
|
-
// Reversed proxies are used for expand storyboard before rendering page.
|
|
2534
|
-
if (reversedProxies.properties.has(ref)) {
|
|
2535
|
-
Object.assign(computedPropsFromProxy, Object.fromEntries(reversedProxies.properties.get(ref).flatMap(propRef => {
|
|
2536
|
-
// `propValue` is computed.
|
|
2537
|
-
var propValue = templateProperties === null || templateProperties === void 0 ? void 0 : templateProperties[propRef.$$reversedRef];
|
|
2538
|
-
if (isTransformableProperty(propRef)) {
|
|
2539
|
-
return Object.entries(preprocessTransformProperties({
|
|
2540
|
-
[propRef.$$reversedRef]: propValue
|
|
2541
|
-
}, propRef.refTransform));
|
|
2542
|
-
}
|
|
2543
|
-
if (isBasicProperty(propRef)) {
|
|
2544
|
-
return [[propRef.refProperty, propValue]];
|
|
2545
|
-
}
|
|
2546
|
-
// Ignore Variable properties.
|
|
2547
|
-
// And mergeable properties are processed later.
|
|
2548
|
-
return [];
|
|
2549
|
-
}).filter(propRef => propRef[1] !== undefined)));
|
|
2550
|
-
|
|
2551
|
-
// Brick properties can be merged multiple times.
|
|
2552
|
-
if (reversedProxies.mergeBases.has(ref)) {
|
|
2553
|
-
Object.assign(computedPropsFromProxy, Object.fromEntries(Array.from(reversedProxies.mergeBases.get(ref).entries()).map(_ref => {
|
|
2554
|
-
var [mergeProperty, mergeBase] = _ref;
|
|
2555
|
-
return [mergeProperty, propertyMergeAll(mergeBase, templateProperties !== null && templateProperties !== void 0 ? templateProperties : {})];
|
|
2556
|
-
}).filter(item => item[1] !== undefined)));
|
|
2557
|
-
}
|
|
2558
|
-
}
|
|
2559
|
-
|
|
2560
|
-
// Use an approach like template-literal's quasis:
|
|
2561
|
-
// `quasi0${0}quais1${1}quasi2...`
|
|
2562
|
-
// Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.
|
|
2563
|
-
var quasisMap = new Map();
|
|
2564
|
-
if (reversedProxies.slots.has(ref)) {
|
|
2565
|
-
for (var item of reversedProxies.slots.get(ref)) {
|
|
2566
|
-
var _item$refPosition, _externalSlots$item$$, _externalSlots$item$$2;
|
|
2567
|
-
if (!quasisMap.has(item.refSlot)) {
|
|
2568
|
-
var quasis = [];
|
|
2569
|
-
// The size of quasis should be the existed slotted bricks' size plus one.
|
|
2570
|
-
var size = brickUtils.hasOwnProperty(slots, item.refSlot) ? slots[item.refSlot].bricks.length + 1 : 1;
|
|
2571
|
-
for (var i = 0; i < size; i += 1) {
|
|
2572
|
-
quasis.push([]);
|
|
2573
|
-
}
|
|
2574
|
-
quasisMap.set(item.refSlot, quasis);
|
|
2575
|
-
}
|
|
2576
|
-
var expandableSlot = quasisMap.get(item.refSlot);
|
|
2577
|
-
var refPosition = (_item$refPosition = item.refPosition) !== null && _item$refPosition !== void 0 ? _item$refPosition : -1;
|
|
2578
|
-
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$$ : []));
|
|
2579
|
-
}
|
|
2580
|
-
}
|
|
2581
|
-
var _loop = function (slotName, _quasis) {
|
|
2582
|
-
if (!brickUtils.hasOwnProperty(slots, slotName)) {
|
|
2583
|
-
slots[slotName] = {
|
|
2584
|
-
type: "bricks",
|
|
2585
|
-
bricks: []
|
|
2586
|
-
};
|
|
2587
|
-
}
|
|
2588
|
-
var slotConf = slots[slotName];
|
|
2589
|
-
slotConf.bricks = _quasis.flatMap((bricks, index) => index < slotConf.bricks.length ? bricks.concat(slotConf.bricks[index]) : bricks);
|
|
2590
|
-
if (slotConf.bricks.length === 0) {
|
|
2591
|
-
delete slots[slotName];
|
|
2592
|
-
}
|
|
2593
|
-
};
|
|
2594
|
-
for (var [slotName, _quasis] of quasisMap.entries()) {
|
|
2595
|
-
_loop(slotName, _quasis);
|
|
2596
|
-
}
|
|
2597
|
-
}
|
|
2598
|
-
return {
|
|
2599
|
-
[symbolForComputedPropsFromProxy]: computedPropsFromProxy,
|
|
2600
|
-
[symbolForRefForProxy]: refForProxy,
|
|
2601
|
-
[symbolForTplContextId]: templateContextId
|
|
2602
|
-
};
|
|
2603
|
-
}
|
|
2604
|
-
|
|
2605
|
-
function setupUseBrickInTemplate(props, proxyContext) {
|
|
2606
|
-
function walk(props) {
|
|
2607
|
-
if (!props) {
|
|
2608
|
-
return;
|
|
2609
|
-
}
|
|
2610
|
-
for (var [key, value] of Object.entries(props)) {
|
|
2611
|
-
if (brickUtils.isObject(value)) {
|
|
2612
|
-
if (key === "useBrick") {
|
|
2613
|
-
if (Array.isArray(value)) {
|
|
2614
|
-
value.forEach(setup);
|
|
2615
|
-
} else {
|
|
2616
|
-
setup(value);
|
|
2617
|
-
}
|
|
2618
|
-
} else {
|
|
2619
|
-
walk(value);
|
|
2620
|
-
}
|
|
2621
|
-
}
|
|
2622
|
-
}
|
|
2623
|
-
}
|
|
2624
|
-
function setup(item) {
|
|
2625
|
-
var {
|
|
2626
|
-
ref,
|
|
2627
|
-
slots: slotsInTemplate
|
|
2628
|
-
} = item;
|
|
2629
|
-
item.slots = Object.fromEntries(Object.entries(slotsInTemplate !== null && slotsInTemplate !== void 0 ? slotsInTemplate : {}).map(_ref => {
|
|
2630
|
-
var _slotConf$bricks;
|
|
2631
|
-
var [slotName, slotConf] = _ref;
|
|
2632
|
-
return [slotName, {
|
|
2633
|
-
type: "bricks",
|
|
2634
|
-
bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(setup)
|
|
2635
|
-
}];
|
|
2636
|
-
}));
|
|
2637
|
-
Object.assign(item, setupTemplateProxy(proxyContext, ref, item.slots));
|
|
2638
|
-
walk(item.properties);
|
|
2639
|
-
return item;
|
|
2640
|
-
}
|
|
2641
|
-
walk(props);
|
|
2642
|
-
}
|
|
2643
|
-
|
|
2644
2418
|
var computeRealValue = (value, context, injectDeep, internalOptions) => {
|
|
2645
2419
|
var preEvaluated = isPreEvaluated(value);
|
|
2646
2420
|
if (preEvaluated || typeof value === "string") {
|
|
@@ -2692,11 +2466,6 @@
|
|
|
2692
2466
|
};
|
|
2693
2467
|
function setProperties(bricks, properties, context, injectDeep) {
|
|
2694
2468
|
var realProps = computeRealProperties(properties, context, injectDeep);
|
|
2695
|
-
if (context.tplContextId) {
|
|
2696
|
-
setupUseBrickInTemplate(realProps, {
|
|
2697
|
-
templateContextId: context.tplContextId
|
|
2698
|
-
});
|
|
2699
|
-
}
|
|
2700
2469
|
if (!Array.isArray(bricks)) {
|
|
2701
2470
|
bricks = [bricks];
|
|
2702
2471
|
}
|
|
@@ -2764,7 +2533,7 @@
|
|
|
2764
2533
|
}) : internalOptions;
|
|
2765
2534
|
}
|
|
2766
2535
|
|
|
2767
|
-
var _excluded$
|
|
2536
|
+
var _excluded$7 = ["children"],
|
|
2768
2537
|
_excluded2$2 = ["children"],
|
|
2769
2538
|
_excluded3 = ["items", "app"];
|
|
2770
2539
|
var symbolAppId = Symbol("appId");
|
|
@@ -3027,7 +2796,7 @@
|
|
|
3027
2796
|
var {
|
|
3028
2797
|
children
|
|
3029
2798
|
} = _ref,
|
|
3030
|
-
rest = _objectWithoutProperties__default["default"](_ref, _excluded$
|
|
2799
|
+
rest = _objectWithoutProperties__default["default"](_ref, _excluded$7);
|
|
3031
2800
|
var overrideAppId = rest[symbolAppId];
|
|
3032
2801
|
if (!rest[symbolMenuI18nNamespace] && overrideAppId !== contextAppId && !appIds.has(overrideAppId) && attemptToVisit(rest, ["I18N"])) {
|
|
3033
2802
|
appIds.add(overrideAppId);
|
|
@@ -3236,15 +3005,19 @@
|
|
|
3236
3005
|
/**
|
|
3237
3006
|
* We say it's an outside app when at least one of the below conditions are true:
|
|
3238
3007
|
* - target app is not found.
|
|
3008
|
+
* - target app is not the current app.
|
|
3239
3009
|
* - current app is non-standalone mode and target app is standalone mode.
|
|
3240
3010
|
*
|
|
3241
3011
|
* Note: when current app is standalone mode, other apps will not be found.
|
|
3242
3012
|
*/
|
|
3243
3013
|
function isOutsideApp(storyboard) {
|
|
3014
|
+
var _getRuntime$getCurren;
|
|
3244
3015
|
if (process.env.NODE_ENV === "test") {
|
|
3245
3016
|
return false;
|
|
3246
3017
|
}
|
|
3247
|
-
return !storyboard ||
|
|
3018
|
+
return !storyboard ||
|
|
3019
|
+
// Sometimes `storyboard.app.standaloneMode` is incorrect.
|
|
3020
|
+
((_getRuntime$getCurren = getRuntime().getCurrentApp()) === null || _getRuntime$getCurren === void 0 ? void 0 : _getRuntime$getCurren.id) !== storyboard.app.id && !window.STANDALONE_MICRO_APPS && storyboard.app.standaloneMode;
|
|
3248
3021
|
}
|
|
3249
3022
|
|
|
3250
3023
|
var kernel;
|
|
@@ -3645,7 +3418,7 @@
|
|
|
3645
3418
|
return kernel.loadDynamicBricksInBrickConf(brickConf);
|
|
3646
3419
|
}
|
|
3647
3420
|
|
|
3648
|
-
var _excluded$
|
|
3421
|
+
var _excluded$6 = ["extraQuery", "clear", "keepHash"];
|
|
3649
3422
|
var blocked = false;
|
|
3650
3423
|
function getUserConfirmation(message, callback) {
|
|
3651
3424
|
blocked = !confirm(message);
|
|
@@ -3675,7 +3448,7 @@
|
|
|
3675
3448
|
clear,
|
|
3676
3449
|
keepHash
|
|
3677
3450
|
} = options,
|
|
3678
|
-
state = _objectWithoutProperties__default["default"](options, _excluded$
|
|
3451
|
+
state = _objectWithoutProperties__default["default"](options, _excluded$6);
|
|
3679
3452
|
var urlSearchParams = new URLSearchParams(clear ? "" : browserHistory.location.search);
|
|
3680
3453
|
var params = {};
|
|
3681
3454
|
Object.assign(params, query, extraQuery);
|
|
@@ -6746,7 +6519,7 @@
|
|
|
6746
6519
|
};
|
|
6747
6520
|
}();
|
|
6748
6521
|
|
|
6749
|
-
var _excluded$
|
|
6522
|
+
var _excluded$5 = ["feature_flags"],
|
|
6750
6523
|
_excluded2$1 = ["featureFlags", "misc"];
|
|
6751
6524
|
function standaloneBootstrap() {
|
|
6752
6525
|
return _standaloneBootstrap.apply(this, arguments);
|
|
@@ -6792,7 +6565,7 @@
|
|
|
6792
6565
|
var {
|
|
6793
6566
|
feature_flags: featureFlags
|
|
6794
6567
|
} = sys_settings,
|
|
6795
|
-
rest = _objectWithoutProperties__default["default"](sys_settings, _excluded$
|
|
6568
|
+
rest = _objectWithoutProperties__default["default"](sys_settings, _excluded$5);
|
|
6796
6569
|
settings = _objectSpread__default["default"]({
|
|
6797
6570
|
featureFlags
|
|
6798
6571
|
}, rest);
|
|
@@ -7750,6 +7523,28 @@
|
|
|
7750
7523
|
var filterProperties = ["instanceId", "brick", "slots", "properties", "events", "if", "context", "bricks", "mountPoint"];
|
|
7751
7524
|
var symbolForFormContextId = Symbol.for("form.contextId");
|
|
7752
7525
|
|
|
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
|
+
|
|
7753
7548
|
function collectRefsInTemplate(template) {
|
|
7754
7549
|
var refMap = new Map();
|
|
7755
7550
|
collectRefsInBrickConfs(template.bricks, refMap);
|
|
@@ -7805,6 +7600,207 @@
|
|
|
7805
7600
|
}
|
|
7806
7601
|
}
|
|
7807
7602
|
|
|
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
|
+
|
|
7808
7804
|
var _excluded$3 = ["properties", "slots"],
|
|
7809
7805
|
_excluded2 = ["ref", "slots"];
|
|
7810
7806
|
function expandCustomTemplate(brickConf, proxyBrick, context) {
|
|
@@ -7961,8 +7957,8 @@
|
|
|
7961
7957
|
bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(item => expandBrickInTemplate(item, proxyContext))
|
|
7962
7958
|
}];
|
|
7963
7959
|
}));
|
|
7964
|
-
setupUseBrickInTemplate(brickConfInTemplate.properties, proxyContext);
|
|
7965
7960
|
return _objectSpread__default["default"](_objectSpread__default["default"]({}, restBrickConfInTemplate), {}, {
|
|
7961
|
+
properties: setupUseBrickInTemplate(brickConfInTemplate.properties, proxyContext),
|
|
7966
7962
|
slots
|
|
7967
7963
|
}, setupTemplateProxy(proxyContext, ref, slots));
|
|
7968
7964
|
}
|