@next-core/brick-kit 2.111.2 → 2.113.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -2664,6 +2664,7 @@ var symbolAppId = Symbol("appId");
2664
2664
  // Caching menu requests to avoid flicker.
2665
2665
  var menuCache = new Map();
2666
2666
  var menuTitleCache = new Map();
2667
+ var processMenuCache = new Map();
2667
2668
  function constructMenu(_x, _x2, _x3) {
2668
2669
  return _constructMenu.apply(this, arguments);
2669
2670
  }
@@ -2700,12 +2701,14 @@ function constructMenuByMenusList(_x4, _x5, _x6) {
2700
2701
 
2701
2702
  function _constructMenuByMenusList() {
2702
2703
  _constructMenuByMenusList = _asyncToGenerator$4(function* (menus, context, kernel) {
2703
- yield Promise.all(menus.map(menuId => processMenu(menuId, context, kernel)));
2704
+ processMenuCache.clear();
2705
+ var data = yield Promise.all(menus.map(menuId => processMenu(menuId, context, kernel)));
2706
+ data.forEach((item, index) => processMenuCache.set(menus[index], item));
2704
2707
  });
2705
2708
  return _constructMenuByMenusList.apply(this, arguments);
2706
2709
  }
2707
2710
 
2708
- var getMenu = menuId => menuCache.get(menuId);
2711
+ var getMenu = menuId => processMenuCache.get(menuId);
2709
2712
  function fetchMenuById(_x7, _x8) {
2710
2713
  return _fetchMenuById.apply(this, arguments);
2711
2714
  }
@@ -3115,6 +3118,11 @@ function _dev_only_getFakeKernel(overrides) {
3115
3118
  getProviderBrick: kernel.getProviderBrick.bind(kernel)
3116
3119
  }, overrides);
3117
3120
  }
3121
+ /* istanbul ignore next */
3122
+
3123
+ function _dev_only_updateStoryboard(appId, storyboardPatch) {
3124
+ kernel._dev_only_updateStoryboard(appId, storyboardPatch);
3125
+ }
3118
3126
  class Runtime {
3119
3127
  constructor() {
3120
3128
  _defineProperty$1(this, "registerBrickTemplate", registerBrickTemplate);
@@ -7798,9 +7806,9 @@ class Kernel {
7798
7806
  }
7799
7807
 
7800
7808
  doFulfilStoryboard(storyboard) {
7801
- return _asyncToGenerator$4(function* () {
7802
- var _storyboard$meta;
7809
+ var _this5 = this;
7803
7810
 
7811
+ return _asyncToGenerator$4(function* () {
7804
7812
  if (window.STANDALONE_MICRO_APPS) {
7805
7813
  Object.assign(storyboard, {
7806
7814
  $$fulfilled: true
@@ -7819,28 +7827,43 @@ class Kernel {
7819
7827
  });
7820
7828
  }
7821
7829
 
7822
- storyboard.app.$$routeAliasMap = scanRouteAliasInStoryboard(storyboard);
7830
+ _this5.postProcessStoryboard(storyboard);
7831
+ })();
7832
+ }
7823
7833
 
7824
- if ((_storyboard$meta = storyboard.meta) !== null && _storyboard$meta !== void 0 && _storyboard$meta.i18n) {
7825
- // Prefix to avoid conflict between brick package's i18n namespace.
7826
- var i18nNamespace = getI18nNamespace("app", storyboard.app.id); // Support any language in `meta.i18n`.
7834
+ postProcessStoryboard(storyboard) {
7835
+ var _storyboard$meta;
7827
7836
 
7828
- Object.entries(storyboard.meta.i18n).forEach(_ref => {
7829
- var [lang, resources] = _ref;
7830
- i18next.addResourceBundle(lang, i18nNamespace, resources);
7831
- });
7832
- }
7833
- })();
7837
+ storyboard.app.$$routeAliasMap = scanRouteAliasInStoryboard(storyboard);
7838
+
7839
+ if ((_storyboard$meta = storyboard.meta) !== null && _storyboard$meta !== void 0 && _storyboard$meta.i18n) {
7840
+ // Prefix to avoid conflict between brick package's i18n namespace.
7841
+ var i18nNamespace = getI18nNamespace("app", storyboard.app.id); // Support any language in `meta.i18n`.
7842
+
7843
+ Object.entries(storyboard.meta.i18n).forEach(_ref => {
7844
+ var [lang, resources] = _ref;
7845
+ i18next.addResourceBundle(lang, i18nNamespace, resources);
7846
+ });
7847
+ }
7848
+ }
7849
+
7850
+ _dev_only_updateStoryboard(appId, storyboardPatch) {
7851
+ var storyboard = this.bootstrapData.storyboards.find(item => item.app.id === appId);
7852
+ Object.assign(storyboard, _objectSpread(_objectSpread({}, storyboardPatch), {}, {
7853
+ $$fulfilling: Promise.resolve(),
7854
+ $$fulfilled: true
7855
+ }));
7856
+ this.postProcessStoryboard(storyboard);
7834
7857
  }
7835
7858
 
7836
7859
  loadDepsOfStoryboard(storyboard) {
7837
- var _this5 = this;
7860
+ var _this6 = this;
7838
7861
 
7839
7862
  return _asyncToGenerator$4(function* () {
7840
7863
  var {
7841
7864
  brickPackages,
7842
7865
  templatePackages
7843
- } = _this5.bootstrapData;
7866
+ } = _this6.bootstrapData;
7844
7867
 
7845
7868
  if (storyboard.dependsAll) {
7846
7869
  var dllPath = window.DLL_PATH || {};
@@ -7906,7 +7929,7 @@ class Kernel {
7906
7929
  }
7907
7930
 
7908
7931
  loadDynamicBricksInBrickConf(brickConf) {
7909
- var _this6 = this;
7932
+ var _this7 = this;
7910
7933
 
7911
7934
  return _asyncToGenerator$4(function* () {
7912
7935
  // Notice: `brickConf` contains runtime data,
@@ -7914,12 +7937,12 @@ class Kernel {
7914
7937
  // which could cause stack overflow while traversing.
7915
7938
  var bricks = scanBricksInBrickConf(brickConf);
7916
7939
  var processors = scanProcessorsInAny(brickConf);
7917
- yield _this6.loadDynamicBricks(bricks, processors);
7940
+ yield _this7.loadDynamicBricks(bricks, processors);
7918
7941
  })();
7919
7942
  }
7920
7943
 
7921
7944
  loadDynamicBricks(bricks, processors) {
7922
- var _this7 = this;
7945
+ var _this8 = this;
7923
7946
 
7924
7947
  return _asyncToGenerator$4(function* () {
7925
7948
  var filteredBricks = bricks.filter( // Only try to load undefined custom elements.
@@ -7931,7 +7954,7 @@ class Kernel {
7931
7954
  } = getDllAndDepsByResource({
7932
7955
  bricks: filteredBricks,
7933
7956
  processors
7934
- }, _this7.bootstrapData.brickPackages);
7957
+ }, _this8.bootstrapData.brickPackages);
7935
7958
  yield loadScriptOfDll(dll);
7936
7959
  yield loadScriptOfBricksOrTemplates(deps);
7937
7960
  yield loadLazyBricks(filteredBricks);
@@ -7939,7 +7962,7 @@ class Kernel {
7939
7962
  }
7940
7963
 
7941
7964
  loadEditorBricks(editorBricks) {
7942
- var _this8 = this;
7965
+ var _this9 = this;
7943
7966
 
7944
7967
  return _asyncToGenerator$4(function* () {
7945
7968
  var {
@@ -7948,7 +7971,7 @@ class Kernel {
7948
7971
  } = getDllAndDepsByResource({
7949
7972
  editorBricks: editorBricks.filter( // Only try to load undefined custom elements.
7950
7973
  item => !customElements.get(item))
7951
- }, _this8.bootstrapData.brickPackages);
7974
+ }, _this9.bootstrapData.brickPackages);
7952
7975
  yield loadScriptOfDll(dll);
7953
7976
  yield loadScriptOfBricksOrTemplates(deps);
7954
7977
  })();
@@ -8052,10 +8075,10 @@ class Kernel {
8052
8075
  }
8053
8076
 
8054
8077
  getMicroAppApiOrchestrationMapAsync() {
8055
- var _this9 = this;
8078
+ var _this10 = this;
8056
8079
 
8057
8080
  return _asyncToGenerator$4(function* () {
8058
- return yield _this9.allMicroAppApiOrchestrationPromise;
8081
+ return yield _this10.allMicroAppApiOrchestrationPromise;
8059
8082
  })();
8060
8083
  }
8061
8084
 
@@ -8147,14 +8170,14 @@ class Kernel {
8147
8170
  }
8148
8171
 
8149
8172
  getRelatedAppsAsync(appId) {
8150
- var _this10 = this;
8173
+ var _this11 = this;
8151
8174
 
8152
8175
  return _asyncToGenerator$4(function* () {
8153
8176
  if (!appId) {
8154
8177
  return [];
8155
8178
  }
8156
8179
 
8157
- var allRelatedApps = yield _this10.allRelatedAppsPromise;
8180
+ var allRelatedApps = yield _this11.allRelatedAppsPromise;
8158
8181
  var thisApp = allRelatedApps.find(item => item.microAppId === appId);
8159
8182
 
8160
8183
  if (!thisApp) {
@@ -8166,38 +8189,38 @@ class Kernel {
8166
8189
  }
8167
8190
 
8168
8191
  updateWorkspaceStack() {
8169
- var _this11 = this;
8192
+ var _this12 = this;
8170
8193
 
8171
8194
  return _asyncToGenerator$4(function* () {
8172
- if (_this11.currentApp && _this11.currentApp.id) {
8195
+ if (_this12.currentApp && _this12.currentApp.id) {
8173
8196
  var workspace = {
8174
- appId: _this11.currentApp.id,
8175
- appName: _this11.currentApp.name,
8176
- appLocaleName: _this11.currentApp.localeName,
8177
- url: _this11.currentUrl
8197
+ appId: _this12.currentApp.id,
8198
+ appName: _this12.currentApp.name,
8199
+ appLocaleName: _this12.currentApp.localeName,
8200
+ url: _this12.currentUrl
8178
8201
  };
8179
8202
 
8180
- if (_this11.workspaceStack.length > 0) {
8181
- var previousWorkspace = _this11.workspaceStack[_this11.workspaceStack.length - 1];
8203
+ if (_this12.workspaceStack.length > 0) {
8204
+ var previousWorkspace = _this12.workspaceStack[_this12.workspaceStack.length - 1];
8182
8205
 
8183
- var _relatedApps = yield _this11.getRelatedAppsAsync(previousWorkspace.appId);
8206
+ var _relatedApps = yield _this12.getRelatedAppsAsync(previousWorkspace.appId);
8184
8207
 
8185
- if (_relatedApps.some(item => item.microAppId === _this11.currentApp.id)) {
8208
+ if (_relatedApps.some(item => item.microAppId === _this12.currentApp.id)) {
8186
8209
  Object.assign(previousWorkspace, workspace);
8187
8210
  return;
8188
8211
  }
8189
8212
  }
8190
8213
 
8191
- var relatedApps = yield _this11.getRelatedAppsAsync(_this11.currentApp.id);
8214
+ var relatedApps = yield _this12.getRelatedAppsAsync(_this12.currentApp.id);
8192
8215
 
8193
8216
  if (relatedApps.length > 0) {
8194
- _this11.workspaceStack.push(workspace);
8217
+ _this12.workspaceStack.push(workspace);
8195
8218
 
8196
8219
  return;
8197
8220
  }
8198
8221
  }
8199
8222
 
8200
- _this11.workspaceStack = [];
8223
+ _this12.workspaceStack = [];
8201
8224
  })();
8202
8225
  }
8203
8226
 
@@ -8238,22 +8261,22 @@ class Kernel {
8238
8261
  }
8239
8262
 
8240
8263
  getProviderBrick(provider) {
8241
- var _this12 = this;
8264
+ var _this13 = this;
8242
8265
 
8243
8266
  return _asyncToGenerator$4(function* () {
8244
8267
  if (isCustomApiProvider(provider)) {
8245
8268
  provider = CUSTOM_API_PROVIDER;
8246
8269
  }
8247
8270
 
8248
- if (_this12.providerRepository.has(provider)) {
8249
- return _this12.providerRepository.get(provider);
8271
+ if (_this13.providerRepository.has(provider)) {
8272
+ return _this13.providerRepository.get(provider);
8250
8273
  }
8251
8274
 
8252
8275
  if (provider === CUSTOM_API_PROVIDER && !customElements.get(provider)) {
8253
8276
  registerCustomApi();
8254
8277
  }
8255
8278
 
8256
- yield _this12.loadDynamicBricks([provider]);
8279
+ yield _this13.loadDynamicBricks([provider]);
8257
8280
 
8258
8281
  if (!customElements.get(provider)) {
8259
8282
  throw new Error("Provider not defined: \"".concat(provider, "\"."));
@@ -8261,7 +8284,7 @@ class Kernel {
8261
8284
 
8262
8285
  var brick = document.createElement(provider);
8263
8286
 
8264
- _this12.providerRepository.set(provider, brick);
8287
+ _this13.providerRepository.set(provider, brick);
8265
8288
 
8266
8289
  return brick;
8267
8290
  })();
@@ -12837,7 +12860,8 @@ var developHelper = {
12837
12860
  getFakeKernel: _dev_only_getFakeKernel,
12838
12861
 
12839
12862
  /** @deprecated Keep it for backward-compatibility. */
12840
- checkoutTplContext: noop
12863
+ checkoutTplContext: noop,
12864
+ updateStoryboard: _dev_only_updateStoryboard
12841
12865
  };
12842
12866
 
12843
12867
  var _excluded$2 = ["type"];