@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/CHANGELOG.md CHANGED
@@ -3,6 +3,29 @@
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.146.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.145.3...@next-core/brick-kit@2.146.0) (2022-09-28)
7
+
8
+
9
+ ### Features
10
+
11
+ * **StoryboardContext:** move logic of track into resolveFreeVariableValue to support tracking state in useBrick ([62b8445](https://github.com/easyops-cn/next-core/commit/62b8445b28e20c6b12e0eda7b3711d83a2be365c))
12
+
13
+
14
+
15
+
16
+
17
+ ## [2.145.3](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.145.2...@next-core/brick-kit@2.145.3) (2022-09-27)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * app to standalone app, path to homepage ([af5a01d](https://github.com/easyops-cn/next-core/commit/af5a01d0e1f1875430084f9e253d326f0994386a))
23
+ * standalone back and show pageNotFound ([80d1c18](https://github.com/easyops-cn/next-core/commit/80d1c185a4f3bf5039192b7861e710456c416080))
24
+
25
+
26
+
27
+
28
+
6
29
  ## [2.145.2](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.145.1...@next-core/brick-kit@2.145.2) (2022-09-27)
7
30
 
8
31
 
@@ -2180,26 +2180,6 @@
2180
2180
  // Or if the resolve is ignored or lazy, use its `value` as a fallback.
2181
2181
  value = computeRealValue(contextConf.value, mergedContext, true);
2182
2182
  }
2183
-
2184
- if (contextConf.track) {
2185
- // Track its dependencies and auto update when each of them changed.
2186
- var deps = (isTemplateState ? brickUtils.trackUsedState : brickUtils.trackUsedContext)(load ? contextConf.resolve : contextConf.value);
2187
-
2188
- for (var dep of deps) {
2189
- var _eventTarget;
2190
-
2191
- var ctx = storyboardContextWrapper.get().get(dep);
2192
- ctx === null || ctx === void 0 ? void 0 : (_eventTarget = ctx.eventTarget) === null || _eventTarget === void 0 ? void 0 : _eventTarget.addEventListener(isTemplateState ? "state.change" : "context.change", () => {
2193
- if (load) {
2194
- storyboardContextWrapper.updateValue(contextConf.name, {
2195
- cache: "default"
2196
- }, "refresh");
2197
- } else {
2198
- storyboardContextWrapper.updateValue(contextConf.name, computeRealValue(contextConf.value, mergedContext, true), "replace");
2199
- }
2200
- });
2201
- }
2202
- }
2203
2183
  }
2204
2184
 
2205
2185
  resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick, load, !isLazyResolve);
@@ -2249,6 +2229,27 @@
2249
2229
  }
2250
2230
  }
2251
2231
 
2232
+ if (contextConf.track) {
2233
+ var isTemplateState = !!storyboardContextWrapper.tplContextId; // Track its dependencies and auto update when each of them changed.
2234
+
2235
+ var deps = (isTemplateState ? brickUtils.trackUsedState : brickUtils.trackUsedContext)(load ? contextConf.resolve : contextConf.value);
2236
+
2237
+ for (var dep of deps) {
2238
+ var _eventTarget;
2239
+
2240
+ var ctx = storyboardContextWrapper.get().get(dep);
2241
+ ctx === null || ctx === void 0 ? void 0 : (_eventTarget = ctx.eventTarget) === null || _eventTarget === void 0 ? void 0 : _eventTarget.addEventListener(isTemplateState ? "state.change" : "context.change", () => {
2242
+ if (load) {
2243
+ storyboardContextWrapper.updateValue(contextConf.name, {
2244
+ cache: "default"
2245
+ }, "refresh");
2246
+ } else {
2247
+ storyboardContextWrapper.updateValue(contextConf.name, computeRealValue(contextConf.value, mergedContext, true), "replace");
2248
+ }
2249
+ });
2250
+ }
2251
+ }
2252
+
2252
2253
  storyboardContextWrapper.set(contextConf.name, newContext);
2253
2254
  }
2254
2255
 
@@ -10614,14 +10615,10 @@
10614
10615
  return "missed";
10615
10616
  }
10616
10617
 
10617
- matchStoryboard(storyboards) {
10618
- if (window.STANDALONE_MICRO_APPS && storyboards.length === 1) {
10619
- return storyboards[0];
10620
- } // Put apps with longer homepage before shorter ones.
10618
+ matchStoryboard(storyboards, location) {
10619
+ // Put apps with longer homepage before shorter ones.
10621
10620
  // E.g., `/legacy/tool` will match first before `/legacy`.
10622
10621
  // This enables two apps with relationship of parent-child of homepage.
10623
-
10624
-
10625
10622
  var sortedStoryboards = _.orderBy(storyboards, storyboard => {
10626
10623
  var _storyboard$app$homep, _storyboard$app, _storyboard$app$homep2;
10627
10624
 
@@ -10634,7 +10631,7 @@
10634
10631
  var homepage = (_storyboard$app2 = storyboard.app) === null || _storyboard$app2 === void 0 ? void 0 : _storyboard$app2.homepage;
10635
10632
 
10636
10633
  if (typeof homepage === "string" && homepage[0] === "/") {
10637
- if (brickUtils.matchPath(this.location.pathname, {
10634
+ if (brickUtils.matchPath((location || this.location).pathname, {
10638
10635
  path: homepage,
10639
10636
  exact: homepage === "/"
10640
10637
  })) {
@@ -12023,6 +12020,20 @@
12023
12020
 
12024
12021
  _this.locationContext.messageDispatcher.reset();
12025
12022
 
12023
+ var storyboard = _this.locationContext.matchStoryboard(_this.kernel.bootstrapData.storyboards, location);
12024
+
12025
+ if (!window.STANDALONE_MICRO_APPS) {
12026
+ if (storyboard && storyboard.app.standaloneMode) {
12027
+ // from non-standalone app to standalone app, should jump out off site
12028
+ window.location.assign(window.location.href);
12029
+ }
12030
+ } else {
12031
+ if (!storyboard) {
12032
+ // from standalone app goback to non-standalone app, should reload
12033
+ window.location.reload();
12034
+ }
12035
+ }
12036
+
12026
12037
  if (_this.rendering) {
12027
12038
  _this.nextLocation = location;
12028
12039
  } else {
@@ -12092,16 +12103,6 @@
12092
12103
  if (storyboard) {
12093
12104
  var _storyboard$meta, _storyboard$meta2, _storyboard$meta3;
12094
12105
 
12095
- if (!window.STANDALONE_MICRO_APPS) {
12096
- if (storyboard.app.standaloneMode) {
12097
- // if nextApp was standalone micro-apps, use location.replace to reload window;
12098
- var path = history.createHref({
12099
- pathname: storyboard.app.homepage
12100
- });
12101
- window.location.replace(path);
12102
- }
12103
- }
12104
-
12105
12106
  yield _this3.kernel.fulfilStoryboard(storyboard); // 将动态解析后的模板还原,以便重新动态解析。
12106
12107
 
12107
12108
  brickUtils.restoreDynamicTemplates(storyboard); // 预加载权限信息