@next-core/brick-kit 2.160.0 → 2.160.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1731,6 +1731,7 @@
1731
1731
  _defineProperty__default["default"](this, "data", new Map());
1732
1732
  _defineProperty__default["default"](this, "tplContextId", void 0);
1733
1733
  _defineProperty__default["default"](this, "formContextId", void 0);
1734
+ _defineProperty__default["default"](this, "pendingStack", []);
1734
1735
  this.tplContextId = tplContextId;
1735
1736
  this.formContextId = formContextId;
1736
1737
  }
@@ -1832,15 +1833,57 @@
1832
1833
  detail: item.value
1833
1834
  }));
1834
1835
  }
1835
- define(contextConfs, coreContext, brick) {
1836
+ waitForUsedContext(data) {
1836
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;
1837
1880
  return _asyncToGenerator__default["default"](function* () {
1838
1881
  if (Array.isArray(contextConfs)) {
1839
1882
  var {
1840
1883
  mergedContext,
1841
1884
  keyword
1842
- } = _this.getResolveOptions(coreContext);
1843
- 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);
1844
1887
  }
1845
1888
  })();
1846
1889
  }
@@ -1892,6 +1935,7 @@
1892
1935
  }
1893
1936
  function _resolveNormalStoryboardContext() {
1894
1937
  _resolveNormalStoryboardContext = _asyncToGenerator__default["default"](function* (contextConf, mergedContext, storyboardContextWrapper, brick) {
1938
+ yield storyboardContextWrapper.waitForUsedContext(contextConf.if);
1895
1939
  if (!looseCheckIf(contextConf, mergedContext)) {
1896
1940
  return false;
1897
1941
  }
@@ -1901,6 +1945,7 @@
1901
1945
  var isLazyResolve = false;
1902
1946
  if (value === undefined) {
1903
1947
  if (contextConf.resolve) {
1948
+ yield storyboardContextWrapper.waitForUsedContext(contextConf.resolve.if);
1904
1949
  if (looseCheckIf(contextConf.resolve, mergedContext)) {
1905
1950
  load = /*#__PURE__*/function () {
1906
1951
  var _ref = _asyncToGenerator__default["default"](function* (options) {
@@ -1924,6 +1969,7 @@
1924
1969
  }
1925
1970
  }
1926
1971
  if ((!load || isLazyResolve) && contextConf.value !== undefined) {
1972
+ yield storyboardContextWrapper.waitForUsedContext(contextConf.value);
1927
1973
  // If the context has no resolve, just use its `value`.
1928
1974
  // Or if the resolve is ignored or lazy, use its `value` as a fallback.
1929
1975
  value = computeRealValue(contextConf.value, mergedContext, true);
@@ -2069,7 +2115,7 @@
2069
2115
  _defineProperty__default["default"](this, "formState", void 0);
2070
2116
  _defineProperty__default["default"](this, "id", _.uniqueId("form-ctx-"));
2071
2117
  FormContextMap.set(this.id, this);
2072
- this.formState = new StoryboardContextWrapper("", this.id);
2118
+ this.formState = new StoryboardContextWrapper(undefined, this.id);
2073
2119
  }
2074
2120
  }
2075
2121
  function getCustomFormContext(formContextId) {
@@ -2820,8 +2866,8 @@
2820
2866
  (function () {
2821
2867
  var menuI18nNamespace = getI18nNamespace("menu", "".concat(menu.menuId, "~").concat(menu.app[0].appId, "+").concat(menu.instanceId));
2822
2868
  // Support any language in `meta.i18n`.
2823
- Object.entries(menu.i18n).forEach(_ref3 => {
2824
- var [lang, resources] = _ref3;
2869
+ Object.entries(menu.i18n).forEach(_ref4 => {
2870
+ var [lang, resources] = _ref4;
2825
2871
  i18next__default["default"].addResourceBundle(lang, menuI18nNamespace, resources);
2826
2872
  });
2827
2873
  menuWithI18n.set(menu, menuI18nNamespace);
@@ -2921,8 +2967,8 @@
2921
2967
  }
2922
2968
  collectAppsRequireI18nFulfilled(items, context.app.id, appsRequireI18nFulfilled);
2923
2969
  yield kernel.fulfilStoryboardI18n([...appsRequireI18nFulfilled]);
2924
- var menuData = _objectSpread__default["default"](_objectSpread__default["default"]({}, computeRealValueWithOverrideApp(restMenuData, rootAppId, context, kernel)), {}, {
2925
- 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)
2926
2972
  });
2927
2973
  return {
2928
2974
  title: yield processMenuTitle(menuData),
@@ -2970,17 +3016,22 @@
2970
3016
  collect(items);
2971
3017
  }
2972
3018
  function computeMenuItemsWithOverrideApp(items, context, kernel) {
2973
- return items.map(_ref2 => {
2974
- var {
2975
- children
2976
- } = _ref2,
2977
- rest = _objectWithoutProperties__default["default"](_ref2, _excluded2$2);
2978
- return _objectSpread__default["default"](_objectSpread__default["default"]({}, computeRealValueWithOverrideApp(rest, rest[symbolAppId], context, kernel)), {}, {
2979
- 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
+ });
2980
3028
  });
2981
- });
3029
+ return function (_x20) {
3030
+ return _ref3.apply(this, arguments);
3031
+ };
3032
+ }()));
2982
3033
  }
2983
- function processMenuTitle(_x20) {
3034
+ function processMenuTitle(_x21) {
2984
3035
  return _processMenuTitle.apply(this, arguments);
2985
3036
  }
2986
3037
  function _processMenuTitle() {
@@ -3059,25 +3110,32 @@
3059
3110
  }
3060
3111
  return false;
3061
3112
  }
3062
- function computeRealValueWithOverrideApp(data, overrideAppId, context, kernel) {
3063
- var newContext = context;
3064
- if (overrideAppId !== context.app.id && attemptToVisit(data, ["APP", "I18N"])) {
3065
- if (window.STANDALONE_MICRO_APPS) {
3066
- newContext = _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
3067
- overrideApp: data[symbolOverrideApp],
3068
- appendI18nNamespace: data[symbolMenuI18nNamespace]
3069
- });
3070
- } else {
3071
- var storyboard = kernel.bootstrapData.storyboards.find(story => story.app.id === overrideAppId);
3072
- newContext = _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
3073
- overrideApp: storyboard === null || storyboard === void 0 ? void 0 : storyboard.app,
3074
- appendI18nNamespace: data[symbolMenuI18nNamespace]
3075
- });
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
+ }
3076
3132
  }
3077
- }
3078
- return computeRealValue(data, newContext, true, {
3079
- ignoreSymbols: true
3133
+ yield kernel.router.waitForUsedContext(data);
3134
+ return computeRealValue(data, newContext, true, {
3135
+ ignoreSymbols: true
3136
+ });
3080
3137
  });
3138
+ return _computeRealValueWithOverrideApp.apply(this, arguments);
3081
3139
  }
3082
3140
 
3083
3141
  var lazyBrickRegistry = new Map();
@@ -7634,17 +7692,21 @@
7634
7692
  }
7635
7693
  return lowLevelExpandCustomTemplate(template, brickConf, proxyBrick, context, tplContext);
7636
7694
  }
7637
- function asyncExpandCustomTemplate(_x, _x2, _x3) {
7695
+ function asyncExpandCustomTemplate(_x, _x2, _x3, _x4) {
7638
7696
  return _asyncExpandCustomTemplate.apply(this, arguments);
7639
7697
  }
7640
7698
  function _asyncExpandCustomTemplate() {
7641
- _asyncExpandCustomTemplate = _asyncToGenerator__default["default"](function* (brickConf, proxyBrick, context) {
7699
+ _asyncExpandCustomTemplate = _asyncToGenerator__default["default"](function* (brickConf, proxyBrick, context, locationContext) {
7642
7700
  var tplContext = new CustomTemplateContext(proxyBrick);
7643
7701
  var template = customTemplateRegistry.get(brickConf.brick);
7644
7702
  if (template.contracts) {
7645
7703
  collectWidgetContract(template.contracts);
7646
7704
  }
7647
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
+ }
7648
7710
  yield tplContext.state.define(template.state, context, proxyBrick);
7649
7711
  }
7650
7712
  return lowLevelExpandCustomTemplate(template, brickConf, proxyBrick, context, tplContext);
@@ -8991,50 +9053,85 @@
8991
9053
  return conf.type === "routes";
8992
9054
  }
8993
9055
 
8994
- function getSubStoryboardByRoute(storyboard, matcher) {
8995
- function getSubRoutes(routes) {
8996
- return matcher(routes).map(getSubRoute);
8997
- }
8998
- function getSubRoute(route) {
8999
- if (route.type === "routes") {
9000
- return _objectSpread__default["default"](_objectSpread__default["default"]({}, route), {}, {
9001
- 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));
9002
9067
  });
9068
+ return _getSubRoutes.apply(this, arguments);
9003
9069
  }
9004
- return _objectSpread__default["default"](_objectSpread__default["default"]({}, route), {}, {
9005
- bricks: getSubBricks(route.bricks)
9006
- });
9007
- }
9008
- function getSubBricks(bricks) {
9009
- if (Array.isArray(bricks)) {
9010
- return bricks.map(brickConf => getSubBrick(brickConf));
9011
- }
9012
- return bricks;
9013
- }
9014
- function getSubBrick(brickConf) {
9015
- if (brickUtils.isObject(brickConf.slots)) {
9016
- return _objectSpread__default["default"](_objectSpread__default["default"]({}, brickConf), {}, {
9017
- slots: Object.fromEntries(Object.entries(brickConf.slots).map(_ref => {
9018
- var [slotId, slotConf] = _ref;
9019
- if (slotConf.type === "routes") {
9020
- return [slotId, _objectSpread__default["default"](_objectSpread__default["default"]({}, slotConf), {}, {
9021
- routes: getSubRoutes(slotConf.routes)
9022
- })];
9023
- } /* istanbul ignore else: should never reach */else if (slotConf.type === "bricks") {
9024
- return [slotId, _objectSpread__default["default"](_objectSpread__default["default"]({}, slotConf), {}, {
9025
- bricks: getSubBricks(slotConf.bricks)
9026
- })];
9027
- }
9028
- /* istanbul ignore next: should never reach */
9029
- return [slotId, slotConf];
9030
- }))
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
+ });
9031
9083
  });
9084
+ return _getSubRoute.apply(this, arguments);
9032
9085
  }
9033
- return brickConf;
9034
- }
9035
- return _objectSpread__default["default"](_objectSpread__default["default"]({}, storyboard), {}, {
9036
- 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
+ });
9037
9133
  });
9134
+ return _getSubStoryboardByRoute.apply(this, arguments);
9038
9135
  }
9039
9136
 
9040
9137
  function listenOnTrackingContext(brick, trackingContextList, context) {
@@ -9085,14 +9182,18 @@
9085
9182
  }
9086
9183
  return getFinalStoryBoard(formData, brickConf, isPreview, formContext);
9087
9184
  }
9088
- function AsyncExpandCustomForm(_x, _x2, _x3, _x4) {
9185
+ function AsyncExpandCustomForm(_x, _x2, _x3, _x4, _x5) {
9089
9186
  return _AsyncExpandCustomForm.apply(this, arguments);
9090
9187
  }
9091
9188
  function _AsyncExpandCustomForm() {
9092
- _AsyncExpandCustomForm = _asyncToGenerator__default["default"](function* (formData, brickConf, isPreview, context) {
9189
+ _AsyncExpandCustomForm = _asyncToGenerator__default["default"](function* (formData, brickConf, isPreview, context, locationContext) {
9093
9190
  var formContext = new CustomFormContext();
9094
9191
  formData = initFormContext(formData, brickConf, isPreview);
9095
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
+ }
9096
9197
  yield formContext.formState.define(formData.context, _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
9097
9198
  formContextId: formContext.id
9098
9199
  }), {});
@@ -9478,7 +9579,7 @@
9478
9579
  _defineProperty__default["default"](this, "observersList", []);
9479
9580
  this.kernel = kernel;
9480
9581
  this.location = location;
9481
- this.resolver = new Resolver(kernel);
9582
+ this.resolver = new Resolver(kernel, this);
9482
9583
  this.query = new URLSearchParams(location.search);
9483
9584
  this.messageDispatcher = getMessageDispatcher();
9484
9585
  }
@@ -9516,60 +9617,79 @@
9516
9617
  match: this.currentMatch
9517
9618
  });
9518
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
+ }
9519
9628
  matchRoutes(routes, app) {
9520
- var _this = this;
9521
- var _loop = function (route) {
9522
- var computedPath = brickUtils.computeRealRoutePath(route.path, app);
9523
- if ([].concat(computedPath).includes(undefined)) {
9524
- // eslint-disable-next-line no-console
9525
- console.error("Invalid route with invalid path:", route);
9526
- return {
9527
- v: "missed"
9528
- };
9529
- }
9530
- var match = brickUtils.matchPath(_this.location.pathname, {
9531
- path: computedPath,
9532
- exact: route.exact,
9533
- checkIf: context => looseCheckIf(route, context),
9534
- getContext: match => _this.getContext({
9535
- match
9536
- })
9537
- });
9538
- if (match !== null) {
9539
- if (app.noAuthGuard || route.public || isLoggedIn()) {
9540
- _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);
9541
9636
  return {
9542
- v: {
9543
- match,
9544
- route
9545
- }
9637
+ v: "missed"
9546
9638
  };
9547
9639
  }
9548
- return {
9549
- v: "unauthenticated"
9550
- };
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;
9551
9667
  }
9552
- };
9553
- for (var route of routes) {
9554
- var _ret = _loop(route);
9555
- if (typeof _ret === "object") return _ret.v;
9556
- }
9557
- return "missed";
9668
+ return "missed";
9669
+ })();
9558
9670
  }
9559
9671
  matchStoryboard(storyboards) {
9560
9672
  return matchStoryboard(storyboards, this.location.pathname);
9561
9673
  }
9562
9674
  getSubStoryboardByRoute(storyboard) {
9563
- var matcher = routes => {
9564
- var matched = this.matchRoutes(routes, storyboard.app);
9565
- return brickUtils.isObject(matched) ? [matched.route] : [];
9566
- };
9567
- 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
+ })();
9568
9688
  }
9569
9689
  mountRoutes(routes, slotId, mountRoutesResult) {
9570
- var _this2 = this;
9690
+ var _this4 = this;
9571
9691
  return _asyncToGenerator__default["default"](function* () {
9572
- var matched = _this2.matchRoutes(routes, _this2.kernel.nextApp);
9692
+ var matched = yield _this4.matchRoutes(routes, _this4.kernel.nextApp);
9573
9693
  var redirect;
9574
9694
  var redirectConf = {};
9575
9695
  var context;
@@ -9583,19 +9703,26 @@
9583
9703
  default:
9584
9704
  mountRoutesResult.route = route = matched.route;
9585
9705
  if (route.segues) {
9586
- Object.assign(_this2.segues, route.segues);
9706
+ Object.assign(_this4.segues, route.segues);
9587
9707
  }
9588
9708
  if (route.hybrid) {
9589
9709
  mountRoutesResult.flags.hybrid = true;
9590
9710
  }
9591
- context = _this2.getContext({
9711
+ context = _this4.getContext({
9592
9712
  match: matched.match
9593
9713
  });
9594
- _this2.resolver.defineResolves(route.defineResolves, context);
9595
- yield _this2.mountProviders(route.providers, matched.match, slotId, mountRoutesResult);
9596
- yield _this2.storyboardContextWrapper.define(route.context, context);
9597
- yield _this2.preCheckPermissions(route, context);
9598
- 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);
9599
9726
  if (redirect) {
9600
9727
  if (typeof redirect === "string") {
9601
9728
  // Directly redirect.
@@ -9605,7 +9732,7 @@
9605
9732
  break;
9606
9733
  } else {
9607
9734
  // Resolvable redirect.
9608
- yield _this2.resolver.resolveOne("reference", redirect, redirectConf);
9735
+ yield _this4.resolver.resolveOne("reference", redirect, redirectConf);
9609
9736
  if (redirectConf.redirect) {
9610
9737
  mountRoutesResult.flags.redirect = {
9611
9738
  path: redirectConf.redirect
@@ -9614,20 +9741,20 @@
9614
9741
  }
9615
9742
  }
9616
9743
  }
9617
- yield _this2.mountMenu(route.menu, matched.match, mountRoutesResult);
9744
+ yield _this4.mountMenu(route.menu, matched.match, mountRoutesResult);
9618
9745
  if (route.documentId) {
9619
9746
  mountRoutesResult.appBar.documentId = route.documentId;
9620
9747
  }
9621
9748
  if (isRouteConfOfRoutes(route) && Array.isArray(route.routes)) {
9622
- yield _this2.preFetchMenu(route.context);
9623
- yield _this2.mountRoutes(route.routes, slotId, mountRoutesResult);
9749
+ yield _this4.preFetchMenu(route.context);
9750
+ yield _this4.mountRoutes(route.routes, slotId, mountRoutesResult);
9624
9751
  } else if (isRouteConfOfBricks(route) && Array.isArray(route.bricks)) {
9625
- yield _this2.preFetchMenu(route);
9626
- yield _this2.mountBricks(route.bricks, matched.match, slotId, mountRoutesResult);
9752
+ yield _this4.preFetchMenu(route);
9753
+ yield _this4.mountBricks(route.bricks, matched.match, slotId, mountRoutesResult);
9627
9754
 
9628
9755
  // analytics data (page_view event)
9629
9756
  if (route.analyticsData) {
9630
- mountRoutesResult.analyticsData = computeRealValue(route.analyticsData, context, true);
9757
+ mountRoutesResult.analyticsData = yield _this4.deferComputeRealValue(route.analyticsData, context, true);
9631
9758
  }
9632
9759
  }
9633
9760
  }
@@ -9635,7 +9762,7 @@
9635
9762
  })();
9636
9763
  }
9637
9764
  mountMenu(menuConf, match, mountRoutesResult) {
9638
- var _this3 = this;
9765
+ var _this5 = this;
9639
9766
  return _asyncToGenerator__default["default"](function* () {
9640
9767
  if (menuConf === false) {
9641
9768
  // `route.menu` 设置为 `false` 表示不显示顶栏和侧栏。
@@ -9647,7 +9774,7 @@
9647
9774
  if (!menuConf) {
9648
9775
  return;
9649
9776
  }
9650
- var context = _this3.getContext({
9777
+ var context = _this5.getContext({
9651
9778
  match
9652
9779
  });
9653
9780
  if (menuConf.type === "brick") {
@@ -9657,6 +9784,7 @@
9657
9784
  // 那么可以将菜单配置指定为一个构件,这个构件会被装载到背景容器中(不会在界面中显示),
9658
9785
  // 应该在这个构件的 `connectedCallback` 中执行相关菜单设置,
9659
9786
  // 例如 `getRuntime().menuBar.setAppMenu(...)`。
9787
+ yield _this5.storyboardContextWrapper.waitForUsedContext(menuConf.properties);
9660
9788
  var brick = {
9661
9789
  type: menuConf.brick,
9662
9790
  properties: computeRealProperties(menuConf.properties, context, menuConf.injectDeep !== false),
@@ -9664,16 +9792,16 @@
9664
9792
  context,
9665
9793
  children: []
9666
9794
  };
9667
- _this3.registerHandlersFromLifeCycle(menuConf.lifeCycle, brick, match);
9795
+ _this5.registerHandlersFromLifeCycle(menuConf.lifeCycle, brick, match);
9668
9796
 
9669
9797
  // Then, resolve the brick.
9670
- yield _this3.resolver.resolve(menuConf, brick, context);
9798
+ yield _this5.resolver.resolve(menuConf, brick, context);
9671
9799
  mountRoutesResult.menuInBg.push(brick);
9672
9800
  return;
9673
9801
  }
9674
9802
  var injectDeep = menuConf.injectDeep;
9675
9803
  if (menuConf.type === "resolve") {
9676
- yield _this3.resolver.resolveOne("reference", _objectSpread__default["default"]({
9804
+ yield _this5.resolver.resolveOne("reference", _objectSpread__default["default"]({
9677
9805
  transformMapArray: false
9678
9806
  }, menuConf.resolve), menuConf, null, context);
9679
9807
  injectDeep = false;
@@ -9681,7 +9809,7 @@
9681
9809
 
9682
9810
  // 静态菜单配置,仅在有值时才设置,这样可以让菜单设置也具有按路由层级覆盖的能力。
9683
9811
  var otherMenuConf = _.omit(menuConf, ["injectDeep", "type"]);
9684
- var injectedMenuConf = injectDeep !== false ? computeRealValue(otherMenuConf, context, true) : otherMenuConf;
9812
+ var injectedMenuConf = injectDeep !== false ? yield _this5.deferComputeRealValue(otherMenuConf, context, true) : otherMenuConf;
9685
9813
  var {
9686
9814
  sidebarMenu,
9687
9815
  pageTitle,
@@ -9713,11 +9841,11 @@
9713
9841
  })();
9714
9842
  }
9715
9843
  mountProviders(providers, match, slotId, mountRoutesResult) {
9716
- var _this4 = this;
9844
+ var _this6 = this;
9717
9845
  return _asyncToGenerator__default["default"](function* () {
9718
9846
  if (Array.isArray(providers)) {
9719
9847
  for (var providerConf of providers) {
9720
- 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" ? {
9721
9849
  brick: providerConf
9722
9850
  } : providerConf), {}, {
9723
9851
  bg: true,
@@ -9728,11 +9856,11 @@
9728
9856
  })();
9729
9857
  }
9730
9858
  mountBricks(bricks, match, slotId, mountRoutesResult, tplStack) {
9731
- var _this5 = this;
9859
+ var _this7 = this;
9732
9860
  return _asyncToGenerator__default["default"](function* () {
9733
9861
  for (var brickConf of bricks) {
9734
9862
  try {
9735
- yield _this5.mountBrick(brickConf, match, slotId, mountRoutesResult, tplStack && new Map(tplStack));
9863
+ yield _this7.mountBrick(brickConf, match, slotId, mountRoutesResult, tplStack && new Map(tplStack));
9736
9864
  } catch (error) {
9737
9865
  if (error instanceof ResolveRequestError) {
9738
9866
  var errorMessage = httpErrorToString(error.rawError);
@@ -9760,57 +9888,59 @@
9760
9888
  })();
9761
9889
  }
9762
9890
  checkResolvableIf(ifContainer, context) {
9763
- var _this6 = this;
9891
+ var _this8 = this;
9764
9892
  return _asyncToGenerator__default["default"](function* () {
9893
+ yield _this8.storyboardContextWrapper.waitForUsedContext(ifContainer.if);
9765
9894
  if (brickUtils.isObject(ifContainer.if)) {
9766
9895
  var ifChecked = computeRealValue(ifContainer.if, context, true);
9767
9896
  var ifConf = {};
9768
- yield _this6.resolver.resolveOne("reference", ifChecked, ifConf);
9897
+ yield _this8.resolver.resolveOne("reference", ifChecked, ifConf);
9769
9898
  return !brickUtils.hasOwnProperty(ifConf, "if") || !!ifConf.if;
9770
9899
  }
9771
9900
  return looseCheckIf(ifContainer, context);
9772
9901
  })();
9773
9902
  }
9774
9903
  preCheckPermissions(container, context) {
9904
+ var _this9 = this;
9775
9905
  return _asyncToGenerator__default["default"](function* () {
9776
9906
  if (isLoggedIn() && !getAuth().isAdmin && container.permissionsPreCheck && Array.isArray(container.permissionsPreCheck)) {
9777
- var usedActions = computeRealValue(container.permissionsPreCheck, context, true);
9907
+ var usedActions = yield _this9.deferComputeRealValue(container.permissionsPreCheck, context, true);
9778
9908
  yield validatePermissions(usedActions);
9779
9909
  }
9780
9910
  })();
9781
9911
  }
9782
9912
  mountBrick(brickConf, match, slotId, mountRoutesResult) {
9783
- var _arguments = arguments,
9784
- _this7 = this;
9913
+ var _arguments2 = arguments,
9914
+ _this10 = this;
9785
9915
  return _asyncToGenerator__default["default"](function* () {
9786
- var _this7$kernel$nextApp, _brickConf$lifeCycle, _brick$lifeCycle;
9787
- 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();
9788
9918
  var tplContextId = brickConf[symbolForTplContextId];
9789
9919
  var formContextId = brickConf[symbolForFormContextId];
9790
- var context = _this7.getContext({
9920
+ var context = _this10.getContext({
9791
9921
  match,
9792
9922
  tplContextId,
9793
9923
  formContextId
9794
9924
  });
9795
9925
 
9796
9926
  // First, check whether the brick should be rendered.
9797
- if (!(yield _this7.checkResolvableIf(brickConf, context))) {
9927
+ if (!(yield _this10.checkResolvableIf(brickConf, context))) {
9798
9928
  return;
9799
9929
  }
9800
9930
 
9801
9931
  // Then, resolve the template to a brick.
9802
9932
  if (brickConf.template) {
9803
- yield _this7.resolver.resolve(brickConf, null, context);
9933
+ yield _this10.resolver.resolve(brickConf, null, context);
9804
9934
  }
9805
9935
 
9806
9936
  // Check `if` again for dynamic loaded templates.
9807
- if (!(yield _this7.checkResolvableIf(brickConf, context))) {
9937
+ if (!(yield _this10.checkResolvableIf(brickConf, context))) {
9808
9938
  return;
9809
9939
  }
9810
9940
 
9811
9941
  // If it's a custom template, `tplTagName` is the tag name of the template.
9812
9942
  // Otherwise, `tplTagName` is false.
9813
- 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);
9814
9944
  if (tplTagName) {
9815
9945
  var _tplStack$get;
9816
9946
  var tplCount = (_tplStack$get = tplStack.get(tplTagName)) !== null && _tplStack$get !== void 0 ? _tplStack$get : 0;
@@ -9823,9 +9953,16 @@
9823
9953
  brickConf.properties.formData = JSON.stringify(brickConf.properties.formData);
9824
9954
  }
9825
9955
  var brick = {};
9826
- yield _this7.storyboardContextWrapper.define(brickConf.context, context, brick);
9827
- 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);
9828
9964
  var trackingContextList = [];
9965
+ yield _this10.storyboardContextWrapper.waitForUsedContext(brickConf.properties);
9829
9966
  Object.assign(brick, _objectSpread__default["default"]({
9830
9967
  type: tplTagName || brickConf.brick,
9831
9968
  properties: computeRealProperties(brickConf.properties, context, brickConf.injectDeep !== false, trackingContextList),
@@ -9843,8 +9980,8 @@
9843
9980
  }
9844
9981
  } : {}));
9845
9982
  if (brickConf[symbolForComputedPropsFromProxy]) {
9846
- Object.entries(brickConf[symbolForComputedPropsFromProxy]).forEach(_ref2 => {
9847
- var [propName, propValue] = _ref2;
9983
+ Object.entries(brickConf[symbolForComputedPropsFromProxy]).forEach(_ref3 => {
9984
+ var [propName, propValue] = _ref3;
9848
9985
  _.set(brick.properties, propName, propValue);
9849
9986
  });
9850
9987
  }
@@ -9852,36 +9989,36 @@
9852
9989
  if (brick.refForProxy) {
9853
9990
  brick.refForProxy.brick = brick;
9854
9991
  }
9855
- _this7.registerHandlersFromLifeCycle(brickConf.lifeCycle, brick, match, tplContextId);
9992
+ _this10.registerHandlersFromLifeCycle(brickConf.lifeCycle, brick, match, tplContextId);
9856
9993
  if ((_brick$lifeCycle = brick.lifeCycle) !== null && _brick$lifeCycle !== void 0 && _brick$lifeCycle.onScrollIntoView) {
9857
- _this7.brickBindObserver(brick);
9994
+ _this10.brickBindObserver(brick);
9858
9995
  }
9859
9996
 
9860
9997
  // Then, resolve the brick.
9861
- yield _this7.resolver.resolve(brickConf, brick, context);
9998
+ yield _this10.resolver.resolve(brickConf, brick, context);
9862
9999
  var expandedBrickConf = brickConf;
9863
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);
9864
- 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)) {
9865
10002
  var _customTemplateRegist;
9866
- 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);
9867
10004
  expandedBrickConf = yield asyncExpandCustomTemplate(_objectSpread__default["default"](_objectSpread__default["default"]({}, brickConf), {}, {
9868
10005
  brick: tplTagName,
9869
10006
  // Properties are computed for custom templates.
9870
10007
  properties: brick.properties
9871
- }), brick, context);
10008
+ }), brick, context, _this10);
9872
10009
 
9873
10010
  // Try to load deps for dynamic added bricks.
9874
- yield _this7.kernel.loadDynamicBricksInBrickConf(expandedBrickConf);
10011
+ yield _this10.kernel.loadDynamicBricksInBrickConf(expandedBrickConf);
9875
10012
  }
9876
10013
  if (brick.type === formRenderer) {
9877
10014
  var formData = typeof brick.properties.formData === "string" ? JSON.parse(brick.properties.formData) : brick.properties.formData;
9878
- expandedBrickConf = yield AsyncExpandCustomForm(formData, brickConf, brick.properties.isPreview, context);
9879
- yield _this7.kernel.loadDynamicBricksInBrickConf(expandedBrickConf);
10015
+ expandedBrickConf = yield AsyncExpandCustomForm(formData, brickConf, brick.properties.isPreview, context, _this10);
10016
+ yield _this10.kernel.loadDynamicBricksInBrickConf(expandedBrickConf);
9880
10017
  }
9881
10018
  if (expandedBrickConf.exports) {
9882
10019
  for (var [prop, ctxName] of Object.entries(expandedBrickConf.exports)) {
9883
10020
  if (typeof ctxName === "string" && ctxName.startsWith("CTX.")) {
9884
- _this7.storyboardContextWrapper.set(ctxName.substring(4), {
10021
+ _this10.storyboardContextWrapper.set(ctxName.substring(4), {
9885
10022
  type: "brick-property",
9886
10023
  brick,
9887
10024
  prop
@@ -9892,8 +10029,8 @@
9892
10029
  if (expandedBrickConf.bg) {
9893
10030
  // A bg brick has no slotId.
9894
10031
  brick.slotId = undefined;
9895
- yield _this7.kernel.loadDynamicBricks([brick.type]);
9896
- appendBrick(brick, _this7.kernel.mountPoints.bg);
10032
+ yield _this10.kernel.loadDynamicBricks([brick.type]);
10033
+ appendBrick(brick, _this10.kernel.mountPoints.bg);
9897
10034
  } else {
9898
10035
  if (expandedBrickConf.portal) {
9899
10036
  // A portal brick has no slotId.
@@ -9908,9 +10045,9 @@
9908
10045
  main: brick.children
9909
10046
  });
9910
10047
  if (slotConf.type === "bricks") {
9911
- yield _this7.mountBricks(slotConf.bricks, match, _slotId, slottedMountRoutesResult, tplStack);
10048
+ yield _this10.mountBricks(slotConf.bricks, match, _slotId, slottedMountRoutesResult, tplStack);
9912
10049
  } else if (slotConf.type === "routes") {
9913
- yield _this7.mountRoutes(slotConf.routes, _slotId, slottedMountRoutesResult);
10050
+ yield _this10.mountRoutes(slotConf.routes, _slotId, slottedMountRoutesResult);
9914
10051
  }
9915
10052
  }
9916
10053
  }
@@ -10086,11 +10223,11 @@
10086
10223
  }
10087
10224
  }
10088
10225
  preFetchMenu(data) {
10089
- var _this8 = this;
10226
+ var _this11 = this;
10090
10227
  return _asyncToGenerator__default["default"](function* () {
10091
10228
  var useMenus = brickUtils.scanAppGetMenuInAny(data);
10092
10229
  if (useMenus.length) {
10093
- yield preConstructMenus(useMenus, _this8.getCurrentContext(), _this8.kernel);
10230
+ yield preConstructMenus(useMenus, _this11.getCurrentContext(), _this11.kernel);
10094
10231
  }
10095
10232
  })();
10096
10233
  }
@@ -10277,12 +10414,13 @@
10277
10414
  }
10278
10415
 
10279
10416
  class Resolver {
10280
- constructor(kernel) {
10417
+ constructor(kernel, locationContext) {
10281
10418
  _defineProperty__default["default"](this, "cache", new Map());
10282
10419
  _defineProperty__default["default"](this, "refreshQueue", new Map());
10283
10420
  _defineProperty__default["default"](this, "definedResolves", new Map());
10284
10421
  _defineProperty__default["default"](this, "active", true);
10285
10422
  this.kernel = kernel;
10423
+ this.locationContext = locationContext;
10286
10424
  }
10287
10425
  resetRefreshQueue() {
10288
10426
  if (this.refreshQueue.size > 0) {
@@ -10306,9 +10444,15 @@
10306
10444
  var _this = this;
10307
10445
  return _asyncToGenerator__default["default"](function* () {
10308
10446
  var _brickConf$lifeCycle$, _brickConf$lifeCycle;
10309
- 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 => {
10310
- return looseCheckIf(r, context);
10311
- });
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));
10312
10456
  yield Promise.all(useResolves.map(resolveConf => _this.resolveOne("brick", resolveConf, brickConf, brick, context)));
10313
10457
  if (brickConf.template) {
10314
10458
  brickConf.$$resolved = true;
@@ -10392,7 +10536,7 @@
10392
10536
  }
10393
10537
  }
10394
10538
  var actualArgs = args ? ref ? args // `args` are already computed for `defineResolves`
10395
- : context ? computeRealValue(args, context, true) : args : providerBrick.args || [];
10539
+ : context ? yield _this2.locationContext.deferComputeRealValue(args, context, true) : args : providerBrick.args || [];
10396
10540
  var cacheKey;
10397
10541
  try {
10398
10542
  // `actualArgs` may contain circular references, which makes
@@ -10455,6 +10599,7 @@
10455
10599
  yield fetchData();
10456
10600
  } catch (error) {
10457
10601
  if (isHandleRejectByTransform(onReject)) {
10602
+ yield _this2.locationContext.storyboardContextWrapper.waitForUsedContext(onReject.transform);
10458
10603
  transformProperties(props, error, context ? computeRealValue(onReject.transform, context, true) : onReject.transform);
10459
10604
  return;
10460
10605
  } else if (isHandleRejectByCatch(onReject)) {
@@ -10467,18 +10612,21 @@
10467
10612
  yield fetchData();
10468
10613
  }
10469
10614
  if (ref) {
10615
+ yield _this2.locationContext.storyboardContextWrapper.waitForUsedContext(transform);
10470
10616
  data = transformIntermediateData(data, context ? computeRealValue(transform, context, true) : transform, transformFrom, transformMapArray);
10471
10617
  }
10618
+ var transformTo = resolveConf.transform || resolveConf.name;
10619
+ yield _this2.locationContext.storyboardContextWrapper.waitForUsedContext(transformTo);
10472
10620
  transformProperties(props, data,
10473
10621
  // Also support legacy `name`
10474
- 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);
10475
10623
  })();
10476
10624
  }
10477
10625
  scheduleRefreshing() {
10478
10626
  var _this3 = this;
10479
10627
  var _loop = function (providerBrick, interval) {
10480
10628
  var request = /*#__PURE__*/function () {
10481
- var _ref2 = _asyncToGenerator__default["default"](function* () {
10629
+ var _ref3 = _asyncToGenerator__default["default"](function* () {
10482
10630
  yield providerBrick.$refresh({
10483
10631
  ignoreErrors: interval.ignoreErrors,
10484
10632
  throwErrors: true,
@@ -10490,7 +10638,7 @@
10490
10638
  }
10491
10639
  });
10492
10640
  return function request() {
10493
- return _ref2.apply(this, arguments);
10641
+ return _ref3.apply(this, arguments);
10494
10642
  };
10495
10643
  }();
10496
10644
  interval.timeoutId = setTimeout(request, interval.delay);
@@ -10887,7 +11035,7 @@
10887
11035
  yield Promise.all(parallelRequests);
10888
11036
 
10889
11037
  // 如果找到匹配的 storyboard,那么根据路由匹配得到的 sub-storyboard 加载它的依赖库。
10890
- var subStoryboard = _this3.locationContext.getSubStoryboardByRoute(storyboard);
11038
+ var subStoryboard = yield _this3.locationContext.getSubStoryboardByRoute(storyboard);
10891
11039
  ({
10892
11040
  pendingTask
10893
11041
  } = yield _this3.kernel.loadDepsOfStoryboard(subStoryboard));
@@ -10959,6 +11107,7 @@
10959
11107
  try {
10960
11108
  var mergedRoutes = mergePreviewRoutes(storyboard.routes);
10961
11109
  yield locationContext.mountRoutes(mergedRoutes, undefined, mountRoutesResult);
11110
+ yield locationContext.storyboardContextWrapper.waitForAllContext();
10962
11111
  } catch (error) {
10963
11112
  // eslint-disable-next-line no-console
10964
11113
  console.error(error);
@@ -11259,6 +11408,9 @@
11259
11408
  handleMessageClose(event) {
11260
11409
  return this.locationContext.handleMessageClose(event);
11261
11410
  }
11411
+ waitForUsedContext(data) {
11412
+ return this.locationContext.storyboardContextWrapper.waitForUsedContext(data);
11413
+ }
11262
11414
  }
11263
11415
 
11264
11416
  var customProcessorRegistry = new Map();