annil 1.0.1 → 1.0.5

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.
Files changed (180) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +105 -6
  3. package/dist/api/DefineComponent/ReturnType/test/normalComponentDoc.test.js +6 -6
  4. package/dist/api/DefineComponent/ReturnType/test/normalComponentDoc.test.js.map +1 -1
  5. package/dist/api/DefineComponent/ReturnType/test/normalPageDoc.test.js.map +1 -1
  6. package/dist/api/DefineComponent/collectOptionsForComponent.d.ts +4 -0
  7. package/dist/api/DefineComponent/collectOptionsForComponent.js +152 -0
  8. package/dist/api/DefineComponent/collectOptionsForComponent.js.map +1 -0
  9. package/dist/api/DefineComponent/index.d.ts +4 -28
  10. package/dist/api/DefineComponent/index.js +2 -37
  11. package/dist/api/DefineComponent/index.js.map +1 -1
  12. package/dist/api/RootComponent/CustomEvents/CustomEventConstraint.d.ts +5 -4
  13. package/dist/api/RootComponent/CustomEvents/GetCustomEventDoc.d.ts +5 -5
  14. package/dist/api/RootComponent/CustomEvents/test/error.test.js +8 -8
  15. package/dist/api/RootComponent/CustomEvents/test/error.test.js.map +1 -1
  16. package/dist/api/RootComponent/CustomEvents/test/normal.test.d.ts +17 -17
  17. package/dist/api/RootComponent/CustomEvents/test/normal.test.js +6 -6
  18. package/dist/api/RootComponent/CustomEvents/test/normal.test.js.map +1 -1
  19. package/dist/api/RootComponent/Data/DataConstraint.d.ts +1 -0
  20. package/dist/api/RootComponent/Data/DataConstraint.js +2 -0
  21. package/dist/api/RootComponent/Data/DataConstraint.js.map +1 -0
  22. package/dist/api/RootComponent/Instance/test/CustomEventsDoc.test.js +5 -5
  23. package/dist/api/RootComponent/Instance/test/CustomEventsDoc.test.js.map +1 -1
  24. package/dist/api/RootComponent/Instance/test/customEvents/normal.test.js +5 -5
  25. package/dist/api/RootComponent/Instance/test/customEvents/normal.test.js.map +1 -1
  26. package/dist/api/RootComponent/Instance/test/properties/mormal.test.js.map +1 -1
  27. package/dist/api/RootComponent/Lifetimes/LifetimesConstraint.d.ts +2 -2
  28. package/dist/api/RootComponent/Lifetimes/test/error.test.js +1 -0
  29. package/dist/api/RootComponent/Lifetimes/test/error.test.js.map +1 -1
  30. package/dist/api/RootComponent/Lifetimes/test/normal.test.js +3 -0
  31. package/dist/api/RootComponent/Lifetimes/test/normal.test.js.map +1 -1
  32. package/dist/api/RootComponent/PageLifetimes/test/normal.test.js.map +1 -1
  33. package/dist/api/RootComponent/Properties/GetOptionalDoc.d.ts +2 -2
  34. package/dist/api/RootComponent/Properties/GetRequiredDoc.d.ts +2 -2
  35. package/dist/api/RootComponent/Properties/PropertiesConstraint.d.ts +6 -6
  36. package/dist/api/RootComponent/Properties/PropertiesValueValidator.d.ts +2 -2
  37. package/dist/api/RootComponent/Properties/test/error.test.js.map +1 -1
  38. package/dist/api/RootComponent/Properties/test/normalOptional.test.js +15 -0
  39. package/dist/api/RootComponent/Properties/test/normalOptional.test.js.map +1 -1
  40. package/dist/api/RootComponent/Properties/test/normalRequired.test.d.ts +21 -21
  41. package/dist/api/RootComponent/index.d.ts +19 -2
  42. package/dist/api/RootComponent/index.js +1 -1
  43. package/dist/api/RootComponent/index.js.map +1 -1
  44. package/dist/api/SubComponent/SubComputed/GetSubComputedDoc.d.ts +1 -1
  45. package/dist/api/SubComponent/SubComputed/test/normal.test.js +4 -4
  46. package/dist/api/SubComponent/SubComputed/test/normal.test.js.map +1 -1
  47. package/dist/api/SubComponent/index.d.ts +2 -2
  48. package/dist/api/SubComponent/index.js.map +1 -1
  49. package/dist/api/navigateTo.d.ts +1 -1
  50. package/dist/{utils → behaviors/BComputedAndWatch}/computedUpdater.d.ts +1 -1
  51. package/dist/{utils → behaviors/BComputedAndWatch}/computedUpdater.js +2 -2
  52. package/dist/behaviors/BComputedAndWatch/computedUpdater.js.map +1 -0
  53. package/dist/{utils → behaviors/BComputedAndWatch}/getPathsValue.d.ts +1 -1
  54. package/dist/behaviors/BComputedAndWatch/getPathsValue.js.map +1 -0
  55. package/dist/behaviors/BComputedAndWatch/index.js +8 -1
  56. package/dist/behaviors/BComputedAndWatch/index.js.map +1 -1
  57. package/dist/behaviors/BComputedAndWatch/initComputed.js +1 -1
  58. package/dist/behaviors/BComputedAndWatch/initComputed.js.map +1 -1
  59. package/dist/behaviors/BStore.js.map +1 -1
  60. package/dist/behaviors/BbeforeCreated.js +1 -2
  61. package/dist/behaviors/BbeforeCreated.js.map +1 -1
  62. package/dist/index.d.ts +3 -2
  63. package/dist/index.js +1 -1
  64. package/dist/index.js.map +1 -1
  65. package/dist/types/{SpecificType.d.ts → DetailedType.d.ts} +1 -1
  66. package/dist/types/DetailedType.js +2 -0
  67. package/dist/types/DetailedType.js.map +1 -0
  68. package/dist/types/GenerateDoc.d.ts +9 -0
  69. package/dist/types/GenerateDoc.js +2 -0
  70. package/dist/types/GenerateDoc.js.map +1 -0
  71. package/dist/types/InferDetailedType.d.ts +2 -0
  72. package/dist/types/InferDetailedType.js +2 -0
  73. package/dist/types/InferDetailedType.js.map +1 -0
  74. package/dist/types/{InferSpecificType.test.js → InferDetailedType.test.js} +1 -1
  75. package/dist/types/InferDetailedType.test.js.map +1 -0
  76. package/dist/types/OfficialTypeAlias.d.ts +6 -6
  77. package/package.json +3 -3
  78. package/src/api/DefineComponent/ReturnType/test/normalComponentDoc.test.ts +12 -12
  79. package/src/api/DefineComponent/ReturnType/test/normalPageDoc.test.ts +4 -4
  80. package/src/api/DefineComponent/collectOptionsForComponent.ts +290 -0
  81. package/src/api/DefineComponent/index.ts +12 -85
  82. package/src/api/RootComponent/Computed/test/normal.test.ts +2 -2
  83. package/src/api/RootComponent/CustomEvents/CustomEventConstraint.ts +6 -4
  84. package/src/api/RootComponent/CustomEvents/CustomEventsOption.ts +2 -2
  85. package/src/api/RootComponent/CustomEvents/GetCustomEventDoc.ts +7 -7
  86. package/src/api/RootComponent/CustomEvents/test/error.test.ts +8 -8
  87. package/src/api/RootComponent/CustomEvents/test/normal.test.ts +9 -9
  88. package/src/api/RootComponent/Data/DataConstraint.ts +1 -0
  89. package/src/api/RootComponent/Events/EventsConstraint.ts +1 -1
  90. package/src/api/RootComponent/Instance/test/CustomEventsDoc.test.ts +8 -8
  91. package/src/api/RootComponent/Instance/test/customEvents/normal.test.ts +8 -8
  92. package/src/api/RootComponent/Instance/test/properties/mormal.test.ts +3 -3
  93. package/src/api/RootComponent/IsPage/IsPageOption.ts +6 -1
  94. package/src/api/RootComponent/Lifetimes/LifetimesConstraint.ts +2 -2
  95. package/src/api/RootComponent/Lifetimes/test/error.test.ts +1 -1
  96. package/src/api/RootComponent/Lifetimes/test/normal.test.ts +3 -3
  97. package/src/api/RootComponent/PageLifetimes/test/normal.test.ts +3 -3
  98. package/src/api/RootComponent/Properties/GetOptionalDoc.ts +5 -5
  99. package/src/api/RootComponent/Properties/GetRequiredDoc.ts +5 -5
  100. package/src/api/RootComponent/Properties/PropertiesConstraint.ts +6 -6
  101. package/src/api/RootComponent/Properties/PropertiesOption.ts +1 -1
  102. package/src/api/RootComponent/Properties/PropertiesValueValidator.ts +2 -2
  103. package/src/api/RootComponent/Properties/test/error.test.ts +2 -2
  104. package/src/api/RootComponent/Properties/test/normalOptional.test.ts +25 -5
  105. package/src/api/RootComponent/Properties/test/normalRequired.test.ts +11 -11
  106. package/src/api/RootComponent/Watch/test/WatchComputed.test.ts +2 -2
  107. package/src/api/RootComponent/Watch/test/WatchProperties.test.ts +4 -4
  108. package/src/api/RootComponent/index.ts +19 -3
  109. package/src/api/SubComponent/SubComputed/test/normal.test.ts +15 -9
  110. package/src/api/SubComponent/index.ts +4 -4
  111. package/src/{utils → behaviors/BComputedAndWatch}/computedUpdater.ts +5 -4
  112. package/src/{utils → behaviors/BComputedAndWatch}/getPathsValue.ts +1 -1
  113. package/src/behaviors/BComputedAndWatch/index.ts +13 -4
  114. package/src/behaviors/BComputedAndWatch/initComputed.ts +1 -1
  115. package/src/behaviors/BStore.ts +2 -2
  116. package/src/behaviors/BbeforeCreated.ts +3 -3
  117. package/src/index.ts +11 -2
  118. package/src/types/DetailedType.ts +15 -0
  119. package/src/types/GenerateDoc.ts +19 -0
  120. package/src/types/InferDetailedType.test.ts +18 -0
  121. package/src/types/{InferSpecificType.ts → InferDetailedType.ts} +4 -4
  122. package/src/types/OfficialTypeAlias.ts +2 -2
  123. package/src/types/RestorePropertiesDoc.ts +3 -3
  124. package/tsconfig.json +7 -16
  125. package/dist/types/InferSpecificType.d.ts +0 -2
  126. package/dist/types/InferSpecificType.js +0 -2
  127. package/dist/types/InferSpecificType.js.map +0 -1
  128. package/dist/types/InferSpecificType.test.js.map +0 -1
  129. package/dist/types/SpecificType.js +0 -2
  130. package/dist/types/SpecificType.js.map +0 -1
  131. package/dist/utils/InternalFieldProtection.d.ts +0 -2
  132. package/dist/utils/InternalFieldProtection.js +0 -11
  133. package/dist/utils/InternalFieldProtection.js.map +0 -1
  134. package/dist/utils/collector.d.ts +0 -5
  135. package/dist/utils/collector.js +0 -21
  136. package/dist/utils/collector.js.map +0 -1
  137. package/dist/utils/computedUpdater.js.map +0 -1
  138. package/dist/utils/createdHijack.d.ts +0 -0
  139. package/dist/utils/createdHijack.js +0 -2
  140. package/dist/utils/createdHijack.js.map +0 -1
  141. package/dist/utils/customEventsHandle.d.ts +0 -2
  142. package/dist/utils/customEventsHandle.js +0 -20
  143. package/dist/utils/customEventsHandle.js.map +0 -1
  144. package/dist/utils/eventsHandle.d.ts +0 -2
  145. package/dist/utils/eventsHandle.js +0 -5
  146. package/dist/utils/eventsHandle.js.map +0 -1
  147. package/dist/utils/funcConfigHandle.d.ts +0 -2
  148. package/dist/utils/funcConfigHandle.js +0 -18
  149. package/dist/utils/funcConfigHandle.js.map +0 -1
  150. package/dist/utils/getPathsValue.js.map +0 -1
  151. package/dist/utils/initWatchOldValue.d.ts +0 -2
  152. package/dist/utils/initWatchOldValue.js +0 -10
  153. package/dist/utils/initWatchOldValue.js.map +0 -1
  154. package/dist/utils/onLoadHijack.d.ts +0 -3
  155. package/dist/utils/onLoadHijack.js +0 -16
  156. package/dist/utils/onLoadHijack.js.map +0 -1
  157. package/dist/utils/onLoadReceivedDataHandle.d.ts +0 -3
  158. package/dist/utils/onLoadReceivedDataHandle.js +0 -14
  159. package/dist/utils/onLoadReceivedDataHandle.js.map +0 -1
  160. package/dist/utils/rootComponentFieldHandle.d.ts +0 -3
  161. package/dist/utils/rootComponentFieldHandle.js +0 -13
  162. package/dist/utils/rootComponentFieldHandle.js.map +0 -1
  163. package/dist/utils/subComponentsHandle.d.ts +0 -3
  164. package/dist/utils/subComponentsHandle.js +0 -12
  165. package/dist/utils/subComponentsHandle.js.map +0 -1
  166. package/src/types/InferSpecificType.test.ts +0 -18
  167. package/src/types/SpecificType.ts +0 -19
  168. package/src/utils/InternalFieldProtection.ts +0 -18
  169. package/src/utils/collector.ts +0 -41
  170. package/src/utils/createdHijack.ts +0 -21
  171. package/src/utils/customEventsHandle.ts +0 -31
  172. package/src/utils/eventsHandle.ts +0 -10
  173. package/src/utils/funcConfigHandle.ts +0 -30
  174. package/src/utils/initWatchOldValue.ts +0 -12
  175. package/src/utils/onLoadHijack.ts +0 -30
  176. package/src/utils/onLoadReceivedDataHandle.ts +0 -31
  177. package/src/utils/rootComponentFieldHandle.ts +0 -27
  178. package/src/utils/subComponentsHandle.ts +0 -25
  179. /package/dist/{utils → behaviors/BComputedAndWatch}/getPathsValue.js +0 -0
  180. /package/dist/types/{InferSpecificType.test.d.ts → InferDetailedType.test.d.ts} +0 -0
@@ -1,40 +1,40 @@
1
1
  import { Checking, type Test } from "hry-types";
2
- import type { SpecificType } from "../../../..";
2
+ import type { DetailedType } from "../../../..";
3
3
  import { RootComponent } from "../..";
4
4
  RootComponent()({
5
5
  customEvents: {
6
6
  str: String,
7
- num: Number as SpecificType<1 | 2>,
8
- union: [String as SpecificType<"male" | "femal">, Number],
7
+ num: Number as DetailedType<1 | 2>,
8
+ union: [String as DetailedType<"male" | "femal">, Number],
9
9
  null: null,
10
10
  bubbles: {
11
- detailType: String,
11
+ detail: String,
12
12
  options: {
13
13
  bubbles: true,
14
14
  },
15
15
  },
16
16
  capturePhase: {
17
- detailType: Number,
17
+ detail: Number,
18
18
  options: {
19
19
  capturePhase: true,
20
20
  },
21
21
  },
22
22
  bubblesComposed: {
23
- detailType: Number,
23
+ detail: Number,
24
24
  options: {
25
25
  bubbles: true,
26
26
  composed: true,
27
27
  },
28
28
  },
29
29
  capturePhaseComposed: {
30
- detailType: Number,
30
+ detail: Number,
31
31
  options: {
32
32
  capturePhase: true,
33
33
  composed: true,
34
34
  },
35
35
  },
36
36
  bubblesCapturePhaseComposed: {
37
- detailType: null,
37
+ detail: null,
38
38
  options: {
39
39
  bubbles: true,
40
40
  capturePhase: true,
@@ -1,41 +1,41 @@
1
1
  import { Checking, type Test } from "hry-types";
2
- import type { SpecificType } from "../../../../..";
2
+ import type { DetailedType } from "../../../../..";
3
3
  import { RootComponent } from "../../..";
4
4
 
5
5
  RootComponent()({
6
6
  customEvents: {
7
7
  str: String,
8
- num: Number as SpecificType<1 | 2>,
9
- union: [String as SpecificType<"male" | "femal">, Number],
8
+ num: Number as DetailedType<1 | 2>,
9
+ union: [String as DetailedType<"male" | "femal">, Number],
10
10
  null: null,
11
11
  bubbles: {
12
- detailType: String,
12
+ detail: String,
13
13
  options: {
14
14
  bubbles: true,
15
15
  },
16
16
  },
17
17
  capturePhase: {
18
- detailType: Number,
18
+ detail: Number,
19
19
  options: {
20
20
  capturePhase: true,
21
21
  },
22
22
  },
23
23
  bubblesComposed: {
24
- detailType: Number,
24
+ detail: Number,
25
25
  options: {
26
26
  bubbles: true,
27
27
  composed: true,
28
28
  },
29
29
  },
30
30
  capturePhaseComposed: {
31
- detailType: Number,
31
+ detail: Number,
32
32
  options: {
33
33
  capturePhase: true,
34
34
  composed: true,
35
35
  },
36
36
  },
37
37
  bubblesCapturePhaseComposed: {
38
- detailType: null,
38
+ detail: null,
39
39
  options: {
40
40
  bubbles: true,
41
41
  capturePhase: true,
@@ -1,13 +1,13 @@
1
1
  import { Checking, type Test } from "hry-types";
2
2
  import type { ReadonlyDeep } from "hry-types/src/Any/ReadonlyDeep";
3
- import { RootComponent, type SpecificType } from "../../../../..";
3
+ import { type DetailedType, RootComponent } from "../../../../..";
4
4
 
5
5
  // 组件时
6
6
  RootComponent()({
7
7
  properties: {
8
8
  obj: Object,
9
9
  optionalObj: {
10
- type: Object as SpecificType<{ name: string }>,
10
+ type: Object as DetailedType<{ name: string }>,
11
11
  value: { name: "zhao" },
12
12
  },
13
13
  },
@@ -25,7 +25,7 @@ RootComponent()({
25
25
  properties: {
26
26
  obj: Object,
27
27
  optionalObj: {
28
- type: Object as SpecificType<{ name: string }>,
28
+ type: Object as DetailedType<{ name: string }>,
29
29
  value: { name: "zhao" },
30
30
  },
31
31
  },
@@ -1 +1,6 @@
1
- export type IsPageOption<TIsPage extends boolean> = { isPage?: TIsPage };
1
+ export type IsPageOption<TIsPage extends boolean> = {
2
+ /**
3
+ * 表示组件是否为页面,可选,默认false
4
+ */
5
+ isPage?: TIsPage;
6
+ };
@@ -1,5 +1,5 @@
1
1
  import type { WMCompLifetimes } from "../../../types/OfficialTypeAlias";
2
- import type { ComponentOptions } from "../../DefineComponent";
2
+ import type { FinalOptionsForComponent } from "../../DefineComponent";
3
3
 
4
4
  export type LifetimesConstraint = // 官方组件生命周期
5
5
  & WMCompLifetimes["lifetimes"]
@@ -7,5 +7,5 @@ export type LifetimesConstraint = // 官方组件生命周期
7
7
  /**
8
8
  * 建立组件时的真正配置对象
9
9
  */
10
- beforeCreate?: (options: ComponentOptions) => void;
10
+ beforeCreate?: (options: FinalOptionsForComponent) => void;
11
11
  };
@@ -4,7 +4,7 @@ import { RootComponent } from "../..";
4
4
  */
5
5
  RootComponent()({
6
6
  lifetimes: {
7
- // beforeCreate() {},
7
+ beforeCreate() {},
8
8
 
9
9
  created() {},
10
10
 
@@ -6,9 +6,9 @@ import { RootComponent } from "../../../..";
6
6
  RootComponent()({
7
7
  lifetimes: {
8
8
  // 新增声明周期用于查看实例初始化之前的配置文件
9
- // beforeCreate(opitons) {
10
- // opitons;
11
- // },
9
+ beforeCreate(opitons) {
10
+ opitons;
11
+ },
12
12
  created() {
13
13
  },
14
14
  attached() {
@@ -1,5 +1,5 @@
1
1
  import { Checking, type Test } from "hry-types";
2
- import { RootComponent, type SpecificType } from "../../../..";
2
+ import { type DetailedType, RootComponent } from "../../../..";
3
3
 
4
4
  import type { RemoveNullOfRequired } from "../../../../types/RemoveNullOfRequired";
5
5
  import type { Mock_User } from "../../Properties/test/normalRequired.test";
@@ -29,11 +29,11 @@ RootComponent()({
29
29
  str: String,
30
30
  obj: Object,
31
31
  union: {
32
- type: Object as SpecificType<Mock_User>,
32
+ type: Object as DetailedType<Mock_User>,
33
33
  value: { id: "001", name: "zhao" },
34
34
  },
35
35
  optionalObject: {
36
- type: Object as SpecificType<Mock_User | null>,
36
+ type: Object as DetailedType<Mock_User | null>,
37
37
  value: null,
38
38
  },
39
39
  },
@@ -1,7 +1,7 @@
1
1
  import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
2
  import type { Select } from "hry-types/src/Object/Select";
3
3
  import type { AddNullForObject } from "../../../types/AddNullForObject";
4
- import type { InferSpecificType } from "../../../types/InferSpecificType";
4
+ import type { InferDetailedType } from "../../../types/InferDetailedType";
5
5
  import type { OptionalType, PropertiesConstraint } from "./PropertiesConstraint";
6
6
 
7
7
  /**
@@ -20,19 +20,19 @@ export type GetOptionalDoc<
20
20
  false,
21
21
  TIsPage,
22
22
  // 组件时 对象加null
23
- AddNullForObject<InferSpecificType<Optional[k]["type"]>>,
23
+ AddNullForObject<InferDetailedType<Optional[k]["type"]>>,
24
24
  // 页面时 对象不加
25
- InferSpecificType<Optional[k]["type"]>
25
+ InferDetailedType<Optional[k]["type"]>
26
26
  >,
27
27
  IfExtends<
28
28
  false,
29
29
  TIsPage,
30
30
  // 组件时 对象加null
31
31
  AddNullForObject<
32
- InferSpecificType<Optional[k]["type"]> | InferSpecificType<(Optional[k]["optionalTypes"] & {})[number]>
32
+ InferDetailedType<Optional[k]["type"]> | InferDetailedType<(Optional[k]["optionalTypes"] & {})[number]>
33
33
  >,
34
34
  // 页面时 对象不加
35
- InferSpecificType<Optional[k]["type"]> | InferSpecificType<(Optional[k]["optionalTypes"] & {})[number]>
35
+ InferDetailedType<Optional[k]["type"]> | InferDetailedType<(Optional[k]["optionalTypes"] & {})[number]>
36
36
  >
37
37
  >;
38
38
  };
@@ -1,7 +1,7 @@
1
1
  import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
2
  import type { Select } from "hry-types/src/Object/Select";
3
3
  import type { AddNullForObject } from "../../../types/AddNullForObject";
4
- import type { InferSpecificType } from "../../../types/InferSpecificType";
4
+ import type { InferDetailedType } from "../../../types/InferDetailedType";
5
5
  import type { PropertiesConstraint, RequiredSingle, RequiredType } from "./PropertiesConstraint";
6
6
 
7
7
  /**
@@ -17,16 +17,16 @@ export type GetRequiredDoc<
17
17
  [k in keyof Required]: IfExtends<
18
18
  Required[k],
19
19
  RequiredSingle,
20
- IfExtends<false, TIsPage, AddNullForObject<InferSpecificType<Required[k]>>, InferSpecificType<Required[k]>>,
20
+ IfExtends<false, TIsPage, AddNullForObject<InferDetailedType<Required[k]>>, InferDetailedType<Required[k]>>,
21
21
  IfExtends<
22
22
  false,
23
23
  TIsPage,
24
24
  // @ts-ignore Required[k] 必为 RequiredUnion
25
- | AddNullForObject<InferSpecificType<Required[k]["type"]>>
25
+ | AddNullForObject<InferDetailedType<Required[k]["type"]>>
26
26
  // @ts-ignore Required[k] 必为 RequiredUnion
27
- | AddNullForObject<InferSpecificType<Required[k]["optionalTypes"][number]>>,
27
+ | AddNullForObject<InferDetailedType<Required[k]["optionalTypes"][number]>>,
28
28
  // @ts-ignore Required[k] 必为 RequiredUnion
29
- InferSpecificType<Required[k]["type"]> | InferSpecificType<Required[k]["optionalTypes"][number]>
29
+ InferDetailedType<Required[k]["type"]> | InferDetailedType<Required[k]["optionalTypes"][number]>
30
30
  >
31
31
  >;
32
32
  };
@@ -1,16 +1,16 @@
1
- import type { SpecificType } from "../../../types/SpecificType";
1
+ import type { DetailedType } from "../../../types/DetailedType";
2
2
 
3
3
  /**
4
4
  * properties 必传(单一)类型
5
5
  */
6
- export type RequiredSingle = SpecificType;
6
+ export type RequiredSingle = DetailedType;
7
7
 
8
8
  /**
9
9
  * properties 必传(联合)类型
10
10
  */
11
11
  export type RequiredUnion<Literal = unknown> = {
12
- type: SpecificType<Literal>;
13
- optionalTypes: SpecificType[];
12
+ type: DetailedType<Literal>;
13
+ optionalTypes: DetailedType[];
14
14
  };
15
15
 
16
16
  /**
@@ -22,9 +22,9 @@ export type RequiredType<Literal = unknown> = RequiredUnion<Literal> | RequiredS
22
22
  * properties 选传类型
23
23
  */
24
24
  export type OptionalType<Literal = unknown> = {
25
- type: SpecificType<Literal>;
25
+ type: DetailedType<Literal>;
26
26
  value: Literal;
27
- optionalTypes?: SpecificType[];
27
+ optionalTypes?: DetailedType[];
28
28
  };
29
29
 
30
30
  /**
@@ -13,7 +13,7 @@ export type PropertiesOption<
13
13
  = // DuplicateFieldCheck extends PropertyKey = "",
14
14
  {
15
15
  /**
16
- * 可通过 as SpecificType<anyType> 书写任意类型
16
+ * 可通过 as DetailedType<anyType> 书写任意类型
17
17
  * @remarks 禁用observable字段,简写或对象写法无value字段时为必传属性(必传对象类型加入null类型),对象写法有value字段为可选属性.
18
18
  */
19
19
  properties?:
@@ -1,5 +1,5 @@
1
1
  import type { EmptyObject } from "hry-types/src/Misc/EmptyObject";
2
- import type { InferSpecificType } from "../../../types/InferSpecificType";
2
+ import type { InferDetailedType } from "../../../types/InferDetailedType";
3
3
 
4
4
  /**
5
5
  * 验证properties的value类型是否正确
@@ -12,7 +12,7 @@ export type PropertiesValueValidator<
12
12
  k in keyof TProperties as TProperties[k] extends {
13
13
  type: infer R;
14
14
  value: infer V;
15
- } ? V extends InferSpecificType<R> ? never
15
+ } ? V extends InferDetailedType<R> ? never
16
16
  : k
17
17
  : never
18
18
  ]: { value: () => "⚠️类型错误⚠️" };
@@ -1,4 +1,4 @@
1
- import { RootComponent, type SpecificType } from "../../../../index";
1
+ import { type DetailedType, RootComponent } from "../../../../index";
2
2
  import type { Mock_Cart } from "./normalRequired.test";
3
3
 
4
4
  // 1 非法字段
@@ -35,7 +35,7 @@ RootComponent()({
35
35
  },
36
36
  optionalObj: {
37
37
  // @ts-expect-error 对象默认值要写null则必须先定义
38
- type: Object as SpecificType<Mock_Cart>,
38
+ type: Object as DetailedType<Mock_Cart>,
39
39
  // @ts-expect-error 对象默认值要写null则必须先定义
40
40
  value: null,
41
41
  },
@@ -1,6 +1,6 @@
1
1
  import { Checking, type Test } from "hry-types";
2
2
  import type { ReadonlyDeep } from "hry-types/src/Any/_api";
3
- import type { SpecificType } from "../../../../types/SpecificType";
3
+ import type { DetailedType } from "../../../../types/DetailedType";
4
4
  import { RootComponent } from "../..";
5
5
  import { type Mock_User } from "./normalRequired.test";
6
6
 
@@ -14,22 +14,22 @@ const OptionalDoc = RootComponent()({
14
14
  value: 123,
15
15
  },
16
16
  optional_gender: {
17
- type: String as SpecificType<"male" | "female">, // 同类字面量联合类型
17
+ type: String as DetailedType<"male" | "female">, // 同类字面量联合类型
18
18
  value: "male",
19
19
  },
20
20
  optional_tuple: {
21
- type: Array as unknown as SpecificType<[number, string, boolean]>, // 元组类型
21
+ type: Array as unknown as DetailedType<[number, string, boolean]>, // 元组类型
22
22
  value: [1, "a", true] as [number, string, boolean],
23
23
  },
24
24
  optional_obj: {
25
- type: Object as SpecificType<Mock_User>, // 对象类型
25
+ type: Object as DetailedType<Mock_User>, // 对象类型
26
26
  value: {
27
27
  id: "id",
28
28
  age: 20,
29
29
  },
30
30
  },
31
31
  optional_objOrNull: {
32
- type: Object as SpecificType<Mock_User | null>, // 对象类型与null的联合
32
+ type: Object as DetailedType<Mock_User | null>, // 对象类型与null的联合
33
33
  value: null,
34
34
  },
35
35
  optional_union: { // 非同类联合类型 string | number
@@ -73,3 +73,23 @@ type OptionalDocExpected = {
73
73
  };
74
74
 
75
75
  Checking<typeof OptionalDoc, OptionalDocExpected, Test.Pass>;
76
+
77
+ // properties 使用DetailedType时,接受interface类型
78
+ interface Foo {
79
+ name: string;
80
+ }
81
+
82
+ RootComponent()({
83
+ properties: {
84
+ xxx: Object as DetailedType<{ dd: Foo }>,
85
+ user: {
86
+ type: Object as DetailedType<Foo>,
87
+ value: { name: "zhao" },
88
+ },
89
+ },
90
+ computed: {
91
+ ddd() {
92
+ this.data.user?.name;
93
+ },
94
+ },
95
+ });
@@ -1,5 +1,5 @@
1
1
  import { Checking, type Test } from "hry-types";
2
- import type { SpecificType } from "../../../../types/SpecificType";
2
+ import type { DetailedType } from "../../../../types/DetailedType";
3
3
 
4
4
  import type { ReadonlyDeep } from "hry-types/src/Any/_api";
5
5
  import { RootComponent } from "../..";
@@ -30,12 +30,12 @@ export const mock_requiredSingle = {
30
30
  bool: Boolean,
31
31
  arr: Array,
32
32
  obj: Object,
33
- tuple: Array as unknown as SpecificType<[string, number, boolean]>,
34
- union_str: String as SpecificType<"male" | "female">,
35
- union_num: Number as SpecificType<0 | 1 | 2>,
36
- union_bool: Boolean as SpecificType<false | true>,
37
- union_arr: Array as SpecificType<number[] | string[]>,
38
- union_obj: Object as SpecificType<Mock_User | Mock_Cart>,
33
+ tuple: Array as unknown as DetailedType<[string, number, boolean]>,
34
+ union_str: String as DetailedType<"male" | "female">,
35
+ union_num: Number as DetailedType<0 | 1 | 2>,
36
+ union_bool: Boolean as DetailedType<false | true>,
37
+ union_arr: Array as DetailedType<number[] | string[]>,
38
+ union_obj: Object as DetailedType<Mock_User | Mock_Cart>,
39
39
  } satisfies Record<string, RequiredSingle>;
40
40
 
41
41
  /**
@@ -47,16 +47,16 @@ export const mock_requiredUnion = {
47
47
  optionalTypes: [Number, Boolean],
48
48
  },
49
49
  union_literalStr_Literalnum: {
50
- type: String as SpecificType<"male" | "female">,
51
- optionalTypes: [Number as SpecificType<0 | 1 | 2>],
50
+ type: String as DetailedType<"male" | "female">,
51
+ optionalTypes: [Number as DetailedType<0 | 1 | 2>],
52
52
  },
53
53
  union_mockUser_num: {
54
- type: Object as SpecificType<Mock_User>,
54
+ type: Object as DetailedType<Mock_User>,
55
55
  optionalTypes: [Number],
56
56
  },
57
57
  union_num_mockUser: {
58
58
  type: Number,
59
- optionalTypes: [Object as SpecificType<Mock_User>],
59
+ optionalTypes: [Object as DetailedType<Mock_User>],
60
60
  },
61
61
  } satisfies Record<string, RequiredUnion>;
62
62
 
@@ -1,6 +1,6 @@
1
1
  import { Checking, type Test } from "hry-types";
2
2
  import type { ReadonlyDeep } from "hry-types/src/Any/_api";
3
- import type { SpecificType } from "../../../../types/SpecificType";
3
+ import type { DetailedType } from "../../../../types/DetailedType";
4
4
  import { RootComponent } from "../..";
5
5
  import type { Mock_User } from "../../Properties/test/normalRequired.test";
6
6
 
@@ -10,7 +10,7 @@ import type { Mock_User } from "../../Properties/test/normalRequired.test";
10
10
  RootComponent()({
11
11
  properties: {
12
12
  Pnum: Number,
13
- obj: Object as SpecificType<Mock_User>,
13
+ obj: Object as DetailedType<Mock_User>,
14
14
  },
15
15
  data: {
16
16
  DNum: 123,
@@ -3,7 +3,7 @@ import { Checking, type Test } from "hry-types";
3
3
  import type { ReadonlyDeep } from "hry-types/src/Any/_api";
4
4
  import { RootComponent } from "../..";
5
5
 
6
- import type { SpecificType } from "../../../..";
6
+ import type { DetailedType } from "../../../..";
7
7
  // import {
8
8
  // type Mock_Cart,
9
9
  // mock_requiredTypes,
@@ -23,11 +23,11 @@ const mock_optional = {
23
23
  value: 123,
24
24
  },
25
25
  optional_gender: {
26
- type: String as SpecificType<"male" | "female">,
26
+ type: String as DetailedType<"male" | "female">,
27
27
  value: "male" as const,
28
28
  },
29
29
  optional_obj: {
30
- type: Object as SpecificType<Mock_User>,
30
+ type: Object as DetailedType<Mock_User>,
31
31
  value: {
32
32
  id: "id",
33
33
  name: "name",
@@ -35,7 +35,7 @@ const mock_optional = {
35
35
  },
36
36
  },
37
37
  optional_objOrNull: {
38
- type: Object as SpecificType<Mock_User | null>, // 可选类型定义null默认值方可为null
38
+ type: Object as DetailedType<Mock_User | null>, // 可选类型定义null默认值方可为null
39
39
  value: null,
40
40
  },
41
41
  } satisfies Record<string, OptionalType>;
@@ -3,7 +3,7 @@ import type { NoInfer } from "hry-types/src/Generic/NoInfer";
3
3
  import type { EmptyObject } from "hry-types/src/Misc/EmptyObject";
4
4
  import type { Func } from "hry-types/src/Misc/Func";
5
5
  import type { ComputeIntersectionDeep } from "hry-types/src/Object/_api";
6
- import type { WMCompOtherOption } from "../../types/OfficialTypeAlias";
6
+ import type { WMCompOtherOption, WMCompPageLifetimes, WMPageLifetimes } from "../../types/OfficialTypeAlias";
7
7
  import type { ComponentDoc } from "../DefineComponent/ReturnType/ComponentDoc";
8
8
  import type { ComputedConstraint } from "./Computed/ComputedConstraint";
9
9
  import type { ComputedOption } from "./Computed/ComputedOption";
@@ -11,11 +11,13 @@ import type { GetComputedDoc } from "./Computed/GetComputedDoc";
11
11
  import type { CustomEventConstraint } from "./CustomEvents/CustomEventConstraint";
12
12
  import type { CustomEventsOption } from "./CustomEvents/CustomEventsOption";
13
13
  import type { GetCustomEventDoc } from "./CustomEvents/GetCustomEventDoc";
14
+ import type { DataConstraint } from "./Data/DataConstraint";
14
15
  import type { DataOption } from "./Data/DataOption";
15
16
  import type { EventsConstraint } from "./Events/EventsConstraint";
16
17
  import type { EventsOption } from "./Events/EventsOption";
17
18
  import type { RootComponentInstance } from "./Instance/RootComponentInstance";
18
19
  import type { IsPageOption } from "./IsPage/IsPageOption";
20
+ import type { LifetimesConstraint } from "./Lifetimes/LifetimesConstraint";
19
21
  import type { LifetimesOption } from "./Lifetimes/LifetimesOption";
20
22
  import type { MethodsConstraint } from "./Methods/MethodsConstraint";
21
23
  import type { MethodsOption } from "./Methods/MethodsOption";
@@ -81,7 +83,7 @@ type RootComponentConstructor<TReceivedComponentDoc extends ComponentDoc[] | Com
81
83
  | boolean
82
84
  | null
83
85
  | Literal[]
84
- | Record<string, Literal>,
86
+ | object,
85
87
  // TEvents 不能有默认值 {} 会引起事件参数类型(e)失效
86
88
  TEvents extends EventsConstraint<TReceivedComponentDoc>,
87
89
  TIsPage extends boolean = false,
@@ -135,5 +137,19 @@ export function RootComponent<
135
137
  >(): RootComponentConstructor<
136
138
  TReceivedComponentDoc
137
139
  > {
138
- return (options: any) => options;
140
+ return ((options: any) => options as RootComponentTrueOptions) as any;
139
141
  }
142
+
143
+ export type RootComponentTrueOptions = {
144
+ isPage?: boolean;
145
+ properties?: PropertiesConstraint;
146
+ data?: DataConstraint;
147
+ computed?: ComputedConstraint;
148
+ customEvents?: CustomEventConstraint;
149
+ methods?: MethodsConstraint;
150
+ events?: EventsConstraint;
151
+ store?: StoreConstraint;
152
+ watch?: Record<string, Func>;
153
+ lifetimes?: LifetimesConstraint;
154
+ pageLifetimes?: Partial<WMCompPageLifetimes & { load: Func } & WMPageLifetimes>;
155
+ };
@@ -19,11 +19,18 @@ type Root = {
19
19
  data: {
20
20
  str: string;
21
21
  };
22
+ store: {
23
+ SNum: number;
24
+ };
22
25
  computed: {
23
26
  bool: boolean;
24
27
  };
25
28
  };
26
29
 
30
+ type $aaa = ComponentDoc<
31
+ { properties: { aaa_str: string; aaa_user: User | null; aaa_num: number; aaa_age: number } }
32
+ >;
33
+
27
34
  SubComponent<{}, OnlyCustomCompDoc>()({
28
35
  // 1 CompDoc的properties为空时,可以写{}
29
36
  computed: {},
@@ -76,6 +83,7 @@ SubComponent<Root, OnlyPropsCompDoc>()({
76
83
  ReadonlyDeep<{
77
84
  num: number;
78
85
  user: User | null;
86
+ SNum: number;
79
87
  str: string;
80
88
  bool: boolean;
81
89
  aaa_num: number;
@@ -98,6 +106,7 @@ SubComponent<Root, OnlyPropsCompDoc>()({
98
106
  num: number;
99
107
  user: User | null;
100
108
  str: string;
109
+ SNum: number;
101
110
  bool: boolean;
102
111
  aaa_num: number;
103
112
  aaa_num123: 123;
@@ -110,18 +119,12 @@ SubComponent<Root, OnlyPropsCompDoc>()({
110
119
  },
111
120
  });
112
121
 
113
- // 计算属性可互相引用 !!!但是没有自动提示!!!
114
- type CompDoc = ComponentDoc<
115
- { properties: { aaa_num: number; aaa_user: User | null; aaa_xxx: number; aaa_age: number } }
116
- >;
122
+ // 计算属性可互相引用,但要加返回类型注释
117
123
 
118
- SubComponent<Root, CompDoc>()({
119
- data: {
120
- aaa_xxx: 123,
121
- },
124
+ SubComponent<Root, $aaa>()({
122
125
  computed: {
123
126
  aaa_num(): number {
124
- return this.data.aaa_xxx;
127
+ return this.data.SNum;
125
128
  },
126
129
  aaa_user(): User | null {
127
130
  return this.data.user;
@@ -129,5 +132,8 @@ SubComponent<Root, CompDoc>()({
129
132
  aaa_age(): number {
130
133
  return this.data.aaa_num;
131
134
  },
135
+ aaa_str(): string {
136
+ return this.data.str;
137
+ },
132
138
  },
133
139
  });
@@ -106,7 +106,8 @@ type SubComponentConstructor<
106
106
  AllRootDataDoc extends object =
107
107
  & Required<TRootDoc["properties"]>
108
108
  & TRootDoc["data"]
109
- & TRootDoc["computed"],
109
+ & TRootDoc["computed"]
110
+ & TRootDoc["store"],
110
111
  > = {
111
112
  <
112
113
  TInherit extends InheritConstraint<AllRootDataDoc, CurrentCompDoc>,
@@ -196,11 +197,10 @@ export function SubComponent<
196
197
  CompDoc extends ComponentDoc,
197
198
  Prefix extends string = "",
198
199
  >(): IfExtends<EmptyObject, CompDoc, (opt: EmptyObject) => never, SubComponentConstructor<RootDoc, CompDoc, Prefix>> {
199
- return ((options: any) => options) as any;
200
+ return ((options: any) => options as SubComponentTrueOptions) as any;
200
201
  }
201
202
 
202
- // 相比与 export type TrivialOption = Options<{},...>,更直观字段和类型,但断耦合,注意类型是否正确.这是为最终生成官方Component API 的options参数而生。
203
- export type SubComponentOptions = {
203
+ export type SubComponentTrueOptions = {
204
204
  inhrit?: string;
205
205
  data?: Record<string, unknown>;
206
206
  computed?: Record<string, Func>;
@@ -1,9 +1,10 @@
1
- import { deepProxy, unwrap } from "../behaviors/BComputedAndWatch/data-tracer";
2
- import type { ComputedDependence } from "../behaviors/BComputedAndWatch/initComputed";
3
- import { isEqual } from "../behaviors/BComputedAndWatch/isEqual";
4
- import type { Instance } from "../behaviors/BComputedAndWatch/types";
1
+ import { deepProxy, unwrap } from "./data-tracer";
5
2
  import { getPathsValue } from "./getPathsValue";
6
3
 
4
+ import type { ComputedDependence } from "./initComputed";
5
+ import { isEqual } from "./isEqual";
6
+ import type { Instance } from "./types";
7
+
7
8
  export function computedUpdater(this: Instance, isUpdated = false): boolean {
8
9
  // console.log("computedUpdater开始");
9
10
 
@@ -1,4 +1,4 @@
1
- import type { Instance } from "../behaviors/BComputedAndWatch/types";
1
+ import type { Instance } from "./types";
2
2
 
3
3
  export function getPathsValue(this: Instance, paths: string[]) {
4
4
  return paths.reduce((pre: any, path) => {