annil 1.7.6 → 1.7.8

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,20 @@
4
4
 
5
5
  * 解决DetailedType不接收接口类型的错误 ([ae8acbf](https://github.com/missannil/annil/commit/ae8acbfc2e62f99db565c448ad9253aa549e78bb))
6
6
 
7
+ ## [1.7.8](https://github.com/missannil/annil/compare/v1.7.7...v1.7.8) (2024-08-22)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * 当SubComponents组件有后缀时,阻止穿透(_catch)事件类型被返回的错误 ([deab409](https://github.com/missannil/annil/commit/deab409c1116d2e810cc018797b6c38061701f25))
13
+
14
+ ## [1.7.7](https://github.com/missannil/annil/compare/v1.7.6...v1.7.7) (2024-08-13)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * 修复SubComponent中计算属性无法获取data和store中数据的错误。 ([014a375](https://github.com/missannil/annil/commit/014a375de3ae657740b185b91f41e1215ef80ace))
20
+
7
21
  ## [1.7.6](https://github.com/missannil/annil/compare/v1.7.5...v1.7.6) (2024-08-10)
8
22
 
9
23
 
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,11 +38,11 @@ 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]>>;
45
- }>, SubComputedDoc extends object = IfExtends<SubComputedConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc & SubStoreDoc)> & Record<InnerFields<CurrentPrefix>, unknown>>, TSubComputed, {}, GetSubComputedDoc<TSubComputed>>, SubEventsDoc extends object = IfExtends<SubEventsConstraint<CurrentCompDoc>, TEvents, {}, TEvents>, SubMethodsDoc extends object = TSubMethods, MissingRequiredField extends PropertyKey = Exclude<RequiredKeys<NonNullable<CurrentCompDoc["properties"]>>, keyof (InheritDoc & SubDataDoc & SubStoreDoc & IfExtends<SubComputedConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc & SubStoreDoc)>>, TSubComputed, {}, GetSubComputedDoc<TSubComputed>>)>>(options: Options<TRootDoc, IsPage, CurrentCompDoc, CurrentPrefix, AllRootDataDoc, TInherit, TSubData, TSubStore, TSubComputed, TEvents, TSubMethods, InheritDoc, SubDataDoc, SubStoreDoc, SubComputedDoc, SubEventsDoc, SubMethodsDoc>) => CreateSubComponentDoc<NonNullable<TOriginalCompDoc["customEvents"]>, SubEventsDoc, MissingRequiredField>;
45
+ }>, SubComputedDoc extends object = IfExtends<SubComputedConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc & SubStoreDoc)> & Record<InnerFields<CurrentPrefix>, unknown>>, TSubComputed, {}, GetSubComputedDoc<TSubComputed>>, SubEventsDoc extends object = IfExtends<SubEventsConstraint<CurrentCompDoc>, TEvents, {}, TEvents>, SubMethodsDoc extends object = TSubMethods, MissingRequiredField extends PropertyKey = Exclude<RequiredKeys<NonNullable<CurrentCompDoc["properties"]>>, keyof (InheritDoc & SubDataDoc & SubStoreDoc & IfExtends<SubComputedConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc & SubStoreDoc)>>, TSubComputed, {}, GetSubComputedDoc<TSubComputed>>)>>(options: Options<TRootDoc, IsPage, CurrentCompDoc, CurrentPrefix, AllRootDataDoc, TInherit, TSubData, TSubStore, TSubComputed, TEvents, TSubMethods, InheritDoc, SubDataDoc, SubStoreDoc, SubComputedDoc, SubEventsDoc, SubMethodsDoc>) => CreateSubComponentDoc<NonNullable<CurrentCompDoc["customEvents"]>, SubEventsDoc, MissingRequiredField>;
46
46
  /**
47
47
  * 子组件构建函数
48
48
  * @returns `(options:) => SubComponentDoc`
@@ -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/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ import type { CreateComponentType } from "./types/CreateComponentType";
7
7
  import type { DetailedType } from "./types/DetailedType";
8
8
  import type { ExtendComponentType } from "./types/ExtendComponentType";
9
9
  import type { ParamsEqual } from "./types/TwoParamsEqual";
10
+ export type { Bubbles, BubblesCapture, BubblesCaptureComposed, BubblesComposed, Capture, CaptureComposed, Composed, CustomEventsTags, } from "./api/RootComponent/CustomEvents/CustomEventsTag";
10
11
  export type { Vant, Wm } from "./thirdLib";
11
12
  export type { CurrentTargetDataset, Dataset, Detail, Mark, TargetDataset, WMBaseEvent, WMCustomEvent, } from "./types/OfficialTypeAlias";
12
13
  export { type CreateComponentType, DefineComponent, type DetailedType, type ExtendComponentType, type IInjectInfo, instanceConfig, navigateTo, type ParamsEqual, RootComponent, SubComponent, };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAoB,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAiBlD,OAAO,EAEL,eAAe,EAIf,cAAc,EACd,UAAU,EAEV,aAAa,EACb,YAAY,GACb,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAoB,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA2BlD,OAAO,EAEL,eAAe,EAIf,cAAc,EACd,UAAU,EAEV,aAAa,EACb,YAAY,GACb,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "annil",
3
- "version": "1.7.6",
3
+ "version": "1.7.8",
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
+ });
@@ -37,3 +37,47 @@ type SubDocExpect = {
37
37
  };
38
38
 
39
39
  Checking<typeof SubDoc, SubDocExpect, Test.Pass>();
40
+ // 去除已经声明的穿透事件
41
+ const removeCatchedEvents = SubComponent<{}, CompDoc>()({
42
+ data: {
43
+ aaa_str: "string",
44
+ },
45
+ events: {
46
+ aaa_bubblesCaptrueComposed_catch(e) {
47
+ console.log(e);
48
+ },
49
+ aaa_bubblesComposed_catch(e) {
50
+ console.log(e);
51
+ },
52
+ aaa_captrueComposed_catch(e) {
53
+ console.log(e);
54
+ },
55
+ },
56
+ });
57
+ void removeCatchedEvents;
58
+ // 返回穿透的自定义事件,并去除了前缀
59
+ type RemoveSubDoc = never;
60
+
61
+ Checking<typeof removeCatchedEvents, RemoveSubDoc, Test.Pass>();
62
+ // 去除有后缀时,已经声明的穿透事件
63
+ const removeCatchedEventsOfSuffix = SubComponent<{}, CompDoc, "aa">()({
64
+ data: {
65
+ aaaAa_str: "string",
66
+ },
67
+ events: {
68
+ aaaAa_bubblesCaptrueComposed_catch(e) {
69
+ console.log(e);
70
+ },
71
+ aaaAa_bubblesComposed_catch(e) {
72
+ console.log(e);
73
+ },
74
+ aaaAa_captrueComposed_catch(e) {
75
+ console.log(e);
76
+ },
77
+ },
78
+ });
79
+ void removeCatchedEventsOfSuffix;
80
+ // 返回穿透的自定义事件,并去除了前缀
81
+ type RemoveCatchedEventsOfSuffix = never;
82
+
83
+ Checking<typeof removeCatchedEventsOfSuffix, RemoveCatchedEventsOfSuffix, Test.Pass>();
@@ -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
  >
@@ -227,7 +231,7 @@ type SubComponentConstructor<
227
231
  SubEventsDoc,
228
232
  SubMethodsDoc
229
233
  >,
230
- ) => CreateSubComponentDoc<NonNullable<TOriginalCompDoc["customEvents"]>, SubEventsDoc, MissingRequiredField>;
234
+ ) => CreateSubComponentDoc<NonNullable<CurrentCompDoc["customEvents"]>, SubEventsDoc, MissingRequiredField>;
231
235
 
232
236
  /**
233
237
  * 子组件构建函数
package/src/index.ts CHANGED
@@ -7,6 +7,16 @@ import type { CreateComponentType } from "./types/CreateComponentType";
7
7
  import type { DetailedType } from "./types/DetailedType";
8
8
  import type { ExtendComponentType } from "./types/ExtendComponentType";
9
9
  import type { ParamsEqual } from "./types/TwoParamsEqual";
10
+ export type {
11
+ Bubbles,
12
+ BubblesCapture,
13
+ BubblesCaptureComposed,
14
+ BubblesComposed,
15
+ Capture,
16
+ CaptureComposed,
17
+ Composed,
18
+ CustomEventsTags,
19
+ } from "./api/RootComponent/CustomEvents/CustomEventsTag";
10
20
  export type { Vant, Wm } from "./thirdLib";
11
21
 
12
22
  export type {