annil 1.7.6 → 1.7.7

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
@@ -4,6 +4,13 @@
4
4
 
5
5
  * 解决DetailedType不接收接口类型的错误 ([ae8acbf](https://github.com/missannil/annil/commit/ae8acbfc2e62f99db565c448ad9253aa549e78bb))
6
6
 
7
+ ## [1.7.7](https://github.com/missannil/annil/compare/v1.7.6...v1.7.7) (2024-08-13)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * 修复SubComponent中计算属性无法获取data和store中数据的错误。 ([014a375](https://github.com/missannil/annil/commit/014a375de3ae657740b185b91f41e1215ef80ace))
13
+
7
14
  ## [1.7.6](https://github.com/missannil/annil/compare/v1.7.5...v1.7.6) (2024-08-10)
8
15
 
9
16
 
package/README.md CHANGED
@@ -27,6 +27,8 @@ annil(安奈儿)是微信小程序原生开发插件。她会给您更佳的开
27
27
 
28
28
  ### 特点
29
29
 
30
+ [代码片段](https://developers.weixin.qq.com/s/kRjkFlme7nTV)
31
+
30
32
  - **组件构建API功能更强大**
31
33
 
32
34
  新的组件构建API加入了[computed](./doc/demo/computed.md)、[watch](./doc/demo/watch.md)、[store](./doc/demo/store.md)(基于mobx的全局响应式数据)`等功能,使开发更便捷。
@@ -146,3 +148,7 @@ annil(安奈儿)是微信小程序原生开发插件。她会给您更佳的开
146
148
  ### 更新日志
147
149
 
148
150
  [CHANGELOG](./CHANGELOG.md)
151
+
152
+ ### 讨论群
153
+
154
+ 加微信 missannil 请注明(annil)
@@ -38,7 +38,7 @@ import type { SubStoreConstraint } from "./SubStore/SubStoreConstraint";
38
38
  import type { SubStoreOption } from "./SubStore/SubStoreOption";
39
39
  import type { SubWatchOption } from "./SubWatch/SubWatchOption";
40
40
  type Options<RootDoc extends RootComponentType, IsPage extends boolean, CurrentCompDoc extends ComponentType, Prefix extends string, AllRootDataDoc extends object, TInherit extends object, TSubData extends object, TSubStore extends object, TSubComputed extends object, TEvents extends object, TSubMethods extends SubMethodsConstraint, InheritDoc extends object, SubDataDoc extends object, SubStoreDoc extends object, SubComputedDoc extends object, SubEventsDoc extends object, SubMethodsDoc extends object, CompDocKeys extends PropertyKey = keyof CurrentCompDoc["properties"]> = SubInheritOption<TInherit, CompDocKeys> & SubDataOption<TSubData, Exclude<CompDocKeys, (keyof InheritDoc)> | InnerFields<Prefix>> & SubStoreOption<TSubStore, Exclude<CompDocKeys, (keyof (InheritDoc & SubDataDoc))> | InnerFields<Prefix>> & SubComputedOption<TSubComputed, Exclude<CompDocKeys, (keyof (InheritDoc & SubDataDoc & SubStoreDoc))> | InnerFields<Prefix>, {
41
- data: ComputeObject<AllRootDataDoc & Replace<SubComputedDoc, Required<CurrentCompDoc["properties"]>> & IInjectAllData>;
41
+ data: ComputeObject<AllRootDataDoc & Replace<SubComputedDoc, Required<CurrentCompDoc["properties"]>> & SubStoreDoc & SubDataDoc & IInjectAllData>;
42
42
  }> & SubEventsOption<TEvents, SubEventsDoc, keyof SubEventsConstraint<CurrentCompDoc>> & SubMethodsOption<TSubMethods, Prefix, keyof (CurrentCompDoc["customEvents"] & SubEventsDoc)> & SubPageLifetimesOption<IsPage, NonNullable<RootDoc["properties"]>> & SubLifetimesOption & SubWatchOption<SubComputedDoc & SubDataDoc & AllRootDataDoc & SubStoreDoc & IInjectStore> & Partial<Omit<WMCompOtherOption, "pageLifetimes" | "definitionFilter" | "export" | "observers" | "relations">> & SubObserversOption<SubComputedDoc & SubDataDoc & AllRootDataDoc & SubStoreDoc & IInjectStore> & ThisType<SubInstance<SubMethodsDoc & RootDoc["methods"], Replace<SubDataDoc, Required<CurrentCompDoc["properties"]>>, AllRootDataDoc & Replace<SubDataDoc & SubComputedDoc & SubStoreDoc, Required<CurrentCompDoc["properties"]>>, NonNullable<RootDoc["customEvents"]>, SubStoreDoc>>;
43
43
  type SubComponentConstructor<TRootDoc extends RootComponentType, TOriginalCompDoc extends ComponentType, TSupplementalPrefix extends string = "", IsPage extends boolean = TRootDoc["isPage"] extends true ? true : false, CurrentPrefix extends string = `${GetComponentPrefix<TOriginalCompDoc>}${Capitalize<TSupplementalPrefix>}`, CurrentCompDoc extends ComponentType = IfExtends<TSupplementalPrefix, "", TOriginalCompDoc, ReplacePrefix<TOriginalCompDoc, CurrentPrefix>>, AllRootDataDoc extends object = Required<TRootDoc["properties"]> & TRootDoc["data"] & TRootDoc["computed"] & TRootDoc["store"]> = <TInherit extends InheritConstraint<AllRootDataDoc, CurrentCompDoc>, TSubData extends SubDataConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof InheritDoc> & Record<InnerFields<CurrentPrefix>, unknown>>, TSubStore extends SubStoreConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc)> & Record<InnerFields<CurrentPrefix>, unknown>>, TEvents extends SubEventsConstraint<CurrentCompDoc>, TSubComputed extends SubComputedConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc & SubStoreDoc)> & Record<InnerFields<CurrentPrefix>, unknown>>, TSubMethods extends SubMethodsConstraint = {}, InheritDoc extends object = IfExtends<InheritConstraint<AllRootDataDoc, CurrentCompDoc>, TInherit, {}, TInherit>, SubDataDoc extends object = IfExtends<SubDataConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof InheritDoc> & Record<InnerFields<CurrentPrefix>, unknown>>, TSubData, {}, TSubData>, SubStoreDoc extends object = IfExtends<SubStoreConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc)> & Record<InnerFields<CurrentPrefix>, unknown>>, TSubStore, {}, {
44
44
  [k in keyof TSubStore]: ReturnType<NonNullable<TSubStore[k]>>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/SubComponent/index.ts"],"names":[],"mappings":"AAuOA;;;GAGG;AACH,MAAM,UAAU,YAAY;IAK1B,8DAA8D;IAC9D,OAAO,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,OAAkC,CAAQ,CAAC;AACvE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/SubComponent/index.ts"],"names":[],"mappings":"AA2OA;;;GAGG;AACH,MAAM,UAAU,YAAY;IAK1B,8DAA8D;IAC9D,OAAO,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,OAAkC,CAAQ,CAAC;AACvE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "annil",
3
- "version": "1.7.6",
3
+ "version": "1.7.7",
4
4
  "description": "微信小程序(原生开发)插件",
5
5
  "main": "dist/index.js",
6
6
  "types": "src/index.ts",
@@ -12,11 +12,12 @@
12
12
  "scripts": {
13
13
  "coverage": "jest --coverage",
14
14
  "prepare": "husky install",
15
- "lint": "eslint . --fix && npm run fmt",
15
+ "lint": "eslint . --fix --max-warnings 0",
16
16
  "fmt": "dprint fmt",
17
- "type": "tsc --watch",
18
- "jest": "jest --watch",
19
- "build": "tsc -p tsconfig.build.json"
17
+ "tsc": "tsc --watch",
18
+ "test": "jest --watch",
19
+ "build": "tsc -p tsconfig.build.json",
20
+ "check": "eslint . --fix --max-warnings 0 && (dprint check || (dprint fmt && exit 1))"
20
21
  },
21
22
  "devDependencies": {
22
23
  "@commitlint/config-conventional": "^17.6.5",
@@ -66,7 +66,7 @@ SubComponent<Root, OnlyPropsCompDoc>()({
66
66
  },
67
67
  },
68
68
  });
69
-
69
+ // 3 computed字段的返回类型应为对应的文档类型,避免返回字面量类型导致与实际文档类型不符
70
70
  SubComponent<Root, OnlyPropsCompDoc>()({
71
71
  computed: {
72
72
  aaa_num() {
@@ -76,7 +76,7 @@ SubComponent<Root, OnlyPropsCompDoc>()({
76
76
  return 123;
77
77
  },
78
78
  aaa_str() {
79
- return "a";
79
+ return "a"; // 默认下返回的类型是'a',但文档中是'a' | 'b'.所以要在this.data中处理
80
80
  },
81
81
  aaa_obj() {
82
82
  // 5 this.data
@@ -143,3 +143,20 @@ SubComponent<Root, $aaa>()({
143
143
  },
144
144
  },
145
145
  });
146
+ // 计算属性this.data可获取store和data的字段中文档中的字段和内部字段(_开头的字段)
147
+ SubComponent<Root, $aaa>()({
148
+ data: {
149
+ aaa_age: 123,
150
+ _aaa_age1: 123,
151
+ },
152
+ store: {
153
+ aaa_str: () => "a",
154
+ _aaa_age: () => 123,
155
+ },
156
+ computed: {
157
+ aaa_num(): number {
158
+ const { aaa_age, _aaa_age1, _aaa_age, aaa_str } = this.data;
159
+ return aaa_age + _aaa_age1 + _aaa_age + aaa_str.length;
160
+ },
161
+ },
162
+ });
@@ -75,7 +75,11 @@ type Options<
75
75
  Exclude<CompDocKeys, (keyof (InheritDoc & SubDataDoc & SubStoreDoc))> | InnerFields<Prefix>,
76
76
  {
77
77
  data: ComputeObject<
78
- AllRootDataDoc & Replace<SubComputedDoc, Required<CurrentCompDoc["properties"]>> & IInjectAllData
78
+ & AllRootDataDoc
79
+ & Replace<SubComputedDoc, Required<CurrentCompDoc["properties"]>>
80
+ & SubStoreDoc
81
+ & SubDataDoc
82
+ & IInjectAllData
79
83
  >;
80
84
  }
81
85
  >