@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/CHANGELOG.md CHANGED
@@ -3,6 +3,45 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.113.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.112.1...@next-core/brick-kit@2.113.0) (2022-03-29)
7
+
8
+
9
+ ### Features
10
+
11
+ * cache fetchMenu, and APP.getMenu change ([07ede47](https://github.com/easyops-cn/next-core/commit/07ede4778f012fbbb7e72d30b1c41d6478660aec))
12
+ * update type ([d7b480e](https://github.com/easyops-cn/next-core/commit/d7b480ecc287263345415c536bd263b7fb317b1e))
13
+
14
+
15
+
16
+
17
+
18
+ ## [2.112.1](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.112.0...@next-core/brick-kit@2.112.1) (2022-03-29)
19
+
20
+ **Note:** Version bump only for package @next-core/brick-kit
21
+
22
+
23
+
24
+
25
+
26
+ # [2.112.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.111.3...@next-core/brick-kit@2.112.0) (2022-03-29)
27
+
28
+
29
+ ### Features
30
+
31
+ * support updating storyboard on the fly ([0a50183](https://github.com/easyops-cn/next-core/commit/0a501838621d44c43ea7c16b211395b511e76c8a))
32
+
33
+
34
+
35
+
36
+
37
+ ## [2.111.3](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.111.2...@next-core/brick-kit@2.111.3) (2022-03-29)
38
+
39
+ **Note:** Version bump only for package @next-core/brick-kit
40
+
41
+
42
+
43
+
44
+
6
45
  ## [2.111.2](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.111.1...@next-core/brick-kit@2.111.2) (2022-03-28)
7
46
 
8
47
  **Note:** Version bump only for package @next-core/brick-kit
@@ -2663,6 +2663,7 @@
2663
2663
  // Caching menu requests to avoid flicker.
2664
2664
  var menuCache = new Map();
2665
2665
  var menuTitleCache = new Map();
2666
+ var processMenuCache = new Map();
2666
2667
  function constructMenu(_x, _x2, _x3) {
2667
2668
  return _constructMenu.apply(this, arguments);
2668
2669
  }
@@ -2699,12 +2700,14 @@
2699
2700
 
2700
2701
  function _constructMenuByMenusList() {
2701
2702
  _constructMenuByMenusList = _asyncToGenerator__default["default"](function* (menus, context, kernel) {
2702
- yield Promise.all(menus.map(menuId => processMenu(menuId, context, kernel)));
2703
+ processMenuCache.clear();
2704
+ var data = yield Promise.all(menus.map(menuId => processMenu(menuId, context, kernel)));
2705
+ data.forEach((item, index) => processMenuCache.set(menus[index], item));
2703
2706
  });
2704
2707
  return _constructMenuByMenusList.apply(this, arguments);
2705
2708
  }
2706
2709
 
2707
- var getMenu = menuId => menuCache.get(menuId);
2710
+ var getMenu = menuId => processMenuCache.get(menuId);
2708
2711
  function fetchMenuById(_x7, _x8) {
2709
2712
  return _fetchMenuById.apply(this, arguments);
2710
2713
  }
@@ -3114,6 +3117,11 @@
3114
3117
  getProviderBrick: kernel.getProviderBrick.bind(kernel)
3115
3118
  }, overrides);
3116
3119
  }
3120
+ /* istanbul ignore next */
3121
+
3122
+ function _dev_only_updateStoryboard(appId, storyboardPatch) {
3123
+ kernel._dev_only_updateStoryboard(appId, storyboardPatch);
3124
+ }
3117
3125
  class Runtime {
3118
3126
  constructor() {
3119
3127
  _defineProperty__default["default"](this, "registerBrickTemplate", registerBrickTemplate);
@@ -7797,9 +7805,9 @@
7797
7805
  }
7798
7806
 
7799
7807
  doFulfilStoryboard(storyboard) {
7800
- return _asyncToGenerator__default["default"](function* () {
7801
- var _storyboard$meta;
7808
+ var _this5 = this;
7802
7809
 
7810
+ return _asyncToGenerator__default["default"](function* () {
7803
7811
  if (window.STANDALONE_MICRO_APPS) {
7804
7812
  Object.assign(storyboard, {
7805
7813
  $$fulfilled: true
@@ -7818,28 +7826,43 @@
7818
7826
  });
7819
7827
  }
7820
7828
 
7821
- storyboard.app.$$routeAliasMap = brickUtils.scanRouteAliasInStoryboard(storyboard);
7829
+ _this5.postProcessStoryboard(storyboard);
7830
+ })();
7831
+ }
7822
7832
 
7823
- if ((_storyboard$meta = storyboard.meta) !== null && _storyboard$meta !== void 0 && _storyboard$meta.i18n) {
7824
- // Prefix to avoid conflict between brick package's i18n namespace.
7825
- var i18nNamespace = getI18nNamespace("app", storyboard.app.id); // Support any language in `meta.i18n`.
7833
+ postProcessStoryboard(storyboard) {
7834
+ var _storyboard$meta;
7826
7835
 
7827
- Object.entries(storyboard.meta.i18n).forEach(_ref => {
7828
- var [lang, resources] = _ref;
7829
- i18next__default["default"].addResourceBundle(lang, i18nNamespace, resources);
7830
- });
7831
- }
7832
- })();
7836
+ storyboard.app.$$routeAliasMap = brickUtils.scanRouteAliasInStoryboard(storyboard);
7837
+
7838
+ if ((_storyboard$meta = storyboard.meta) !== null && _storyboard$meta !== void 0 && _storyboard$meta.i18n) {
7839
+ // Prefix to avoid conflict between brick package's i18n namespace.
7840
+ var i18nNamespace = getI18nNamespace("app", storyboard.app.id); // Support any language in `meta.i18n`.
7841
+
7842
+ Object.entries(storyboard.meta.i18n).forEach(_ref => {
7843
+ var [lang, resources] = _ref;
7844
+ i18next__default["default"].addResourceBundle(lang, i18nNamespace, resources);
7845
+ });
7846
+ }
7847
+ }
7848
+
7849
+ _dev_only_updateStoryboard(appId, storyboardPatch) {
7850
+ var storyboard = this.bootstrapData.storyboards.find(item => item.app.id === appId);
7851
+ Object.assign(storyboard, _objectSpread__default["default"](_objectSpread__default["default"]({}, storyboardPatch), {}, {
7852
+ $$fulfilling: Promise.resolve(),
7853
+ $$fulfilled: true
7854
+ }));
7855
+ this.postProcessStoryboard(storyboard);
7833
7856
  }
7834
7857
 
7835
7858
  loadDepsOfStoryboard(storyboard) {
7836
- var _this5 = this;
7859
+ var _this6 = this;
7837
7860
 
7838
7861
  return _asyncToGenerator__default["default"](function* () {
7839
7862
  var {
7840
7863
  brickPackages,
7841
7864
  templatePackages
7842
- } = _this5.bootstrapData;
7865
+ } = _this6.bootstrapData;
7843
7866
 
7844
7867
  if (storyboard.dependsAll) {
7845
7868
  var dllPath = window.DLL_PATH || {};
@@ -7905,7 +7928,7 @@
7905
7928
  }
7906
7929
 
7907
7930
  loadDynamicBricksInBrickConf(brickConf) {
7908
- var _this6 = this;
7931
+ var _this7 = this;
7909
7932
 
7910
7933
  return _asyncToGenerator__default["default"](function* () {
7911
7934
  // Notice: `brickConf` contains runtime data,
@@ -7913,12 +7936,12 @@
7913
7936
  // which could cause stack overflow while traversing.
7914
7937
  var bricks = brickUtils.scanBricksInBrickConf(brickConf);
7915
7938
  var processors = brickUtils.scanProcessorsInAny(brickConf);
7916
- yield _this6.loadDynamicBricks(bricks, processors);
7939
+ yield _this7.loadDynamicBricks(bricks, processors);
7917
7940
  })();
7918
7941
  }
7919
7942
 
7920
7943
  loadDynamicBricks(bricks, processors) {
7921
- var _this7 = this;
7944
+ var _this8 = this;
7922
7945
 
7923
7946
  return _asyncToGenerator__default["default"](function* () {
7924
7947
  var filteredBricks = bricks.filter( // Only try to load undefined custom elements.
@@ -7930,7 +7953,7 @@
7930
7953
  } = brickUtils.getDllAndDepsByResource({
7931
7954
  bricks: filteredBricks,
7932
7955
  processors
7933
- }, _this7.bootstrapData.brickPackages);
7956
+ }, _this8.bootstrapData.brickPackages);
7934
7957
  yield loadScriptOfDll(dll);
7935
7958
  yield loadScriptOfBricksOrTemplates(deps);
7936
7959
  yield loadLazyBricks(filteredBricks);
@@ -7938,7 +7961,7 @@
7938
7961
  }
7939
7962
 
7940
7963
  loadEditorBricks(editorBricks) {
7941
- var _this8 = this;
7964
+ var _this9 = this;
7942
7965
 
7943
7966
  return _asyncToGenerator__default["default"](function* () {
7944
7967
  var {
@@ -7947,7 +7970,7 @@
7947
7970
  } = brickUtils.getDllAndDepsByResource({
7948
7971
  editorBricks: editorBricks.filter( // Only try to load undefined custom elements.
7949
7972
  item => !customElements.get(item))
7950
- }, _this8.bootstrapData.brickPackages);
7973
+ }, _this9.bootstrapData.brickPackages);
7951
7974
  yield loadScriptOfDll(dll);
7952
7975
  yield loadScriptOfBricksOrTemplates(deps);
7953
7976
  })();
@@ -8051,10 +8074,10 @@
8051
8074
  }
8052
8075
 
8053
8076
  getMicroAppApiOrchestrationMapAsync() {
8054
- var _this9 = this;
8077
+ var _this10 = this;
8055
8078
 
8056
8079
  return _asyncToGenerator__default["default"](function* () {
8057
- return yield _this9.allMicroAppApiOrchestrationPromise;
8080
+ return yield _this10.allMicroAppApiOrchestrationPromise;
8058
8081
  })();
8059
8082
  }
8060
8083
 
@@ -8146,14 +8169,14 @@
8146
8169
  }
8147
8170
 
8148
8171
  getRelatedAppsAsync(appId) {
8149
- var _this10 = this;
8172
+ var _this11 = this;
8150
8173
 
8151
8174
  return _asyncToGenerator__default["default"](function* () {
8152
8175
  if (!appId) {
8153
8176
  return [];
8154
8177
  }
8155
8178
 
8156
- var allRelatedApps = yield _this10.allRelatedAppsPromise;
8179
+ var allRelatedApps = yield _this11.allRelatedAppsPromise;
8157
8180
  var thisApp = allRelatedApps.find(item => item.microAppId === appId);
8158
8181
 
8159
8182
  if (!thisApp) {
@@ -8165,38 +8188,38 @@
8165
8188
  }
8166
8189
 
8167
8190
  updateWorkspaceStack() {
8168
- var _this11 = this;
8191
+ var _this12 = this;
8169
8192
 
8170
8193
  return _asyncToGenerator__default["default"](function* () {
8171
- if (_this11.currentApp && _this11.currentApp.id) {
8194
+ if (_this12.currentApp && _this12.currentApp.id) {
8172
8195
  var workspace = {
8173
- appId: _this11.currentApp.id,
8174
- appName: _this11.currentApp.name,
8175
- appLocaleName: _this11.currentApp.localeName,
8176
- url: _this11.currentUrl
8196
+ appId: _this12.currentApp.id,
8197
+ appName: _this12.currentApp.name,
8198
+ appLocaleName: _this12.currentApp.localeName,
8199
+ url: _this12.currentUrl
8177
8200
  };
8178
8201
 
8179
- if (_this11.workspaceStack.length > 0) {
8180
- var previousWorkspace = _this11.workspaceStack[_this11.workspaceStack.length - 1];
8202
+ if (_this12.workspaceStack.length > 0) {
8203
+ var previousWorkspace = _this12.workspaceStack[_this12.workspaceStack.length - 1];
8181
8204
 
8182
- var _relatedApps = yield _this11.getRelatedAppsAsync(previousWorkspace.appId);
8205
+ var _relatedApps = yield _this12.getRelatedAppsAsync(previousWorkspace.appId);
8183
8206
 
8184
- if (_relatedApps.some(item => item.microAppId === _this11.currentApp.id)) {
8207
+ if (_relatedApps.some(item => item.microAppId === _this12.currentApp.id)) {
8185
8208
  Object.assign(previousWorkspace, workspace);
8186
8209
  return;
8187
8210
  }
8188
8211
  }
8189
8212
 
8190
- var relatedApps = yield _this11.getRelatedAppsAsync(_this11.currentApp.id);
8213
+ var relatedApps = yield _this12.getRelatedAppsAsync(_this12.currentApp.id);
8191
8214
 
8192
8215
  if (relatedApps.length > 0) {
8193
- _this11.workspaceStack.push(workspace);
8216
+ _this12.workspaceStack.push(workspace);
8194
8217
 
8195
8218
  return;
8196
8219
  }
8197
8220
  }
8198
8221
 
8199
- _this11.workspaceStack = [];
8222
+ _this12.workspaceStack = [];
8200
8223
  })();
8201
8224
  }
8202
8225
 
@@ -8237,22 +8260,22 @@
8237
8260
  }
8238
8261
 
8239
8262
  getProviderBrick(provider) {
8240
- var _this12 = this;
8263
+ var _this13 = this;
8241
8264
 
8242
8265
  return _asyncToGenerator__default["default"](function* () {
8243
8266
  if (isCustomApiProvider(provider)) {
8244
8267
  provider = CUSTOM_API_PROVIDER;
8245
8268
  }
8246
8269
 
8247
- if (_this12.providerRepository.has(provider)) {
8248
- return _this12.providerRepository.get(provider);
8270
+ if (_this13.providerRepository.has(provider)) {
8271
+ return _this13.providerRepository.get(provider);
8249
8272
  }
8250
8273
 
8251
8274
  if (provider === CUSTOM_API_PROVIDER && !customElements.get(provider)) {
8252
8275
  registerCustomApi();
8253
8276
  }
8254
8277
 
8255
- yield _this12.loadDynamicBricks([provider]);
8278
+ yield _this13.loadDynamicBricks([provider]);
8256
8279
 
8257
8280
  if (!customElements.get(provider)) {
8258
8281
  throw new Error("Provider not defined: \"".concat(provider, "\"."));
@@ -8260,7 +8283,7 @@
8260
8283
 
8261
8284
  var brick = document.createElement(provider);
8262
8285
 
8263
- _this12.providerRepository.set(provider, brick);
8286
+ _this13.providerRepository.set(provider, brick);
8264
8287
 
8265
8288
  return brick;
8266
8289
  })();
@@ -12836,7 +12859,8 @@
12836
12859
  getFakeKernel: _dev_only_getFakeKernel,
12837
12860
 
12838
12861
  /** @deprecated Keep it for backward-compatibility. */
12839
- checkoutTplContext: lodash.noop
12862
+ checkoutTplContext: lodash.noop,
12863
+ updateStoryboard: _dev_only_updateStoryboard
12840
12864
  };
12841
12865
 
12842
12866
  var _excluded$2 = ["type"];