annil 1.11.0-alpha.3 → 1.11.0-alpha.4

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,25 @@
4
4
 
5
5
  * 解决DetailedType不接收接口类型的错误 ([ae8acbf](https://github.com/missannil/annil/commit/ae8acbfc2e62f99db565c448ad9253aa549e78bb))
6
6
 
7
+ ## [1.11.0-alpha.4](https://github.com/missannil/annil/compare/v1.11.0-alpha.3...v1.11.0-alpha.4) (2025-01-14)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * 类型修改 ([278058c](https://github.com/missannil/annil/commit/278058ccc13cae016bfcc9678875ed8c79a35472))
13
+
14
+
15
+ ### Miscellaneous Chores
16
+
17
+ * release alpha.4 ([433779f](https://github.com/missannil/annil/commit/433779f12e7a3549a77d87c2663d37405ea2692f))
18
+
19
+ ## [1.11.0-alpha.3](https://github.com/missannil/annil/compare/v1.11.0-alpha.3...v1.11.0-alpha.3) (2025-01-14)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * 类型修改 ([278058c](https://github.com/missannil/annil/commit/278058ccc13cae016bfcc9678875ed8c79a35472))
25
+
7
26
  ## [1.11.0-alpha.3](https://github.com/missannil/annil/compare/v1.11.0-alpha.2...v1.11.0-alpha.3) (2025-01-13)
8
27
 
9
28
 
@@ -18,7 +18,7 @@ export interface IInjectInfo extends BaseInjectInfo {
18
18
  export type IInjectAllData = IfEquals<{}, injectData & IInjectStore, {}, ComputeIntersection<injectData & IInjectStore>>;
19
19
  type injectData = DataConstraint extends IInjectInfo["data"] ? {} : IInjectInfo["data"];
20
20
  export type IInjectStore = StoreConstraint extends IInjectInfo["store"] ? {} : ReturnTypeInObject<IInjectInfo["store"]>;
21
- export type IInjectMethods = IInjectInfo["methods"];
21
+ export type IInjectMethods = MethodsConstraint extends IInjectInfo["methods"] ? {} : IInjectInfo["methods"];
22
22
  /**
23
23
  * 实例配置接口
24
24
  */
@@ -13,6 +13,7 @@ import type { RootComponentType } from "../RootComponent/RootComponentType";
13
13
  import type { GetStoreDoc } from "../RootComponent/Store/GeTStoreDoc";
14
14
  import type { StoreConstraint } from "../RootComponent/Store/StoreConstraint";
15
15
  import type { WatchOption } from "../RootComponent/Watch/WatchOption";
16
+ import type { SubComponentType } from "../SubComponent/SubComponentType";
16
17
  import type { GetSlotComputedDoc } from "./SlotComputed/GetSlotComputedDoc";
17
18
  import type { SlotComputedOption } from "./SlotComputed/SlotComputedOption";
18
19
  import type { SlotDataOption } from "./SlotData/SlotDataOption";
@@ -25,10 +26,5 @@ type SoltComponentOptions<Prefix extends string, TSuperData extends PropertyKey[
25
26
  data: ComputeObject<TData & StoreDoc & AllSuperDatas & ComputedDoc & IInjectAllData>;
26
27
  }, Prefix> & SlotEventsOption<TEvents, keyof (AllSuperMethods & AllSuperEvents & IInjectMethods), `${Prefix}_${string}`> & SlotMethodsOption<TMethods, keyof (AllSuperMethods & AllSuperEvents & EventsDoc & IInjectMethods), `${Prefix}_${string}`> & PageLifetimesOption<TIsPage, PropertiesDoc> & LifetimesOption & WatchOption<ComputedDoc & Required<AllSuperDatas> & DataDoc & StoreDoc & IInjectStore> & Partial<Omit<WMCompOtherOption, "pageLifetimes" | "definitionFilter" | "observers">> & ObserversOption<ComputedDoc & Required<AllSuperDatas> & DataDoc & StoreDoc & IInjectStore> & ThisType<RootComponentInstance<TIsPage, TMethods & AllSuperMethods, DataDoc, DataDoc & StoreDoc & ComputedDoc & AllSuperDatas & IInjectAllData, {}, StoreDoc>>;
27
28
  type SlotComponentConstructor<RootDoc extends RootComponentType, SubDoc extends SubComponentType, Prefix extends string, IsPage extends boolean = RootDoc["isPage"] extends true ? true : false, AllSuperDatas extends object = Required<RootDoc["properties"]> & RootDoc["data"] & RootDoc["computed"] & RootDoc["store"] & SubDoc["allDatas"], AllSuperMethods extends object = RootDoc["methods"] & SubDoc["methods"] & {}, AllSuperEvents extends object = RootDoc["events"] & SubDoc["methods"] & SubDoc["events"] & {}> = <TSuperData extends (keyof AllSuperDatas)[], TEvents extends SlotEventsConstraint, TData extends object = {}, TStore extends StoreConstraint = {}, TComputed extends ComputedConstraint = {}, TMethods extends MethodsConstraint = {}, DataDoc extends object = TData, EventsDoc extends object = IfExtends<SlotEventsConstraint, TEvents, {}, TEvents>, PropertiesDoc extends object = RootDoc["properties"] & {}, StoreDoc extends object = GetStoreDoc<TStore>, ComputedDoc extends object = GetSlotComputedDoc<TComputed>>(options: SoltComponentOptions<Prefix, TSuperData, TEvents, IsPage, TMethods, TData, TStore, TComputed, EventsDoc, PropertiesDoc, DataDoc, StoreDoc, ComputedDoc, AllSuperDatas, AllSuperMethods, AllSuperEvents>) => never;
28
- type SubComponentType = {
29
- allDatas?: Record<string, unknown>;
30
- methods?: Record<string, () => unknown>;
31
- events?: Record<string, () => unknown>;
32
- };
33
29
  export declare function SlotComponent<RootDoc extends RootComponentType, SubDoc extends SubComponentType, name extends string>(): SlotComponentConstructor<RootDoc, SubDoc, name>;
34
30
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/SlotComponent/index.ts"],"names":[],"mappings":"AAkJA,MAAM,UAAU,aAAa;IAS3B,8DAA8D;IAC9D,OAAO,CAAC,OAAY,EAAE,EAAE,CAAC,OAAgB,CAAC;AAC5C,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/SlotComponent/index.ts"],"names":[],"mappings":"AA+IA,MAAM,UAAU,aAAa;IAS3B,8DAA8D;IAC9D,OAAO,CAAC,OAAY,EAAE,EAAE,CAAC,OAAgB,CAAC;AAC5C,CAAC"}
@@ -1,8 +1,10 @@
1
+ import type { Func } from "hry-types/src/Misc/_api";
1
2
  import type { CustomEventsTags } from "../RootComponent/CustomEvents/CustomEventsTag";
2
3
  type _SubComponentType = {
3
4
  composedEvents?: Record<string, string | number | bigint | boolean | symbol | null | undefined | Record<string, any> | unknown[] | CustomEventsTags>;
4
5
  allDatas?: Record<string, unknown>;
5
- methods?: Record<string, unknown>;
6
+ methods?: Record<string, Func>;
7
+ events?: Record<string, Func>;
6
8
  };
7
9
  /**
8
10
  * SubComponent API 返回类型
@@ -15,5 +15,7 @@ export type CreateSubComponentDoc<OriginalCompDoc extends object, SubEventsDoc e
15
15
  methods: SubMethods;
16
16
  }> & IfExtends<EmptyObject, allDatas, {}, {
17
17
  allDatas: allDatas;
18
- }>>> = IfExtends<MissingRequiredField, never, IfExtends<EmptyObject, SubCompDoc, never, SubCompDoc>, `缺少必传的字段${UnionToComma<MissingRequiredField & string>}`>;
18
+ }> & IfExtends<EmptyObject, SubEventsDoc, {}, {
19
+ events: SubEventsDoc;
20
+ }>>> = IfExtends<MissingRequiredField, never, IfExtends<EmptyObject, SubCompDoc, {}, SubCompDoc>, `缺少必传的字段${UnionToComma<MissingRequiredField & string>}`>;
19
21
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/SubComponent/index.ts"],"names":[],"mappings":"AAqSA;;;GAGG;AACH,MAAM,UAAU,YAAY;IAK1B,8DAA8D;IAC9D,OAAO,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,OAAkC,CAAQ,CAAC;AACvE,CAAC;AAiBD,uCAAuC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/SubComponent/index.ts"],"names":[],"mappings":"AAuSA;;;GAGG;AACH,MAAM,UAAU,YAAY;IAK1B,8DAA8D;IAC9D,OAAO,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,OAAkC,CAAQ,CAAC;AACvE,CAAC;AAiBD,uCAAuC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "annil",
3
- "version": "1.11.0-alpha.3",
3
+ "version": "1.11.0-alpha.4",
4
4
  "description": "微信小程序(原生开发)插件",
5
5
  "main": "dist/index.js",
6
6
  "types": "src/index.ts",
@@ -31,7 +31,7 @@ type injectData = DataConstraint extends IInjectInfo["data"] ? {} : IInjectInfo[
31
31
  export type IInjectStore = StoreConstraint extends IInjectInfo["store"] ? {}
32
32
  : ReturnTypeInObject<IInjectInfo["store"]>;
33
33
 
34
- export type IInjectMethods = IInjectInfo["methods"];
34
+ export type IInjectMethods = MethodsConstraint extends IInjectInfo["methods"] ? {} : IInjectInfo["methods"];
35
35
 
36
36
  /**
37
37
  * 实例配置接口
@@ -13,6 +13,7 @@ import type { RootComponentType } from "../RootComponent/RootComponentType";
13
13
  import type { GetStoreDoc } from "../RootComponent/Store/GeTStoreDoc";
14
14
  import type { StoreConstraint } from "../RootComponent/Store/StoreConstraint";
15
15
  import type { WatchOption } from "../RootComponent/Watch/WatchOption";
16
+ import type { SubComponentType } from "../SubComponent/SubComponentType";
16
17
  import type { GetSlotComputedDoc } from "./SlotComputed/GetSlotComputedDoc";
17
18
  import type { SlotComputedOption } from "./SlotComputed/SlotComputedOption";
18
19
  import type { SlotDataOption } from "./SlotData/SlotDataOption";
@@ -139,11 +140,7 @@ type SlotComponentConstructor<
139
140
  AllSuperEvents
140
141
  >,
141
142
  ) => never;
142
- type SubComponentType = {
143
- allDatas?: Record<string, unknown>;
144
- methods?: Record<string, () => unknown>;
145
- events?: Record<string, () => unknown>;
146
- };
143
+
147
144
  export function SlotComponent<
148
145
  RootDoc extends RootComponentType,
149
146
  SubDoc extends SubComponentType,
@@ -1,3 +1,4 @@
1
+ import type { Func } from "hry-types/src/Misc/_api";
1
2
  import type { CustomEventsTags } from "../RootComponent/CustomEvents/CustomEventsTag";
2
3
 
3
4
  type _SubComponentType = {
@@ -16,7 +17,8 @@ type _SubComponentType = {
16
17
  | CustomEventsTags
17
18
  >;
18
19
  allDatas?: Record<string, unknown>;
19
- methods?: Record<string, unknown>;
20
+ methods?: Record<string, Func>;
21
+ events?: Record<string, Func>;
20
22
  };
21
23
 
22
24
  // type _Validator<O, ErrKeys = Exclude<keyof O, SelectKeys<O, Composed, "contains->">>> = [ErrKeys] extends [never]
@@ -61,6 +61,15 @@ type Sub1Expected = {
61
61
  CapturePhaseComposed: string | CaptureComposed;
62
62
  BubblesCapturePhaseComposed: string | BubblesCaptureComposed;
63
63
  };
64
+ events: {
65
+ aaa_str(e: Detail<string>): void;
66
+ aaa_bubbles(e: Detail<string>): void;
67
+ aaa_CapturePhase(e: Detail<string>): void;
68
+ aaa_BubblesCapturePhase(e: Detail<null>): void;
69
+ aaa_BubblesComposed(e: Detail<string>): void;
70
+ aaa_CapturePhaseComposed(e: Detail<string>): void;
71
+ aaa_BubblesCapturePhaseComposed(e: Detail<string>): void;
72
+ };
64
73
  };
65
74
 
66
75
  // 1.2 Composed事件会被返回
@@ -83,6 +92,10 @@ Checking<typeof sub2, {
83
92
  composedEvents: {
84
93
  BubblesCapturePhaseComposed: string | BubblesCaptureComposed;
85
94
  };
95
+ events: {
96
+ aaa_BubblesComposed_catch(e: Detail<string>): void;
97
+ aaa_CapturePhaseComposed_catch(e: Detail<string>): void;
98
+ };
86
99
  }, Test.Pass>;
87
100
 
88
101
  const sub3 = SubComponent<{}, CompDoc>()({
@@ -100,7 +113,13 @@ const sub3 = SubComponent<{}, CompDoc>()({
100
113
  });
101
114
 
102
115
  // 2.4 若Composed事件都被阻止则返回never
103
- Checking<typeof sub3, never, Test.Pass>;
116
+ Checking<typeof sub3, {
117
+ events: {
118
+ aaa_BubblesComposed_catch(e: Detail<string>): void;
119
+ aaa_CapturePhaseComposed_catch(e: Detail<string>): void;
120
+ aaa_BubblesCapturePhaseComposed_catch(e: Detail<string>): void;
121
+ };
122
+ }, Test.Pass>;
104
123
 
105
124
  // 3.1 基础组件基本事件参数为WMBaseEvent
106
125
  SubComponent<{}, Wm.View>()({
@@ -37,10 +37,11 @@ export type CreateSubComponentDoc<
37
37
  & IfExtends<EmptyObject, ComposedEvents, {}, { composedEvents: ComposedEvents }>
38
38
  & IfExtends<EmptyObject, SubMethods, {}, { methods: SubMethods }>
39
39
  & IfExtends<EmptyObject, allDatas, {}, { allDatas: allDatas }>
40
+ & IfExtends<EmptyObject, SubEventsDoc, {}, { events: SubEventsDoc }>
40
41
  >,
41
42
  > = IfExtends<
42
43
  MissingRequiredField,
43
44
  never,
44
- IfExtends<EmptyObject, SubCompDoc, never, SubCompDoc>,
45
+ IfExtends<EmptyObject, SubCompDoc, {}, SubCompDoc>,
45
46
  `缺少必传的字段${UnionToComma<MissingRequiredField & string>}`
46
47
  >;
@@ -12,7 +12,7 @@ type CompDoc = ComponentType<{
12
12
 
13
13
  const SubDoc = SubComponent<{}, CompDoc>()({});
14
14
  void SubDoc;
15
- // 返回穿透的自定义事件,并去除了前缀
15
+ // 返回穿透的自定义事件, 并去除了前缀
16
16
  type SubDocExpect = "缺少必传的字段aaa_str、aaa_bool";
17
17
 
18
18
  Checking<typeof SubDoc, SubDocExpect, Test.Pass>();
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-empty-function */
1
2
  import { Checking, type Test } from "hry-types";
2
3
  import type { ComponentType } from "../../../DefineComponent/ReturnType/ComponentType";
3
4
  import type {
@@ -48,14 +49,11 @@ const removeCatchedEvents = SubComponent<{}, CompDoc>()({
48
49
  aaa_str: "string",
49
50
  },
50
51
  events: {
51
- aaa_bubblesCaptrueComposed_catch(e) {
52
- console.log(e);
52
+ aaa_bubblesCaptrueComposed_catch() {
53
53
  },
54
- aaa_bubblesComposed_catch(e) {
55
- console.log(e);
54
+ aaa_bubblesComposed_catch() {
56
55
  },
57
- aaa_captrueComposed_catch(e) {
58
- console.log(e);
56
+ aaa_captrueComposed_catch() {
59
57
  },
60
58
  },
61
59
  });
@@ -65,6 +63,11 @@ type RemoveSubDoc = {
65
63
  allDatas: {
66
64
  aaa_str: "string";
67
65
  };
66
+ events: {
67
+ aaa_bubblesCaptrueComposed_catch(): void;
68
+ aaa_bubblesComposed_catch(): void;
69
+ aaa_captrueComposed_catch(): void;
70
+ };
68
71
  };
69
72
 
70
73
  Checking<typeof removeCatchedEvents, RemoveSubDoc, Test.Pass>();
@@ -74,15 +77,9 @@ const removeCatchedEventsOfSuffix = SubComponent<{}, CompDoc, "aa">()({
74
77
  aaaAa_str: "string",
75
78
  },
76
79
  events: {
77
- aaaAa_bubblesCaptrueComposed_catch(e) {
78
- console.log(e);
79
- },
80
- aaaAa_bubblesComposed_catch(e) {
81
- console.log(e);
82
- },
83
- aaaAa_captrueComposed_catch(e) {
84
- console.log(e);
85
- },
80
+ aaaAa_bubblesCaptrueComposed_catch() {},
81
+ aaaAa_bubblesComposed_catch() {},
82
+ aaaAa_captrueComposed_catch() {},
86
83
  },
87
84
  });
88
85
  void removeCatchedEventsOfSuffix;
@@ -91,6 +88,11 @@ type RemoveCatchedEventsOfSuffix = {
91
88
  allDatas: {
92
89
  aaaAa_str: "string";
93
90
  };
91
+ events: {
92
+ aaaAa_bubblesCaptrueComposed_catch(): void;
93
+ aaaAa_bubblesComposed_catch(): void;
94
+ aaaAa_captrueComposed_catch(): void;
95
+ };
94
96
  };
95
97
 
96
98
  Checking<typeof removeCatchedEventsOfSuffix, RemoveCatchedEventsOfSuffix, Test.Pass>();
@@ -283,13 +283,15 @@ type SubComponentConstructor<
283
283
  SubEventsDoc,
284
284
  SubMethodsDoc
285
285
  >,
286
- ) => CreateSubComponentDoc<
286
+ ) => // SubComponentType<
287
+ CreateSubComponentDoc<
287
288
  NonNullable<CurrentCompDoc["customEvents"]>,
288
289
  SubEventsDoc,
289
290
  MissingRequiredField,
290
291
  ComputeObject<SubDataDoc & SubComputedDoc & SubStoreDoc>, // allDatas
291
292
  SubMethodsDoc
292
- >;
293
+ > // >
294
+ ; // must satisfied SubComponentType
293
295
 
294
296
  /**
295
297
  * 子组件构建函数