@next-core/brick-kit 2.174.3 → 2.175.1

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.
@@ -1802,6 +1802,7 @@
1802
1802
  _defineProperty__default["default"](this, "data", new Map());
1803
1803
  _defineProperty__default["default"](this, "batchUpdate", false);
1804
1804
  _defineProperty__default["default"](this, "batchUpdateContextsNames", []);
1805
+ _defineProperty__default["default"](this, "batchTriggerContextsNamesMap", new Map());
1805
1806
  _defineProperty__default["default"](this, "tplContextId", void 0);
1806
1807
  _defineProperty__default["default"](this, "formContextId", void 0);
1807
1808
  _defineProperty__default["default"](this, "eventName", void 0);
@@ -2038,6 +2039,9 @@
2038
2039
  keyword: "CTX"
2039
2040
  };
2040
2041
  }
2042
+ getContextTriggerSetByLifecycle(lifecycle) {
2043
+ return this.batchTriggerContextsNamesMap.get(lifecycle) || [];
2044
+ }
2041
2045
  }
2042
2046
  function resolveStoryboardContext(_x, _x2, _x3, _x4) {
2043
2047
  return _resolveStoryboardContext.apply(this, arguments);
@@ -2061,6 +2065,7 @@
2061
2065
  });
2062
2066
  return _resolveStoryboardContext.apply(this, arguments);
2063
2067
  }
2068
+ var supportContextResolveTriggerBrickLifeCycle = ["onBeforePageLoad", "onPageLoad", "onBeforePageLeave", "onPageLeave", "onAnchorLoad", "onAnchorUnload"];
2064
2069
  function resolveNormalStoryboardContext(_x5, _x6, _x7, _x8) {
2065
2070
  return _resolveNormalStoryboardContext.apply(this, arguments);
2066
2071
  }
@@ -2094,6 +2099,20 @@
2094
2099
  isLazyResolve = contextConf.resolve.lazy;
2095
2100
  if (!isLazyResolve) {
2096
2101
  value = yield load();
2102
+ } else if (isLazyResolve && contextConf.resolve.trigger) {
2103
+ var lifecycleName = contextConf.resolve.trigger;
2104
+ if (supportContextResolveTriggerBrickLifeCycle.includes(lifecycleName)) {
2105
+ var contextNameArray = storyboardContextWrapper.batchTriggerContextsNamesMap.get(lifecycleName) || [];
2106
+ contextNameArray.push({
2107
+ name: contextConf.name,
2108
+ type: storyboardContextWrapper.tplContextId ? "state" : "context",
2109
+ tplContextId: storyboardContextWrapper.tplContextId
2110
+ });
2111
+ storyboardContextWrapper.batchTriggerContextsNamesMap.set(lifecycleName, contextNameArray);
2112
+ } else {
2113
+ // eslint-disable-next-line no-console
2114
+ console.error("unsupported lifecycle: \"".concat(lifecycleName, "\""));
2115
+ }
2097
2116
  }
2098
2117
  } else if (!brickUtils.hasOwnProperty(contextConf, "value")) {
2099
2118
  return false;
@@ -2208,6 +2227,9 @@
2208
2227
  function getCustomTemplateContext(tplContextId) {
2209
2228
  return tplContextMap.get(tplContextId);
2210
2229
  }
2230
+ function getCustomContextTriggerListByLifecycle(lifecycle) {
2231
+ return [...tplContextMap.values()].map(tplContext => tplContext.state.getContextTriggerSetByLifecycle(lifecycle)).filter(trigger => trigger.length > 0).flat(1);
2232
+ }
2211
2233
 
2212
2234
  var MediaBreakpoint;
2213
2235
  (function (MediaBreakpoint) {
@@ -9535,7 +9557,9 @@
9535
9557
  }
9536
9558
  getFeatureFlags() {
9537
9559
  var _this$bootstrapData, _this$bootstrapData$s, _this$nextApp, _this$nextApp$config, _this$nextApp$config$;
9538
- 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, (_this$nextApp = this.nextApp) === null || _this$nextApp === void 0 ? void 0 : (_this$nextApp$config = _this$nextApp.config) === null || _this$nextApp$config === void 0 ? void 0 : (_this$nextApp$config$ = _this$nextApp$config.settings) === null || _this$nextApp$config$ === void 0 ? void 0 : _this$nextApp$config$.featureFlags);
9560
+ var flags = _objectSpread__default["default"](_objectSpread__default["default"]({}, (_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), (_this$nextApp = this.nextApp) === null || _this$nextApp === void 0 ? void 0 : (_this$nextApp$config = _this$nextApp.config) === null || _this$nextApp$config === void 0 ? void 0 : (_this$nextApp$config$ = _this$nextApp$config.settings) === null || _this$nextApp$config$ === void 0 ? void 0 : _this$nextApp$config$.featureFlags);
9561
+ delete flags["migrate-to-brick-next-v3"];
9562
+ return flags;
9539
9563
  }
9540
9564
  getStandaloneMenus(menuId, isPreFetch) {
9541
9565
  var _this12 = this;
@@ -10888,9 +10912,11 @@
10888
10912
  }
10889
10913
  }
10890
10914
  handleBeforePageLoad() {
10915
+ this.attachContextTriggerToLifecycle("onBeforePageLoad", this.beforePageLoadHandlers);
10891
10916
  this.dispatchLifeCycleEvent(new CustomEvent("page.beforeLoad"), this.beforePageLoadHandlers);
10892
10917
  }
10893
10918
  handlePageLoad() {
10919
+ this.attachContextTriggerToLifecycle("onPageLoad", this.pageLoadHandlers);
10894
10920
  var event = new CustomEvent("page.load");
10895
10921
  this.dispatchLifeCycleEvent(event, this.pageLoadHandlers);
10896
10922
 
@@ -10898,16 +10924,19 @@
10898
10924
  window.dispatchEvent(event);
10899
10925
  }
10900
10926
  handleBeforePageLeave(detail) {
10927
+ this.attachContextTriggerToLifecycle("onBeforePageLeave", this.beforePageLeaveHandlers);
10901
10928
  this.dispatchLifeCycleEvent(new CustomEvent("page.beforeLeave", {
10902
10929
  detail
10903
10930
  }), this.beforePageLeaveHandlers);
10904
10931
  }
10905
10932
  handlePageLeave() {
10933
+ this.attachContextTriggerToLifecycle("onPageLeave", this.pageLeaveHandlers);
10906
10934
  this.dispatchLifeCycleEvent(new CustomEvent("page.leave"), this.pageLeaveHandlers);
10907
10935
  }
10908
10936
  handleAnchorLoad() {
10909
10937
  var hash = getHistory().location.hash;
10910
10938
  if (hash && hash !== "#") {
10939
+ this.attachContextTriggerToLifecycle("onAnchorLoad", this.anchorLoadHandlers);
10911
10940
  this.dispatchLifeCycleEvent(new CustomEvent("anchor.load", {
10912
10941
  detail: {
10913
10942
  hash,
@@ -10915,6 +10944,7 @@
10915
10944
  }
10916
10945
  }), this.anchorLoadHandlers);
10917
10946
  } else {
10947
+ this.attachContextTriggerToLifecycle("onAnchorUnload", this.anchorUnloadHandlers);
10918
10948
  this.dispatchLifeCycleEvent(new CustomEvent("anchor.unload"), this.anchorUnloadHandlers);
10919
10949
  }
10920
10950
  }
@@ -10986,6 +11016,22 @@
10986
11016
  $$observe: () => observer.observe(brick.element)
10987
11017
  });
10988
11018
  }
11019
+ attachContextTriggerToLifecycle(lifecycle, handlers) {
11020
+ var contextNameArray = this.storyboardContextWrapper.getContextTriggerSetByLifecycle(lifecycle).concat(getCustomContextTriggerListByLifecycle(lifecycle));
11021
+ if ((contextNameArray === null || contextNameArray === void 0 ? void 0 : contextNameArray.length) > 0) {
11022
+ for (var context of contextNameArray) {
11023
+ handlers.push({
11024
+ brick: null,
11025
+ match: this.currentMatch,
11026
+ tplContextId: context.tplContextId,
11027
+ handler: [{
11028
+ action: "".concat(context.type, ".load"),
11029
+ args: [context.name]
11030
+ }]
11031
+ });
11032
+ }
11033
+ }
11034
+ }
10989
11035
  }
10990
11036
 
10991
11037
  function unmountTree(mountPoint) {