@next-core/brick-kit 2.159.3 → 2.159.5

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
@@ -8110,6 +8110,9 @@ class Kernel {
8110
8110
  yield loadScriptOfDll(Object.values(dllPath));
8111
8111
  yield loadScriptOfBricksOrTemplates(brickPackages.map(item => item.filePath).concat(templatePackages.map(item => item.filePath)));
8112
8112
  yield loadAllLazyBricks();
8113
+ return {
8114
+ pendingTask: Promise.resolve()
8115
+ };
8113
8116
  } else {
8114
8117
  // 先加载模板
8115
8118
  var templateDeps = getTemplateDepsOfStoryboard(storyboard, templatePackages);
@@ -8118,13 +8121,19 @@ class Kernel {
8118
8121
  var {
8119
8122
  dll,
8120
8123
  deps,
8121
- bricks
8124
+ bricks,
8125
+ byProcessors
8122
8126
  } = getDllAndDepsOfStoryboard(yield asyncProcessStoryboard(storyboard, brickTemplateRegistry, templatePackages), brickPackages, {
8123
8127
  ignoreBricksInUnusedCustomTemplates: true
8124
8128
  });
8125
- yield loadScriptOfDll(dll);
8126
- yield loadScriptOfBricksOrTemplates(deps);
8127
- yield loadLazyBricks(bricks);
8129
+ // 需要先阻塞加载 Custom Processors。
8130
+ yield loadScriptOfDll(byProcessors.dll);
8131
+ yield loadScriptOfBricksOrTemplates(byProcessors.deps);
8132
+ // 加载构件资源时,不再阻塞后续业务数据的加载,在挂载构件时再等待该任务完成。
8133
+ // 挂载构件可能包括:Provider 构件实时挂载、路由准备完成后的统一挂载等。
8134
+ return {
8135
+ pendingTask: loadScriptOfDll(dll).then(() => loadScriptOfBricksOrTemplates(deps)).then(() => loadLazyBricks(bricks))
8136
+ };
8128
8137
  }
8129
8138
  });
8130
8139
  return function (_x) {
@@ -8527,14 +8536,14 @@ class Kernel {
8527
8536
  args[_key - 1] = _arguments[_key];
8528
8537
  }
8529
8538
  try {
8530
- yield fn(...args);
8539
+ return yield fn(...args);
8531
8540
  } catch (e) {
8532
8541
  if (e instanceof Event && e.target instanceof HTMLScriptElement) {
8533
8542
  // The scripts maybe stale when a user stays in page while upgrades been applied.
8534
8543
  // So we force reloading again automatically.
8535
8544
  // NOTE: reload only once to avoid a infinite loop.
8536
8545
  yield _this8.reloadMicroApps();
8537
- yield fn(...args);
8546
+ return yield fn(...args);
8538
8547
  } else {
8539
8548
  throw e;
8540
8549
  }
@@ -9883,6 +9892,7 @@ class LocationContext {
9883
9892
  if (expandedBrickConf.bg) {
9884
9893
  // A bg brick has no slotId.
9885
9894
  brick.slotId = undefined;
9895
+ yield _this7.kernel.loadDynamicBricks([brick.type]);
9886
9896
  appendBrick(brick, _this7.kernel.mountPoints.bg);
9887
9897
  } else {
9888
9898
  if (expandedBrickConf.portal) {
@@ -10844,6 +10854,9 @@ class Router {
10844
10854
  var tracePageEnd = (_apiAnalyzer$getInsta = apiAnalyzer.getInstance()) === null || _apiAnalyzer$getInsta === void 0 ? void 0 : _apiAnalyzer$getInsta.tracePage();
10845
10855
  var locationContext = _this3.locationContext = new LocationContext(_this3.kernel, location);
10846
10856
  var storyboard = locationContext.matchStoryboard(_this3.kernel.bootstrapData.storyboards);
10857
+
10858
+ /** Pending task for loading bricks */
10859
+ var pendingTask;
10847
10860
  if (storyboard) {
10848
10861
  var _storyboard$meta, _storyboard$meta2, _storyboard$meta3;
10849
10862
  yield _this3.kernel.fulfilStoryboard(storyboard);
@@ -10875,7 +10888,9 @@ class Router {
10875
10888
 
10876
10889
  // 如果找到匹配的 storyboard,那么根据路由匹配得到的 sub-storyboard 加载它的依赖库。
10877
10890
  var subStoryboard = _this3.locationContext.getSubStoryboardByRoute(storyboard);
10878
- yield _this3.kernel.loadDepsOfStoryboard(subStoryboard);
10891
+ ({
10892
+ pendingTask
10893
+ } = yield _this3.kernel.loadDepsOfStoryboard(subStoryboard));
10879
10894
 
10880
10895
  // 注册 Storyboard 中定义的自定义模板和函数。
10881
10896
  _this3.kernel.registerCustomTemplatesInStoryboard(storyboard);
@@ -11051,14 +11066,21 @@ class Router {
11051
11066
  }
11052
11067
  _this3.setNavConfig(mountRoutesResult);
11053
11068
  _this3.kernel.toggleLegacyIframe(actualLegacy === "iframe");
11054
- menuInBg.forEach(brick => {
11055
- appendBrick(brick, mountPoints.portal);
11056
- });
11069
+ yield Promise.all(menuInBg.map( /*#__PURE__*/function () {
11070
+ var _ref2 = _asyncToGenerator$3(function* (brick) {
11071
+ yield _this3.kernel.loadDynamicBricks([brick.type]);
11072
+ appendBrick(brick, mountPoints.portal);
11073
+ });
11074
+ return function (_x3) {
11075
+ return _ref2.apply(this, arguments);
11076
+ };
11077
+ }()));
11057
11078
 
11058
11079
  // When we have a matched route other than an abstract route,
11059
11080
  // we say *page found*, otherwise, *page not found*.
11060
11081
  if (route && route.type !== "routes" || failed) {
11061
11082
  var _this3$kernel$bootstr, _this3$kernel$bootstr2, _getAuth$license;
11083
+ yield pendingTask;
11062
11084
  main.length > 0 && mountTree(main, mountPoints.main);
11063
11085
  portal.length > 0 && mountTree(portal, mountPoints.portal);
11064
11086
  afterMountTree(mountPoints.main);