annil 1.16.0 → 1.17.0
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 +7 -0
- package/dist/api/DefineComponent/normalizeOptions/injectInfoHandler.js +1 -1
- package/dist/api/DefineComponent/normalizeOptions/injectInfoHandler.js.map +1 -1
- package/dist/api/InstanceInject/instanceConfig.d.ts +2 -2
- package/dist/api/InstanceInject/instanceConfig.js.map +1 -1
- package/dist/api/RootComponent/index.d.ts +3 -3
- package/dist/api/RootComponent/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/DefineComponent/normalizeOptions/injectInfoHandler.ts +1 -1
- package/src/api/InstanceInject/inject.ts +7 -2
- package/src/api/InstanceInject/instanceConfig.ts +3 -4
- package/src/api/InstanceInject/test/normal.test.ts +7 -6
- package/src/api/RootComponent/Instance/test/datas/mormal.test.ts +43 -0
- package/src/api/RootComponent/Instance/test/methods/mormal.test.ts +11 -2
- package/src/api/RootComponent/Store/test/normal.test.ts +24 -4
- package/src/api/RootComponent/index.ts +20 -7
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
* 解决DetailedType不接收接口类型的错误 ([ae8acbf](https://github.com/missannil/annil/commit/ae8acbfc2e62f99db565c448ad9253aa549e78bb))
|
|
6
6
|
|
|
7
|
+
## [1.17.0](https://github.com/missannil/annil/compare/v1.16.0...v1.17.0) (2026-06-30)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* 注入配置完善组件覆盖逻辑 ([17b75c4](https://github.com/missannil/annil/commit/17b75c445dc46c39cd30b56ffeece992f88aa722))
|
|
13
|
+
|
|
7
14
|
## [1.16.0](https://github.com/missannil/annil/compare/v1.15.1...v1.16.0) (2026-06-18)
|
|
8
15
|
|
|
9
16
|
|
|
@@ -10,7 +10,7 @@ function mergeOptions(finalOptionsForComponent, injectInfo) {
|
|
|
10
10
|
finalOptionsForComponent["behaviors"].push(...injectVal);
|
|
11
11
|
break;
|
|
12
12
|
default:
|
|
13
|
-
finalOptionsForComponent[renamedKey] = Object.assign(
|
|
13
|
+
finalOptionsForComponent[renamedKey] = Object.assign(injectVal, originalVal);
|
|
14
14
|
break;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectInfoHandler.js","sourceRoot":"","sources":["../../../../src/api/DefineComponent/normalizeOptions/injectInfoHandler.ts"],"names":[],"mappings":"AAYA,SAAS,YAAY,CACnB,wBAAiD,EACjD,UAAuB;IAEvB,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,MAAM,WAAW,GAAG,GAAgB,CAAC;QACrC,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;QAE1C,IAAI,GAAG,IAAI,wBAAwB,EAAE,CAAC;YACpC,MAAM,UAAU,GAAG,GAAoC,CAAC;YACxD,MAAM,WAAW,GAAG,wBAAwB,CAAC,UAAU,CAAC,CAAC;YACzD,QAAQ,WAAW,EAAE,CAAC;gBACpB,KAAK,WAAW;oBACd,wBAAwB,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,SAAqB,CAAC,CAAC;oBAErE,MAAM;gBAER;oBAEE,wBAAwB,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"injectInfoHandler.js","sourceRoot":"","sources":["../../../../src/api/DefineComponent/normalizeOptions/injectInfoHandler.ts"],"names":[],"mappings":"AAYA,SAAS,YAAY,CACnB,wBAAiD,EACjD,UAAuB;IAEvB,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,MAAM,WAAW,GAAG,GAAgB,CAAC;QACrC,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;QAE1C,IAAI,GAAG,IAAI,wBAAwB,EAAE,CAAC;YACpC,MAAM,UAAU,GAAG,GAAoC,CAAC;YACxD,MAAM,WAAW,GAAG,wBAAwB,CAAC,UAAU,CAAC,CAAC;YACzD,QAAQ,WAAW,EAAE,CAAC;gBACpB,KAAK,WAAW;oBACd,wBAAwB,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,SAAqB,CAAC,CAAC;oBAErE,MAAM;gBAER;oBAEE,wBAAwB,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;oBAE7E,MAAM;YACV,CAAC;QACH,CAAC;aAAM,CAAC;YAEN,wBAAwB,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;QAC5C,CAAC;IACH,CAAC;IAED,OAAO,wBAAwB,CAAC;AAClC,CAAC;AACD,MAAM,UAAU,iBAAiB,CAC/B,wBAAiD,EACjD,UAAmC;IAEnC,IAAI,CAAC,UAAU;QAAE,OAAO,wBAAwB,CAAC;IAEjD,OAAO,YAAY,CAAC,wBAAwB,EAAE,UAAU,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -16,8 +16,8 @@ interface BaseInjectInfo {
|
|
|
16
16
|
}
|
|
17
17
|
export interface IInjectInfo extends BaseInjectInfo {
|
|
18
18
|
}
|
|
19
|
-
export type
|
|
20
|
-
type
|
|
19
|
+
export type InjectData = DataConstraint extends IInjectInfo["data"] ? {} : IInjectInfo["data"];
|
|
20
|
+
export type IInjectAllData = IfEquals<{}, InjectData & IInjectStore, {}, ComputeIntersection<InjectData & IInjectStore>>;
|
|
21
21
|
export type IInjectStore = StoreConstraint extends IInjectInfo["store"] ? {} : ReturnTypeInObject<IInjectInfo["store"]>;
|
|
22
22
|
export type IInjectMethods = MethodsConstraint extends IInjectInfo["methods"] ? {} : IInjectInfo["methods"];
|
|
23
23
|
declare class InstanceConfig {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instanceConfig.js","sourceRoot":"","sources":["../../../src/api/InstanceInject/instanceConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"instanceConfig.js","sourceRoot":"","sources":["../../../src/api/InstanceInject/instanceConfig.ts"],"names":[],"mappings":"AAsCA,MAAM,cAAc;IAApB;QACU,SAAI,GAAiC,EAAE,CAAC;IAOlD,CAAC;IANC,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;IAC9B,CAAC;IACM,aAAa,CAAC,IAA6B;QAChD,IAAI,IAAI;YAAE,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACxC,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -6,7 +6,7 @@ import type { ComputeObject } from "../../types/ComputeObject";
|
|
|
6
6
|
import type { WMCompOtherOption } from "../../types/OfficialTypeAlias";
|
|
7
7
|
import type { RemoveNullOfRequired } from "../../types/RemoveNullOfRequired";
|
|
8
8
|
import type { ComponentDoc } from "../DefineComponent/returnType/ComponentDoc";
|
|
9
|
-
import type { IInjectStore } from "../InstanceInject/instanceConfig";
|
|
9
|
+
import type { IInjectAllData, IInjectMethods, IInjectStore, InjectData } from "../InstanceInject/instanceConfig";
|
|
10
10
|
import type { ComputedConstraint } from "./Computed/ComputedConstraint";
|
|
11
11
|
import type { ComputedOption } from "./Computed/ComputedOption";
|
|
12
12
|
import type { GetComputedDef } from "./Computed/GetComputedDef";
|
|
@@ -30,8 +30,8 @@ import type { GetStoreDef } from "./Store/GetStoreDef";
|
|
|
30
30
|
import type { StoreConstraint } from "./Store/StoreConstraint";
|
|
31
31
|
import type { StoreOption } from "./Store/StoreOption";
|
|
32
32
|
import type { WatchOption } from "./Watch/WatchOption";
|
|
33
|
-
type RootComponentOptions<TEvents extends object, TIsPage extends boolean, TCustomEvents extends CustomEventConstraint, TMethods extends MethodsConstraint, TProperties extends PropertiesConstraint, TData extends object, TStore extends StoreConstraint, TComputed extends Record<string, Func>, EventsDef extends object, CustomEventsDef extends object, PropertiesDef extends object, DataDef extends object, StoreDef extends object, ComputedDef extends object> = MethodsOption<TMethods, keyof (EventsDef & CustomEventsDef)> & PropertiesOption<TProperties> & IsPageOption<TIsPage> & EventsOption<TEvents> & IfExtends<TIsPage, false, CustomEventsOption<TCustomEvents, keyof EventsDef>, {}> & DataOption<TData, keyof PropertiesDef> & StoreOption<TStore, keyof (PropertiesDef & DataDef)> & ComputedOption<TComputed, keyof (PropertiesDef & DataDef & StoreDef)> & PageLifetimesOption<TIsPage, PropertiesDef> & LifetimesOption & WatchOption<ComputedDef & Required<PropertiesDef> & DataDef & StoreDef & IInjectStore> & Partial<Omit<WMCompOtherOption, "pageLifetimes" | "definitionFilter" | "observers">> & ObserversOption<ComputedDef & Required<PropertiesDef> & DataDef & StoreDef & IInjectStore> & ThisType<RootComponentInstance<TIsPage, TMethods
|
|
34
|
-
type RootComponentConstructor<TComponentDocList extends ComponentDoc[]> = <TEvents extends EventsConstraint<TComponentDocList>, TStore extends StoreConstraint<PropertiesDef
|
|
33
|
+
type RootComponentOptions<TEvents extends object, TIsPage extends boolean, TCustomEvents extends CustomEventConstraint, TMethods extends MethodsConstraint, TProperties extends PropertiesConstraint, TData extends object, TStore extends StoreConstraint, TComputed extends Record<string, Func>, EventsDef extends object, CustomEventsDef extends object, PropertiesDef extends object, DataDef extends object, StoreDef extends object, ComputedDef extends object, SelfAllDatas extends object, ValidInjectDatas extends object> = MethodsOption<TMethods, keyof (EventsDef & CustomEventsDef)> & PropertiesOption<TProperties> & IsPageOption<TIsPage> & EventsOption<TEvents> & IfExtends<TIsPage, false, CustomEventsOption<TCustomEvents, keyof EventsDef>, {}> & DataOption<TData, keyof PropertiesDef> & StoreOption<TStore, keyof (PropertiesDef & DataDef)> & ComputedOption<TComputed, keyof (PropertiesDef & DataDef & StoreDef)> & PageLifetimesOption<TIsPage, PropertiesDef> & LifetimesOption & WatchOption<ComputedDef & Required<PropertiesDef> & DataDef & StoreDef & IInjectStore> & Partial<Omit<WMCompOtherOption, "pageLifetimes" | "definitionFilter" | "observers">> & ObserversOption<ComputedDef & Required<PropertiesDef> & DataDef & StoreDef & IInjectStore> & ThisType<RootComponentInstance<TIsPage, TMethods & Omit<IInjectMethods, keyof TMethods>, DataDef, SelfAllDatas & ValidInjectDatas, CustomEventsDef, StoreDef>>;
|
|
34
|
+
type RootComponentConstructor<TComponentDocList extends ComponentDoc[]> = <TEvents extends EventsConstraint<TComponentDocList>, TStore extends StoreConstraint<ComputeIntersection<Required<PropertiesDef> & DataDef & Omit<InjectData, keyof (PropertiesDef & DataDef)>>>, TIsPage extends boolean = false, const TProperties extends PropertiesConstraint = {}, TData extends object = {}, TComputed extends ComputedConstraint = {}, TCustomEvents extends IfExtends<TIsPage, false, CustomEventConstraint, EmptyObject> = {}, TMethods extends MethodsConstraint = {}, EventsDef extends object = IfExtends<EventsConstraint<TComponentDocList>, TEvents, {}, TEvents>, CustomEventsDef extends object = GetCustomEventsDef<TCustomEvents>, PropertiesDef extends object = GetPropertiesDef<TProperties>, DataDef extends object = TData, StoreDef extends object = StoreConstraint<ComputeIntersection<Required<PropertiesDef> & DataDef & Omit<InjectData, keyof (PropertiesDef & DataDef)>>> extends TStore ? {} : GetStoreDef<TStore>, ComputedDef extends object = GetComputedDef<TComputed>, SelfAllDatas extends object = Required<PropertiesDef> & DataDef & StoreDef & ComputedDef, ValidInjectDatas extends object = Omit<IInjectAllData, keyof SelfAllDatas>>(options: RootComponentOptions<TEvents, TIsPage, TCustomEvents, TMethods, TProperties, TData, TStore, TComputed, EventsDef, CustomEventsDef, PropertiesDef, DataDef, StoreDef, ComputedDef, SelfAllDatas, ValidInjectDatas>) => ComputeIntersection<IfExtends<TIsPage, false, {}, {
|
|
35
35
|
isPage: true;
|
|
36
36
|
}> & IfExtends<EmptyObject, PropertiesDef, {}, {
|
|
37
37
|
properties: IfExtends<false, TIsPage, PropertiesDef, RemoveNullOfRequired<PropertiesDef>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/RootComponent/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/RootComponent/index.ts"],"names":[],"mappings":"AAyJA,MAAM,UAAU,aAAa;IAO3B,OAAO,CAAC,OAAY,EAAE,EAAE,CAAC,OAAO,CAAC;AACnC,CAAC"}
|
package/package.json
CHANGED
|
@@ -11,15 +11,20 @@ wx.onThemeChange((Res) => {
|
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
// 注入的方法;
|
|
14
|
-
function
|
|
14
|
+
function injectMethodA(data: string) {
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
function injectMethodB(data: number) {
|
|
15
18
|
return data;
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
const data = {
|
|
19
22
|
injectStr: "injectStr",
|
|
23
|
+
injectNum: 123,
|
|
20
24
|
};
|
|
21
25
|
const methods = {
|
|
22
|
-
|
|
26
|
+
injectMethodA,
|
|
27
|
+
injectMethodB,
|
|
23
28
|
};
|
|
24
29
|
const store = {
|
|
25
30
|
injectTheme: () => themeStore.theme,
|
|
@@ -19,16 +19,15 @@ interface BaseInjectInfo {
|
|
|
19
19
|
|
|
20
20
|
export interface IInjectInfo extends BaseInjectInfo {
|
|
21
21
|
}
|
|
22
|
+
export type InjectData = DataConstraint extends IInjectInfo["data"] ? {} : IInjectInfo["data"];
|
|
22
23
|
|
|
23
24
|
export type IInjectAllData = IfEquals<
|
|
24
25
|
{},
|
|
25
|
-
|
|
26
|
+
InjectData & IInjectStore,
|
|
26
27
|
{},
|
|
27
|
-
ComputeIntersection<
|
|
28
|
+
ComputeIntersection<InjectData & IInjectStore>
|
|
28
29
|
>;
|
|
29
30
|
|
|
30
|
-
type injectData = DataConstraint extends IInjectInfo["data"] ? {} : IInjectInfo["data"];
|
|
31
|
-
|
|
32
31
|
export type IInjectStore = StoreConstraint extends IInjectInfo["store"] ? {}
|
|
33
32
|
: ReturnTypeInObject<IInjectInfo["store"]>;
|
|
34
33
|
|
|
@@ -10,7 +10,7 @@ RootComponent()({
|
|
|
10
10
|
|
|
11
11
|
Checking<typeof this.data.injectTheme, "dark" | "light" | undefined, Test.Pass>;
|
|
12
12
|
|
|
13
|
-
Checking<typeof this.
|
|
13
|
+
Checking<typeof this.injectMethodA, (data: string) => string, Test.Pass>;
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
});
|
|
@@ -18,12 +18,12 @@ RootComponent()({
|
|
|
18
18
|
// 2. 注入字段重复时,自身覆盖注入类型
|
|
19
19
|
RootComponent()({
|
|
20
20
|
data: {
|
|
21
|
-
//
|
|
21
|
+
// 覆盖注入的数据类型,注入的类型为string。
|
|
22
22
|
injectStr: 123,
|
|
23
23
|
},
|
|
24
24
|
store: {
|
|
25
|
-
//
|
|
26
|
-
injectTheme: (
|
|
25
|
+
// 覆盖注入的数据类型,注入的类型为"dark" | "light" | undefined。
|
|
26
|
+
injectTheme: () => "aaa",
|
|
27
27
|
},
|
|
28
28
|
methods: {
|
|
29
29
|
// 覆盖注入的方法类型
|
|
@@ -31,9 +31,10 @@ RootComponent()({
|
|
|
31
31
|
return 123;
|
|
32
32
|
},
|
|
33
33
|
testInjectTypes() {
|
|
34
|
+
// 覆盖注入的数据类型,注入的类型为string。
|
|
34
35
|
Checking<typeof this.data.injectStr, number, Test.Pass>;
|
|
35
|
-
|
|
36
|
-
Checking<typeof this.data.injectTheme,
|
|
36
|
+
// 覆盖注入的数据类型,注入的类型为"dark" | "light" | undefined。
|
|
37
|
+
Checking<typeof this.data.injectTheme, string, Test.Pass>;
|
|
37
38
|
|
|
38
39
|
Checking<typeof this.injectMethod, () => 123, Test.Pass>;
|
|
39
40
|
},
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Checking, type Test } from "hry-types";
|
|
2
|
+
import { type DetailedType, RootComponent } from "../../../../..";
|
|
3
|
+
|
|
4
|
+
// 组件时
|
|
5
|
+
RootComponent()({
|
|
6
|
+
properties: {
|
|
7
|
+
obj: Object,
|
|
8
|
+
optionalObj: {
|
|
9
|
+
type: Object as DetailedType<{ name: string }>,
|
|
10
|
+
value: { name: "zhao" },
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
data: {
|
|
14
|
+
dataStr: "dataStr",
|
|
15
|
+
// 相同字段覆盖注入类型
|
|
16
|
+
injectStr: 123,
|
|
17
|
+
},
|
|
18
|
+
store: {
|
|
19
|
+
storeData: (data) => {
|
|
20
|
+
return data.optionalObj.name;
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
lifetimes: {
|
|
24
|
+
attached() {
|
|
25
|
+
// 组件实例对象格外添加null类型
|
|
26
|
+
Checking<
|
|
27
|
+
typeof this.data,
|
|
28
|
+
{
|
|
29
|
+
optionalObj: {
|
|
30
|
+
name: string;
|
|
31
|
+
};
|
|
32
|
+
obj: object;
|
|
33
|
+
dataStr: string;
|
|
34
|
+
storeData: string;
|
|
35
|
+
injectTheme: "dark" | "light" | undefined;
|
|
36
|
+
injectStr: number; // 相同字段覆盖注入类型 injectStr: string -> number
|
|
37
|
+
injectNum: number;
|
|
38
|
+
},
|
|
39
|
+
Test.Pass
|
|
40
|
+
>();
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
@@ -3,14 +3,23 @@ import { RootComponent } from "../../../../..";
|
|
|
3
3
|
|
|
4
4
|
RootComponent()({
|
|
5
5
|
methods: {
|
|
6
|
+
// 与注入方法同名,会覆盖注入方法
|
|
7
|
+
injectMethodB(num: string) {
|
|
8
|
+
return num;
|
|
9
|
+
},
|
|
10
|
+
|
|
6
11
|
M1() {
|
|
7
12
|
return 1;
|
|
8
13
|
},
|
|
9
14
|
|
|
10
15
|
M2(str: string) {
|
|
11
|
-
|
|
16
|
+
Checking<typeof this.M1, () => 1, Test.Pass>();
|
|
17
|
+
|
|
18
|
+
Checking<typeof this.M2, (str: string) => string, Test.Pass>();
|
|
12
19
|
|
|
13
|
-
|
|
20
|
+
Checking<typeof this.injectMethodA, (str: string) => string, Test.Pass>();
|
|
21
|
+
// 自身方法会覆盖注入方法,所以类型为自身方法的类型
|
|
22
|
+
Checking<typeof this.injectMethodB, (num: string) => string, Test.Pass>();
|
|
14
23
|
|
|
15
24
|
return str;
|
|
16
25
|
},
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Checking, type Test } from "hry-types";
|
|
1
2
|
import { observable } from "mobx";
|
|
2
3
|
import { typeEqual } from "../../../../utils/_utils";
|
|
3
4
|
import { RootComponent } from "../..";
|
|
@@ -9,15 +10,30 @@ const user = observable({
|
|
|
9
10
|
const storeDoc = RootComponent()({
|
|
10
11
|
properties: {
|
|
11
12
|
condition: Number,
|
|
13
|
+
optional: {
|
|
14
|
+
type: Number,
|
|
15
|
+
value: 10,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
data: {
|
|
19
|
+
injectStr: 123,
|
|
12
20
|
},
|
|
13
21
|
store: {
|
|
14
|
-
//
|
|
22
|
+
// 1. 简单的箭头函数写法
|
|
15
23
|
userName: () => user.name,
|
|
16
|
-
//
|
|
17
|
-
userAge: (
|
|
18
|
-
|
|
24
|
+
// 2. 使用参数 datas
|
|
25
|
+
userAge: (datas) => {
|
|
26
|
+
// 参数类型为Required<PropertiesDef> & DataDef & Omit<InjectData, keyof (PropertiesDef & DataDef).
|
|
27
|
+
Checking<
|
|
28
|
+
typeof datas,
|
|
29
|
+
{ condition: number; optional: number; injectStr: number; injectNum: number },
|
|
30
|
+
Test.Pass
|
|
31
|
+
>();
|
|
32
|
+
|
|
33
|
+
if (datas.condition > 10) {
|
|
19
34
|
return user.age;
|
|
20
35
|
}
|
|
36
|
+
// 返回undefined时字段不会被响应式追踪,不会报错(有警告).
|
|
21
37
|
return undefined;
|
|
22
38
|
},
|
|
23
39
|
},
|
|
@@ -25,8 +41,12 @@ const storeDoc = RootComponent()({
|
|
|
25
41
|
|
|
26
42
|
type StoreDocExpected = {
|
|
27
43
|
properties: {
|
|
44
|
+
optional?: number;
|
|
28
45
|
condition: number;
|
|
29
46
|
};
|
|
47
|
+
data: {
|
|
48
|
+
injectStr: number;
|
|
49
|
+
};
|
|
30
50
|
store: {
|
|
31
51
|
userName: string;
|
|
32
52
|
userAge: number | undefined;
|
|
@@ -6,7 +6,7 @@ import type { ComputeObject } from "../../types/ComputeObject";
|
|
|
6
6
|
import type { WMCompOtherOption } from "../../types/OfficialTypeAlias";
|
|
7
7
|
import type { RemoveNullOfRequired } from "../../types/RemoveNullOfRequired";
|
|
8
8
|
import type { ComponentDoc } from "../DefineComponent/returnType/ComponentDoc";
|
|
9
|
-
import type { IInjectStore } from "../InstanceInject/instanceConfig";
|
|
9
|
+
import type { IInjectAllData, IInjectMethods, IInjectStore, InjectData } from "../InstanceInject/instanceConfig";
|
|
10
10
|
import type { ComputedConstraint } from "./Computed/ComputedConstraint";
|
|
11
11
|
import type { ComputedOption } from "./Computed/ComputedOption";
|
|
12
12
|
import type { GetComputedDef } from "./Computed/GetComputedDef";
|
|
@@ -46,6 +46,8 @@ type RootComponentOptions<
|
|
|
46
46
|
DataDef extends object,
|
|
47
47
|
StoreDef extends object,
|
|
48
48
|
ComputedDef extends object,
|
|
49
|
+
SelfAllDatas extends object,
|
|
50
|
+
ValidInjectDatas extends object,
|
|
49
51
|
> =
|
|
50
52
|
& MethodsOption<TMethods, keyof (EventsDef & CustomEventsDef)>
|
|
51
53
|
& PropertiesOption<TProperties>
|
|
@@ -57,7 +59,7 @@ type RootComponentOptions<
|
|
|
57
59
|
& ComputedOption<
|
|
58
60
|
TComputed,
|
|
59
61
|
keyof (PropertiesDef & DataDef & StoreDef)
|
|
60
|
-
>
|
|
62
|
+
>
|
|
61
63
|
& PageLifetimesOption<TIsPage, PropertiesDef>
|
|
62
64
|
& LifetimesOption
|
|
63
65
|
& WatchOption<
|
|
@@ -78,9 +80,9 @@ type RootComponentOptions<
|
|
|
78
80
|
& ThisType<
|
|
79
81
|
RootComponentInstance<
|
|
80
82
|
TIsPage,
|
|
81
|
-
TMethods,
|
|
83
|
+
TMethods & Omit<IInjectMethods, keyof TMethods>,
|
|
82
84
|
DataDef,
|
|
83
|
-
|
|
85
|
+
SelfAllDatas & ValidInjectDatas,
|
|
84
86
|
CustomEventsDef,
|
|
85
87
|
StoreDef
|
|
86
88
|
>
|
|
@@ -88,7 +90,9 @@ type RootComponentOptions<
|
|
|
88
90
|
|
|
89
91
|
type RootComponentConstructor<TComponentDocList extends ComponentDoc[]> = <
|
|
90
92
|
TEvents extends EventsConstraint<TComponentDocList>,
|
|
91
|
-
TStore extends StoreConstraint<
|
|
93
|
+
TStore extends StoreConstraint<
|
|
94
|
+
ComputeIntersection<Required<PropertiesDef> & DataDef & Omit<InjectData, keyof (PropertiesDef & DataDef)>>
|
|
95
|
+
>,
|
|
92
96
|
TIsPage extends boolean = false,
|
|
93
97
|
const TProperties extends PropertiesConstraint = {},
|
|
94
98
|
TData extends object = {},
|
|
@@ -100,8 +104,13 @@ type RootComponentConstructor<TComponentDocList extends ComponentDoc[]> = <
|
|
|
100
104
|
CustomEventsDef extends object = GetCustomEventsDef<TCustomEvents>,
|
|
101
105
|
PropertiesDef extends object = GetPropertiesDef<TProperties>,
|
|
102
106
|
DataDef extends object = TData,
|
|
103
|
-
StoreDef extends object = StoreConstraint<
|
|
107
|
+
StoreDef extends object = StoreConstraint<
|
|
108
|
+
ComputeIntersection<Required<PropertiesDef> & DataDef & Omit<InjectData, keyof (PropertiesDef & DataDef)>>
|
|
109
|
+
> extends TStore ? {}
|
|
110
|
+
: GetStoreDef<TStore>,
|
|
104
111
|
ComputedDef extends object = GetComputedDef<TComputed>,
|
|
112
|
+
SelfAllDatas extends object = Required<PropertiesDef> & DataDef & StoreDef & ComputedDef,
|
|
113
|
+
ValidInjectDatas extends object = Omit<IInjectAllData, keyof SelfAllDatas>,
|
|
105
114
|
>(
|
|
106
115
|
options: RootComponentOptions<
|
|
107
116
|
TEvents,
|
|
@@ -118,7 +127,9 @@ type RootComponentConstructor<TComponentDocList extends ComponentDoc[]> = <
|
|
|
118
127
|
PropertiesDef,
|
|
119
128
|
DataDef,
|
|
120
129
|
StoreDef,
|
|
121
|
-
ComputedDef
|
|
130
|
+
ComputedDef,
|
|
131
|
+
SelfAllDatas,
|
|
132
|
+
ValidInjectDatas
|
|
122
133
|
>,
|
|
123
134
|
) => // 生成RootComponentDefinition
|
|
124
135
|
ComputeIntersection<
|
|
@@ -149,3 +160,5 @@ export function RootComponent<
|
|
|
149
160
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
150
161
|
return (options: any) => options;
|
|
151
162
|
}
|
|
163
|
+
|
|
164
|
+
// 全局实例增加 有效的注入数据,store字段参数包含 (prop + data + 有效的注入数据)
|