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.
- package/CHANGELOG.md +19 -0
- package/README.md +105 -6
- package/dist/api/DefineComponent/ReturnType/test/normalComponentDoc.test.js +6 -6
- package/dist/api/DefineComponent/ReturnType/test/normalComponentDoc.test.js.map +1 -1
- package/dist/api/DefineComponent/ReturnType/test/normalPageDoc.test.js.map +1 -1
- package/dist/api/DefineComponent/collectOptionsForComponent.d.ts +4 -0
- package/dist/api/DefineComponent/collectOptionsForComponent.js +152 -0
- package/dist/api/DefineComponent/collectOptionsForComponent.js.map +1 -0
- package/dist/api/DefineComponent/index.d.ts +4 -28
- package/dist/api/DefineComponent/index.js +2 -37
- package/dist/api/DefineComponent/index.js.map +1 -1
- package/dist/api/RootComponent/CustomEvents/CustomEventConstraint.d.ts +5 -4
- package/dist/api/RootComponent/CustomEvents/GetCustomEventDoc.d.ts +5 -5
- package/dist/api/RootComponent/CustomEvents/test/error.test.js +8 -8
- package/dist/api/RootComponent/CustomEvents/test/error.test.js.map +1 -1
- package/dist/api/RootComponent/CustomEvents/test/normal.test.d.ts +17 -17
- package/dist/api/RootComponent/CustomEvents/test/normal.test.js +6 -6
- package/dist/api/RootComponent/CustomEvents/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/Data/DataConstraint.d.ts +1 -0
- package/dist/api/RootComponent/Data/DataConstraint.js +2 -0
- package/dist/api/RootComponent/Data/DataConstraint.js.map +1 -0
- package/dist/api/RootComponent/Instance/test/CustomEventsDoc.test.js +5 -5
- package/dist/api/RootComponent/Instance/test/CustomEventsDoc.test.js.map +1 -1
- package/dist/api/RootComponent/Instance/test/customEvents/normal.test.js +5 -5
- package/dist/api/RootComponent/Instance/test/customEvents/normal.test.js.map +1 -1
- package/dist/api/RootComponent/Instance/test/properties/mormal.test.js.map +1 -1
- package/dist/api/RootComponent/Lifetimes/LifetimesConstraint.d.ts +2 -2
- package/dist/api/RootComponent/Lifetimes/test/error.test.js +1 -0
- package/dist/api/RootComponent/Lifetimes/test/error.test.js.map +1 -1
- package/dist/api/RootComponent/Lifetimes/test/normal.test.js +3 -0
- package/dist/api/RootComponent/Lifetimes/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/PageLifetimes/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/Properties/GetOptionalDoc.d.ts +2 -2
- package/dist/api/RootComponent/Properties/GetRequiredDoc.d.ts +2 -2
- package/dist/api/RootComponent/Properties/PropertiesConstraint.d.ts +6 -6
- package/dist/api/RootComponent/Properties/PropertiesValueValidator.d.ts +2 -2
- package/dist/api/RootComponent/Properties/test/error.test.js.map +1 -1
- package/dist/api/RootComponent/Properties/test/normalOptional.test.js +15 -0
- package/dist/api/RootComponent/Properties/test/normalOptional.test.js.map +1 -1
- package/dist/api/RootComponent/Properties/test/normalRequired.test.d.ts +21 -21
- package/dist/api/RootComponent/index.d.ts +19 -2
- package/dist/api/RootComponent/index.js +1 -1
- package/dist/api/RootComponent/index.js.map +1 -1
- package/dist/api/SubComponent/SubComputed/GetSubComputedDoc.d.ts +1 -1
- package/dist/api/SubComponent/SubComputed/test/normal.test.js +4 -4
- package/dist/api/SubComponent/SubComputed/test/normal.test.js.map +1 -1
- package/dist/api/SubComponent/index.d.ts +2 -2
- package/dist/api/SubComponent/index.js.map +1 -1
- package/dist/api/navigateTo.d.ts +1 -1
- package/dist/{utils → behaviors/BComputedAndWatch}/computedUpdater.d.ts +1 -1
- package/dist/{utils → behaviors/BComputedAndWatch}/computedUpdater.js +2 -2
- package/dist/behaviors/BComputedAndWatch/computedUpdater.js.map +1 -0
- package/dist/{utils → behaviors/BComputedAndWatch}/getPathsValue.d.ts +1 -1
- package/dist/behaviors/BComputedAndWatch/getPathsValue.js.map +1 -0
- package/dist/behaviors/BComputedAndWatch/index.js +8 -1
- package/dist/behaviors/BComputedAndWatch/index.js.map +1 -1
- package/dist/behaviors/BComputedAndWatch/initComputed.js +1 -1
- package/dist/behaviors/BComputedAndWatch/initComputed.js.map +1 -1
- package/dist/behaviors/BStore.js.map +1 -1
- package/dist/behaviors/BbeforeCreated.js +1 -2
- package/dist/behaviors/BbeforeCreated.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/{SpecificType.d.ts → DetailedType.d.ts} +1 -1
- package/dist/types/DetailedType.js +2 -0
- package/dist/types/DetailedType.js.map +1 -0
- package/dist/types/GenerateDoc.d.ts +9 -0
- package/dist/types/GenerateDoc.js +2 -0
- package/dist/types/GenerateDoc.js.map +1 -0
- package/dist/types/InferDetailedType.d.ts +2 -0
- package/dist/types/InferDetailedType.js +2 -0
- package/dist/types/InferDetailedType.js.map +1 -0
- package/dist/types/{InferSpecificType.test.js → InferDetailedType.test.js} +1 -1
- package/dist/types/InferDetailedType.test.js.map +1 -0
- package/dist/types/OfficialTypeAlias.d.ts +6 -6
- package/package.json +3 -3
- package/src/api/DefineComponent/ReturnType/test/normalComponentDoc.test.ts +12 -12
- package/src/api/DefineComponent/ReturnType/test/normalPageDoc.test.ts +4 -4
- package/src/api/DefineComponent/collectOptionsForComponent.ts +290 -0
- package/src/api/DefineComponent/index.ts +12 -85
- package/src/api/RootComponent/Computed/test/normal.test.ts +2 -2
- package/src/api/RootComponent/CustomEvents/CustomEventConstraint.ts +6 -4
- package/src/api/RootComponent/CustomEvents/CustomEventsOption.ts +2 -2
- package/src/api/RootComponent/CustomEvents/GetCustomEventDoc.ts +7 -7
- package/src/api/RootComponent/CustomEvents/test/error.test.ts +8 -8
- package/src/api/RootComponent/CustomEvents/test/normal.test.ts +9 -9
- package/src/api/RootComponent/Data/DataConstraint.ts +1 -0
- package/src/api/RootComponent/Events/EventsConstraint.ts +1 -1
- package/src/api/RootComponent/Instance/test/CustomEventsDoc.test.ts +8 -8
- package/src/api/RootComponent/Instance/test/customEvents/normal.test.ts +8 -8
- package/src/api/RootComponent/Instance/test/properties/mormal.test.ts +3 -3
- package/src/api/RootComponent/IsPage/IsPageOption.ts +6 -1
- package/src/api/RootComponent/Lifetimes/LifetimesConstraint.ts +2 -2
- package/src/api/RootComponent/Lifetimes/test/error.test.ts +1 -1
- package/src/api/RootComponent/Lifetimes/test/normal.test.ts +3 -3
- package/src/api/RootComponent/PageLifetimes/test/normal.test.ts +3 -3
- package/src/api/RootComponent/Properties/GetOptionalDoc.ts +5 -5
- package/src/api/RootComponent/Properties/GetRequiredDoc.ts +5 -5
- package/src/api/RootComponent/Properties/PropertiesConstraint.ts +6 -6
- package/src/api/RootComponent/Properties/PropertiesOption.ts +1 -1
- package/src/api/RootComponent/Properties/PropertiesValueValidator.ts +2 -2
- package/src/api/RootComponent/Properties/test/error.test.ts +2 -2
- package/src/api/RootComponent/Properties/test/normalOptional.test.ts +25 -5
- package/src/api/RootComponent/Properties/test/normalRequired.test.ts +11 -11
- package/src/api/RootComponent/Watch/test/WatchComputed.test.ts +2 -2
- package/src/api/RootComponent/Watch/test/WatchProperties.test.ts +4 -4
- package/src/api/RootComponent/index.ts +19 -3
- package/src/api/SubComponent/SubComputed/test/normal.test.ts +15 -9
- package/src/api/SubComponent/index.ts +4 -4
- package/src/{utils → behaviors/BComputedAndWatch}/computedUpdater.ts +5 -4
- package/src/{utils → behaviors/BComputedAndWatch}/getPathsValue.ts +1 -1
- package/src/behaviors/BComputedAndWatch/index.ts +13 -4
- package/src/behaviors/BComputedAndWatch/initComputed.ts +1 -1
- package/src/behaviors/BStore.ts +2 -2
- package/src/behaviors/BbeforeCreated.ts +3 -3
- package/src/index.ts +11 -2
- package/src/types/DetailedType.ts +15 -0
- package/src/types/GenerateDoc.ts +19 -0
- package/src/types/InferDetailedType.test.ts +18 -0
- package/src/types/{InferSpecificType.ts → InferDetailedType.ts} +4 -4
- package/src/types/OfficialTypeAlias.ts +2 -2
- package/src/types/RestorePropertiesDoc.ts +3 -3
- package/tsconfig.json +7 -16
- package/dist/types/InferSpecificType.d.ts +0 -2
- package/dist/types/InferSpecificType.js +0 -2
- package/dist/types/InferSpecificType.js.map +0 -1
- package/dist/types/InferSpecificType.test.js.map +0 -1
- package/dist/types/SpecificType.js +0 -2
- package/dist/types/SpecificType.js.map +0 -1
- package/dist/utils/InternalFieldProtection.d.ts +0 -2
- package/dist/utils/InternalFieldProtection.js +0 -11
- package/dist/utils/InternalFieldProtection.js.map +0 -1
- package/dist/utils/collector.d.ts +0 -5
- package/dist/utils/collector.js +0 -21
- package/dist/utils/collector.js.map +0 -1
- package/dist/utils/computedUpdater.js.map +0 -1
- package/dist/utils/createdHijack.d.ts +0 -0
- package/dist/utils/createdHijack.js +0 -2
- package/dist/utils/createdHijack.js.map +0 -1
- package/dist/utils/customEventsHandle.d.ts +0 -2
- package/dist/utils/customEventsHandle.js +0 -20
- package/dist/utils/customEventsHandle.js.map +0 -1
- package/dist/utils/eventsHandle.d.ts +0 -2
- package/dist/utils/eventsHandle.js +0 -5
- package/dist/utils/eventsHandle.js.map +0 -1
- package/dist/utils/funcConfigHandle.d.ts +0 -2
- package/dist/utils/funcConfigHandle.js +0 -18
- package/dist/utils/funcConfigHandle.js.map +0 -1
- package/dist/utils/getPathsValue.js.map +0 -1
- package/dist/utils/initWatchOldValue.d.ts +0 -2
- package/dist/utils/initWatchOldValue.js +0 -10
- package/dist/utils/initWatchOldValue.js.map +0 -1
- package/dist/utils/onLoadHijack.d.ts +0 -3
- package/dist/utils/onLoadHijack.js +0 -16
- package/dist/utils/onLoadHijack.js.map +0 -1
- package/dist/utils/onLoadReceivedDataHandle.d.ts +0 -3
- package/dist/utils/onLoadReceivedDataHandle.js +0 -14
- package/dist/utils/onLoadReceivedDataHandle.js.map +0 -1
- package/dist/utils/rootComponentFieldHandle.d.ts +0 -3
- package/dist/utils/rootComponentFieldHandle.js +0 -13
- package/dist/utils/rootComponentFieldHandle.js.map +0 -1
- package/dist/utils/subComponentsHandle.d.ts +0 -3
- package/dist/utils/subComponentsHandle.js +0 -12
- package/dist/utils/subComponentsHandle.js.map +0 -1
- package/src/types/InferSpecificType.test.ts +0 -18
- package/src/types/SpecificType.ts +0 -19
- package/src/utils/InternalFieldProtection.ts +0 -18
- package/src/utils/collector.ts +0 -41
- package/src/utils/createdHijack.ts +0 -21
- package/src/utils/customEventsHandle.ts +0 -31
- package/src/utils/eventsHandle.ts +0 -10
- package/src/utils/funcConfigHandle.ts +0 -30
- package/src/utils/initWatchOldValue.ts +0 -12
- package/src/utils/onLoadHijack.ts +0 -30
- package/src/utils/onLoadReceivedDataHandle.ts +0 -31
- package/src/utils/rootComponentFieldHandle.ts +0 -27
- package/src/utils/subComponentsHandle.ts +0 -25
- /package/dist/{utils → behaviors/BComputedAndWatch}/getPathsValue.js +0 -0
- /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 {
|
|
2
|
+
import type { DetailedType } from "../../../..";
|
|
3
3
|
import { RootComponent } from "../..";
|
|
4
4
|
RootComponent()({
|
|
5
5
|
customEvents: {
|
|
6
6
|
str: String,
|
|
7
|
-
num: Number as
|
|
8
|
-
union: [String as
|
|
7
|
+
num: Number as DetailedType<1 | 2>,
|
|
8
|
+
union: [String as DetailedType<"male" | "femal">, Number],
|
|
9
9
|
null: null,
|
|
10
10
|
bubbles: {
|
|
11
|
-
|
|
11
|
+
detail: String,
|
|
12
12
|
options: {
|
|
13
13
|
bubbles: true,
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
capturePhase: {
|
|
17
|
-
|
|
17
|
+
detail: Number,
|
|
18
18
|
options: {
|
|
19
19
|
capturePhase: true,
|
|
20
20
|
},
|
|
21
21
|
},
|
|
22
22
|
bubblesComposed: {
|
|
23
|
-
|
|
23
|
+
detail: Number,
|
|
24
24
|
options: {
|
|
25
25
|
bubbles: true,
|
|
26
26
|
composed: true,
|
|
27
27
|
},
|
|
28
28
|
},
|
|
29
29
|
capturePhaseComposed: {
|
|
30
|
-
|
|
30
|
+
detail: Number,
|
|
31
31
|
options: {
|
|
32
32
|
capturePhase: true,
|
|
33
33
|
composed: true,
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
36
|
bubblesCapturePhaseComposed: {
|
|
37
|
-
|
|
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 {
|
|
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
|
|
9
|
-
union: [String as
|
|
8
|
+
num: Number as DetailedType<1 | 2>,
|
|
9
|
+
union: [String as DetailedType<"male" | "femal">, Number],
|
|
10
10
|
null: null,
|
|
11
11
|
bubbles: {
|
|
12
|
-
|
|
12
|
+
detail: String,
|
|
13
13
|
options: {
|
|
14
14
|
bubbles: true,
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
17
|
capturePhase: {
|
|
18
|
-
|
|
18
|
+
detail: Number,
|
|
19
19
|
options: {
|
|
20
20
|
capturePhase: true,
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
bubblesComposed: {
|
|
24
|
-
|
|
24
|
+
detail: Number,
|
|
25
25
|
options: {
|
|
26
26
|
bubbles: true,
|
|
27
27
|
composed: true,
|
|
28
28
|
},
|
|
29
29
|
},
|
|
30
30
|
capturePhaseComposed: {
|
|
31
|
-
|
|
31
|
+
detail: Number,
|
|
32
32
|
options: {
|
|
33
33
|
capturePhase: true,
|
|
34
34
|
composed: true,
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
37
|
bubblesCapturePhaseComposed: {
|
|
38
|
-
|
|
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 {
|
|
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
|
|
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
|
|
28
|
+
type: Object as DetailedType<{ name: string }>,
|
|
29
29
|
value: { name: "zhao" },
|
|
30
30
|
},
|
|
31
31
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { WMCompLifetimes } from "../../../types/OfficialTypeAlias";
|
|
2
|
-
import type {
|
|
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:
|
|
10
|
+
beforeCreate?: (options: FinalOptionsForComponent) => void;
|
|
11
11
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
|
-
import {
|
|
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
|
|
32
|
+
type: Object as DetailedType<Mock_User>,
|
|
33
33
|
value: { id: "001", name: "zhao" },
|
|
34
34
|
},
|
|
35
35
|
optionalObject: {
|
|
36
|
-
type: Object as
|
|
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 {
|
|
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<
|
|
23
|
+
AddNullForObject<InferDetailedType<Optional[k]["type"]>>,
|
|
24
24
|
// 页面时 对象不加
|
|
25
|
-
|
|
25
|
+
InferDetailedType<Optional[k]["type"]>
|
|
26
26
|
>,
|
|
27
27
|
IfExtends<
|
|
28
28
|
false,
|
|
29
29
|
TIsPage,
|
|
30
30
|
// 组件时 对象加null
|
|
31
31
|
AddNullForObject<
|
|
32
|
-
|
|
32
|
+
InferDetailedType<Optional[k]["type"]> | InferDetailedType<(Optional[k]["optionalTypes"] & {})[number]>
|
|
33
33
|
>,
|
|
34
34
|
// 页面时 对象不加
|
|
35
|
-
|
|
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 {
|
|
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<
|
|
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<
|
|
25
|
+
| AddNullForObject<InferDetailedType<Required[k]["type"]>>
|
|
26
26
|
// @ts-ignore Required[k] 必为 RequiredUnion
|
|
27
|
-
| AddNullForObject<
|
|
27
|
+
| AddNullForObject<InferDetailedType<Required[k]["optionalTypes"][number]>>,
|
|
28
28
|
// @ts-ignore Required[k] 必为 RequiredUnion
|
|
29
|
-
|
|
29
|
+
InferDetailedType<Required[k]["type"]> | InferDetailedType<Required[k]["optionalTypes"][number]>
|
|
30
30
|
>
|
|
31
31
|
>;
|
|
32
32
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DetailedType } from "../../../types/DetailedType";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* properties 必传(单一)类型
|
|
5
5
|
*/
|
|
6
|
-
export type RequiredSingle =
|
|
6
|
+
export type RequiredSingle = DetailedType;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* properties 必传(联合)类型
|
|
10
10
|
*/
|
|
11
11
|
export type RequiredUnion<Literal = unknown> = {
|
|
12
|
-
type:
|
|
13
|
-
optionalTypes:
|
|
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:
|
|
25
|
+
type: DetailedType<Literal>;
|
|
26
26
|
value: Literal;
|
|
27
|
-
optionalTypes?:
|
|
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
|
|
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 {
|
|
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
|
|
15
|
+
} ? V extends InferDetailedType<R> ? never
|
|
16
16
|
: k
|
|
17
17
|
: never
|
|
18
18
|
]: { value: () => "⚠️类型错误⚠️" };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
|
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 {
|
|
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
|
|
17
|
+
type: String as DetailedType<"male" | "female">, // 同类字面量联合类型
|
|
18
18
|
value: "male",
|
|
19
19
|
},
|
|
20
20
|
optional_tuple: {
|
|
21
|
-
type: Array as unknown as
|
|
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
|
|
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
|
|
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 {
|
|
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
|
|
34
|
-
union_str: String as
|
|
35
|
-
union_num: Number as
|
|
36
|
-
union_bool: Boolean as
|
|
37
|
-
union_arr: Array as
|
|
38
|
-
union_obj: Object as
|
|
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
|
|
51
|
-
optionalTypes: [Number as
|
|
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
|
|
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
|
|
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 {
|
|
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
|
|
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 {
|
|
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
|
|
26
|
+
type: String as DetailedType<"male" | "female">,
|
|
27
27
|
value: "male" as const,
|
|
28
28
|
},
|
|
29
29
|
optional_obj: {
|
|
30
|
-
type: Object as
|
|
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
|
|
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
|
-
|
|
|
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,
|
|
119
|
-
data: {
|
|
120
|
-
aaa_xxx: 123,
|
|
121
|
-
},
|
|
124
|
+
SubComponent<Root, $aaa>()({
|
|
122
125
|
computed: {
|
|
123
126
|
aaa_num(): number {
|
|
124
|
-
return this.data.
|
|
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
|
-
|
|
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 "
|
|
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
|
|