@next-core/brick-kit 2.160.0 → 2.160.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 +336 -184
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +337 -185
- package/dist/index.esm.js.map +1 -1
- package/dist/types/core/CustomForms/CustomFormContext.d.ts.map +1 -1
- package/dist/types/core/CustomForms/ExpandCustomForm.d.ts +3 -2
- package/dist/types/core/CustomForms/ExpandCustomForm.d.ts.map +1 -1
- package/dist/types/core/CustomTemplates/expandCustomTemplate.d.ts +2 -1
- package/dist/types/core/CustomTemplates/expandCustomTemplate.d.ts.map +1 -1
- package/dist/types/core/Kernel.d.ts.map +1 -1
- package/dist/types/core/LocationContext.d.ts +3 -1
- package/dist/types/core/LocationContext.d.ts.map +1 -1
- package/dist/types/core/Resolver.d.ts +3 -2
- package/dist/types/core/Resolver.d.ts.map +1 -1
- package/dist/types/core/Router.d.ts +1 -0
- package/dist/types/core/Router.d.ts.map +1 -1
- package/dist/types/core/StoryboardContext.d.ts +5 -0
- package/dist/types/core/StoryboardContext.d.ts.map +1 -1
- package/dist/types/internal/getSubStoryboardByRoute.d.ts +2 -2
- package/dist/types/internal/getSubStoryboardByRoute.d.ts.map +1 -1
- package/dist/types/internal/menu.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
|
|
|
4
4
|
import _asyncToGenerator$3 from '@babel/runtime/helpers/asyncToGenerator';
|
|
5
5
|
import _defineProperty$1 from '@babel/runtime/helpers/defineProperty';
|
|
6
6
|
import React, { useState, useEffect, useRef, useMemo, useCallback, forwardRef, useImperativeHandle, useContext, createContext, useReducer } from 'react';
|
|
7
|
-
import { JsonStorage, toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable, transformAndInject, transform, trackContext, trackState, trackFormState, scanPermissionActionsInStoryboard, precookFunction, cook, resolveContextConcurrently, syncResolveContextConcurrently, trackUsedState, trackUsedContext, shouldAllowRecursiveEvaluations, preevaluate, inject, scanPermissionActionsInAny, matchPath, deepFreeze, createProviderClass, removeDeadConditionsInTpl, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, getDllAndDepsByResource, scanRouteAliasInStoryboard, prefetchScript, scanBricksInBrickConf, scanProcessorsInAny, loadScript, scanAppGetMenuInAny, asyncProcessBrick, scanInstalledAppsInStoryboard, removeDeadConditions, restoreDynamicTemplates, scanStoryboard, mapCustomApisToNameAndNamespace } from '@next-core/brick-utils';
|
|
7
|
+
import { JsonStorage, toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable, transformAndInject, transform, trackContext, trackState, trackFormState, scanPermissionActionsInStoryboard, precookFunction, cook, collectContextUsage, deferResolveContextConcurrently, resolveContextConcurrently, syncResolveContextConcurrently, trackUsedState, trackUsedContext, shouldAllowRecursiveEvaluations, preevaluate, inject, scanPermissionActionsInAny, matchPath, deepFreeze, createProviderClass, removeDeadConditionsInTpl, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, getDllAndDepsByResource, scanRouteAliasInStoryboard, prefetchScript, scanBricksInBrickConf, scanProcessorsInAny, loadScript, scanAppGetMenuInAny, asyncProcessBrick, scanInstalledAppsInStoryboard, removeDeadConditions, restoreDynamicTemplates, scanStoryboard, mapCustomApisToNameAndNamespace } from '@next-core/brick-utils';
|
|
8
8
|
import _, { set, get, difference, identity, uniqueId, cloneDeep, clamp, isNil, isEmpty, sortBy, orderBy, merge, isObject as isObject$1, uniq, pick, omit, findLastIndex, noop, isString as isString$1 } from 'lodash';
|
|
9
9
|
import { http, HttpResponseError, HttpAbortError, HttpFetchError } from '@next-core/brick-http';
|
|
10
10
|
import moment from 'moment';
|
|
@@ -1732,6 +1732,7 @@ class StoryboardContextWrapper {
|
|
|
1732
1732
|
_defineProperty$1(this, "data", new Map());
|
|
1733
1733
|
_defineProperty$1(this, "tplContextId", void 0);
|
|
1734
1734
|
_defineProperty$1(this, "formContextId", void 0);
|
|
1735
|
+
_defineProperty$1(this, "pendingStack", []);
|
|
1735
1736
|
this.tplContextId = tplContextId;
|
|
1736
1737
|
this.formContextId = formContextId;
|
|
1737
1738
|
}
|
|
@@ -1833,15 +1834,57 @@ class StoryboardContextWrapper {
|
|
|
1833
1834
|
detail: item.value
|
|
1834
1835
|
}));
|
|
1835
1836
|
}
|
|
1836
|
-
|
|
1837
|
+
waitForUsedContext(data) {
|
|
1837
1838
|
var _this = this;
|
|
1839
|
+
return _asyncToGenerator$3(function* () {
|
|
1840
|
+
if (_this.tplContextId || _this.formContextId) {
|
|
1841
|
+
return;
|
|
1842
|
+
}
|
|
1843
|
+
var usage = collectContextUsage(data, "CTX");
|
|
1844
|
+
if (usage.includesComputed) {
|
|
1845
|
+
for (var pending of _this.pendingStack) {
|
|
1846
|
+
yield pending.pendingResult;
|
|
1847
|
+
}
|
|
1848
|
+
} else if (usage.usedContexts.length > 0) {
|
|
1849
|
+
var _loop = function* (pendingContexts) {
|
|
1850
|
+
yield Promise.all(usage.usedContexts.map(ctx => pendingContexts.get(ctx)));
|
|
1851
|
+
};
|
|
1852
|
+
for (var {
|
|
1853
|
+
pendingContexts
|
|
1854
|
+
} of _this.pendingStack) {
|
|
1855
|
+
yield* _loop(pendingContexts);
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
})();
|
|
1859
|
+
}
|
|
1860
|
+
waitForAllContext() {
|
|
1861
|
+
var _this2 = this;
|
|
1862
|
+
return _asyncToGenerator$3(function* () {
|
|
1863
|
+
if (_this2.tplContextId || _this2.formContextId) {
|
|
1864
|
+
return;
|
|
1865
|
+
}
|
|
1866
|
+
for (var pending of _this2.pendingStack) {
|
|
1867
|
+
yield pending.pendingResult;
|
|
1868
|
+
}
|
|
1869
|
+
})();
|
|
1870
|
+
}
|
|
1871
|
+
deferDefine(contextConfs, coreContext, brick) {
|
|
1872
|
+
var {
|
|
1873
|
+
mergedContext,
|
|
1874
|
+
keyword
|
|
1875
|
+
} = this.getResolveOptions(coreContext);
|
|
1876
|
+
var pending = deferResolveContextConcurrently(Array.isArray(contextConfs) ? contextConfs : [], contextConf => resolveStoryboardContext(contextConf, mergedContext, this, brick), keyword);
|
|
1877
|
+
this.pendingStack.push(pending);
|
|
1878
|
+
}
|
|
1879
|
+
define(contextConfs, coreContext, brick) {
|
|
1880
|
+
var _this3 = this;
|
|
1838
1881
|
return _asyncToGenerator$3(function* () {
|
|
1839
1882
|
if (Array.isArray(contextConfs)) {
|
|
1840
1883
|
var {
|
|
1841
1884
|
mergedContext,
|
|
1842
1885
|
keyword
|
|
1843
|
-
} =
|
|
1844
|
-
yield resolveContextConcurrently(contextConfs, contextConf => resolveStoryboardContext(contextConf, mergedContext,
|
|
1886
|
+
} = _this3.getResolveOptions(coreContext);
|
|
1887
|
+
yield resolveContextConcurrently(contextConfs, contextConf => resolveStoryboardContext(contextConf, mergedContext, _this3, brick), keyword);
|
|
1845
1888
|
}
|
|
1846
1889
|
})();
|
|
1847
1890
|
}
|
|
@@ -1893,6 +1936,7 @@ function resolveNormalStoryboardContext(_x5, _x6, _x7, _x8) {
|
|
|
1893
1936
|
}
|
|
1894
1937
|
function _resolveNormalStoryboardContext() {
|
|
1895
1938
|
_resolveNormalStoryboardContext = _asyncToGenerator$3(function* (contextConf, mergedContext, storyboardContextWrapper, brick) {
|
|
1939
|
+
yield storyboardContextWrapper.waitForUsedContext(contextConf.if);
|
|
1896
1940
|
if (!looseCheckIf(contextConf, mergedContext)) {
|
|
1897
1941
|
return false;
|
|
1898
1942
|
}
|
|
@@ -1902,6 +1946,7 @@ function _resolveNormalStoryboardContext() {
|
|
|
1902
1946
|
var isLazyResolve = false;
|
|
1903
1947
|
if (value === undefined) {
|
|
1904
1948
|
if (contextConf.resolve) {
|
|
1949
|
+
yield storyboardContextWrapper.waitForUsedContext(contextConf.resolve.if);
|
|
1905
1950
|
if (looseCheckIf(contextConf.resolve, mergedContext)) {
|
|
1906
1951
|
load = /*#__PURE__*/function () {
|
|
1907
1952
|
var _ref = _asyncToGenerator$3(function* (options) {
|
|
@@ -1925,6 +1970,7 @@ function _resolveNormalStoryboardContext() {
|
|
|
1925
1970
|
}
|
|
1926
1971
|
}
|
|
1927
1972
|
if ((!load || isLazyResolve) && contextConf.value !== undefined) {
|
|
1973
|
+
yield storyboardContextWrapper.waitForUsedContext(contextConf.value);
|
|
1928
1974
|
// If the context has no resolve, just use its `value`.
|
|
1929
1975
|
// Or if the resolve is ignored or lazy, use its `value` as a fallback.
|
|
1930
1976
|
value = computeRealValue(contextConf.value, mergedContext, true);
|
|
@@ -2070,7 +2116,7 @@ class CustomFormContext {
|
|
|
2070
2116
|
_defineProperty$1(this, "formState", void 0);
|
|
2071
2117
|
_defineProperty$1(this, "id", uniqueId("form-ctx-"));
|
|
2072
2118
|
FormContextMap.set(this.id, this);
|
|
2073
|
-
this.formState = new StoryboardContextWrapper(
|
|
2119
|
+
this.formState = new StoryboardContextWrapper(undefined, this.id);
|
|
2074
2120
|
}
|
|
2075
2121
|
}
|
|
2076
2122
|
function getCustomFormContext(formContextId) {
|
|
@@ -2821,8 +2867,8 @@ function _mergeMenu() {
|
|
|
2821
2867
|
(function () {
|
|
2822
2868
|
var menuI18nNamespace = getI18nNamespace("menu", "".concat(menu.menuId, "~").concat(menu.app[0].appId, "+").concat(menu.instanceId));
|
|
2823
2869
|
// Support any language in `meta.i18n`.
|
|
2824
|
-
Object.entries(menu.i18n).forEach(
|
|
2825
|
-
var [lang, resources] =
|
|
2870
|
+
Object.entries(menu.i18n).forEach(_ref4 => {
|
|
2871
|
+
var [lang, resources] = _ref4;
|
|
2826
2872
|
i18next.addResourceBundle(lang, menuI18nNamespace, resources);
|
|
2827
2873
|
});
|
|
2828
2874
|
menuWithI18n.set(menu, menuI18nNamespace);
|
|
@@ -2922,8 +2968,8 @@ function _processMenu() {
|
|
|
2922
2968
|
}
|
|
2923
2969
|
collectAppsRequireI18nFulfilled(items, context.app.id, appsRequireI18nFulfilled);
|
|
2924
2970
|
yield kernel.fulfilStoryboardI18n([...appsRequireI18nFulfilled]);
|
|
2925
|
-
var menuData = _objectSpread(_objectSpread({}, computeRealValueWithOverrideApp(restMenuData, rootAppId, context, kernel)), {}, {
|
|
2926
|
-
items: computeMenuItemsWithOverrideApp(items, context, kernel)
|
|
2971
|
+
var menuData = _objectSpread(_objectSpread({}, yield computeRealValueWithOverrideApp(restMenuData, rootAppId, context, kernel)), {}, {
|
|
2972
|
+
items: yield computeMenuItemsWithOverrideApp(items, context, kernel)
|
|
2927
2973
|
});
|
|
2928
2974
|
return {
|
|
2929
2975
|
title: yield processMenuTitle(menuData),
|
|
@@ -2971,17 +3017,22 @@ function collectAppsRequireI18nFulfilled(items, contextAppId, appIds) {
|
|
|
2971
3017
|
collect(items);
|
|
2972
3018
|
}
|
|
2973
3019
|
function computeMenuItemsWithOverrideApp(items, context, kernel) {
|
|
2974
|
-
return items.map(
|
|
2975
|
-
var {
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
3020
|
+
return Promise.all(items.map( /*#__PURE__*/function () {
|
|
3021
|
+
var _ref3 = _asyncToGenerator$3(function* (_ref2) {
|
|
3022
|
+
var {
|
|
3023
|
+
children
|
|
3024
|
+
} = _ref2,
|
|
3025
|
+
rest = _objectWithoutProperties(_ref2, _excluded2$2);
|
|
3026
|
+
return _objectSpread(_objectSpread({}, yield computeRealValueWithOverrideApp(rest, rest[symbolAppId], context, kernel)), {}, {
|
|
3027
|
+
children: children && (yield computeMenuItemsWithOverrideApp(children, context, kernel))
|
|
3028
|
+
});
|
|
2981
3029
|
});
|
|
2982
|
-
|
|
3030
|
+
return function (_x20) {
|
|
3031
|
+
return _ref3.apply(this, arguments);
|
|
3032
|
+
};
|
|
3033
|
+
}()));
|
|
2983
3034
|
}
|
|
2984
|
-
function processMenuTitle(
|
|
3035
|
+
function processMenuTitle(_x21) {
|
|
2985
3036
|
return _processMenuTitle.apply(this, arguments);
|
|
2986
3037
|
}
|
|
2987
3038
|
function _processMenuTitle() {
|
|
@@ -3060,25 +3111,32 @@ function attemptToVisit(data, globals) {
|
|
|
3060
3111
|
}
|
|
3061
3112
|
return false;
|
|
3062
3113
|
}
|
|
3063
|
-
function computeRealValueWithOverrideApp(
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3114
|
+
function computeRealValueWithOverrideApp(_x22, _x23, _x24, _x25) {
|
|
3115
|
+
return _computeRealValueWithOverrideApp.apply(this, arguments);
|
|
3116
|
+
}
|
|
3117
|
+
function _computeRealValueWithOverrideApp() {
|
|
3118
|
+
_computeRealValueWithOverrideApp = _asyncToGenerator$3(function* (data, overrideAppId, context, kernel) {
|
|
3119
|
+
var newContext = context;
|
|
3120
|
+
if (overrideAppId !== context.app.id && attemptToVisit(data, ["APP", "I18N"])) {
|
|
3121
|
+
if (window.STANDALONE_MICRO_APPS) {
|
|
3122
|
+
newContext = _objectSpread(_objectSpread({}, context), {}, {
|
|
3123
|
+
overrideApp: data[symbolOverrideApp],
|
|
3124
|
+
appendI18nNamespace: data[symbolMenuI18nNamespace]
|
|
3125
|
+
});
|
|
3126
|
+
} else {
|
|
3127
|
+
var storyboard = kernel.bootstrapData.storyboards.find(story => story.app.id === overrideAppId);
|
|
3128
|
+
newContext = _objectSpread(_objectSpread({}, context), {}, {
|
|
3129
|
+
overrideApp: storyboard === null || storyboard === void 0 ? void 0 : storyboard.app,
|
|
3130
|
+
appendI18nNamespace: data[symbolMenuI18nNamespace]
|
|
3131
|
+
});
|
|
3132
|
+
}
|
|
3077
3133
|
}
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3134
|
+
yield kernel.router.waitForUsedContext(data);
|
|
3135
|
+
return computeRealValue(data, newContext, true, {
|
|
3136
|
+
ignoreSymbols: true
|
|
3137
|
+
});
|
|
3081
3138
|
});
|
|
3139
|
+
return _computeRealValueWithOverrideApp.apply(this, arguments);
|
|
3082
3140
|
}
|
|
3083
3141
|
|
|
3084
3142
|
var lazyBrickRegistry = new Map();
|
|
@@ -7635,17 +7693,21 @@ function expandCustomTemplate(brickConf, proxyBrick, context) {
|
|
|
7635
7693
|
}
|
|
7636
7694
|
return lowLevelExpandCustomTemplate(template, brickConf, proxyBrick, context, tplContext);
|
|
7637
7695
|
}
|
|
7638
|
-
function asyncExpandCustomTemplate(_x, _x2, _x3) {
|
|
7696
|
+
function asyncExpandCustomTemplate(_x, _x2, _x3, _x4) {
|
|
7639
7697
|
return _asyncExpandCustomTemplate.apply(this, arguments);
|
|
7640
7698
|
}
|
|
7641
7699
|
function _asyncExpandCustomTemplate() {
|
|
7642
|
-
_asyncExpandCustomTemplate = _asyncToGenerator$3(function* (brickConf, proxyBrick, context) {
|
|
7700
|
+
_asyncExpandCustomTemplate = _asyncToGenerator$3(function* (brickConf, proxyBrick, context, locationContext) {
|
|
7643
7701
|
var tplContext = new CustomTemplateContext(proxyBrick);
|
|
7644
7702
|
var template = customTemplateRegistry.get(brickConf.brick);
|
|
7645
7703
|
if (template.contracts) {
|
|
7646
7704
|
collectWidgetContract(template.contracts);
|
|
7647
7705
|
}
|
|
7648
7706
|
if (Array.isArray(template.state)) {
|
|
7707
|
+
if (locationContext) {
|
|
7708
|
+
// Handle use cases of using `CTX.*` in template states.
|
|
7709
|
+
yield locationContext.storyboardContextWrapper.waitForUsedContext(template.state.map(state => [state.if, state.value, state.resolve]));
|
|
7710
|
+
}
|
|
7649
7711
|
yield tplContext.state.define(template.state, context, proxyBrick);
|
|
7650
7712
|
}
|
|
7651
7713
|
return lowLevelExpandCustomTemplate(template, brickConf, proxyBrick, context, tplContext);
|
|
@@ -8992,50 +9054,85 @@ function isRouteConfOfRoutes(conf) {
|
|
|
8992
9054
|
return conf.type === "routes";
|
|
8993
9055
|
}
|
|
8994
9056
|
|
|
8995
|
-
function getSubStoryboardByRoute(
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
function
|
|
9000
|
-
|
|
9001
|
-
return
|
|
9002
|
-
|
|
9057
|
+
function getSubStoryboardByRoute(_x, _x2) {
|
|
9058
|
+
return _getSubStoryboardByRoute.apply(this, arguments);
|
|
9059
|
+
}
|
|
9060
|
+
function _getSubStoryboardByRoute() {
|
|
9061
|
+
_getSubStoryboardByRoute = _asyncToGenerator$3(function* (storyboard, matcher) {
|
|
9062
|
+
function getSubRoutes(_x3) {
|
|
9063
|
+
return _getSubRoutes.apply(this, arguments);
|
|
9064
|
+
}
|
|
9065
|
+
function _getSubRoutes() {
|
|
9066
|
+
_getSubRoutes = _asyncToGenerator$3(function* (routes) {
|
|
9067
|
+
return Promise.all((yield matcher(routes)).map(getSubRoute));
|
|
9003
9068
|
});
|
|
9069
|
+
return _getSubRoutes.apply(this, arguments);
|
|
9004
9070
|
}
|
|
9005
|
-
|
|
9006
|
-
|
|
9007
|
-
}
|
|
9008
|
-
|
|
9009
|
-
|
|
9010
|
-
|
|
9011
|
-
|
|
9012
|
-
|
|
9013
|
-
|
|
9014
|
-
|
|
9015
|
-
|
|
9016
|
-
|
|
9017
|
-
|
|
9018
|
-
slots: Object.fromEntries(Object.entries(brickConf.slots).map(_ref => {
|
|
9019
|
-
var [slotId, slotConf] = _ref;
|
|
9020
|
-
if (slotConf.type === "routes") {
|
|
9021
|
-
return [slotId, _objectSpread(_objectSpread({}, slotConf), {}, {
|
|
9022
|
-
routes: getSubRoutes(slotConf.routes)
|
|
9023
|
-
})];
|
|
9024
|
-
} /* istanbul ignore else: should never reach */else if (slotConf.type === "bricks") {
|
|
9025
|
-
return [slotId, _objectSpread(_objectSpread({}, slotConf), {}, {
|
|
9026
|
-
bricks: getSubBricks(slotConf.bricks)
|
|
9027
|
-
})];
|
|
9028
|
-
}
|
|
9029
|
-
/* istanbul ignore next: should never reach */
|
|
9030
|
-
return [slotId, slotConf];
|
|
9031
|
-
}))
|
|
9071
|
+
function getSubRoute(_x4) {
|
|
9072
|
+
return _getSubRoute.apply(this, arguments);
|
|
9073
|
+
}
|
|
9074
|
+
function _getSubRoute() {
|
|
9075
|
+
_getSubRoute = _asyncToGenerator$3(function* (route) {
|
|
9076
|
+
if (route.type === "routes") {
|
|
9077
|
+
return _objectSpread(_objectSpread({}, route), {}, {
|
|
9078
|
+
routes: yield getSubRoutes(route.routes)
|
|
9079
|
+
});
|
|
9080
|
+
}
|
|
9081
|
+
return _objectSpread(_objectSpread({}, route), {}, {
|
|
9082
|
+
bricks: yield getSubBricks(route.bricks)
|
|
9083
|
+
});
|
|
9032
9084
|
});
|
|
9085
|
+
return _getSubRoute.apply(this, arguments);
|
|
9033
9086
|
}
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9087
|
+
function getSubBricks(_x5) {
|
|
9088
|
+
return _getSubBricks.apply(this, arguments);
|
|
9089
|
+
}
|
|
9090
|
+
function _getSubBricks() {
|
|
9091
|
+
_getSubBricks = _asyncToGenerator$3(function* (bricks) {
|
|
9092
|
+
if (Array.isArray(bricks)) {
|
|
9093
|
+
return Promise.all(bricks.map(brickConf => getSubBrick(brickConf)));
|
|
9094
|
+
}
|
|
9095
|
+
return bricks;
|
|
9096
|
+
});
|
|
9097
|
+
return _getSubBricks.apply(this, arguments);
|
|
9098
|
+
}
|
|
9099
|
+
function getSubBrick(_x6) {
|
|
9100
|
+
return _getSubBrick.apply(this, arguments);
|
|
9101
|
+
}
|
|
9102
|
+
function _getSubBrick() {
|
|
9103
|
+
_getSubBrick = _asyncToGenerator$3(function* (brickConf) {
|
|
9104
|
+
if (isObject(brickConf.slots)) {
|
|
9105
|
+
return _objectSpread(_objectSpread({}, brickConf), {}, {
|
|
9106
|
+
slots: Object.fromEntries(yield Promise.all(Object.entries(brickConf.slots).map( /*#__PURE__*/function () {
|
|
9107
|
+
var _ref2 = _asyncToGenerator$3(function* (_ref) {
|
|
9108
|
+
var [slotId, slotConf] = _ref;
|
|
9109
|
+
if (slotConf.type === "routes") {
|
|
9110
|
+
return [slotId, _objectSpread(_objectSpread({}, slotConf), {}, {
|
|
9111
|
+
routes: yield getSubRoutes(slotConf.routes)
|
|
9112
|
+
})];
|
|
9113
|
+
} /* istanbul ignore else: should never reach */else if (slotConf.type === "bricks") {
|
|
9114
|
+
return [slotId, _objectSpread(_objectSpread({}, slotConf), {}, {
|
|
9115
|
+
bricks: yield getSubBricks(slotConf.bricks)
|
|
9116
|
+
})];
|
|
9117
|
+
}
|
|
9118
|
+
/* istanbul ignore next: should never reach */
|
|
9119
|
+
return [slotId, slotConf];
|
|
9120
|
+
});
|
|
9121
|
+
return function (_x7) {
|
|
9122
|
+
return _ref2.apply(this, arguments);
|
|
9123
|
+
};
|
|
9124
|
+
}())))
|
|
9125
|
+
});
|
|
9126
|
+
}
|
|
9127
|
+
return brickConf;
|
|
9128
|
+
});
|
|
9129
|
+
return _getSubBrick.apply(this, arguments);
|
|
9130
|
+
}
|
|
9131
|
+
return _objectSpread(_objectSpread({}, storyboard), {}, {
|
|
9132
|
+
routes: yield getSubRoutes(storyboard.routes)
|
|
9133
|
+
});
|
|
9038
9134
|
});
|
|
9135
|
+
return _getSubStoryboardByRoute.apply(this, arguments);
|
|
9039
9136
|
}
|
|
9040
9137
|
|
|
9041
9138
|
function listenOnTrackingContext(brick, trackingContextList, context) {
|
|
@@ -9086,14 +9183,18 @@ function ExpandCustomForm(formData, brickConf, isPreview, context) {
|
|
|
9086
9183
|
}
|
|
9087
9184
|
return getFinalStoryBoard(formData, brickConf, isPreview, formContext);
|
|
9088
9185
|
}
|
|
9089
|
-
function AsyncExpandCustomForm(_x, _x2, _x3, _x4) {
|
|
9186
|
+
function AsyncExpandCustomForm(_x, _x2, _x3, _x4, _x5) {
|
|
9090
9187
|
return _AsyncExpandCustomForm.apply(this, arguments);
|
|
9091
9188
|
}
|
|
9092
9189
|
function _AsyncExpandCustomForm() {
|
|
9093
|
-
_AsyncExpandCustomForm = _asyncToGenerator$3(function* (formData, brickConf, isPreview, context) {
|
|
9190
|
+
_AsyncExpandCustomForm = _asyncToGenerator$3(function* (formData, brickConf, isPreview, context, locationContext) {
|
|
9094
9191
|
var formContext = new CustomFormContext();
|
|
9095
9192
|
formData = initFormContext(formData, brickConf, isPreview);
|
|
9096
9193
|
if (Array.isArray(formData.context)) {
|
|
9194
|
+
if (locationContext) {
|
|
9195
|
+
// Handle use cases of using `CTX.*` in template states.
|
|
9196
|
+
yield locationContext.storyboardContextWrapper.waitForUsedContext(formData.context.map(state => [state.if, state.value, state.resolve]));
|
|
9197
|
+
}
|
|
9097
9198
|
yield formContext.formState.define(formData.context, _objectSpread(_objectSpread({}, context), {}, {
|
|
9098
9199
|
formContextId: formContext.id
|
|
9099
9200
|
}), {});
|
|
@@ -9479,7 +9580,7 @@ class LocationContext {
|
|
|
9479
9580
|
_defineProperty$1(this, "observersList", []);
|
|
9480
9581
|
this.kernel = kernel;
|
|
9481
9582
|
this.location = location;
|
|
9482
|
-
this.resolver = new Resolver(kernel);
|
|
9583
|
+
this.resolver = new Resolver(kernel, this);
|
|
9483
9584
|
this.query = new URLSearchParams(location.search);
|
|
9484
9585
|
this.messageDispatcher = getMessageDispatcher();
|
|
9485
9586
|
}
|
|
@@ -9517,60 +9618,79 @@ class LocationContext {
|
|
|
9517
9618
|
match: this.currentMatch
|
|
9518
9619
|
});
|
|
9519
9620
|
}
|
|
9621
|
+
deferComputeRealValue() {
|
|
9622
|
+
var _arguments = arguments,
|
|
9623
|
+
_this = this;
|
|
9624
|
+
return _asyncToGenerator$3(function* () {
|
|
9625
|
+
yield _this.storyboardContextWrapper.waitForUsedContext(_arguments.length <= 0 ? undefined : _arguments[0]);
|
|
9626
|
+
return computeRealValue(..._arguments);
|
|
9627
|
+
})();
|
|
9628
|
+
}
|
|
9520
9629
|
matchRoutes(routes, app) {
|
|
9521
|
-
var
|
|
9522
|
-
|
|
9523
|
-
var
|
|
9524
|
-
|
|
9525
|
-
|
|
9526
|
-
|
|
9527
|
-
|
|
9528
|
-
v: "missed"
|
|
9529
|
-
};
|
|
9530
|
-
}
|
|
9531
|
-
var match = matchPath(_this.location.pathname, {
|
|
9532
|
-
path: computedPath,
|
|
9533
|
-
exact: route.exact,
|
|
9534
|
-
checkIf: context => looseCheckIf(route, context),
|
|
9535
|
-
getContext: match => _this.getContext({
|
|
9536
|
-
match
|
|
9537
|
-
})
|
|
9538
|
-
});
|
|
9539
|
-
if (match !== null) {
|
|
9540
|
-
if (app.noAuthGuard || route.public || isLoggedIn()) {
|
|
9541
|
-
_this.currentMatch = match;
|
|
9630
|
+
var _this2 = this;
|
|
9631
|
+
return _asyncToGenerator$3(function* () {
|
|
9632
|
+
var _loop = function* (route) {
|
|
9633
|
+
var computedPath = computeRealRoutePath(route.path, app);
|
|
9634
|
+
if ([].concat(computedPath).includes(undefined)) {
|
|
9635
|
+
// eslint-disable-next-line no-console
|
|
9636
|
+
console.error("Invalid route with invalid path:", route);
|
|
9542
9637
|
return {
|
|
9543
|
-
v:
|
|
9544
|
-
match,
|
|
9545
|
-
route
|
|
9546
|
-
}
|
|
9638
|
+
v: "missed"
|
|
9547
9639
|
};
|
|
9548
9640
|
}
|
|
9549
|
-
|
|
9550
|
-
|
|
9551
|
-
|
|
9641
|
+
yield _this2.storyboardContextWrapper.waitForUsedContext(route.if);
|
|
9642
|
+
var match = matchPath(_this2.location.pathname, {
|
|
9643
|
+
path: computedPath,
|
|
9644
|
+
exact: route.exact,
|
|
9645
|
+
checkIf: context => looseCheckIf(route, context),
|
|
9646
|
+
getContext: match => _this2.getContext({
|
|
9647
|
+
match
|
|
9648
|
+
})
|
|
9649
|
+
});
|
|
9650
|
+
if (match !== null) {
|
|
9651
|
+
if (app.noAuthGuard || route.public || isLoggedIn()) {
|
|
9652
|
+
_this2.currentMatch = match;
|
|
9653
|
+
return {
|
|
9654
|
+
v: {
|
|
9655
|
+
match,
|
|
9656
|
+
route
|
|
9657
|
+
}
|
|
9658
|
+
};
|
|
9659
|
+
}
|
|
9660
|
+
return {
|
|
9661
|
+
v: "unauthenticated"
|
|
9662
|
+
};
|
|
9663
|
+
}
|
|
9664
|
+
};
|
|
9665
|
+
for (var route of routes) {
|
|
9666
|
+
var _ret = yield* _loop(route);
|
|
9667
|
+
if (typeof _ret === "object") return _ret.v;
|
|
9552
9668
|
}
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
var _ret = _loop(route);
|
|
9556
|
-
if (typeof _ret === "object") return _ret.v;
|
|
9557
|
-
}
|
|
9558
|
-
return "missed";
|
|
9669
|
+
return "missed";
|
|
9670
|
+
})();
|
|
9559
9671
|
}
|
|
9560
9672
|
matchStoryboard(storyboards) {
|
|
9561
9673
|
return matchStoryboard(storyboards, this.location.pathname);
|
|
9562
9674
|
}
|
|
9563
9675
|
getSubStoryboardByRoute(storyboard) {
|
|
9564
|
-
var
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
|
|
9568
|
-
|
|
9676
|
+
var _this3 = this;
|
|
9677
|
+
return _asyncToGenerator$3(function* () {
|
|
9678
|
+
var matcher = /*#__PURE__*/function () {
|
|
9679
|
+
var _ref2 = _asyncToGenerator$3(function* (routes) {
|
|
9680
|
+
var matched = yield _this3.matchRoutes(routes, storyboard.app);
|
|
9681
|
+
return isObject(matched) ? [matched.route] : [];
|
|
9682
|
+
});
|
|
9683
|
+
return function matcher(_x) {
|
|
9684
|
+
return _ref2.apply(this, arguments);
|
|
9685
|
+
};
|
|
9686
|
+
}();
|
|
9687
|
+
return getSubStoryboardByRoute(storyboard, matcher);
|
|
9688
|
+
})();
|
|
9569
9689
|
}
|
|
9570
9690
|
mountRoutes(routes, slotId, mountRoutesResult) {
|
|
9571
|
-
var
|
|
9691
|
+
var _this4 = this;
|
|
9572
9692
|
return _asyncToGenerator$3(function* () {
|
|
9573
|
-
var matched =
|
|
9693
|
+
var matched = yield _this4.matchRoutes(routes, _this4.kernel.nextApp);
|
|
9574
9694
|
var redirect;
|
|
9575
9695
|
var redirectConf = {};
|
|
9576
9696
|
var context;
|
|
@@ -9584,19 +9704,26 @@ class LocationContext {
|
|
|
9584
9704
|
default:
|
|
9585
9705
|
mountRoutesResult.route = route = matched.route;
|
|
9586
9706
|
if (route.segues) {
|
|
9587
|
-
Object.assign(
|
|
9707
|
+
Object.assign(_this4.segues, route.segues);
|
|
9588
9708
|
}
|
|
9589
9709
|
if (route.hybrid) {
|
|
9590
9710
|
mountRoutesResult.flags.hybrid = true;
|
|
9591
9711
|
}
|
|
9592
|
-
context =
|
|
9712
|
+
context = _this4.getContext({
|
|
9593
9713
|
match: matched.match
|
|
9594
9714
|
});
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
yield
|
|
9598
|
-
|
|
9599
|
-
|
|
9715
|
+
yield _this4.storyboardContextWrapper.waitForUsedContext(route.defineResolves);
|
|
9716
|
+
_this4.resolver.defineResolves(route.defineResolves, context);
|
|
9717
|
+
yield _this4.mountProviders(route.providers, matched.match, slotId, mountRoutesResult);
|
|
9718
|
+
|
|
9719
|
+
// istanbul ignore else
|
|
9720
|
+
if (_this4.kernel.getFeatureFlags()["next-core-deferred-context"]) {
|
|
9721
|
+
_this4.storyboardContextWrapper.deferDefine(route.context, context);
|
|
9722
|
+
} else {
|
|
9723
|
+
yield _this4.storyboardContextWrapper.define(route.context, context);
|
|
9724
|
+
}
|
|
9725
|
+
yield _this4.preCheckPermissions(route, context);
|
|
9726
|
+
redirect = yield _this4.deferComputeRealValue(route.redirect, context, true);
|
|
9600
9727
|
if (redirect) {
|
|
9601
9728
|
if (typeof redirect === "string") {
|
|
9602
9729
|
// Directly redirect.
|
|
@@ -9606,7 +9733,7 @@ class LocationContext {
|
|
|
9606
9733
|
break;
|
|
9607
9734
|
} else {
|
|
9608
9735
|
// Resolvable redirect.
|
|
9609
|
-
yield
|
|
9736
|
+
yield _this4.resolver.resolveOne("reference", redirect, redirectConf);
|
|
9610
9737
|
if (redirectConf.redirect) {
|
|
9611
9738
|
mountRoutesResult.flags.redirect = {
|
|
9612
9739
|
path: redirectConf.redirect
|
|
@@ -9615,20 +9742,20 @@ class LocationContext {
|
|
|
9615
9742
|
}
|
|
9616
9743
|
}
|
|
9617
9744
|
}
|
|
9618
|
-
yield
|
|
9745
|
+
yield _this4.mountMenu(route.menu, matched.match, mountRoutesResult);
|
|
9619
9746
|
if (route.documentId) {
|
|
9620
9747
|
mountRoutesResult.appBar.documentId = route.documentId;
|
|
9621
9748
|
}
|
|
9622
9749
|
if (isRouteConfOfRoutes(route) && Array.isArray(route.routes)) {
|
|
9623
|
-
yield
|
|
9624
|
-
yield
|
|
9750
|
+
yield _this4.preFetchMenu(route.context);
|
|
9751
|
+
yield _this4.mountRoutes(route.routes, slotId, mountRoutesResult);
|
|
9625
9752
|
} else if (isRouteConfOfBricks(route) && Array.isArray(route.bricks)) {
|
|
9626
|
-
yield
|
|
9627
|
-
yield
|
|
9753
|
+
yield _this4.preFetchMenu(route);
|
|
9754
|
+
yield _this4.mountBricks(route.bricks, matched.match, slotId, mountRoutesResult);
|
|
9628
9755
|
|
|
9629
9756
|
// analytics data (page_view event)
|
|
9630
9757
|
if (route.analyticsData) {
|
|
9631
|
-
mountRoutesResult.analyticsData =
|
|
9758
|
+
mountRoutesResult.analyticsData = yield _this4.deferComputeRealValue(route.analyticsData, context, true);
|
|
9632
9759
|
}
|
|
9633
9760
|
}
|
|
9634
9761
|
}
|
|
@@ -9636,7 +9763,7 @@ class LocationContext {
|
|
|
9636
9763
|
})();
|
|
9637
9764
|
}
|
|
9638
9765
|
mountMenu(menuConf, match, mountRoutesResult) {
|
|
9639
|
-
var
|
|
9766
|
+
var _this5 = this;
|
|
9640
9767
|
return _asyncToGenerator$3(function* () {
|
|
9641
9768
|
if (menuConf === false) {
|
|
9642
9769
|
// `route.menu` 设置为 `false` 表示不显示顶栏和侧栏。
|
|
@@ -9648,7 +9775,7 @@ class LocationContext {
|
|
|
9648
9775
|
if (!menuConf) {
|
|
9649
9776
|
return;
|
|
9650
9777
|
}
|
|
9651
|
-
var context =
|
|
9778
|
+
var context = _this5.getContext({
|
|
9652
9779
|
match
|
|
9653
9780
|
});
|
|
9654
9781
|
if (menuConf.type === "brick") {
|
|
@@ -9658,6 +9785,7 @@ class LocationContext {
|
|
|
9658
9785
|
// 那么可以将菜单配置指定为一个构件,这个构件会被装载到背景容器中(不会在界面中显示),
|
|
9659
9786
|
// 应该在这个构件的 `connectedCallback` 中执行相关菜单设置,
|
|
9660
9787
|
// 例如 `getRuntime().menuBar.setAppMenu(...)`。
|
|
9788
|
+
yield _this5.storyboardContextWrapper.waitForUsedContext(menuConf.properties);
|
|
9661
9789
|
var brick = {
|
|
9662
9790
|
type: menuConf.brick,
|
|
9663
9791
|
properties: computeRealProperties(menuConf.properties, context, menuConf.injectDeep !== false),
|
|
@@ -9665,16 +9793,16 @@ class LocationContext {
|
|
|
9665
9793
|
context,
|
|
9666
9794
|
children: []
|
|
9667
9795
|
};
|
|
9668
|
-
|
|
9796
|
+
_this5.registerHandlersFromLifeCycle(menuConf.lifeCycle, brick, match);
|
|
9669
9797
|
|
|
9670
9798
|
// Then, resolve the brick.
|
|
9671
|
-
yield
|
|
9799
|
+
yield _this5.resolver.resolve(menuConf, brick, context);
|
|
9672
9800
|
mountRoutesResult.menuInBg.push(brick);
|
|
9673
9801
|
return;
|
|
9674
9802
|
}
|
|
9675
9803
|
var injectDeep = menuConf.injectDeep;
|
|
9676
9804
|
if (menuConf.type === "resolve") {
|
|
9677
|
-
yield
|
|
9805
|
+
yield _this5.resolver.resolveOne("reference", _objectSpread({
|
|
9678
9806
|
transformMapArray: false
|
|
9679
9807
|
}, menuConf.resolve), menuConf, null, context);
|
|
9680
9808
|
injectDeep = false;
|
|
@@ -9682,7 +9810,7 @@ class LocationContext {
|
|
|
9682
9810
|
|
|
9683
9811
|
// 静态菜单配置,仅在有值时才设置,这样可以让菜单设置也具有按路由层级覆盖的能力。
|
|
9684
9812
|
var otherMenuConf = omit(menuConf, ["injectDeep", "type"]);
|
|
9685
|
-
var injectedMenuConf = injectDeep !== false ?
|
|
9813
|
+
var injectedMenuConf = injectDeep !== false ? yield _this5.deferComputeRealValue(otherMenuConf, context, true) : otherMenuConf;
|
|
9686
9814
|
var {
|
|
9687
9815
|
sidebarMenu,
|
|
9688
9816
|
pageTitle,
|
|
@@ -9714,11 +9842,11 @@ class LocationContext {
|
|
|
9714
9842
|
})();
|
|
9715
9843
|
}
|
|
9716
9844
|
mountProviders(providers, match, slotId, mountRoutesResult) {
|
|
9717
|
-
var
|
|
9845
|
+
var _this6 = this;
|
|
9718
9846
|
return _asyncToGenerator$3(function* () {
|
|
9719
9847
|
if (Array.isArray(providers)) {
|
|
9720
9848
|
for (var providerConf of providers) {
|
|
9721
|
-
yield
|
|
9849
|
+
yield _this6.mountBrick(_objectSpread(_objectSpread({}, typeof providerConf === "string" ? {
|
|
9722
9850
|
brick: providerConf
|
|
9723
9851
|
} : providerConf), {}, {
|
|
9724
9852
|
bg: true,
|
|
@@ -9729,11 +9857,11 @@ class LocationContext {
|
|
|
9729
9857
|
})();
|
|
9730
9858
|
}
|
|
9731
9859
|
mountBricks(bricks, match, slotId, mountRoutesResult, tplStack) {
|
|
9732
|
-
var
|
|
9860
|
+
var _this7 = this;
|
|
9733
9861
|
return _asyncToGenerator$3(function* () {
|
|
9734
9862
|
for (var brickConf of bricks) {
|
|
9735
9863
|
try {
|
|
9736
|
-
yield
|
|
9864
|
+
yield _this7.mountBrick(brickConf, match, slotId, mountRoutesResult, tplStack && new Map(tplStack));
|
|
9737
9865
|
} catch (error) {
|
|
9738
9866
|
if (error instanceof ResolveRequestError) {
|
|
9739
9867
|
var errorMessage = httpErrorToString(error.rawError);
|
|
@@ -9761,57 +9889,59 @@ class LocationContext {
|
|
|
9761
9889
|
})();
|
|
9762
9890
|
}
|
|
9763
9891
|
checkResolvableIf(ifContainer, context) {
|
|
9764
|
-
var
|
|
9892
|
+
var _this8 = this;
|
|
9765
9893
|
return _asyncToGenerator$3(function* () {
|
|
9894
|
+
yield _this8.storyboardContextWrapper.waitForUsedContext(ifContainer.if);
|
|
9766
9895
|
if (isObject(ifContainer.if)) {
|
|
9767
9896
|
var ifChecked = computeRealValue(ifContainer.if, context, true);
|
|
9768
9897
|
var ifConf = {};
|
|
9769
|
-
yield
|
|
9898
|
+
yield _this8.resolver.resolveOne("reference", ifChecked, ifConf);
|
|
9770
9899
|
return !hasOwnProperty(ifConf, "if") || !!ifConf.if;
|
|
9771
9900
|
}
|
|
9772
9901
|
return looseCheckIf(ifContainer, context);
|
|
9773
9902
|
})();
|
|
9774
9903
|
}
|
|
9775
9904
|
preCheckPermissions(container, context) {
|
|
9905
|
+
var _this9 = this;
|
|
9776
9906
|
return _asyncToGenerator$3(function* () {
|
|
9777
9907
|
if (isLoggedIn() && !getAuth().isAdmin && container.permissionsPreCheck && Array.isArray(container.permissionsPreCheck)) {
|
|
9778
|
-
var usedActions =
|
|
9908
|
+
var usedActions = yield _this9.deferComputeRealValue(container.permissionsPreCheck, context, true);
|
|
9779
9909
|
yield validatePermissions(usedActions);
|
|
9780
9910
|
}
|
|
9781
9911
|
})();
|
|
9782
9912
|
}
|
|
9783
9913
|
mountBrick(brickConf, match, slotId, mountRoutesResult) {
|
|
9784
|
-
var
|
|
9785
|
-
|
|
9914
|
+
var _arguments2 = arguments,
|
|
9915
|
+
_this10 = this;
|
|
9786
9916
|
return _asyncToGenerator$3(function* () {
|
|
9787
|
-
var
|
|
9788
|
-
var tplStack =
|
|
9917
|
+
var _this10$kernel$nextAp, _brickConf$lifeCycle, _brick$lifeCycle;
|
|
9918
|
+
var tplStack = _arguments2.length > 4 && _arguments2[4] !== undefined ? _arguments2[4] : new Map();
|
|
9789
9919
|
var tplContextId = brickConf[symbolForTplContextId];
|
|
9790
9920
|
var formContextId = brickConf[symbolForFormContextId];
|
|
9791
|
-
var context =
|
|
9921
|
+
var context = _this10.getContext({
|
|
9792
9922
|
match,
|
|
9793
9923
|
tplContextId,
|
|
9794
9924
|
formContextId
|
|
9795
9925
|
});
|
|
9796
9926
|
|
|
9797
9927
|
// First, check whether the brick should be rendered.
|
|
9798
|
-
if (!(yield
|
|
9928
|
+
if (!(yield _this10.checkResolvableIf(brickConf, context))) {
|
|
9799
9929
|
return;
|
|
9800
9930
|
}
|
|
9801
9931
|
|
|
9802
9932
|
// Then, resolve the template to a brick.
|
|
9803
9933
|
if (brickConf.template) {
|
|
9804
|
-
yield
|
|
9934
|
+
yield _this10.resolver.resolve(brickConf, null, context);
|
|
9805
9935
|
}
|
|
9806
9936
|
|
|
9807
9937
|
// Check `if` again for dynamic loaded templates.
|
|
9808
|
-
if (!(yield
|
|
9938
|
+
if (!(yield _this10.checkResolvableIf(brickConf, context))) {
|
|
9809
9939
|
return;
|
|
9810
9940
|
}
|
|
9811
9941
|
|
|
9812
9942
|
// If it's a custom template, `tplTagName` is the tag name of the template.
|
|
9813
9943
|
// Otherwise, `tplTagName` is false.
|
|
9814
|
-
var tplTagName = getTagNameOfCustomTemplate(brickConf.brick, (
|
|
9944
|
+
var tplTagName = getTagNameOfCustomTemplate(brickConf.brick, (_this10$kernel$nextAp = _this10.kernel.nextApp) === null || _this10$kernel$nextAp === void 0 ? void 0 : _this10$kernel$nextAp.id);
|
|
9815
9945
|
if (tplTagName) {
|
|
9816
9946
|
var _tplStack$get;
|
|
9817
9947
|
var tplCount = (_tplStack$get = tplStack.get(tplTagName)) !== null && _tplStack$get !== void 0 ? _tplStack$get : 0;
|
|
@@ -9824,9 +9954,16 @@ class LocationContext {
|
|
|
9824
9954
|
brickConf.properties.formData = JSON.stringify(brickConf.properties.formData);
|
|
9825
9955
|
}
|
|
9826
9956
|
var brick = {};
|
|
9827
|
-
|
|
9828
|
-
|
|
9957
|
+
|
|
9958
|
+
// istanbul ignore else
|
|
9959
|
+
if (_this10.kernel.getFeatureFlags()["next-core-deferred-context"]) {
|
|
9960
|
+
_this10.storyboardContextWrapper.deferDefine(brickConf.context, context, brick);
|
|
9961
|
+
} else {
|
|
9962
|
+
yield _this10.storyboardContextWrapper.define(brickConf.context, context, brick);
|
|
9963
|
+
}
|
|
9964
|
+
yield _this10.preCheckPermissions(brickConf, context);
|
|
9829
9965
|
var trackingContextList = [];
|
|
9966
|
+
yield _this10.storyboardContextWrapper.waitForUsedContext(brickConf.properties);
|
|
9830
9967
|
Object.assign(brick, _objectSpread({
|
|
9831
9968
|
type: tplTagName || brickConf.brick,
|
|
9832
9969
|
properties: computeRealProperties(brickConf.properties, context, brickConf.injectDeep !== false, trackingContextList),
|
|
@@ -9844,8 +9981,8 @@ class LocationContext {
|
|
|
9844
9981
|
}
|
|
9845
9982
|
} : {}));
|
|
9846
9983
|
if (brickConf[symbolForComputedPropsFromProxy]) {
|
|
9847
|
-
Object.entries(brickConf[symbolForComputedPropsFromProxy]).forEach(
|
|
9848
|
-
var [propName, propValue] =
|
|
9984
|
+
Object.entries(brickConf[symbolForComputedPropsFromProxy]).forEach(_ref3 => {
|
|
9985
|
+
var [propName, propValue] = _ref3;
|
|
9849
9986
|
set(brick.properties, propName, propValue);
|
|
9850
9987
|
});
|
|
9851
9988
|
}
|
|
@@ -9853,36 +9990,36 @@ class LocationContext {
|
|
|
9853
9990
|
if (brick.refForProxy) {
|
|
9854
9991
|
brick.refForProxy.brick = brick;
|
|
9855
9992
|
}
|
|
9856
|
-
|
|
9993
|
+
_this10.registerHandlersFromLifeCycle(brickConf.lifeCycle, brick, match, tplContextId);
|
|
9857
9994
|
if ((_brick$lifeCycle = brick.lifeCycle) !== null && _brick$lifeCycle !== void 0 && _brick$lifeCycle.onScrollIntoView) {
|
|
9858
|
-
|
|
9995
|
+
_this10.brickBindObserver(brick);
|
|
9859
9996
|
}
|
|
9860
9997
|
|
|
9861
9998
|
// Then, resolve the brick.
|
|
9862
|
-
yield
|
|
9999
|
+
yield _this10.resolver.resolve(brickConf, brick, context);
|
|
9863
10000
|
var expandedBrickConf = brickConf;
|
|
9864
10001
|
var isBaseLayout = ["base-layout.tpl-homepage-base-module", "base-layout.tpl-base-page-module", "base-layout.tpl-homepage-base-module-cmdb", "base-layout.tpl-base-page-module-cmdb"].includes(tplTagName);
|
|
9865
|
-
if (tplTagName && (!isBaseLayout ||
|
|
10002
|
+
if (tplTagName && (!isBaseLayout || _this10.kernel.getFeatureFlags()["support-ui-8.0-base-layout"] && isBaseLayout)) {
|
|
9866
10003
|
var _customTemplateRegist;
|
|
9867
|
-
yield
|
|
10004
|
+
yield _this10.preFetchMenu((_customTemplateRegist = customTemplateRegistry.get(tplTagName)) === null || _customTemplateRegist === void 0 ? void 0 : _customTemplateRegist.bricks);
|
|
9868
10005
|
expandedBrickConf = yield asyncExpandCustomTemplate(_objectSpread(_objectSpread({}, brickConf), {}, {
|
|
9869
10006
|
brick: tplTagName,
|
|
9870
10007
|
// Properties are computed for custom templates.
|
|
9871
10008
|
properties: brick.properties
|
|
9872
|
-
}), brick, context);
|
|
10009
|
+
}), brick, context, _this10);
|
|
9873
10010
|
|
|
9874
10011
|
// Try to load deps for dynamic added bricks.
|
|
9875
|
-
yield
|
|
10012
|
+
yield _this10.kernel.loadDynamicBricksInBrickConf(expandedBrickConf);
|
|
9876
10013
|
}
|
|
9877
10014
|
if (brick.type === formRenderer) {
|
|
9878
10015
|
var formData = typeof brick.properties.formData === "string" ? JSON.parse(brick.properties.formData) : brick.properties.formData;
|
|
9879
|
-
expandedBrickConf = yield AsyncExpandCustomForm(formData, brickConf, brick.properties.isPreview, context);
|
|
9880
|
-
yield
|
|
10016
|
+
expandedBrickConf = yield AsyncExpandCustomForm(formData, brickConf, brick.properties.isPreview, context, _this10);
|
|
10017
|
+
yield _this10.kernel.loadDynamicBricksInBrickConf(expandedBrickConf);
|
|
9881
10018
|
}
|
|
9882
10019
|
if (expandedBrickConf.exports) {
|
|
9883
10020
|
for (var [prop, ctxName] of Object.entries(expandedBrickConf.exports)) {
|
|
9884
10021
|
if (typeof ctxName === "string" && ctxName.startsWith("CTX.")) {
|
|
9885
|
-
|
|
10022
|
+
_this10.storyboardContextWrapper.set(ctxName.substring(4), {
|
|
9886
10023
|
type: "brick-property",
|
|
9887
10024
|
brick,
|
|
9888
10025
|
prop
|
|
@@ -9893,8 +10030,8 @@ class LocationContext {
|
|
|
9893
10030
|
if (expandedBrickConf.bg) {
|
|
9894
10031
|
// A bg brick has no slotId.
|
|
9895
10032
|
brick.slotId = undefined;
|
|
9896
|
-
yield
|
|
9897
|
-
appendBrick(brick,
|
|
10033
|
+
yield _this10.kernel.loadDynamicBricks([brick.type]);
|
|
10034
|
+
appendBrick(brick, _this10.kernel.mountPoints.bg);
|
|
9898
10035
|
} else {
|
|
9899
10036
|
if (expandedBrickConf.portal) {
|
|
9900
10037
|
// A portal brick has no slotId.
|
|
@@ -9909,9 +10046,9 @@ class LocationContext {
|
|
|
9909
10046
|
main: brick.children
|
|
9910
10047
|
});
|
|
9911
10048
|
if (slotConf.type === "bricks") {
|
|
9912
|
-
yield
|
|
10049
|
+
yield _this10.mountBricks(slotConf.bricks, match, _slotId, slottedMountRoutesResult, tplStack);
|
|
9913
10050
|
} else if (slotConf.type === "routes") {
|
|
9914
|
-
yield
|
|
10051
|
+
yield _this10.mountRoutes(slotConf.routes, _slotId, slottedMountRoutesResult);
|
|
9915
10052
|
}
|
|
9916
10053
|
}
|
|
9917
10054
|
}
|
|
@@ -10087,11 +10224,11 @@ class LocationContext {
|
|
|
10087
10224
|
}
|
|
10088
10225
|
}
|
|
10089
10226
|
preFetchMenu(data) {
|
|
10090
|
-
var
|
|
10227
|
+
var _this11 = this;
|
|
10091
10228
|
return _asyncToGenerator$3(function* () {
|
|
10092
10229
|
var useMenus = scanAppGetMenuInAny(data);
|
|
10093
10230
|
if (useMenus.length) {
|
|
10094
|
-
yield preConstructMenus(useMenus,
|
|
10231
|
+
yield preConstructMenus(useMenus, _this11.getCurrentContext(), _this11.kernel);
|
|
10095
10232
|
}
|
|
10096
10233
|
})();
|
|
10097
10234
|
}
|
|
@@ -10278,12 +10415,13 @@ function makeProviderRefreshable(providerBrick) {
|
|
|
10278
10415
|
}
|
|
10279
10416
|
|
|
10280
10417
|
class Resolver {
|
|
10281
|
-
constructor(kernel) {
|
|
10418
|
+
constructor(kernel, locationContext) {
|
|
10282
10419
|
_defineProperty$1(this, "cache", new Map());
|
|
10283
10420
|
_defineProperty$1(this, "refreshQueue", new Map());
|
|
10284
10421
|
_defineProperty$1(this, "definedResolves", new Map());
|
|
10285
10422
|
_defineProperty$1(this, "active", true);
|
|
10286
10423
|
this.kernel = kernel;
|
|
10424
|
+
this.locationContext = locationContext;
|
|
10287
10425
|
}
|
|
10288
10426
|
resetRefreshQueue() {
|
|
10289
10427
|
if (this.refreshQueue.size > 0) {
|
|
@@ -10307,9 +10445,15 @@ class Resolver {
|
|
|
10307
10445
|
var _this = this;
|
|
10308
10446
|
return _asyncToGenerator$3(function* () {
|
|
10309
10447
|
var _brickConf$lifeCycle$, _brickConf$lifeCycle;
|
|
10310
|
-
var useResolves = ((_brickConf$lifeCycle$ = (_brickConf$lifeCycle = brickConf.lifeCycle) === null || _brickConf$lifeCycle === void 0 ? void 0 : _brickConf$lifeCycle.useResolves) !== null && _brickConf$lifeCycle$ !== void 0 ? _brickConf$lifeCycle$ : []).
|
|
10311
|
-
|
|
10312
|
-
|
|
10448
|
+
var useResolves = (yield Promise.all(((_brickConf$lifeCycle$ = (_brickConf$lifeCycle = brickConf.lifeCycle) === null || _brickConf$lifeCycle === void 0 ? void 0 : _brickConf$lifeCycle.useResolves) !== null && _brickConf$lifeCycle$ !== void 0 ? _brickConf$lifeCycle$ : []).map( /*#__PURE__*/function () {
|
|
10449
|
+
var _ref = _asyncToGenerator$3(function* (r) {
|
|
10450
|
+
yield _this.locationContext.storyboardContextWrapper.waitForUsedContext(r.if);
|
|
10451
|
+
return r;
|
|
10452
|
+
});
|
|
10453
|
+
return function (_x) {
|
|
10454
|
+
return _ref.apply(this, arguments);
|
|
10455
|
+
};
|
|
10456
|
+
}()))).filter(r => looseCheckIf(r, context));
|
|
10313
10457
|
yield Promise.all(useResolves.map(resolveConf => _this.resolveOne("brick", resolveConf, brickConf, brick, context)));
|
|
10314
10458
|
if (brickConf.template) {
|
|
10315
10459
|
brickConf.$$resolved = true;
|
|
@@ -10393,7 +10537,7 @@ class Resolver {
|
|
|
10393
10537
|
}
|
|
10394
10538
|
}
|
|
10395
10539
|
var actualArgs = args ? ref ? args // `args` are already computed for `defineResolves`
|
|
10396
|
-
: context ?
|
|
10540
|
+
: context ? yield _this2.locationContext.deferComputeRealValue(args, context, true) : args : providerBrick.args || [];
|
|
10397
10541
|
var cacheKey;
|
|
10398
10542
|
try {
|
|
10399
10543
|
// `actualArgs` may contain circular references, which makes
|
|
@@ -10456,6 +10600,7 @@ class Resolver {
|
|
|
10456
10600
|
yield fetchData();
|
|
10457
10601
|
} catch (error) {
|
|
10458
10602
|
if (isHandleRejectByTransform(onReject)) {
|
|
10603
|
+
yield _this2.locationContext.storyboardContextWrapper.waitForUsedContext(onReject.transform);
|
|
10459
10604
|
transformProperties(props, error, context ? computeRealValue(onReject.transform, context, true) : onReject.transform);
|
|
10460
10605
|
return;
|
|
10461
10606
|
} else if (isHandleRejectByCatch(onReject)) {
|
|
@@ -10468,18 +10613,21 @@ class Resolver {
|
|
|
10468
10613
|
yield fetchData();
|
|
10469
10614
|
}
|
|
10470
10615
|
if (ref) {
|
|
10616
|
+
yield _this2.locationContext.storyboardContextWrapper.waitForUsedContext(transform);
|
|
10471
10617
|
data = transformIntermediateData(data, context ? computeRealValue(transform, context, true) : transform, transformFrom, transformMapArray);
|
|
10472
10618
|
}
|
|
10619
|
+
var transformTo = resolveConf.transform || resolveConf.name;
|
|
10620
|
+
yield _this2.locationContext.storyboardContextWrapper.waitForUsedContext(transformTo);
|
|
10473
10621
|
transformProperties(props, data,
|
|
10474
10622
|
// Also support legacy `name`
|
|
10475
|
-
context ? computeRealValue(
|
|
10623
|
+
context ? computeRealValue(transformTo, context, true) : transformTo, resolveConf.transformFrom, resolveConf.transformMapArray);
|
|
10476
10624
|
})();
|
|
10477
10625
|
}
|
|
10478
10626
|
scheduleRefreshing() {
|
|
10479
10627
|
var _this3 = this;
|
|
10480
10628
|
var _loop = function (providerBrick, interval) {
|
|
10481
10629
|
var request = /*#__PURE__*/function () {
|
|
10482
|
-
var
|
|
10630
|
+
var _ref3 = _asyncToGenerator$3(function* () {
|
|
10483
10631
|
yield providerBrick.$refresh({
|
|
10484
10632
|
ignoreErrors: interval.ignoreErrors,
|
|
10485
10633
|
throwErrors: true,
|
|
@@ -10491,7 +10639,7 @@ class Resolver {
|
|
|
10491
10639
|
}
|
|
10492
10640
|
});
|
|
10493
10641
|
return function request() {
|
|
10494
|
-
return
|
|
10642
|
+
return _ref3.apply(this, arguments);
|
|
10495
10643
|
};
|
|
10496
10644
|
}();
|
|
10497
10645
|
interval.timeoutId = setTimeout(request, interval.delay);
|
|
@@ -10888,7 +11036,7 @@ class Router {
|
|
|
10888
11036
|
yield Promise.all(parallelRequests);
|
|
10889
11037
|
|
|
10890
11038
|
// 如果找到匹配的 storyboard,那么根据路由匹配得到的 sub-storyboard 加载它的依赖库。
|
|
10891
|
-
var subStoryboard = _this3.locationContext.getSubStoryboardByRoute(storyboard);
|
|
11039
|
+
var subStoryboard = yield _this3.locationContext.getSubStoryboardByRoute(storyboard);
|
|
10892
11040
|
({
|
|
10893
11041
|
pendingTask
|
|
10894
11042
|
} = yield _this3.kernel.loadDepsOfStoryboard(subStoryboard));
|
|
@@ -10960,6 +11108,7 @@ class Router {
|
|
|
10960
11108
|
try {
|
|
10961
11109
|
var mergedRoutes = mergePreviewRoutes(storyboard.routes);
|
|
10962
11110
|
yield locationContext.mountRoutes(mergedRoutes, undefined, mountRoutesResult);
|
|
11111
|
+
yield locationContext.storyboardContextWrapper.waitForAllContext();
|
|
10963
11112
|
} catch (error) {
|
|
10964
11113
|
// eslint-disable-next-line no-console
|
|
10965
11114
|
console.error(error);
|
|
@@ -11260,6 +11409,9 @@ class Router {
|
|
|
11260
11409
|
handleMessageClose(event) {
|
|
11261
11410
|
return this.locationContext.handleMessageClose(event);
|
|
11262
11411
|
}
|
|
11412
|
+
waitForUsedContext(data) {
|
|
11413
|
+
return this.locationContext.storyboardContextWrapper.waitForUsedContext(data);
|
|
11414
|
+
}
|
|
11263
11415
|
}
|
|
11264
11416
|
|
|
11265
11417
|
var customProcessorRegistry = new Map();
|