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