@next-core/brick-kit 2.117.3 → 2.117.6

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,41 @@
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.117.6](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.117.5...@next-core/brick-kit@2.117.6) (2022-04-11)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * handle checking isInIframeOfLegacyConsole when previewing in visual builder by iframe ([8e347b9](https://github.com/easyops-cn/next-core/commit/8e347b969033992412ee349ecd6f633141be95d5))
12
+ * reload bootstrap again when loading bricks failed ([f022593](https://github.com/easyops-cn/next-core/commit/f0225934d5a1694ee06f96f3d1b5cd1c9b92c1b2))
13
+
14
+
15
+
16
+
17
+
18
+ ## [2.117.5](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.117.4...@next-core/brick-kit@2.117.5) (2022-04-11)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * useProvider hook 支持query查询provider ([c8581e8](https://github.com/easyops-cn/next-core/commit/c8581e877f740f4218ac296eaa6448ce54be2803))
24
+
25
+
26
+
27
+
28
+
29
+ ## [2.117.4](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.117.3...@next-core/brick-kit@2.117.4) (2022-04-11)
30
+
31
+
32
+ ### Bug Fixes
33
+
34
+ * bg bricks should have no slot ([0c93d41](https://github.com/easyops-cn/next-core/commit/0c93d417da911b5b7d012d81f73bdeeadbf4f9d2))
35
+ * no menu for template preview ([6f5ed88](https://github.com/easyops-cn/next-core/commit/6f5ed88002f61f105a6e2ab87481ffab2bbb0616))
36
+
37
+
38
+
39
+
40
+
6
41
  ## [2.117.3](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.117.2...@next-core/brick-kit@2.117.3) (2022-04-08)
7
42
 
8
43
 
@@ -7753,6 +7753,8 @@
7753
7753
 
7754
7754
  class Kernel {
7755
7755
  constructor() {
7756
+ var _this = this;
7757
+
7756
7758
  _defineProperty__default["default"](this, "mountPoints", void 0);
7757
7759
 
7758
7760
  _defineProperty__default["default"](this, "bootstrapData", void 0);
@@ -7794,36 +7796,111 @@
7794
7796
  _defineProperty__default["default"](this, "loadUsersStarted", false);
7795
7797
 
7796
7798
  _defineProperty__default["default"](this, "loadMagicBrickConfigStarted", false);
7799
+
7800
+ _defineProperty__default["default"](this, "_loadDepsOfStoryboard", /*#__PURE__*/function () {
7801
+ var _ref = _asyncToGenerator__default["default"](function* (storyboard) {
7802
+ var {
7803
+ brickPackages,
7804
+ templatePackages
7805
+ } = _this.bootstrapData;
7806
+
7807
+ if (storyboard.dependsAll) {
7808
+ var dllPath = window.DLL_PATH || {};
7809
+ yield loadScriptOfDll(Object.values(dllPath));
7810
+ yield loadScriptOfBricksOrTemplates(brickPackages.map(item => item.filePath).concat(templatePackages.map(item => item.filePath)));
7811
+ yield loadAllLazyBricks();
7812
+ } else {
7813
+ // 先加载模板
7814
+ var templateDeps = brickUtils.getTemplateDepsOfStoryboard(storyboard, templatePackages);
7815
+ yield loadScriptOfBricksOrTemplates(templateDeps); // 加载模板后才能加工得到最终的构件表
7816
+
7817
+ var {
7818
+ dll,
7819
+ deps,
7820
+ bricks
7821
+ } = brickUtils.getDllAndDepsOfStoryboard(yield brickUtils.asyncProcessStoryboard(storyboard, brickTemplateRegistry, templatePackages), brickPackages, {
7822
+ ignoreBricksInUnusedCustomTemplates: true
7823
+ });
7824
+ yield loadScriptOfDll(dll);
7825
+ yield loadScriptOfBricksOrTemplates(deps);
7826
+ yield loadLazyBricks(bricks);
7827
+ }
7828
+ });
7829
+
7830
+ return function (_x) {
7831
+ return _ref.apply(this, arguments);
7832
+ };
7833
+ }());
7834
+
7835
+ _defineProperty__default["default"](this, "_loadDynamicBricks", /*#__PURE__*/function () {
7836
+ var _ref2 = _asyncToGenerator__default["default"](function* (bricks, processors) {
7837
+ var filteredBricks = bricks.filter( // Only try to load undefined custom elements.
7838
+ item => !customElements.get(item)); // Try to load deps for dynamic added bricks.
7839
+
7840
+ var {
7841
+ dll,
7842
+ deps
7843
+ } = brickUtils.getDllAndDepsByResource({
7844
+ bricks: filteredBricks,
7845
+ processors
7846
+ }, _this.bootstrapData.brickPackages);
7847
+ yield loadScriptOfDll(dll);
7848
+ yield loadScriptOfBricksOrTemplates(deps);
7849
+ yield loadLazyBricks(filteredBricks);
7850
+ });
7851
+
7852
+ return function (_x2, _x3) {
7853
+ return _ref2.apply(this, arguments);
7854
+ };
7855
+ }());
7856
+
7857
+ _defineProperty__default["default"](this, "_loadEditorBricks", /*#__PURE__*/function () {
7858
+ var _ref3 = _asyncToGenerator__default["default"](function* (editorBricks) {
7859
+ var {
7860
+ dll,
7861
+ deps
7862
+ } = brickUtils.getDllAndDepsByResource({
7863
+ editorBricks: editorBricks.filter( // Only try to load undefined custom elements.
7864
+ item => !customElements.get(item))
7865
+ }, _this.bootstrapData.brickPackages);
7866
+ yield loadScriptOfDll(dll);
7867
+ yield loadScriptOfBricksOrTemplates(deps);
7868
+ });
7869
+
7870
+ return function (_x4) {
7871
+ return _ref3.apply(this, arguments);
7872
+ };
7873
+ }());
7797
7874
  }
7798
7875
 
7799
7876
  bootstrap(mountPoints) {
7800
- var _this = this;
7877
+ var _this2 = this;
7801
7878
 
7802
7879
  return _asyncToGenerator__default["default"](function* () {
7803
- var _this$bootstrapData$s, _this$bootstrapData$s2;
7880
+ var _this2$bootstrapData$, _this2$bootstrapData$2;
7804
7881
 
7805
- _this.mountPoints = mountPoints;
7806
- yield Promise.all([_this.loadCheckLogin(), _this.loadMicroApps()]);
7882
+ _this2.mountPoints = mountPoints;
7883
+ yield Promise.all([_this2.loadCheckLogin(), _this2.loadMicroApps()]);
7807
7884
 
7808
- if (_this.bootstrapData.storyboards.length === 0) {
7885
+ if (_this2.bootstrapData.storyboards.length === 0) {
7809
7886
  throw new Error("No storyboard were found.");
7810
7887
  }
7811
7888
 
7812
- generateColorTheme((_this$bootstrapData$s = _this.bootstrapData.settings) === null || _this$bootstrapData$s === void 0 ? void 0 : (_this$bootstrapData$s2 = _this$bootstrapData$s.misc) === null || _this$bootstrapData$s2 === void 0 ? void 0 : _this$bootstrapData$s2.theme);
7889
+ generateColorTheme((_this2$bootstrapData$ = _this2.bootstrapData.settings) === null || _this2$bootstrapData$ === void 0 ? void 0 : (_this2$bootstrapData$2 = _this2$bootstrapData$.misc) === null || _this2$bootstrapData$2 === void 0 ? void 0 : _this2$bootstrapData$2.theme);
7813
7890
 
7814
7891
  if (isLoggedIn()) {
7815
- _this.loadSharedData();
7892
+ _this2.loadSharedData();
7816
7893
  }
7817
7894
 
7818
- _this.menuBar = new MenuBar(_this, "menuBar");
7819
- _this.appBar = new AppBar(_this, "appBar");
7820
- _this.loadingBar = new BaseBar(_this, "loadingBar");
7821
- _this.router = new Router(_this);
7895
+ _this2.menuBar = new MenuBar(_this2, "menuBar");
7896
+ _this2.appBar = new AppBar(_this2, "appBar");
7897
+ _this2.loadingBar = new BaseBar(_this2, "loadingBar");
7898
+ _this2.router = new Router(_this2);
7822
7899
  initAnalytics();
7823
- yield _this.router.bootstrap();
7900
+ yield _this2.router.bootstrap();
7824
7901
 
7825
7902
  if (!window.STANDALONE_MICRO_APPS) {
7826
- _this.legacyAuthGuard();
7903
+ _this2.legacyAuthGuard();
7827
7904
  }
7828
7905
 
7829
7906
  listenDevtools();
@@ -7831,7 +7908,7 @@
7831
7908
  }
7832
7909
 
7833
7910
  layoutBootstrap(layout) {
7834
- var _this2 = this;
7911
+ var _this3 = this;
7835
7912
 
7836
7913
  return _asyncToGenerator__default["default"](function* () {
7837
7914
  var supportedLayouts = ["console", "business"];
@@ -7840,12 +7917,12 @@
7840
7917
  throw new Error("Unknown layout: ".concat(layout));
7841
7918
  }
7842
7919
 
7843
- _this2.currentLayout = layout;
7844
- _this2.presetBricks = layout === "business" ? {
7920
+ _this3.currentLayout = layout;
7921
+ _this3.presetBricks = layout === "business" ? {
7845
7922
  loadingBar: "business-website.loading-bar",
7846
7923
  pageNotFound: "business-website.page-not-found",
7847
7924
  pageError: "business-website.page-error"
7848
- } : _objectSpread__default["default"](_objectSpread__default["default"]({}, _this2.bootstrapData.navbar), {}, {
7925
+ } : _objectSpread__default["default"](_objectSpread__default["default"]({}, _this3.bootstrapData.navbar), {}, {
7849
7926
  pageNotFound: "basic-bricks.page-not-found",
7850
7927
  pageError: "basic-bricks.page-error"
7851
7928
  });
@@ -7858,9 +7935,9 @@
7858
7935
  }
7859
7936
  }
7860
7937
 
7861
- yield Promise.all([_this2.menuBar.bootstrap(_this2.presetBricks.menuBar, {
7938
+ yield Promise.all([_this3.menuBar.bootstrap(_this3.presetBricks.menuBar, {
7862
7939
  testid: "brick-next-menu-bar"
7863
- }), _this2.appBar.bootstrap(_this2.presetBricks.appBar), _this2.loadingBar.bootstrap(_this2.presetBricks.loadingBar)]);
7940
+ }), _this3.appBar.bootstrap(_this3.presetBricks.appBar), _this3.loadingBar.bootstrap(_this3.presetBricks.loadingBar)]);
7864
7941
  })();
7865
7942
  }
7866
7943
 
@@ -7897,7 +7974,7 @@
7897
7974
  }
7898
7975
 
7899
7976
  loadMicroApps(params, interceptorParams) {
7900
- var _this3 = this;
7977
+ var _this4 = this;
7901
7978
 
7902
7979
  return _asyncToGenerator__default["default"](function* () {
7903
7980
  var data = yield window.STANDALONE_MICRO_APPS ? standaloneBootstrap() : BootstrapV2Api_bootstrapV2(_objectSpread__default["default"]({
@@ -7914,7 +7991,7 @@
7914
7991
 
7915
7992
 
7916
7993
  processBootstrapResponse(bootstrapResponse);
7917
- _this3.bootstrapData = _objectSpread__default["default"](_objectSpread__default["default"]({}, bootstrapResponse), {}, {
7994
+ _this4.bootstrapData = _objectSpread__default["default"](_objectSpread__default["default"]({}, bootstrapResponse), {}, {
7918
7995
  microApps: bootstrapResponse.storyboards.map(storyboard => storyboard.app).filter(Boolean)
7919
7996
  });
7920
7997
  })();
@@ -7928,7 +8005,7 @@
7928
8005
  }
7929
8006
 
7930
8007
  fulfilStoryboard(storyboard) {
7931
- var _this4 = this;
8008
+ var _this5 = this;
7932
8009
 
7933
8010
  return _asyncToGenerator__default["default"](function* () {
7934
8011
  if (storyboard.$$fulfilled) {
@@ -7936,7 +8013,7 @@
7936
8013
  }
7937
8014
 
7938
8015
  if (!storyboard.$$fulfilling) {
7939
- storyboard.$$fulfilling = _this4.doFulfilStoryboard(storyboard);
8016
+ storyboard.$$fulfilling = _this5.doFulfilStoryboard(storyboard);
7940
8017
  }
7941
8018
 
7942
8019
  return storyboard.$$fulfilling;
@@ -7944,7 +8021,7 @@
7944
8021
  }
7945
8022
 
7946
8023
  doFulfilStoryboard(storyboard) {
7947
- var _this5 = this;
8024
+ var _this6 = this;
7948
8025
 
7949
8026
  return _asyncToGenerator__default["default"](function* () {
7950
8027
  if (window.STANDALONE_MICRO_APPS) {
@@ -7965,7 +8042,7 @@
7965
8042
  });
7966
8043
  }
7967
8044
 
7968
- _this5.postProcessStoryboard(storyboard);
8045
+ _this6.postProcessStoryboard(storyboard);
7969
8046
  })();
7970
8047
  }
7971
8048
 
@@ -7978,8 +8055,8 @@
7978
8055
  // Prefix to avoid conflict between brick package's i18n namespace.
7979
8056
  var i18nNamespace = getI18nNamespace("app", storyboard.app.id); // Support any language in `meta.i18n`.
7980
8057
 
7981
- Object.entries(storyboard.meta.i18n).forEach(_ref => {
7982
- var [lang, resources] = _ref;
8058
+ Object.entries(storyboard.meta.i18n).forEach(_ref4 => {
8059
+ var [lang, resources] = _ref4;
7983
8060
  i18next__default["default"].addResourceBundle(lang, i18nNamespace, resources);
7984
8061
  });
7985
8062
  }
@@ -8006,7 +8083,9 @@
8006
8083
  path: previewPath,
8007
8084
  bricks: [_objectSpread__default["default"]({
8008
8085
  brick: templateId
8009
- }, lodash.pick(settings, "properties"))]
8086
+ }, lodash.pick(settings, "properties"))],
8087
+ menu: false,
8088
+ exact: true
8010
8089
  };
8011
8090
 
8012
8091
  if (previewRouteIndex === -1) {
@@ -8017,34 +8096,30 @@
8017
8096
  }
8018
8097
 
8019
8098
  loadDepsOfStoryboard(storyboard) {
8020
- var _this6 = this;
8099
+ return this.gracefullyLoadDeps(this._loadDepsOfStoryboard, storyboard);
8100
+ }
8101
+
8102
+ gracefullyLoadDeps(fn) {
8103
+ var _arguments = arguments,
8104
+ _this7 = this;
8021
8105
 
8022
8106
  return _asyncToGenerator__default["default"](function* () {
8023
- var {
8024
- brickPackages,
8025
- templatePackages
8026
- } = _this6.bootstrapData;
8027
-
8028
- if (storyboard.dependsAll) {
8029
- var dllPath = window.DLL_PATH || {};
8030
- yield loadScriptOfDll(Object.values(dllPath));
8031
- yield loadScriptOfBricksOrTemplates(brickPackages.map(item => item.filePath).concat(templatePackages.map(item => item.filePath)));
8032
- yield loadAllLazyBricks();
8033
- } else {
8034
- // 先加载模板
8035
- var templateDeps = brickUtils.getTemplateDepsOfStoryboard(storyboard, templatePackages);
8036
- yield loadScriptOfBricksOrTemplates(templateDeps); // 加载模板后才能加工得到最终的构件表
8107
+ for (var _len = _arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
8108
+ args[_key - 1] = _arguments[_key];
8109
+ }
8037
8110
 
8038
- var {
8039
- dll,
8040
- deps,
8041
- bricks
8042
- } = brickUtils.getDllAndDepsOfStoryboard(yield brickUtils.asyncProcessStoryboard(storyboard, brickTemplateRegistry, templatePackages), brickPackages, {
8043
- ignoreBricksInUnusedCustomTemplates: true
8044
- });
8045
- yield loadScriptOfDll(dll);
8046
- yield loadScriptOfBricksOrTemplates(deps);
8047
- yield loadLazyBricks(bricks);
8111
+ try {
8112
+ yield fn(...args);
8113
+ } catch (e) {
8114
+ if (e instanceof Event && e.target instanceof HTMLScriptElement) {
8115
+ // The scripts maybe stale when a user stays in page while upgrades been applied.
8116
+ // So we force reloading again automatically.
8117
+ // NOTE: reload only once to avoid a infinite loop.
8118
+ yield _this7.reloadMicroApps();
8119
+ yield fn(...args);
8120
+ } else {
8121
+ throw e;
8122
+ }
8048
8123
  }
8049
8124
  })();
8050
8125
  }
@@ -8089,7 +8164,7 @@
8089
8164
  }
8090
8165
 
8091
8166
  loadDynamicBricksInBrickConf(brickConf) {
8092
- var _this7 = this;
8167
+ var _this8 = this;
8093
8168
 
8094
8169
  return _asyncToGenerator__default["default"](function* () {
8095
8170
  // Notice: `brickConf` contains runtime data,
@@ -8097,44 +8172,16 @@
8097
8172
  // which could cause stack overflow while traversing.
8098
8173
  var bricks = brickUtils.scanBricksInBrickConf(brickConf);
8099
8174
  var processors = brickUtils.scanProcessorsInAny(brickConf);
8100
- yield _this7.loadDynamicBricks(bricks, processors);
8175
+ yield _this8.loadDynamicBricks(bricks, processors);
8101
8176
  })();
8102
8177
  }
8103
8178
 
8104
8179
  loadDynamicBricks(bricks, processors) {
8105
- var _this8 = this;
8106
-
8107
- return _asyncToGenerator__default["default"](function* () {
8108
- var filteredBricks = bricks.filter( // Only try to load undefined custom elements.
8109
- item => !customElements.get(item)); // Try to load deps for dynamic added bricks.
8110
-
8111
- var {
8112
- dll,
8113
- deps
8114
- } = brickUtils.getDllAndDepsByResource({
8115
- bricks: filteredBricks,
8116
- processors
8117
- }, _this8.bootstrapData.brickPackages);
8118
- yield loadScriptOfDll(dll);
8119
- yield loadScriptOfBricksOrTemplates(deps);
8120
- yield loadLazyBricks(filteredBricks);
8121
- })();
8180
+ return this.gracefullyLoadDeps(this._loadDynamicBricks, bricks, processors);
8122
8181
  }
8123
8182
 
8124
8183
  loadEditorBricks(editorBricks) {
8125
- var _this9 = this;
8126
-
8127
- return _asyncToGenerator__default["default"](function* () {
8128
- var {
8129
- dll,
8130
- deps
8131
- } = brickUtils.getDllAndDepsByResource({
8132
- editorBricks: editorBricks.filter( // Only try to load undefined custom elements.
8133
- item => !customElements.get(item))
8134
- }, _this9.bootstrapData.brickPackages);
8135
- yield loadScriptOfDll(dll);
8136
- yield loadScriptOfBricksOrTemplates(deps);
8137
- })();
8184
+ return this.gracefullyLoadDeps(this._loadEditorBricks, editorBricks);
8138
8185
  }
8139
8186
 
8140
8187
  firstRendered() {
@@ -8235,10 +8282,10 @@
8235
8282
  }
8236
8283
 
8237
8284
  getMicroAppApiOrchestrationMapAsync() {
8238
- var _this10 = this;
8285
+ var _this9 = this;
8239
8286
 
8240
8287
  return _asyncToGenerator__default["default"](function* () {
8241
- return yield _this10.allMicroAppApiOrchestrationPromise;
8288
+ return yield _this9.allMicroAppApiOrchestrationPromise;
8242
8289
  })();
8243
8290
  }
8244
8291
 
@@ -8330,14 +8377,14 @@
8330
8377
  }
8331
8378
 
8332
8379
  getRelatedAppsAsync(appId) {
8333
- var _this11 = this;
8380
+ var _this10 = this;
8334
8381
 
8335
8382
  return _asyncToGenerator__default["default"](function* () {
8336
8383
  if (!appId) {
8337
8384
  return [];
8338
8385
  }
8339
8386
 
8340
- var allRelatedApps = yield _this11.allRelatedAppsPromise;
8387
+ var allRelatedApps = yield _this10.allRelatedAppsPromise;
8341
8388
  var thisApp = allRelatedApps.find(item => item.microAppId === appId);
8342
8389
 
8343
8390
  if (!thisApp) {
@@ -8349,38 +8396,38 @@
8349
8396
  }
8350
8397
 
8351
8398
  updateWorkspaceStack() {
8352
- var _this12 = this;
8399
+ var _this11 = this;
8353
8400
 
8354
8401
  return _asyncToGenerator__default["default"](function* () {
8355
- if (_this12.currentApp && _this12.currentApp.id) {
8402
+ if (_this11.currentApp && _this11.currentApp.id) {
8356
8403
  var workspace = {
8357
- appId: _this12.currentApp.id,
8358
- appName: _this12.currentApp.name,
8359
- appLocaleName: _this12.currentApp.localeName,
8360
- url: _this12.currentUrl
8404
+ appId: _this11.currentApp.id,
8405
+ appName: _this11.currentApp.name,
8406
+ appLocaleName: _this11.currentApp.localeName,
8407
+ url: _this11.currentUrl
8361
8408
  };
8362
8409
 
8363
- if (_this12.workspaceStack.length > 0) {
8364
- var previousWorkspace = _this12.workspaceStack[_this12.workspaceStack.length - 1];
8410
+ if (_this11.workspaceStack.length > 0) {
8411
+ var previousWorkspace = _this11.workspaceStack[_this11.workspaceStack.length - 1];
8365
8412
 
8366
- var _relatedApps = yield _this12.getRelatedAppsAsync(previousWorkspace.appId);
8413
+ var _relatedApps = yield _this11.getRelatedAppsAsync(previousWorkspace.appId);
8367
8414
 
8368
- if (_relatedApps.some(item => item.microAppId === _this12.currentApp.id)) {
8415
+ if (_relatedApps.some(item => item.microAppId === _this11.currentApp.id)) {
8369
8416
  Object.assign(previousWorkspace, workspace);
8370
8417
  return;
8371
8418
  }
8372
8419
  }
8373
8420
 
8374
- var relatedApps = yield _this12.getRelatedAppsAsync(_this12.currentApp.id);
8421
+ var relatedApps = yield _this11.getRelatedAppsAsync(_this11.currentApp.id);
8375
8422
 
8376
8423
  if (relatedApps.length > 0) {
8377
- _this12.workspaceStack.push(workspace);
8424
+ _this11.workspaceStack.push(workspace);
8378
8425
 
8379
8426
  return;
8380
8427
  }
8381
8428
  }
8382
8429
 
8383
- _this12.workspaceStack = [];
8430
+ _this11.workspaceStack = [];
8384
8431
  })();
8385
8432
  }
8386
8433
 
@@ -8403,9 +8450,9 @@
8403
8450
  }
8404
8451
 
8405
8452
  getFeatureFlags() {
8406
- var _this$bootstrapData, _this$bootstrapData$s3;
8453
+ var _this$bootstrapData, _this$bootstrapData$s;
8407
8454
 
8408
- return Object.assign({}, (_this$bootstrapData = this.bootstrapData) === null || _this$bootstrapData === void 0 ? void 0 : (_this$bootstrapData$s3 = _this$bootstrapData.settings) === null || _this$bootstrapData$s3 === void 0 ? void 0 : _this$bootstrapData$s3.featureFlags);
8455
+ return Object.assign({}, (_this$bootstrapData = this.bootstrapData) === null || _this$bootstrapData === void 0 ? void 0 : (_this$bootstrapData$s = _this$bootstrapData.settings) === null || _this$bootstrapData$s === void 0 ? void 0 : _this$bootstrapData$s.featureFlags);
8409
8456
  }
8410
8457
 
8411
8458
  getStandaloneMenus(menuId) {
@@ -8421,22 +8468,22 @@
8421
8468
  }
8422
8469
 
8423
8470
  getProviderBrick(provider) {
8424
- var _this13 = this;
8471
+ var _this12 = this;
8425
8472
 
8426
8473
  return _asyncToGenerator__default["default"](function* () {
8427
8474
  if (isCustomApiProvider(provider)) {
8428
8475
  provider = CUSTOM_API_PROVIDER;
8429
8476
  }
8430
8477
 
8431
- if (_this13.providerRepository.has(provider)) {
8432
- return _this13.providerRepository.get(provider);
8478
+ if (_this12.providerRepository.has(provider)) {
8479
+ return _this12.providerRepository.get(provider);
8433
8480
  }
8434
8481
 
8435
8482
  if (provider === CUSTOM_API_PROVIDER && !customElements.get(provider)) {
8436
8483
  registerCustomApi();
8437
8484
  }
8438
8485
 
8439
- yield _this13.loadDynamicBricks([provider]);
8486
+ yield _this12.loadDynamicBricks([provider]);
8440
8487
 
8441
8488
  if (!customElements.get(provider)) {
8442
8489
  throw new Error("Provider not defined: \"".concat(provider, "\"."));
@@ -8444,7 +8491,7 @@
8444
8491
 
8445
8492
  var brick = document.createElement(provider);
8446
8493
 
8447
- _this13.providerRepository.set(provider, brick);
8494
+ _this12.providerRepository.set(provider, brick);
8448
8495
 
8449
8496
  return brick;
8450
8497
  })();
@@ -8453,7 +8500,7 @@
8453
8500
  } // Since `@next-dll/editor-bricks-helper` depends on `@next-dll/react-dnd`,
8454
8501
  // always load react-dnd before loading editor-bricks-helper.
8455
8502
 
8456
- function loadScriptOfDll(_x) {
8503
+ function loadScriptOfDll(_x5) {
8457
8504
  return _loadScriptOfDll.apply(this, arguments);
8458
8505
  }
8459
8506
 
@@ -8628,7 +8675,8 @@
8628
8675
  misc.isInIframe = true;
8629
8676
 
8630
8677
  try {
8631
- misc.isInIframeOfLegacyConsole = window.origin === window.parent.origin;
8678
+ // Handle when previewing in visual builder by iframe.
8679
+ misc.isInIframeOfLegacyConsole = window.origin === window.parent.origin && getBasePath() === "/next/" && !window.parent.location.pathname.startsWith("/next/");
8632
8680
  } catch (e) {// do nothing
8633
8681
  }
8634
8682
  }
@@ -9230,6 +9278,8 @@
9230
9278
  }
9231
9279
 
9232
9280
  if (expandedBrickConf.bg) {
9281
+ // A bg brick has no slotId.
9282
+ brick.slotId = undefined;
9233
9283
  appendBrick(brick, _this6.kernel.mountPoints.bg);
9234
9284
  } else {
9235
9285
  if (expandedBrickConf.portal) {
@@ -10167,7 +10217,9 @@
10167
10217
  path: "${APP.homepage}/_dev_only_/template-preview/:templateId",
10168
10218
  bricks: [{
10169
10219
  brick: "span"
10170
- }]
10220
+ }],
10221
+ menu: false,
10222
+ exact: true
10171
10223
  }), undefined, mountRoutesResult);
10172
10224
  } catch (error) {
10173
10225
  // eslint-disable-next-line no-console
@@ -13619,26 +13671,32 @@
13619
13671
  var response = React.useRef();
13620
13672
  var data = React.useRef(defaults.data);
13621
13673
  var forceUpdate = React.useReducer(() => ({}), [])[1];
13622
- var doFetch = React.useCallback( /*#__PURE__*/_asyncToGenerator__default["default"](function* () {
13623
- try {
13624
- error.current = undefined;
13625
- if (!suspense) setLoading(true);
13674
+ var doFetch = React.useCallback( /*#__PURE__*/function () {
13675
+ var _ref = _asyncToGenerator__default["default"](function* (provider) {
13676
+ try {
13677
+ error.current = undefined;
13678
+ if (!suspense) setLoading(true);
13679
+
13680
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
13681
+ args[_key - 1] = arguments[_key];
13682
+ }
13626
13683
 
13627
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
13628
- args[_key] = arguments[_key];
13684
+ var newRes = yield fetch(provider, ...args);
13685
+ response.current = newRes;
13686
+ data.current = transform(data.current, newRes);
13687
+ } catch (e) {
13688
+ error.current = e;
13629
13689
  }
13630
13690
 
13631
- var newRes = yield fetch(provider, ...args);
13632
- response.current = newRes;
13633
- data.current = transform(data.current, newRes);
13634
- } catch (e) {
13635
- error.current = e;
13636
- }
13691
+ if (!suspense) setLoading(false);
13692
+ if (error.current) onError(error.current);
13693
+ return data.current;
13694
+ });
13637
13695
 
13638
- if (!suspense) setLoading(false);
13639
- if (error.current) onError(error.current);
13640
- return data.current;
13641
- }), [provider, customOptions, dependencies, requestInit, suspense, transform, defaults.data, onError]);
13696
+ return function (_x) {
13697
+ return _ref.apply(this, arguments);
13698
+ };
13699
+ }(), [provider, customOptions, dependencies, requestInit, suspense, transform, defaults.data, onError]);
13642
13700
  var makeFetch = React.useCallback( /*#__PURE__*/function () {
13643
13701
  var _ref2 = _asyncToGenerator__default["default"](function* (providerOrBody, args) {
13644
13702
  var providerStr = provider;
@@ -13658,7 +13716,7 @@
13658
13716
 
13659
13717
  if (suspense) {
13660
13718
  return _asyncToGenerator__default["default"](function* () {
13661
- suspender.current = doFetch(...actualArgs).then(newData => {
13719
+ suspender.current = doFetch(providerStr, ...actualArgs).then(newData => {
13662
13720
  suspenseStatus.current = "success";
13663
13721
  return newData;
13664
13722
  }, error => {
@@ -13671,10 +13729,10 @@
13671
13729
  })();
13672
13730
  }
13673
13731
 
13674
- return doFetch(...actualArgs);
13732
+ return doFetch(providerStr, ...actualArgs);
13675
13733
  });
13676
13734
 
13677
- return function (_x, _x2) {
13735
+ return function (_x2, _x3) {
13678
13736
  return _ref2.apply(this, arguments);
13679
13737
  };
13680
13738
  }(), [doFetch]);