annil 1.6.1 → 1.6.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 +7 -0
- package/dist/api/DefineComponent/assignOptions/index.js +0 -8
- package/dist/api/DefineComponent/assignOptions/index.js.map +1 -1
- package/dist/api/InstanceInject/instanceConfig.d.ts +5 -2
- package/dist/api/InstanceInject/instanceConfig.js.map +1 -1
- package/dist/api/RootComponent/Instance/RootComponentInstance.d.ts +3 -6
- package/dist/api/RootComponent/Observers/ObserversOption.d.ts +2 -3
- package/dist/api/RootComponent/Watch/WatchOption.d.ts +2 -3
- package/dist/api/RootComponent/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/api/DefineComponent/assignOptions/index.ts +12 -12
- package/src/api/InstanceInject/instanceConfig.ts +11 -2
- package/src/api/RootComponent/Computed/test/normal.test.ts +16 -16
- package/src/api/RootComponent/CustomEvents/test/normal.test.ts +0 -19
- package/src/api/RootComponent/Data/test/normal.test.ts +5 -36
- package/src/api/RootComponent/Instance/RootComponentInstance.ts +4 -5
- package/src/api/RootComponent/Instance/test/properties/mormal.test.ts +9 -4
- package/src/api/RootComponent/Observers/ObserversOption.ts +8 -11
- package/src/api/RootComponent/Observers/test/normal.test.ts +2 -3
- package/src/api/RootComponent/Properties/test/normalEmpty.test.ts +5 -6
- package/src/api/RootComponent/Properties/test/normalOptional.test.ts +4 -4
- package/src/api/RootComponent/Properties/test/normalRequired.test.ts +4 -4
- package/src/api/RootComponent/Watch/WatchOption.ts +17 -23
- package/src/api/RootComponent/Watch/test/WatchComputed.test.ts +4 -4
- package/src/api/RootComponent/Watch/test/WatchData.test.ts +4 -5
- package/src/api/RootComponent/Watch/test/WatchProperties.test.ts +13 -23
- package/src/api/RootComponent/index.ts +2 -2
- package/src/api/SubComponent/SubComputed/test/normal.test.ts +6 -6
- package/src/api/SubComponent/SubData/test/normal.test.ts +5 -5
- package/src/api/SubComponent/SubInstance/test/normal.test.ts +4 -4
- package/src/api/SubComponent/SubWatch/test/WatchProperties.test.ts +13 -23
- package/src/api/SubComponent/SubWatch/test/WatchRootData.test.ts +10 -11
- package/src/api/RootComponent/Instance/test/cloneData/error.test.ts +0 -31
- package/src/api/RootComponent/Instance/test/cloneData/normal.test.ts +0 -53
- package/src/api/SubComponent/SubInstance/test/cloneData/error.test.ts +0 -22
- package/src/api/SubComponent/SubInstance/test/cloneData/normal.test.ts +0 -73
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.6.2](https://github.com/missannil/annil/compare/v1.6.1...v1.6.2) (2024-02-03)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* 去除this.data、observer参数,watch参数的readonlyDeep类型 ([4df6fd1](https://github.com/missannil/annil/commit/4df6fd117e573980293e609dc422c2d5f4a91c32))
|
|
13
|
+
|
|
7
14
|
## [1.6.1](https://github.com/missannil/annil/compare/v1.6.0...v1.6.1) (2024-02-02)
|
|
8
15
|
|
|
9
16
|
|
|
@@ -17,13 +17,6 @@ export function isPageCheck(isPage) {
|
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
function addCloneDataToInstance() {
|
|
21
|
-
this.cloneData = new Proxy(this.data, {
|
|
22
|
-
get: (target, key) => {
|
|
23
|
-
return deepClone(target)[key];
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
20
|
function onLoadReceivedDataHandle(option) {
|
|
28
21
|
const innerData = option[INNERMARKER.url];
|
|
29
22
|
if (innerData === undefined)
|
|
@@ -200,7 +193,6 @@ export function assignOptions(defineComponentOption) {
|
|
|
200
193
|
&& hijack(finalOptionsForComponent.pageLifetimes, "load", [loadReceivedDataHandle]);
|
|
201
194
|
hijack(finalOptionsForComponent.methods, "onLoad", [onLoadReceivedDataHandle]);
|
|
202
195
|
hijack(finalOptionsForComponent.lifetimes, "attached", [isPageCheck(rootComponentOption === null || rootComponentOption === void 0 ? void 0 : rootComponentOption.isPage)]);
|
|
203
|
-
hijack(finalOptionsForComponent.lifetimes, "created", [addCloneDataToInstance]);
|
|
204
196
|
finalOptionsForComponent.isPage
|
|
205
197
|
&& finalOptionsForComponent.options && Reflect.deleteProperty(finalOptionsForComponent.options, "virtualHost");
|
|
206
198
|
initStore(finalOptionsForComponent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/DefineComponent/assignOptions/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAGlE,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAmBrE,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAuDxC,MAAM,UAAU,WAAW,CAAC,MAA2B;IACrD,OAAO;QACL,MAAM,KAAK,GAAI,IAAqB,CAAC,KAA2B,CAAC;QACjE,IAAI,KAAK,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YAE7B,MAAM,KAAK,CACT,OAAO,KAAK,yCAAyC,CACtD,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,KAAK,IAAI,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAEvD,MAAM,KAAK,CACT,MAAM,IAAI,CAA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;IAGjH,SAAS,CAAC,wBAAwB,CAAC,CAAC;IAGpC,mBAAmB,CAAC,wBAAwB,CAAC,CAAC;IAG9C,wBAAwB,CAAC,SAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAExD,OAAO,wBAAwB,CAAC;AAClC,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { IfEquals } from "hry-types/src/Any/IfEquals";
|
|
2
|
+
import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
|
|
1
3
|
import type { ReturnTypeInObject } from "hry-types/src/Object/ReturnTypeInObject";
|
|
2
4
|
import type { WMComponentOption } from "../../types/OfficialTypeAlias";
|
|
3
5
|
import type { DataConstraint } from "../RootComponent/Data/DataConstraint";
|
|
@@ -12,8 +14,9 @@ interface BaseInjectInfo {
|
|
|
12
14
|
}
|
|
13
15
|
export interface IInjectInfo extends BaseInjectInfo {
|
|
14
16
|
}
|
|
15
|
-
export type
|
|
16
|
-
|
|
17
|
+
export type IInjectAllData = IfEquals<{}, injectData & IInjectStore, {}, ComputeIntersection<injectData & IInjectStore>>;
|
|
18
|
+
type injectData = DataConstraint extends IInjectInfo["data"] ? {} : IInjectInfo["data"];
|
|
19
|
+
export type IInjectStore = StoreConstraint extends IInjectInfo["store"] ? {} : ReturnTypeInObject<IInjectInfo["store"]>;
|
|
17
20
|
export type IInjectMethods = IInjectInfo["methods"];
|
|
18
21
|
declare class InstanceConfig {
|
|
19
22
|
private info;
|
|
@@ -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":"AAwCA,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,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACxC,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
2
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
3
2
|
import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
|
|
4
3
|
import type { IReactionDisposer } from "mobx";
|
|
5
4
|
import type { Assign } from "../../../types/Assign";
|
|
6
5
|
import type { ComputeObject } from "../../../types/ComputeObj";
|
|
7
6
|
import type { WMComponentInstance, WMInstanceMethods, WMPageInstance } from "../../../types/OfficialTypeAlias";
|
|
8
|
-
import type {
|
|
7
|
+
import type { IInjectAllData, IInjectMethods } from "../../InstanceInject/instanceConfig";
|
|
9
8
|
import type { CustomEventMethods } from "./CustomEventMethods";
|
|
10
9
|
import type { CustomSetData } from "./CustomSetData";
|
|
11
|
-
export type RootComponentInstance<TIsPage extends boolean, TMethods extends object, TDataForSetData extends object, AllData extends object, CustomEventsDoc extends object, StoreDoc extends object, instanceData = ComputeObject<Assign<
|
|
10
|
+
export type RootComponentInstance<TIsPage extends boolean, TMethods extends object, TDataForSetData extends object, AllData extends object, CustomEventsDoc extends object, StoreDoc extends object, instanceData = ComputeObject<Assign<IInjectAllData, ComputeIntersection<AllData>>>> = IfExtends<false, TIsPage, WMComponentInstance, WMPageInstance> & Omit<WMInstanceMethods<{}>, "setData"> & CustomSetData<TDataForSetData> & IfExtends<{}, StoreDoc, unknown, {
|
|
12
11
|
disposer: {
|
|
13
12
|
[k in keyof StoreDoc]: IReactionDisposer;
|
|
14
13
|
};
|
|
15
14
|
}> & Assign<IInjectMethods, TMethods & CustomEventMethods<CustomEventsDoc>> & {
|
|
16
|
-
data:
|
|
17
|
-
} & {
|
|
18
|
-
cloneData: ComputeObject<Assign<IInjectData, ComputeIntersection<AllData>>>;
|
|
15
|
+
data: instanceData;
|
|
19
16
|
};
|
|
20
17
|
export type ComponentInstance = RootComponentInstance<false, {}, {}, {}, {}, {}>;
|
|
21
18
|
export type PageInstance = RootComponentInstance<true, {}, {}, {}, {}, {}>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
2
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
3
2
|
import type { IsPureObject } from "hry-types/src/Any/IsPureObject";
|
|
4
3
|
import type { NoInfer } from "hry-types/src/Generic/NoInfer";
|
|
@@ -8,11 +7,11 @@ type getLastKeys<T extends string> = T extends `${string}.${infer L}` ? L : neve
|
|
|
8
7
|
type AddFieldsOfObject<TWatchData extends object, _WatchKeys extends keyof TWatchData, secondKeys extends string = {
|
|
9
8
|
[k in _WatchKeys]: IsPureObject<Exclude<TWatchData[k], null>> extends true ? `${k & string}.${(keyof Exclude<TWatchData[k], null>) & string}` | `${k & string}.**` : never;
|
|
10
9
|
}[_WatchKeys]> = {
|
|
11
|
-
[k in secondKeys]?: (newValue:
|
|
10
|
+
[k in secondKeys]?: (newValue: IfExtends<getLastKeys<k>, "**", TWatchData[getFirstKeys<k>], NonNullable<(Exclude<TWatchData[getFirstKeys<k>], null>)[getLastKeys<k>]>>) => void;
|
|
12
11
|
};
|
|
13
12
|
export type ObserversOption<TWatchData extends object, _WatchKeys extends keyof TWatchData = keyof TWatchData> = {
|
|
14
13
|
observers?: IfExtends<{}, TWatchData, EmptyObject, NoInfer<{
|
|
15
|
-
[k in _WatchKeys | "**"]?: (newValue: k extends keyof TWatchData ?
|
|
14
|
+
[k in _WatchKeys | "**"]?: (newValue: k extends keyof TWatchData ? TWatchData[k] : unknown) => void;
|
|
16
15
|
} & {
|
|
17
16
|
[k in _WatchKeys as never]: unknown;
|
|
18
17
|
} & AddFieldsOfObject<TWatchData, _WatchKeys>>>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
2
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
3
2
|
import type { IsPureObject } from "hry-types/src/Any/IsPureObject";
|
|
4
3
|
import type { NoInfer } from "hry-types/src/Generic/NoInfer";
|
|
@@ -8,11 +7,11 @@ type getLastKeys<T extends string> = T extends `${string}.${infer L}` ? L : neve
|
|
|
8
7
|
type AddFieldsOfObject<TWatchData extends object, _WatchKeys extends keyof TWatchData, secondKeys extends string = {
|
|
9
8
|
[k in _WatchKeys]: IsPureObject<Exclude<TWatchData[k], null>> extends true ? `${k & string}.${(keyof Exclude<TWatchData[k], null>) & string}` | `${k & string}.**` : never;
|
|
10
9
|
}[_WatchKeys]> = {
|
|
11
|
-
[k in secondKeys]?: (newValue:
|
|
10
|
+
[k in secondKeys]?: (newValue: IfExtends<getLastKeys<k>, "**", Exclude<TWatchData[getFirstKeys<k>], null>, NonNullable<(Exclude<TWatchData[getFirstKeys<k>], null>)[getLastKeys<k>]>>, oldValue: IfExtends<getLastKeys<k>, "**", TWatchData[getFirstKeys<k>], (Exclude<TWatchData[getFirstKeys<k>], null>)[getLastKeys<k>]>) => void;
|
|
12
11
|
};
|
|
13
12
|
export type WatchOption<TWatchData extends object, _WatchKeys extends keyof TWatchData = keyof TWatchData> = {
|
|
14
13
|
watch?: IfExtends<{}, TWatchData, EmptyObject, NoInfer<{
|
|
15
|
-
[k in _WatchKeys]?: (newValue:
|
|
14
|
+
[k in _WatchKeys]?: (newValue: Exclude<TWatchData[k], null>, oldValue: TWatchData[k]) => void;
|
|
16
15
|
} & {
|
|
17
16
|
[k in _WatchKeys as never]: unknown;
|
|
18
17
|
} & AddFieldsOfObject<TWatchData, _WatchKeys>>>;
|
|
@@ -5,7 +5,7 @@ import type { ComputeIntersection } from "hry-types/src/Object/_api";
|
|
|
5
5
|
import type { ComputeObject } from "../../types/ComputeObj";
|
|
6
6
|
import type { WMCompOtherOption } from "../../types/OfficialTypeAlias";
|
|
7
7
|
import type { ComponentDoc } from "../DefineComponent/ReturnType/ComponentDoc";
|
|
8
|
-
import type {
|
|
8
|
+
import type { IInjectAllData, IInjectStore } from "../InstanceInject/instanceConfig";
|
|
9
9
|
import type { ComputedConstraint } from "./Computed/ComputedConstraint";
|
|
10
10
|
import type { ComputedOption } from "./Computed/ComputedOption";
|
|
11
11
|
import type { GetComputedDoc } from "./Computed/GetComputedDoc";
|
|
@@ -32,7 +32,7 @@ import type { StoreConstraint } from "./Store/StoreConstraint";
|
|
|
32
32
|
import type { StoreOption } from "./Store/StoreOption";
|
|
33
33
|
import type { WatchOption } from "./Watch/WatchOption";
|
|
34
34
|
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>, EventsDoc extends object, CustomEventsDoc extends object, PropertiesDoc extends object, DataDoc extends object, StoreDoc extends object, ComputedDoc extends object> = MethodsOption<TMethods, keyof (EventsDoc & CustomEventsDoc)> & PropertiesOption<TProperties> & IsPageOption<TIsPage> & EventsOption<TEvents> & CustomEventsOption<TCustomEvents, keyof EventsDoc> & DataOption<TData, keyof PropertiesDoc> & StoreOption<TStore, keyof (PropertiesDoc & DataDoc)> & ComputedOption<TComputed, keyof (PropertiesDoc & DataDoc & StoreDoc), {
|
|
35
|
-
data: ComputeObject<DataDoc & Required<PropertiesDoc> & StoreDoc & ComputedDoc &
|
|
35
|
+
data: ComputeObject<DataDoc & Required<PropertiesDoc> & StoreDoc & ComputedDoc & IInjectAllData>;
|
|
36
36
|
}> & PageLifetimesOption<TIsPage, PropertiesDoc> & LifetimesOption & WatchOption<ComputedDoc & Required<PropertiesDoc> & DataDoc & StoreDoc & IInjectStore> & Partial<Omit<WMCompOtherOption, "pageLifetimes" | "definitionFilter" | "observers">> & ObserversOption<ComputedDoc & Required<PropertiesDoc> & DataDoc & StoreDoc & IInjectStore> & ThisType<RootComponentInstance<TIsPage, TMethods, DataDoc, DataDoc & Required<PropertiesDoc> & StoreDoc & ComputedDoc, CustomEventsDoc, StoreDoc>>;
|
|
37
37
|
type RootComponentConstructor<TComponentDocList extends ComponentDoc[]> = {
|
|
38
38
|
<TEvents extends EventsConstraint<TComponentDocList>, TIsPage extends boolean = false, const TProperties extends PropertiesConstraint = {}, TData extends object = {}, TStore extends StoreConstraint = {}, TComputed extends ComputedConstraint = {}, TCustomEvents extends IfExtends<TIsPage, false, CustomEventConstraint, EmptyObject> = {}, TMethods extends MethodsConstraint = {}, EventsDoc extends object = IfExtends<EventsConstraint<TComponentDocList>, TEvents, {}, TEvents>, CustomEventsDoc extends object = GetCustomEventDoc<TCustomEvents>, PropertiesDoc extends object = GetPropertiesDoc<TProperties, TIsPage>, DataDoc extends object = TData, StoreDoc extends object = GetStoreDoc<TStore>, ComputedDoc extends object = GetComputedDoc<TComputed>>(options: RootComponentOptions<TEvents, TIsPage, TCustomEvents, TMethods, TProperties, TData, TStore, TComputed, EventsDoc, CustomEventsDoc, PropertiesDoc, DataDoc, StoreDoc, ComputedDoc>): ComputeIntersection<IfExtends<TIsPage, false, {}, {
|
package/package.json
CHANGED
|
@@ -101,13 +101,13 @@ export function isPageCheck(isPage: boolean | undefined) {
|
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
function addCloneDataToInstance(this: Instance) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
104
|
+
// function addCloneDataToInstance(this: Instance) {
|
|
105
|
+
// this.cloneData = new Proxy(this.data, {
|
|
106
|
+
// get: <T extends object>(target: T, key: keyof T) => {
|
|
107
|
+
// return deepClone(target)[key];
|
|
108
|
+
// },
|
|
109
|
+
// });
|
|
110
|
+
// }
|
|
111
111
|
/**
|
|
112
112
|
* 原生Component会对传入的对象字段匹配的properties字段setData赋值。不符合字段或Page时不会赋值。
|
|
113
113
|
* 此函数为给实例setData赋值,默认传递值与properties相符(ts类型安全)。
|
|
@@ -446,11 +446,11 @@ export function assignOptions(
|
|
|
446
446
|
[isPageCheck(rootComponentOption?.isPage)],
|
|
447
447
|
);
|
|
448
448
|
|
|
449
|
-
hijack(
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
);
|
|
449
|
+
// hijack(
|
|
450
|
+
// finalOptionsForComponent.lifetimes!,
|
|
451
|
+
// "created",
|
|
452
|
+
// [addCloneDataToInstance],
|
|
453
|
+
// );
|
|
454
454
|
|
|
455
455
|
// 页面时删除预设的虚拟组件字段
|
|
456
456
|
finalOptionsForComponent.isPage
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
|
|
2
2
|
|
|
3
|
+
import type { IfEquals } from "hry-types/src/Any/IfEquals";
|
|
4
|
+
import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
|
|
3
5
|
import type { ReturnTypeInObject } from "hry-types/src/Object/ReturnTypeInObject";
|
|
4
6
|
import type { WMComponentOption } from "../../types/OfficialTypeAlias";
|
|
5
7
|
import type { DataConstraint } from "../RootComponent/Data/DataConstraint";
|
|
@@ -19,9 +21,16 @@ interface BaseInjectInfo {
|
|
|
19
21
|
export interface IInjectInfo extends BaseInjectInfo {
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
export type
|
|
24
|
+
export type IInjectAllData = IfEquals<
|
|
25
|
+
{},
|
|
26
|
+
injectData & IInjectStore,
|
|
27
|
+
{},
|
|
28
|
+
ComputeIntersection<injectData & IInjectStore>
|
|
29
|
+
>;
|
|
23
30
|
|
|
24
|
-
|
|
31
|
+
type injectData = DataConstraint extends IInjectInfo["data"] ? {} : IInjectInfo["data"];
|
|
32
|
+
|
|
33
|
+
export type IInjectStore = StoreConstraint extends IInjectInfo["store"] ? {}
|
|
25
34
|
: ReturnTypeInObject<IInjectInfo["store"]>;
|
|
26
35
|
|
|
27
36
|
export type IInjectMethods = IInjectInfo["methods"];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { ComputeIntersection } from "hry-types/src/Object/_api";
|
|
3
|
+
import type { IInjectAllData } from "../../../InstanceInject/instanceConfig";
|
|
4
4
|
import { RootComponent } from "../..";
|
|
5
5
|
import type { Mock_User } from "../../Properties/test/normalRequired.test";
|
|
6
6
|
|
|
@@ -31,18 +31,18 @@ const RootDoc = RootComponent()({
|
|
|
31
31
|
// 3 this.data 类型是深度只读的
|
|
32
32
|
Checking<
|
|
33
33
|
typeof this.data,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
ComputeIntersection<
|
|
35
|
+
{
|
|
36
|
+
firstName: string;
|
|
37
|
+
lastName: string;
|
|
38
|
+
mock_User: Mock_User;
|
|
39
|
+
fullName: string;
|
|
40
|
+
user: Mock_User;
|
|
41
|
+
prefix: string;
|
|
42
|
+
id_fullName: string;
|
|
43
|
+
readOnly: "str";
|
|
44
|
+
} & IInjectAllData
|
|
45
|
+
>,
|
|
46
46
|
Test.Pass
|
|
47
47
|
>;
|
|
48
48
|
|
|
@@ -71,7 +71,7 @@ const noComputedFieldDoc = RootComponent()({
|
|
|
71
71
|
methods: {
|
|
72
72
|
M1() {
|
|
73
73
|
// 5.1 无computed,this.data中为{}
|
|
74
|
-
Checking<typeof this.data,
|
|
74
|
+
Checking<typeof this.data, IInjectAllData, Test.Pass>;
|
|
75
75
|
},
|
|
76
76
|
},
|
|
77
77
|
});
|
|
@@ -86,7 +86,7 @@ const EmptyComputedFieldDoc = RootComponent()({
|
|
|
86
86
|
methods: {
|
|
87
87
|
M1() {
|
|
88
88
|
// 6.1 computed为{},this.data中为{}
|
|
89
|
-
Checking<typeof this.data,
|
|
89
|
+
Checking<typeof this.data, IInjectAllData, Test.Pass>;
|
|
90
90
|
},
|
|
91
91
|
},
|
|
92
92
|
});
|
|
@@ -95,22 +95,3 @@ const rootDocNoFields = RootComponent()({});
|
|
|
95
95
|
|
|
96
96
|
// 3. 无customEvents字段时,Doc中无customEvents字段
|
|
97
97
|
Checking<typeof rootDocNoFields, {}, Test.Pass>;
|
|
98
|
-
|
|
99
|
-
// 4 实例中的对象数组都是readOnlyDeep类型,可以传递给自定义做参数
|
|
100
|
-
RootComponent()({
|
|
101
|
-
properties: {
|
|
102
|
-
obj: Object as DetailedType<Mock_User>,
|
|
103
|
-
},
|
|
104
|
-
data: {
|
|
105
|
-
obj1: {} as Mock_User,
|
|
106
|
-
_ddd: {} as Mock_User,
|
|
107
|
-
},
|
|
108
|
-
customEvents: mock_customEvents,
|
|
109
|
-
events: {
|
|
110
|
-
ddd() {
|
|
111
|
-
this.obj(this.data.obj!);
|
|
112
|
-
|
|
113
|
-
this.obj(this.data.obj1);
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
});
|
|
@@ -1,45 +1,14 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
|
-
|
|
3
|
-
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
4
|
-
import type { IInjectData } from "../../../InstanceInject/instanceConfig";
|
|
2
|
+
import type { IInjectAllData } from "../../../InstanceInject/instanceConfig";
|
|
5
3
|
import { RootComponent } from "../..";
|
|
6
4
|
|
|
7
|
-
type Gender = "male" | "female";
|
|
8
|
-
|
|
9
|
-
const RootDoc = RootComponent()({
|
|
10
|
-
data: {
|
|
11
|
-
gender: "male" as Gender, // 联合字面量
|
|
12
|
-
num: 123,
|
|
13
|
-
_innernalFields: 123, // 内部字段无法在wxml中使用
|
|
14
|
-
},
|
|
15
|
-
methods: {
|
|
16
|
-
foo() {
|
|
17
|
-
this.cloneData.num = 123;
|
|
18
|
-
|
|
19
|
-
Checking<
|
|
20
|
-
typeof this.data,
|
|
21
|
-
ReadonlyDeep<{ gender: Gender; num: number; _innernalFields: number } & IInjectData>,
|
|
22
|
-
Test.Pass
|
|
23
|
-
>;
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
type RootDocExpected = {
|
|
29
|
-
gender: Gender;
|
|
30
|
-
num: number;
|
|
31
|
-
_innernalFields: number;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
Checking<typeof RootDoc["data"], RootDocExpected, Test.Pass>;
|
|
35
|
-
|
|
36
5
|
// data为空对象时
|
|
37
6
|
const EmptyDataRootDoc = RootComponent()({
|
|
38
7
|
data: {},
|
|
39
8
|
methods: {
|
|
40
9
|
M1() {
|
|
41
|
-
// 3.1 data为空对象时 this.data
|
|
42
|
-
Checking<typeof this.data,
|
|
10
|
+
// 3.1 data为空对象时 this.data为注入数据类型
|
|
11
|
+
Checking<typeof this.data, IInjectAllData, Test.Pass>;
|
|
43
12
|
},
|
|
44
13
|
},
|
|
45
14
|
});
|
|
@@ -53,8 +22,8 @@ Checking<typeof EmptyDataRootDoc, { methods: { M1: () => void } }, Test.Pass>;
|
|
|
53
22
|
const noDataRootDoc = RootComponent()({
|
|
54
23
|
methods: {
|
|
55
24
|
M1() {
|
|
56
|
-
// 4.1 data为空对象时 this.data
|
|
57
|
-
Checking<typeof this.data,
|
|
25
|
+
// 4.1 data为空对象时 this.data为注入数据类型
|
|
26
|
+
Checking<typeof this.data, IInjectAllData, Test.Pass>;
|
|
58
27
|
},
|
|
59
28
|
},
|
|
60
29
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
2
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
3
2
|
import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
|
|
4
3
|
import type { IReactionDisposer } from "mobx";
|
|
@@ -6,7 +5,7 @@ import type { IReactionDisposer } from "mobx";
|
|
|
6
5
|
import type { Assign } from "../../../types/Assign";
|
|
7
6
|
import type { ComputeObject } from "../../../types/ComputeObj";
|
|
8
7
|
import type { WMComponentInstance, WMInstanceMethods, WMPageInstance } from "../../../types/OfficialTypeAlias";
|
|
9
|
-
import type {
|
|
8
|
+
import type { IInjectAllData, IInjectMethods } from "../../InstanceInject/instanceConfig";
|
|
10
9
|
import type { CustomEventMethods } from "./CustomEventMethods";
|
|
11
10
|
import type { CustomSetData } from "./CustomSetData";
|
|
12
11
|
export type RootComponentInstance<
|
|
@@ -16,7 +15,7 @@ export type RootComponentInstance<
|
|
|
16
15
|
AllData extends object,
|
|
17
16
|
CustomEventsDoc extends object,
|
|
18
17
|
StoreDoc extends object,
|
|
19
|
-
instanceData = ComputeObject<Assign<
|
|
18
|
+
instanceData = ComputeObject<Assign<IInjectAllData, ComputeIntersection<AllData>>>,
|
|
20
19
|
> =
|
|
21
20
|
// 官方实例属性is options dataset等
|
|
22
21
|
& IfExtends<false, TIsPage, WMComponentInstance, WMPageInstance>
|
|
@@ -28,8 +27,8 @@ export type RootComponentInstance<
|
|
|
28
27
|
disposer: { [k in keyof StoreDoc]: IReactionDisposer };
|
|
29
28
|
}>
|
|
30
29
|
& Assign<IInjectMethods, TMethods & CustomEventMethods<CustomEventsDoc>>
|
|
31
|
-
& { data:
|
|
32
|
-
|
|
30
|
+
& { data: instanceData };
|
|
31
|
+
// & { cloneData: ComputeObject<Assign<IInjectData, ComputeIntersection<AllData>>> };
|
|
33
32
|
|
|
34
33
|
export type ComponentInstance = RootComponentInstance<false, {}, {}, {}, {}, {}>;
|
|
35
34
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
|
|
3
3
|
import { type DetailedType, RootComponent } from "../../../../..";
|
|
4
|
-
import type {
|
|
4
|
+
import type { IInjectAllData } from "../../../../InstanceInject/instanceConfig";
|
|
5
5
|
|
|
6
6
|
// 组件时
|
|
7
7
|
RootComponent()({
|
|
@@ -17,7 +17,12 @@ RootComponent()({
|
|
|
17
17
|
// 组件实例对象格外添加null类型
|
|
18
18
|
Checking<
|
|
19
19
|
typeof this.data,
|
|
20
|
-
|
|
20
|
+
ComputeIntersection<
|
|
21
|
+
{
|
|
22
|
+
optionalObj: { name: string } | null;
|
|
23
|
+
obj: object | null;
|
|
24
|
+
} & IInjectAllData
|
|
25
|
+
>,
|
|
21
26
|
Test.Pass
|
|
22
27
|
>;
|
|
23
28
|
},
|
|
@@ -44,7 +49,7 @@ RootComponent()({
|
|
|
44
49
|
}, Test.Pass>;
|
|
45
50
|
|
|
46
51
|
// 页面实例对象不额外添加null
|
|
47
|
-
Checking<typeof this.data.optionalObj,
|
|
52
|
+
Checking<typeof this.data.optionalObj, { name: string }, Test.Pass>;
|
|
48
53
|
|
|
49
54
|
// 页面实例对象不额外添加null
|
|
50
55
|
Checking<typeof this.data.obj, object, Test.Pass>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
2
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
3
2
|
import type { IsPureObject } from "hry-types/src/Any/IsPureObject";
|
|
4
3
|
import type { NoInfer } from "hry-types/src/Generic/NoInfer";
|
|
@@ -20,15 +19,13 @@ type AddFieldsOfObject<
|
|
|
20
19
|
> = {
|
|
21
20
|
[k in secondKeys]?: (
|
|
22
21
|
// @ts-ignore
|
|
23
|
-
newValue:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
NonNullable<(Exclude<TWatchData[getFirstKeys<k>], null>)[getLastKeys<k>]>
|
|
31
|
-
>
|
|
22
|
+
newValue: IfExtends<
|
|
23
|
+
getLastKeys<k>,
|
|
24
|
+
"**",
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
TWatchData[getFirstKeys<k>],
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
NonNullable<(Exclude<TWatchData[getFirstKeys<k>], null>)[getLastKeys<k>]>
|
|
32
29
|
>,
|
|
33
30
|
) => void;
|
|
34
31
|
};
|
|
@@ -46,7 +43,7 @@ export type ObserversOption<TWatchData extends object, _WatchKeys extends keyof
|
|
|
46
43
|
NoInfer<
|
|
47
44
|
& {
|
|
48
45
|
[k in _WatchKeys | "**"]?: (
|
|
49
|
-
newValue: k extends keyof TWatchData ?
|
|
46
|
+
newValue: k extends keyof TWatchData ? TWatchData[k] : unknown,
|
|
50
47
|
) => void;
|
|
51
48
|
}
|
|
52
49
|
// 解决单独书写计算书写字段的报错(或许是:ts字面量约束检测提前计算属性key引起的错误提示)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
|
-
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
3
2
|
|
|
4
3
|
import type { User } from "../../../../../jest/common";
|
|
5
4
|
import { RootComponent } from "../..";
|
|
@@ -10,10 +9,10 @@ RootComponent()({
|
|
|
10
9
|
},
|
|
11
10
|
observers: {
|
|
12
11
|
obj(a) {
|
|
13
|
-
Checking<typeof a,
|
|
12
|
+
Checking<typeof a, User | null, Test.Pass>;
|
|
14
13
|
},
|
|
15
14
|
"obj.**"(a) {
|
|
16
|
-
Checking<typeof a,
|
|
15
|
+
Checking<typeof a, User | null, Test.Pass>;
|
|
17
16
|
},
|
|
18
17
|
"obj.age"(a) {
|
|
19
18
|
Checking<typeof a, number, Test.Pass>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
|
-
import type {
|
|
3
|
-
import type { IInjectData } from "../../../InstanceInject/instanceConfig";
|
|
2
|
+
import type { IInjectAllData } from "../../../InstanceInject/instanceConfig";
|
|
4
3
|
import { RootComponent } from "../..";
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -10,8 +9,8 @@ const emptyObj = RootComponent()({
|
|
|
10
9
|
properties: {},
|
|
11
10
|
methods: {
|
|
12
11
|
foo() {
|
|
13
|
-
// 1 this.data
|
|
14
|
-
Checking<typeof this.data,
|
|
12
|
+
// 1 this.data 为注入数据类型
|
|
13
|
+
Checking<typeof this.data, IInjectAllData, Test.Pass>;
|
|
15
14
|
},
|
|
16
15
|
},
|
|
17
16
|
});
|
|
@@ -29,8 +28,8 @@ Checking<typeof emptyObj, {
|
|
|
29
28
|
const noProperties = RootComponent()({
|
|
30
29
|
methods: {
|
|
31
30
|
foo() {
|
|
32
|
-
// 3 this.data
|
|
33
|
-
Checking<typeof this.data,
|
|
31
|
+
// 3 this.data 为注入数据类型
|
|
32
|
+
Checking<typeof this.data, IInjectAllData, Test.Pass>;
|
|
34
33
|
},
|
|
35
34
|
},
|
|
36
35
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ComputeIntersection } from "hry-types/src/Object/_api";
|
|
3
3
|
import type { DetailedType } from "../../../../types/DetailedType";
|
|
4
|
-
import type {
|
|
4
|
+
import type { IInjectAllData } from "../../../InstanceInject/instanceConfig";
|
|
5
5
|
import { RootComponent } from "../..";
|
|
6
6
|
import { type Mock_User } from "./normalRequired.test";
|
|
7
7
|
|
|
@@ -48,7 +48,7 @@ const OptionalDoc = RootComponent()({
|
|
|
48
48
|
// 1. 内部this.data中的类型(去除可选)
|
|
49
49
|
Checking<
|
|
50
50
|
typeof this.data,
|
|
51
|
-
|
|
51
|
+
ComputeIntersection<
|
|
52
52
|
{
|
|
53
53
|
optional_num: number;
|
|
54
54
|
optional_gender: "male" | "female";
|
|
@@ -57,7 +57,7 @@ const OptionalDoc = RootComponent()({
|
|
|
57
57
|
optional_objOrNull: Mock_User | null;
|
|
58
58
|
optional_union: string | number;
|
|
59
59
|
optional_arr: string[];
|
|
60
|
-
} &
|
|
60
|
+
} & IInjectAllData
|
|
61
61
|
>,
|
|
62
62
|
Test.Pass
|
|
63
63
|
>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
|
+
import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
|
|
2
3
|
import type { DetailedType } from "../../../../types/DetailedType";
|
|
3
|
-
|
|
4
|
-
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
5
|
-
import type { IInjectData } from "../../../InstanceInject/instanceConfig";
|
|
4
|
+
import type { IInjectAllData } from "../../../InstanceInject/instanceConfig";
|
|
6
5
|
import { RootComponent } from "../..";
|
|
7
6
|
import type { RequiredSingle, RequiredType, RequiredUnion } from "../PropertiesConstraint";
|
|
8
7
|
|
|
@@ -92,10 +91,11 @@ const RequiredDoc = RootComponent()({
|
|
|
92
91
|
methods: {
|
|
93
92
|
foo() {
|
|
94
93
|
// 1 this.data中的类型(对象类型加null)
|
|
95
|
-
Checking<typeof this.data,
|
|
94
|
+
Checking<typeof this.data, ComputeIntersection<RequiredTypeExpected & IInjectAllData>, Test.Pass>;
|
|
96
95
|
},
|
|
97
96
|
},
|
|
98
97
|
});
|
|
98
|
+
|
|
99
99
|
/**
|
|
100
100
|
* 2 properties配置为必传类型时预期文档类型(与this.data一致)
|
|
101
101
|
*/
|