annil 1.1.0 → 1.1.2
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 +14 -0
- package/dist/api/DefineComponent/collectOptionsForComponent.d.ts +2 -2
- package/dist/api/DefineComponent/collectOptionsForComponent.js +55 -6
- package/dist/api/DefineComponent/collectOptionsForComponent.js.map +1 -1
- package/dist/api/DefineComponent/index.d.ts +2 -2
- package/dist/api/RootComponent/Computed/ComputedOption.d.ts +2 -2
- package/dist/api/RootComponent/Computed/GetComputedDoc.d.ts +2 -2
- package/dist/api/RootComponent/Computed/test/normal.test.js +5 -12
- package/dist/api/RootComponent/Computed/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/CustomEvents/CustomEventsOption.d.ts +2 -2
- package/dist/api/RootComponent/Data/DataConstraint.d.ts +1 -1
- package/dist/api/RootComponent/Data/DataOption.d.ts +2 -2
- package/dist/api/RootComponent/Data/GetDataDoc.d.ts +1 -4
- package/dist/api/RootComponent/Data/test/GetDataDoc.test.d.ts +3 -2
- package/dist/api/RootComponent/Data/test/GetDataDoc.test.js +5 -5
- package/dist/api/RootComponent/Data/test/GetDataDoc.test.js.map +1 -1
- package/dist/api/RootComponent/Data/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/Events/EventsConstraint.d.ts +6 -5
- package/dist/api/RootComponent/Events/EventsOption.d.ts +2 -3
- package/dist/api/RootComponent/Events/test/normal.test.js +1 -1
- package/dist/api/RootComponent/Events/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/Lifetimes/LifetimesConstraint.d.ts +5 -4
- package/dist/api/RootComponent/Lifetimes/test/error.test.js.map +1 -1
- package/dist/api/RootComponent/PageLifetimes/PageLifetimesOption.d.ts +6 -7
- package/dist/api/RootComponent/PageLifetimes/test/error.test.js +3 -1
- package/dist/api/RootComponent/PageLifetimes/test/error.test.js.map +1 -1
- package/dist/api/RootComponent/PageLifetimes/test/normal.test.js +3 -1
- package/dist/api/RootComponent/PageLifetimes/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/RootComponentDoc.d.ts +17 -3
- package/dist/api/RootComponent/Store/GeTStoreDoc.d.ts +1 -1
- package/dist/api/RootComponent/Store/StoreOption.d.ts +2 -2
- package/dist/api/RootComponent/Store/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/Watch/test/WatchProperties.test.js +0 -2
- package/dist/api/RootComponent/Watch/test/WatchProperties.test.js.map +1 -1
- package/dist/api/RootComponent/index.d.ts +5 -5
- package/dist/api/RootComponent/index.js.map +1 -1
- package/dist/api/SubComponent/SubData/SubDataConstraint.d.ts +2 -2
- package/dist/api/SubComponent/SubData/test/normal.test.js +0 -15
- package/dist/api/SubComponent/SubData/test/normal.test.js.map +1 -1
- package/dist/api/SubComponent/SubEvents/SubEventsConstraint.d.ts +2 -2
- package/dist/api/SubComponent/SubEvents/SubEventsOptions.d.ts +2 -2
- package/dist/api/SubComponent/SubEvents/test/error.test.js.map +1 -1
- package/dist/api/SubComponent/SubEvents/test/normal.test.js +20 -0
- package/dist/api/SubComponent/SubEvents/test/normal.test.js.map +1 -1
- package/dist/api/SubComponent/SubInherit/SubInheritConstraint.d.ts +3 -2
- package/dist/api/SubComponent/SubInherit/SubInheritOption.d.ts +3 -0
- package/dist/api/SubComponent/SubInherit/SubInheritOption.js +2 -0
- package/dist/api/SubComponent/SubInherit/SubInheritOption.js.map +1 -0
- package/dist/api/SubComponent/SubInherit/test/error.test.js +1 -1
- package/dist/api/SubComponent/SubInherit/test/error.test.js.map +1 -1
- package/dist/api/SubComponent/SubInherit/test/normal.test.js.map +1 -1
- package/dist/api/SubComponent/SubMethods/SubMethodsOption.d.ts +3 -2
- package/dist/api/SubComponent/SubMethods/test/error.test.js +6 -0
- package/dist/api/SubComponent/SubMethods/test/error.test.js.map +1 -1
- package/dist/api/SubComponent/SubMethods/test/normarl.test.js +3 -3
- package/dist/api/SubComponent/SubMethods/test/normarl.test.js.map +1 -1
- package/dist/api/SubComponent/SubPageLifetimes/test/error.test.d.ts +0 -1
- package/dist/api/SubComponent/SubPageLifetimes/test/error.test.js +1 -11
- package/dist/api/SubComponent/SubPageLifetimes/test/error.test.js.map +1 -1
- package/dist/api/SubComponent/SubPageLifetimes/test/normal.test.d.ts +0 -1
- package/dist/api/SubComponent/SubPageLifetimes/test/normal.test.js +1 -25
- package/dist/api/SubComponent/SubPageLifetimes/test/normal.test.js.map +1 -1
- package/dist/api/SubComponent/SubStore/SubDataConstraint.d.ts +2 -2
- package/dist/api/SubComponent/SubStore/SubStoreOption.d.ts +1 -1
- package/dist/api/SubComponent/SubStore/test/error.test.js +2 -0
- package/dist/api/SubComponent/SubStore/test/error.test.js.map +1 -1
- package/dist/api/SubComponent/SubStore/test/normal.test.js +1 -0
- package/dist/api/SubComponent/SubStore/test/normal.test.js.map +1 -1
- package/dist/api/SubComponent/SubWatch/SubWatchOption.d.ts +2 -1
- package/dist/api/SubComponent/SubWatch/test/WatchComputed.test.d.ts +1 -0
- package/dist/api/SubComponent/SubWatch/test/WatchComputed.test.js +44 -1
- package/dist/api/SubComponent/SubWatch/test/WatchComputed.test.js.map +1 -1
- package/dist/api/SubComponent/SubWatch/test/error.test.js +10 -2
- package/dist/api/SubComponent/SubWatch/test/error.test.js.map +1 -1
- package/dist/api/SubComponent/index.d.ts +3 -4
- package/dist/api/SubComponent/index.js.map +1 -1
- package/dist/behaviors/BComputedAndWatch/computedUpdater.js +1 -3
- package/dist/behaviors/BComputedAndWatch/computedUpdater.js.map +1 -1
- package/dist/behaviors/BComputedAndWatch/index.js.map +1 -1
- package/dist/behaviors/BComputedAndWatch/initComputed.js +1 -3
- package/dist/behaviors/BComputedAndWatch/initComputed.js.map +1 -1
- package/dist/behaviors/BComputedAndWatch/types.d.ts +1 -0
- package/dist/behaviors/BStore.js.map +1 -1
- package/dist/behaviors/BbeforeCreated.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/OfficialTypeAlias.d.ts +1 -1
- package/dist/types/RemoveInnerData.d.ts +1 -0
- package/dist/types/RemoveInnerData.js +2 -0
- package/dist/types/RemoveInnerData.js.map +1 -0
- package/package.json +4 -2
- package/src/api/DefineComponent/collectOptionsForComponent.ts +99 -16
- package/src/api/DefineComponent/index.ts +2 -2
- package/src/api/RootComponent/Computed/ComputedOption.ts +23 -3
- package/src/api/RootComponent/Computed/GetComputedDoc.ts +1 -3
- package/src/api/RootComponent/Computed/test/normal.test.ts +9 -19
- package/src/api/RootComponent/CustomEvents/CustomEventsOption.ts +26 -22
- package/src/api/RootComponent/CustomEvents/test/error.test.ts +5 -5
- package/src/api/RootComponent/CustomEvents/test/normal.test.ts +1 -1
- package/src/api/RootComponent/Data/DataConstraint.ts +1 -1
- package/src/api/RootComponent/Data/DataOption.ts +6 -4
- package/src/api/RootComponent/Data/GetDataDoc.ts +1 -18
- package/src/api/RootComponent/Data/test/GetDataDoc.test.ts +14 -25
- package/src/api/RootComponent/Data/test/error.test.ts +2 -2
- package/src/api/RootComponent/Data/test/normal.test.ts +5 -8
- package/src/api/RootComponent/Events/EventsConstraint.ts +24 -19
- package/src/api/RootComponent/Events/EventsOption.ts +54 -6
- package/src/api/RootComponent/Events/test/normal.test.ts +16 -16
- package/src/api/RootComponent/Instance/test/properties/mormal.test.ts +1 -1
- package/src/api/RootComponent/IsPage/IsPageOption.ts +1 -1
- package/src/api/RootComponent/Lifetimes/LifetimesConstraint.ts +11 -8
- package/src/api/RootComponent/Lifetimes/LifetimesOption.ts +26 -0
- package/src/api/RootComponent/Lifetimes/test/error.test.ts +3 -13
- package/src/api/RootComponent/Lifetimes/test/normal.test.ts +1 -1
- package/src/api/RootComponent/Methods/MethodsOption.ts +3 -0
- package/src/api/RootComponent/PageLifetimes/PageLifetimesOption.ts +21 -10
- package/src/api/RootComponent/PageLifetimes/test/error.test.ts +7 -5
- package/src/api/RootComponent/PageLifetimes/test/normal.test.ts +9 -10
- package/src/api/RootComponent/Properties/PropertiesOption.ts +19 -32
- package/src/api/RootComponent/RootComponentDoc.ts +19 -3
- package/src/api/RootComponent/Store/GeTStoreDoc.ts +1 -1
- package/src/api/RootComponent/Store/StoreOption.ts +14 -2
- package/src/api/RootComponent/Store/test/error.test.ts +5 -5
- package/src/api/RootComponent/Store/test/normal.test.ts +1 -0
- package/src/api/RootComponent/Watch/test/WatchProperties.test.ts +1 -12
- package/src/api/RootComponent/index.ts +13 -15
- package/src/api/SubComponent/SubComputed/SubComputedOption.ts +0 -1
- package/src/api/SubComponent/SubData/SubDataConstraint.ts +2 -3
- package/src/api/SubComponent/SubData/SubDataOption.ts +4 -0
- package/src/api/SubComponent/SubData/test/error.test.ts +1 -1
- package/src/api/SubComponent/SubData/test/normal.test.ts +6 -37
- package/src/api/SubComponent/SubEvents/SubEventsConstraint.ts +7 -2
- package/src/api/SubComponent/SubEvents/SubEventsOptions.ts +7 -2
- package/src/api/SubComponent/SubEvents/test/error.test.ts +5 -4
- package/src/api/SubComponent/SubEvents/test/normal.test.ts +31 -4
- package/src/api/SubComponent/SubInherit/SubInheritConstraint.ts +6 -3
- package/src/api/SubComponent/SubInherit/SubInheritOption.ts +8 -0
- package/src/api/SubComponent/SubInherit/test/error.test.ts +9 -7
- package/src/api/SubComponent/SubInherit/test/normal.test.ts +5 -4
- package/src/api/SubComponent/SubMethods/SubMethodsOption.ts +7 -3
- package/src/api/SubComponent/SubMethods/test/error.test.ts +13 -5
- package/src/api/SubComponent/SubMethods/test/normarl.test.ts +6 -12
- package/src/api/SubComponent/SubPageLifetimes/test/error.test.ts +1 -32
- package/src/api/SubComponent/SubPageLifetimes/test/normal.test.ts +1 -74
- package/src/api/SubComponent/SubStore/SubDataConstraint.ts +2 -2
- package/src/api/SubComponent/SubStore/SubStoreOption.ts +15 -1
- package/src/api/SubComponent/SubStore/test/error.test.ts +4 -0
- package/src/api/SubComponent/SubStore/test/normal.test.ts +2 -0
- package/src/api/SubComponent/SubWatch/SubWatchOption.ts +2 -1
- package/src/api/SubComponent/SubWatch/test/WatchComputed.test.ts +75 -43
- package/src/api/SubComponent/SubWatch/test/error.test.ts +12 -3
- package/src/api/SubComponent/index.ts +9 -5
- package/src/behaviors/BComputedAndWatch/computedUpdater.ts +1 -0
- package/src/behaviors/BComputedAndWatch/index.ts +2 -2
- package/src/behaviors/BComputedAndWatch/initComputed.ts +1 -0
- package/src/behaviors/BComputedAndWatch/types.ts +1 -0
- package/src/behaviors/BStore.ts +2 -2
- package/src/behaviors/BbeforeCreated.ts +2 -2
- package/src/index.ts +9 -1
- package/src/types/OfficialTypeAlias.ts +7 -11
- package/src/types/RemoveInnerData.ts +5 -0
|
@@ -1,74 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { Mock_User } from "../../../RootComponent/Properties/test/normalRequired.test";
|
|
4
|
-
import type { RootComponentDoc } from "../../../RootComponent/RootComponentDoc";
|
|
5
|
-
import { SubComponent } from "../..";
|
|
6
|
-
|
|
7
|
-
type RootDocComp = RootComponentDoc<{
|
|
8
|
-
properties: {
|
|
9
|
-
union?: Mock_User;
|
|
10
|
-
optionalObject?: Mock_User | null;
|
|
11
|
-
str: string;
|
|
12
|
-
obj: object | null;
|
|
13
|
-
};
|
|
14
|
-
}>;
|
|
15
|
-
|
|
16
|
-
type RootDocCompPage = RootComponentDoc<{
|
|
17
|
-
isPage: true;
|
|
18
|
-
properties: {
|
|
19
|
-
union?: Mock_User;
|
|
20
|
-
optionalObject?: Mock_User | null;
|
|
21
|
-
str: string;
|
|
22
|
-
obj: object | null;
|
|
23
|
-
};
|
|
24
|
-
}>;
|
|
25
|
-
|
|
26
|
-
type CompDoc = RootComponentDoc<{
|
|
27
|
-
properties: {
|
|
28
|
-
aaa_str: string;
|
|
29
|
-
};
|
|
30
|
-
customEvents: {
|
|
31
|
-
aaa_num: number;
|
|
32
|
-
};
|
|
33
|
-
}>;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 测试 组件时
|
|
37
|
-
*/
|
|
38
|
-
SubComponent<RootDocComp, CompDoc>()({
|
|
39
|
-
pageLifetimes: {
|
|
40
|
-
hide() {},
|
|
41
|
-
load() {},
|
|
42
|
-
resize(size) {
|
|
43
|
-
Checking<typeof size, WechatMiniprogram.Page.IResizeOption, Test.Pass>;
|
|
44
|
-
},
|
|
45
|
-
show() {},
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* 页面时
|
|
51
|
-
*/
|
|
52
|
-
SubComponent<RootDocCompPage, CompDoc>()({
|
|
53
|
-
pageLifetimes: {
|
|
54
|
-
onLoad(props) {
|
|
55
|
-
// 接受的必传properties字段,不应该有null
|
|
56
|
-
Checking<
|
|
57
|
-
typeof props,
|
|
58
|
-
{
|
|
59
|
-
str: string;
|
|
60
|
-
obj: object;
|
|
61
|
-
union: Mock_User;
|
|
62
|
-
optionalObject: Mock_User | null;
|
|
63
|
-
},
|
|
64
|
-
Test.Pass
|
|
65
|
-
>;
|
|
66
|
-
},
|
|
67
|
-
onHide() {
|
|
68
|
-
console.log("onHide");
|
|
69
|
-
},
|
|
70
|
-
onResize(options) {
|
|
71
|
-
console.log("onResize", options);
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
});
|
|
1
|
+
// 同 RootComponent的PageLifetimes
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import type { V } from "hry-types";
|
|
2
2
|
|
|
3
3
|
export type SubStoreOption<TSubStore extends object, legalKeys extends PropertyKey, TPrefix extends string> = {
|
|
4
|
+
/**
|
|
5
|
+
* 全局响应式数据字段,全局store对应数据变化实例对应数据自动setData。
|
|
6
|
+
* 约束为组件properties字段去除inherit和data的剩余字段和内部字段
|
|
7
|
+
* 有非法字段(除了约束字段外的字段)检测
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* {
|
|
11
|
+
* //...
|
|
12
|
+
* store: {
|
|
13
|
+
* aaa_str: () => sroreX.str,
|
|
14
|
+
* },
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
4
18
|
store?:
|
|
5
19
|
& TSubStore
|
|
6
20
|
& V.IllegalFieldValidator<
|
|
@@ -8,6 +22,6 @@ export type SubStoreOption<TSubStore extends object, legalKeys extends PropertyK
|
|
|
8
22
|
legalKeys | `_${TPrefix}_${string}`,
|
|
9
23
|
0,
|
|
10
24
|
"",
|
|
11
|
-
"
|
|
25
|
+
"与inherit和data字段重复或前缀错误"
|
|
12
26
|
>;
|
|
13
27
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NoInfer } from "hry-types/src/Generic/NoInfer";
|
|
1
2
|
import type { WatchOption } from "../../RootComponent/Watch/WatchOption";
|
|
2
3
|
|
|
3
|
-
export type SubWatchOption<TWatchData extends object> = WatchOption<TWatchData
|
|
4
|
+
export type SubWatchOption<TWatchData extends object> = WatchOption<NoInfer<TWatchData>>;
|
|
@@ -1,46 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { Checking, type Test } from "hry-types";
|
|
2
|
+
import type { ComponentDoc } from "../../../DefineComponent/ReturnType/ComponentDoc";
|
|
3
|
+
import type { Mock_User } from "../../../RootComponent/Properties/test/normalRequired.test";
|
|
4
|
+
import type { RootComponentDoc } from "../../../RootComponent/RootComponentDoc";
|
|
5
|
+
import { SubComponent } from "../..";
|
|
6
|
+
|
|
7
|
+
type RootDoc = RootComponentDoc<{
|
|
8
|
+
properties: {
|
|
9
|
+
obj: Mock_User | null;
|
|
10
|
+
};
|
|
11
|
+
data: {
|
|
12
|
+
num: number;
|
|
13
|
+
};
|
|
14
|
+
store: {
|
|
15
|
+
bool: boolean;
|
|
16
|
+
};
|
|
17
|
+
}>;
|
|
18
|
+
|
|
19
|
+
type CompDoc = ComponentDoc<{
|
|
20
|
+
properties: {
|
|
21
|
+
aaa_obj: Mock_User | null;
|
|
22
|
+
aaa_str: string;
|
|
23
|
+
aaa_num: number;
|
|
24
|
+
aaa_bool: boolean;
|
|
25
|
+
};
|
|
26
|
+
}>;
|
|
18
27
|
|
|
19
28
|
/**
|
|
20
|
-
*
|
|
29
|
+
* watch computed字段时需要手写类型,可悬停鼠标到key查看类型
|
|
21
30
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
SubComponent<RootDoc, CompDoc>()({
|
|
32
|
+
computed: {
|
|
33
|
+
aaa_str(): string {
|
|
34
|
+
return this.data.aaa_num.toString();
|
|
35
|
+
},
|
|
36
|
+
aaa_num(): number {
|
|
37
|
+
return 123;
|
|
38
|
+
},
|
|
39
|
+
aaa_bool(): boolean {
|
|
40
|
+
return this.data.bool;
|
|
41
|
+
},
|
|
42
|
+
aaa_obj(): Mock_User {
|
|
43
|
+
return {} as Mock_User;
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
watch: {
|
|
47
|
+
aaa_num(newValue: number, oldValue: number) {
|
|
48
|
+
Checking<number, typeof newValue, Test.Pass>;
|
|
49
|
+
|
|
50
|
+
Checking<number, typeof oldValue, Test.Pass>;
|
|
51
|
+
},
|
|
52
|
+
aaa_str(newValue: string, oldValue: string) {
|
|
53
|
+
Checking<string, typeof newValue, Test.Pass>;
|
|
54
|
+
|
|
55
|
+
Checking<string, typeof oldValue, Test.Pass>;
|
|
56
|
+
},
|
|
57
|
+
aaa_bool(newValue: boolean, oldValue: boolean) {
|
|
58
|
+
Checking<boolean, typeof newValue, Test.Pass>;
|
|
59
|
+
|
|
60
|
+
Checking<boolean, typeof oldValue, Test.Pass>;
|
|
61
|
+
},
|
|
62
|
+
aaa_obj(newValue: Mock_User, oldValue: Mock_User | null) {
|
|
63
|
+
Checking<Mock_User, typeof newValue, Test.Pass>;
|
|
64
|
+
|
|
65
|
+
Checking<Mock_User | null, typeof oldValue, Test.Pass>;
|
|
66
|
+
},
|
|
67
|
+
"aaa_obj.id"(newValue: string, oldValue: string) {
|
|
68
|
+
Checking<string, typeof newValue, Test.Pass>;
|
|
69
|
+
|
|
70
|
+
Checking<string, typeof oldValue, Test.Pass>;
|
|
71
|
+
},
|
|
72
|
+
"aaa_obj.age"(newValue: number, oldValue: number) {
|
|
73
|
+
Checking<number, typeof newValue, Test.Pass>;
|
|
74
|
+
|
|
75
|
+
Checking<number, typeof oldValue, Test.Pass>;
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
});
|
|
@@ -5,7 +5,7 @@ import { SubComponent } from "../..";
|
|
|
5
5
|
SubComponent<{ events: { a: string } }, Wm.View>()({
|
|
6
6
|
watch: {
|
|
7
7
|
// @ts-expect-error 无可监控字段时,约束为EmptyObject,不可写任何字段
|
|
8
|
-
|
|
8
|
+
nothing() {},
|
|
9
9
|
},
|
|
10
10
|
});
|
|
11
11
|
|
|
@@ -14,7 +14,16 @@ SubComponent<{ events: { a: string } }, Wm.View>()({
|
|
|
14
14
|
*/
|
|
15
15
|
SubComponent<{ events: { a: string } }, Wm.View>()({
|
|
16
16
|
data: {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
view_style: "",
|
|
18
|
+
},
|
|
19
|
+
watch: {
|
|
20
|
+
view_style(newValue, oldValue) { // ok
|
|
21
|
+
newValue;
|
|
22
|
+
|
|
23
|
+
oldValue;
|
|
24
|
+
},
|
|
25
|
+
// @ts-expect-error 超出约束字段错误
|
|
26
|
+
view_XXstyle() {
|
|
27
|
+
},
|
|
19
28
|
},
|
|
20
29
|
});
|
|
@@ -21,6 +21,7 @@ import type { SubDataOption } from "./SubData/SubDataOption";
|
|
|
21
21
|
import type { SubEventsConstraint } from "./SubEvents/SubEventsConstraint";
|
|
22
22
|
import type { SubEventsOption } from "./SubEvents/SubEventsOptions";
|
|
23
23
|
import type { InheritConstraint } from "./SubInherit/SubInheritConstraint";
|
|
24
|
+
import type { SubInheritOption } from "./SubInherit/SubInheritOption";
|
|
24
25
|
import type { SubInstance } from "./SubInstance/SubInstance";
|
|
25
26
|
import type { SubLifetimesOption } from "./SubLifetimes/SubLifetimesOption";
|
|
26
27
|
import type { SubMethodsConstraint } from "./SubMethods/SubMethodsConstraint";
|
|
@@ -42,7 +43,7 @@ type Options<
|
|
|
42
43
|
TSubStore extends object,
|
|
43
44
|
TSubComputed extends object,
|
|
44
45
|
TEvents extends object,
|
|
45
|
-
TSubMethods extends
|
|
46
|
+
TSubMethods extends SubMethodsConstraint,
|
|
46
47
|
InheritDoc extends object,
|
|
47
48
|
SubDataDoc extends object,
|
|
48
49
|
SubStoreDoc extends object,
|
|
@@ -50,7 +51,7 @@ type Options<
|
|
|
50
51
|
SubEventsDoc extends object,
|
|
51
52
|
SubMethodsDoc extends object,
|
|
52
53
|
> =
|
|
53
|
-
&
|
|
54
|
+
& SubInheritOption<TInherit>
|
|
54
55
|
& SubDataOption<
|
|
55
56
|
TSubData,
|
|
56
57
|
Exclude<keyof CurrentCompDoc["properties"], (keyof InheritDoc)>,
|
|
@@ -67,8 +68,9 @@ type Options<
|
|
|
67
68
|
// 合法的配置
|
|
68
69
|
Omit<CurrentCompDoc["properties"], (keyof (InheritDoc & SubDataDoc & SubStoreDoc))>
|
|
69
70
|
>
|
|
71
|
+
// 无需与根组件的events字段重复检测,因为根组件多了bubbles字段,一定不会重复
|
|
70
72
|
& SubEventsOption<TEvents, SubEventsDoc, keyof SubEventsConstraint<CurrentCompDoc>>
|
|
71
|
-
& SubMethodsOption<TSubMethods, Prefix, keyof CurrentCompDoc["customEvents"]>
|
|
73
|
+
& SubMethodsOption<TSubMethods, Prefix, keyof (CurrentCompDoc["customEvents"] & SubEventsDoc)>
|
|
72
74
|
& SubPageLifetimesOption<IsPage, RootDoc["properties"] & {}>
|
|
73
75
|
& SubLifetimesOption
|
|
74
76
|
& SubWatchOption<
|
|
@@ -104,7 +106,8 @@ type SubComponentConstructor<
|
|
|
104
106
|
ReplacePrefix<TOriginalCompDoc, CurrentPrefix>
|
|
105
107
|
>,
|
|
106
108
|
AllRootDataDoc extends object =
|
|
107
|
-
|
|
109
|
+
// rootDoc中的properties是带有可选的,这是为了给使用者(上层组件)提示,而在自身组件实例中并不存在可选状态,故加了Required,正因加了Required使得最终结果不可能为unknown而是`{}`,满足object约束
|
|
110
|
+
& Required<TRootDoc["properties"]> // Required<unknown> = {}
|
|
108
111
|
& TRootDoc["data"]
|
|
109
112
|
& TRootDoc["computed"]
|
|
110
113
|
& TRootDoc["store"],
|
|
@@ -114,9 +117,10 @@ type SubComponentConstructor<
|
|
|
114
117
|
TSubData extends SubDataConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof InheritDoc>>,
|
|
115
118
|
TSubStore extends SubStoreConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc)>>,
|
|
116
119
|
TEvents extends SubEventsConstraint<CurrentCompDoc>,
|
|
120
|
+
// 加默认值计算字段无提示且需要手写返回类型,不加watch无法对computed监控
|
|
117
121
|
TSubComputed extends SubComputedConstraint<
|
|
118
122
|
Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc & SubStoreDoc)>
|
|
119
|
-
|
|
123
|
+
> = {},
|
|
120
124
|
TSubMethods extends SubMethodsConstraint = {},
|
|
121
125
|
InheritDoc extends object = IfExtends<InheritConstraint<AllRootDataDoc, CurrentCompDoc>, TInherit, {}, TInherit>,
|
|
122
126
|
SubDataDoc extends object = IfExtends<
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Func } from "hry-types/src/Misc/Func";
|
|
2
|
-
import type {
|
|
2
|
+
import type { FinalOptionsOfComponent } from "../../api/DefineComponent";
|
|
3
3
|
import { deepClone } from "../../utils/deepClone";
|
|
4
4
|
import { deleteProtoField } from "../../utils/deleteProtoField";
|
|
5
5
|
|
|
@@ -32,7 +32,7 @@ function initWatchOldValue(this: Instance, watchConfig: object): WatchOldValue {
|
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
34
|
export const BComputedAndWatch = Behavior({
|
|
35
|
-
definitionFilter(options:
|
|
35
|
+
definitionFilter(options: FinalOptionsOfComponent) {
|
|
36
36
|
const computedConfig = options.computed;
|
|
37
37
|
|
|
38
38
|
// computed handle
|
package/src/behaviors/BStore.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type mobx from "mobx";
|
|
2
|
-
import type {
|
|
2
|
+
import type { FinalOptionsOfComponent } from "../api/DefineComponent";
|
|
3
3
|
import { deleteProtoField } from "../utils/deleteProtoField";
|
|
4
4
|
import type { Instance } from "./BComputedAndWatch/types";
|
|
5
5
|
|
|
6
6
|
export const BStore = Behavior({
|
|
7
|
-
definitionFilter(options:
|
|
7
|
+
definitionFilter(options: FinalOptionsOfComponent) {
|
|
8
8
|
// 初始化store
|
|
9
9
|
const storeConfig = options.store;
|
|
10
10
|
if (!storeConfig) return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FinalOptionsOfComponent } from "../api/DefineComponent";
|
|
2
2
|
|
|
3
3
|
export const BBeforeCreate = Behavior({
|
|
4
|
-
definitionFilter(options:
|
|
4
|
+
definitionFilter(options: FinalOptionsOfComponent) {
|
|
5
5
|
// 触发beforeCreate生命周期函数
|
|
6
6
|
const beforeCreateFunc = options.lifetimes!.beforeCreate;
|
|
7
7
|
|
package/src/index.ts
CHANGED
|
@@ -13,7 +13,15 @@ import type { GenerateDoc } from "./types/GenerateDoc";
|
|
|
13
13
|
import type { ParamsEqual } from "./types/TwoParamsEqual";
|
|
14
14
|
export type { Vant, Wm } from "./thirdLib";
|
|
15
15
|
|
|
16
|
-
export type {
|
|
16
|
+
export type {
|
|
17
|
+
CurrentTargetDataset,
|
|
18
|
+
Dataset,
|
|
19
|
+
Detail,
|
|
20
|
+
Mark,
|
|
21
|
+
TargetDataset,
|
|
22
|
+
WMBaseEvent,
|
|
23
|
+
WMCustomEvent,
|
|
24
|
+
} from "./types/OfficialTypeAlias";
|
|
17
25
|
|
|
18
26
|
export {
|
|
19
27
|
type ComponentDocExtension,
|
|
@@ -31,11 +31,13 @@ export type Dataset<
|
|
|
31
31
|
/**
|
|
32
32
|
* 自定义事件Detail类型
|
|
33
33
|
*/
|
|
34
|
-
export type Mark<TMark extends object> =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
export type Mark<TMark extends object> = Required<
|
|
35
|
+
WechatMiniprogram.CustomEvent<
|
|
36
|
+
object,
|
|
37
|
+
TMark,
|
|
38
|
+
object,
|
|
39
|
+
object
|
|
40
|
+
>
|
|
39
41
|
>;
|
|
40
42
|
|
|
41
43
|
/**
|
|
@@ -53,12 +55,6 @@ export type CurrentTargetDataset<T extends object> = WMCustomEvent<{}, {}, T>;
|
|
|
53
55
|
*/
|
|
54
56
|
export type TargetDataset<TargetDataset extends object> = WMCustomEvent<{}, {}, {}, TargetDataset>;
|
|
55
57
|
|
|
56
|
-
// export type WMTrivialOption<
|
|
57
|
-
// TData extends WechatMiniprogram.Component.DataOption,
|
|
58
|
-
// TProperty extends WechatMiniprogram.Component.PropertyOption,
|
|
59
|
-
// TMethod extends WechatMiniprogram.Component.MethodOption,
|
|
60
|
-
// TCustomInstanceProperty extends WechatMiniprogram.IAnyObject = {},
|
|
61
|
-
// TIsPage extends boolean = false,
|
|
62
58
|
export type WMComponentOption = WechatMiniprogram.Component.TrivialOption;
|
|
63
59
|
|
|
64
60
|
export type WMNavigateToSuccessCallbackResult = WechatMiniprogram.NavigateToSuccessCallbackResult;
|