@next-core/brick-kit 2.145.2 → 2.146.0

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
@@ -2181,26 +2181,6 @@ function _resolveNormalStoryboardContext() {
2181
2181
  // Or if the resolve is ignored or lazy, use its `value` as a fallback.
2182
2182
  value = computeRealValue(contextConf.value, mergedContext, true);
2183
2183
  }
2184
-
2185
- if (contextConf.track) {
2186
- // Track its dependencies and auto update when each of them changed.
2187
- var deps = (isTemplateState ? trackUsedState : trackUsedContext)(load ? contextConf.resolve : contextConf.value);
2188
-
2189
- for (var dep of deps) {
2190
- var _eventTarget;
2191
-
2192
- var ctx = storyboardContextWrapper.get().get(dep);
2193
- ctx === null || ctx === void 0 ? void 0 : (_eventTarget = ctx.eventTarget) === null || _eventTarget === void 0 ? void 0 : _eventTarget.addEventListener(isTemplateState ? "state.change" : "context.change", () => {
2194
- if (load) {
2195
- storyboardContextWrapper.updateValue(contextConf.name, {
2196
- cache: "default"
2197
- }, "refresh");
2198
- } else {
2199
- storyboardContextWrapper.updateValue(contextConf.name, computeRealValue(contextConf.value, mergedContext, true), "replace");
2200
- }
2201
- });
2202
- }
2203
- }
2204
2184
  }
2205
2185
 
2206
2186
  resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick, load, !isLazyResolve);
@@ -2250,6 +2230,27 @@ function resolveFreeVariableValue(value, contextConf, mergedContext, storyboardC
2250
2230
  }
2251
2231
  }
2252
2232
 
2233
+ if (contextConf.track) {
2234
+ var isTemplateState = !!storyboardContextWrapper.tplContextId; // Track its dependencies and auto update when each of them changed.
2235
+
2236
+ var deps = (isTemplateState ? trackUsedState : trackUsedContext)(load ? contextConf.resolve : contextConf.value);
2237
+
2238
+ for (var dep of deps) {
2239
+ var _eventTarget;
2240
+
2241
+ var ctx = storyboardContextWrapper.get().get(dep);
2242
+ ctx === null || ctx === void 0 ? void 0 : (_eventTarget = ctx.eventTarget) === null || _eventTarget === void 0 ? void 0 : _eventTarget.addEventListener(isTemplateState ? "state.change" : "context.change", () => {
2243
+ if (load) {
2244
+ storyboardContextWrapper.updateValue(contextConf.name, {
2245
+ cache: "default"
2246
+ }, "refresh");
2247
+ } else {
2248
+ storyboardContextWrapper.updateValue(contextConf.name, computeRealValue(contextConf.value, mergedContext, true), "replace");
2249
+ }
2250
+ });
2251
+ }
2252
+ }
2253
+
2253
2254
  storyboardContextWrapper.set(contextConf.name, newContext);
2254
2255
  }
2255
2256
 
@@ -10615,14 +10616,10 @@ class LocationContext {
10615
10616
  return "missed";
10616
10617
  }
10617
10618
 
10618
- matchStoryboard(storyboards) {
10619
- if (window.STANDALONE_MICRO_APPS && storyboards.length === 1) {
10620
- return storyboards[0];
10621
- } // Put apps with longer homepage before shorter ones.
10619
+ matchStoryboard(storyboards, location) {
10620
+ // Put apps with longer homepage before shorter ones.
10622
10621
  // E.g., `/legacy/tool` will match first before `/legacy`.
10623
10622
  // This enables two apps with relationship of parent-child of homepage.
10624
-
10625
-
10626
10623
  var sortedStoryboards = orderBy(storyboards, storyboard => {
10627
10624
  var _storyboard$app$homep, _storyboard$app, _storyboard$app$homep2;
10628
10625
 
@@ -10635,7 +10632,7 @@ class LocationContext {
10635
10632
  var homepage = (_storyboard$app2 = storyboard.app) === null || _storyboard$app2 === void 0 ? void 0 : _storyboard$app2.homepage;
10636
10633
 
10637
10634
  if (typeof homepage === "string" && homepage[0] === "/") {
10638
- if (matchPath(this.location.pathname, {
10635
+ if (matchPath((location || this.location).pathname, {
10639
10636
  path: homepage,
10640
10637
  exact: homepage === "/"
10641
10638
  })) {
@@ -12024,6 +12021,20 @@ class Router {
12024
12021
 
12025
12022
  _this.locationContext.messageDispatcher.reset();
12026
12023
 
12024
+ var storyboard = _this.locationContext.matchStoryboard(_this.kernel.bootstrapData.storyboards, location);
12025
+
12026
+ if (!window.STANDALONE_MICRO_APPS) {
12027
+ if (storyboard && storyboard.app.standaloneMode) {
12028
+ // from non-standalone app to standalone app, should jump out off site
12029
+ window.location.assign(window.location.href);
12030
+ }
12031
+ } else {
12032
+ if (!storyboard) {
12033
+ // from standalone app goback to non-standalone app, should reload
12034
+ window.location.reload();
12035
+ }
12036
+ }
12037
+
12027
12038
  if (_this.rendering) {
12028
12039
  _this.nextLocation = location;
12029
12040
  } else {
@@ -12093,16 +12104,6 @@ class Router {
12093
12104
  if (storyboard) {
12094
12105
  var _storyboard$meta, _storyboard$meta2, _storyboard$meta3;
12095
12106
 
12096
- if (!window.STANDALONE_MICRO_APPS) {
12097
- if (storyboard.app.standaloneMode) {
12098
- // if nextApp was standalone micro-apps, use location.replace to reload window;
12099
- var path = history.createHref({
12100
- pathname: storyboard.app.homepage
12101
- });
12102
- window.location.replace(path);
12103
- }
12104
- }
12105
-
12106
12107
  yield _this3.kernel.fulfilStoryboard(storyboard); // 将动态解析后的模板还原,以便重新动态解析。
12107
12108
 
12108
12109
  restoreDynamicTemplates(storyboard); // 预加载权限信息