@next-core/brick-kit 2.145.3 → 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,17 @@
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
+
6
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)
7
18
 
8
19
 
@@ -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