annil 1.0.1 → 1.0.4
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 +12 -0
- package/README.md +36 -6
- 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 +2 -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/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/Properties/test/normalOptional.test.js +15 -0
- package/dist/api/RootComponent/Properties/test/normalOptional.test.js.map +1 -1
- 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/index.d.ts +1 -1
- package/dist/api/SubComponent/index.js.map +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/types/OfficialTypeAlias.d.ts +2 -2
- package/package.json +3 -3
- package/src/api/DefineComponent/collectOptionsForComponent.ts +290 -0
- package/src/api/DefineComponent/index.ts +12 -85
- package/src/api/RootComponent/CustomEvents/CustomEventConstraint.ts +3 -1
- package/src/api/RootComponent/Data/DataConstraint.ts +1 -0
- 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/Properties/test/normalOptional.test.ts +20 -0
- package/src/api/RootComponent/index.ts +19 -3
- package/src/api/SubComponent/index.ts +2 -3
- 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/types/OfficialTypeAlias.ts +2 -2
- package/src/types/SpecificType.ts +0 -4
- package/tsconfig.json +6 -15
- 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/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
|
@@ -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
|
},
|
|
@@ -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
|
/**
|
|
@@ -10,10 +10,6 @@
|
|
|
10
10
|
* unionArr: Array as SpecificType<string[] | number[]>,
|
|
11
11
|
* },
|
|
12
12
|
* });
|
|
13
|
-
* type PropConstructor<T> =
|
|
14
|
-
| { (): T }
|
|
15
|
-
| { new (...args: never[]): T & object }
|
|
16
|
-
| { new (...args: string[]): Func }
|
|
17
13
|
* ```
|
|
18
14
|
*/
|
|
19
15
|
export type SpecificType<T = unknown> = { (): T } | { new(...arg: any[]): T };
|
package/tsconfig.json
CHANGED
|
@@ -1,37 +1,28 @@
|
|
|
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
|
|
25
|
+
// 指定加载包的路径,默认加载所有@types下的包 包含上级目录
|
|
35
26
|
"types": ["./node_modules/hry-types", "./node_modules/mobx", "jest", "./node_modules/miniprogram-api-typings/"]
|
|
36
27
|
},
|
|
37
28
|
"include": ["**/*.ts"]
|
|
@@ -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
|
-
/**
|
|
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
|
-
}
|
package/src/utils/collector.ts
DELETED
|
@@ -1,41 +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
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 把配置为函数的字段方法收集到funcConfig中
|
|
7
|
-
*/
|
|
8
|
-
export function funcFieldsCollect(
|
|
9
|
-
config: Record<string, Func>,
|
|
10
|
-
funcConfig: FuncConfig,
|
|
11
|
-
type: "pageLifetimes" | "lifetimes" | "watch",
|
|
12
|
-
) {
|
|
13
|
-
for (const key in config) {
|
|
14
|
-
const handler = config[key];
|
|
15
|
-
// 收集声明周期函数
|
|
16
|
-
const tempCache: object = funcConfig[type] ||= {};
|
|
17
|
-
const filedList: Func[] = tempCache[key] ||= [];
|
|
18
|
-
|
|
19
|
-
filedList.push(handler);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// 其他字段加入到componentOptions对应字段配置中
|
|
24
|
-
export function otherFieldsHandle(
|
|
25
|
-
componentOptions: ComponentOptions,
|
|
26
|
-
rootComponentOptions: Omit<RootComponentDoc, "customEvents" | "events" | "pageLifetimes">,
|
|
27
|
-
) {
|
|
28
|
-
for (const key in rootComponentOptions) {
|
|
29
|
-
const config = rootComponentOptions[key];
|
|
30
|
-
// 好像只有behaviors是数组吧?.
|
|
31
|
-
|
|
32
|
-
if (Array.isArray(config)) {
|
|
33
|
-
/* istanbul ignore next */
|
|
34
|
-
componentOptions[key] ||= [];
|
|
35
|
-
|
|
36
|
-
componentOptions[key].push(...config);
|
|
37
|
-
} else {
|
|
38
|
-
Object.assign(componentOptions[key] ||= {}, config);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// export function createdHijack(
|
|
2
|
-
// componentOptions: ComponentOptions,
|
|
3
|
-
// before: Func[] = [],
|
|
4
|
-
// after: Func[] = [],
|
|
5
|
-
// ) {
|
|
6
|
-
// const lifetimes = componentOptions.lifetimes ||= {};
|
|
7
|
-
// // const originalOptions = deepClone(options);
|
|
8
|
-
// const originalCreatedFn = lifetimes.created;
|
|
9
|
-
|
|
10
|
-
// lifetimes.created = function() {
|
|
11
|
-
// before.forEach((func) => {
|
|
12
|
-
// func.call(this, componentOptions);
|
|
13
|
-
// });
|
|
14
|
-
|
|
15
|
-
// originalCreatedFn && originalCreatedFn.call(this);
|
|
16
|
-
|
|
17
|
-
// after.forEach((func) => {
|
|
18
|
-
// func.call(this, componentOptions);
|
|
19
|
-
// });
|
|
20
|
-
// };
|
|
21
|
-
// }
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { ComponentOptions } from "../api/DefineComponent";
|
|
2
|
-
import type { FullCustomEvents, ShortCustomeEvents } from "../api/RootComponent/CustomEvents/CustomEventConstraint";
|
|
3
|
-
import type { Instance } from "../behaviors/BComputedAndWatch/types";
|
|
4
|
-
// 类型守卫
|
|
5
|
-
function IsFullCustomEvents(
|
|
6
|
-
customEventOptions: FullCustomEvents | ShortCustomeEvents,
|
|
7
|
-
): customEventOptions is FullCustomEvents {
|
|
8
|
-
return Object.prototype.toString.call(customEventOptions) === "[object Object]";
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 把customEvents字段配置变成函数放入到componentOptions.methods中
|
|
13
|
-
*/
|
|
14
|
-
export function customEventsHandle(componentOptions: ComponentOptions, customEventsConfig: object) {
|
|
15
|
-
/* istanbul ignore next */
|
|
16
|
-
componentOptions.methods ||= {};
|
|
17
|
-
|
|
18
|
-
for (const key in customEventsConfig) {
|
|
19
|
-
const customEventOptions = customEventsConfig[key];
|
|
20
|
-
|
|
21
|
-
if (IsFullCustomEvents(customEventOptions)) {
|
|
22
|
-
componentOptions.methods[key] = function(detail: unknown) {
|
|
23
|
-
(this as unknown as Instance).triggerEvent(key, detail, customEventOptions.options);
|
|
24
|
-
};
|
|
25
|
-
} else {
|
|
26
|
-
componentOptions.methods[key] = function(detail: unknown) {
|
|
27
|
-
(this as unknown as Instance).triggerEvent(key, detail);
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ComponentOptions } from "../api/DefineComponent";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 把customEvents字段配置变成函数放入到componentOptions.methods中
|
|
5
|
-
*/
|
|
6
|
-
export function eventsHandle(componentOptions: ComponentOptions, eventsConfig: object) {
|
|
7
|
-
componentOptions.methods ||= {};
|
|
8
|
-
|
|
9
|
-
Object.assign(componentOptions.methods, eventsConfig);
|
|
10
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Func } from "hry-types/src/Misc/_api";
|
|
2
|
-
import type { ComponentOptions, FuncConfig } from "../api/DefineComponent";
|
|
3
|
-
/**
|
|
4
|
-
* 把函数配置放入一个配置中依次运行
|
|
5
|
-
*/
|
|
6
|
-
function _funcConfigHandle(methodsConfig: object, configList: Record<string, Func[]>) {
|
|
7
|
-
for (const key in configList) {
|
|
8
|
-
methodsConfig[key] = function(...args: unknown[]) {
|
|
9
|
-
configList[key].forEach(ele => ele.call(this, ...args));
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function funcConfigHandle(
|
|
15
|
-
componentOptions: ComponentOptions,
|
|
16
|
-
isPage: boolean | undefined,
|
|
17
|
-
funcConfig: FuncConfig,
|
|
18
|
-
) {
|
|
19
|
-
if (isPage) {
|
|
20
|
-
// 页面时 生命周期方法(即 on 开头的方法),(https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/component.html)
|
|
21
|
-
// 测试框架无法测试page特性
|
|
22
|
-
funcConfig.pageLifetimes && _funcConfigHandle(componentOptions.methods ||= {}, funcConfig.pageLifetimes);
|
|
23
|
-
} else {
|
|
24
|
-
// 组件时
|
|
25
|
-
funcConfig.pageLifetimes && _funcConfigHandle(componentOptions.pageLifetimes ||= {}, funcConfig.pageLifetimes);
|
|
26
|
-
}
|
|
27
|
-
funcConfig.lifetimes && _funcConfigHandle(componentOptions.lifetimes ||= {}, funcConfig.lifetimes);
|
|
28
|
-
|
|
29
|
-
funcConfig.watch && _funcConfigHandle(componentOptions.watch ||= {}, funcConfig.watch);
|
|
30
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Instance, WatchOldValue } from "../behaviors/BComputedAndWatch/types";
|
|
2
|
-
import { deepClone } from "./deepClone";
|
|
3
|
-
import { getPathsValue } from "./getPathsValue";
|
|
4
|
-
|
|
5
|
-
export function initWatchOldValue(this: Instance, watchConfig: object): WatchOldValue {
|
|
6
|
-
const watchOldValue = {};
|
|
7
|
-
for (const key in watchConfig) {
|
|
8
|
-
watchOldValue[key] = deepClone(getPathsValue.call(this, key.split(".")));
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return watchOldValue;
|
|
12
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Func } from "hry-types/src/Misc/Func";
|
|
2
|
-
import type { ComponentOptions } from "../api/DefineComponent";
|
|
3
|
-
import { deepClone } from "./deepClone";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* onLoad生命周期劫持函数
|
|
7
|
-
*/
|
|
8
|
-
/* istanbul ignore next */
|
|
9
|
-
export function onLoadHijack(
|
|
10
|
-
options: ComponentOptions,
|
|
11
|
-
before: Func[],
|
|
12
|
-
after: Func[] = [],
|
|
13
|
-
) {
|
|
14
|
-
options.methods ||= {};
|
|
15
|
-
|
|
16
|
-
const cloneOpt = deepClone(options);
|
|
17
|
-
const originalOnLoad: Func | undefined = options.methods.onLoad;
|
|
18
|
-
|
|
19
|
-
options.methods.onLoad = function(props: unknown) {
|
|
20
|
-
before.forEach((func) => {
|
|
21
|
-
func.call(this, props, cloneOpt);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
originalOnLoad?.call(this, props);
|
|
25
|
-
|
|
26
|
-
after.forEach((func) => {
|
|
27
|
-
func.call(this, props, cloneOpt);
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
}
|