@next-core/brick-kit 2.136.2 → 2.137.2

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,36 @@
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.137.2](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.137.1...@next-core/brick-kit@2.137.2) (2022-09-07)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * to collect contracts before state define ([3d7cd86](https://github.com/easyops-cn/next-core/commit/3d7cd86441b33494c387bc2053c8698a688abf71))
12
+
13
+
14
+
15
+
16
+
17
+ ## [2.137.1](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.137.0...@next-core/brick-kit@2.137.1) (2022-09-07)
18
+
19
+ **Note:** Version bump only for package @next-core/brick-kit
20
+
21
+
22
+
23
+
24
+
25
+ # [2.137.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.136.2...@next-core/brick-kit@2.137.0) (2022-09-06)
26
+
27
+
28
+ ### Features
29
+
30
+ * support to use contract in widgets ([25b3337](https://github.com/easyops-cn/next-core/commit/25b333724f9c45131b209845a7caef3e8597888d))
31
+
32
+
33
+
34
+
35
+
6
36
  ## [2.136.2](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.136.1...@next-core/brick-kit@2.136.2) (2022-09-06)
7
37
 
8
38
  **Note:** Version bump only for package @next-core/brick-kit
@@ -6054,13 +6054,25 @@
6054
6054
  }();
6055
6055
 
6056
6056
  var contractsMap = new Map();
6057
- function collectContract(contracts) {
6057
+ var widgetContractMap = new Map();
6058
+
6059
+ var addContract = (contracts, map) => {
6058
6060
  contracts === null || contracts === void 0 ? void 0 : contracts.forEach(contract => {
6059
- contractsMap.set("".concat(contract.namespaceId, ".").concat(contract.name), contract);
6061
+ map.set("".concat(contract.namespaceId, ".").concat(contract.name), contract);
6060
6062
  });
6063
+ };
6064
+
6065
+ function collectContract(contracts) {
6066
+ addContract(contracts, contractsMap);
6067
+ }
6068
+ function collectWidgetContract(contracts) {
6069
+ addContract(contracts, widgetContractMap);
6070
+ }
6071
+ function clearCollectWidgetContract() {
6072
+ widgetContractMap.clear();
6061
6073
  }
6062
6074
  function getContract(name) {
6063
- return contractsMap.get(name);
6075
+ return contractsMap.get(name) || widgetContractMap.get(name);
6064
6076
  }
6065
6077
 
6066
6078
  var flowApiDefinitionPromiseMap = new Map(); // Legacy Custom API: `${namespace}@${name}`
@@ -8377,6 +8389,10 @@
8377
8389
  var tplContext = new CustomTemplateContext(proxyBrick);
8378
8390
  var template = customTemplateRegistry.get(brickConf.brick);
8379
8391
 
8392
+ if (template.contracts) {
8393
+ collectWidgetContract(template.contracts);
8394
+ }
8395
+
8380
8396
  if (Array.isArray(template.state)) {
8381
8397
  tplContext.state.syncDefine(template.state, context, proxyBrick);
8382
8398
  }
@@ -8392,6 +8408,10 @@
8392
8408
  var tplContext = new CustomTemplateContext(proxyBrick);
8393
8409
  var template = customTemplateRegistry.get(brickConf.brick);
8394
8410
 
8411
+ if (template.contracts) {
8412
+ collectWidgetContract(template.contracts);
8413
+ }
8414
+
8395
8415
  if (Array.isArray(template.state)) {
8396
8416
  yield tplContext.state.define(template.state, context, proxyBrick);
8397
8417
  }
@@ -11925,6 +11945,7 @@
11925
11945
  _this3.renderId = _.uniqueId("render-id-");
11926
11946
  resetAllInjected();
11927
11947
  clearPollTimeout();
11948
+ clearCollectWidgetContract();
11928
11949
 
11929
11950
  if (_this3.locationContext) {
11930
11951
  _this3.locationContext.resolver.resetRefreshQueue();