annil 1.0.7 → 1.0.8
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/ReturnType/CreateComponentDoc.d.ts +2 -2
- package/dist/api/DefineComponent/ReturnType/CreatePageDoc.d.ts +2 -2
- package/dist/api/RootComponent/Properties/GetOptionalDoc.d.ts +3 -4
- package/dist/api/RootComponent/Properties/GetPropertiesDoc.d.ts +3 -4
- package/dist/api/RootComponent/Properties/GetRequiredDoc.d.ts +3 -4
- package/dist/api/RootComponent/Store/test/normal.test.js +3 -1
- package/dist/api/RootComponent/Store/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/index.d.ts +5 -4
- package/dist/api/RootComponent/index.js.map +1 -1
- package/dist/api/SubComponent/SubData/test/normal.test.js.map +1 -1
- package/dist/api/SubComponent/index.d.ts +2 -2
- package/dist/index.d.ts +4 -3
- package/dist/index.js.map +1 -1
- package/dist/types/ComponentDocExtension.d.ts +7 -0
- package/dist/types/ComponentDocExtension.js +2 -0
- package/dist/types/ComponentDocExtension.js.map +1 -0
- package/dist/types/ComputeObj.d.ts +3 -0
- package/dist/types/ComputeObj.js +2 -0
- package/dist/types/ComputeObj.js.map +1 -0
- package/dist/types/GetComponentPrefix.d.ts +2 -1
- package/package.json +1 -1
- package/src/api/DefineComponent/ReturnType/CreateComponentDoc.ts +2 -2
- package/src/api/DefineComponent/ReturnType/CreatePageDoc.ts +2 -2
- package/src/api/RootComponent/CustomEvents/GetCustomEventDoc.ts +0 -2
- package/src/api/RootComponent/Properties/GetOptionalDoc.ts +10 -11
- package/src/api/RootComponent/Properties/GetPropertiesDoc.ts +6 -16
- package/src/api/RootComponent/Properties/GetRequiredDoc.ts +25 -15
- package/src/api/RootComponent/Store/test/normal.test.ts +11 -1
- package/src/api/RootComponent/index.ts +6 -5
- package/src/api/SubComponent/SubData/test/normal.test.ts +5 -2
- package/src/api/SubComponent/index.ts +2 -2
- package/src/index.ts +5 -4
- package/src/types/ComponentDocExtension.ts +36 -0
- package/src/types/ComputeObj.ts +1 -0
- package/src/types/GetComponentPrefix.ts +15 -13
- package/dist/types/CompDocExtends.d.ts +0 -8
- package/dist/types/CompDocExtends.js +0 -2
- package/dist/types/CompDocExtends.js.map +0 -1
- package/dist/types/Drop.d.ts +0 -2
- package/dist/types/Drop.js +0 -2
- package/dist/types/Drop.js.map +0 -1
- package/dist/types/DropStr.d.ts +0 -1
- package/dist/types/DropStr.js +0 -2
- package/dist/types/DropStr.js.map +0 -1
- package/dist/types/RestorePropertiesDoc.d.ts +0 -0
- package/dist/types/RestorePropertiesDoc.js +0 -2
- package/dist/types/RestorePropertiesDoc.js.map +0 -1
- package/src/types/CompDocExtends.ts +0 -14
- package/src/types/Drop.ts +0 -18
- package/src/types/DropStr.ts +0 -5
- package/src/types/RestorePropertiesDoc.ts +0 -26
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.0.8](https://github.com/missannil/annil/compare/v1.0.7...v1.0.8) (2023-12-03)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* 组件类型中别名被解析的问题 ([67e4886](https://github.com/missannil/annil/commit/67e48868b55853c41f5ad4c713dab12e31380f64))
|
|
13
|
+
|
|
7
14
|
## [1.0.7](https://github.com/missannil/annil/compare/v1.0.6...v1.0.7) (2023-12-02)
|
|
8
15
|
|
|
9
16
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
|
|
3
3
|
import type { AddNullForObject } from "../../../types/AddNullForObject";
|
|
4
4
|
import type { RootComponentDoc } from "../../RootComponent/RootComponentDoc";
|
|
5
5
|
import type { SubComponentDoc } from "../../SubComponent/SubComponentDoc";
|
|
@@ -7,7 +7,7 @@ import type { GetCustomEventDocOfSubDoc } from "./GetCustomEventDocOfSubDoc";
|
|
|
7
7
|
type GetStopKeys<O> = {
|
|
8
8
|
[k in keyof O]: k extends `${string}_${infer Key}_${string}_catch` ? Key : never;
|
|
9
9
|
}[keyof O];
|
|
10
|
-
export type CreateComponentDoc<TRootDoc extends RootComponentDoc, TName extends string, TSubComponentTuple extends SubComponentDoc[], AllPropertiesDoc extends unknown | object = TRootDoc["properties"], AllCustomEventsDoc extends unknown | object = TRootDoc["customEvents"] & GetCustomEventDocOfSubDoc<TSubComponentTuple[number]>, StopKeys extends string = GetStopKeys<TRootDoc["events"]>, FinalCustomEventDoc extends object = Omit<AllCustomEventsDoc, StopKeys>> =
|
|
10
|
+
export type CreateComponentDoc<TRootDoc extends RootComponentDoc, TName extends string, TSubComponentTuple extends SubComponentDoc[], AllPropertiesDoc extends unknown | object = TRootDoc["properties"], AllCustomEventsDoc extends unknown | object = TRootDoc["customEvents"] & GetCustomEventDocOfSubDoc<TSubComponentTuple[number]>, StopKeys extends string = GetStopKeys<TRootDoc["events"]>, FinalCustomEventDoc extends object = Omit<AllCustomEventsDoc, StopKeys>> = ComputeIntersection<IfExtends<unknown, AllPropertiesDoc, {}, {
|
|
11
11
|
properties: {
|
|
12
12
|
[k in keyof AllPropertiesDoc as `${TName}_${k & string}`]: AddNullForObject<AllPropertiesDoc[k]>;
|
|
13
13
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
|
|
3
3
|
import type { RootComponentDoc } from "../../RootComponent/RootComponentDoc";
|
|
4
|
-
export type CreatePageDoc<TRootDoc extends RootComponentDoc, TPath extends string> =
|
|
4
|
+
export type CreatePageDoc<TRootDoc extends RootComponentDoc, TPath extends string> = ComputeIntersection<{
|
|
5
5
|
path: TPath;
|
|
6
6
|
} & IfExtends<unknown, TRootDoc["properties"], unknown, {
|
|
7
7
|
properties: TRootDoc["properties"];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
|
-
import type { Select } from "hry-types/src/Object/Select";
|
|
3
2
|
import type { AddNullForObject } from "../../../types/AddNullForObject";
|
|
4
3
|
import type { InferDetailedType } from "../../../types/InferDetailedType";
|
|
5
|
-
import type { OptionalType
|
|
6
|
-
export type GetOptionalDoc<
|
|
7
|
-
[k in keyof
|
|
4
|
+
import type { OptionalType } from "./PropertiesConstraint";
|
|
5
|
+
export type GetOptionalDoc<TOptionalProperties extends Record<string, OptionalType>, TIsPage extends boolean> = {
|
|
6
|
+
-readonly [k in keyof TOptionalProperties]?: IfExtends<unknown, TOptionalProperties[k]["optionalTypes"], IfExtends<false, TIsPage, AddNullForObject<InferDetailedType<TOptionalProperties[k]["type"]>>, InferDetailedType<TOptionalProperties[k]["type"]>>, IfExtends<false, TIsPage, AddNullForObject<InferDetailedType<TOptionalProperties[k]["type"]> | InferDetailedType<(TOptionalProperties[k]["optionalTypes"] & {})[number]>>, InferDetailedType<TOptionalProperties[k]["type"]> | InferDetailedType<(TOptionalProperties[k]["optionalTypes"] & {})[number]>>>;
|
|
8
7
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
1
|
import type { Select } from "hry-types/src/Object/Select";
|
|
3
|
-
import type { ComputeIntersection
|
|
2
|
+
import type { ComputeIntersection } from "hry-types/src/Object/_api";
|
|
4
3
|
import type { GetOptionalDoc } from "./GetOptionalDoc";
|
|
5
4
|
import type { GetRequiredDoc } from "./GetRequiredDoc";
|
|
6
5
|
import type { OptionalType, PropertiesConstraint } from "./PropertiesConstraint";
|
|
7
|
-
type _GetPropertiesDoc<TProperties extends PropertiesConstraint, TIsPage extends boolean,
|
|
8
|
-
export type GetPropertiesDoc<TProperties extends PropertiesConstraint, TisPage extends boolean
|
|
6
|
+
type _GetPropertiesDoc<TProperties extends PropertiesConstraint, TIsPage extends boolean, OptionalDoc extends object = GetOptionalDoc<Select<TProperties, OptionalType>, TIsPage>, RequiredDoc extends object = GetRequiredDoc<Omit<TProperties, keyof OptionalDoc>, TIsPage>> = ComputeIntersection<OptionalDoc & RequiredDoc>;
|
|
7
|
+
export type GetPropertiesDoc<TProperties extends PropertiesConstraint, TisPage extends boolean> = _GetPropertiesDoc<TProperties, TisPage>;
|
|
9
8
|
export {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
|
-
import type { Select } from "hry-types/src/Object/Select";
|
|
3
2
|
import type { AddNullForObject } from "../../../types/AddNullForObject";
|
|
4
3
|
import type { InferDetailedType } from "../../../types/InferDetailedType";
|
|
5
|
-
import type {
|
|
6
|
-
export type GetRequiredDoc<TProperties extends
|
|
7
|
-
[k in keyof
|
|
4
|
+
import type { RequiredSingle, RequiredType } from "./PropertiesConstraint";
|
|
5
|
+
export type GetRequiredDoc<TProperties extends Record<string, RequiredType>, TIsPage extends boolean> = {
|
|
6
|
+
-readonly [k in keyof TProperties]: IfExtends<TProperties[k], RequiredSingle, IfExtends<false, TIsPage, AddNullForObject<InferDetailedType<TProperties[k]>>, InferDetailedType<TProperties[k]>>, IfExtends<false, TIsPage, AddNullForObject<InferDetailedType<TProperties[k]["type"]> | InferDetailedType<TProperties[k]["optionalTypes"][number]>>, InferDetailedType<TProperties[k]["type"]> | InferDetailedType<TProperties[k]["optionalTypes"][number]>>>;
|
|
8
7
|
};
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { Checking } from "hry-types";
|
|
1
2
|
import { observable } from "mobx";
|
|
2
3
|
import { RootComponent } from "../..";
|
|
3
4
|
const user = observable({
|
|
4
5
|
name: "zhao",
|
|
5
6
|
age: 20,
|
|
6
7
|
});
|
|
7
|
-
RootComponent()({
|
|
8
|
+
const storeDoc = RootComponent()({
|
|
8
9
|
store: {
|
|
9
10
|
userName: () => user.name,
|
|
10
11
|
userAge: () => user.age,
|
|
11
12
|
},
|
|
12
13
|
});
|
|
14
|
+
Checking;
|
|
13
15
|
//# sourceMappingURL=normal.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normal.test.js","sourceRoot":"","sources":["../../../../../src/api/RootComponent/Store/test/normal.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,MAAM,IAAI,GAAG,UAAU,CAAC;IACtB,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,EAAE;CACR,CAAC,CAAC;AAEH,aAAa,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"normal.test.js","sourceRoot":"","sources":["../../../../../src/api/RootComponent/Store/test/normal.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,MAAM,IAAI,GAAG,UAAU,CAAC;IACtB,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,EAAE;CACR,CAAC,CAAC;AAEH,MAAM,QAAQ,GAAG,aAAa,EAAE,CAAC;IAC/B,KAAK,EAAE;QACL,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI;QACzB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG;KACxB;CACF,CAAC,CAAC;AASH,QAAsD,CAAC"}
|
|
@@ -2,7 +2,8 @@ import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
|
2
2
|
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
|
-
import type {
|
|
5
|
+
import type { ComputeIntersection } from "hry-types/src/Object/_api";
|
|
6
|
+
import type { ComputeObject } from "../../types/ComputeObj";
|
|
6
7
|
import type { WMCompOtherOption, WMCompPageLifetimes, WMPageLifetimes } from "../../types/OfficialTypeAlias";
|
|
7
8
|
import type { ComponentDoc } from "../DefineComponent/ReturnType/ComponentDoc";
|
|
8
9
|
import type { ComputedConstraint } from "./Computed/ComputedConstraint";
|
|
@@ -31,14 +32,14 @@ import type { StoreOption } from "./Store/StoreOption";
|
|
|
31
32
|
import type { WatchOption } from "./Watch/WatchOption";
|
|
32
33
|
type RootComponentOptions<TReceivedComponentDoc extends object, 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> & CustomEventsOption<TCustomEvents, EventsDoc> & EventsOption<TEvents, EventsConstraint<TReceivedComponentDoc>> & DataOption<TData, PropertiesDoc> & StoreOption<TStore, PropertiesDoc & DataDoc> & ComputedOption<TComputed, Required<PropertiesDoc> & DataDoc & StoreDoc> & PageLifetimesOption<TIsPage, NoInfer<PropertiesDoc>> & LifetimesOption<TIsPage> & WatchOption<ComputedDoc & Required<PropertiesDoc> & DataDoc & StoreDoc> & Partial<Omit<WMCompOtherOption, "pageLifetimes">> & ThisType<RootComponentInstance<TIsPage, TMethods, DataDoc, DataDoc & Required<PropertiesDoc> & StoreDoc & ComputedDoc, CustomEventsDoc, StoreDoc>>;
|
|
33
34
|
type RootComponentConstructor<TReceivedComponentDoc extends ComponentDoc[] | ComponentDoc> = {
|
|
34
|
-
<TEvents extends EventsConstraint<TReceivedComponentDoc>, 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<TReceivedComponentDoc>, 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<TReceivedComponentDoc, TEvents, TIsPage, TCustomEvents, TMethods, TProperties, TData, TStore, TComputed, EventsDoc, CustomEventsDoc, PropertiesDoc, DataDoc, StoreDoc, ComputedDoc>):
|
|
35
|
+
<TEvents extends EventsConstraint<TReceivedComponentDoc>, 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<TReceivedComponentDoc>, 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<TReceivedComponentDoc, TEvents, TIsPage, TCustomEvents, TMethods, TProperties, TData, TStore, TComputed, EventsDoc, CustomEventsDoc, PropertiesDoc, DataDoc, StoreDoc, ComputedDoc>): ComputeIntersection<IfExtends<TIsPage, false, {}, {
|
|
35
36
|
isPage: true;
|
|
36
37
|
}> & IfExtends<EmptyObject, PropertiesDoc, {}, {
|
|
37
38
|
properties: PropertiesDoc;
|
|
38
39
|
}> & IfExtends<EmptyObject, DataDoc, {}, {
|
|
39
40
|
data: DataDoc;
|
|
40
41
|
}> & IfExtends<EmptyObject, StoreDoc, {}, {
|
|
41
|
-
store: StoreDoc
|
|
42
|
+
store: ComputeObject<StoreDoc>;
|
|
42
43
|
}> & IfExtends<EmptyObject, ComputedDoc, {}, {
|
|
43
44
|
computed: ComputedDoc;
|
|
44
45
|
}> & IfExtends<EmptyObject, TMethods, {}, {
|
|
@@ -46,7 +47,7 @@ type RootComponentConstructor<TReceivedComponentDoc extends ComponentDoc[] | Com
|
|
|
46
47
|
}> & IfExtends<EmptyObject, EventsDoc, {}, {
|
|
47
48
|
events: EventsDoc;
|
|
48
49
|
}> & IfExtends<EmptyObject, CustomEventsDoc, {}, {
|
|
49
|
-
customEvents: CustomEventsDoc
|
|
50
|
+
customEvents: ComputeObject<CustomEventsDoc>;
|
|
50
51
|
}>>;
|
|
51
52
|
};
|
|
52
53
|
export declare function RootComponent<TReceivedComponentDoc extends ComponentDoc[] | ComponentDoc = {}>(): RootComponentConstructor<TReceivedComponentDoc>;
|
|
@@ -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":"AA+HA,MAAM,UAAU,aAAa;IAM3B,OAAO,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,OAAmC,CAAQ,CAAC;AACxE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normal.test.js","sourceRoot":"","sources":["../../../../../src/api/SubComponent/SubData/test/normal.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,MAAM,WAAW,CAAC;AAOhD,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAWrC,YAAY,EAAe,CAAC;IAC1B,OAAO,EAAE;QACP,OAAO,EAAE,MAAM;KAChB;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,GAAG;QACZ,OAAO,EAAE,GAAG;QACZ,aAAa,EAAE,UAAU;KAC1B;CACF,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"normal.test.js","sourceRoot":"","sources":["../../../../../src/api/SubComponent/SubData/test/normal.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,MAAM,WAAW,CAAC;AAOhD,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAWrC,YAAY,EAAe,CAAC;IAC1B,OAAO,EAAE;QACP,OAAO,EAAE,MAAM;KAChB;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,GAAG;QACZ,OAAO,EAAE,GAAG;QACZ,aAAa,EAAE,UAAU;KAC1B;CACF,CAAC,CAAC;AAQH,MAAM,GAAG,GAAG,YAAY,EAAmB,CAAC;IAC1C,OAAO,EAAE;QACP,UAAU,EAAE,MAAM;KACnB;IACD,IAAI,EAAE;QAEJ,UAAU,EAAE,QAAQ;QACpB,gBAAgB,EAAE,MAAM;QAExB,QAAQ,EAAE,EAAsB;QAChC,QAAQ,EAAE,GAAG;QACb,QAAQ,EAAE,GAAG;KACd;CACF,CAAC,CAAC;AAEH,QAAsC,CAAC;AAGvC,YAAY,EAAe,CAAC;IAC1B,OAAO,EAAE;QACP,OAAO,EAAE,MAAM;QACf,OAAO,EAAE,MAAM;QACf,OAAO,EAAE,MAAM;KAChB;IACD,IAAI,EAAE;QACJ,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC,CAAC;AAMH,MAAM,IAAI,GAAG,YAAY,EAAoB,CAAC,EAAE,CAAC,CAAC;AAElD,QAAuC,CAAC;AAExC,YAAY,EAAe,CAAC;IAC1B,IAAI,EAAE;QACJ,OAAO,EAAE,GAAG;QACZ,OAAO,EAAE,GAAG;QACZ,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,KAAK;KAChB;IACD,OAAO,EAAE;QACP,KAAK;YAEH,QASC,CAAC;QACJ,CAAC;KACF;CACF,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
2
|
import type { EmptyObject } from "hry-types/src/Misc/EmptyObject";
|
|
3
3
|
import type { RequiredKeys } from "hry-types/src/Object/RequiredKeys";
|
|
4
|
-
import type {
|
|
4
|
+
import type { GetComponentPrefix } from "../../types/GetComponentPrefix";
|
|
5
5
|
import type { ReplacePrefix } from "../../types/ReplacePrefix";
|
|
6
6
|
import type { ComponentDoc } from "../DefineComponent/ReturnType/ComponentDoc";
|
|
7
7
|
import type { Func } from "hry-types/src/Misc/Func";
|
|
@@ -27,7 +27,7 @@ import type { SubWatchOption } from "./SubWatch/SubWatchOption";
|
|
|
27
27
|
type Options<RootDoc extends RootComponentDoc, IsPage extends boolean, CurrentCompDoc extends ComponentDoc, Prefix extends string, AllRootDataDoc extends object, TInherit extends object, TSubData extends object, TSubStore extends object, TSubComputed extends object, TEvents extends object, TSubMethods extends object, InheritDoc extends object, SubDataDoc extends object, SubStoreDoc extends object, SubComputedDoc extends object, SubEventsDoc extends object, SubMethodsDoc extends object> = {
|
|
28
28
|
inherit?: TInherit;
|
|
29
29
|
} & SubDataOption<TSubData, Exclude<keyof CurrentCompDoc["properties"], (keyof InheritDoc)>, Prefix> & SubStoreOption<TSubStore, Exclude<keyof CurrentCompDoc["properties"], (keyof (InheritDoc & SubDataDoc))>, Prefix> & SubComputedOption<TSubComputed, Omit<CurrentCompDoc["properties"], (keyof (InheritDoc & SubDataDoc & SubStoreDoc))>> & SubEventsOption<TEvents, SubEventsDoc, keyof SubEventsConstraint<CurrentCompDoc>> & SubMethodsOption<TSubMethods, Prefix, keyof CurrentCompDoc["customEvents"]> & SubPageLifetimesOption<IsPage, RootDoc["properties"] & {}> & SubLifetimesOption & SubWatchOption<SubComputedDoc & SubDataDoc & AllRootDataDoc & SubStoreDoc> & Partial<Omit<WMCompOtherOption, "pageLifetimes">> & ThisType<SubInstance<SubMethodsDoc & RootDoc["methods"], TSubData, AllRootDataDoc & SubDataDoc & SubComputedDoc & SubStoreDoc, RootDoc["customEvents"] & {}, SubStoreDoc>>;
|
|
30
|
-
type SubComponentConstructor<TRootDoc extends RootComponentDoc, TOriginalCompDoc extends ComponentDoc, TSupplementalPrefix extends string = "", IsPage extends boolean = TRootDoc["isPage"] extends true ? true : false, CurrentPrefix extends string = `${
|
|
30
|
+
type SubComponentConstructor<TRootDoc extends RootComponentDoc, TOriginalCompDoc extends ComponentDoc, TSupplementalPrefix extends string = "", IsPage extends boolean = TRootDoc["isPage"] extends true ? true : false, CurrentPrefix extends string = `${GetComponentPrefix<TOriginalCompDoc>}${Capitalize<TSupplementalPrefix>}`, CurrentCompDoc extends ComponentDoc = IfExtends<TSupplementalPrefix, "", TOriginalCompDoc, ReplacePrefix<TOriginalCompDoc, CurrentPrefix>>, AllRootDataDoc extends object = Required<TRootDoc["properties"]> & TRootDoc["data"] & TRootDoc["computed"] & TRootDoc["store"]> = {
|
|
31
31
|
<TInherit extends InheritConstraint<AllRootDataDoc, CurrentCompDoc>, TSubData extends SubDataConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof InheritDoc>>, TSubStore extends SubStoreConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc)>>, TEvents extends SubEventsConstraint<CurrentCompDoc>, TSubComputed extends SubComputedConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc & SubStoreDoc)>>, TSubMethods extends SubMethodsConstraint = {}, InheritDoc extends object = IfExtends<InheritConstraint<AllRootDataDoc, CurrentCompDoc>, TInherit, {}, TInherit>, SubDataDoc extends object = IfExtends<SubDataConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof InheritDoc>>, TSubData, {}, TSubData>, SubStoreDoc extends object = IfExtends<SubStoreConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc)>>, TSubStore, {}, {
|
|
32
32
|
[k in keyof TSubStore]: ReturnType<TSubStore[k] & {}>;
|
|
33
33
|
}>, SubComputedDoc extends object = IfExtends<SubComputedConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc & SubStoreDoc)>>, TSubComputed, {}, GetSubComputedDoc<TSubComputed>>, SubEventsDoc extends object = IfExtends<SubEventsConstraint<CurrentCompDoc>, TEvents, {}, TEvents>, SubMethodsDoc extends object = TSubMethods, MissingRequiredField extends PropertyKey = Exclude<RequiredKeys<CurrentCompDoc["properties"] & {}>, keyof (InheritDoc & SubDataDoc & SubStoreDoc & IfExtends<SubComputedConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc & SubStoreDoc)>>, TSubComputed, {}, GetSubComputedDoc<TSubComputed>>)>>(options: Options<TRootDoc, IsPage, CurrentCompDoc, CurrentPrefix, AllRootDataDoc, TInherit, TSubData, TSubStore, TSubComputed, TEvents, TSubMethods, InheritDoc, SubDataDoc, SubStoreDoc, SubComputedDoc, SubEventsDoc, SubMethodsDoc>): CreateSubComponentDoc<TOriginalCompDoc["customEvents"] & {}, SubEventsDoc, MissingRequiredField>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export type { Vant, Wm } from "./thirdLib";
|
|
2
|
-
export type { Dataset, Detail, WMBaseEvent, WMCustomEvent } from "./types/OfficialTypeAlias";
|
|
3
1
|
import { navigateTo } from "./api/navigateTo";
|
|
4
2
|
import { DefineComponent } from "./api/DefineComponent";
|
|
5
3
|
import { RootComponent } from "./api/RootComponent";
|
|
6
4
|
import { SubComponent } from "./api/SubComponent";
|
|
7
5
|
import type { DetailedType } from "./types/DetailedType";
|
|
6
|
+
import type { ComponentDocExtension } from "./types/ComponentDocExtension";
|
|
8
7
|
import type { GenerateDoc } from "./types/GenerateDoc";
|
|
9
8
|
import type { ParamsEqual } from "./types/TwoParamsEqual";
|
|
10
|
-
export
|
|
9
|
+
export type { Vant, Wm } from "./thirdLib";
|
|
10
|
+
export type { Dataset, Detail, WMBaseEvent, WMCustomEvent } from "./types/OfficialTypeAlias";
|
|
11
|
+
export { type ComponentDocExtension, DefineComponent, type DetailedType, type GenerateDoc, navigateTo, type ParamsEqual, RootComponent, SubComponent, };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAWlD,OAAO,EAEL,eAAe,EAGf,UAAU,EAEV,aAAa,EACb,YAAY,GACb,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
|
+
import type { ComputeIntersectionDeep } from "hry-types/src/Object/ComputeIntersectionDeep";
|
|
3
|
+
import type { ComponentDoc } from "../api/DefineComponent/ReturnType/ComponentDoc";
|
|
4
|
+
import type { GetComponentPrefix } from "./GetComponentPrefix";
|
|
5
|
+
type Validator<TOriginalComponentDoc extends ComponentDoc, TExtensionDoc extends ComponentDoc, TOriginalPrefix extends PropertyKey = GetComponentPrefix<TOriginalComponentDoc>, TExtenstionPrefix extends PropertyKey = GetComponentPrefix<TExtensionDoc>, DuplicateKeys extends PropertyKey = Extract<keyof TExtensionDoc["properties"], keyof TOriginalComponentDoc["properties"]> | Extract<keyof TExtensionDoc["customEvents"], keyof TOriginalComponentDoc["customEvents"]>> = IfExtends<TOriginalPrefix, TExtenstionPrefix, IfExtends<DuplicateKeys, never, ComponentDoc, `${DuplicateKeys & string}字段重复`>, `前缀错误,应为${TOriginalPrefix & string}`>;
|
|
6
|
+
export type ComponentDocExtension<TOriginalComponentDoc extends ComponentDoc, TExtensionDoc extends Validator<TOriginalComponentDoc, TExtensionDoc>> = ComputeIntersectionDeep<TOriginalComponentDoc & TExtensionDoc>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComponentDocExtension.js","sourceRoot":"","sources":["../../src/types/ComponentDocExtension.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComputeObj.js","sourceRoot":"","sources":["../../src/types/ComputeObj.ts"],"names":[],"mappings":""}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
|
+
import type { EmptyObject } from "hry-types/src/Misc/EmptyObject";
|
|
2
3
|
import type { ComponentDoc } from "../api/DefineComponent/ReturnType/ComponentDoc";
|
|
3
|
-
export type
|
|
4
|
+
export type GetComponentPrefix<TComponentDoc extends ComponentDoc> = EmptyObject extends TComponentDoc ? never : keyof IfExtends<unknown, TComponentDoc["properties"], TComponentDoc["customEvents"], TComponentDoc["properties"]> extends `${infer P}_${string}` ? P : never;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
|
|
3
3
|
import type { AddNullForObject } from "../../../types/AddNullForObject";
|
|
4
4
|
import type { RootComponentDoc } from "../../RootComponent/RootComponentDoc";
|
|
5
5
|
import type { SubComponentDoc } from "../../SubComponent/SubComponentDoc";
|
|
@@ -19,7 +19,7 @@ export type CreateComponentDoc<
|
|
|
19
19
|
& GetCustomEventDocOfSubDoc<TSubComponentTuple[number]>,
|
|
20
20
|
StopKeys extends string = GetStopKeys<TRootDoc["events"]>,
|
|
21
21
|
FinalCustomEventDoc extends object = Omit<AllCustomEventsDoc, StopKeys>,
|
|
22
|
-
> =
|
|
22
|
+
> = ComputeIntersection<
|
|
23
23
|
& IfExtends<
|
|
24
24
|
unknown,
|
|
25
25
|
AllPropertiesDoc,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
|
|
3
3
|
import type { RootComponentDoc } from "../../RootComponent/RootComponentDoc";
|
|
4
4
|
|
|
5
5
|
export type CreatePageDoc<
|
|
6
6
|
TRootDoc extends RootComponentDoc,
|
|
7
7
|
TPath extends string,
|
|
8
|
-
> =
|
|
8
|
+
> = ComputeIntersection<
|
|
9
9
|
& { path: TPath }
|
|
10
10
|
& IfExtends<
|
|
11
11
|
unknown,
|
|
@@ -1,38 +1,37 @@
|
|
|
1
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
|
-
import type { Select } from "hry-types/src/Object/Select";
|
|
3
2
|
import type { AddNullForObject } from "../../../types/AddNullForObject";
|
|
4
3
|
import type { InferDetailedType } from "../../../types/InferDetailedType";
|
|
5
|
-
import type { OptionalType
|
|
4
|
+
import type { OptionalType } from "./PropertiesConstraint";
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* 获取properties可传字段文档类型
|
|
9
8
|
*/
|
|
10
9
|
export type GetOptionalDoc<
|
|
11
|
-
|
|
10
|
+
TOptionalProperties extends Record<string, OptionalType>,
|
|
12
11
|
TIsPage extends boolean,
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
Optional extends Record<string, OptionalType> = Select<TProperties, OptionalType>,
|
|
15
12
|
> = {
|
|
16
|
-
[k in keyof
|
|
13
|
+
-readonly [k in keyof TOptionalProperties]?: IfExtends<
|
|
17
14
|
unknown,
|
|
18
|
-
|
|
15
|
+
TOptionalProperties[k]["optionalTypes"],
|
|
19
16
|
IfExtends<
|
|
20
17
|
false,
|
|
21
18
|
TIsPage,
|
|
22
19
|
// 组件时 对象加null
|
|
23
|
-
AddNullForObject<InferDetailedType<
|
|
20
|
+
AddNullForObject<InferDetailedType<TOptionalProperties[k]["type"]>>,
|
|
24
21
|
// 页面时 对象不加
|
|
25
|
-
InferDetailedType<
|
|
22
|
+
InferDetailedType<TOptionalProperties[k]["type"]>
|
|
26
23
|
>,
|
|
27
24
|
IfExtends<
|
|
28
25
|
false,
|
|
29
26
|
TIsPage,
|
|
30
27
|
// 组件时 对象加null
|
|
31
28
|
AddNullForObject<
|
|
32
|
-
|
|
29
|
+
| InferDetailedType<TOptionalProperties[k]["type"]>
|
|
30
|
+
| InferDetailedType<(TOptionalProperties[k]["optionalTypes"] & {})[number]>
|
|
33
31
|
>,
|
|
34
32
|
// 页面时 对象不加
|
|
35
|
-
|
|
33
|
+
| InferDetailedType<TOptionalProperties[k]["type"]>
|
|
34
|
+
| InferDetailedType<(TOptionalProperties[k]["optionalTypes"] & {})[number]>
|
|
36
35
|
>
|
|
37
36
|
>;
|
|
38
37
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
1
|
import type { Select } from "hry-types/src/Object/Select";
|
|
3
2
|
|
|
4
|
-
import type { ComputeIntersection
|
|
3
|
+
import type { ComputeIntersection } from "hry-types/src/Object/_api";
|
|
5
4
|
import type { GetOptionalDoc } from "./GetOptionalDoc";
|
|
6
5
|
import type { GetRequiredDoc } from "./GetRequiredDoc";
|
|
7
6
|
import type { OptionalType, PropertiesConstraint } from "./PropertiesConstraint";
|
|
@@ -9,25 +8,16 @@ import type { OptionalType, PropertiesConstraint } from "./PropertiesConstraint"
|
|
|
9
8
|
type _GetPropertiesDoc<
|
|
10
9
|
TProperties extends PropertiesConstraint,
|
|
11
10
|
TIsPage extends boolean,
|
|
12
|
-
Type extends "Required" | "Optional" | "all" = "all",
|
|
13
|
-
OptionalDoc = NonReadonlyDeep<GetOptionalDoc<Select<TProperties, OptionalType>, TIsPage>>,
|
|
14
|
-
RequiredDoc = NonReadonlyDeep<GetRequiredDoc<Omit<TProperties, keyof OptionalDoc>, TIsPage>>,
|
|
15
|
-
> = IfExtends<
|
|
16
|
-
Type,
|
|
17
|
-
"all",
|
|
18
11
|
// @ts-ignore
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
OptionalDoc extends object = GetOptionalDoc<Select<TProperties, OptionalType>, TIsPage>,
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
RequiredDoc extends object = GetRequiredDoc<Omit<TProperties, keyof OptionalDoc>, TIsPage>,
|
|
15
|
+
> = ComputeIntersection<OptionalDoc & RequiredDoc>;
|
|
22
16
|
|
|
23
17
|
/**
|
|
24
18
|
* properties字段的文档类型
|
|
25
|
-
* @param TProperties - `PropertiesConstraint`
|
|
26
|
-
* @param Type - "Required" | "Optional" | "all"
|
|
27
|
-
* @returns `GetRequiredDoc` | `GetOptionalDoc` | (`GetOptionalDoc` & `GetRequiredDoc`)
|
|
28
19
|
*/
|
|
29
20
|
export type GetPropertiesDoc<
|
|
30
21
|
TProperties extends PropertiesConstraint,
|
|
31
22
|
TisPage extends boolean,
|
|
32
|
-
|
|
33
|
-
> = _GetPropertiesDoc<TProperties, TisPage, Type>;
|
|
23
|
+
> = _GetPropertiesDoc<TProperties, TisPage>;
|
|
@@ -1,32 +1,42 @@
|
|
|
1
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
|
-
import type { Select } from "hry-types/src/Object/Select";
|
|
3
2
|
import type { AddNullForObject } from "../../../types/AddNullForObject";
|
|
4
3
|
import type { InferDetailedType } from "../../../types/InferDetailedType";
|
|
5
|
-
import type {
|
|
4
|
+
import type { RequiredSingle, RequiredType } from "./PropertiesConstraint";
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* 获取properties必传字段的文档类型
|
|
9
|
-
* @remarks 小程序中必传字段如果是object,默认类型为null
|
|
8
|
+
* @remarks 小程序中必传字段如果是object,默认类型为null,所以组件文档对象类型要联合上null类型
|
|
10
9
|
*/
|
|
11
10
|
export type GetRequiredDoc<
|
|
12
|
-
TProperties extends
|
|
11
|
+
TProperties extends Record<string, RequiredType>,
|
|
13
12
|
TIsPage extends boolean,
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
Required extends Record<string, RequiredType> = Select<TProperties, RequiredType>,
|
|
16
13
|
> = {
|
|
17
|
-
[k in keyof
|
|
18
|
-
|
|
14
|
+
-readonly [k in keyof TProperties]: IfExtends<
|
|
15
|
+
TProperties[k],
|
|
16
|
+
// 非对象写法
|
|
19
17
|
RequiredSingle,
|
|
20
|
-
IfExtends<false, TIsPage, AddNullForObject<InferDetailedType<Required[k]>>, InferDetailedType<Required[k]>>,
|
|
21
18
|
IfExtends<
|
|
22
19
|
false,
|
|
23
20
|
TIsPage,
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
// 组件的对象类型加null
|
|
22
|
+
AddNullForObject<InferDetailedType<TProperties[k]>>,
|
|
23
|
+
// 页面的对象类型不加null
|
|
24
|
+
InferDetailedType<TProperties[k]>
|
|
25
|
+
>,
|
|
26
|
+
// 对象写法 RequiredUnion
|
|
27
|
+
IfExtends<
|
|
28
|
+
false,
|
|
29
|
+
TIsPage,
|
|
30
|
+
// 组件的对象类型加null
|
|
31
|
+
AddNullForObject<
|
|
32
|
+
// @ts-ignore TProperties[k] 必为 RequiredUnion
|
|
33
|
+
| InferDetailedType<TProperties[k]["type"]>
|
|
34
|
+
// @ts-ignore TProperties[k] 必为 RequiredUnion
|
|
35
|
+
| InferDetailedType<TProperties[k]["optionalTypes"][number]>
|
|
36
|
+
>,
|
|
37
|
+
// 页面的对象类型不加null
|
|
38
|
+
// @ts-ignore TProperties[k] 必为 RequiredUnion
|
|
39
|
+
InferDetailedType<TProperties[k]["type"]> | InferDetailedType<TProperties[k]["optionalTypes"][number]>
|
|
30
40
|
>
|
|
31
41
|
>;
|
|
32
42
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Checking, type Test } from "hry-types";
|
|
1
2
|
import { observable } from "mobx";
|
|
2
3
|
import { RootComponent } from "../..";
|
|
3
4
|
const user = observable({
|
|
@@ -5,9 +6,18 @@ const user = observable({
|
|
|
5
6
|
age: 20,
|
|
6
7
|
});
|
|
7
8
|
|
|
8
|
-
RootComponent()({
|
|
9
|
+
const storeDoc = RootComponent()({
|
|
9
10
|
store: {
|
|
10
11
|
userName: () => user.name,
|
|
11
12
|
userAge: () => user.age,
|
|
12
13
|
},
|
|
13
14
|
});
|
|
15
|
+
|
|
16
|
+
type StoreDocExpected = {
|
|
17
|
+
store: {
|
|
18
|
+
userName: string;
|
|
19
|
+
userAge: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
Checking<typeof storeDoc, StoreDocExpected, Test.Pass>;
|
|
@@ -2,7 +2,8 @@ import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
|
2
2
|
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
|
-
import type {
|
|
5
|
+
import type { ComputeIntersection } from "hry-types/src/Object/_api";
|
|
6
|
+
import type { ComputeObject } from "../../types/ComputeObj";
|
|
6
7
|
import type { WMCompOtherOption, WMCompPageLifetimes, WMPageLifetimes } from "../../types/OfficialTypeAlias";
|
|
7
8
|
import type { ComponentDoc } from "../DefineComponent/ReturnType/ComponentDoc";
|
|
8
9
|
import type { ComputedConstraint } from "./Computed/ComputedConstraint";
|
|
@@ -111,16 +112,16 @@ type RootComponentConstructor<TReceivedComponentDoc extends ComponentDoc[] | Com
|
|
|
111
112
|
StoreDoc,
|
|
112
113
|
ComputedDoc
|
|
113
114
|
>,
|
|
114
|
-
): // 返回类型 RootComponentDoc
|
|
115
|
-
|
|
115
|
+
): // 返回类型 satisfies RootComponentDoc
|
|
116
|
+
ComputeIntersection<
|
|
116
117
|
& IfExtends<TIsPage, false, {}, { isPage: true }>
|
|
117
118
|
& IfExtends<EmptyObject, PropertiesDoc, {}, { properties: PropertiesDoc }>
|
|
118
119
|
& IfExtends<EmptyObject, DataDoc, {}, { data: DataDoc }>
|
|
119
|
-
& IfExtends<EmptyObject, StoreDoc, {}, { store: StoreDoc }>
|
|
120
|
+
& IfExtends<EmptyObject, StoreDoc, {}, { store: ComputeObject<StoreDoc> }>
|
|
120
121
|
& IfExtends<EmptyObject, ComputedDoc, {}, { computed: ComputedDoc }>
|
|
121
122
|
& IfExtends<EmptyObject, TMethods, {}, { methods: TMethods }>
|
|
122
123
|
& IfExtends<EmptyObject, EventsDoc, {}, { events: EventsDoc }>
|
|
123
|
-
& IfExtends<EmptyObject, CustomEventsDoc, {}, { customEvents: CustomEventsDoc }>
|
|
124
|
+
& IfExtends<EmptyObject, CustomEventsDoc, {}, { customEvents: ComputeObject<CustomEventsDoc> }>
|
|
124
125
|
>;
|
|
125
126
|
};
|
|
126
127
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
2
|
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
3
3
|
import type { Wm } from "../../../../thirdLib";
|
|
4
|
-
import type {
|
|
4
|
+
import type { ComponentDocExtension } from "../../../../types/ComponentDocExtension";
|
|
5
5
|
import type { ComponentDoc } from "../../../DefineComponent/ReturnType/ComponentDoc";
|
|
6
6
|
|
|
7
7
|
import type { Mock_User } from "../../../RootComponent/Properties/test/normalRequired.test";
|
|
@@ -28,7 +28,10 @@ SubComponent<{}, CompDoc>()({
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
// 2. 使用CompDocExtends泛型拓展组件文档,满足内部组件内部包含一些slot或基本组件数据
|
|
31
|
-
type viewExtends =
|
|
31
|
+
type viewExtends = ComponentDocExtension<
|
|
32
|
+
Wm.View,
|
|
33
|
+
{ properties: { view_obj: Mock_User | null; view_str: string; view_ddd: number } }
|
|
34
|
+
>;
|
|
32
35
|
|
|
33
36
|
const res = SubComponent<{}, viewExtends>()({
|
|
34
37
|
inherit: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
2
|
import type { EmptyObject } from "hry-types/src/Misc/EmptyObject";
|
|
3
3
|
import type { RequiredKeys } from "hry-types/src/Object/RequiredKeys";
|
|
4
|
-
import type {
|
|
4
|
+
import type { GetComponentPrefix } from "../../types/GetComponentPrefix";
|
|
5
5
|
import type { ReplacePrefix } from "../../types/ReplacePrefix";
|
|
6
6
|
import type { ComponentDoc } from "../DefineComponent/ReturnType/ComponentDoc";
|
|
7
7
|
|
|
@@ -95,7 +95,7 @@ type SubComponentConstructor<
|
|
|
95
95
|
TSupplementalPrefix extends string = "",
|
|
96
96
|
IsPage extends boolean = TRootDoc["isPage"] extends true ? true : false,
|
|
97
97
|
// 重构子组件的前缀
|
|
98
|
-
CurrentPrefix extends string = `${
|
|
98
|
+
CurrentPrefix extends string = `${GetComponentPrefix<TOriginalCompDoc>}${Capitalize<TSupplementalPrefix>}`,
|
|
99
99
|
// 更新原始文档的前缀为Prefix
|
|
100
100
|
CurrentCompDoc extends ComponentDoc = IfExtends<
|
|
101
101
|
TSupplementalPrefix,
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
export type { Vant, Wm } from "./thirdLib";
|
|
2
|
-
|
|
3
|
-
export type { Dataset, Detail, WMBaseEvent, WMCustomEvent } from "./types/OfficialTypeAlias";
|
|
4
|
-
|
|
5
1
|
import { navigateTo } from "./api/navigateTo";
|
|
6
2
|
|
|
7
3
|
import { DefineComponent } from "./api/DefineComponent";
|
|
@@ -12,10 +8,15 @@ import { SubComponent } from "./api/SubComponent";
|
|
|
12
8
|
|
|
13
9
|
import type { DetailedType } from "./types/DetailedType";
|
|
14
10
|
|
|
11
|
+
import type { ComponentDocExtension } from "./types/ComponentDocExtension";
|
|
15
12
|
import type { GenerateDoc } from "./types/GenerateDoc";
|
|
16
13
|
import type { ParamsEqual } from "./types/TwoParamsEqual";
|
|
14
|
+
export type { Vant, Wm } from "./thirdLib";
|
|
15
|
+
|
|
16
|
+
export type { Dataset, Detail, WMBaseEvent, WMCustomEvent } from "./types/OfficialTypeAlias";
|
|
17
17
|
|
|
18
18
|
export {
|
|
19
|
+
type ComponentDocExtension,
|
|
19
20
|
DefineComponent,
|
|
20
21
|
type DetailedType,
|
|
21
22
|
type GenerateDoc,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
|
+
import type { ComputeIntersectionDeep } from "hry-types/src/Object/ComputeIntersectionDeep";
|
|
3
|
+
import type { ComponentDoc } from "../api/DefineComponent/ReturnType/ComponentDoc";
|
|
4
|
+
import type { GetComponentPrefix } from "./GetComponentPrefix";
|
|
5
|
+
|
|
6
|
+
type Validator<
|
|
7
|
+
TOriginalComponentDoc extends ComponentDoc,
|
|
8
|
+
TExtensionDoc extends ComponentDoc,
|
|
9
|
+
TOriginalPrefix extends PropertyKey = GetComponentPrefix<TOriginalComponentDoc>,
|
|
10
|
+
TExtenstionPrefix extends PropertyKey = GetComponentPrefix<TExtensionDoc>,
|
|
11
|
+
DuplicateKeys extends PropertyKey =
|
|
12
|
+
| Extract<keyof TExtensionDoc["properties"], keyof TOriginalComponentDoc["properties"]>
|
|
13
|
+
| Extract<keyof TExtensionDoc["customEvents"], keyof TOriginalComponentDoc["customEvents"]>,
|
|
14
|
+
> = IfExtends<
|
|
15
|
+
TOriginalPrefix,
|
|
16
|
+
TExtenstionPrefix,
|
|
17
|
+
IfExtends<DuplicateKeys, never, ComponentDoc, `${DuplicateKeys & string}字段重复`>,
|
|
18
|
+
`前缀错误,应为${TOriginalPrefix & string}`
|
|
19
|
+
>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 有时组件文档内部包含一些slot或基本组件,可通过CompDocExtends泛型拓展组件文档,使得类型更安全
|
|
23
|
+
*/
|
|
24
|
+
export type ComponentDocExtension<
|
|
25
|
+
TOriginalComponentDoc extends ComponentDoc,
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
TExtensionDoc extends Validator<TOriginalComponentDoc, TExtensionDoc>,
|
|
28
|
+
> = ComputeIntersectionDeep<TOriginalComponentDoc & TExtensionDoc>;
|
|
29
|
+
|
|
30
|
+
// type test0 = ComponentDocExtension<{ properties: { aaa_xxx: string } }, { properties: { aaa_xxx: string } }>; // => "aaa_xxx字段重复"
|
|
31
|
+
|
|
32
|
+
// type test1 = ComponentDocExtension<{ customEvents: { aaa_xxx: string } }, { customEvents: { aaa_xxx: string } }>; // => "aaa_xxx字段重复"
|
|
33
|
+
|
|
34
|
+
// type test2 = ComponentDocExtension<{ properties: { aaa_xxx: string } }, { properties: { ddd_xxx: string } }>; // => "前缀错误,应为aaa"
|
|
35
|
+
|
|
36
|
+
// type test3 = ComponentDocExtension<{ customEvents: { aaa_xxx: string } }, { customEvents: { ddd_xxx: string } }>; // => "前缀错误,应为aaa"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ComputeObject<T> = T extends unknown ? { [k in keyof T]: T[k] } : never;
|
|
@@ -1,34 +1,36 @@
|
|
|
1
1
|
// import { Checking, type Test } from "hry-types";
|
|
2
2
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
3
|
+
import type { EmptyObject } from "hry-types/src/Misc/EmptyObject";
|
|
3
4
|
import type { ComponentDoc } from "../api/DefineComponent/ReturnType/ComponentDoc";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* 提取文档前缀名
|
|
7
|
-
* @param TComponentDoc - ComponentDoc
|
|
8
8
|
*/
|
|
9
|
-
export type
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
export type GetComponentPrefix<TComponentDoc extends ComponentDoc> = EmptyObject extends TComponentDoc ? never
|
|
10
|
+
: keyof IfExtends<
|
|
11
|
+
unknown,
|
|
12
|
+
TComponentDoc["properties"],
|
|
13
|
+
TComponentDoc["customEvents"],
|
|
14
|
+
TComponentDoc["properties"]
|
|
15
|
+
> extends `${infer P}_${string}` ? P
|
|
16
|
+
: never;
|
|
16
17
|
|
|
17
|
-
// type Test1 =
|
|
18
|
+
// type Test1 = GetComponentPrefix<{ properties: { xxx_name: string } }>;
|
|
18
19
|
|
|
19
20
|
// type Test1Expect = "xxx";
|
|
20
21
|
|
|
21
22
|
// Checking<Test1, Test1Expect, Test.Pass>;
|
|
22
23
|
|
|
23
|
-
// type Test2 =
|
|
24
|
+
// type Test2 = GetComponentPrefix<{ customEvents: { xxx_name: string } }>;
|
|
24
25
|
|
|
25
26
|
// type Test2Expect = "xxx";
|
|
26
27
|
|
|
27
28
|
// Checking<Test2, Test2Expect, Test.Pass>;
|
|
28
29
|
|
|
29
|
-
//
|
|
30
|
-
// type Test3 = ExtractDocPrefix<{}>;
|
|
30
|
+
// type demo = never extends `${infer P}_${string}` ? P : ""; // => string why?
|
|
31
31
|
|
|
32
|
-
// type
|
|
32
|
+
// type Test3 = GetComponentPrefix<{}>;
|
|
33
|
+
|
|
34
|
+
// type Test3Expect = never;
|
|
33
35
|
|
|
34
36
|
// Checking<Test3, Test3Expect, Test.Pass>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ComputeIntersectionDeep } from "hry-types/src/Object/ComputeIntersectionDeep";
|
|
2
|
-
import type { ComponentDoc } from "../api/DefineComponent/ReturnType/ComponentDoc";
|
|
3
|
-
import type { UnionToComma } from "./UnionToComma.test";
|
|
4
|
-
type _Validator<T, ExistingKeys extends PropertyKey, DuplicateKeys extends PropertyKey = Extract<keyof T, ExistingKeys>> = [DuplicateKeys] extends [never] ? object : `重复的字段${UnionToComma<DuplicateKeys & string>}`;
|
|
5
|
-
export type CompDocExtends<TSubComp extends ComponentDoc, Ext extends _Validator<Ext, keyof (TSubComp["properties"])> = {}> = ComputeIntersectionDeep<TSubComp & {
|
|
6
|
-
properties: Ext;
|
|
7
|
-
}>;
|
|
8
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CompDocExtends.js","sourceRoot":"","sources":["../../src/types/CompDocExtends.ts"],"names":[],"mappings":""}
|
package/dist/types/Drop.d.ts
DELETED
package/dist/types/Drop.js
DELETED
package/dist/types/Drop.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Drop.js","sourceRoot":"","sources":["../../src/types/Drop.ts"],"names":[],"mappings":""}
|
package/dist/types/DropStr.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type DropStr<S1 extends string, S2 extends string> = S1 extends `${infer Head}${S2}${infer Tail}` ? DropStr<`${Head}${Tail}`, S2> : S1;
|
package/dist/types/DropStr.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DropStr.js","sourceRoot":"","sources":["../../src/types/DropStr.ts"],"names":[],"mappings":""}
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RestorePropertiesDoc.js","sourceRoot":"","sources":["../../src/types/RestorePropertiesDoc.ts"],"names":[],"mappings":""}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ComputeIntersectionDeep } from "hry-types/src/Object/ComputeIntersectionDeep";
|
|
2
|
-
import type { ComponentDoc } from "../api/DefineComponent/ReturnType/ComponentDoc";
|
|
3
|
-
import type { UnionToComma } from "./UnionToComma.test";
|
|
4
|
-
|
|
5
|
-
type _Validator<
|
|
6
|
-
T,
|
|
7
|
-
ExistingKeys extends PropertyKey,
|
|
8
|
-
DuplicateKeys extends PropertyKey = Extract<keyof T, ExistingKeys>,
|
|
9
|
-
> = [DuplicateKeys] extends [never] ? object : `重复的字段${UnionToComma<DuplicateKeys & string>}`;
|
|
10
|
-
|
|
11
|
-
export type CompDocExtends<
|
|
12
|
-
TSubComp extends ComponentDoc,
|
|
13
|
-
Ext extends _Validator<Ext, keyof (TSubComp["properties"])> = {},
|
|
14
|
-
> = ComputeIntersectionDeep<TSubComp & { properties: Ext }>;
|
package/src/types/Drop.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Equals } from "hry-types/src/Any/Equals";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 从' T '中删除' A '项
|
|
5
|
-
* @param T - 元组类型
|
|
6
|
-
* @param A - 任意类型
|
|
7
|
-
* @returns [[unknown[]]]
|
|
8
|
-
* @example
|
|
9
|
-
*/
|
|
10
|
-
export type Drop<T extends unknown[], A> = T extends [infer Head, ...infer Rest]
|
|
11
|
-
? Equals<A, Head> extends true ? Rest : Drop<[...Rest, Head], A>
|
|
12
|
-
: T;
|
|
13
|
-
|
|
14
|
-
// // type Test = Drop<[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3>[number];
|
|
15
|
-
|
|
16
|
-
// // type TestExpect = [4, 5, 6, 8, 7, 9, 10, 1, 2][number];
|
|
17
|
-
|
|
18
|
-
// // Checking<Test, TestExpect, Test.Pass>;
|
package/src/types/DropStr.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// import type { ComponentDoc } from "../api/DefineComponent/CreateDoc/ComponentDoc";
|
|
2
|
-
// import type { Drop } from "./Drop";
|
|
3
|
-
|
|
4
|
-
// import type { ListOfSamePrimitive } from "./ListOfSamePrimitive";
|
|
5
|
-
// import type { ReStorePropTypeOfList } from "./ReStorePropTypeOfList";
|
|
6
|
-
// import type { DetailedType } from "./DetailedType";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 还原properties描述
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* type doc = {properties:{a:'1'|'2',b:boolean,c:string[],d:{name:string}}}
|
|
13
|
-
* type test = ReStorePropertiesDoc<doc>
|
|
14
|
-
* //=> {a: "1" | "2" | {type: "1" | "2"; value?: "1" | "2";}; b: boolean | {type: boolean; value?: boolean;}; c: string[] | {type: string[]; value?: string[];}; d: {name: string;} | {type: {name: string;}; value?: {name: string;};}}
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
// type ReStorePropertiesDoc<T extends ComponentDoc> = {
|
|
18
|
-
// [k in keyof T]?: ListOfSamePrimitive<T[k]> extends infer R extends unknown[]
|
|
19
|
-
// ? R["length"] extends 1 ? DetailedType<R[0]> | { type: DetailedType<R[0]>; value: R[0] }
|
|
20
|
-
// : {
|
|
21
|
-
// type: DetailedType<R[0]>;
|
|
22
|
-
// value?: R[0];
|
|
23
|
-
// optionalTypes?: ReStorePropTypeOfList<Drop<R, R[0]>>[number][];
|
|
24
|
-
// }
|
|
25
|
-
// : never;
|
|
26
|
-
// };
|