@next-core/brick-kit 2.117.5 → 2.117.8

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,40 @@
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.8](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.117.7...@next-core/brick-kit@2.117.8) (2022-04-14)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * put template preview route before others ([590153d](https://github.com/easyops-cn/next-core/commit/590153d5ce84c4ba0f410931d6c35846342c3436))
12
+
13
+
14
+
15
+
16
+
17
+ ## [2.117.7](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.117.6...@next-core/brick-kit@2.117.7) (2022-04-12)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **template-preview:** support setting lifeCycle and events ([275cf02](https://github.com/easyops-cn/next-core/commit/275cf02fe2a2ce46241cb55d93b4822768e20459))
23
+
24
+
25
+
26
+
27
+
28
+ ## [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)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * handle checking isInIframeOfLegacyConsole when previewing in visual builder by iframe ([8e347b9](https://github.com/easyops-cn/next-core/commit/8e347b969033992412ee349ecd6f633141be95d5))
34
+ * reload bootstrap again when loading bricks failed ([f022593](https://github.com/easyops-cn/next-core/commit/f0225934d5a1694ee06f96f3d1b5cd1c9b92c1b2))
35
+
36
+
37
+
38
+
39
+
6
40
  ## [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)
7
41
 
8
42
 
@@ -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,7 @@
8006
8083
  path: previewPath,
8007
8084
  bricks: [_objectSpread__default["default"]({
8008
8085
  brick: templateId
8009
- }, lodash.pick(settings, "properties"))],
8086
+ }, lodash.pick(settings, "properties", "events", "lifeCycle"))],
8010
8087
  menu: false,
8011
8088
  exact: true
8012
8089
  };
@@ -8019,34 +8096,30 @@
8019
8096
  }
8020
8097
 
8021
8098
  loadDepsOfStoryboard(storyboard) {
8022
- var _this6 = this;
8099
+ return this.gracefullyLoadDeps(this._loadDepsOfStoryboard, storyboard);
8100
+ }
8101
+
8102
+ gracefullyLoadDeps(fn) {
8103
+ var _arguments = arguments,
8104
+ _this7 = this;
8023
8105
 
8024
8106
  return _asyncToGenerator__default["default"](function* () {
8025
- var {
8026
- brickPackages,
8027
- templatePackages
8028
- } = _this6.bootstrapData;
8029
-
8030
- if (storyboard.dependsAll) {
8031
- var dllPath = window.DLL_PATH || {};
8032
- yield loadScriptOfDll(Object.values(dllPath));
8033
- yield loadScriptOfBricksOrTemplates(brickPackages.map(item => item.filePath).concat(templatePackages.map(item => item.filePath)));
8034
- yield loadAllLazyBricks();
8035
- } else {
8036
- // 先加载模板
8037
- var templateDeps = brickUtils.getTemplateDepsOfStoryboard(storyboard, templatePackages);
8038
- 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
+ }
8039
8110
 
8040
- var {
8041
- dll,
8042
- deps,
8043
- bricks
8044
- } = brickUtils.getDllAndDepsOfStoryboard(yield brickUtils.asyncProcessStoryboard(storyboard, brickTemplateRegistry, templatePackages), brickPackages, {
8045
- ignoreBricksInUnusedCustomTemplates: true
8046
- });
8047
- yield loadScriptOfDll(dll);
8048
- yield loadScriptOfBricksOrTemplates(deps);
8049
- 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
+ }
8050
8123
  }
8051
8124
  })();
8052
8125
  }
@@ -8091,7 +8164,7 @@
8091
8164
  }
8092
8165
 
8093
8166
  loadDynamicBricksInBrickConf(brickConf) {
8094
- var _this7 = this;
8167
+ var _this8 = this;
8095
8168
 
8096
8169
  return _asyncToGenerator__default["default"](function* () {
8097
8170
  // Notice: `brickConf` contains runtime data,
@@ -8099,44 +8172,16 @@
8099
8172
  // which could cause stack overflow while traversing.
8100
8173
  var bricks = brickUtils.scanBricksInBrickConf(brickConf);
8101
8174
  var processors = brickUtils.scanProcessorsInAny(brickConf);
8102
- yield _this7.loadDynamicBricks(bricks, processors);
8175
+ yield _this8.loadDynamicBricks(bricks, processors);
8103
8176
  })();
8104
8177
  }
8105
8178
 
8106
8179
  loadDynamicBricks(bricks, processors) {
8107
- var _this8 = this;
8108
-
8109
- return _asyncToGenerator__default["default"](function* () {
8110
- var filteredBricks = bricks.filter( // Only try to load undefined custom elements.
8111
- item => !customElements.get(item)); // Try to load deps for dynamic added bricks.
8112
-
8113
- var {
8114
- dll,
8115
- deps
8116
- } = brickUtils.getDllAndDepsByResource({
8117
- bricks: filteredBricks,
8118
- processors
8119
- }, _this8.bootstrapData.brickPackages);
8120
- yield loadScriptOfDll(dll);
8121
- yield loadScriptOfBricksOrTemplates(deps);
8122
- yield loadLazyBricks(filteredBricks);
8123
- })();
8180
+ return this.gracefullyLoadDeps(this._loadDynamicBricks, bricks, processors);
8124
8181
  }
8125
8182
 
8126
8183
  loadEditorBricks(editorBricks) {
8127
- var _this9 = this;
8128
-
8129
- return _asyncToGenerator__default["default"](function* () {
8130
- var {
8131
- dll,
8132
- deps
8133
- } = brickUtils.getDllAndDepsByResource({
8134
- editorBricks: editorBricks.filter( // Only try to load undefined custom elements.
8135
- item => !customElements.get(item))
8136
- }, _this9.bootstrapData.brickPackages);
8137
- yield loadScriptOfDll(dll);
8138
- yield loadScriptOfBricksOrTemplates(deps);
8139
- })();
8184
+ return this.gracefullyLoadDeps(this._loadEditorBricks, editorBricks);
8140
8185
  }
8141
8186
 
8142
8187
  firstRendered() {
@@ -8237,10 +8282,10 @@
8237
8282
  }
8238
8283
 
8239
8284
  getMicroAppApiOrchestrationMapAsync() {
8240
- var _this10 = this;
8285
+ var _this9 = this;
8241
8286
 
8242
8287
  return _asyncToGenerator__default["default"](function* () {
8243
- return yield _this10.allMicroAppApiOrchestrationPromise;
8288
+ return yield _this9.allMicroAppApiOrchestrationPromise;
8244
8289
  })();
8245
8290
  }
8246
8291
 
@@ -8332,14 +8377,14 @@
8332
8377
  }
8333
8378
 
8334
8379
  getRelatedAppsAsync(appId) {
8335
- var _this11 = this;
8380
+ var _this10 = this;
8336
8381
 
8337
8382
  return _asyncToGenerator__default["default"](function* () {
8338
8383
  if (!appId) {
8339
8384
  return [];
8340
8385
  }
8341
8386
 
8342
- var allRelatedApps = yield _this11.allRelatedAppsPromise;
8387
+ var allRelatedApps = yield _this10.allRelatedAppsPromise;
8343
8388
  var thisApp = allRelatedApps.find(item => item.microAppId === appId);
8344
8389
 
8345
8390
  if (!thisApp) {
@@ -8351,38 +8396,38 @@
8351
8396
  }
8352
8397
 
8353
8398
  updateWorkspaceStack() {
8354
- var _this12 = this;
8399
+ var _this11 = this;
8355
8400
 
8356
8401
  return _asyncToGenerator__default["default"](function* () {
8357
- if (_this12.currentApp && _this12.currentApp.id) {
8402
+ if (_this11.currentApp && _this11.currentApp.id) {
8358
8403
  var workspace = {
8359
- appId: _this12.currentApp.id,
8360
- appName: _this12.currentApp.name,
8361
- appLocaleName: _this12.currentApp.localeName,
8362
- url: _this12.currentUrl
8404
+ appId: _this11.currentApp.id,
8405
+ appName: _this11.currentApp.name,
8406
+ appLocaleName: _this11.currentApp.localeName,
8407
+ url: _this11.currentUrl
8363
8408
  };
8364
8409
 
8365
- if (_this12.workspaceStack.length > 0) {
8366
- var previousWorkspace = _this12.workspaceStack[_this12.workspaceStack.length - 1];
8410
+ if (_this11.workspaceStack.length > 0) {
8411
+ var previousWorkspace = _this11.workspaceStack[_this11.workspaceStack.length - 1];
8367
8412
 
8368
- var _relatedApps = yield _this12.getRelatedAppsAsync(previousWorkspace.appId);
8413
+ var _relatedApps = yield _this11.getRelatedAppsAsync(previousWorkspace.appId);
8369
8414
 
8370
- if (_relatedApps.some(item => item.microAppId === _this12.currentApp.id)) {
8415
+ if (_relatedApps.some(item => item.microAppId === _this11.currentApp.id)) {
8371
8416
  Object.assign(previousWorkspace, workspace);
8372
8417
  return;
8373
8418
  }
8374
8419
  }
8375
8420
 
8376
- var relatedApps = yield _this12.getRelatedAppsAsync(_this12.currentApp.id);
8421
+ var relatedApps = yield _this11.getRelatedAppsAsync(_this11.currentApp.id);
8377
8422
 
8378
8423
  if (relatedApps.length > 0) {
8379
- _this12.workspaceStack.push(workspace);
8424
+ _this11.workspaceStack.push(workspace);
8380
8425
 
8381
8426
  return;
8382
8427
  }
8383
8428
  }
8384
8429
 
8385
- _this12.workspaceStack = [];
8430
+ _this11.workspaceStack = [];
8386
8431
  })();
8387
8432
  }
8388
8433
 
@@ -8405,9 +8450,9 @@
8405
8450
  }
8406
8451
 
8407
8452
  getFeatureFlags() {
8408
- var _this$bootstrapData, _this$bootstrapData$s3;
8453
+ var _this$bootstrapData, _this$bootstrapData$s;
8409
8454
 
8410
- 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);
8411
8456
  }
8412
8457
 
8413
8458
  getStandaloneMenus(menuId) {
@@ -8423,22 +8468,22 @@
8423
8468
  }
8424
8469
 
8425
8470
  getProviderBrick(provider) {
8426
- var _this13 = this;
8471
+ var _this12 = this;
8427
8472
 
8428
8473
  return _asyncToGenerator__default["default"](function* () {
8429
8474
  if (isCustomApiProvider(provider)) {
8430
8475
  provider = CUSTOM_API_PROVIDER;
8431
8476
  }
8432
8477
 
8433
- if (_this13.providerRepository.has(provider)) {
8434
- return _this13.providerRepository.get(provider);
8478
+ if (_this12.providerRepository.has(provider)) {
8479
+ return _this12.providerRepository.get(provider);
8435
8480
  }
8436
8481
 
8437
8482
  if (provider === CUSTOM_API_PROVIDER && !customElements.get(provider)) {
8438
8483
  registerCustomApi();
8439
8484
  }
8440
8485
 
8441
- yield _this13.loadDynamicBricks([provider]);
8486
+ yield _this12.loadDynamicBricks([provider]);
8442
8487
 
8443
8488
  if (!customElements.get(provider)) {
8444
8489
  throw new Error("Provider not defined: \"".concat(provider, "\"."));
@@ -8446,7 +8491,7 @@
8446
8491
 
8447
8492
  var brick = document.createElement(provider);
8448
8493
 
8449
- _this13.providerRepository.set(provider, brick);
8494
+ _this12.providerRepository.set(provider, brick);
8450
8495
 
8451
8496
  return brick;
8452
8497
  })();
@@ -8455,7 +8500,7 @@
8455
8500
  } // Since `@next-dll/editor-bricks-helper` depends on `@next-dll/react-dnd`,
8456
8501
  // always load react-dnd before loading editor-bricks-helper.
8457
8502
 
8458
- function loadScriptOfDll(_x) {
8503
+ function loadScriptOfDll(_x5) {
8459
8504
  return _loadScriptOfDll.apply(this, arguments);
8460
8505
  }
8461
8506
 
@@ -8630,7 +8675,8 @@
8630
8675
  misc.isInIframe = true;
8631
8676
 
8632
8677
  try {
8633
- 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/");
8634
8680
  } catch (e) {// do nothing
8635
8681
  }
8636
8682
  }
@@ -10167,14 +10213,14 @@
10167
10213
 
10168
10214
  try {
10169
10215
  yield locationContext.mountRoutes( // Concat with a placeholder when loading template preview settings.
10170
- storyboard.routes.concat({
10216
+ [{
10171
10217
  path: "${APP.homepage}/_dev_only_/template-preview/:templateId",
10172
10218
  bricks: [{
10173
10219
  brick: "span"
10174
10220
  }],
10175
10221
  menu: false,
10176
10222
  exact: true
10177
- }), undefined, mountRoutesResult);
10223
+ }].concat(storyboard.routes), undefined, mountRoutesResult);
10178
10224
  } catch (error) {
10179
10225
  // eslint-disable-next-line no-console
10180
10226
  console.error(error); // Redirect to login page if not logged in.