@next-core/brick-kit 2.160.0 → 2.160.2
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 +354 -197
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +355 -198
- 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,59 @@ 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
|
+
if (Array.isArray(contextConfs) && contextConfs.length > 0) {
|
|
1877
|
+
var pending = deferResolveContextConcurrently(contextConfs, contextConf => resolveStoryboardContext(contextConf, mergedContext, this, brick), keyword);
|
|
1878
|
+
this.pendingStack.push(pending);
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
define(contextConfs, coreContext, brick) {
|
|
1882
|
+
var _this3 = this;
|
|
1838
1883
|
return _asyncToGenerator$3(function* () {
|
|
1839
1884
|
if (Array.isArray(contextConfs)) {
|
|
1840
1885
|
var {
|
|
1841
1886
|
mergedContext,
|
|
1842
1887
|
keyword
|
|
1843
|
-
} =
|
|
1844
|
-
yield resolveContextConcurrently(contextConfs, contextConf => resolveStoryboardContext(contextConf, mergedContext,
|
|
1888
|
+
} = _this3.getResolveOptions(coreContext);
|
|
1889
|
+
yield resolveContextConcurrently(contextConfs, contextConf => resolveStoryboardContext(contextConf, mergedContext, _this3, brick), keyword);
|
|
1845
1890
|
}
|
|
1846
1891
|
})();
|
|
1847
1892
|
}
|
|
@@ -1893,6 +1938,7 @@ function resolveNormalStoryboardContext(_x5, _x6, _x7, _x8) {
|
|
|
1893
1938
|
}
|
|
1894
1939
|
function _resolveNormalStoryboardContext() {
|
|
1895
1940
|
_resolveNormalStoryboardContext = _asyncToGenerator$3(function* (contextConf, mergedContext, storyboardContextWrapper, brick) {
|
|
1941
|
+
yield storyboardContextWrapper.waitForUsedContext(contextConf.if);
|
|
1896
1942
|
if (!looseCheckIf(contextConf, mergedContext)) {
|
|
1897
1943
|
return false;
|
|
1898
1944
|
}
|
|
@@ -1902,6 +1948,7 @@ function _resolveNormalStoryboardContext() {
|
|
|
1902
1948
|
var isLazyResolve = false;
|
|
1903
1949
|
if (value === undefined) {
|
|
1904
1950
|
if (contextConf.resolve) {
|
|
1951
|
+
yield storyboardContextWrapper.waitForUsedContext(contextConf.resolve.if);
|
|
1905
1952
|
if (looseCheckIf(contextConf.resolve, mergedContext)) {
|
|
1906
1953
|
load = /*#__PURE__*/function () {
|
|
1907
1954
|
var _ref = _asyncToGenerator$3(function* (options) {
|
|
@@ -1925,6 +1972,7 @@ function _resolveNormalStoryboardContext() {
|
|
|
1925
1972
|
}
|
|
1926
1973
|
}
|
|
1927
1974
|
if ((!load || isLazyResolve) && contextConf.value !== undefined) {
|
|
1975
|
+
yield storyboardContextWrapper.waitForUsedContext(contextConf.value);
|
|
1928
1976
|
// If the context has no resolve, just use its `value`.
|
|
1929
1977
|
// Or if the resolve is ignored or lazy, use its `value` as a fallback.
|
|
1930
1978
|
value = computeRealValue(contextConf.value, mergedContext, true);
|
|
@@ -2070,7 +2118,7 @@ class CustomFormContext {
|
|
|
2070
2118
|
_defineProperty$1(this, "formState", void 0);
|
|
2071
2119
|
_defineProperty$1(this, "id", uniqueId("form-ctx-"));
|
|
2072
2120
|
FormContextMap.set(this.id, this);
|
|
2073
|
-
this.formState = new StoryboardContextWrapper(
|
|
2121
|
+
this.formState = new StoryboardContextWrapper(undefined, this.id);
|
|
2074
2122
|
}
|
|
2075
2123
|
}
|
|
2076
2124
|
function getCustomFormContext(formContextId) {
|
|
@@ -2727,20 +2775,23 @@ function constructMenu(_x, _x2, _x3) {
|
|
|
2727
2775
|
function _constructMenu() {
|
|
2728
2776
|
_constructMenu = _asyncToGenerator$3(function* (menuBar, context, kernel) {
|
|
2729
2777
|
var hasSubMenu = !!menuBar.subMenuId;
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2778
|
+
yield Promise.all([_asyncToGenerator$3(function* () {
|
|
2779
|
+
if (menuBar.menuId) {
|
|
2780
|
+
var _menuBar$menu;
|
|
2781
|
+
var defaultCollapsed = (_menuBar$menu = menuBar.menu) === null || _menuBar$menu === void 0 ? void 0 : _menuBar$menu.defaultCollapsed;
|
|
2782
|
+
var menu = yield processMenu(menuBar.menuId, context, kernel, hasSubMenu);
|
|
2783
|
+
if (!isNil(defaultCollapsed)) {
|
|
2784
|
+
menu.defaultCollapsed = defaultCollapsed;
|
|
2785
|
+
}
|
|
2786
|
+
menuBar.menu = menu;
|
|
2787
|
+
}
|
|
2788
|
+
})(), _asyncToGenerator$3(function* () {
|
|
2789
|
+
if (hasSubMenu) {
|
|
2790
|
+
menuBar.subMenu = yield processMenu(menuBar.subMenuId, context, kernel);
|
|
2791
|
+
} else {
|
|
2792
|
+
menuBar.subMenu = null;
|
|
2736
2793
|
}
|
|
2737
|
-
|
|
2738
|
-
}
|
|
2739
|
-
if (hasSubMenu) {
|
|
2740
|
-
menuBar.subMenu = yield processMenu(menuBar.subMenuId, context, kernel);
|
|
2741
|
-
} else {
|
|
2742
|
-
menuBar.subMenu = null;
|
|
2743
|
-
}
|
|
2794
|
+
})()]);
|
|
2744
2795
|
});
|
|
2745
2796
|
return _constructMenu.apply(this, arguments);
|
|
2746
2797
|
}
|
|
@@ -2821,8 +2872,8 @@ function _mergeMenu() {
|
|
|
2821
2872
|
(function () {
|
|
2822
2873
|
var menuI18nNamespace = getI18nNamespace("menu", "".concat(menu.menuId, "~").concat(menu.app[0].appId, "+").concat(menu.instanceId));
|
|
2823
2874
|
// Support any language in `meta.i18n`.
|
|
2824
|
-
Object.entries(menu.i18n).forEach(
|
|
2825
|
-
var [lang, resources] =
|
|
2875
|
+
Object.entries(menu.i18n).forEach(_ref6 => {
|
|
2876
|
+
var [lang, resources] = _ref6;
|
|
2826
2877
|
i18next.addResourceBundle(lang, menuI18nNamespace, resources);
|
|
2827
2878
|
});
|
|
2828
2879
|
menuWithI18n.set(menu, menuI18nNamespace);
|
|
@@ -2922,8 +2973,8 @@ function _processMenu() {
|
|
|
2922
2973
|
}
|
|
2923
2974
|
collectAppsRequireI18nFulfilled(items, context.app.id, appsRequireI18nFulfilled);
|
|
2924
2975
|
yield kernel.fulfilStoryboardI18n([...appsRequireI18nFulfilled]);
|
|
2925
|
-
var menuData = _objectSpread(_objectSpread({}, computeRealValueWithOverrideApp(restMenuData, rootAppId, context, kernel)), {}, {
|
|
2926
|
-
items: computeMenuItemsWithOverrideApp(items, context, kernel)
|
|
2976
|
+
var menuData = _objectSpread(_objectSpread({}, yield computeRealValueWithOverrideApp(restMenuData, rootAppId, context, kernel)), {}, {
|
|
2977
|
+
items: yield computeMenuItemsWithOverrideApp(items, context, kernel)
|
|
2927
2978
|
});
|
|
2928
2979
|
return {
|
|
2929
2980
|
title: yield processMenuTitle(menuData),
|
|
@@ -2971,17 +3022,22 @@ function collectAppsRequireI18nFulfilled(items, contextAppId, appIds) {
|
|
|
2971
3022
|
collect(items);
|
|
2972
3023
|
}
|
|
2973
3024
|
function computeMenuItemsWithOverrideApp(items, context, kernel) {
|
|
2974
|
-
return items.map(
|
|
2975
|
-
var {
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
3025
|
+
return Promise.all(items.map( /*#__PURE__*/function () {
|
|
3026
|
+
var _ref3 = _asyncToGenerator$3(function* (_ref2) {
|
|
3027
|
+
var {
|
|
3028
|
+
children
|
|
3029
|
+
} = _ref2,
|
|
3030
|
+
rest = _objectWithoutProperties(_ref2, _excluded2$2);
|
|
3031
|
+
return _objectSpread(_objectSpread({}, yield computeRealValueWithOverrideApp(rest, rest[symbolAppId], context, kernel)), {}, {
|
|
3032
|
+
children: children && (yield computeMenuItemsWithOverrideApp(children, context, kernel))
|
|
3033
|
+
});
|
|
2981
3034
|
});
|
|
2982
|
-
|
|
3035
|
+
return function (_x20) {
|
|
3036
|
+
return _ref3.apply(this, arguments);
|
|
3037
|
+
};
|
|
3038
|
+
}()));
|
|
2983
3039
|
}
|
|
2984
|
-
function processMenuTitle(
|
|
3040
|
+
function processMenuTitle(_x21) {
|
|
2985
3041
|
return _processMenuTitle.apply(this, arguments);
|
|
2986
3042
|
}
|
|
2987
3043
|
function _processMenuTitle() {
|
|
@@ -3060,25 +3116,32 @@ function attemptToVisit(data, globals) {
|
|
|
3060
3116
|
}
|
|
3061
3117
|
return false;
|
|
3062
3118
|
}
|
|
3063
|
-
function computeRealValueWithOverrideApp(
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3119
|
+
function computeRealValueWithOverrideApp(_x22, _x23, _x24, _x25) {
|
|
3120
|
+
return _computeRealValueWithOverrideApp.apply(this, arguments);
|
|
3121
|
+
}
|
|
3122
|
+
function _computeRealValueWithOverrideApp() {
|
|
3123
|
+
_computeRealValueWithOverrideApp = _asyncToGenerator$3(function* (data, overrideAppId, context, kernel) {
|
|
3124
|
+
var newContext = context;
|
|
3125
|
+
if (overrideAppId !== context.app.id && attemptToVisit(data, ["APP", "I18N"])) {
|
|
3126
|
+
if (window.STANDALONE_MICRO_APPS) {
|
|
3127
|
+
newContext = _objectSpread(_objectSpread({}, context), {}, {
|
|
3128
|
+
overrideApp: data[symbolOverrideApp],
|
|
3129
|
+
appendI18nNamespace: data[symbolMenuI18nNamespace]
|
|
3130
|
+
});
|
|
3131
|
+
} else {
|
|
3132
|
+
var storyboard = kernel.bootstrapData.storyboards.find(story => story.app.id === overrideAppId);
|
|
3133
|
+
newContext = _objectSpread(_objectSpread({}, context), {}, {
|
|
3134
|
+
overrideApp: storyboard === null || storyboard === void 0 ? void 0 : storyboard.app,
|
|
3135
|
+
appendI18nNamespace: data[symbolMenuI18nNamespace]
|
|
3136
|
+
});
|
|
3137
|
+
}
|
|
3077
3138
|
}
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3139
|
+
yield kernel.router.waitForUsedContext(data);
|
|
3140
|
+
return computeRealValue(data, newContext, true, {
|
|
3141
|
+
ignoreSymbols: true
|
|
3142
|
+
});
|
|
3081
3143
|
});
|
|
3144
|
+
return _computeRealValueWithOverrideApp.apply(this, arguments);
|
|
3082
3145
|
}
|
|
3083
3146
|
|
|
3084
3147
|
var lazyBrickRegistry = new Map();
|
|
@@ -7635,17 +7698,21 @@ function expandCustomTemplate(brickConf, proxyBrick, context) {
|
|
|
7635
7698
|
}
|
|
7636
7699
|
return lowLevelExpandCustomTemplate(template, brickConf, proxyBrick, context, tplContext);
|
|
7637
7700
|
}
|
|
7638
|
-
function asyncExpandCustomTemplate(_x, _x2, _x3) {
|
|
7701
|
+
function asyncExpandCustomTemplate(_x, _x2, _x3, _x4) {
|
|
7639
7702
|
return _asyncExpandCustomTemplate.apply(this, arguments);
|
|
7640
7703
|
}
|
|
7641
7704
|
function _asyncExpandCustomTemplate() {
|
|
7642
|
-
_asyncExpandCustomTemplate = _asyncToGenerator$3(function* (brickConf, proxyBrick, context) {
|
|
7705
|
+
_asyncExpandCustomTemplate = _asyncToGenerator$3(function* (brickConf, proxyBrick, context, locationContext) {
|
|
7643
7706
|
var tplContext = new CustomTemplateContext(proxyBrick);
|
|
7644
7707
|
var template = customTemplateRegistry.get(brickConf.brick);
|
|
7645
7708
|
if (template.contracts) {
|
|
7646
7709
|
collectWidgetContract(template.contracts);
|
|
7647
7710
|
}
|
|
7648
7711
|
if (Array.isArray(template.state)) {
|
|
7712
|
+
if (locationContext) {
|
|
7713
|
+
// Handle use cases of using `CTX.*` in template states.
|
|
7714
|
+
yield locationContext.storyboardContextWrapper.waitForUsedContext(template.state.map(state => [state.if, state.value, state.resolve]));
|
|
7715
|
+
}
|
|
7649
7716
|
yield tplContext.state.define(template.state, context, proxyBrick);
|
|
7650
7717
|
}
|
|
7651
7718
|
return lowLevelExpandCustomTemplate(template, brickConf, proxyBrick, context, tplContext);
|
|
@@ -8992,50 +9059,85 @@ function isRouteConfOfRoutes(conf) {
|
|
|
8992
9059
|
return conf.type === "routes";
|
|
8993
9060
|
}
|
|
8994
9061
|
|
|
8995
|
-
function getSubStoryboardByRoute(
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
function
|
|
9000
|
-
|
|
9001
|
-
return
|
|
9002
|
-
|
|
9062
|
+
function getSubStoryboardByRoute(_x, _x2) {
|
|
9063
|
+
return _getSubStoryboardByRoute.apply(this, arguments);
|
|
9064
|
+
}
|
|
9065
|
+
function _getSubStoryboardByRoute() {
|
|
9066
|
+
_getSubStoryboardByRoute = _asyncToGenerator$3(function* (storyboard, matcher) {
|
|
9067
|
+
function getSubRoutes(_x3) {
|
|
9068
|
+
return _getSubRoutes.apply(this, arguments);
|
|
9069
|
+
}
|
|
9070
|
+
function _getSubRoutes() {
|
|
9071
|
+
_getSubRoutes = _asyncToGenerator$3(function* (routes) {
|
|
9072
|
+
return Promise.all((yield matcher(routes)).map(getSubRoute));
|
|
9003
9073
|
});
|
|
9074
|
+
return _getSubRoutes.apply(this, arguments);
|
|
9004
9075
|
}
|
|
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
|
-
}))
|
|
9076
|
+
function getSubRoute(_x4) {
|
|
9077
|
+
return _getSubRoute.apply(this, arguments);
|
|
9078
|
+
}
|
|
9079
|
+
function _getSubRoute() {
|
|
9080
|
+
_getSubRoute = _asyncToGenerator$3(function* (route) {
|
|
9081
|
+
if (route.type === "routes") {
|
|
9082
|
+
return _objectSpread(_objectSpread({}, route), {}, {
|
|
9083
|
+
routes: yield getSubRoutes(route.routes)
|
|
9084
|
+
});
|
|
9085
|
+
}
|
|
9086
|
+
return _objectSpread(_objectSpread({}, route), {}, {
|
|
9087
|
+
bricks: yield getSubBricks(route.bricks)
|
|
9088
|
+
});
|
|
9032
9089
|
});
|
|
9090
|
+
return _getSubRoute.apply(this, arguments);
|
|
9033
9091
|
}
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9092
|
+
function getSubBricks(_x5) {
|
|
9093
|
+
return _getSubBricks.apply(this, arguments);
|
|
9094
|
+
}
|
|
9095
|
+
function _getSubBricks() {
|
|
9096
|
+
_getSubBricks = _asyncToGenerator$3(function* (bricks) {
|
|
9097
|
+
if (Array.isArray(bricks)) {
|
|
9098
|
+
return Promise.all(bricks.map(brickConf => getSubBrick(brickConf)));
|
|
9099
|
+
}
|
|
9100
|
+
return bricks;
|
|
9101
|
+
});
|
|
9102
|
+
return _getSubBricks.apply(this, arguments);
|
|
9103
|
+
}
|
|
9104
|
+
function getSubBrick(_x6) {
|
|
9105
|
+
return _getSubBrick.apply(this, arguments);
|
|
9106
|
+
}
|
|
9107
|
+
function _getSubBrick() {
|
|
9108
|
+
_getSubBrick = _asyncToGenerator$3(function* (brickConf) {
|
|
9109
|
+
if (isObject(brickConf.slots)) {
|
|
9110
|
+
return _objectSpread(_objectSpread({}, brickConf), {}, {
|
|
9111
|
+
slots: Object.fromEntries(yield Promise.all(Object.entries(brickConf.slots).map( /*#__PURE__*/function () {
|
|
9112
|
+
var _ref2 = _asyncToGenerator$3(function* (_ref) {
|
|
9113
|
+
var [slotId, slotConf] = _ref;
|
|
9114
|
+
if (slotConf.type === "routes") {
|
|
9115
|
+
return [slotId, _objectSpread(_objectSpread({}, slotConf), {}, {
|
|
9116
|
+
routes: yield getSubRoutes(slotConf.routes)
|
|
9117
|
+
})];
|
|
9118
|
+
} /* istanbul ignore else: should never reach */else if (slotConf.type === "bricks") {
|
|
9119
|
+
return [slotId, _objectSpread(_objectSpread({}, slotConf), {}, {
|
|
9120
|
+
bricks: yield getSubBricks(slotConf.bricks)
|
|
9121
|
+
})];
|
|
9122
|
+
}
|
|
9123
|
+
/* istanbul ignore next: should never reach */
|
|
9124
|
+
return [slotId, slotConf];
|
|
9125
|
+
});
|
|
9126
|
+
return function (_x7) {
|
|
9127
|
+
return _ref2.apply(this, arguments);
|
|
9128
|
+
};
|
|
9129
|
+
}())))
|
|
9130
|
+
});
|
|
9131
|
+
}
|
|
9132
|
+
return brickConf;
|
|
9133
|
+
});
|
|
9134
|
+
return _getSubBrick.apply(this, arguments);
|
|
9135
|
+
}
|
|
9136
|
+
return _objectSpread(_objectSpread({}, storyboard), {}, {
|
|
9137
|
+
routes: yield getSubRoutes(storyboard.routes)
|
|
9138
|
+
});
|
|
9038
9139
|
});
|
|
9140
|
+
return _getSubStoryboardByRoute.apply(this, arguments);
|
|
9039
9141
|
}
|
|
9040
9142
|
|
|
9041
9143
|
function listenOnTrackingContext(brick, trackingContextList, context) {
|
|
@@ -9086,14 +9188,18 @@ function ExpandCustomForm(formData, brickConf, isPreview, context) {
|
|
|
9086
9188
|
}
|
|
9087
9189
|
return getFinalStoryBoard(formData, brickConf, isPreview, formContext);
|
|
9088
9190
|
}
|
|
9089
|
-
function AsyncExpandCustomForm(_x, _x2, _x3, _x4) {
|
|
9191
|
+
function AsyncExpandCustomForm(_x, _x2, _x3, _x4, _x5) {
|
|
9090
9192
|
return _AsyncExpandCustomForm.apply(this, arguments);
|
|
9091
9193
|
}
|
|
9092
9194
|
function _AsyncExpandCustomForm() {
|
|
9093
|
-
_AsyncExpandCustomForm = _asyncToGenerator$3(function* (formData, brickConf, isPreview, context) {
|
|
9195
|
+
_AsyncExpandCustomForm = _asyncToGenerator$3(function* (formData, brickConf, isPreview, context, locationContext) {
|
|
9094
9196
|
var formContext = new CustomFormContext();
|
|
9095
9197
|
formData = initFormContext(formData, brickConf, isPreview);
|
|
9096
9198
|
if (Array.isArray(formData.context)) {
|
|
9199
|
+
if (locationContext) {
|
|
9200
|
+
// Handle use cases of using `CTX.*` in template states.
|
|
9201
|
+
yield locationContext.storyboardContextWrapper.waitForUsedContext(formData.context.map(state => [state.if, state.value, state.resolve]));
|
|
9202
|
+
}
|
|
9097
9203
|
yield formContext.formState.define(formData.context, _objectSpread(_objectSpread({}, context), {}, {
|
|
9098
9204
|
formContextId: formContext.id
|
|
9099
9205
|
}), {});
|
|
@@ -9479,7 +9585,7 @@ class LocationContext {
|
|
|
9479
9585
|
_defineProperty$1(this, "observersList", []);
|
|
9480
9586
|
this.kernel = kernel;
|
|
9481
9587
|
this.location = location;
|
|
9482
|
-
this.resolver = new Resolver(kernel);
|
|
9588
|
+
this.resolver = new Resolver(kernel, this);
|
|
9483
9589
|
this.query = new URLSearchParams(location.search);
|
|
9484
9590
|
this.messageDispatcher = getMessageDispatcher();
|
|
9485
9591
|
}
|
|
@@ -9517,60 +9623,79 @@ class LocationContext {
|
|
|
9517
9623
|
match: this.currentMatch
|
|
9518
9624
|
});
|
|
9519
9625
|
}
|
|
9626
|
+
deferComputeRealValue() {
|
|
9627
|
+
var _arguments = arguments,
|
|
9628
|
+
_this = this;
|
|
9629
|
+
return _asyncToGenerator$3(function* () {
|
|
9630
|
+
yield _this.storyboardContextWrapper.waitForUsedContext(_arguments.length <= 0 ? undefined : _arguments[0]);
|
|
9631
|
+
return computeRealValue(..._arguments);
|
|
9632
|
+
})();
|
|
9633
|
+
}
|
|
9520
9634
|
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;
|
|
9635
|
+
var _this2 = this;
|
|
9636
|
+
return _asyncToGenerator$3(function* () {
|
|
9637
|
+
var _loop = function* (route) {
|
|
9638
|
+
var computedPath = computeRealRoutePath(route.path, app);
|
|
9639
|
+
if ([].concat(computedPath).includes(undefined)) {
|
|
9640
|
+
// eslint-disable-next-line no-console
|
|
9641
|
+
console.error("Invalid route with invalid path:", route);
|
|
9542
9642
|
return {
|
|
9543
|
-
v:
|
|
9544
|
-
match,
|
|
9545
|
-
route
|
|
9546
|
-
}
|
|
9643
|
+
v: "missed"
|
|
9547
9644
|
};
|
|
9548
9645
|
}
|
|
9549
|
-
|
|
9550
|
-
|
|
9551
|
-
|
|
9646
|
+
yield _this2.storyboardContextWrapper.waitForUsedContext(route.if);
|
|
9647
|
+
var match = matchPath(_this2.location.pathname, {
|
|
9648
|
+
path: computedPath,
|
|
9649
|
+
exact: route.exact,
|
|
9650
|
+
checkIf: context => looseCheckIf(route, context),
|
|
9651
|
+
getContext: match => _this2.getContext({
|
|
9652
|
+
match
|
|
9653
|
+
})
|
|
9654
|
+
});
|
|
9655
|
+
if (match !== null) {
|
|
9656
|
+
if (app.noAuthGuard || route.public || isLoggedIn()) {
|
|
9657
|
+
_this2.currentMatch = match;
|
|
9658
|
+
return {
|
|
9659
|
+
v: {
|
|
9660
|
+
match,
|
|
9661
|
+
route
|
|
9662
|
+
}
|
|
9663
|
+
};
|
|
9664
|
+
}
|
|
9665
|
+
return {
|
|
9666
|
+
v: "unauthenticated"
|
|
9667
|
+
};
|
|
9668
|
+
}
|
|
9669
|
+
};
|
|
9670
|
+
for (var route of routes) {
|
|
9671
|
+
var _ret = yield* _loop(route);
|
|
9672
|
+
if (typeof _ret === "object") return _ret.v;
|
|
9552
9673
|
}
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
var _ret = _loop(route);
|
|
9556
|
-
if (typeof _ret === "object") return _ret.v;
|
|
9557
|
-
}
|
|
9558
|
-
return "missed";
|
|
9674
|
+
return "missed";
|
|
9675
|
+
})();
|
|
9559
9676
|
}
|
|
9560
9677
|
matchStoryboard(storyboards) {
|
|
9561
9678
|
return matchStoryboard(storyboards, this.location.pathname);
|
|
9562
9679
|
}
|
|
9563
9680
|
getSubStoryboardByRoute(storyboard) {
|
|
9564
|
-
var
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
|
|
9568
|
-
|
|
9681
|
+
var _this3 = this;
|
|
9682
|
+
return _asyncToGenerator$3(function* () {
|
|
9683
|
+
var matcher = /*#__PURE__*/function () {
|
|
9684
|
+
var _ref2 = _asyncToGenerator$3(function* (routes) {
|
|
9685
|
+
var matched = yield _this3.matchRoutes(routes, storyboard.app);
|
|
9686
|
+
return isObject(matched) ? [matched.route] : [];
|
|
9687
|
+
});
|
|
9688
|
+
return function matcher(_x) {
|
|
9689
|
+
return _ref2.apply(this, arguments);
|
|
9690
|
+
};
|
|
9691
|
+
}();
|
|
9692
|
+
return getSubStoryboardByRoute(storyboard, matcher);
|
|
9693
|
+
})();
|
|
9569
9694
|
}
|
|
9570
9695
|
mountRoutes(routes, slotId, mountRoutesResult) {
|
|
9571
|
-
var
|
|
9696
|
+
var _this4 = this;
|
|
9572
9697
|
return _asyncToGenerator$3(function* () {
|
|
9573
|
-
var matched =
|
|
9698
|
+
var matched = yield _this4.matchRoutes(routes, _this4.kernel.nextApp);
|
|
9574
9699
|
var redirect;
|
|
9575
9700
|
var redirectConf = {};
|
|
9576
9701
|
var context;
|
|
@@ -9584,19 +9709,26 @@ class LocationContext {
|
|
|
9584
9709
|
default:
|
|
9585
9710
|
mountRoutesResult.route = route = matched.route;
|
|
9586
9711
|
if (route.segues) {
|
|
9587
|
-
Object.assign(
|
|
9712
|
+
Object.assign(_this4.segues, route.segues);
|
|
9588
9713
|
}
|
|
9589
9714
|
if (route.hybrid) {
|
|
9590
9715
|
mountRoutesResult.flags.hybrid = true;
|
|
9591
9716
|
}
|
|
9592
|
-
context =
|
|
9717
|
+
context = _this4.getContext({
|
|
9593
9718
|
match: matched.match
|
|
9594
9719
|
});
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
yield
|
|
9598
|
-
|
|
9599
|
-
|
|
9720
|
+
yield _this4.storyboardContextWrapper.waitForUsedContext(route.defineResolves);
|
|
9721
|
+
_this4.resolver.defineResolves(route.defineResolves, context);
|
|
9722
|
+
yield _this4.mountProviders(route.providers, matched.match, slotId, mountRoutesResult);
|
|
9723
|
+
|
|
9724
|
+
// istanbul ignore else
|
|
9725
|
+
if (_this4.kernel.getFeatureFlags()["next-core-deferred-context"]) {
|
|
9726
|
+
_this4.storyboardContextWrapper.deferDefine(route.context, context);
|
|
9727
|
+
} else {
|
|
9728
|
+
yield _this4.storyboardContextWrapper.define(route.context, context);
|
|
9729
|
+
}
|
|
9730
|
+
yield _this4.preCheckPermissions(route, context);
|
|
9731
|
+
redirect = yield _this4.deferComputeRealValue(route.redirect, context, true);
|
|
9600
9732
|
if (redirect) {
|
|
9601
9733
|
if (typeof redirect === "string") {
|
|
9602
9734
|
// Directly redirect.
|
|
@@ -9606,7 +9738,7 @@ class LocationContext {
|
|
|
9606
9738
|
break;
|
|
9607
9739
|
} else {
|
|
9608
9740
|
// Resolvable redirect.
|
|
9609
|
-
yield
|
|
9741
|
+
yield _this4.resolver.resolveOne("reference", redirect, redirectConf);
|
|
9610
9742
|
if (redirectConf.redirect) {
|
|
9611
9743
|
mountRoutesResult.flags.redirect = {
|
|
9612
9744
|
path: redirectConf.redirect
|
|
@@ -9615,20 +9747,20 @@ class LocationContext {
|
|
|
9615
9747
|
}
|
|
9616
9748
|
}
|
|
9617
9749
|
}
|
|
9618
|
-
yield
|
|
9750
|
+
yield _this4.mountMenu(route.menu, matched.match, mountRoutesResult);
|
|
9619
9751
|
if (route.documentId) {
|
|
9620
9752
|
mountRoutesResult.appBar.documentId = route.documentId;
|
|
9621
9753
|
}
|
|
9622
9754
|
if (isRouteConfOfRoutes(route) && Array.isArray(route.routes)) {
|
|
9623
|
-
yield
|
|
9624
|
-
yield
|
|
9755
|
+
yield _this4.preFetchMenu(route.context);
|
|
9756
|
+
yield _this4.mountRoutes(route.routes, slotId, mountRoutesResult);
|
|
9625
9757
|
} else if (isRouteConfOfBricks(route) && Array.isArray(route.bricks)) {
|
|
9626
|
-
yield
|
|
9627
|
-
yield
|
|
9758
|
+
yield _this4.preFetchMenu(route);
|
|
9759
|
+
yield _this4.mountBricks(route.bricks, matched.match, slotId, mountRoutesResult);
|
|
9628
9760
|
|
|
9629
9761
|
// analytics data (page_view event)
|
|
9630
9762
|
if (route.analyticsData) {
|
|
9631
|
-
mountRoutesResult.analyticsData =
|
|
9763
|
+
mountRoutesResult.analyticsData = yield _this4.deferComputeRealValue(route.analyticsData, context, true);
|
|
9632
9764
|
}
|
|
9633
9765
|
}
|
|
9634
9766
|
}
|
|
@@ -9636,7 +9768,7 @@ class LocationContext {
|
|
|
9636
9768
|
})();
|
|
9637
9769
|
}
|
|
9638
9770
|
mountMenu(menuConf, match, mountRoutesResult) {
|
|
9639
|
-
var
|
|
9771
|
+
var _this5 = this;
|
|
9640
9772
|
return _asyncToGenerator$3(function* () {
|
|
9641
9773
|
if (menuConf === false) {
|
|
9642
9774
|
// `route.menu` 设置为 `false` 表示不显示顶栏和侧栏。
|
|
@@ -9648,7 +9780,7 @@ class LocationContext {
|
|
|
9648
9780
|
if (!menuConf) {
|
|
9649
9781
|
return;
|
|
9650
9782
|
}
|
|
9651
|
-
var context =
|
|
9783
|
+
var context = _this5.getContext({
|
|
9652
9784
|
match
|
|
9653
9785
|
});
|
|
9654
9786
|
if (menuConf.type === "brick") {
|
|
@@ -9658,6 +9790,7 @@ class LocationContext {
|
|
|
9658
9790
|
// 那么可以将菜单配置指定为一个构件,这个构件会被装载到背景容器中(不会在界面中显示),
|
|
9659
9791
|
// 应该在这个构件的 `connectedCallback` 中执行相关菜单设置,
|
|
9660
9792
|
// 例如 `getRuntime().menuBar.setAppMenu(...)`。
|
|
9793
|
+
yield _this5.storyboardContextWrapper.waitForUsedContext(menuConf.properties);
|
|
9661
9794
|
var brick = {
|
|
9662
9795
|
type: menuConf.brick,
|
|
9663
9796
|
properties: computeRealProperties(menuConf.properties, context, menuConf.injectDeep !== false),
|
|
@@ -9665,16 +9798,16 @@ class LocationContext {
|
|
|
9665
9798
|
context,
|
|
9666
9799
|
children: []
|
|
9667
9800
|
};
|
|
9668
|
-
|
|
9801
|
+
_this5.registerHandlersFromLifeCycle(menuConf.lifeCycle, brick, match);
|
|
9669
9802
|
|
|
9670
9803
|
// Then, resolve the brick.
|
|
9671
|
-
yield
|
|
9804
|
+
yield _this5.resolver.resolve(menuConf, brick, context);
|
|
9672
9805
|
mountRoutesResult.menuInBg.push(brick);
|
|
9673
9806
|
return;
|
|
9674
9807
|
}
|
|
9675
9808
|
var injectDeep = menuConf.injectDeep;
|
|
9676
9809
|
if (menuConf.type === "resolve") {
|
|
9677
|
-
yield
|
|
9810
|
+
yield _this5.resolver.resolveOne("reference", _objectSpread({
|
|
9678
9811
|
transformMapArray: false
|
|
9679
9812
|
}, menuConf.resolve), menuConf, null, context);
|
|
9680
9813
|
injectDeep = false;
|
|
@@ -9682,7 +9815,7 @@ class LocationContext {
|
|
|
9682
9815
|
|
|
9683
9816
|
// 静态菜单配置,仅在有值时才设置,这样可以让菜单设置也具有按路由层级覆盖的能力。
|
|
9684
9817
|
var otherMenuConf = omit(menuConf, ["injectDeep", "type"]);
|
|
9685
|
-
var injectedMenuConf = injectDeep !== false ?
|
|
9818
|
+
var injectedMenuConf = injectDeep !== false ? yield _this5.deferComputeRealValue(otherMenuConf, context, true) : otherMenuConf;
|
|
9686
9819
|
var {
|
|
9687
9820
|
sidebarMenu,
|
|
9688
9821
|
pageTitle,
|
|
@@ -9714,11 +9847,11 @@ class LocationContext {
|
|
|
9714
9847
|
})();
|
|
9715
9848
|
}
|
|
9716
9849
|
mountProviders(providers, match, slotId, mountRoutesResult) {
|
|
9717
|
-
var
|
|
9850
|
+
var _this6 = this;
|
|
9718
9851
|
return _asyncToGenerator$3(function* () {
|
|
9719
9852
|
if (Array.isArray(providers)) {
|
|
9720
9853
|
for (var providerConf of providers) {
|
|
9721
|
-
yield
|
|
9854
|
+
yield _this6.mountBrick(_objectSpread(_objectSpread({}, typeof providerConf === "string" ? {
|
|
9722
9855
|
brick: providerConf
|
|
9723
9856
|
} : providerConf), {}, {
|
|
9724
9857
|
bg: true,
|
|
@@ -9729,11 +9862,11 @@ class LocationContext {
|
|
|
9729
9862
|
})();
|
|
9730
9863
|
}
|
|
9731
9864
|
mountBricks(bricks, match, slotId, mountRoutesResult, tplStack) {
|
|
9732
|
-
var
|
|
9865
|
+
var _this7 = this;
|
|
9733
9866
|
return _asyncToGenerator$3(function* () {
|
|
9734
9867
|
for (var brickConf of bricks) {
|
|
9735
9868
|
try {
|
|
9736
|
-
yield
|
|
9869
|
+
yield _this7.mountBrick(brickConf, match, slotId, mountRoutesResult, tplStack && new Map(tplStack));
|
|
9737
9870
|
} catch (error) {
|
|
9738
9871
|
if (error instanceof ResolveRequestError) {
|
|
9739
9872
|
var errorMessage = httpErrorToString(error.rawError);
|
|
@@ -9761,57 +9894,59 @@ class LocationContext {
|
|
|
9761
9894
|
})();
|
|
9762
9895
|
}
|
|
9763
9896
|
checkResolvableIf(ifContainer, context) {
|
|
9764
|
-
var
|
|
9897
|
+
var _this8 = this;
|
|
9765
9898
|
return _asyncToGenerator$3(function* () {
|
|
9899
|
+
yield _this8.storyboardContextWrapper.waitForUsedContext(ifContainer.if);
|
|
9766
9900
|
if (isObject(ifContainer.if)) {
|
|
9767
9901
|
var ifChecked = computeRealValue(ifContainer.if, context, true);
|
|
9768
9902
|
var ifConf = {};
|
|
9769
|
-
yield
|
|
9903
|
+
yield _this8.resolver.resolveOne("reference", ifChecked, ifConf);
|
|
9770
9904
|
return !hasOwnProperty(ifConf, "if") || !!ifConf.if;
|
|
9771
9905
|
}
|
|
9772
9906
|
return looseCheckIf(ifContainer, context);
|
|
9773
9907
|
})();
|
|
9774
9908
|
}
|
|
9775
9909
|
preCheckPermissions(container, context) {
|
|
9910
|
+
var _this9 = this;
|
|
9776
9911
|
return _asyncToGenerator$3(function* () {
|
|
9777
9912
|
if (isLoggedIn() && !getAuth().isAdmin && container.permissionsPreCheck && Array.isArray(container.permissionsPreCheck)) {
|
|
9778
|
-
var usedActions =
|
|
9913
|
+
var usedActions = yield _this9.deferComputeRealValue(container.permissionsPreCheck, context, true);
|
|
9779
9914
|
yield validatePermissions(usedActions);
|
|
9780
9915
|
}
|
|
9781
9916
|
})();
|
|
9782
9917
|
}
|
|
9783
9918
|
mountBrick(brickConf, match, slotId, mountRoutesResult) {
|
|
9784
|
-
var
|
|
9785
|
-
|
|
9919
|
+
var _arguments2 = arguments,
|
|
9920
|
+
_this10 = this;
|
|
9786
9921
|
return _asyncToGenerator$3(function* () {
|
|
9787
|
-
var
|
|
9788
|
-
var tplStack =
|
|
9922
|
+
var _this10$kernel$nextAp, _brickConf$lifeCycle, _brick$lifeCycle;
|
|
9923
|
+
var tplStack = _arguments2.length > 4 && _arguments2[4] !== undefined ? _arguments2[4] : new Map();
|
|
9789
9924
|
var tplContextId = brickConf[symbolForTplContextId];
|
|
9790
9925
|
var formContextId = brickConf[symbolForFormContextId];
|
|
9791
|
-
var context =
|
|
9926
|
+
var context = _this10.getContext({
|
|
9792
9927
|
match,
|
|
9793
9928
|
tplContextId,
|
|
9794
9929
|
formContextId
|
|
9795
9930
|
});
|
|
9796
9931
|
|
|
9797
9932
|
// First, check whether the brick should be rendered.
|
|
9798
|
-
if (!(yield
|
|
9933
|
+
if (!(yield _this10.checkResolvableIf(brickConf, context))) {
|
|
9799
9934
|
return;
|
|
9800
9935
|
}
|
|
9801
9936
|
|
|
9802
9937
|
// Then, resolve the template to a brick.
|
|
9803
9938
|
if (brickConf.template) {
|
|
9804
|
-
yield
|
|
9939
|
+
yield _this10.resolver.resolve(brickConf, null, context);
|
|
9805
9940
|
}
|
|
9806
9941
|
|
|
9807
9942
|
// Check `if` again for dynamic loaded templates.
|
|
9808
|
-
if (!(yield
|
|
9943
|
+
if (!(yield _this10.checkResolvableIf(brickConf, context))) {
|
|
9809
9944
|
return;
|
|
9810
9945
|
}
|
|
9811
9946
|
|
|
9812
9947
|
// If it's a custom template, `tplTagName` is the tag name of the template.
|
|
9813
9948
|
// Otherwise, `tplTagName` is false.
|
|
9814
|
-
var tplTagName = getTagNameOfCustomTemplate(brickConf.brick, (
|
|
9949
|
+
var tplTagName = getTagNameOfCustomTemplate(brickConf.brick, (_this10$kernel$nextAp = _this10.kernel.nextApp) === null || _this10$kernel$nextAp === void 0 ? void 0 : _this10$kernel$nextAp.id);
|
|
9815
9950
|
if (tplTagName) {
|
|
9816
9951
|
var _tplStack$get;
|
|
9817
9952
|
var tplCount = (_tplStack$get = tplStack.get(tplTagName)) !== null && _tplStack$get !== void 0 ? _tplStack$get : 0;
|
|
@@ -9824,9 +9959,16 @@ class LocationContext {
|
|
|
9824
9959
|
brickConf.properties.formData = JSON.stringify(brickConf.properties.formData);
|
|
9825
9960
|
}
|
|
9826
9961
|
var brick = {};
|
|
9827
|
-
|
|
9828
|
-
|
|
9962
|
+
|
|
9963
|
+
// istanbul ignore else
|
|
9964
|
+
if (_this10.kernel.getFeatureFlags()["next-core-deferred-context"]) {
|
|
9965
|
+
_this10.storyboardContextWrapper.deferDefine(brickConf.context, context, brick);
|
|
9966
|
+
} else {
|
|
9967
|
+
yield _this10.storyboardContextWrapper.define(brickConf.context, context, brick);
|
|
9968
|
+
}
|
|
9969
|
+
yield _this10.preCheckPermissions(brickConf, context);
|
|
9829
9970
|
var trackingContextList = [];
|
|
9971
|
+
yield _this10.storyboardContextWrapper.waitForUsedContext(brickConf.properties);
|
|
9830
9972
|
Object.assign(brick, _objectSpread({
|
|
9831
9973
|
type: tplTagName || brickConf.brick,
|
|
9832
9974
|
properties: computeRealProperties(brickConf.properties, context, brickConf.injectDeep !== false, trackingContextList),
|
|
@@ -9844,8 +9986,8 @@ class LocationContext {
|
|
|
9844
9986
|
}
|
|
9845
9987
|
} : {}));
|
|
9846
9988
|
if (brickConf[symbolForComputedPropsFromProxy]) {
|
|
9847
|
-
Object.entries(brickConf[symbolForComputedPropsFromProxy]).forEach(
|
|
9848
|
-
var [propName, propValue] =
|
|
9989
|
+
Object.entries(brickConf[symbolForComputedPropsFromProxy]).forEach(_ref3 => {
|
|
9990
|
+
var [propName, propValue] = _ref3;
|
|
9849
9991
|
set(brick.properties, propName, propValue);
|
|
9850
9992
|
});
|
|
9851
9993
|
}
|
|
@@ -9853,36 +9995,36 @@ class LocationContext {
|
|
|
9853
9995
|
if (brick.refForProxy) {
|
|
9854
9996
|
brick.refForProxy.brick = brick;
|
|
9855
9997
|
}
|
|
9856
|
-
|
|
9998
|
+
_this10.registerHandlersFromLifeCycle(brickConf.lifeCycle, brick, match, tplContextId);
|
|
9857
9999
|
if ((_brick$lifeCycle = brick.lifeCycle) !== null && _brick$lifeCycle !== void 0 && _brick$lifeCycle.onScrollIntoView) {
|
|
9858
|
-
|
|
10000
|
+
_this10.brickBindObserver(brick);
|
|
9859
10001
|
}
|
|
9860
10002
|
|
|
9861
10003
|
// Then, resolve the brick.
|
|
9862
|
-
yield
|
|
10004
|
+
yield _this10.resolver.resolve(brickConf, brick, context);
|
|
9863
10005
|
var expandedBrickConf = brickConf;
|
|
9864
10006
|
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 ||
|
|
10007
|
+
if (tplTagName && (!isBaseLayout || _this10.kernel.getFeatureFlags()["support-ui-8.0-base-layout"] && isBaseLayout)) {
|
|
9866
10008
|
var _customTemplateRegist;
|
|
9867
|
-
yield
|
|
10009
|
+
yield _this10.preFetchMenu((_customTemplateRegist = customTemplateRegistry.get(tplTagName)) === null || _customTemplateRegist === void 0 ? void 0 : _customTemplateRegist.bricks);
|
|
9868
10010
|
expandedBrickConf = yield asyncExpandCustomTemplate(_objectSpread(_objectSpread({}, brickConf), {}, {
|
|
9869
10011
|
brick: tplTagName,
|
|
9870
10012
|
// Properties are computed for custom templates.
|
|
9871
10013
|
properties: brick.properties
|
|
9872
|
-
}), brick, context);
|
|
10014
|
+
}), brick, context, _this10);
|
|
9873
10015
|
|
|
9874
10016
|
// Try to load deps for dynamic added bricks.
|
|
9875
|
-
yield
|
|
10017
|
+
yield _this10.kernel.loadDynamicBricksInBrickConf(expandedBrickConf);
|
|
9876
10018
|
}
|
|
9877
10019
|
if (brick.type === formRenderer) {
|
|
9878
10020
|
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
|
|
10021
|
+
expandedBrickConf = yield AsyncExpandCustomForm(formData, brickConf, brick.properties.isPreview, context, _this10);
|
|
10022
|
+
yield _this10.kernel.loadDynamicBricksInBrickConf(expandedBrickConf);
|
|
9881
10023
|
}
|
|
9882
10024
|
if (expandedBrickConf.exports) {
|
|
9883
10025
|
for (var [prop, ctxName] of Object.entries(expandedBrickConf.exports)) {
|
|
9884
10026
|
if (typeof ctxName === "string" && ctxName.startsWith("CTX.")) {
|
|
9885
|
-
|
|
10027
|
+
_this10.storyboardContextWrapper.set(ctxName.substring(4), {
|
|
9886
10028
|
type: "brick-property",
|
|
9887
10029
|
brick,
|
|
9888
10030
|
prop
|
|
@@ -9893,8 +10035,8 @@ class LocationContext {
|
|
|
9893
10035
|
if (expandedBrickConf.bg) {
|
|
9894
10036
|
// A bg brick has no slotId.
|
|
9895
10037
|
brick.slotId = undefined;
|
|
9896
|
-
yield
|
|
9897
|
-
appendBrick(brick,
|
|
10038
|
+
yield _this10.kernel.loadDynamicBricks([brick.type]);
|
|
10039
|
+
appendBrick(brick, _this10.kernel.mountPoints.bg);
|
|
9898
10040
|
} else {
|
|
9899
10041
|
if (expandedBrickConf.portal) {
|
|
9900
10042
|
// A portal brick has no slotId.
|
|
@@ -9909,9 +10051,9 @@ class LocationContext {
|
|
|
9909
10051
|
main: brick.children
|
|
9910
10052
|
});
|
|
9911
10053
|
if (slotConf.type === "bricks") {
|
|
9912
|
-
yield
|
|
10054
|
+
yield _this10.mountBricks(slotConf.bricks, match, _slotId, slottedMountRoutesResult, tplStack);
|
|
9913
10055
|
} else if (slotConf.type === "routes") {
|
|
9914
|
-
yield
|
|
10056
|
+
yield _this10.mountRoutes(slotConf.routes, _slotId, slottedMountRoutesResult);
|
|
9915
10057
|
}
|
|
9916
10058
|
}
|
|
9917
10059
|
}
|
|
@@ -10087,11 +10229,11 @@ class LocationContext {
|
|
|
10087
10229
|
}
|
|
10088
10230
|
}
|
|
10089
10231
|
preFetchMenu(data) {
|
|
10090
|
-
var
|
|
10232
|
+
var _this11 = this;
|
|
10091
10233
|
return _asyncToGenerator$3(function* () {
|
|
10092
10234
|
var useMenus = scanAppGetMenuInAny(data);
|
|
10093
10235
|
if (useMenus.length) {
|
|
10094
|
-
yield preConstructMenus(useMenus,
|
|
10236
|
+
yield preConstructMenus(useMenus, _this11.getCurrentContext(), _this11.kernel);
|
|
10095
10237
|
}
|
|
10096
10238
|
})();
|
|
10097
10239
|
}
|
|
@@ -10278,12 +10420,13 @@ function makeProviderRefreshable(providerBrick) {
|
|
|
10278
10420
|
}
|
|
10279
10421
|
|
|
10280
10422
|
class Resolver {
|
|
10281
|
-
constructor(kernel) {
|
|
10423
|
+
constructor(kernel, locationContext) {
|
|
10282
10424
|
_defineProperty$1(this, "cache", new Map());
|
|
10283
10425
|
_defineProperty$1(this, "refreshQueue", new Map());
|
|
10284
10426
|
_defineProperty$1(this, "definedResolves", new Map());
|
|
10285
10427
|
_defineProperty$1(this, "active", true);
|
|
10286
10428
|
this.kernel = kernel;
|
|
10429
|
+
this.locationContext = locationContext;
|
|
10287
10430
|
}
|
|
10288
10431
|
resetRefreshQueue() {
|
|
10289
10432
|
if (this.refreshQueue.size > 0) {
|
|
@@ -10307,9 +10450,15 @@ class Resolver {
|
|
|
10307
10450
|
var _this = this;
|
|
10308
10451
|
return _asyncToGenerator$3(function* () {
|
|
10309
10452
|
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
|
-
|
|
10453
|
+
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 () {
|
|
10454
|
+
var _ref = _asyncToGenerator$3(function* (r) {
|
|
10455
|
+
yield _this.locationContext.storyboardContextWrapper.waitForUsedContext(r.if);
|
|
10456
|
+
return r;
|
|
10457
|
+
});
|
|
10458
|
+
return function (_x) {
|
|
10459
|
+
return _ref.apply(this, arguments);
|
|
10460
|
+
};
|
|
10461
|
+
}()))).filter(r => looseCheckIf(r, context));
|
|
10313
10462
|
yield Promise.all(useResolves.map(resolveConf => _this.resolveOne("brick", resolveConf, brickConf, brick, context)));
|
|
10314
10463
|
if (brickConf.template) {
|
|
10315
10464
|
brickConf.$$resolved = true;
|
|
@@ -10393,7 +10542,7 @@ class Resolver {
|
|
|
10393
10542
|
}
|
|
10394
10543
|
}
|
|
10395
10544
|
var actualArgs = args ? ref ? args // `args` are already computed for `defineResolves`
|
|
10396
|
-
: context ?
|
|
10545
|
+
: context ? yield _this2.locationContext.deferComputeRealValue(args, context, true) : args : providerBrick.args || [];
|
|
10397
10546
|
var cacheKey;
|
|
10398
10547
|
try {
|
|
10399
10548
|
// `actualArgs` may contain circular references, which makes
|
|
@@ -10456,6 +10605,7 @@ class Resolver {
|
|
|
10456
10605
|
yield fetchData();
|
|
10457
10606
|
} catch (error) {
|
|
10458
10607
|
if (isHandleRejectByTransform(onReject)) {
|
|
10608
|
+
yield _this2.locationContext.storyboardContextWrapper.waitForUsedContext(onReject.transform);
|
|
10459
10609
|
transformProperties(props, error, context ? computeRealValue(onReject.transform, context, true) : onReject.transform);
|
|
10460
10610
|
return;
|
|
10461
10611
|
} else if (isHandleRejectByCatch(onReject)) {
|
|
@@ -10468,18 +10618,21 @@ class Resolver {
|
|
|
10468
10618
|
yield fetchData();
|
|
10469
10619
|
}
|
|
10470
10620
|
if (ref) {
|
|
10621
|
+
yield _this2.locationContext.storyboardContextWrapper.waitForUsedContext(transform);
|
|
10471
10622
|
data = transformIntermediateData(data, context ? computeRealValue(transform, context, true) : transform, transformFrom, transformMapArray);
|
|
10472
10623
|
}
|
|
10624
|
+
var transformTo = resolveConf.transform || resolveConf.name;
|
|
10625
|
+
yield _this2.locationContext.storyboardContextWrapper.waitForUsedContext(transformTo);
|
|
10473
10626
|
transformProperties(props, data,
|
|
10474
10627
|
// Also support legacy `name`
|
|
10475
|
-
context ? computeRealValue(
|
|
10628
|
+
context ? computeRealValue(transformTo, context, true) : transformTo, resolveConf.transformFrom, resolveConf.transformMapArray);
|
|
10476
10629
|
})();
|
|
10477
10630
|
}
|
|
10478
10631
|
scheduleRefreshing() {
|
|
10479
10632
|
var _this3 = this;
|
|
10480
10633
|
var _loop = function (providerBrick, interval) {
|
|
10481
10634
|
var request = /*#__PURE__*/function () {
|
|
10482
|
-
var
|
|
10635
|
+
var _ref3 = _asyncToGenerator$3(function* () {
|
|
10483
10636
|
yield providerBrick.$refresh({
|
|
10484
10637
|
ignoreErrors: interval.ignoreErrors,
|
|
10485
10638
|
throwErrors: true,
|
|
@@ -10491,7 +10644,7 @@ class Resolver {
|
|
|
10491
10644
|
}
|
|
10492
10645
|
});
|
|
10493
10646
|
return function request() {
|
|
10494
|
-
return
|
|
10647
|
+
return _ref3.apply(this, arguments);
|
|
10495
10648
|
};
|
|
10496
10649
|
}();
|
|
10497
10650
|
interval.timeoutId = setTimeout(request, interval.delay);
|
|
@@ -10888,7 +11041,7 @@ class Router {
|
|
|
10888
11041
|
yield Promise.all(parallelRequests);
|
|
10889
11042
|
|
|
10890
11043
|
// 如果找到匹配的 storyboard,那么根据路由匹配得到的 sub-storyboard 加载它的依赖库。
|
|
10891
|
-
var subStoryboard = _this3.locationContext.getSubStoryboardByRoute(storyboard);
|
|
11044
|
+
var subStoryboard = yield _this3.locationContext.getSubStoryboardByRoute(storyboard);
|
|
10892
11045
|
({
|
|
10893
11046
|
pendingTask
|
|
10894
11047
|
} = yield _this3.kernel.loadDepsOfStoryboard(subStoryboard));
|
|
@@ -10960,6 +11113,7 @@ class Router {
|
|
|
10960
11113
|
try {
|
|
10961
11114
|
var mergedRoutes = mergePreviewRoutes(storyboard.routes);
|
|
10962
11115
|
yield locationContext.mountRoutes(mergedRoutes, undefined, mountRoutesResult);
|
|
11116
|
+
yield locationContext.storyboardContextWrapper.waitForAllContext();
|
|
10963
11117
|
} catch (error) {
|
|
10964
11118
|
// eslint-disable-next-line no-console
|
|
10965
11119
|
console.error(error);
|
|
@@ -11260,6 +11414,9 @@ class Router {
|
|
|
11260
11414
|
handleMessageClose(event) {
|
|
11261
11415
|
return this.locationContext.handleMessageClose(event);
|
|
11262
11416
|
}
|
|
11417
|
+
waitForUsedContext(data) {
|
|
11418
|
+
return this.locationContext.storyboardContextWrapper.waitForUsedContext(data);
|
|
11419
|
+
}
|
|
11263
11420
|
}
|
|
11264
11421
|
|
|
11265
11422
|
var customProcessorRegistry = new Map();
|