@next-core/brick-kit 2.166.0 → 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.
- package/dist/index.bundle.js +234 -229
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +235 -230
- package/dist/index.esm.js.map +1 -1
- package/dist/types/internal/setProperties.d.ts.map +1 -1
- package/package.json +2 -2
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, isNil, isEmpty, merge, sortBy, orderBy, isObject as isObject$1,
|
|
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';
|
|
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';
|
|
@@ -2431,6 +2431,229 @@ function evaluate(raw) {
|
|
|
2431
2431
|
}
|
|
2432
2432
|
}
|
|
2433
2433
|
|
|
2434
|
+
function isBasicProperty(propRef) {
|
|
2435
|
+
return !!propRef.refProperty;
|
|
2436
|
+
}
|
|
2437
|
+
function isTransformableProperty(propRef) {
|
|
2438
|
+
return !!propRef.refTransform;
|
|
2439
|
+
}
|
|
2440
|
+
function isMergeableProperty(propRef) {
|
|
2441
|
+
return !!propRef.mergeProperty;
|
|
2442
|
+
}
|
|
2443
|
+
function isRefProperty(propRef) {
|
|
2444
|
+
return !!propRef.ref;
|
|
2445
|
+
}
|
|
2446
|
+
function isVariableProperty(propRef) {
|
|
2447
|
+
return !!propRef.asVariable;
|
|
2448
|
+
}
|
|
2449
|
+
|
|
2450
|
+
var customTemplateRegistry = new Map();
|
|
2451
|
+
var appRegistered = new Set();
|
|
2452
|
+
var symbolForComputedPropsFromProxy = Symbol.for("tpl.computedPropsFromProxy");
|
|
2453
|
+
var symbolForRefForProxy = Symbol.for("tpl.refForProxy");
|
|
2454
|
+
var symbolForTplContextId = Symbol.for("tpl.contextId");
|
|
2455
|
+
|
|
2456
|
+
function propertyMerge(conf, value, object) {
|
|
2457
|
+
return propertyMergeAll(conf.$$mergeBase, Object.fromEntries(conf.$$mergeBase.proxies.map(proxy => [proxy.$$reversedRef, proxy === conf ? value : object[proxy.$$reversedRef]])));
|
|
2458
|
+
}
|
|
2459
|
+
function propertyMergeAll(mergeBase, object) {
|
|
2460
|
+
if (mergeBase.mergeType === "array") {
|
|
2461
|
+
return propertyMergeAllOfArray(mergeBase, object);
|
|
2462
|
+
}
|
|
2463
|
+
if (mergeBase.mergeType === "object") {
|
|
2464
|
+
return propertyMergeAllOfObject(mergeBase, object);
|
|
2465
|
+
}
|
|
2466
|
+
// istanbul ignore next: should never reach
|
|
2467
|
+
throw new TypeError("unsupported mergeType: \"".concat(mergeBase.mergeType, "\""));
|
|
2468
|
+
}
|
|
2469
|
+
function propertyMergeAllOfArray(_ref, object) {
|
|
2470
|
+
var _, _proxy$mergeArgs;
|
|
2471
|
+
var {
|
|
2472
|
+
baseValue,
|
|
2473
|
+
context,
|
|
2474
|
+
proxies
|
|
2475
|
+
} = _ref;
|
|
2476
|
+
// Use an approach like template-literal's quasis:
|
|
2477
|
+
// `quasi0${0}quais1${1}quasi2...`
|
|
2478
|
+
// Every quasi can be merged with multiple items.
|
|
2479
|
+
var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true, {
|
|
2480
|
+
$$lazyForUseBrick: true
|
|
2481
|
+
}) : [];
|
|
2482
|
+
var quasis = [];
|
|
2483
|
+
var size = computedBaseValue.length + 1;
|
|
2484
|
+
for (var i = 0; i < size; i += 1) {
|
|
2485
|
+
quasis.push([]);
|
|
2486
|
+
}
|
|
2487
|
+
for (var proxy of proxies) {
|
|
2488
|
+
var position = void 0;
|
|
2489
|
+
switch (proxy.mergeMethod) {
|
|
2490
|
+
case "append":
|
|
2491
|
+
position = computedBaseValue.length;
|
|
2492
|
+
break;
|
|
2493
|
+
case "prepend":
|
|
2494
|
+
position = 0;
|
|
2495
|
+
break;
|
|
2496
|
+
case "insertAt":
|
|
2497
|
+
// Defaults to `-1`.
|
|
2498
|
+
position = (_ = (_proxy$mergeArgs = proxy.mergeArgs) === null || _proxy$mergeArgs === void 0 ? void 0 : _proxy$mergeArgs[0]) !== null && _ !== void 0 ? _ : -1;
|
|
2499
|
+
if (position < 0) {
|
|
2500
|
+
// It's counted from the end if position is negative.
|
|
2501
|
+
position += quasis.length;
|
|
2502
|
+
}
|
|
2503
|
+
position = clamp(position, 0, computedBaseValue.length);
|
|
2504
|
+
break;
|
|
2505
|
+
// istanbul ignore next: should never reach
|
|
2506
|
+
default:
|
|
2507
|
+
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
2508
|
+
}
|
|
2509
|
+
var patchValue = object[proxy.$$reversedRef];
|
|
2510
|
+
if (!Array.isArray(patchValue)) {
|
|
2511
|
+
patchValue = [];
|
|
2512
|
+
}
|
|
2513
|
+
quasis[position].push(...patchValue);
|
|
2514
|
+
}
|
|
2515
|
+
return quasis.flatMap((item, index) => index < computedBaseValue.length ? item.concat(computedBaseValue[index]) : item);
|
|
2516
|
+
}
|
|
2517
|
+
function propertyMergeAllOfObject(_ref2, object) {
|
|
2518
|
+
var {
|
|
2519
|
+
baseValue,
|
|
2520
|
+
proxies,
|
|
2521
|
+
context
|
|
2522
|
+
} = _ref2;
|
|
2523
|
+
var computedBaseValue = isObject(baseValue) ? computeRealValue(baseValue, context, true) : {};
|
|
2524
|
+
return proxies.reduce((acc, proxy) => {
|
|
2525
|
+
switch (proxy.mergeMethod) {
|
|
2526
|
+
case "extend":
|
|
2527
|
+
return _objectSpread(_objectSpread({}, acc), object[proxy.$$reversedRef]);
|
|
2528
|
+
// istanbul ignore next: should never reach
|
|
2529
|
+
default:
|
|
2530
|
+
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
2531
|
+
}
|
|
2532
|
+
}, computedBaseValue);
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
function setupTemplateProxy(proxyContext, ref, slots) {
|
|
2536
|
+
var computedPropsFromProxy = {};
|
|
2537
|
+
var refForProxy;
|
|
2538
|
+
var {
|
|
2539
|
+
reversedProxies,
|
|
2540
|
+
templateProperties,
|
|
2541
|
+
externalSlots,
|
|
2542
|
+
templateContextId,
|
|
2543
|
+
proxyBrick
|
|
2544
|
+
} = proxyContext;
|
|
2545
|
+
if (ref && reversedProxies) {
|
|
2546
|
+
refForProxy = {};
|
|
2547
|
+
proxyBrick.proxyRefs.set(ref, refForProxy);
|
|
2548
|
+
|
|
2549
|
+
// Reversed proxies are used for expand storyboard before rendering page.
|
|
2550
|
+
if (reversedProxies.properties.has(ref)) {
|
|
2551
|
+
Object.assign(computedPropsFromProxy, Object.fromEntries(reversedProxies.properties.get(ref).flatMap(propRef => {
|
|
2552
|
+
// `propValue` is computed.
|
|
2553
|
+
var propValue = templateProperties === null || templateProperties === void 0 ? void 0 : templateProperties[propRef.$$reversedRef];
|
|
2554
|
+
if (isTransformableProperty(propRef)) {
|
|
2555
|
+
return Object.entries(preprocessTransformProperties({
|
|
2556
|
+
[propRef.$$reversedRef]: propValue
|
|
2557
|
+
}, propRef.refTransform));
|
|
2558
|
+
}
|
|
2559
|
+
if (isBasicProperty(propRef)) {
|
|
2560
|
+
return [[propRef.refProperty, propValue]];
|
|
2561
|
+
}
|
|
2562
|
+
// Ignore Variable properties.
|
|
2563
|
+
// And mergeable properties are processed later.
|
|
2564
|
+
return [];
|
|
2565
|
+
}).filter(propRef => propRef[1] !== undefined)));
|
|
2566
|
+
|
|
2567
|
+
// Brick properties can be merged multiple times.
|
|
2568
|
+
if (reversedProxies.mergeBases.has(ref)) {
|
|
2569
|
+
Object.assign(computedPropsFromProxy, Object.fromEntries(Array.from(reversedProxies.mergeBases.get(ref).entries()).map(_ref => {
|
|
2570
|
+
var [mergeProperty, mergeBase] = _ref;
|
|
2571
|
+
return [mergeProperty, propertyMergeAll(mergeBase, templateProperties !== null && templateProperties !== void 0 ? templateProperties : {})];
|
|
2572
|
+
}).filter(item => item[1] !== undefined)));
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2576
|
+
// Use an approach like template-literal's quasis:
|
|
2577
|
+
// `quasi0${0}quais1${1}quasi2...`
|
|
2578
|
+
// Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.
|
|
2579
|
+
var quasisMap = new Map();
|
|
2580
|
+
if (reversedProxies.slots.has(ref)) {
|
|
2581
|
+
for (var item of reversedProxies.slots.get(ref)) {
|
|
2582
|
+
var _item$refPosition, _externalSlots$item$$, _externalSlots$item$$2;
|
|
2583
|
+
if (!quasisMap.has(item.refSlot)) {
|
|
2584
|
+
var quasis = [];
|
|
2585
|
+
// The size of quasis should be the existed slotted bricks' size plus one.
|
|
2586
|
+
var size = hasOwnProperty(slots, item.refSlot) ? slots[item.refSlot].bricks.length + 1 : 1;
|
|
2587
|
+
for (var i = 0; i < size; i += 1) {
|
|
2588
|
+
quasis.push([]);
|
|
2589
|
+
}
|
|
2590
|
+
quasisMap.set(item.refSlot, quasis);
|
|
2591
|
+
}
|
|
2592
|
+
var expandableSlot = quasisMap.get(item.refSlot);
|
|
2593
|
+
var refPosition = (_item$refPosition = item.refPosition) !== null && _item$refPosition !== void 0 ? _item$refPosition : -1;
|
|
2594
|
+
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$$ : []));
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
var _loop = function (slotName, _quasis) {
|
|
2598
|
+
if (!hasOwnProperty(slots, slotName)) {
|
|
2599
|
+
slots[slotName] = {
|
|
2600
|
+
type: "bricks",
|
|
2601
|
+
bricks: []
|
|
2602
|
+
};
|
|
2603
|
+
}
|
|
2604
|
+
var slotConf = slots[slotName];
|
|
2605
|
+
slotConf.bricks = _quasis.flatMap((bricks, index) => index < slotConf.bricks.length ? bricks.concat(slotConf.bricks[index]) : bricks);
|
|
2606
|
+
if (slotConf.bricks.length === 0) {
|
|
2607
|
+
delete slots[slotName];
|
|
2608
|
+
}
|
|
2609
|
+
};
|
|
2610
|
+
for (var [slotName, _quasis] of quasisMap.entries()) {
|
|
2611
|
+
_loop(slotName, _quasis);
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
return {
|
|
2615
|
+
[symbolForComputedPropsFromProxy]: computedPropsFromProxy,
|
|
2616
|
+
[symbolForRefForProxy]: refForProxy,
|
|
2617
|
+
[symbolForTplContextId]: templateContextId
|
|
2618
|
+
};
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2621
|
+
var _excluded$7 = ["properties", "slots"];
|
|
2622
|
+
function setupUseBrickInTemplate(props, proxyContext) {
|
|
2623
|
+
function walk(props) {
|
|
2624
|
+
if (!isObject(props)) {
|
|
2625
|
+
return props;
|
|
2626
|
+
}
|
|
2627
|
+
if (Array.isArray(props)) {
|
|
2628
|
+
return props.map(walk);
|
|
2629
|
+
}
|
|
2630
|
+
return Object.fromEntries(Object.entries(props).map(_ref => {
|
|
2631
|
+
var [key, value] = _ref;
|
|
2632
|
+
return isObject(value) && key === "useBrick" ? Array.isArray(value) ? [key, value.map(setup)] : [key, setup(value)] : [key, walk(value)];
|
|
2633
|
+
}).concat(Object.getOwnPropertySymbols(props).map(k => [k, props[k]])));
|
|
2634
|
+
}
|
|
2635
|
+
function setup(item) {
|
|
2636
|
+
var {
|
|
2637
|
+
properties,
|
|
2638
|
+
slots: originalSlots
|
|
2639
|
+
} = item,
|
|
2640
|
+
restConf = _objectWithoutProperties(item, _excluded$7);
|
|
2641
|
+
var slots = Object.fromEntries(Object.entries(originalSlots !== null && originalSlots !== void 0 ? originalSlots : {}).map(_ref2 => {
|
|
2642
|
+
var _slotConf$bricks;
|
|
2643
|
+
var [slotName, slotConf] = _ref2;
|
|
2644
|
+
return [slotName, {
|
|
2645
|
+
type: "bricks",
|
|
2646
|
+
bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(setup)
|
|
2647
|
+
}];
|
|
2648
|
+
}));
|
|
2649
|
+
return _objectSpread(_objectSpread({}, restConf), {}, {
|
|
2650
|
+
properties: walk(properties),
|
|
2651
|
+
slots
|
|
2652
|
+
}, setupTemplateProxy(proxyContext, restConf.ref, slots));
|
|
2653
|
+
}
|
|
2654
|
+
return walk(props);
|
|
2655
|
+
}
|
|
2656
|
+
|
|
2434
2657
|
var computeRealValue = (value, context, injectDeep, internalOptions) => {
|
|
2435
2658
|
var preEvaluated = isPreEvaluated(value);
|
|
2436
2659
|
if (preEvaluated || typeof value === "string") {
|
|
@@ -2482,6 +2705,11 @@ var computeRealValue = (value, context, injectDeep, internalOptions) => {
|
|
|
2482
2705
|
};
|
|
2483
2706
|
function setProperties(bricks, properties, context, injectDeep) {
|
|
2484
2707
|
var realProps = computeRealProperties(properties, context, injectDeep);
|
|
2708
|
+
if (context.tplContextId) {
|
|
2709
|
+
realProps = setupUseBrickInTemplate(realProps, {
|
|
2710
|
+
templateContextId: context.tplContextId
|
|
2711
|
+
});
|
|
2712
|
+
}
|
|
2485
2713
|
if (!Array.isArray(bricks)) {
|
|
2486
2714
|
bricks = [bricks];
|
|
2487
2715
|
}
|
|
@@ -2549,7 +2777,7 @@ function getNextInternalOptions(internalOptions, isArray, key) {
|
|
|
2549
2777
|
}) : internalOptions;
|
|
2550
2778
|
}
|
|
2551
2779
|
|
|
2552
|
-
var _excluded$
|
|
2780
|
+
var _excluded$6 = ["children"],
|
|
2553
2781
|
_excluded2$2 = ["children"],
|
|
2554
2782
|
_excluded3 = ["items", "app"];
|
|
2555
2783
|
var symbolAppId = Symbol("appId");
|
|
@@ -2812,7 +3040,7 @@ function collectAppsRequireI18nFulfilled(items, contextAppId, appIds) {
|
|
|
2812
3040
|
var {
|
|
2813
3041
|
children
|
|
2814
3042
|
} = _ref,
|
|
2815
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
3043
|
+
rest = _objectWithoutProperties(_ref, _excluded$6);
|
|
2816
3044
|
var overrideAppId = rest[symbolAppId];
|
|
2817
3045
|
if (!rest[symbolMenuI18nNamespace] && overrideAppId !== contextAppId && !appIds.has(overrideAppId) && attemptToVisit(rest, ["I18N"])) {
|
|
2818
3046
|
appIds.add(overrideAppId);
|
|
@@ -3434,7 +3662,7 @@ function _internalApiLoadDynamicBricksInBrickConf(brickConf) {
|
|
|
3434
3662
|
return kernel.loadDynamicBricksInBrickConf(brickConf);
|
|
3435
3663
|
}
|
|
3436
3664
|
|
|
3437
|
-
var _excluded$
|
|
3665
|
+
var _excluded$5 = ["extraQuery", "clear", "keepHash"];
|
|
3438
3666
|
var blocked = false;
|
|
3439
3667
|
function getUserConfirmation(message, callback) {
|
|
3440
3668
|
blocked = !confirm(message);
|
|
@@ -3464,7 +3692,7 @@ function historyExtended(browserHistory) {
|
|
|
3464
3692
|
clear,
|
|
3465
3693
|
keepHash
|
|
3466
3694
|
} = options,
|
|
3467
|
-
state = _objectWithoutProperties(options, _excluded$
|
|
3695
|
+
state = _objectWithoutProperties(options, _excluded$5);
|
|
3468
3696
|
var urlSearchParams = new URLSearchParams(clear ? "" : browserHistory.location.search);
|
|
3469
3697
|
var params = {};
|
|
3470
3698
|
Object.assign(params, query, extraQuery);
|
|
@@ -6535,7 +6763,7 @@ var RuntimeApi_searchMicroAppStandalone = /*#__PURE__*/function () {
|
|
|
6535
6763
|
};
|
|
6536
6764
|
}();
|
|
6537
6765
|
|
|
6538
|
-
var _excluded$
|
|
6766
|
+
var _excluded$4 = ["feature_flags"],
|
|
6539
6767
|
_excluded2$1 = ["featureFlags", "misc"];
|
|
6540
6768
|
function standaloneBootstrap() {
|
|
6541
6769
|
return _standaloneBootstrap.apply(this, arguments);
|
|
@@ -6581,7 +6809,7 @@ function _standaloneBootstrap() {
|
|
|
6581
6809
|
var {
|
|
6582
6810
|
feature_flags: featureFlags
|
|
6583
6811
|
} = sys_settings,
|
|
6584
|
-
rest = _objectWithoutProperties(sys_settings, _excluded$
|
|
6812
|
+
rest = _objectWithoutProperties(sys_settings, _excluded$4);
|
|
6585
6813
|
settings = _objectSpread({
|
|
6586
6814
|
featureFlags
|
|
6587
6815
|
}, rest);
|
|
@@ -7539,28 +7767,6 @@ var formRenderer = "form-renderer.form-renderer";
|
|
|
7539
7767
|
var filterProperties = ["instanceId", "brick", "slots", "properties", "events", "if", "context", "bricks", "mountPoint"];
|
|
7540
7768
|
var symbolForFormContextId = Symbol.for("form.contextId");
|
|
7541
7769
|
|
|
7542
|
-
var customTemplateRegistry = new Map();
|
|
7543
|
-
var appRegistered = new Set();
|
|
7544
|
-
var symbolForComputedPropsFromProxy = Symbol.for("tpl.computedPropsFromProxy");
|
|
7545
|
-
var symbolForRefForProxy = Symbol.for("tpl.refForProxy");
|
|
7546
|
-
var symbolForTplContextId = Symbol.for("tpl.contextId");
|
|
7547
|
-
|
|
7548
|
-
function isBasicProperty(propRef) {
|
|
7549
|
-
return !!propRef.refProperty;
|
|
7550
|
-
}
|
|
7551
|
-
function isTransformableProperty(propRef) {
|
|
7552
|
-
return !!propRef.refTransform;
|
|
7553
|
-
}
|
|
7554
|
-
function isMergeableProperty(propRef) {
|
|
7555
|
-
return !!propRef.mergeProperty;
|
|
7556
|
-
}
|
|
7557
|
-
function isRefProperty(propRef) {
|
|
7558
|
-
return !!propRef.ref;
|
|
7559
|
-
}
|
|
7560
|
-
function isVariableProperty(propRef) {
|
|
7561
|
-
return !!propRef.asVariable;
|
|
7562
|
-
}
|
|
7563
|
-
|
|
7564
7770
|
function collectRefsInTemplate(template) {
|
|
7565
7771
|
var refMap = new Map();
|
|
7566
7772
|
collectRefsInBrickConfs(template.bricks, refMap);
|
|
@@ -7616,207 +7822,6 @@ function collectMergeBases(conf, mergeBases, contextInTemplate, refToBrickConf)
|
|
|
7616
7822
|
}
|
|
7617
7823
|
}
|
|
7618
7824
|
|
|
7619
|
-
function propertyMerge(conf, value, object) {
|
|
7620
|
-
return propertyMergeAll(conf.$$mergeBase, Object.fromEntries(conf.$$mergeBase.proxies.map(proxy => [proxy.$$reversedRef, proxy === conf ? value : object[proxy.$$reversedRef]])));
|
|
7621
|
-
}
|
|
7622
|
-
function propertyMergeAll(mergeBase, object) {
|
|
7623
|
-
if (mergeBase.mergeType === "array") {
|
|
7624
|
-
return propertyMergeAllOfArray(mergeBase, object);
|
|
7625
|
-
}
|
|
7626
|
-
if (mergeBase.mergeType === "object") {
|
|
7627
|
-
return propertyMergeAllOfObject(mergeBase, object);
|
|
7628
|
-
}
|
|
7629
|
-
// istanbul ignore next: should never reach
|
|
7630
|
-
throw new TypeError("unsupported mergeType: \"".concat(mergeBase.mergeType, "\""));
|
|
7631
|
-
}
|
|
7632
|
-
function propertyMergeAllOfArray(_ref, object) {
|
|
7633
|
-
var _, _proxy$mergeArgs;
|
|
7634
|
-
var {
|
|
7635
|
-
baseValue,
|
|
7636
|
-
context,
|
|
7637
|
-
proxies
|
|
7638
|
-
} = _ref;
|
|
7639
|
-
// Use an approach like template-literal's quasis:
|
|
7640
|
-
// `quasi0${0}quais1${1}quasi2...`
|
|
7641
|
-
// Every quasi can be merged with multiple items.
|
|
7642
|
-
var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true, {
|
|
7643
|
-
$$lazyForUseBrick: true
|
|
7644
|
-
}) : [];
|
|
7645
|
-
var quasis = [];
|
|
7646
|
-
var size = computedBaseValue.length + 1;
|
|
7647
|
-
for (var i = 0; i < size; i += 1) {
|
|
7648
|
-
quasis.push([]);
|
|
7649
|
-
}
|
|
7650
|
-
for (var proxy of proxies) {
|
|
7651
|
-
var position = void 0;
|
|
7652
|
-
switch (proxy.mergeMethod) {
|
|
7653
|
-
case "append":
|
|
7654
|
-
position = computedBaseValue.length;
|
|
7655
|
-
break;
|
|
7656
|
-
case "prepend":
|
|
7657
|
-
position = 0;
|
|
7658
|
-
break;
|
|
7659
|
-
case "insertAt":
|
|
7660
|
-
// Defaults to `-1`.
|
|
7661
|
-
position = (_ = (_proxy$mergeArgs = proxy.mergeArgs) === null || _proxy$mergeArgs === void 0 ? void 0 : _proxy$mergeArgs[0]) !== null && _ !== void 0 ? _ : -1;
|
|
7662
|
-
if (position < 0) {
|
|
7663
|
-
// It's counted from the end if position is negative.
|
|
7664
|
-
position += quasis.length;
|
|
7665
|
-
}
|
|
7666
|
-
position = clamp(position, 0, computedBaseValue.length);
|
|
7667
|
-
break;
|
|
7668
|
-
// istanbul ignore next: should never reach
|
|
7669
|
-
default:
|
|
7670
|
-
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
7671
|
-
}
|
|
7672
|
-
var patchValue = object[proxy.$$reversedRef];
|
|
7673
|
-
if (!Array.isArray(patchValue)) {
|
|
7674
|
-
patchValue = [];
|
|
7675
|
-
}
|
|
7676
|
-
quasis[position].push(...patchValue);
|
|
7677
|
-
}
|
|
7678
|
-
return quasis.flatMap((item, index) => index < computedBaseValue.length ? item.concat(computedBaseValue[index]) : item);
|
|
7679
|
-
}
|
|
7680
|
-
function propertyMergeAllOfObject(_ref2, object) {
|
|
7681
|
-
var {
|
|
7682
|
-
baseValue,
|
|
7683
|
-
proxies,
|
|
7684
|
-
context
|
|
7685
|
-
} = _ref2;
|
|
7686
|
-
var computedBaseValue = isObject(baseValue) ? computeRealValue(baseValue, context, true) : {};
|
|
7687
|
-
return proxies.reduce((acc, proxy) => {
|
|
7688
|
-
switch (proxy.mergeMethod) {
|
|
7689
|
-
case "extend":
|
|
7690
|
-
return _objectSpread(_objectSpread({}, acc), object[proxy.$$reversedRef]);
|
|
7691
|
-
// istanbul ignore next: should never reach
|
|
7692
|
-
default:
|
|
7693
|
-
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
7694
|
-
}
|
|
7695
|
-
}, computedBaseValue);
|
|
7696
|
-
}
|
|
7697
|
-
|
|
7698
|
-
function setupTemplateProxy(proxyContext, ref, slots) {
|
|
7699
|
-
var computedPropsFromProxy = {};
|
|
7700
|
-
var refForProxy;
|
|
7701
|
-
var {
|
|
7702
|
-
reversedProxies,
|
|
7703
|
-
templateProperties,
|
|
7704
|
-
externalSlots,
|
|
7705
|
-
templateContextId,
|
|
7706
|
-
proxyBrick
|
|
7707
|
-
} = proxyContext;
|
|
7708
|
-
if (ref && reversedProxies) {
|
|
7709
|
-
refForProxy = {};
|
|
7710
|
-
proxyBrick.proxyRefs.set(ref, refForProxy);
|
|
7711
|
-
|
|
7712
|
-
// Reversed proxies are used for expand storyboard before rendering page.
|
|
7713
|
-
if (reversedProxies.properties.has(ref)) {
|
|
7714
|
-
Object.assign(computedPropsFromProxy, Object.fromEntries(reversedProxies.properties.get(ref).flatMap(propRef => {
|
|
7715
|
-
// `propValue` is computed.
|
|
7716
|
-
var propValue = templateProperties === null || templateProperties === void 0 ? void 0 : templateProperties[propRef.$$reversedRef];
|
|
7717
|
-
if (isTransformableProperty(propRef)) {
|
|
7718
|
-
return Object.entries(preprocessTransformProperties({
|
|
7719
|
-
[propRef.$$reversedRef]: propValue
|
|
7720
|
-
}, propRef.refTransform));
|
|
7721
|
-
}
|
|
7722
|
-
if (isBasicProperty(propRef)) {
|
|
7723
|
-
return [[propRef.refProperty, propValue]];
|
|
7724
|
-
}
|
|
7725
|
-
// Ignore Variable properties.
|
|
7726
|
-
// And mergeable properties are processed later.
|
|
7727
|
-
return [];
|
|
7728
|
-
}).filter(propRef => propRef[1] !== undefined)));
|
|
7729
|
-
|
|
7730
|
-
// Brick properties can be merged multiple times.
|
|
7731
|
-
if (reversedProxies.mergeBases.has(ref)) {
|
|
7732
|
-
Object.assign(computedPropsFromProxy, Object.fromEntries(Array.from(reversedProxies.mergeBases.get(ref).entries()).map(_ref => {
|
|
7733
|
-
var [mergeProperty, mergeBase] = _ref;
|
|
7734
|
-
return [mergeProperty, propertyMergeAll(mergeBase, templateProperties !== null && templateProperties !== void 0 ? templateProperties : {})];
|
|
7735
|
-
}).filter(item => item[1] !== undefined)));
|
|
7736
|
-
}
|
|
7737
|
-
}
|
|
7738
|
-
|
|
7739
|
-
// Use an approach like template-literal's quasis:
|
|
7740
|
-
// `quasi0${0}quais1${1}quasi2...`
|
|
7741
|
-
// Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.
|
|
7742
|
-
var quasisMap = new Map();
|
|
7743
|
-
if (reversedProxies.slots.has(ref)) {
|
|
7744
|
-
for (var item of reversedProxies.slots.get(ref)) {
|
|
7745
|
-
var _item$refPosition, _externalSlots$item$$, _externalSlots$item$$2;
|
|
7746
|
-
if (!quasisMap.has(item.refSlot)) {
|
|
7747
|
-
var quasis = [];
|
|
7748
|
-
// The size of quasis should be the existed slotted bricks' size plus one.
|
|
7749
|
-
var size = hasOwnProperty(slots, item.refSlot) ? slots[item.refSlot].bricks.length + 1 : 1;
|
|
7750
|
-
for (var i = 0; i < size; i += 1) {
|
|
7751
|
-
quasis.push([]);
|
|
7752
|
-
}
|
|
7753
|
-
quasisMap.set(item.refSlot, quasis);
|
|
7754
|
-
}
|
|
7755
|
-
var expandableSlot = quasisMap.get(item.refSlot);
|
|
7756
|
-
var refPosition = (_item$refPosition = item.refPosition) !== null && _item$refPosition !== void 0 ? _item$refPosition : -1;
|
|
7757
|
-
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$$ : []));
|
|
7758
|
-
}
|
|
7759
|
-
}
|
|
7760
|
-
var _loop = function (slotName, _quasis) {
|
|
7761
|
-
if (!hasOwnProperty(slots, slotName)) {
|
|
7762
|
-
slots[slotName] = {
|
|
7763
|
-
type: "bricks",
|
|
7764
|
-
bricks: []
|
|
7765
|
-
};
|
|
7766
|
-
}
|
|
7767
|
-
var slotConf = slots[slotName];
|
|
7768
|
-
slotConf.bricks = _quasis.flatMap((bricks, index) => index < slotConf.bricks.length ? bricks.concat(slotConf.bricks[index]) : bricks);
|
|
7769
|
-
if (slotConf.bricks.length === 0) {
|
|
7770
|
-
delete slots[slotName];
|
|
7771
|
-
}
|
|
7772
|
-
};
|
|
7773
|
-
for (var [slotName, _quasis] of quasisMap.entries()) {
|
|
7774
|
-
_loop(slotName, _quasis);
|
|
7775
|
-
}
|
|
7776
|
-
}
|
|
7777
|
-
return {
|
|
7778
|
-
[symbolForComputedPropsFromProxy]: computedPropsFromProxy,
|
|
7779
|
-
[symbolForRefForProxy]: refForProxy,
|
|
7780
|
-
[symbolForTplContextId]: templateContextId
|
|
7781
|
-
};
|
|
7782
|
-
}
|
|
7783
|
-
|
|
7784
|
-
var _excluded$4 = ["properties", "slots"];
|
|
7785
|
-
function setupUseBrickInTemplate(props, proxyContext) {
|
|
7786
|
-
function walk(props) {
|
|
7787
|
-
if (!isObject(props)) {
|
|
7788
|
-
return props;
|
|
7789
|
-
}
|
|
7790
|
-
if (Array.isArray(props)) {
|
|
7791
|
-
return props.map(walk);
|
|
7792
|
-
}
|
|
7793
|
-
return Object.fromEntries(Object.entries(props).map(_ref => {
|
|
7794
|
-
var [key, value] = _ref;
|
|
7795
|
-
return isObject(value) && key === "useBrick" ? Array.isArray(value) ? [key, value.map(setup)] : [key, setup(value)] : [key, walk(value)];
|
|
7796
|
-
}).concat(Object.getOwnPropertySymbols(props).map(k => [k, props[k]])));
|
|
7797
|
-
}
|
|
7798
|
-
function setup(item) {
|
|
7799
|
-
var {
|
|
7800
|
-
properties,
|
|
7801
|
-
slots: originalSlots
|
|
7802
|
-
} = item,
|
|
7803
|
-
restConf = _objectWithoutProperties(item, _excluded$4);
|
|
7804
|
-
var slots = Object.fromEntries(Object.entries(originalSlots !== null && originalSlots !== void 0 ? originalSlots : {}).map(_ref2 => {
|
|
7805
|
-
var _slotConf$bricks;
|
|
7806
|
-
var [slotName, slotConf] = _ref2;
|
|
7807
|
-
return [slotName, {
|
|
7808
|
-
type: "bricks",
|
|
7809
|
-
bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(setup)
|
|
7810
|
-
}];
|
|
7811
|
-
}));
|
|
7812
|
-
return _objectSpread(_objectSpread({}, restConf), {}, {
|
|
7813
|
-
properties: walk(properties),
|
|
7814
|
-
slots
|
|
7815
|
-
}, setupTemplateProxy(proxyContext, restConf.ref, slots));
|
|
7816
|
-
}
|
|
7817
|
-
return walk(props);
|
|
7818
|
-
}
|
|
7819
|
-
|
|
7820
7825
|
var _excluded$3 = ["properties", "slots"],
|
|
7821
7826
|
_excluded2 = ["ref", "slots"];
|
|
7822
7827
|
function expandCustomTemplate(brickConf, proxyBrick, context) {
|