annil 1.0.1 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +105 -6
- package/dist/api/DefineComponent/ReturnType/test/normalComponentDoc.test.js +6 -6
- package/dist/api/DefineComponent/ReturnType/test/normalComponentDoc.test.js.map +1 -1
- package/dist/api/DefineComponent/ReturnType/test/normalPageDoc.test.js.map +1 -1
- package/dist/api/DefineComponent/collectOptionsForComponent.d.ts +4 -0
- package/dist/api/DefineComponent/collectOptionsForComponent.js +152 -0
- package/dist/api/DefineComponent/collectOptionsForComponent.js.map +1 -0
- package/dist/api/DefineComponent/index.d.ts +4 -28
- package/dist/api/DefineComponent/index.js +2 -37
- package/dist/api/DefineComponent/index.js.map +1 -1
- package/dist/api/RootComponent/CustomEvents/CustomEventConstraint.d.ts +5 -4
- package/dist/api/RootComponent/CustomEvents/GetCustomEventDoc.d.ts +5 -5
- package/dist/api/RootComponent/CustomEvents/test/error.test.js +8 -8
- package/dist/api/RootComponent/CustomEvents/test/error.test.js.map +1 -1
- package/dist/api/RootComponent/CustomEvents/test/normal.test.d.ts +17 -17
- package/dist/api/RootComponent/CustomEvents/test/normal.test.js +6 -6
- package/dist/api/RootComponent/CustomEvents/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/Data/DataConstraint.d.ts +1 -0
- package/dist/api/RootComponent/Data/DataConstraint.js +2 -0
- package/dist/api/RootComponent/Data/DataConstraint.js.map +1 -0
- package/dist/api/RootComponent/Instance/test/CustomEventsDoc.test.js +5 -5
- package/dist/api/RootComponent/Instance/test/CustomEventsDoc.test.js.map +1 -1
- package/dist/api/RootComponent/Instance/test/customEvents/normal.test.js +5 -5
- package/dist/api/RootComponent/Instance/test/customEvents/normal.test.js.map +1 -1
- package/dist/api/RootComponent/Instance/test/properties/mormal.test.js.map +1 -1
- package/dist/api/RootComponent/Lifetimes/LifetimesConstraint.d.ts +2 -2
- package/dist/api/RootComponent/Lifetimes/test/error.test.js +1 -0
- package/dist/api/RootComponent/Lifetimes/test/error.test.js.map +1 -1
- package/dist/api/RootComponent/Lifetimes/test/normal.test.js +3 -0
- package/dist/api/RootComponent/Lifetimes/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/PageLifetimes/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/Properties/GetOptionalDoc.d.ts +2 -2
- package/dist/api/RootComponent/Properties/GetRequiredDoc.d.ts +2 -2
- package/dist/api/RootComponent/Properties/PropertiesConstraint.d.ts +6 -6
- package/dist/api/RootComponent/Properties/PropertiesValueValidator.d.ts +2 -2
- package/dist/api/RootComponent/Properties/test/error.test.js.map +1 -1
- package/dist/api/RootComponent/Properties/test/normalOptional.test.js +15 -0
- package/dist/api/RootComponent/Properties/test/normalOptional.test.js.map +1 -1
- package/dist/api/RootComponent/Properties/test/normalRequired.test.d.ts +21 -21
- package/dist/api/RootComponent/index.d.ts +19 -2
- package/dist/api/RootComponent/index.js +1 -1
- package/dist/api/RootComponent/index.js.map +1 -1
- package/dist/api/SubComponent/SubComputed/GetSubComputedDoc.d.ts +1 -1
- package/dist/api/SubComponent/SubComputed/test/normal.test.js +4 -4
- package/dist/api/SubComponent/SubComputed/test/normal.test.js.map +1 -1
- package/dist/api/SubComponent/index.d.ts +2 -2
- package/dist/api/SubComponent/index.js.map +1 -1
- package/dist/api/navigateTo.d.ts +1 -1
- package/dist/{utils → behaviors/BComputedAndWatch}/computedUpdater.d.ts +1 -1
- package/dist/{utils → behaviors/BComputedAndWatch}/computedUpdater.js +2 -2
- package/dist/behaviors/BComputedAndWatch/computedUpdater.js.map +1 -0
- package/dist/{utils → behaviors/BComputedAndWatch}/getPathsValue.d.ts +1 -1
- package/dist/behaviors/BComputedAndWatch/getPathsValue.js.map +1 -0
- package/dist/behaviors/BComputedAndWatch/index.js +8 -1
- package/dist/behaviors/BComputedAndWatch/index.js.map +1 -1
- package/dist/behaviors/BComputedAndWatch/initComputed.js +1 -1
- package/dist/behaviors/BComputedAndWatch/initComputed.js.map +1 -1
- package/dist/behaviors/BStore.js.map +1 -1
- package/dist/behaviors/BbeforeCreated.js +1 -2
- package/dist/behaviors/BbeforeCreated.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/{SpecificType.d.ts → DetailedType.d.ts} +1 -1
- package/dist/types/DetailedType.js +2 -0
- package/dist/types/DetailedType.js.map +1 -0
- package/dist/types/GenerateDoc.d.ts +9 -0
- package/dist/types/GenerateDoc.js +2 -0
- package/dist/types/GenerateDoc.js.map +1 -0
- package/dist/types/InferDetailedType.d.ts +2 -0
- package/dist/types/InferDetailedType.js +2 -0
- package/dist/types/InferDetailedType.js.map +1 -0
- package/dist/types/{InferSpecificType.test.js → InferDetailedType.test.js} +1 -1
- package/dist/types/InferDetailedType.test.js.map +1 -0
- package/dist/types/OfficialTypeAlias.d.ts +6 -6
- package/package.json +3 -3
- package/src/api/DefineComponent/ReturnType/test/normalComponentDoc.test.ts +12 -12
- package/src/api/DefineComponent/ReturnType/test/normalPageDoc.test.ts +4 -4
- package/src/api/DefineComponent/collectOptionsForComponent.ts +290 -0
- package/src/api/DefineComponent/index.ts +12 -85
- package/src/api/RootComponent/Computed/test/normal.test.ts +2 -2
- package/src/api/RootComponent/CustomEvents/CustomEventConstraint.ts +6 -4
- package/src/api/RootComponent/CustomEvents/CustomEventsOption.ts +2 -2
- package/src/api/RootComponent/CustomEvents/GetCustomEventDoc.ts +7 -7
- package/src/api/RootComponent/CustomEvents/test/error.test.ts +8 -8
- package/src/api/RootComponent/CustomEvents/test/normal.test.ts +9 -9
- package/src/api/RootComponent/Data/DataConstraint.ts +1 -0
- package/src/api/RootComponent/Events/EventsConstraint.ts +1 -1
- package/src/api/RootComponent/Instance/test/CustomEventsDoc.test.ts +8 -8
- package/src/api/RootComponent/Instance/test/customEvents/normal.test.ts +8 -8
- package/src/api/RootComponent/Instance/test/properties/mormal.test.ts +3 -3
- package/src/api/RootComponent/IsPage/IsPageOption.ts +6 -1
- package/src/api/RootComponent/Lifetimes/LifetimesConstraint.ts +2 -2
- package/src/api/RootComponent/Lifetimes/test/error.test.ts +1 -1
- package/src/api/RootComponent/Lifetimes/test/normal.test.ts +3 -3
- package/src/api/RootComponent/PageLifetimes/test/normal.test.ts +3 -3
- package/src/api/RootComponent/Properties/GetOptionalDoc.ts +5 -5
- package/src/api/RootComponent/Properties/GetRequiredDoc.ts +5 -5
- package/src/api/RootComponent/Properties/PropertiesConstraint.ts +6 -6
- package/src/api/RootComponent/Properties/PropertiesOption.ts +1 -1
- package/src/api/RootComponent/Properties/PropertiesValueValidator.ts +2 -2
- package/src/api/RootComponent/Properties/test/error.test.ts +2 -2
- package/src/api/RootComponent/Properties/test/normalOptional.test.ts +25 -5
- package/src/api/RootComponent/Properties/test/normalRequired.test.ts +11 -11
- package/src/api/RootComponent/Watch/test/WatchComputed.test.ts +2 -2
- package/src/api/RootComponent/Watch/test/WatchProperties.test.ts +4 -4
- package/src/api/RootComponent/index.ts +19 -3
- package/src/api/SubComponent/SubComputed/test/normal.test.ts +15 -9
- package/src/api/SubComponent/index.ts +4 -4
- package/src/{utils → behaviors/BComputedAndWatch}/computedUpdater.ts +5 -4
- package/src/{utils → behaviors/BComputedAndWatch}/getPathsValue.ts +1 -1
- package/src/behaviors/BComputedAndWatch/index.ts +13 -4
- package/src/behaviors/BComputedAndWatch/initComputed.ts +1 -1
- package/src/behaviors/BStore.ts +2 -2
- package/src/behaviors/BbeforeCreated.ts +3 -3
- package/src/index.ts +11 -2
- package/src/types/DetailedType.ts +15 -0
- package/src/types/GenerateDoc.ts +19 -0
- package/src/types/InferDetailedType.test.ts +18 -0
- package/src/types/{InferSpecificType.ts → InferDetailedType.ts} +4 -4
- package/src/types/OfficialTypeAlias.ts +2 -2
- package/src/types/RestorePropertiesDoc.ts +3 -3
- package/tsconfig.json +7 -16
- package/dist/types/InferSpecificType.d.ts +0 -2
- package/dist/types/InferSpecificType.js +0 -2
- package/dist/types/InferSpecificType.js.map +0 -1
- package/dist/types/InferSpecificType.test.js.map +0 -1
- package/dist/types/SpecificType.js +0 -2
- package/dist/types/SpecificType.js.map +0 -1
- package/dist/utils/InternalFieldProtection.d.ts +0 -2
- package/dist/utils/InternalFieldProtection.js +0 -11
- package/dist/utils/InternalFieldProtection.js.map +0 -1
- package/dist/utils/collector.d.ts +0 -5
- package/dist/utils/collector.js +0 -21
- package/dist/utils/collector.js.map +0 -1
- package/dist/utils/computedUpdater.js.map +0 -1
- package/dist/utils/createdHijack.d.ts +0 -0
- package/dist/utils/createdHijack.js +0 -2
- package/dist/utils/createdHijack.js.map +0 -1
- package/dist/utils/customEventsHandle.d.ts +0 -2
- package/dist/utils/customEventsHandle.js +0 -20
- package/dist/utils/customEventsHandle.js.map +0 -1
- package/dist/utils/eventsHandle.d.ts +0 -2
- package/dist/utils/eventsHandle.js +0 -5
- package/dist/utils/eventsHandle.js.map +0 -1
- package/dist/utils/funcConfigHandle.d.ts +0 -2
- package/dist/utils/funcConfigHandle.js +0 -18
- package/dist/utils/funcConfigHandle.js.map +0 -1
- package/dist/utils/getPathsValue.js.map +0 -1
- package/dist/utils/initWatchOldValue.d.ts +0 -2
- package/dist/utils/initWatchOldValue.js +0 -10
- package/dist/utils/initWatchOldValue.js.map +0 -1
- package/dist/utils/onLoadHijack.d.ts +0 -3
- package/dist/utils/onLoadHijack.js +0 -16
- package/dist/utils/onLoadHijack.js.map +0 -1
- package/dist/utils/onLoadReceivedDataHandle.d.ts +0 -3
- package/dist/utils/onLoadReceivedDataHandle.js +0 -14
- package/dist/utils/onLoadReceivedDataHandle.js.map +0 -1
- package/dist/utils/rootComponentFieldHandle.d.ts +0 -3
- package/dist/utils/rootComponentFieldHandle.js +0 -13
- package/dist/utils/rootComponentFieldHandle.js.map +0 -1
- package/dist/utils/subComponentsHandle.d.ts +0 -3
- package/dist/utils/subComponentsHandle.js +0 -12
- package/dist/utils/subComponentsHandle.js.map +0 -1
- package/src/types/InferSpecificType.test.ts +0 -18
- package/src/types/SpecificType.ts +0 -19
- package/src/utils/InternalFieldProtection.ts +0 -18
- package/src/utils/collector.ts +0 -41
- package/src/utils/createdHijack.ts +0 -21
- package/src/utils/customEventsHandle.ts +0 -31
- package/src/utils/eventsHandle.ts +0 -10
- package/src/utils/funcConfigHandle.ts +0 -30
- package/src/utils/initWatchOldValue.ts +0 -12
- package/src/utils/onLoadHijack.ts +0 -30
- package/src/utils/onLoadReceivedDataHandle.ts +0 -31
- package/src/utils/rootComponentFieldHandle.ts +0 -27
- package/src/utils/subComponentsHandle.ts +0 -25
- /package/dist/{utils → behaviors/BComputedAndWatch}/getPathsValue.js +0 -0
- /package/dist/types/{InferSpecificType.test.d.ts → InferDetailedType.test.d.ts} +0 -0
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import type { Func } from "hry-types/src/Misc/Func";
|
|
2
|
-
import type {
|
|
2
|
+
import type { FinalOptionsForComponent } from "../../api/DefineComponent";
|
|
3
3
|
import { deepClone } from "../../utils/deepClone";
|
|
4
4
|
import { deleteProtoField } from "../../utils/deleteProtoField";
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
import { isEmptyObject } from "../../utils/isEmptyObject";
|
|
7
|
+
import { getPathsValue } from "./getPathsValue";
|
|
7
8
|
import { initComputed } from "./initComputed";
|
|
8
9
|
import { isEqual } from "./isEqual";
|
|
9
10
|
import { isPage } from "./IsPage";
|
|
10
|
-
import type { Instance } from "./types";
|
|
11
|
+
import type { Instance, WatchOldValue } from "./types";
|
|
12
|
+
function initWatchOldValue(this: Instance, watchConfig: object): WatchOldValue {
|
|
13
|
+
const watchOldValue = {};
|
|
14
|
+
for (const key in watchConfig) {
|
|
15
|
+
watchOldValue[key] = deepClone(getPathsValue.call(this, key.split(".")));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return watchOldValue;
|
|
19
|
+
}
|
|
11
20
|
/**
|
|
12
21
|
* 实现
|
|
13
22
|
* 1. 计算属性初始化在attached之后(前版本在beforeCreate)
|
|
@@ -23,7 +32,7 @@ import type { Instance } from "./types";
|
|
|
23
32
|
*/
|
|
24
33
|
|
|
25
34
|
export const BComputedAndWatch = Behavior({
|
|
26
|
-
definitionFilter(options:
|
|
35
|
+
definitionFilter(options: FinalOptionsForComponent) {
|
|
27
36
|
const computedConfig = options.computed;
|
|
28
37
|
|
|
29
38
|
// computed handle
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// import type { IsDependOnOthers } from "./data-tracer";
|
|
3
3
|
|
|
4
4
|
import type { Func } from "hry-types/src/Misc/Func";
|
|
5
|
-
import { computedUpdater } from "../../utils/computedUpdater";
|
|
6
5
|
import { deleteProtoField } from "../../utils/deleteProtoField";
|
|
6
|
+
import { computedUpdater } from "./computedUpdater";
|
|
7
7
|
import { deepProxy, unwrap } from "./data-tracer";
|
|
8
8
|
import type { ComputedCache, Instance } from "./types";
|
|
9
9
|
export type ComputedDependence = { paths: string[]; val: unknown };
|
package/src/behaviors/BStore.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type mobx from "mobx";
|
|
2
|
-
import type {
|
|
2
|
+
import type { FinalOptionsForComponent } from "../api/DefineComponent";
|
|
3
3
|
import { deleteProtoField } from "../utils/deleteProtoField";
|
|
4
4
|
import type { Instance } from "./BComputedAndWatch/types";
|
|
5
5
|
|
|
6
6
|
export const BStore = Behavior({
|
|
7
|
-
definitionFilter(options:
|
|
7
|
+
definitionFilter(options: FinalOptionsForComponent) {
|
|
8
8
|
// 初始化store
|
|
9
9
|
const storeConfig = options.store;
|
|
10
10
|
if (!storeConfig) return;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FinalOptionsForComponent } from "../api/DefineComponent";
|
|
2
2
|
|
|
3
3
|
export const BBeforeCreate = Behavior({
|
|
4
|
-
definitionFilter(options:
|
|
4
|
+
definitionFilter(options: FinalOptionsForComponent) {
|
|
5
5
|
// 触发beforeCreate生命周期函数
|
|
6
|
-
const beforeCreateFunc = options.lifetimes
|
|
6
|
+
const beforeCreateFunc = options.lifetimes!.beforeCreate;
|
|
7
7
|
|
|
8
8
|
beforeCreateFunc && beforeCreateFunc(options);
|
|
9
9
|
},
|
package/src/index.ts
CHANGED
|
@@ -10,8 +10,17 @@ import { RootComponent } from "./api/RootComponent";
|
|
|
10
10
|
|
|
11
11
|
import { SubComponent } from "./api/SubComponent";
|
|
12
12
|
|
|
13
|
-
import type {
|
|
13
|
+
import type { DetailedType } from "./types/DetailedType";
|
|
14
14
|
|
|
15
|
+
import type { GenerateDoc } from "./types/GenerateDoc";
|
|
15
16
|
import type { ParamsEqual } from "./types/TwoParamsEqual";
|
|
16
17
|
|
|
17
|
-
export {
|
|
18
|
+
export {
|
|
19
|
+
DefineComponent,
|
|
20
|
+
type DetailedType,
|
|
21
|
+
type GenerateDoc,
|
|
22
|
+
navigateTo,
|
|
23
|
+
type ParamsEqual,
|
|
24
|
+
RootComponent,
|
|
25
|
+
SubComponent,
|
|
26
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 通过as DetailedType 指定具体类型。
|
|
3
|
+
* @remarks
|
|
4
|
+
* 在js中使用构造函数(Object,Array等)表示类型时,无法给出明确的类型,DetailedType为此而生
|
|
5
|
+
* @example
|
|
6
|
+
* ``` ts
|
|
7
|
+
* RootComponent()({
|
|
8
|
+
* properties: {
|
|
9
|
+
* gender: String as DetailedType<"male" | "female">,
|
|
10
|
+
* unionArr: Array as DetailedType<string[] | number[]>,
|
|
11
|
+
* },
|
|
12
|
+
* });
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export type DetailedType<T = unknown> = { (): T } | { new(...arg: any[]): T };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
|
+
import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
|
|
3
|
+
import type { ComponentDoc } from "../api/DefineComponent/ReturnType/ComponentDoc";
|
|
4
|
+
import type { AddPrefix } from "./AddPrefix";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 生成组件文档类型
|
|
8
|
+
*/
|
|
9
|
+
export type GenerateDoc<TName extends string, T extends ComponentDoc> = ComputeIntersection<
|
|
10
|
+
& IfExtends<
|
|
11
|
+
unknown,
|
|
12
|
+
T["properties"],
|
|
13
|
+
{},
|
|
14
|
+
{
|
|
15
|
+
properties: AddPrefix<T["properties"] & {}, TName>;
|
|
16
|
+
}
|
|
17
|
+
>
|
|
18
|
+
& IfExtends<unknown, T["customEvents"], {}, { customEvents: AddPrefix<T["customEvents"] & {}, TName> }>
|
|
19
|
+
>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Checking, type Test } from "hry-types";
|
|
2
|
+
|
|
3
|
+
import type { DetailedType } from "./DetailedType";
|
|
4
|
+
import type { InferDetailedType } from "./InferDetailedType";
|
|
5
|
+
|
|
6
|
+
Checking<InferDetailedType<StringConstructor>, string, Test.Pass>;
|
|
7
|
+
|
|
8
|
+
Checking<InferDetailedType<NumberConstructor>, number, Test.Pass>;
|
|
9
|
+
|
|
10
|
+
Checking<InferDetailedType<BooleanConstructor>, boolean, Test.Pass>;
|
|
11
|
+
|
|
12
|
+
Checking<InferDetailedType<ArrayConstructor>, unknown[], Test.Pass>;
|
|
13
|
+
|
|
14
|
+
Checking<InferDetailedType<ObjectConstructor>, object, Test.Pass>;
|
|
15
|
+
|
|
16
|
+
Checking<InferDetailedType<DetailedType<"a" | "b">>, "a" | "b", Test.Pass>;
|
|
17
|
+
|
|
18
|
+
Checking<InferDetailedType<DetailedType<[string, number, boolean]>>, [string, number, boolean], Test.Pass>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DetailedType } from "./DetailedType";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* 解析
|
|
4
|
+
* 解析DetailedType的类型
|
|
5
5
|
*/
|
|
6
|
-
export type
|
|
6
|
+
export type InferDetailedType<T> = T extends StringConstructor ? string
|
|
7
7
|
: T extends NumberConstructor ? number
|
|
8
8
|
: T extends BooleanConstructor ? boolean
|
|
9
9
|
: T extends ArrayConstructor ? unknown[]
|
|
10
10
|
: T extends ObjectConstructor ? object
|
|
11
|
-
: T extends
|
|
11
|
+
: T extends DetailedType<infer R> ? R
|
|
12
12
|
: never;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type WMTriggerEventOption = WechatMiniprogram.Component.TriggerEventOption;
|
|
2
2
|
|
|
3
3
|
export type WMCustomEvent<
|
|
4
|
-
Detail =
|
|
4
|
+
Detail = undefined,
|
|
5
5
|
Mark extends object = object,
|
|
6
6
|
CurrentTargetDataset extends object = object,
|
|
7
7
|
TargetDataset extends object = CurrentTargetDataset,
|
|
@@ -25,7 +25,7 @@ export type WMBaseEvent<
|
|
|
25
25
|
export type Dataset<
|
|
26
26
|
TCurrentTargetDataset extends object,
|
|
27
27
|
TargetDataset extends object = TCurrentTargetDataset,
|
|
28
|
-
Detail =
|
|
28
|
+
Detail = undefined,
|
|
29
29
|
> = WMCustomEvent<Detail, object, TCurrentTargetDataset, TargetDataset>;
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
// import type { ListOfSamePrimitive } from "./ListOfSamePrimitive";
|
|
5
5
|
// import type { ReStorePropTypeOfList } from "./ReStorePropTypeOfList";
|
|
6
|
-
// import type {
|
|
6
|
+
// import type { DetailedType } from "./DetailedType";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* 还原properties描述
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
*/
|
|
17
17
|
// type ReStorePropertiesDoc<T extends ComponentDoc> = {
|
|
18
18
|
// [k in keyof T]?: ListOfSamePrimitive<T[k]> extends infer R extends unknown[]
|
|
19
|
-
// ? R["length"] extends 1 ?
|
|
19
|
+
// ? R["length"] extends 1 ? DetailedType<R[0]> | { type: DetailedType<R[0]>; value: R[0] }
|
|
20
20
|
// : {
|
|
21
|
-
// type:
|
|
21
|
+
// type: DetailedType<R[0]>;
|
|
22
22
|
// value?: R[0];
|
|
23
23
|
// optionalTypes?: ReStorePropTypeOfList<Drop<R, R[0]>>[number][];
|
|
24
24
|
// }
|
package/tsconfig.json
CHANGED
|
@@ -1,38 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"lib": ["ES2022", "DOM"],
|
|
3
|
+
"lib": ["ES2022", "DOM"], // jest中用到了DOM类型
|
|
4
4
|
"target": "ES2017",
|
|
5
5
|
"module": "ES2022",
|
|
6
|
-
"strict": true,
|
|
6
|
+
"strict": true,
|
|
7
7
|
"strictFunctionTypes": false, // e: Dataset<{ id: string }>会报错。
|
|
8
8
|
"exactOptionalPropertyTypes": true, // 带有?标志的属性类型不在包含undefined
|
|
9
9
|
"skipLibCheck": true, // 跳过声明文件的类型检查(.d.ts),除了你引用的, 默认false(不跳过)。
|
|
10
|
-
"moduleResolution": "
|
|
11
|
-
|
|
10
|
+
"moduleResolution": "Bundler", // 模块解析策略 //5.0 新值 bundler
|
|
11
|
+
"noImplicitAny": true, // 不允许隐式的any类型
|
|
12
12
|
"esModuleInterop": true, // 默认false 将 CommonJS/AMD/UMD 模块视为类似于 ES6 模块,但有缺陷。
|
|
13
13
|
"removeComments": true, // 去除注释
|
|
14
14
|
"noEmit": true,
|
|
15
|
-
"allowJs": true, // 默认false 开启后会保留js文件
|
|
16
|
-
// "diagnostics": true, // 2.65
|
|
17
|
-
// "watch": true,
|
|
18
|
-
// // "experimentalDecorators": true,//实验性质的装饰器
|
|
19
15
|
"noImplicitReturns": true, // 隐式函数返回
|
|
20
|
-
// "resolveJsonModule": true, //import settings from "./settings.json";
|
|
21
16
|
"forceConsistentCasingInFileNames": true, // 区分文件名的大小写
|
|
22
|
-
"noUnusedLocals":
|
|
17
|
+
"noUnusedLocals": true, // 报告未使用局部变量的错误
|
|
23
18
|
"noUnusedParameters": false, // 报告函数中未使用参数的错误
|
|
24
19
|
"suppressImplicitAnyIndexErrors": true, // 为true关闭隐式索引错误,但很激进,建议使用@ts-ignore
|
|
25
20
|
"isolatedModules": true, // 独立模块(必须有导入或导出) 默认false
|
|
26
21
|
"preserveValueImports": true, // 引入类型加type
|
|
27
|
-
"useUnknownInCatchVariables": false, // catch 子句 err为unknown 可以显示指定类型 4.4 --strict
|
|
28
|
-
// "verbatimModuleSyntax": true,
|
|
29
|
-
// "importsNotUsedAsValues":"remove",
|
|
30
22
|
"ignoreDeprecations": "5.0",
|
|
31
|
-
// "noEmitOnError": true, // 错误情况下不编译 开启会导致wtach下报错
|
|
32
23
|
"noFallthroughCasesInSwitch": true, // 报告switch语句中漏接情况的错误
|
|
33
|
-
// 指定加载包的路径,默认加载所有@types下的包 包含上级目录
|
|
34
24
|
"allowSyntheticDefaultImports": true, // esModuleInterop 为true时自动true
|
|
35
|
-
|
|
25
|
+
// 默认加载所有@types下的包 types指定具体的包,其他拒绝。包含上级目录
|
|
26
|
+
"types": ["hry-types", "mobx", "jest", "miniprogram-api-typings"]
|
|
36
27
|
},
|
|
37
28
|
"include": ["**/*.ts"]
|
|
38
29
|
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import type { SpecificType } from "./SpecificType";
|
|
2
|
-
export type InferSpecificType<T> = T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends ArrayConstructor ? unknown[] : T extends ObjectConstructor ? object : T extends SpecificType<infer R> ? R : never;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InferSpecificType.js","sourceRoot":"","sources":["../../src/types/InferSpecificType.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InferSpecificType.test.js","sourceRoot":"","sources":["../../src/types/InferSpecificType.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,MAAM,WAAW,CAAC;AAKhD,QAAiE,CAAC;AAElE,QAAiE,CAAC;AAElE,QAAmE,CAAC;AAEpE,QAAmE,CAAC;AAEpE,QAAiE,CAAC;AAElE,QAA0E,CAAC;AAE3E,QAA0G,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SpecificType.js","sourceRoot":"","sources":["../../src/types/SpecificType.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export const INNERFIELDS = ["disposer"];
|
|
2
|
-
export function InternalFieldProtection(methodsConfig) {
|
|
3
|
-
const fields = ["disposer"];
|
|
4
|
-
const methodsConfigKeys = Object.keys(methodsConfig);
|
|
5
|
-
for (const key of fields) {
|
|
6
|
-
if (methodsConfigKeys.includes(key)) {
|
|
7
|
-
throw Error(`${key}已被内部字段占用`);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=InternalFieldProtection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InternalFieldProtection.js","sourceRoot":"","sources":["../../src/utils/InternalFieldProtection.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,UAAU,CAAC,CAAC;AAMxC,MAAM,UAAU,uBAAuB,CAAC,aAAqB;IAC3D,MAAM,MAAM,GAAG,CAAC,UAAU,CAAC,CAAC;IAC5B,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACrD,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,iBAAiB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACpC,MAAM,KAAK,CAAC,GAAG,GAAG,UAAU,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Func } from "hry-types/src/Misc/Func";
|
|
2
|
-
import type { ComponentOptions, FuncConfig } from "../api/DefineComponent";
|
|
3
|
-
import type { RootComponentDoc } from "../api/RootComponent/RootComponentDoc";
|
|
4
|
-
export declare function funcFieldsCollect(config: Record<string, Func>, funcConfig: FuncConfig, type: "pageLifetimes" | "lifetimes" | "watch"): void;
|
|
5
|
-
export declare function otherFieldsHandle(componentOptions: ComponentOptions, rootComponentOptions: Omit<RootComponentDoc, "customEvents" | "events" | "pageLifetimes">): void;
|
package/dist/utils/collector.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export function funcFieldsCollect(config, funcConfig, type) {
|
|
2
|
-
for (const key in config) {
|
|
3
|
-
const handler = config[key];
|
|
4
|
-
const tempCache = funcConfig[type] || (funcConfig[type] = {});
|
|
5
|
-
const filedList = tempCache[key] || (tempCache[key] = []);
|
|
6
|
-
filedList.push(handler);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export function otherFieldsHandle(componentOptions, rootComponentOptions) {
|
|
10
|
-
for (const key in rootComponentOptions) {
|
|
11
|
-
const config = rootComponentOptions[key];
|
|
12
|
-
if (Array.isArray(config)) {
|
|
13
|
-
componentOptions[key] || (componentOptions[key] = []);
|
|
14
|
-
componentOptions[key].push(...config);
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
Object.assign(componentOptions[key] || (componentOptions[key] = {}), config);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=collector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collector.js","sourceRoot":"","sources":["../../src/utils/collector.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,iBAAiB,CAC/B,MAA4B,EAC5B,UAAsB,EACtB,IAA6C;IAE7C,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAE5B,MAAM,SAAS,GAAW,UAAU,CAAC,IAAI,MAAf,UAAU,CAAC,IAAI,IAAM,EAAE,CAAA,CAAC;QAClD,MAAM,SAAS,GAAW,SAAS,CAAC,GAAG,MAAb,SAAS,CAAC,GAAG,IAAM,EAAE,CAAA,CAAC;QAEhD,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC;AAGD,MAAM,UAAU,iBAAiB,CAC/B,gBAAkC,EAClC,oBAAyF;IAEzF,KAAK,MAAM,GAAG,IAAI,oBAAoB,EAAE,CAAC;QACvC,MAAM,MAAM,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;QAGzC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAE1B,gBAAgB,CAAC,GAAG,MAApB,gBAAgB,CAAC,GAAG,IAAM,EAAE,EAAC;YAE7B,gBAAgB,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;QACxC,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,MAApB,gBAAgB,CAAC,GAAG,IAAM,EAAE,GAAE,MAAM,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"computedUpdater.js","sourceRoot":"","sources":["../../src/utils/computedUpdater.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,4CAA4C,CAAC;AAE/E,OAAO,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,UAAU,eAAe,CAAiB,SAAS,GAAG,KAAK;IAK/D,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAGzC,MAAM,SAAS,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;QAC9C,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,KAAK,MAAM,GAAG,IAAI,SAAS,CAAC,WAAW,EAAE,CAAC;YACxC,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;YAGnD,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9B,OAAO,GAAG,IAAI,CAAC;gBAEf,MAAM;YACR,CAAC;QACH,CAAC;QAED,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,cAAc,GAAyB,EAAE,CAAC;YAEhD,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;gBACrC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC;aAC3C,CAAC,CAAC;YAGH,IAAI,CAAC,OAAO,CAAC;gBACX,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;aACxB,CAAC,CAAC;YAEH,SAAS,GAAG,IAAI,CAAC;YAGjB,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,WAAW,GAAG,cAAc,CAAC;YAGzD,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createdHijack.js","sourceRoot":"","sources":["../../src/utils/createdHijack.ts"],"names":[],"mappings":""}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
function IsFullCustomEvents(customEventOptions) {
|
|
2
|
-
return Object.prototype.toString.call(customEventOptions) === "[object Object]";
|
|
3
|
-
}
|
|
4
|
-
export function customEventsHandle(componentOptions, customEventsConfig) {
|
|
5
|
-
componentOptions.methods || (componentOptions.methods = {});
|
|
6
|
-
for (const key in customEventsConfig) {
|
|
7
|
-
const customEventOptions = customEventsConfig[key];
|
|
8
|
-
if (IsFullCustomEvents(customEventOptions)) {
|
|
9
|
-
componentOptions.methods[key] = function (detail) {
|
|
10
|
-
this.triggerEvent(key, detail, customEventOptions.options);
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
componentOptions.methods[key] = function (detail) {
|
|
15
|
-
this.triggerEvent(key, detail);
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=customEventsHandle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customEventsHandle.js","sourceRoot":"","sources":["../../src/utils/customEventsHandle.ts"],"names":[],"mappings":"AAIA,SAAS,kBAAkB,CACzB,kBAAyD;IAEzD,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,iBAAiB,CAAC;AAClF,CAAC;AAKD,MAAM,UAAU,kBAAkB,CAAC,gBAAkC,EAAE,kBAA0B;IAE/F,gBAAgB,CAAC,OAAO,KAAxB,gBAAgB,CAAC,OAAO,GAAK,EAAE,EAAC;IAEhC,KAAK,MAAM,GAAG,IAAI,kBAAkB,EAAE,CAAC;QACrC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAEnD,IAAI,kBAAkB,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAC3C,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,UAAS,MAAe;gBACrD,IAA4B,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;YACtF,CAAC,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,UAAS,MAAe;gBACrD,IAA4B,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAC1D,CAAC,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eventsHandle.js","sourceRoot":"","sources":["../../src/utils/eventsHandle.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,YAAY,CAAC,gBAAkC,EAAE,YAAoB;IACnF,gBAAgB,CAAC,OAAO,KAAxB,gBAAgB,CAAC,OAAO,GAAK,EAAE,EAAC;IAEhC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
function _funcConfigHandle(methodsConfig, configList) {
|
|
2
|
-
for (const key in configList) {
|
|
3
|
-
methodsConfig[key] = function (...args) {
|
|
4
|
-
configList[key].forEach(ele => ele.call(this, ...args));
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
export function funcConfigHandle(componentOptions, isPage, funcConfig) {
|
|
9
|
-
if (isPage) {
|
|
10
|
-
funcConfig.pageLifetimes && _funcConfigHandle(componentOptions.methods || (componentOptions.methods = {}), funcConfig.pageLifetimes);
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
funcConfig.pageLifetimes && _funcConfigHandle(componentOptions.pageLifetimes || (componentOptions.pageLifetimes = {}), funcConfig.pageLifetimes);
|
|
14
|
-
}
|
|
15
|
-
funcConfig.lifetimes && _funcConfigHandle(componentOptions.lifetimes || (componentOptions.lifetimes = {}), funcConfig.lifetimes);
|
|
16
|
-
funcConfig.watch && _funcConfigHandle(componentOptions.watch || (componentOptions.watch = {}), funcConfig.watch);
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=funcConfigHandle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"funcConfigHandle.js","sourceRoot":"","sources":["../../src/utils/funcConfigHandle.ts"],"names":[],"mappings":"AAKA,SAAS,iBAAiB,CAAC,aAAqB,EAAE,UAAkC;IAClF,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,aAAa,CAAC,GAAG,CAAC,GAAG,UAAS,GAAG,IAAe;YAC9C,UAAU,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;QAC1D,CAAC,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,gBAAkC,EAClC,MAA2B,EAC3B,UAAsB;IAEtB,IAAI,MAAM,EAAE,CAAC;QAGX,UAAU,CAAC,aAAa,IAAI,iBAAiB,CAAC,gBAAgB,CAAC,OAAO,KAAxB,gBAAgB,CAAC,OAAO,GAAK,EAAE,GAAE,UAAU,CAAC,aAAa,CAAC,CAAC;IAC3G,CAAC;SAAM,CAAC;QAEN,UAAU,CAAC,aAAa,IAAI,iBAAiB,CAAC,gBAAgB,CAAC,aAAa,KAA9B,gBAAgB,CAAC,aAAa,GAAK,EAAE,GAAE,UAAU,CAAC,aAAa,CAAC,CAAC;IACjH,CAAC;IACD,UAAU,CAAC,SAAS,IAAI,iBAAiB,CAAC,gBAAgB,CAAC,SAAS,KAA1B,gBAAgB,CAAC,SAAS,GAAK,EAAE,GAAE,UAAU,CAAC,SAAS,CAAC,CAAC;IAEnG,UAAU,CAAC,KAAK,IAAI,iBAAiB,CAAC,gBAAgB,CAAC,KAAK,KAAtB,gBAAgB,CAAC,KAAK,GAAK,EAAE,GAAE,UAAU,CAAC,KAAK,CAAC,CAAC;AACzF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getPathsValue.js","sourceRoot":"","sources":["../../src/utils/getPathsValue.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,aAAa,CAAiB,KAAe;IAC3D,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,GAAQ,EAAE,IAAI,EAAE,EAAE;QAErC,IAAI,CAAC;YACH,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { deepClone } from "./deepClone";
|
|
2
|
-
import { getPathsValue } from "./getPathsValue";
|
|
3
|
-
export function initWatchOldValue(watchConfig) {
|
|
4
|
-
const watchOldValue = {};
|
|
5
|
-
for (const key in watchConfig) {
|
|
6
|
-
watchOldValue[key] = deepClone(getPathsValue.call(this, key.split(".")));
|
|
7
|
-
}
|
|
8
|
-
return watchOldValue;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=initWatchOldValue.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initWatchOldValue.js","sourceRoot":"","sources":["../../src/utils/initWatchOldValue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,UAAU,iBAAiB,CAAiB,WAAmB;IACnE,MAAM,aAAa,GAAG,EAAE,CAAC;IACzB,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,aAAa,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { deepClone } from "./deepClone";
|
|
2
|
-
export function onLoadHijack(options, before, after = []) {
|
|
3
|
-
options.methods || (options.methods = {});
|
|
4
|
-
const cloneOpt = deepClone(options);
|
|
5
|
-
const originalOnLoad = options.methods.onLoad;
|
|
6
|
-
options.methods.onLoad = function (props) {
|
|
7
|
-
before.forEach((func) => {
|
|
8
|
-
func.call(this, props, cloneOpt);
|
|
9
|
-
});
|
|
10
|
-
originalOnLoad === null || originalOnLoad === void 0 ? void 0 : originalOnLoad.call(this, props);
|
|
11
|
-
after.forEach((func) => {
|
|
12
|
-
func.call(this, props, cloneOpt);
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=onLoadHijack.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"onLoadHijack.js","sourceRoot":"","sources":["../../src/utils/onLoadHijack.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAMxC,MAAM,UAAU,YAAY,CAC1B,OAAyB,EACzB,MAAc,EACd,QAAgB,EAAE;IAElB,OAAO,CAAC,OAAO,KAAf,OAAO,CAAC,OAAO,GAAK,EAAE,EAAC;IAEvB,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,cAAc,GAAqB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC;IAEhE,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,UAAS,KAAc;QAC9C,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACtB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAElC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { INNERMARKER } from "./InnerMarker";
|
|
2
|
-
export function onLoadReceivedDataHandle(option) {
|
|
3
|
-
const innerData = option[INNERMARKER.url];
|
|
4
|
-
if (innerData === undefined)
|
|
5
|
-
return;
|
|
6
|
-
const optionData = JSON.parse(decodeURIComponent(innerData));
|
|
7
|
-
for (const key in optionData) {
|
|
8
|
-
option[key] = optionData[key];
|
|
9
|
-
}
|
|
10
|
-
this.setData(option);
|
|
11
|
-
delete option[INNERMARKER.url];
|
|
12
|
-
delete this.data[INNERMARKER.url];
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=onLoadReceivedDataHandle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"onLoadReceivedDataHandle.js","sourceRoot":"","sources":["../../src/utils/onLoadReceivedDataHandle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAS5C,MAAM,UAAU,wBAAwB,CAEtC,MAA8C;IAE9C,MAAM,SAAS,GAAuB,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAE9D,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO;IACpC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC;IAG7D,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAGD,IAAI,CAAC,OAAO,CAAC,MAAa,CAAC,CAAC;IAE5B,OAAO,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAE/B,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { ComponentOptions, FuncConfig } from "../api/DefineComponent";
|
|
2
|
-
import type { RootComponentDoc } from "../api/RootComponent/RootComponentDoc";
|
|
3
|
-
export declare function rootComponentFieldHandle(rootComponentConfig: RootComponentDoc, componentOptions: ComponentOptions, funcConfig: FuncConfig): void;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { funcFieldsCollect, otherFieldsHandle } from "./collector";
|
|
2
|
-
import { customEventsHandle } from "./customEventsHandle";
|
|
3
|
-
import { eventsHandle } from "./eventsHandle";
|
|
4
|
-
export function rootComponentFieldHandle(rootComponentConfig, componentOptions, funcConfig) {
|
|
5
|
-
rootComponentConfig.customEvents && customEventsHandle(componentOptions, rootComponentConfig.customEvents);
|
|
6
|
-
rootComponentConfig.events && eventsHandle(componentOptions, rootComponentConfig.events);
|
|
7
|
-
rootComponentConfig.pageLifetimes
|
|
8
|
-
&& funcFieldsCollect(rootComponentConfig.pageLifetimes, funcConfig, "pageLifetimes");
|
|
9
|
-
rootComponentConfig.lifetimes && funcFieldsCollect(rootComponentConfig.lifetimes, funcConfig, "lifetimes");
|
|
10
|
-
rootComponentConfig.watch && funcFieldsCollect(rootComponentConfig.watch, funcConfig, "watch");
|
|
11
|
-
otherFieldsHandle(componentOptions, rootComponentConfig);
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=rootComponentFieldHandle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rootComponentFieldHandle.js","sourceRoot":"","sources":["../../src/utils/rootComponentFieldHandle.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,UAAU,wBAAwB,CACtC,mBAAqC,EACrC,gBAAkC,EAClC,UAAsB;IAEtB,mBAAmB,CAAC,YAAY,IAAI,kBAAkB,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;IAE3G,mBAAmB,CAAC,MAAM,IAAI,YAAY,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAIzF,mBAAmB,CAAC,aAAa;WAC5B,iBAAiB,CAAC,mBAAmB,CAAC,aAAa,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;IAEvF,mBAAmB,CAAC,SAAS,IAAI,iBAAiB,CAAC,mBAAmB,CAAC,SAAS,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;IAE3G,mBAAmB,CAAC,KAAK,IAAI,iBAAiB,CAAC,mBAAmB,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAE/F,iBAAiB,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { ComponentOptions, FuncConfig } from "../api/DefineComponent";
|
|
2
|
-
import type { SubComponentOptions } from "../api/SubComponent";
|
|
3
|
-
export declare function subComponentsHandle(componentOptions: ComponentOptions, subComponents: SubComponentOptions[], funcConfig: FuncConfig): void;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { funcFieldsCollect, otherFieldsHandle } from "./collector";
|
|
2
|
-
import { eventsHandle } from "./eventsHandle";
|
|
3
|
-
export function subComponentsHandle(componentOptions, subComponents, funcConfig) {
|
|
4
|
-
subComponents.forEach((subOption) => {
|
|
5
|
-
subOption.events && eventsHandle(componentOptions, subOption.events);
|
|
6
|
-
subOption.pageLifetimes && funcFieldsCollect(subOption.pageLifetimes, funcConfig, "pageLifetimes");
|
|
7
|
-
subOption.lifetimes && funcFieldsCollect(subOption.lifetimes, funcConfig, "lifetimes");
|
|
8
|
-
subOption.watch && funcFieldsCollect(subOption.watch, funcConfig, "watch");
|
|
9
|
-
otherFieldsHandle(componentOptions, subOption);
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=subComponentsHandle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subComponentsHandle.js","sourceRoot":"","sources":["../../src/utils/subComponentsHandle.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,UAAU,mBAAmB,CACjC,gBAAkC,EAClC,aAAoC,EACpC,UAAsB;IAEtB,aAAa,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAClC,SAAS,CAAC,MAAM,IAAI,YAAY,CAAC,gBAAgB,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;QAIrE,SAAS,CAAC,aAAa,IAAI,iBAAiB,CAAC,SAAS,CAAC,aAAa,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;QAEnG,SAAS,CAAC,SAAS,IAAI,iBAAiB,CAAC,SAAS,CAAC,SAAS,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QAEvF,SAAS,CAAC,KAAK,IAAI,iBAAiB,CAAC,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QAE3E,iBAAiB,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Checking, type Test } from "hry-types";
|
|
2
|
-
|
|
3
|
-
import type { InferSpecificType } from "./InferSpecificType";
|
|
4
|
-
import type { SpecificType } from "./SpecificType";
|
|
5
|
-
|
|
6
|
-
Checking<InferSpecificType<StringConstructor>, string, Test.Pass>;
|
|
7
|
-
|
|
8
|
-
Checking<InferSpecificType<NumberConstructor>, number, Test.Pass>;
|
|
9
|
-
|
|
10
|
-
Checking<InferSpecificType<BooleanConstructor>, boolean, Test.Pass>;
|
|
11
|
-
|
|
12
|
-
Checking<InferSpecificType<ArrayConstructor>, unknown[], Test.Pass>;
|
|
13
|
-
|
|
14
|
-
Checking<InferSpecificType<ObjectConstructor>, object, Test.Pass>;
|
|
15
|
-
|
|
16
|
-
Checking<InferSpecificType<SpecificType<"a" | "b">>, "a" | "b", Test.Pass>;
|
|
17
|
-
|
|
18
|
-
Checking<InferSpecificType<SpecificType<[string, number, boolean]>>, [string, number, boolean], Test.Pass>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 通过as SpecificType 指定具体类型。
|
|
3
|
-
* @remarks
|
|
4
|
-
* 在js中使用构造函数(Object,Array等)表示类型时,无法给出明确的类型,SpecificType为此而生
|
|
5
|
-
* @example
|
|
6
|
-
* ``` ts
|
|
7
|
-
* RootComponent()({
|
|
8
|
-
* properties: {
|
|
9
|
-
* gender: String as SpecificType<"male" | "female">,
|
|
10
|
-
* unionArr: Array as SpecificType<string[] | number[]>,
|
|
11
|
-
* },
|
|
12
|
-
* });
|
|
13
|
-
* type PropConstructor<T> =
|
|
14
|
-
| { (): T }
|
|
15
|
-
| { new (...args: never[]): T & object }
|
|
16
|
-
| { new (...args: string[]): Func }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export type SpecificType<T = unknown> = { (): T } | { new(...arg: any[]): T };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 内部保护字段 即不允许配置的字段名(所有方法下)
|
|
3
|
-
*/
|
|
4
|
-
export const INNERFIELDS = ["disposer"];
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 报错的形式避免输入字段和内部字段冲突
|
|
8
|
-
*/
|
|
9
|
-
/* istanbul ignore next */
|
|
10
|
-
export function InternalFieldProtection(methodsConfig: object) {
|
|
11
|
-
const fields = ["disposer"];
|
|
12
|
-
const methodsConfigKeys = Object.keys(methodsConfig);
|
|
13
|
-
for (const key of fields) {
|
|
14
|
-
if (methodsConfigKeys.includes(key)) {
|
|
15
|
-
throw Error(`${key}已被内部字段占用`);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|