@next-core/brick-kit 2.159.5 → 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.
@@ -840,6 +840,7 @@
840
840
  data
841
841
  };
842
842
  if (options !== null && options !== void 0 && options.tplContextId) runtimeContext.tplContextId = options.tplContextId;
843
+ if (options !== null && options !== void 0 && options.formContextId) runtimeContext.formContextId = options.formContextId;
843
844
  result = evaluate(to, runtimeContext, options === null || options === void 0 ? void 0 : options.evaluateOptions);
844
845
  dismissRecursiveMarkingInjected = shouldDismissRecursiveMarkingInjected(to);
845
846
  } else {
@@ -1730,6 +1731,7 @@
1730
1731
  _defineProperty__default["default"](this, "data", new Map());
1731
1732
  _defineProperty__default["default"](this, "tplContextId", void 0);
1732
1733
  _defineProperty__default["default"](this, "formContextId", void 0);
1734
+ _defineProperty__default["default"](this, "pendingStack", []);
1733
1735
  this.tplContextId = tplContextId;
1734
1736
  this.formContextId = formContextId;
1735
1737
  }
@@ -1831,15 +1833,57 @@
1831
1833
  detail: item.value
1832
1834
  }));
1833
1835
  }
1834
- define(contextConfs, coreContext, brick) {
1836
+ waitForUsedContext(data) {
1835
1837
  var _this = this;
1838
+ return _asyncToGenerator__default["default"](function* () {
1839
+ if (_this.tplContextId || _this.formContextId) {
1840
+ return;
1841
+ }
1842
+ var usage = brickUtils.collectContextUsage(data, "CTX");
1843
+ if (usage.includesComputed) {
1844
+ for (var pending of _this.pendingStack) {
1845
+ yield pending.pendingResult;
1846
+ }
1847
+ } else if (usage.usedContexts.length > 0) {
1848
+ var _loop = function* (pendingContexts) {
1849
+ yield Promise.all(usage.usedContexts.map(ctx => pendingContexts.get(ctx)));
1850
+ };
1851
+ for (var {
1852
+ pendingContexts
1853
+ } of _this.pendingStack) {
1854
+ yield* _loop(pendingContexts);
1855
+ }
1856
+ }
1857
+ })();
1858
+ }
1859
+ waitForAllContext() {
1860
+ var _this2 = this;
1861
+ return _asyncToGenerator__default["default"](function* () {
1862
+ if (_this2.tplContextId || _this2.formContextId) {
1863
+ return;
1864
+ }
1865
+ for (var pending of _this2.pendingStack) {
1866
+ yield pending.pendingResult;
1867
+ }
1868
+ })();
1869
+ }
1870
+ deferDefine(contextConfs, coreContext, brick) {
1871
+ var {
1872
+ mergedContext,
1873
+ keyword
1874
+ } = this.getResolveOptions(coreContext);
1875
+ var pending = brickUtils.deferResolveContextConcurrently(Array.isArray(contextConfs) ? contextConfs : [], contextConf => resolveStoryboardContext(contextConf, mergedContext, this, brick), keyword);
1876
+ this.pendingStack.push(pending);
1877
+ }
1878
+ define(contextConfs, coreContext, brick) {
1879
+ var _this3 = this;
1836
1880
  return _asyncToGenerator__default["default"](function* () {
1837
1881
  if (Array.isArray(contextConfs)) {
1838
1882
  var {
1839
1883
  mergedContext,
1840
1884
  keyword
1841
- } = _this.getResolveOptions(coreContext);
1842
- yield brickUtils.resolveContextConcurrently(contextConfs, contextConf => resolveStoryboardContext(contextConf, mergedContext, _this, brick), keyword);
1885
+ } = _this3.getResolveOptions(coreContext);
1886
+ yield brickUtils.resolveContextConcurrently(contextConfs, contextConf => resolveStoryboardContext(contextConf, mergedContext, _this3, brick), keyword);
1843
1887
  }
1844
1888
  })();
1845
1889
  }
@@ -1891,6 +1935,7 @@
1891
1935
  }
1892
1936
  function _resolveNormalStoryboardContext() {
1893
1937
  _resolveNormalStoryboardContext = _asyncToGenerator__default["default"](function* (contextConf, mergedContext, storyboardContextWrapper, brick) {
1938
+ yield storyboardContextWrapper.waitForUsedContext(contextConf.if);
1894
1939
  if (!looseCheckIf(contextConf, mergedContext)) {
1895
1940
  return false;
1896
1941
  }
@@ -1900,6 +1945,7 @@
1900
1945
  var isLazyResolve = false;
1901
1946
  if (value === undefined) {
1902
1947
  if (contextConf.resolve) {
1948
+ yield storyboardContextWrapper.waitForUsedContext(contextConf.resolve.if);
1903
1949
  if (looseCheckIf(contextConf.resolve, mergedContext)) {
1904
1950
  load = /*#__PURE__*/function () {
1905
1951
  var _ref = _asyncToGenerator__default["default"](function* (options) {
@@ -1923,6 +1969,7 @@
1923
1969
  }
1924
1970
  }
1925
1971
  if ((!load || isLazyResolve) && contextConf.value !== undefined) {
1972
+ yield storyboardContextWrapper.waitForUsedContext(contextConf.value);
1926
1973
  // If the context has no resolve, just use its `value`.
1927
1974
  // Or if the resolve is ignored or lazy, use its `value` as a fallback.
1928
1975
  value = computeRealValue(contextConf.value, mergedContext, true);
@@ -2068,7 +2115,7 @@
2068
2115
  _defineProperty__default["default"](this, "formState", void 0);
2069
2116
  _defineProperty__default["default"](this, "id", _.uniqueId("form-ctx-"));
2070
2117
  FormContextMap.set(this.id, this);
2071
- this.formState = new StoryboardContextWrapper("", this.id);
2118
+ this.formState = new StoryboardContextWrapper(undefined, this.id);
2072
2119
  }
2073
2120
  }
2074
2121
  function getCustomFormContext(formContextId) {
@@ -2819,8 +2866,8 @@
2819
2866
  (function () {
2820
2867
  var menuI18nNamespace = getI18nNamespace("menu", "".concat(menu.menuId, "~").concat(menu.app[0].appId, "+").concat(menu.instanceId));
2821
2868
  // Support any language in `meta.i18n`.
2822
- Object.entries(menu.i18n).forEach(_ref3 => {
2823
- var [lang, resources] = _ref3;
2869
+ Object.entries(menu.i18n).forEach(_ref4 => {
2870
+ var [lang, resources] = _ref4;
2824
2871
  i18next__default["default"].addResourceBundle(lang, menuI18nNamespace, resources);
2825
2872
  });
2826
2873
  menuWithI18n.set(menu, menuI18nNamespace);
@@ -2920,8 +2967,8 @@
2920
2967
  }
2921
2968
  collectAppsRequireI18nFulfilled(items, context.app.id, appsRequireI18nFulfilled);
2922
2969
  yield kernel.fulfilStoryboardI18n([...appsRequireI18nFulfilled]);
2923
- var menuData = _objectSpread__default["default"](_objectSpread__default["default"]({}, computeRealValueWithOverrideApp(restMenuData, rootAppId, context, kernel)), {}, {
2924
- items: computeMenuItemsWithOverrideApp(items, context, kernel)
2970
+ var menuData = _objectSpread__default["default"](_objectSpread__default["default"]({}, yield computeRealValueWithOverrideApp(restMenuData, rootAppId, context, kernel)), {}, {
2971
+ items: yield computeMenuItemsWithOverrideApp(items, context, kernel)
2925
2972
  });
2926
2973
  return {
2927
2974
  title: yield processMenuTitle(menuData),
@@ -2969,17 +3016,22 @@
2969
3016
  collect(items);
2970
3017
  }
2971
3018
  function computeMenuItemsWithOverrideApp(items, context, kernel) {
2972
- return items.map(_ref2 => {
2973
- var {
2974
- children
2975
- } = _ref2,
2976
- rest = _objectWithoutProperties__default["default"](_ref2, _excluded2$2);
2977
- return _objectSpread__default["default"](_objectSpread__default["default"]({}, computeRealValueWithOverrideApp(rest, rest[symbolAppId], context, kernel)), {}, {
2978
- children: children && computeMenuItemsWithOverrideApp(children, context, kernel)
3019
+ return Promise.all(items.map( /*#__PURE__*/function () {
3020
+ var _ref3 = _asyncToGenerator__default["default"](function* (_ref2) {
3021
+ var {
3022
+ children
3023
+ } = _ref2,
3024
+ rest = _objectWithoutProperties__default["default"](_ref2, _excluded2$2);
3025
+ return _objectSpread__default["default"](_objectSpread__default["default"]({}, yield computeRealValueWithOverrideApp(rest, rest[symbolAppId], context, kernel)), {}, {
3026
+ children: children && (yield computeMenuItemsWithOverrideApp(children, context, kernel))
3027
+ });
2979
3028
  });
2980
- });
3029
+ return function (_x20) {
3030
+ return _ref3.apply(this, arguments);
3031
+ };
3032
+ }()));
2981
3033
  }
2982
- function processMenuTitle(_x20) {
3034
+ function processMenuTitle(_x21) {
2983
3035
  return _processMenuTitle.apply(this, arguments);
2984
3036
  }
2985
3037
  function _processMenuTitle() {
@@ -3058,25 +3110,32 @@
3058
3110
  }
3059
3111
  return false;
3060
3112
  }
3061
- function computeRealValueWithOverrideApp(data, overrideAppId, context, kernel) {
3062
- var newContext = context;
3063
- if (overrideAppId !== context.app.id && attemptToVisit(data, ["APP", "I18N"])) {
3064
- if (window.STANDALONE_MICRO_APPS) {
3065
- newContext = _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
3066
- overrideApp: data[symbolOverrideApp],
3067
- appendI18nNamespace: data[symbolMenuI18nNamespace]
3068
- });
3069
- } else {
3070
- var storyboard = kernel.bootstrapData.storyboards.find(story => story.app.id === overrideAppId);
3071
- newContext = _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
3072
- overrideApp: storyboard === null || storyboard === void 0 ? void 0 : storyboard.app,
3073
- appendI18nNamespace: data[symbolMenuI18nNamespace]
3074
- });
3113
+ function computeRealValueWithOverrideApp(_x22, _x23, _x24, _x25) {
3114
+ return _computeRealValueWithOverrideApp.apply(this, arguments);
3115
+ }
3116
+ function _computeRealValueWithOverrideApp() {
3117
+ _computeRealValueWithOverrideApp = _asyncToGenerator__default["default"](function* (data, overrideAppId, context, kernel) {
3118
+ var newContext = context;
3119
+ if (overrideAppId !== context.app.id && attemptToVisit(data, ["APP", "I18N"])) {
3120
+ if (window.STANDALONE_MICRO_APPS) {
3121
+ newContext = _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
3122
+ overrideApp: data[symbolOverrideApp],
3123
+ appendI18nNamespace: data[symbolMenuI18nNamespace]
3124
+ });
3125
+ } else {
3126
+ var storyboard = kernel.bootstrapData.storyboards.find(story => story.app.id === overrideAppId);
3127
+ newContext = _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
3128
+ overrideApp: storyboard === null || storyboard === void 0 ? void 0 : storyboard.app,
3129
+ appendI18nNamespace: data[symbolMenuI18nNamespace]
3130
+ });
3131
+ }
3075
3132
  }
3076
- }
3077
- return computeRealValue(data, newContext, true, {
3078
- ignoreSymbols: true
3133
+ yield kernel.router.waitForUsedContext(data);
3134
+ return computeRealValue(data, newContext, true, {
3135
+ ignoreSymbols: true
3136
+ });
3079
3137
  });
3138
+ return _computeRealValueWithOverrideApp.apply(this, arguments);
3080
3139
  }
3081
3140
 
3082
3141
  var lazyBrickRegistry = new Map();
@@ -7633,17 +7692,21 @@
7633
7692
  }
7634
7693
  return lowLevelExpandCustomTemplate(template, brickConf, proxyBrick, context, tplContext);
7635
7694
  }
7636
- function asyncExpandCustomTemplate(_x, _x2, _x3) {
7695
+ function asyncExpandCustomTemplate(_x, _x2, _x3, _x4) {
7637
7696
  return _asyncExpandCustomTemplate.apply(this, arguments);
7638
7697
  }
7639
7698
  function _asyncExpandCustomTemplate() {
7640
- _asyncExpandCustomTemplate = _asyncToGenerator__default["default"](function* (brickConf, proxyBrick, context) {
7699
+ _asyncExpandCustomTemplate = _asyncToGenerator__default["default"](function* (brickConf, proxyBrick, context, locationContext) {
7641
7700
  var tplContext = new CustomTemplateContext(proxyBrick);
7642
7701
  var template = customTemplateRegistry.get(brickConf.brick);
7643
7702
  if (template.contracts) {
7644
7703
  collectWidgetContract(template.contracts);
7645
7704
  }
7646
7705
  if (Array.isArray(template.state)) {
7706
+ if (locationContext) {
7707
+ // Handle use cases of using `CTX.*` in template states.
7708
+ yield locationContext.storyboardContextWrapper.waitForUsedContext(template.state.map(state => [state.if, state.value, state.resolve]));
7709
+ }
7647
7710
  yield tplContext.state.define(template.state, context, proxyBrick);
7648
7711
  }
7649
7712
  return lowLevelExpandCustomTemplate(template, brickConf, proxyBrick, context, tplContext);
@@ -8990,50 +9053,85 @@
8990
9053
  return conf.type === "routes";
8991
9054
  }
8992
9055
 
8993
- function getSubStoryboardByRoute(storyboard, matcher) {
8994
- function getSubRoutes(routes) {
8995
- return matcher(routes).map(getSubRoute);
8996
- }
8997
- function getSubRoute(route) {
8998
- if (route.type === "routes") {
8999
- return _objectSpread__default["default"](_objectSpread__default["default"]({}, route), {}, {
9000
- routes: getSubRoutes(route.routes)
9056
+ function getSubStoryboardByRoute(_x, _x2) {
9057
+ return _getSubStoryboardByRoute.apply(this, arguments);
9058
+ }
9059
+ function _getSubStoryboardByRoute() {
9060
+ _getSubStoryboardByRoute = _asyncToGenerator__default["default"](function* (storyboard, matcher) {
9061
+ function getSubRoutes(_x3) {
9062
+ return _getSubRoutes.apply(this, arguments);
9063
+ }
9064
+ function _getSubRoutes() {
9065
+ _getSubRoutes = _asyncToGenerator__default["default"](function* (routes) {
9066
+ return Promise.all((yield matcher(routes)).map(getSubRoute));
9001
9067
  });
9068
+ return _getSubRoutes.apply(this, arguments);
9002
9069
  }
9003
- return _objectSpread__default["default"](_objectSpread__default["default"]({}, route), {}, {
9004
- bricks: getSubBricks(route.bricks)
9005
- });
9006
- }
9007
- function getSubBricks(bricks) {
9008
- if (Array.isArray(bricks)) {
9009
- return bricks.map(brickConf => getSubBrick(brickConf));
9010
- }
9011
- return bricks;
9012
- }
9013
- function getSubBrick(brickConf) {
9014
- if (brickUtils.isObject(brickConf.slots)) {
9015
- return _objectSpread__default["default"](_objectSpread__default["default"]({}, brickConf), {}, {
9016
- slots: Object.fromEntries(Object.entries(brickConf.slots).map(_ref => {
9017
- var [slotId, slotConf] = _ref;
9018
- if (slotConf.type === "routes") {
9019
- return [slotId, _objectSpread__default["default"](_objectSpread__default["default"]({}, slotConf), {}, {
9020
- routes: getSubRoutes(slotConf.routes)
9021
- })];
9022
- } /* istanbul ignore else: should never reach */else if (slotConf.type === "bricks") {
9023
- return [slotId, _objectSpread__default["default"](_objectSpread__default["default"]({}, slotConf), {}, {
9024
- bricks: getSubBricks(slotConf.bricks)
9025
- })];
9026
- }
9027
- /* istanbul ignore next: should never reach */
9028
- return [slotId, slotConf];
9029
- }))
9070
+ function getSubRoute(_x4) {
9071
+ return _getSubRoute.apply(this, arguments);
9072
+ }
9073
+ function _getSubRoute() {
9074
+ _getSubRoute = _asyncToGenerator__default["default"](function* (route) {
9075
+ if (route.type === "routes") {
9076
+ return _objectSpread__default["default"](_objectSpread__default["default"]({}, route), {}, {
9077
+ routes: yield getSubRoutes(route.routes)
9078
+ });
9079
+ }
9080
+ return _objectSpread__default["default"](_objectSpread__default["default"]({}, route), {}, {
9081
+ bricks: yield getSubBricks(route.bricks)
9082
+ });
9030
9083
  });
9084
+ return _getSubRoute.apply(this, arguments);
9031
9085
  }
9032
- return brickConf;
9033
- }
9034
- return _objectSpread__default["default"](_objectSpread__default["default"]({}, storyboard), {}, {
9035
- routes: getSubRoutes(storyboard.routes)
9086
+ function getSubBricks(_x5) {
9087
+ return _getSubBricks.apply(this, arguments);
9088
+ }
9089
+ function _getSubBricks() {
9090
+ _getSubBricks = _asyncToGenerator__default["default"](function* (bricks) {
9091
+ if (Array.isArray(bricks)) {
9092
+ return Promise.all(bricks.map(brickConf => getSubBrick(brickConf)));
9093
+ }
9094
+ return bricks;
9095
+ });
9096
+ return _getSubBricks.apply(this, arguments);
9097
+ }
9098
+ function getSubBrick(_x6) {
9099
+ return _getSubBrick.apply(this, arguments);
9100
+ }
9101
+ function _getSubBrick() {
9102
+ _getSubBrick = _asyncToGenerator__default["default"](function* (brickConf) {
9103
+ if (brickUtils.isObject(brickConf.slots)) {
9104
+ return _objectSpread__default["default"](_objectSpread__default["default"]({}, brickConf), {}, {
9105
+ slots: Object.fromEntries(yield Promise.all(Object.entries(brickConf.slots).map( /*#__PURE__*/function () {
9106
+ var _ref2 = _asyncToGenerator__default["default"](function* (_ref) {
9107
+ var [slotId, slotConf] = _ref;
9108
+ if (slotConf.type === "routes") {
9109
+ return [slotId, _objectSpread__default["default"](_objectSpread__default["default"]({}, slotConf), {}, {
9110
+ routes: yield getSubRoutes(slotConf.routes)
9111
+ })];
9112
+ } /* istanbul ignore else: should never reach */else if (slotConf.type === "bricks") {
9113
+ return [slotId, _objectSpread__default["default"](_objectSpread__default["default"]({}, slotConf), {}, {
9114
+ bricks: yield getSubBricks(slotConf.bricks)
9115
+ })];
9116
+ }
9117
+ /* istanbul ignore next: should never reach */
9118
+ return [slotId, slotConf];
9119
+ });
9120
+ return function (_x7) {
9121
+ return _ref2.apply(this, arguments);
9122
+ };
9123
+ }())))
9124
+ });
9125
+ }
9126
+ return brickConf;
9127
+ });
9128
+ return _getSubBrick.apply(this, arguments);
9129
+ }
9130
+ return _objectSpread__default["default"](_objectSpread__default["default"]({}, storyboard), {}, {
9131
+ routes: yield getSubRoutes(storyboard.routes)
9132
+ });
9036
9133
  });
9134
+ return _getSubStoryboardByRoute.apply(this, arguments);
9037
9135
  }
9038
9136
 
9039
9137
  function listenOnTrackingContext(brick, trackingContextList, context) {
@@ -9084,14 +9182,18 @@
9084
9182
  }
9085
9183
  return getFinalStoryBoard(formData, brickConf, isPreview, formContext);
9086
9184
  }
9087
- function AsyncExpandCustomForm(_x, _x2, _x3, _x4) {
9185
+ function AsyncExpandCustomForm(_x, _x2, _x3, _x4, _x5) {
9088
9186
  return _AsyncExpandCustomForm.apply(this, arguments);
9089
9187
  }
9090
9188
  function _AsyncExpandCustomForm() {
9091
- _AsyncExpandCustomForm = _asyncToGenerator__default["default"](function* (formData, brickConf, isPreview, context) {
9189
+ _AsyncExpandCustomForm = _asyncToGenerator__default["default"](function* (formData, brickConf, isPreview, context, locationContext) {
9092
9190
  var formContext = new CustomFormContext();
9093
9191
  formData = initFormContext(formData, brickConf, isPreview);
9094
9192
  if (Array.isArray(formData.context)) {
9193
+ if (locationContext) {
9194
+ // Handle use cases of using `CTX.*` in template states.
9195
+ yield locationContext.storyboardContextWrapper.waitForUsedContext(formData.context.map(state => [state.if, state.value, state.resolve]));
9196
+ }
9095
9197
  yield formContext.formState.define(formData.context, _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
9096
9198
  formContextId: formContext.id
9097
9199
  }), {});
@@ -9477,7 +9579,7 @@
9477
9579
  _defineProperty__default["default"](this, "observersList", []);
9478
9580
  this.kernel = kernel;
9479
9581
  this.location = location;
9480
- this.resolver = new Resolver(kernel);
9582
+ this.resolver = new Resolver(kernel, this);
9481
9583
  this.query = new URLSearchParams(location.search);
9482
9584
  this.messageDispatcher = getMessageDispatcher();
9483
9585
  }
@@ -9515,60 +9617,79 @@
9515
9617
  match: this.currentMatch
9516
9618
  });
9517
9619
  }
9620
+ deferComputeRealValue() {
9621
+ var _arguments = arguments,
9622
+ _this = this;
9623
+ return _asyncToGenerator__default["default"](function* () {
9624
+ yield _this.storyboardContextWrapper.waitForUsedContext(_arguments.length <= 0 ? undefined : _arguments[0]);
9625
+ return computeRealValue(..._arguments);
9626
+ })();
9627
+ }
9518
9628
  matchRoutes(routes, app) {
9519
- var _this = this;
9520
- var _loop = function (route) {
9521
- var computedPath = brickUtils.computeRealRoutePath(route.path, app);
9522
- if ([].concat(computedPath).includes(undefined)) {
9523
- // eslint-disable-next-line no-console
9524
- console.error("Invalid route with invalid path:", route);
9525
- return {
9526
- v: "missed"
9527
- };
9528
- }
9529
- var match = brickUtils.matchPath(_this.location.pathname, {
9530
- path: computedPath,
9531
- exact: route.exact,
9532
- checkIf: context => looseCheckIf(route, context),
9533
- getContext: match => _this.getContext({
9534
- match
9535
- })
9536
- });
9537
- if (match !== null) {
9538
- if (app.noAuthGuard || route.public || isLoggedIn()) {
9539
- _this.currentMatch = match;
9629
+ var _this2 = this;
9630
+ return _asyncToGenerator__default["default"](function* () {
9631
+ var _loop = function* (route) {
9632
+ var computedPath = brickUtils.computeRealRoutePath(route.path, app);
9633
+ if ([].concat(computedPath).includes(undefined)) {
9634
+ // eslint-disable-next-line no-console
9635
+ console.error("Invalid route with invalid path:", route);
9540
9636
  return {
9541
- v: {
9542
- match,
9543
- route
9544
- }
9637
+ v: "missed"
9545
9638
  };
9546
9639
  }
9547
- return {
9548
- v: "unauthenticated"
9549
- };
9640
+ yield _this2.storyboardContextWrapper.waitForUsedContext(route.if);
9641
+ var match = brickUtils.matchPath(_this2.location.pathname, {
9642
+ path: computedPath,
9643
+ exact: route.exact,
9644
+ checkIf: context => looseCheckIf(route, context),
9645
+ getContext: match => _this2.getContext({
9646
+ match
9647
+ })
9648
+ });
9649
+ if (match !== null) {
9650
+ if (app.noAuthGuard || route.public || isLoggedIn()) {
9651
+ _this2.currentMatch = match;
9652
+ return {
9653
+ v: {
9654
+ match,
9655
+ route
9656
+ }
9657
+ };
9658
+ }
9659
+ return {
9660
+ v: "unauthenticated"
9661
+ };
9662
+ }
9663
+ };
9664
+ for (var route of routes) {
9665
+ var _ret = yield* _loop(route);
9666
+ if (typeof _ret === "object") return _ret.v;
9550
9667
  }
9551
- };
9552
- for (var route of routes) {
9553
- var _ret = _loop(route);
9554
- if (typeof _ret === "object") return _ret.v;
9555
- }
9556
- return "missed";
9668
+ return "missed";
9669
+ })();
9557
9670
  }
9558
9671
  matchStoryboard(storyboards) {
9559
9672
  return matchStoryboard(storyboards, this.location.pathname);
9560
9673
  }
9561
9674
  getSubStoryboardByRoute(storyboard) {
9562
- var matcher = routes => {
9563
- var matched = this.matchRoutes(routes, storyboard.app);
9564
- return brickUtils.isObject(matched) ? [matched.route] : [];
9565
- };
9566
- return getSubStoryboardByRoute(storyboard, matcher);
9675
+ var _this3 = this;
9676
+ return _asyncToGenerator__default["default"](function* () {
9677
+ var matcher = /*#__PURE__*/function () {
9678
+ var _ref2 = _asyncToGenerator__default["default"](function* (routes) {
9679
+ var matched = yield _this3.matchRoutes(routes, storyboard.app);
9680
+ return brickUtils.isObject(matched) ? [matched.route] : [];
9681
+ });
9682
+ return function matcher(_x) {
9683
+ return _ref2.apply(this, arguments);
9684
+ };
9685
+ }();
9686
+ return getSubStoryboardByRoute(storyboard, matcher);
9687
+ })();
9567
9688
  }
9568
9689
  mountRoutes(routes, slotId, mountRoutesResult) {
9569
- var _this2 = this;
9690
+ var _this4 = this;
9570
9691
  return _asyncToGenerator__default["default"](function* () {
9571
- var matched = _this2.matchRoutes(routes, _this2.kernel.nextApp);
9692
+ var matched = yield _this4.matchRoutes(routes, _this4.kernel.nextApp);
9572
9693
  var redirect;
9573
9694
  var redirectConf = {};
9574
9695
  var context;
@@ -9582,19 +9703,26 @@
9582
9703
  default:
9583
9704
  mountRoutesResult.route = route = matched.route;
9584
9705
  if (route.segues) {
9585
- Object.assign(_this2.segues, route.segues);
9706
+ Object.assign(_this4.segues, route.segues);
9586
9707
  }
9587
9708
  if (route.hybrid) {
9588
9709
  mountRoutesResult.flags.hybrid = true;
9589
9710
  }
9590
- context = _this2.getContext({
9711
+ context = _this4.getContext({
9591
9712
  match: matched.match
9592
9713
  });
9593
- _this2.resolver.defineResolves(route.defineResolves, context);
9594
- yield _this2.mountProviders(route.providers, matched.match, slotId, mountRoutesResult);
9595
- yield _this2.storyboardContextWrapper.define(route.context, context);
9596
- yield _this2.preCheckPermissions(route, context);
9597
- redirect = computeRealValue(route.redirect, context, true);
9714
+ yield _this4.storyboardContextWrapper.waitForUsedContext(route.defineResolves);
9715
+ _this4.resolver.defineResolves(route.defineResolves, context);
9716
+ yield _this4.mountProviders(route.providers, matched.match, slotId, mountRoutesResult);
9717
+
9718
+ // istanbul ignore else
9719
+ if (_this4.kernel.getFeatureFlags()["next-core-deferred-context"]) {
9720
+ _this4.storyboardContextWrapper.deferDefine(route.context, context);
9721
+ } else {
9722
+ yield _this4.storyboardContextWrapper.define(route.context, context);
9723
+ }
9724
+ yield _this4.preCheckPermissions(route, context);
9725
+ redirect = yield _this4.deferComputeRealValue(route.redirect, context, true);
9598
9726
  if (redirect) {
9599
9727
  if (typeof redirect === "string") {
9600
9728
  // Directly redirect.
@@ -9604,7 +9732,7 @@
9604
9732
  break;
9605
9733
  } else {
9606
9734
  // Resolvable redirect.
9607
- yield _this2.resolver.resolveOne("reference", redirect, redirectConf);
9735
+ yield _this4.resolver.resolveOne("reference", redirect, redirectConf);
9608
9736
  if (redirectConf.redirect) {
9609
9737
  mountRoutesResult.flags.redirect = {
9610
9738
  path: redirectConf.redirect
@@ -9613,20 +9741,20 @@
9613
9741
  }
9614
9742
  }
9615
9743
  }
9616
- yield _this2.mountMenu(route.menu, matched.match, mountRoutesResult);
9744
+ yield _this4.mountMenu(route.menu, matched.match, mountRoutesResult);
9617
9745
  if (route.documentId) {
9618
9746
  mountRoutesResult.appBar.documentId = route.documentId;
9619
9747
  }
9620
9748
  if (isRouteConfOfRoutes(route) && Array.isArray(route.routes)) {
9621
- yield _this2.preFetchMenu(route.context);
9622
- yield _this2.mountRoutes(route.routes, slotId, mountRoutesResult);
9749
+ yield _this4.preFetchMenu(route.context);
9750
+ yield _this4.mountRoutes(route.routes, slotId, mountRoutesResult);
9623
9751
  } else if (isRouteConfOfBricks(route) && Array.isArray(route.bricks)) {
9624
- yield _this2.preFetchMenu(route);
9625
- yield _this2.mountBricks(route.bricks, matched.match, slotId, mountRoutesResult);
9752
+ yield _this4.preFetchMenu(route);
9753
+ yield _this4.mountBricks(route.bricks, matched.match, slotId, mountRoutesResult);
9626
9754
 
9627
9755
  // analytics data (page_view event)
9628
9756
  if (route.analyticsData) {
9629
- mountRoutesResult.analyticsData = computeRealValue(route.analyticsData, context, true);
9757
+ mountRoutesResult.analyticsData = yield _this4.deferComputeRealValue(route.analyticsData, context, true);
9630
9758
  }
9631
9759
  }
9632
9760
  }
@@ -9634,7 +9762,7 @@
9634
9762
  })();
9635
9763
  }
9636
9764
  mountMenu(menuConf, match, mountRoutesResult) {
9637
- var _this3 = this;
9765
+ var _this5 = this;
9638
9766
  return _asyncToGenerator__default["default"](function* () {
9639
9767
  if (menuConf === false) {
9640
9768
  // `route.menu` 设置为 `false` 表示不显示顶栏和侧栏。
@@ -9646,7 +9774,7 @@
9646
9774
  if (!menuConf) {
9647
9775
  return;
9648
9776
  }
9649
- var context = _this3.getContext({
9777
+ var context = _this5.getContext({
9650
9778
  match
9651
9779
  });
9652
9780
  if (menuConf.type === "brick") {
@@ -9656,6 +9784,7 @@
9656
9784
  // 那么可以将菜单配置指定为一个构件,这个构件会被装载到背景容器中(不会在界面中显示),
9657
9785
  // 应该在这个构件的 `connectedCallback` 中执行相关菜单设置,
9658
9786
  // 例如 `getRuntime().menuBar.setAppMenu(...)`。
9787
+ yield _this5.storyboardContextWrapper.waitForUsedContext(menuConf.properties);
9659
9788
  var brick = {
9660
9789
  type: menuConf.brick,
9661
9790
  properties: computeRealProperties(menuConf.properties, context, menuConf.injectDeep !== false),
@@ -9663,16 +9792,16 @@
9663
9792
  context,
9664
9793
  children: []
9665
9794
  };
9666
- _this3.registerHandlersFromLifeCycle(menuConf.lifeCycle, brick, match);
9795
+ _this5.registerHandlersFromLifeCycle(menuConf.lifeCycle, brick, match);
9667
9796
 
9668
9797
  // Then, resolve the brick.
9669
- yield _this3.resolver.resolve(menuConf, brick, context);
9798
+ yield _this5.resolver.resolve(menuConf, brick, context);
9670
9799
  mountRoutesResult.menuInBg.push(brick);
9671
9800
  return;
9672
9801
  }
9673
9802
  var injectDeep = menuConf.injectDeep;
9674
9803
  if (menuConf.type === "resolve") {
9675
- yield _this3.resolver.resolveOne("reference", _objectSpread__default["default"]({
9804
+ yield _this5.resolver.resolveOne("reference", _objectSpread__default["default"]({
9676
9805
  transformMapArray: false
9677
9806
  }, menuConf.resolve), menuConf, null, context);
9678
9807
  injectDeep = false;
@@ -9680,7 +9809,7 @@
9680
9809
 
9681
9810
  // 静态菜单配置,仅在有值时才设置,这样可以让菜单设置也具有按路由层级覆盖的能力。
9682
9811
  var otherMenuConf = _.omit(menuConf, ["injectDeep", "type"]);
9683
- var injectedMenuConf = injectDeep !== false ? computeRealValue(otherMenuConf, context, true) : otherMenuConf;
9812
+ var injectedMenuConf = injectDeep !== false ? yield _this5.deferComputeRealValue(otherMenuConf, context, true) : otherMenuConf;
9684
9813
  var {
9685
9814
  sidebarMenu,
9686
9815
  pageTitle,
@@ -9712,11 +9841,11 @@
9712
9841
  })();
9713
9842
  }
9714
9843
  mountProviders(providers, match, slotId, mountRoutesResult) {
9715
- var _this4 = this;
9844
+ var _this6 = this;
9716
9845
  return _asyncToGenerator__default["default"](function* () {
9717
9846
  if (Array.isArray(providers)) {
9718
9847
  for (var providerConf of providers) {
9719
- yield _this4.mountBrick(_objectSpread__default["default"](_objectSpread__default["default"]({}, typeof providerConf === "string" ? {
9848
+ yield _this6.mountBrick(_objectSpread__default["default"](_objectSpread__default["default"]({}, typeof providerConf === "string" ? {
9720
9849
  brick: providerConf
9721
9850
  } : providerConf), {}, {
9722
9851
  bg: true,
@@ -9727,11 +9856,11 @@
9727
9856
  })();
9728
9857
  }
9729
9858
  mountBricks(bricks, match, slotId, mountRoutesResult, tplStack) {
9730
- var _this5 = this;
9859
+ var _this7 = this;
9731
9860
  return _asyncToGenerator__default["default"](function* () {
9732
9861
  for (var brickConf of bricks) {
9733
9862
  try {
9734
- yield _this5.mountBrick(brickConf, match, slotId, mountRoutesResult, tplStack && new Map(tplStack));
9863
+ yield _this7.mountBrick(brickConf, match, slotId, mountRoutesResult, tplStack && new Map(tplStack));
9735
9864
  } catch (error) {
9736
9865
  if (error instanceof ResolveRequestError) {
9737
9866
  var errorMessage = httpErrorToString(error.rawError);
@@ -9759,57 +9888,59 @@
9759
9888
  })();
9760
9889
  }
9761
9890
  checkResolvableIf(ifContainer, context) {
9762
- var _this6 = this;
9891
+ var _this8 = this;
9763
9892
  return _asyncToGenerator__default["default"](function* () {
9893
+ yield _this8.storyboardContextWrapper.waitForUsedContext(ifContainer.if);
9764
9894
  if (brickUtils.isObject(ifContainer.if)) {
9765
9895
  var ifChecked = computeRealValue(ifContainer.if, context, true);
9766
9896
  var ifConf = {};
9767
- yield _this6.resolver.resolveOne("reference", ifChecked, ifConf);
9897
+ yield _this8.resolver.resolveOne("reference", ifChecked, ifConf);
9768
9898
  return !brickUtils.hasOwnProperty(ifConf, "if") || !!ifConf.if;
9769
9899
  }
9770
9900
  return looseCheckIf(ifContainer, context);
9771
9901
  })();
9772
9902
  }
9773
9903
  preCheckPermissions(container, context) {
9904
+ var _this9 = this;
9774
9905
  return _asyncToGenerator__default["default"](function* () {
9775
9906
  if (isLoggedIn() && !getAuth().isAdmin && container.permissionsPreCheck && Array.isArray(container.permissionsPreCheck)) {
9776
- var usedActions = computeRealValue(container.permissionsPreCheck, context, true);
9907
+ var usedActions = yield _this9.deferComputeRealValue(container.permissionsPreCheck, context, true);
9777
9908
  yield validatePermissions(usedActions);
9778
9909
  }
9779
9910
  })();
9780
9911
  }
9781
9912
  mountBrick(brickConf, match, slotId, mountRoutesResult) {
9782
- var _arguments = arguments,
9783
- _this7 = this;
9913
+ var _arguments2 = arguments,
9914
+ _this10 = this;
9784
9915
  return _asyncToGenerator__default["default"](function* () {
9785
- var _this7$kernel$nextApp, _brickConf$lifeCycle, _brick$lifeCycle;
9786
- var tplStack = _arguments.length > 4 && _arguments[4] !== undefined ? _arguments[4] : new Map();
9916
+ var _this10$kernel$nextAp, _brickConf$lifeCycle, _brick$lifeCycle;
9917
+ var tplStack = _arguments2.length > 4 && _arguments2[4] !== undefined ? _arguments2[4] : new Map();
9787
9918
  var tplContextId = brickConf[symbolForTplContextId];
9788
9919
  var formContextId = brickConf[symbolForFormContextId];
9789
- var context = _this7.getContext({
9920
+ var context = _this10.getContext({
9790
9921
  match,
9791
9922
  tplContextId,
9792
9923
  formContextId
9793
9924
  });
9794
9925
 
9795
9926
  // First, check whether the brick should be rendered.
9796
- if (!(yield _this7.checkResolvableIf(brickConf, context))) {
9927
+ if (!(yield _this10.checkResolvableIf(brickConf, context))) {
9797
9928
  return;
9798
9929
  }
9799
9930
 
9800
9931
  // Then, resolve the template to a brick.
9801
9932
  if (brickConf.template) {
9802
- yield _this7.resolver.resolve(brickConf, null, context);
9933
+ yield _this10.resolver.resolve(brickConf, null, context);
9803
9934
  }
9804
9935
 
9805
9936
  // Check `if` again for dynamic loaded templates.
9806
- if (!(yield _this7.checkResolvableIf(brickConf, context))) {
9937
+ if (!(yield _this10.checkResolvableIf(brickConf, context))) {
9807
9938
  return;
9808
9939
  }
9809
9940
 
9810
9941
  // If it's a custom template, `tplTagName` is the tag name of the template.
9811
9942
  // Otherwise, `tplTagName` is false.
9812
- var tplTagName = getTagNameOfCustomTemplate(brickConf.brick, (_this7$kernel$nextApp = _this7.kernel.nextApp) === null || _this7$kernel$nextApp === void 0 ? void 0 : _this7$kernel$nextApp.id);
9943
+ var tplTagName = getTagNameOfCustomTemplate(brickConf.brick, (_this10$kernel$nextAp = _this10.kernel.nextApp) === null || _this10$kernel$nextAp === void 0 ? void 0 : _this10$kernel$nextAp.id);
9813
9944
  if (tplTagName) {
9814
9945
  var _tplStack$get;
9815
9946
  var tplCount = (_tplStack$get = tplStack.get(tplTagName)) !== null && _tplStack$get !== void 0 ? _tplStack$get : 0;
@@ -9822,9 +9953,16 @@
9822
9953
  brickConf.properties.formData = JSON.stringify(brickConf.properties.formData);
9823
9954
  }
9824
9955
  var brick = {};
9825
- yield _this7.storyboardContextWrapper.define(brickConf.context, context, brick);
9826
- yield _this7.preCheckPermissions(brickConf, context);
9956
+
9957
+ // istanbul ignore else
9958
+ if (_this10.kernel.getFeatureFlags()["next-core-deferred-context"]) {
9959
+ _this10.storyboardContextWrapper.deferDefine(brickConf.context, context, brick);
9960
+ } else {
9961
+ yield _this10.storyboardContextWrapper.define(brickConf.context, context, brick);
9962
+ }
9963
+ yield _this10.preCheckPermissions(brickConf, context);
9827
9964
  var trackingContextList = [];
9965
+ yield _this10.storyboardContextWrapper.waitForUsedContext(brickConf.properties);
9828
9966
  Object.assign(brick, _objectSpread__default["default"]({
9829
9967
  type: tplTagName || brickConf.brick,
9830
9968
  properties: computeRealProperties(brickConf.properties, context, brickConf.injectDeep !== false, trackingContextList),
@@ -9842,8 +9980,8 @@
9842
9980
  }
9843
9981
  } : {}));
9844
9982
  if (brickConf[symbolForComputedPropsFromProxy]) {
9845
- Object.entries(brickConf[symbolForComputedPropsFromProxy]).forEach(_ref2 => {
9846
- var [propName, propValue] = _ref2;
9983
+ Object.entries(brickConf[symbolForComputedPropsFromProxy]).forEach(_ref3 => {
9984
+ var [propName, propValue] = _ref3;
9847
9985
  _.set(brick.properties, propName, propValue);
9848
9986
  });
9849
9987
  }
@@ -9851,36 +9989,36 @@
9851
9989
  if (brick.refForProxy) {
9852
9990
  brick.refForProxy.brick = brick;
9853
9991
  }
9854
- _this7.registerHandlersFromLifeCycle(brickConf.lifeCycle, brick, match, tplContextId);
9992
+ _this10.registerHandlersFromLifeCycle(brickConf.lifeCycle, brick, match, tplContextId);
9855
9993
  if ((_brick$lifeCycle = brick.lifeCycle) !== null && _brick$lifeCycle !== void 0 && _brick$lifeCycle.onScrollIntoView) {
9856
- _this7.brickBindObserver(brick);
9994
+ _this10.brickBindObserver(brick);
9857
9995
  }
9858
9996
 
9859
9997
  // Then, resolve the brick.
9860
- yield _this7.resolver.resolve(brickConf, brick, context);
9998
+ yield _this10.resolver.resolve(brickConf, brick, context);
9861
9999
  var expandedBrickConf = brickConf;
9862
10000
  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);
9863
- if (tplTagName && (!isBaseLayout || _this7.kernel.getFeatureFlags()["support-ui-8.0-base-layout"] && isBaseLayout)) {
10001
+ if (tplTagName && (!isBaseLayout || _this10.kernel.getFeatureFlags()["support-ui-8.0-base-layout"] && isBaseLayout)) {
9864
10002
  var _customTemplateRegist;
9865
- yield _this7.preFetchMenu((_customTemplateRegist = customTemplateRegistry.get(tplTagName)) === null || _customTemplateRegist === void 0 ? void 0 : _customTemplateRegist.bricks);
10003
+ yield _this10.preFetchMenu((_customTemplateRegist = customTemplateRegistry.get(tplTagName)) === null || _customTemplateRegist === void 0 ? void 0 : _customTemplateRegist.bricks);
9866
10004
  expandedBrickConf = yield asyncExpandCustomTemplate(_objectSpread__default["default"](_objectSpread__default["default"]({}, brickConf), {}, {
9867
10005
  brick: tplTagName,
9868
10006
  // Properties are computed for custom templates.
9869
10007
  properties: brick.properties
9870
- }), brick, context);
10008
+ }), brick, context, _this10);
9871
10009
 
9872
10010
  // Try to load deps for dynamic added bricks.
9873
- yield _this7.kernel.loadDynamicBricksInBrickConf(expandedBrickConf);
10011
+ yield _this10.kernel.loadDynamicBricksInBrickConf(expandedBrickConf);
9874
10012
  }
9875
10013
  if (brick.type === formRenderer) {
9876
10014
  var formData = typeof brick.properties.formData === "string" ? JSON.parse(brick.properties.formData) : brick.properties.formData;
9877
- expandedBrickConf = yield AsyncExpandCustomForm(formData, brickConf, brick.properties.isPreview, context);
9878
- yield _this7.kernel.loadDynamicBricksInBrickConf(expandedBrickConf);
10015
+ expandedBrickConf = yield AsyncExpandCustomForm(formData, brickConf, brick.properties.isPreview, context, _this10);
10016
+ yield _this10.kernel.loadDynamicBricksInBrickConf(expandedBrickConf);
9879
10017
  }
9880
10018
  if (expandedBrickConf.exports) {
9881
10019
  for (var [prop, ctxName] of Object.entries(expandedBrickConf.exports)) {
9882
10020
  if (typeof ctxName === "string" && ctxName.startsWith("CTX.")) {
9883
- _this7.storyboardContextWrapper.set(ctxName.substring(4), {
10021
+ _this10.storyboardContextWrapper.set(ctxName.substring(4), {
9884
10022
  type: "brick-property",
9885
10023
  brick,
9886
10024
  prop
@@ -9891,8 +10029,8 @@
9891
10029
  if (expandedBrickConf.bg) {
9892
10030
  // A bg brick has no slotId.
9893
10031
  brick.slotId = undefined;
9894
- yield _this7.kernel.loadDynamicBricks([brick.type]);
9895
- appendBrick(brick, _this7.kernel.mountPoints.bg);
10032
+ yield _this10.kernel.loadDynamicBricks([brick.type]);
10033
+ appendBrick(brick, _this10.kernel.mountPoints.bg);
9896
10034
  } else {
9897
10035
  if (expandedBrickConf.portal) {
9898
10036
  // A portal brick has no slotId.
@@ -9907,9 +10045,9 @@
9907
10045
  main: brick.children
9908
10046
  });
9909
10047
  if (slotConf.type === "bricks") {
9910
- yield _this7.mountBricks(slotConf.bricks, match, _slotId, slottedMountRoutesResult, tplStack);
10048
+ yield _this10.mountBricks(slotConf.bricks, match, _slotId, slottedMountRoutesResult, tplStack);
9911
10049
  } else if (slotConf.type === "routes") {
9912
- yield _this7.mountRoutes(slotConf.routes, _slotId, slottedMountRoutesResult);
10050
+ yield _this10.mountRoutes(slotConf.routes, _slotId, slottedMountRoutesResult);
9913
10051
  }
9914
10052
  }
9915
10053
  }
@@ -10085,11 +10223,11 @@
10085
10223
  }
10086
10224
  }
10087
10225
  preFetchMenu(data) {
10088
- var _this8 = this;
10226
+ var _this11 = this;
10089
10227
  return _asyncToGenerator__default["default"](function* () {
10090
10228
  var useMenus = brickUtils.scanAppGetMenuInAny(data);
10091
10229
  if (useMenus.length) {
10092
- yield preConstructMenus(useMenus, _this8.getCurrentContext(), _this8.kernel);
10230
+ yield preConstructMenus(useMenus, _this11.getCurrentContext(), _this11.kernel);
10093
10231
  }
10094
10232
  })();
10095
10233
  }
@@ -10276,12 +10414,13 @@
10276
10414
  }
10277
10415
 
10278
10416
  class Resolver {
10279
- constructor(kernel) {
10417
+ constructor(kernel, locationContext) {
10280
10418
  _defineProperty__default["default"](this, "cache", new Map());
10281
10419
  _defineProperty__default["default"](this, "refreshQueue", new Map());
10282
10420
  _defineProperty__default["default"](this, "definedResolves", new Map());
10283
10421
  _defineProperty__default["default"](this, "active", true);
10284
10422
  this.kernel = kernel;
10423
+ this.locationContext = locationContext;
10285
10424
  }
10286
10425
  resetRefreshQueue() {
10287
10426
  if (this.refreshQueue.size > 0) {
@@ -10305,9 +10444,15 @@
10305
10444
  var _this = this;
10306
10445
  return _asyncToGenerator__default["default"](function* () {
10307
10446
  var _brickConf$lifeCycle$, _brickConf$lifeCycle;
10308
- 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$ : []).filter(r => {
10309
- return looseCheckIf(r, context);
10310
- });
10447
+ 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 () {
10448
+ var _ref = _asyncToGenerator__default["default"](function* (r) {
10449
+ yield _this.locationContext.storyboardContextWrapper.waitForUsedContext(r.if);
10450
+ return r;
10451
+ });
10452
+ return function (_x) {
10453
+ return _ref.apply(this, arguments);
10454
+ };
10455
+ }()))).filter(r => looseCheckIf(r, context));
10311
10456
  yield Promise.all(useResolves.map(resolveConf => _this.resolveOne("brick", resolveConf, brickConf, brick, context)));
10312
10457
  if (brickConf.template) {
10313
10458
  brickConf.$$resolved = true;
@@ -10391,7 +10536,7 @@
10391
10536
  }
10392
10537
  }
10393
10538
  var actualArgs = args ? ref ? args // `args` are already computed for `defineResolves`
10394
- : context ? computeRealValue(args, context, true) : args : providerBrick.args || [];
10539
+ : context ? yield _this2.locationContext.deferComputeRealValue(args, context, true) : args : providerBrick.args || [];
10395
10540
  var cacheKey;
10396
10541
  try {
10397
10542
  // `actualArgs` may contain circular references, which makes
@@ -10454,6 +10599,7 @@
10454
10599
  yield fetchData();
10455
10600
  } catch (error) {
10456
10601
  if (isHandleRejectByTransform(onReject)) {
10602
+ yield _this2.locationContext.storyboardContextWrapper.waitForUsedContext(onReject.transform);
10457
10603
  transformProperties(props, error, context ? computeRealValue(onReject.transform, context, true) : onReject.transform);
10458
10604
  return;
10459
10605
  } else if (isHandleRejectByCatch(onReject)) {
@@ -10466,18 +10612,21 @@
10466
10612
  yield fetchData();
10467
10613
  }
10468
10614
  if (ref) {
10615
+ yield _this2.locationContext.storyboardContextWrapper.waitForUsedContext(transform);
10469
10616
  data = transformIntermediateData(data, context ? computeRealValue(transform, context, true) : transform, transformFrom, transformMapArray);
10470
10617
  }
10618
+ var transformTo = resolveConf.transform || resolveConf.name;
10619
+ yield _this2.locationContext.storyboardContextWrapper.waitForUsedContext(transformTo);
10471
10620
  transformProperties(props, data,
10472
10621
  // Also support legacy `name`
10473
- context ? computeRealValue(resolveConf.transform || resolveConf.name, context, true) : resolveConf.transform || resolveConf.name, resolveConf.transformFrom, resolveConf.transformMapArray);
10622
+ context ? computeRealValue(transformTo, context, true) : transformTo, resolveConf.transformFrom, resolveConf.transformMapArray);
10474
10623
  })();
10475
10624
  }
10476
10625
  scheduleRefreshing() {
10477
10626
  var _this3 = this;
10478
10627
  var _loop = function (providerBrick, interval) {
10479
10628
  var request = /*#__PURE__*/function () {
10480
- var _ref2 = _asyncToGenerator__default["default"](function* () {
10629
+ var _ref3 = _asyncToGenerator__default["default"](function* () {
10481
10630
  yield providerBrick.$refresh({
10482
10631
  ignoreErrors: interval.ignoreErrors,
10483
10632
  throwErrors: true,
@@ -10489,7 +10638,7 @@
10489
10638
  }
10490
10639
  });
10491
10640
  return function request() {
10492
- return _ref2.apply(this, arguments);
10641
+ return _ref3.apply(this, arguments);
10493
10642
  };
10494
10643
  }();
10495
10644
  interval.timeoutId = setTimeout(request, interval.delay);
@@ -10886,7 +11035,7 @@
10886
11035
  yield Promise.all(parallelRequests);
10887
11036
 
10888
11037
  // 如果找到匹配的 storyboard,那么根据路由匹配得到的 sub-storyboard 加载它的依赖库。
10889
- var subStoryboard = _this3.locationContext.getSubStoryboardByRoute(storyboard);
11038
+ var subStoryboard = yield _this3.locationContext.getSubStoryboardByRoute(storyboard);
10890
11039
  ({
10891
11040
  pendingTask
10892
11041
  } = yield _this3.kernel.loadDepsOfStoryboard(subStoryboard));
@@ -10958,6 +11107,7 @@
10958
11107
  try {
10959
11108
  var mergedRoutes = mergePreviewRoutes(storyboard.routes);
10960
11109
  yield locationContext.mountRoutes(mergedRoutes, undefined, mountRoutesResult);
11110
+ yield locationContext.storyboardContextWrapper.waitForAllContext();
10961
11111
  } catch (error) {
10962
11112
  // eslint-disable-next-line no-console
10963
11113
  console.error(error);
@@ -11258,6 +11408,9 @@
11258
11408
  handleMessageClose(event) {
11259
11409
  return this.locationContext.handleMessageClose(event);
11260
11410
  }
11411
+ waitForUsedContext(data) {
11412
+ return this.locationContext.storyboardContextWrapper.waitForUsedContext(data);
11413
+ }
11261
11414
  }
11262
11415
 
11263
11416
  var customProcessorRegistry = new Map();
@@ -11564,13 +11717,15 @@
11564
11717
  var getCurrentRunTimeBrick = (useBrick, tplTagName, data) => {
11565
11718
  var trackingContextList = [];
11566
11719
  var tplContextId = useBrick[symbolForTplContextId];
11720
+ var formContextId = useBrick[symbolForFormContextId];
11567
11721
  var transformOption = {
11568
11722
  // Keep lazy fields inside `useBrick` inside the `properties`.
11569
11723
  // They will be transformed by their `BrickAsComponent` later.
11570
11724
  $$lazyForUseBrick: true,
11571
11725
  trackingContextList,
11572
11726
  allowInject: true,
11573
- tplContextId
11727
+ tplContextId,
11728
+ formContextId
11574
11729
  };
11575
11730
  var properties = doTransform(data, cloneDeepWithInjectedMark(useBrick.properties) || {}, transformOption);
11576
11731
  var brick = _objectSpread__default["default"](_objectSpread__default["default"]({}, useBrick), {}, {
@@ -11580,7 +11735,8 @@
11580
11735
  });
11581
11736
  var runtimeContext = _internalApiGetCurrentContext();
11582
11737
  listenOnTrackingContext(brick, trackingContextList, _objectSpread__default["default"](_objectSpread__default["default"]({}, runtimeContext), {}, {
11583
- tplContextId
11738
+ tplContextId,
11739
+ formContextId
11584
11740
  }));
11585
11741
  return brick;
11586
11742
  };
@@ -11631,7 +11787,8 @@
11631
11787
  var requireSuspense = React.useMemo(() => {
11632
11788
  var context;
11633
11789
  if (useBrick.brick === formRenderer) {
11634
- context = useBrick.properties.formData.context;
11790
+ var formData = typeof useBrick.properties.formData === "string" ? JSON.parse(useBrick.properties.formData) : useBrick.properties.formData;
11791
+ context = formData.context;
11635
11792
  } else if (tplTagName) {
11636
11793
  context = customTemplateRegistry.get(tplTagName).state;
11637
11794
  }
@@ -11649,7 +11806,7 @@
11649
11806
  }
11650
11807
  _internalApiLoadDynamicBricksInBrickConf(useBrick).catch(handleHttpError);
11651
11808
  var brick = getCurrentRunTimeBrick(useBrick, tplTagName, data);
11652
- var expanded = useBrick.brick === formRenderer ? (requireSuspense ? AsyncExpandCustomForm : ExpandCustomForm)(useBrick.properties.formData, useBrick, false) : expandTemplateInUseBrick(useBrick, tplTagName, brick, requireSuspense);
11809
+ var expanded = useBrick.brick === formRenderer ? (requireSuspense ? AsyncExpandCustomForm : ExpandCustomForm)(typeof useBrick.properties.formData === "string" ? JSON.parse(useBrick.properties.formData) : useBrick.properties.formData, useBrick, false) : expandTemplateInUseBrick(useBrick, tplTagName, brick, requireSuspense);
11653
11810
  if (requireSuspense) {
11654
11811
  setExpandedBrickConf(yield expanded);
11655
11812
  setSuspenseReady(true);
@@ -11675,7 +11832,8 @@
11675
11832
  brick: useBrick.brick,
11676
11833
  lifeCycle: useBrick.lifeCycle
11677
11834
  }, brick, _objectSpread__default["default"](_objectSpread__default["default"]({}, _internalApiGetCurrentContext()), {}, {
11678
- tplContextId: useBrick[symbolForTplContextId]
11835
+ tplContextId: useBrick[symbolForTplContextId],
11836
+ formContextId: useBrick[symbolForFormContextId]
11679
11837
  }));
11680
11838
  }
11681
11839
  return brick;
@@ -11684,7 +11842,8 @@
11684
11842
  var _ref4 = _asyncToGenerator__default["default"](function* (event, handlers, brick) {
11685
11843
  for (var handler of [].concat(handlers)) {
11686
11844
  listenerFactory(handler, _objectSpread__default["default"](_objectSpread__default["default"]({}, _internalApiGetCurrentContext()), {}, {
11687
- tplContextId: useBrick[symbolForTplContextId]
11845
+ tplContextId: useBrick[symbolForTplContextId],
11846
+ formContextId: useBrick[symbolForFormContextId]
11688
11847
  }), brick)(event);
11689
11848
  }
11690
11849
  });
@@ -11697,6 +11856,9 @@
11697
11856
  var {
11698
11857
  [symbolForTplContextId]: tplContextId
11699
11858
  } = useBrick;
11859
+ var {
11860
+ [symbolForFormContextId]: formContextId
11861
+ } = useBrick;
11700
11862
  if (useBrick.iid) {
11701
11863
  element.dataset.iid = useBrick.iid;
11702
11864
  }
@@ -11704,7 +11866,8 @@
11704
11866
  unbindListeners(element);
11705
11867
  if (brick.events) {
11706
11868
  bindListeners(element, transformEvents(data, brick.events), _objectSpread__default["default"](_objectSpread__default["default"]({}, _internalApiGetCurrentContext()), {}, {
11707
- tplContextId
11869
+ tplContextId,
11870
+ formContextId
11708
11871
  }));
11709
11872
  }
11710
11873
  // 设置proxyEvent
@@ -11878,7 +12041,8 @@
11878
12041
  var requireSuspense = React.useMemo(() => {
11879
12042
  var context;
11880
12043
  if (useBrick.brick === formRenderer) {
11881
- context = useBrick.properties.formData.context;
12044
+ var formData = typeof useBrick.properties.formData === "string" ? JSON.parse(useBrick.properties.formData) : useBrick.properties.formData;
12045
+ context = formData.context;
11882
12046
  } else if (tplTagName) {
11883
12047
  context = customTemplateRegistry.get(tplTagName).state;
11884
12048
  }
@@ -11901,7 +12065,7 @@
11901
12065
  }
11902
12066
  _internalApiLoadDynamicBricksInBrickConf(useBrick).catch(handleHttpError);
11903
12067
  var brick = getCurrentRunTimeBrick(useBrick, tplTagName, data);
11904
- var expanded = useBrick.brick === formRenderer ? (requireSuspense ? AsyncExpandCustomForm : ExpandCustomForm)(useBrick.properties.formData, useBrick, false) : expandTemplateInUseBrick(useBrick, tplTagName, brick, requireSuspense);
12068
+ var expanded = useBrick.brick === formRenderer ? (requireSuspense ? AsyncExpandCustomForm : ExpandCustomForm)(typeof useBrick.properties.formData === "string" ? JSON.parse(useBrick.properties.formData) : useBrick.properties.formData, useBrick, false) : expandTemplateInUseBrick(useBrick, tplTagName, brick, requireSuspense);
11905
12069
  if (requireSuspense) {
11906
12070
  setExpandedBrickConf(yield expanded);
11907
12071
  setSuspenseReady(true);