annil 1.1.2 → 1.2.0-beta.1
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 +14 -0
- package/dist/api/DefineComponent/collectOptionsForComponent.js +27 -73
- package/dist/api/DefineComponent/collectOptionsForComponent.js.map +1 -1
- package/dist/api/DefineComponent/index.d.ts +11 -11
- package/dist/api/DefineComponent/index.js.map +1 -1
- package/dist/api/RootComponent/index.d.ts +5 -6
- package/dist/api/RootComponent/index.js.map +1 -1
- package/dist/api/SubComponent/SubPageLifetimes/SubPageLifetimesOption.d.ts +1 -1
- package/dist/api/SubComponent/index.d.ts +16 -9
- package/dist/api/SubComponent/index.js.map +1 -1
- package/dist/behaviors/BStore.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/InnerMarker.js +1 -1
- package/dist/utils/InnerMarker.js.map +1 -1
- package/dist/utils/deepClone.js.map +1 -1
- package/package.json +1 -1
- package/src/api/DefineComponent/collectOptionsForComponent.ts +146 -120
- package/src/api/DefineComponent/index.ts +12 -8
- package/src/api/RootComponent/PageLifetimes/PageLifetimesOption.ts +2 -2
- package/src/api/RootComponent/index.ts +7 -4
- package/src/api/SubComponent/SubPageLifetimes/SubPageLifetimesOption.ts +2 -2
- package/src/api/SubComponent/index.ts +19 -12
- package/src/behaviors/BStore.ts +2 -4
- package/src/index.ts +3 -7
- package/src/utils/InnerMarker.ts +1 -1
- package/src/utils/deepClone.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
* 解决DetailedType不接收接口类型的错误 ([ae8acbf](https://github.com/missannil/annil/commit/ae8acbfc2e62f99db565c448ad9253aa549e78bb))
|
|
6
6
|
|
|
7
|
+
## [1.2.0-beta.1](https://github.com/missannil/annil/compare/v1.2.0-beta.0...v1.2.0-beta.1) (2023-12-07)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* 组件/页面接受load和onLoad是参数解析的问题 ([d4b13f9](https://github.com/missannil/annil/commit/d4b13f95679dd5ea81f872991403fe4bb3cfd448))
|
|
13
|
+
|
|
14
|
+
## [1.2.0-beta.0](https://github.com/missannil/annil/compare/v1.1.2...v1.2.0-beta.0) (2023-12-07)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* 页面onLoad和组件pageLifetimes.load周期参数使用encodeURI加密和解析 ([8b5cc6e](https://github.com/missannil/annil/commit/8b5cc6ee65abb0def005126c9382a07b8affc0ca))
|
|
20
|
+
|
|
7
21
|
## [1.1.2](https://github.com/missannil/annil/compare/v1.1.1...v1.1.2) (2023-12-06)
|
|
8
22
|
|
|
9
23
|
|
|
@@ -2,47 +2,33 @@ import { BBeforeCreate } from "../../behaviors/BbeforeCreated";
|
|
|
2
2
|
import { BComputedAndWatch } from "../../behaviors/BComputedAndWatch";
|
|
3
3
|
import { initComputed } from "../../behaviors/BComputedAndWatch/initComputed";
|
|
4
4
|
import { BStore } from "../../behaviors/BStore";
|
|
5
|
-
import { deepClone } from "../../utils/deepClone";
|
|
6
5
|
import { INNERMARKER } from "../../utils/InnerMarker";
|
|
7
6
|
import { isEmptyObject } from "../../utils/isEmptyObject";
|
|
8
7
|
function onLoadReceivedDataHandle(option) {
|
|
9
8
|
const innerData = option[INNERMARKER.url];
|
|
10
|
-
if (innerData
|
|
9
|
+
if (innerData !== INNERMARKER.url)
|
|
11
10
|
return;
|
|
12
|
-
const optionData = JSON.parse(decodeURIComponent(innerData));
|
|
13
|
-
for (const key in optionData) {
|
|
14
|
-
option[key] = optionData[key];
|
|
15
|
-
}
|
|
16
|
-
this.setData(option);
|
|
17
11
|
delete option[INNERMARKER.url];
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
function onLoadHijack(options, before, after = []) {
|
|
21
|
-
options.methods || (options.methods = {});
|
|
22
|
-
const cloneOpt = deepClone(options);
|
|
23
|
-
const originalOnLoad = options.methods.onLoad;
|
|
24
|
-
options.methods.onLoad = function (props) {
|
|
25
|
-
before.forEach((func) => {
|
|
26
|
-
func.call(this, props, cloneOpt);
|
|
27
|
-
});
|
|
28
|
-
originalOnLoad === null || originalOnLoad === void 0 ? void 0 : originalOnLoad.call(this, props);
|
|
29
|
-
after.forEach((func) => {
|
|
30
|
-
func.call(this, props, cloneOpt);
|
|
31
|
-
});
|
|
32
|
-
};
|
|
12
|
+
this.setData(option);
|
|
33
13
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
14
|
+
function loadReceivedDataHandle(option) {
|
|
15
|
+
const innerData = option[INNERMARKER.url];
|
|
16
|
+
if (innerData === undefined)
|
|
17
|
+
return;
|
|
18
|
+
const decodeOption = JSON.parse(decodeURIComponent(innerData));
|
|
19
|
+
for (const key in decodeOption) {
|
|
20
|
+
option[key] = decodeOption[key];
|
|
21
|
+
}
|
|
22
|
+
option[INNERMARKER.url] = INNERMARKER.url;
|
|
23
|
+
}
|
|
24
|
+
function hijack(config, field, before = [], after = []) {
|
|
25
|
+
const originalFunc = config[field];
|
|
26
|
+
config[field] = function (...args) {
|
|
27
|
+
before.forEach(func => func.call(this, ...args));
|
|
28
|
+
originalFunc && originalFunc.apply(this, args);
|
|
29
|
+
after.forEach(func => func.call(this, ...args));
|
|
45
30
|
};
|
|
31
|
+
return;
|
|
46
32
|
}
|
|
47
33
|
function InternalFieldProtection(config, keys) {
|
|
48
34
|
if (!config)
|
|
@@ -124,40 +110,7 @@ function customEventsHandle(componentOptions, customEventsConfig) {
|
|
|
124
110
|
}
|
|
125
111
|
}
|
|
126
112
|
}
|
|
127
|
-
function triggerCompLoad(props) {
|
|
128
|
-
if (!this.__compLoadList__)
|
|
129
|
-
return;
|
|
130
|
-
this.__compLoadList__.forEach((loadFunc) => {
|
|
131
|
-
loadFunc(props);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
function getPageInstance(pageId) {
|
|
135
|
-
const pagestack = getCurrentPages();
|
|
136
|
-
let pageInstance;
|
|
137
|
-
pagestack.some((instance) => {
|
|
138
|
-
if (instance.getPageId() === pageId) {
|
|
139
|
-
pageInstance = instance;
|
|
140
|
-
return true;
|
|
141
|
-
}
|
|
142
|
-
return false;
|
|
143
|
-
});
|
|
144
|
-
return pageInstance;
|
|
145
|
-
}
|
|
146
|
-
function collectLoadLifetimesOfComponent(finalOptionsForComponent) {
|
|
147
|
-
var _a;
|
|
148
|
-
const loadFunc = (_a = finalOptionsForComponent.pageLifetimes) === null || _a === void 0 ? void 0 : _a.load;
|
|
149
|
-
console.log(loadFunc, finalOptionsForComponent);
|
|
150
|
-
if (!loadFunc)
|
|
151
|
-
return;
|
|
152
|
-
const pageInstance = getPageInstance(this.getPageId());
|
|
153
|
-
const __compLoadList__ = (pageInstance.__compLoadList__ || (pageInstance.__compLoadList__ = []));
|
|
154
|
-
__compLoadList__.push(loadFunc.bind(this));
|
|
155
|
-
}
|
|
156
113
|
function collectRootComponentOption(finalOptions, funcOptions, rootComponentOptions) {
|
|
157
|
-
console.log("-------------------------");
|
|
158
|
-
InternalFieldProtection(rootComponentOptions.customEvents, ["load"]);
|
|
159
|
-
InternalFieldProtection(rootComponentOptions.methods, ["load"]);
|
|
160
|
-
InternalFieldProtection(rootComponentOptions.events, ["load"]);
|
|
161
114
|
rootComponentOptions.customEvents && customEventsHandle(finalOptions, rootComponentOptions.customEvents);
|
|
162
115
|
delete rootComponentOptions.customEvents;
|
|
163
116
|
rootComponentOptions.events && eventsHandle(finalOptions, rootComponentOptions.events);
|
|
@@ -166,8 +119,10 @@ function collectRootComponentOption(finalOptions, funcOptions, rootComponentOpti
|
|
|
166
119
|
otherFieldsHandle(finalOptions, rootComponentOptions);
|
|
167
120
|
}
|
|
168
121
|
export function collectOptionsForComponent(rootComponentOption, subComponentsList) {
|
|
122
|
+
var _a, _b;
|
|
169
123
|
const finalOptionsForComponent = {
|
|
170
124
|
options: {
|
|
125
|
+
addGlobalClass: true,
|
|
171
126
|
multipleSlots: true,
|
|
172
127
|
pureDataPattern: /^_/,
|
|
173
128
|
virtualHost: true,
|
|
@@ -185,17 +140,16 @@ export function collectOptionsForComponent(rootComponentOption, subComponentsLis
|
|
|
185
140
|
if (subComponentsList && !isEmptyObject(subComponentsList)) {
|
|
186
141
|
subComponentsHandle(finalOptionsForComponent, subComponentsList, funcOptions);
|
|
187
142
|
}
|
|
188
|
-
|
|
189
|
-
funcConfigHandle(finalOptionsForComponent, rootComponentOption === null || rootComponentOption === void 0 ? void 0 : rootComponentOption.isPage, funcOptions);
|
|
190
|
-
}
|
|
143
|
+
funcConfigHandle(finalOptionsForComponent, rootComponentOption === null || rootComponentOption === void 0 ? void 0 : rootComponentOption.isPage, funcOptions);
|
|
191
144
|
finalOptionsForComponent.methods && InternalFieldProtection(finalOptionsForComponent.methods, ["disposer"]);
|
|
192
|
-
finalOptionsForComponent.
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
145
|
+
((_a = finalOptionsForComponent.methods) === null || _a === void 0 ? void 0 : _a.onLoad)
|
|
146
|
+
&& hijack(finalOptionsForComponent.methods, "onLoad", [onLoadReceivedDataHandle, initComputed], []);
|
|
147
|
+
((_b = finalOptionsForComponent.pageLifetimes) === null || _b === void 0 ? void 0 : _b.load)
|
|
148
|
+
&& hijack(finalOptionsForComponent.pageLifetimes, "load", [loadReceivedDataHandle], []);
|
|
196
149
|
if (finalOptionsForComponent.isPage) {
|
|
197
150
|
Reflect.deleteProperty(finalOptionsForComponent.options, "virtualHost");
|
|
198
151
|
}
|
|
152
|
+
finalOptionsForComponent.behaviors.push(BBeforeCreate);
|
|
199
153
|
return finalOptionsForComponent;
|
|
200
154
|
}
|
|
201
155
|
//# sourceMappingURL=collectOptionsForComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectOptionsForComponent.js","sourceRoot":"","sources":["../../../src/api/DefineComponent/collectOptionsForComponent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAE9E,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"collectOptionsForComponent.js","sourceRoot":"","sources":["../../../src/api/DefineComponent/collectOptionsForComponent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAE9E,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAmB1D,SAAS,wBAAwB,CAE/B,MAA8C;IAE9C,MAAM,SAAS,GAAuB,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAG9D,IAAI,SAAS,KAAK,WAAW,CAAC,GAAG;QAAE,OAAO;IAE1C,OAAO,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAE/B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACvB,CAAC;AAMD,SAAS,sBAAsB,CAE7B,MAA8C;IAE9C,MAAM,SAAS,GAAuB,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAE9D,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO;IACpC,MAAM,YAAY,GAAG,IAAI,CAAC,KAA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AC,CAAC;IAG1F,IAAI,wBAAwB,CAAC,MAAM,EAAE,CAAC;QAEpC,OAAO,CAAC,cAAc,CAAC,wBAAwB,CAAC,OAAQ,EAAE,aAAa,CAAC,CAAC;IAC3E,CAAC;IAED,wBAAwB,CAAC,SAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAExD,OAAO,wBAAwB,CAAC;AAClC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
2
|
import type { Func } from "hry-types/src/Misc/Func";
|
|
3
|
-
import type { WMComponent
|
|
3
|
+
import type { WMComponent } from "../../types/OfficialTypeAlias";
|
|
4
4
|
import type { LifetimesConstraint } from "../RootComponent/Lifetimes/LifetimesConstraint";
|
|
5
5
|
import type { RootComponentDoc } from "../RootComponent/RootComponentDoc";
|
|
6
6
|
import type { SubComponentDoc } from "../SubComponent/SubComponentDoc";
|
|
@@ -9,6 +9,11 @@ import type { CreateComponentDoc } from "./ReturnType/CreateComponentDoc";
|
|
|
9
9
|
import type { CreatePageDoc } from "./ReturnType/CreatePageDoc";
|
|
10
10
|
import type { RootComponentOption } from "./RootComponent/RootComponentOption";
|
|
11
11
|
import type { SubComponentsOption } from "./SubComponents/SubComponentsOption";
|
|
12
|
+
import type { ComputedConstraint } from "../RootComponent/Computed/ComputedConstraint";
|
|
13
|
+
import type { DataConstraint } from "../RootComponent/Data/DataConstraint";
|
|
14
|
+
import type { MethodsConstraint } from "../RootComponent/Methods/MethodsConstraint";
|
|
15
|
+
import type { PageLifetimesOption } from "../RootComponent/PageLifetimes/PageLifetimesOption";
|
|
16
|
+
import type { StoreConstraint } from "../RootComponent/Store/StoreConstraint";
|
|
12
17
|
type Path = `/${string}`;
|
|
13
18
|
type RootOptions<TRootComponentDoc extends RootComponentDoc, TSubComponentTuple extends SubComponentDoc[], TName extends string, TPath extends Path> = NameOrPathOption<TName, TPath, TRootComponentDoc["isPage"] & {}> & RootComponentOption<TRootComponentDoc> & SubComponentsOption<TSubComponentTuple>;
|
|
14
19
|
interface DefineComponentConstructor {
|
|
@@ -19,19 +24,14 @@ export type FinalOptionsOfComponent = {
|
|
|
19
24
|
isPage?: boolean;
|
|
20
25
|
options?: WMComponent.Options;
|
|
21
26
|
properties?: Record<string, any>;
|
|
22
|
-
data?:
|
|
23
|
-
store?:
|
|
24
|
-
computed?:
|
|
27
|
+
data?: DataConstraint;
|
|
28
|
+
store?: StoreConstraint;
|
|
29
|
+
computed?: ComputedConstraint;
|
|
25
30
|
observers?: Record<string, Func>;
|
|
26
31
|
behaviors?: string[];
|
|
27
|
-
methods?:
|
|
28
|
-
__storeConfig__?: Func;
|
|
29
|
-
};
|
|
32
|
+
methods?: MethodsConstraint;
|
|
30
33
|
watch?: Record<string, Func>;
|
|
31
34
|
lifetimes?: LifetimesConstraint;
|
|
32
|
-
|
|
33
|
-
load: (prop: unknown) => void;
|
|
34
|
-
} & WMPageLifetimes>;
|
|
35
|
-
};
|
|
35
|
+
} & PageLifetimesOption<false, object>;
|
|
36
36
|
export declare const DefineComponent: DefineComponentConstructor;
|
|
37
37
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/DefineComponent/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/DefineComponent/index.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAwD1E,MAAM,CAAC,MAAM,eAAe,GAA+B,UAAS,OAAO;IACzE,SAAS,CACP,0BAA0B,CAAC,OAAO,CAAC,aAAyC,EAAE,OAAO,CAAC,aAAa,CAAC,CACrG,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
|
-
import type { NoInfer } from "hry-types/src/Generic/NoInfer";
|
|
3
2
|
import type { EmptyObject } from "hry-types/src/Misc/EmptyObject";
|
|
4
3
|
import type { Func } from "hry-types/src/Misc/Func";
|
|
5
4
|
import type { ComputeIntersection } from "hry-types/src/Object/_api";
|
|
6
5
|
import type { ComputeObject } from "../../types/ComputeObj";
|
|
7
|
-
import type { WMCompOtherOption
|
|
6
|
+
import type { WMCompOtherOption } from "../../types/OfficialTypeAlias";
|
|
8
7
|
import type { ComponentDoc } from "../DefineComponent/ReturnType/ComponentDoc";
|
|
9
8
|
import type { ComputedConstraint } from "./Computed/ComputedConstraint";
|
|
10
9
|
import type { ComputedOption } from "./Computed/ComputedOption";
|
|
@@ -30,7 +29,7 @@ import type { GetStoreDoc } from "./Store/GeTStoreDoc";
|
|
|
30
29
|
import type { StoreConstraint } from "./Store/StoreConstraint";
|
|
31
30
|
import type { StoreOption } from "./Store/StoreOption";
|
|
32
31
|
import type { WatchOption } from "./Watch/WatchOption";
|
|
33
|
-
type RootComponentOptions<TEvents extends object, TIsPage extends boolean, TCustomEvents extends CustomEventConstraint, TMethods extends MethodsConstraint, TProperties extends PropertiesConstraint, TData extends object, TStore extends StoreConstraint, TComputed extends Record<string, Func>, EventsDoc extends object, CustomEventsDoc extends object, PropertiesDoc extends object, DataDoc extends object, StoreDoc extends object, ComputedDoc extends object> = MethodsOption<TMethods, keyof (EventsDoc & CustomEventsDoc)> & PropertiesOption<TProperties> & IsPageOption<TIsPage> & EventsOption<TEvents> & CustomEventsOption<TCustomEvents, keyof EventsDoc> & DataOption<TData, keyof PropertiesDoc> & StoreOption<TStore, keyof (PropertiesDoc & DataDoc)> & ComputedOption<TComputed, keyof (PropertiesDoc & DataDoc & StoreDoc)> & PageLifetimesOption<TIsPage,
|
|
32
|
+
type RootComponentOptions<TEvents extends object, TIsPage extends boolean, TCustomEvents extends CustomEventConstraint, TMethods extends MethodsConstraint, TProperties extends PropertiesConstraint, TData extends object, TStore extends StoreConstraint, TComputed extends Record<string, Func>, EventsDoc extends object, CustomEventsDoc extends object, PropertiesDoc extends object, DataDoc extends object, StoreDoc extends object, ComputedDoc extends object> = MethodsOption<TMethods, keyof (EventsDoc & CustomEventsDoc)> & PropertiesOption<TProperties> & IsPageOption<TIsPage> & EventsOption<TEvents> & CustomEventsOption<TCustomEvents, keyof EventsDoc> & DataOption<TData, keyof PropertiesDoc> & StoreOption<TStore, keyof (PropertiesDoc & DataDoc)> & ComputedOption<TComputed, keyof (PropertiesDoc & DataDoc & StoreDoc)> & PageLifetimesOption<TIsPage, 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>>;
|
|
34
33
|
type RootComponentConstructor<TComponentDocList extends ComponentDoc[]> = {
|
|
35
34
|
<TEvents extends EventsConstraint<TComponentDocList>, TIsPage extends boolean = false, const TProperties extends PropertiesConstraint = {}, TData extends object = {}, TStore extends StoreConstraint = {}, TComputed extends ComputedConstraint = {}, TCustomEvents extends IfExtends<TIsPage, false, CustomEventConstraint, EmptyObject> = {}, TMethods extends MethodsConstraint = {}, EventsDoc extends object = IfExtends<EventsConstraint<TComponentDocList>, TEvents, {}, TEvents>, CustomEventsDoc extends object = GetCustomEventDoc<TCustomEvents>, PropertiesDoc extends object = GetPropertiesDoc<TProperties, TIsPage>, DataDoc extends object = TData, StoreDoc extends object = GetStoreDoc<TStore>, ComputedDoc extends object = GetComputedDoc<TComputed>>(options: RootComponentOptions<TEvents, TIsPage, TCustomEvents, TMethods, TProperties, TData, TStore, TComputed, EventsDoc, CustomEventsDoc, PropertiesDoc, DataDoc, StoreDoc, ComputedDoc>): ComputeIntersection<IfExtends<TIsPage, false, {}, {
|
|
36
35
|
isPage: true;
|
|
@@ -57,13 +56,13 @@ export type RootComponentTrueOptions = {
|
|
|
57
56
|
data?: DataConstraint;
|
|
58
57
|
computed?: ComputedConstraint;
|
|
59
58
|
customEvents?: CustomEventConstraint;
|
|
59
|
+
observers?: Record<string, Func>;
|
|
60
60
|
methods?: MethodsConstraint;
|
|
61
|
+
behaviors?: string[];
|
|
61
62
|
events?: EventsConstraint;
|
|
62
63
|
store?: StoreConstraint;
|
|
63
64
|
watch?: Record<string, Func>;
|
|
64
65
|
lifetimes?: LifetimesConstraint;
|
|
65
|
-
pageLifetimes?:
|
|
66
|
-
load: Func;
|
|
67
|
-
} & WMPageLifetimes>;
|
|
66
|
+
pageLifetimes?: PageLifetimesOption<false, object>["pageLifetimes"] | PageLifetimesOption<true, object>["pageLifetimes"];
|
|
68
67
|
};
|
|
69
68
|
export {};
|
|
@@ -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":"AA4HA,MAAM,UAAU,aAAa;IAM3B,OAAO,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,OAAmC,CAAQ,CAAC;AACxE,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { PageLifetimesOption } from "../../RootComponent/PageLifetimes/PageLifetimesOption";
|
|
2
|
-
export type SubPageLifetimesOption<TIsPage extends boolean,
|
|
2
|
+
export type SubPageLifetimesOption<TIsPage extends boolean, PropertiesDoc extends object> = PageLifetimesOption<TIsPage, PropertiesDoc>;
|
|
@@ -5,8 +5,15 @@ 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";
|
|
8
|
-
import type {
|
|
8
|
+
import type { WMCompOtherOption } from "../../types/OfficialTypeAlias";
|
|
9
|
+
import type { ComputedConstraint } from "../RootComponent/Computed/ComputedConstraint";
|
|
10
|
+
import type { DataConstraint } from "../RootComponent/Data/DataConstraint";
|
|
11
|
+
import type { EventsConstraint } from "../RootComponent/Events/EventsConstraint";
|
|
12
|
+
import type { LifetimesConstraint } from "../RootComponent/Lifetimes/LifetimesConstraint";
|
|
13
|
+
import type { MethodsConstraint } from "../RootComponent/Methods/MethodsConstraint";
|
|
14
|
+
import type { PageLifetimesOption } from "../RootComponent/PageLifetimes/PageLifetimesOption";
|
|
9
15
|
import type { RootComponentDoc } from "../RootComponent/RootComponentDoc";
|
|
16
|
+
import type { StoreConstraint } from "../RootComponent/Store/StoreConstraint";
|
|
10
17
|
import type { GetSubComputedDoc } from "./SubComputed/GetSubComputedDoc";
|
|
11
18
|
import type { SubComputedConstraint } from "./SubComputed/SubComputedConstraint";
|
|
12
19
|
import type { SubComputedOption } from "./SubComputed/SubComputedOption";
|
|
@@ -34,14 +41,14 @@ type SubComponentConstructor<TRootDoc extends RootComponentDoc, TOriginalCompDoc
|
|
|
34
41
|
export declare function SubComponent<RootDoc extends RootComponentDoc, CompDoc extends ComponentDoc, Prefix extends string = "">(): IfExtends<EmptyObject, CompDoc, (opt: EmptyObject) => never, SubComponentConstructor<RootDoc, CompDoc, Prefix>>;
|
|
35
42
|
export type SubComponentTrueOptions = {
|
|
36
43
|
inhrit?: string;
|
|
37
|
-
data?:
|
|
38
|
-
computed?:
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
data?: DataConstraint;
|
|
45
|
+
computed?: ComputedConstraint;
|
|
46
|
+
store?: StoreConstraint;
|
|
47
|
+
events?: EventsConstraint;
|
|
48
|
+
methods?: MethodsConstraint;
|
|
49
|
+
observers?: Record<string, Func>;
|
|
41
50
|
watch?: Record<string, Func>;
|
|
42
|
-
lifetimes?:
|
|
43
|
-
pageLifetimes?:
|
|
44
|
-
load: Func;
|
|
45
|
-
} & WMPageLifetimes>;
|
|
51
|
+
lifetimes?: LifetimesConstraint;
|
|
52
|
+
pageLifetimes?: PageLifetimesOption<false, object>["pageLifetimes"] | PageLifetimesOption<true, object>["pageLifetimes"];
|
|
46
53
|
};
|
|
47
54
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/SubComponent/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/SubComponent/index.ts"],"names":[],"mappings":"AAwMA,MAAM,UAAU,YAAY;IAK1B,OAAO,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,OAAkC,CAAQ,CAAC;AACvE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BStore.js","sourceRoot":"","sources":["../../src/behaviors/BStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAG7D,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC;IAC7B,gBAAgB,CAAC,OAAgC;QAE/C,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC;QAClC,IAAI,CAAC,WAAW;YAAE,OAAO;QACzB,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAgB,CAAC;QAChD,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;YAC9B,OAAO,CAAC,IAAI,KAAZ,OAAO,CAAC,IAAI,GAAK,EAAE,EAAC;YAEpB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"BStore.js","sourceRoot":"","sources":["../../src/behaviors/BStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAG7D,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC;IAC7B,gBA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,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;QAC5C,CAAC;QAED,QAAQ;YAEN,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAChC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,CAAC;QACH,CAAC;KACF;CACF,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { navigateTo } from "./api/navigateTo";
|
|
2
1
|
import { DefineComponent } from "./api/DefineComponent";
|
|
2
|
+
import { navigateTo } from "./api/navigateTo";
|
|
3
3
|
import { RootComponent } from "./api/RootComponent";
|
|
4
4
|
import { SubComponent } from "./api/SubComponent";
|
|
5
|
-
import type { DetailedType } from "./types/DetailedType";
|
|
6
5
|
import type { ComponentDocExtension } from "./types/ComponentDocExtension";
|
|
6
|
+
import type { DetailedType } from "./types/DetailedType";
|
|
7
7
|
import type { GenerateDoc } from "./types/GenerateDoc";
|
|
8
8
|
import type { ParamsEqual } from "./types/TwoParamsEqual";
|
|
9
9
|
export type { Vant, Wm } from "./thirdLib";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { navigateTo } from "./api/navigateTo";
|
|
2
1
|
import { DefineComponent } from "./api/DefineComponent";
|
|
2
|
+
import { navigateTo } from "./api/navigateTo";
|
|
3
3
|
import { RootComponent } from "./api/RootComponent";
|
|
4
4
|
import { SubComponent } from "./api/SubComponent";
|
|
5
5
|
export { DefineComponent, navigateTo, RootComponent, SubComponent, };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAiBlD,OAAO,EAEL,eAAe,EAIf,UAAU,EAEV,aAAa,EACb,YAAY,GACb,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InnerMarker.js","sourceRoot":"","sources":["../../src/utils/InnerMarker.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"InnerMarker.js","sourceRoot":"","sources":["../../src/utils/InnerMarker.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,GAAG,EAAE,WAAkC;CAExC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepClone.js","sourceRoot":"","sources":["../../src/utils/deepClone.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,SAAS,CAAI,KAAQ;IACnC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;
|
|
1
|
+
{"version":3,"file":"deepClone.js","sourceRoot":"","sources":["../../src/utils/deepClone.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,SAAS,CAAI,KAAQ;IACnC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAM,CAAC;IAEpD,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IAE3D,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;YACrD,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,6 @@ import { BComputedAndWatch } from "../../behaviors/BComputedAndWatch";
|
|
|
4
4
|
import { initComputed } from "../../behaviors/BComputedAndWatch/initComputed";
|
|
5
5
|
import type { Instance } from "../../behaviors/BComputedAndWatch/types";
|
|
6
6
|
import { BStore } from "../../behaviors/BStore";
|
|
7
|
-
import { deepClone } from "../../utils/deepClone";
|
|
8
7
|
import { INNERMARKER } from "../../utils/InnerMarker";
|
|
9
8
|
import { isEmptyObject } from "../../utils/isEmptyObject";
|
|
10
9
|
import type { RootComponentTrueOptions } from "../RootComponent";
|
|
@@ -18,95 +17,127 @@ import type { PageInstance } from "../RootComponent/Instance/RootComponentInstan
|
|
|
18
17
|
import type { SubComponentTrueOptions } from "../SubComponent";
|
|
19
18
|
import type { FinalOptionsOfComponent, FuncOptions } from ".";
|
|
20
19
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* 原生Component会对传入的对象字段匹配的properties字段setData赋值。不符合字段或Page时不会赋值。
|
|
21
|
+
* 此函数为给实例setData赋值,默认传递值与properties相符(ts类型安全)。
|
|
22
|
+
* @param option - 传入onLoad的参数 有以下两种可能
|
|
23
|
+
* 1. 使用wx.navigateTo传值的。这种情况无内置字段 option[INNERMARKER.url] 等于 undefined
|
|
24
|
+
* 2. 使用插件提供的navigateTo传值。这种情况 INNERMARKER.url被load周期劫持函数解码后赋值INNERMARKER.url字段为本身,即option[INNERMARKER.url] 等于 INNERMARKER.url
|
|
23
25
|
*/
|
|
24
|
-
/* istanbul ignore next */
|
|
26
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
25
27
|
function onLoadReceivedDataHandle(
|
|
26
28
|
this: PageInstance,
|
|
27
29
|
option: Record<typeof INNERMARKER.url, string>,
|
|
28
30
|
) {
|
|
29
31
|
const innerData: string | undefined = option[INNERMARKER.url];
|
|
30
|
-
// 未使用自定义的navigateTo
|
|
31
|
-
if (innerData === undefined) return;
|
|
32
|
-
const optionData = JSON.parse(decodeURIComponent(innerData));
|
|
33
32
|
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
option[key] = optionData[key];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// setData会触发计算属性 继承属性等 。
|
|
40
|
-
this.setData(option as any);
|
|
33
|
+
// 情况1为undefined,2为INNERMARKER.url所以innerData !== INNERMARKER.url表示没有通过插件提供的API传值
|
|
34
|
+
if (innerData !== INNERMARKER.url) return;
|
|
41
35
|
|
|
42
36
|
delete option[INNERMARKER.url];
|
|
43
37
|
|
|
44
|
-
|
|
38
|
+
this.setData(option);
|
|
45
39
|
}
|
|
46
|
-
|
|
47
40
|
/**
|
|
48
|
-
*
|
|
41
|
+
* 针对通过 navigateTo传过来的数据对组件load周期传入数据解析
|
|
42
|
+
* @param option - option中的url是拼接了encodeURIComponent转码的data对象的,key为INNERMARKER.url
|
|
49
43
|
*/
|
|
50
|
-
/* istanbul ignore next */
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
after: Func[] = [],
|
|
44
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
45
|
+
function loadReceivedDataHandle(
|
|
46
|
+
this: PageInstance,
|
|
47
|
+
option: Record<typeof INNERMARKER.url, string>,
|
|
55
48
|
) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
options.methods.onLoad = function(props: unknown) {
|
|
62
|
-
before.forEach((func) => {
|
|
63
|
-
func.call(this, props, cloneOpt);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
originalOnLoad?.call(this, props);
|
|
49
|
+
const innerData: string | undefined = option[INNERMARKER.url];
|
|
50
|
+
// 未使用自定义的navigateTo
|
|
51
|
+
if (innerData === undefined) return;
|
|
52
|
+
const decodeOption = JSON.parse(decodeURIComponent(innerData));
|
|
67
53
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
54
|
+
// 使用navigateTo API
|
|
55
|
+
for (const key in decodeOption) {
|
|
56
|
+
option[key] = decodeOption[key];
|
|
57
|
+
}
|
|
58
|
+
// 给onLoad劫持函数一个标记,判断传值来自哪个API
|
|
59
|
+
option[INNERMARKER.url] = INNERMARKER.url;
|
|
72
60
|
}
|
|
73
61
|
/**
|
|
74
|
-
*
|
|
62
|
+
* 劫持指定配置字段
|
|
75
63
|
*/
|
|
76
|
-
/* istanbul ignore next
|
|
77
|
-
function
|
|
78
|
-
|
|
79
|
-
before: Func[],
|
|
80
|
-
after: Func[] = [],
|
|
81
|
-
) {
|
|
82
|
-
/* istanbul ignore next */
|
|
83
|
-
options.lifetimes ||= {};
|
|
64
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
65
|
+
function hijack(config: object, field: string, before: Func[] = [], after: Func[] = []) {
|
|
66
|
+
const originalFunc: Func | undefined = config[field];
|
|
84
67
|
|
|
85
|
-
|
|
68
|
+
config[field] = function(...args: any[]) {
|
|
69
|
+
before.forEach(func => func.call(this, ...args));
|
|
86
70
|
|
|
87
|
-
|
|
88
|
-
before.forEach((func) => {
|
|
89
|
-
func.call(this, options);
|
|
90
|
-
});
|
|
71
|
+
originalFunc && originalFunc.apply(this, args);
|
|
91
72
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
/* istanbul ignore next */
|
|
95
|
-
after.forEach((func) => {
|
|
96
|
-
func.call(this, options);
|
|
97
|
-
});
|
|
73
|
+
after.forEach(func => func.call(this, ...args));
|
|
98
74
|
};
|
|
75
|
+
|
|
76
|
+
return;
|
|
99
77
|
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* onLoad生命周期劫持函数
|
|
81
|
+
*/
|
|
82
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
83
|
+
// function onLoadHijack(
|
|
84
|
+
// options: FinalOptionsOfComponent,
|
|
85
|
+
// before: Func[],
|
|
86
|
+
// after: Func[] = [],
|
|
87
|
+
// ) {
|
|
88
|
+
// options.methods ||= {};
|
|
89
|
+
|
|
90
|
+
// const cloneOpt = deepClone(options);
|
|
91
|
+
// const originalOnLoad: Func | undefined = options.methods.onLoad;
|
|
92
|
+
|
|
93
|
+
// options.methods.onLoad = function(props: unknown) {
|
|
94
|
+
// before.forEach((func) => {
|
|
95
|
+
// func.call(this, props, cloneOpt);
|
|
96
|
+
// });
|
|
97
|
+
|
|
98
|
+
// originalOnLoad?.call(this, props);
|
|
99
|
+
|
|
100
|
+
// after.forEach((func) => {
|
|
101
|
+
// func.call(this, props, cloneOpt);
|
|
102
|
+
// });
|
|
103
|
+
// };
|
|
104
|
+
// }
|
|
105
|
+
/**
|
|
106
|
+
* 劫持pageLifetimes中的load字段
|
|
107
|
+
*/
|
|
108
|
+
/* istanbul ignore next */
|
|
109
|
+
// function loadHijack(
|
|
110
|
+
// options: FinalOptionsOfComponent,
|
|
111
|
+
// before: Func[],
|
|
112
|
+
// after: Func[] = [],
|
|
113
|
+
// ) {
|
|
114
|
+
// /* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
115
|
+
// options.lifetimes ||= {};
|
|
116
|
+
|
|
117
|
+
// const originalAttached: Func | undefined = options.lifetimes.attached;
|
|
118
|
+
|
|
119
|
+
// options.lifetimes.attached = function() {
|
|
120
|
+
// before.forEach((func) => {
|
|
121
|
+
// func.call(this, options);
|
|
122
|
+
// });
|
|
123
|
+
|
|
124
|
+
// originalAttached?.call(this);
|
|
125
|
+
|
|
126
|
+
// /* istanbul ignore next */
|
|
127
|
+
// after.forEach((func) => {
|
|
128
|
+
// func.call(this, options);
|
|
129
|
+
// });
|
|
130
|
+
// };
|
|
131
|
+
// }
|
|
100
132
|
/**
|
|
101
133
|
* 内部保护字段 即不允许配置的字段名(所有方法下)
|
|
102
134
|
*/
|
|
103
135
|
// const INNERFIELDS = ["disposer"];
|
|
104
136
|
|
|
105
137
|
/**
|
|
106
|
-
*
|
|
107
|
-
* 保护config下不被配置keys包含的内部预定字段
|
|
138
|
+
* 报错的形式避免输入字段和内部字段冲突,保证config下不包含内部预定字段(列表)
|
|
108
139
|
*/
|
|
109
|
-
/* istanbul ignore next */
|
|
140
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
110
141
|
function InternalFieldProtection(config: object | undefined, keys: string[]) {
|
|
111
142
|
if (!config) return;
|
|
112
143
|
const methodsConfigKeys = Object.keys(config);
|
|
@@ -126,14 +157,16 @@ function _funcConfigHandle(methodsConfig: object, configList: Record<string, Fun
|
|
|
126
157
|
};
|
|
127
158
|
}
|
|
128
159
|
}
|
|
129
|
-
|
|
160
|
+
/**
|
|
161
|
+
* 把函数列表配置放入一个配置中循环一次运行
|
|
162
|
+
*/
|
|
130
163
|
function funcConfigHandle(
|
|
131
164
|
finalOptionsForComponent: FinalOptionsOfComponent,
|
|
132
165
|
isPage: boolean | undefined,
|
|
133
166
|
funcOptions: FuncOptions,
|
|
134
167
|
) {
|
|
135
168
|
// 测试框架无法测试page情形
|
|
136
|
-
/* istanbul ignore next */
|
|
169
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
137
170
|
if (isPage) {
|
|
138
171
|
// 页面时 生命周期方法(即 on 开头的方法),(https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/component.html)
|
|
139
172
|
funcOptions.pageLifetimes && _funcConfigHandle(finalOptionsForComponent.methods ||= {}, funcOptions.pageLifetimes);
|
|
@@ -165,7 +198,9 @@ function funcFieldsCollect(
|
|
|
165
198
|
}
|
|
166
199
|
}
|
|
167
200
|
|
|
168
|
-
|
|
201
|
+
/**
|
|
202
|
+
* 其他字段加入到componentOptions对应字段配置中
|
|
203
|
+
*/
|
|
169
204
|
function otherFieldsHandle(
|
|
170
205
|
finalOptions: FinalOptionsOfComponent,
|
|
171
206
|
rootComponentOptions: RootComponentTrueOptions,
|
|
@@ -174,7 +209,7 @@ function otherFieldsHandle(
|
|
|
174
209
|
const config = rootComponentOptions[key];
|
|
175
210
|
if (Array.isArray(config)) {
|
|
176
211
|
// 好像只有behaviors是数组吧.
|
|
177
|
-
/* istanbul ignore next */
|
|
212
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
178
213
|
(finalOptions[key] ||= []).push(...config);
|
|
179
214
|
} else {
|
|
180
215
|
Object.assign(finalOptions[key] ||= {}, config);
|
|
@@ -182,10 +217,10 @@ function otherFieldsHandle(
|
|
|
182
217
|
}
|
|
183
218
|
}
|
|
184
219
|
/**
|
|
185
|
-
* 把events
|
|
220
|
+
* 把events字段放入到componentOptions.methods中
|
|
186
221
|
*/
|
|
187
222
|
function eventsHandle(componentOptions: FinalOptionsOfComponent, eventsConfig: EventsConstraint) {
|
|
188
|
-
/* istanbul ignore next */
|
|
223
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
189
224
|
componentOptions.methods ||= {};
|
|
190
225
|
|
|
191
226
|
Object.assign(componentOptions.methods, eventsConfig);
|
|
@@ -218,7 +253,7 @@ function customEventsHandle(
|
|
|
218
253
|
componentOptions: FinalOptionsOfComponent,
|
|
219
254
|
customEventsConfig: CustomEventConstraint,
|
|
220
255
|
) {
|
|
221
|
-
/* istanbul ignore next */
|
|
256
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
222
257
|
componentOptions.methods ||= {};
|
|
223
258
|
|
|
224
259
|
for (const key in customEventsConfig) {
|
|
@@ -239,45 +274,45 @@ function customEventsHandle(
|
|
|
239
274
|
* 触发各个组件的页面load事件
|
|
240
275
|
*/
|
|
241
276
|
/* istanbul ignore next */
|
|
242
|
-
function triggerCompLoad(this: Instance, props: object) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
277
|
+
// function triggerCompLoad(this: Instance, props: object) {
|
|
278
|
+
// if (!this.__compLoadList__) return;
|
|
279
|
+
// this.__compLoadList__.forEach((loadFunc) => {
|
|
280
|
+
// loadFunc(props);
|
|
281
|
+
// });
|
|
282
|
+
// }
|
|
248
283
|
/* istanbul ignore next */
|
|
249
|
-
function getPageInstance(pageId: string): Instance {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
}
|
|
284
|
+
// function getPageInstance(pageId: string): Instance {
|
|
285
|
+
// const pagestack = getCurrentPages() as unknown as Instance[];
|
|
286
|
+
// let pageInstance: Instance;
|
|
287
|
+
// pagestack.some((instance) => {
|
|
288
|
+
// if (instance.getPageId() === pageId) {
|
|
289
|
+
// pageInstance = instance;
|
|
290
|
+
|
|
291
|
+
// return true;
|
|
292
|
+
// }
|
|
293
|
+
|
|
294
|
+
// return false;
|
|
295
|
+
// });
|
|
296
|
+
|
|
297
|
+
// // @ts-ignore pagestack中一定赋值了
|
|
298
|
+
// return pageInstance;
|
|
299
|
+
// }
|
|
265
300
|
/**
|
|
266
301
|
* 收集组件pageLifetimes下的load周期函数到页面实例的__loadFunList__
|
|
267
302
|
*/
|
|
268
303
|
/* istanbul ignore next */
|
|
269
|
-
function collectLoadLifetimesOfComponent(this: Instance, finalOptionsForComponent: FinalOptionsOfComponent) {
|
|
270
|
-
|
|
304
|
+
// function collectLoadLifetimesOfComponent(this: Instance, finalOptionsForComponent: FinalOptionsOfComponent) {
|
|
305
|
+
// const loadFunc = finalOptionsForComponent.pageLifetimes?.load;
|
|
271
306
|
|
|
272
|
-
|
|
307
|
+
// console.log(loadFunc, finalOptionsForComponent);
|
|
273
308
|
|
|
274
|
-
|
|
309
|
+
// if (!loadFunc) return;
|
|
275
310
|
|
|
276
|
-
|
|
277
|
-
|
|
311
|
+
// const pageInstance = getPageInstance(this.getPageId());
|
|
312
|
+
// const __compLoadList__: Function[] = (pageInstance.__compLoadList__ ||= []);
|
|
278
313
|
|
|
279
|
-
|
|
280
|
-
}
|
|
314
|
+
// __compLoadList__.push(loadFunc.bind(this));
|
|
315
|
+
// }
|
|
281
316
|
/**
|
|
282
317
|
* 收集 rootComponentOptions 配置到 finalOptions 和 funcOptions 中
|
|
283
318
|
* @param finalOptions - 收集配置对象
|
|
@@ -289,14 +324,6 @@ function collectRootComponentOption(
|
|
|
289
324
|
funcOptions: FuncOptions,
|
|
290
325
|
rootComponentOptions: RootComponentTrueOptions,
|
|
291
326
|
) {
|
|
292
|
-
console.log("-------------------------");
|
|
293
|
-
|
|
294
|
-
InternalFieldProtection(rootComponentOptions.customEvents, ["load"]);
|
|
295
|
-
|
|
296
|
-
InternalFieldProtection(rootComponentOptions.methods, ["load"]);
|
|
297
|
-
|
|
298
|
-
InternalFieldProtection(rootComponentOptions.events, ["load"]);
|
|
299
|
-
|
|
300
327
|
rootComponentOptions.customEvents && customEventsHandle(finalOptions, rootComponentOptions.customEvents);
|
|
301
328
|
|
|
302
329
|
delete rootComponentOptions.customEvents;
|
|
@@ -322,7 +349,7 @@ export function collectOptionsForComponent(
|
|
|
322
349
|
const finalOptionsForComponent: FinalOptionsOfComponent = {
|
|
323
350
|
// default options
|
|
324
351
|
options: {
|
|
325
|
-
|
|
352
|
+
addGlobalClass: true, // "styleIsolation": "apply-shared"
|
|
326
353
|
multipleSlots: true,
|
|
327
354
|
pureDataPattern: /^_/,
|
|
328
355
|
virtualHost: true,
|
|
@@ -346,28 +373,27 @@ export function collectOptionsForComponent(
|
|
|
346
373
|
if (subComponentsList && !isEmptyObject(subComponentsList)) {
|
|
347
374
|
subComponentsHandle(finalOptionsForComponent, subComponentsList, funcOptions);
|
|
348
375
|
}
|
|
349
|
-
//
|
|
350
|
-
/* istanbul ignore next */
|
|
351
|
-
|
|
352
|
-
funcConfigHandle(finalOptionsForComponent, rootComponentOption?.isPage, funcOptions);
|
|
353
|
-
}
|
|
376
|
+
// miniprogram-simulate(当前版本 1.6.1) 无法测试页面
|
|
377
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
378
|
+
funcConfigHandle(finalOptionsForComponent, rootComponentOption?.isPage, funcOptions);
|
|
354
379
|
|
|
355
380
|
finalOptionsForComponent.methods && InternalFieldProtection(finalOptionsForComponent.methods, ["disposer"]);
|
|
356
381
|
|
|
357
|
-
|
|
358
|
-
finalOptionsForComponent.
|
|
359
|
-
|
|
360
|
-
console.log(finalOptionsForComponent, 999, funcOptions);
|
|
361
|
-
|
|
362
|
-
attachedHijack(finalOptionsForComponent, [collectLoadLifetimesOfComponent], []);
|
|
382
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
383
|
+
finalOptionsForComponent.methods?.onLoad
|
|
384
|
+
&& hijack(finalOptionsForComponent.methods, "onLoad", [onLoadReceivedDataHandle, initComputed], []);
|
|
363
385
|
|
|
364
|
-
|
|
386
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
387
|
+
finalOptionsForComponent.pageLifetimes?.load
|
|
388
|
+
&& hijack(finalOptionsForComponent.pageLifetimes, "load", [loadReceivedDataHandle], []);
|
|
365
389
|
|
|
366
|
-
|
|
367
|
-
/* istanbul ignore next */
|
|
390
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
368
391
|
if (finalOptionsForComponent.isPage) {
|
|
392
|
+
// 页面时删除预设的虚拟组件字段
|
|
369
393
|
Reflect.deleteProperty(finalOptionsForComponent.options!, "virtualHost");
|
|
370
394
|
}
|
|
395
|
+
// BBeforeCreate在最后面,让BeforeCreate生命周期运行在最终建立组件时。
|
|
396
|
+
finalOptionsForComponent.behaviors!.push(BBeforeCreate);
|
|
371
397
|
|
|
372
398
|
return finalOptionsForComponent;
|
|
373
399
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
2
|
import type { Func } from "hry-types/src/Misc/Func";
|
|
3
|
-
import type { WMComponent
|
|
3
|
+
import type { WMComponent } from "../../types/OfficialTypeAlias";
|
|
4
4
|
|
|
5
5
|
import type { LifetimesConstraint } from "../RootComponent/Lifetimes/LifetimesConstraint";
|
|
6
6
|
import type { RootComponentDoc } from "../RootComponent/RootComponentDoc";
|
|
@@ -12,6 +12,11 @@ import type { RootComponentOption } from "./RootComponent/RootComponentOption";
|
|
|
12
12
|
import type { SubComponentsOption } from "./SubComponents/SubComponentsOption";
|
|
13
13
|
|
|
14
14
|
import type { RootComponentTrueOptions } from "../RootComponent";
|
|
15
|
+
import type { ComputedConstraint } from "../RootComponent/Computed/ComputedConstraint";
|
|
16
|
+
import type { DataConstraint } from "../RootComponent/Data/DataConstraint";
|
|
17
|
+
import type { MethodsConstraint } from "../RootComponent/Methods/MethodsConstraint";
|
|
18
|
+
import type { PageLifetimesOption } from "../RootComponent/PageLifetimes/PageLifetimesOption";
|
|
19
|
+
import type { StoreConstraint } from "../RootComponent/Store/StoreConstraint";
|
|
15
20
|
import { collectOptionsForComponent } from "./collectOptionsForComponent";
|
|
16
21
|
|
|
17
22
|
type Path = `/${string}`;
|
|
@@ -58,19 +63,18 @@ export type FinalOptionsOfComponent = {
|
|
|
58
63
|
isPage?: boolean;
|
|
59
64
|
options?: WMComponent.Options;
|
|
60
65
|
properties?: Record<string, any>;
|
|
61
|
-
data?:
|
|
62
|
-
store?:
|
|
63
|
-
computed?:
|
|
66
|
+
data?: DataConstraint;
|
|
67
|
+
store?: StoreConstraint;
|
|
68
|
+
computed?: ComputedConstraint;
|
|
64
69
|
observers?: Record<string, Func>;
|
|
65
70
|
behaviors?: string[];
|
|
66
|
-
methods?:
|
|
71
|
+
methods?: MethodsConstraint;
|
|
67
72
|
watch?: Record<string, Func>;
|
|
68
73
|
lifetimes?: LifetimesConstraint;
|
|
69
|
-
|
|
70
|
-
};
|
|
74
|
+
} & PageLifetimesOption<false, object>;
|
|
71
75
|
|
|
72
76
|
export const DefineComponent: DefineComponentConstructor = function(options): any {
|
|
73
77
|
Component(
|
|
74
|
-
collectOptionsForComponent(options.rootComponent as RootComponentTrueOptions
|
|
78
|
+
collectOptionsForComponent(options.rootComponent as RootComponentTrueOptions, options.subComponents),
|
|
75
79
|
);
|
|
76
80
|
};
|
|
@@ -14,7 +14,8 @@ export type PageLifetimesOption<TIsPage extends boolean, PropertiesDoc extends o
|
|
|
14
14
|
& Partial<WMCompPageLifetimes>
|
|
15
15
|
& {
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* 周期发生在组件attached之后,页面onLoad之前,要求组件为同步组件
|
|
18
|
+
* 最低基础库: `3.0.2`
|
|
18
19
|
*/
|
|
19
20
|
load?: (props: object) => void | Promise<void>;
|
|
20
21
|
}
|
|
@@ -33,7 +34,6 @@ export type PageLifetimesOption<TIsPage extends boolean, PropertiesDoc extends o
|
|
|
33
34
|
* 页面加载时触发。一个页面只会调用一次,可以在 onLoad 的参数中获取Properties定义的数据。
|
|
34
35
|
*/
|
|
35
36
|
onLoad?: (
|
|
36
|
-
// 页面时PropertiesDoc对象字段是格外不加null的
|
|
37
37
|
props: PropertiesDoc,
|
|
38
38
|
) => void | Promise<void>;
|
|
39
39
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
|
-
import type { NoInfer } from "hry-types/src/Generic/NoInfer";
|
|
3
2
|
import type { EmptyObject } from "hry-types/src/Misc/EmptyObject";
|
|
4
3
|
import type { Func } from "hry-types/src/Misc/Func";
|
|
5
4
|
import type { ComputeIntersection } from "hry-types/src/Object/_api";
|
|
6
5
|
import type { ComputeObject } from "../../types/ComputeObj";
|
|
7
|
-
import type { WMCompOtherOption
|
|
6
|
+
import type { WMCompOtherOption } from "../../types/OfficialTypeAlias";
|
|
8
7
|
import type { ComponentDoc } from "../DefineComponent/ReturnType/ComponentDoc";
|
|
9
8
|
import type { ComputedConstraint } from "./Computed/ComputedConstraint";
|
|
10
9
|
import type { ComputedOption } from "./Computed/ComputedOption";
|
|
@@ -55,7 +54,7 @@ type RootComponentOptions<
|
|
|
55
54
|
& DataOption<TData, keyof PropertiesDoc>
|
|
56
55
|
& StoreOption<TStore, keyof (PropertiesDoc & DataDoc)>
|
|
57
56
|
& ComputedOption<TComputed, keyof (PropertiesDoc & DataDoc & StoreDoc)>
|
|
58
|
-
& PageLifetimesOption<TIsPage,
|
|
57
|
+
& PageLifetimesOption<TIsPage, PropertiesDoc>
|
|
59
58
|
& LifetimesOption<TIsPage>
|
|
60
59
|
& WatchOption<
|
|
61
60
|
& ComputedDoc
|
|
@@ -138,10 +137,14 @@ export type RootComponentTrueOptions = {
|
|
|
138
137
|
data?: DataConstraint;
|
|
139
138
|
computed?: ComputedConstraint;
|
|
140
139
|
customEvents?: CustomEventConstraint;
|
|
140
|
+
observers?: Record<string, Func>;
|
|
141
141
|
methods?: MethodsConstraint;
|
|
142
|
+
behaviors?: string[];
|
|
142
143
|
events?: EventsConstraint;
|
|
143
144
|
store?: StoreConstraint;
|
|
144
145
|
watch?: Record<string, Func>;
|
|
145
146
|
lifetimes?: LifetimesConstraint;
|
|
146
|
-
pageLifetimes?:
|
|
147
|
+
pageLifetimes?:
|
|
148
|
+
| PageLifetimesOption<false, object>["pageLifetimes"]
|
|
149
|
+
| PageLifetimesOption<true, object>["pageLifetimes"];
|
|
147
150
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PageLifetimesOption } from "../../RootComponent/PageLifetimes/PageLifetimesOption";
|
|
2
2
|
|
|
3
|
-
export type SubPageLifetimesOption<TIsPage extends boolean,
|
|
3
|
+
export type SubPageLifetimesOption<TIsPage extends boolean, PropertiesDoc extends object> = PageLifetimesOption<
|
|
4
4
|
TIsPage,
|
|
5
|
-
|
|
5
|
+
PropertiesDoc
|
|
6
6
|
>;
|
|
@@ -6,13 +6,15 @@ import type { ReplacePrefix } from "../../types/ReplacePrefix";
|
|
|
6
6
|
import type { ComponentDoc } from "../DefineComponent/ReturnType/ComponentDoc";
|
|
7
7
|
|
|
8
8
|
import type { Func } from "hry-types/src/Misc/Func";
|
|
9
|
-
import type {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from "
|
|
9
|
+
import type { WMCompOtherOption } from "../../types/OfficialTypeAlias";
|
|
10
|
+
import type { ComputedConstraint } from "../RootComponent/Computed/ComputedConstraint";
|
|
11
|
+
import type { DataConstraint } from "../RootComponent/Data/DataConstraint";
|
|
12
|
+
import type { EventsConstraint } from "../RootComponent/Events/EventsConstraint";
|
|
13
|
+
import type { LifetimesConstraint } from "../RootComponent/Lifetimes/LifetimesConstraint";
|
|
14
|
+
import type { MethodsConstraint } from "../RootComponent/Methods/MethodsConstraint";
|
|
15
|
+
import type { PageLifetimesOption } from "../RootComponent/PageLifetimes/PageLifetimesOption";
|
|
15
16
|
import type { RootComponentDoc } from "../RootComponent/RootComponentDoc";
|
|
17
|
+
import type { StoreConstraint } from "../RootComponent/Store/StoreConstraint";
|
|
16
18
|
import type { GetSubComputedDoc } from "./SubComputed/GetSubComputedDoc";
|
|
17
19
|
import type { SubComputedConstraint } from "./SubComputed/SubComputedConstraint";
|
|
18
20
|
import type { SubComputedOption } from "./SubComputed/SubComputedOption";
|
|
@@ -206,11 +208,16 @@ export function SubComponent<
|
|
|
206
208
|
|
|
207
209
|
export type SubComponentTrueOptions = {
|
|
208
210
|
inhrit?: string;
|
|
209
|
-
data?:
|
|
210
|
-
computed?:
|
|
211
|
-
|
|
212
|
-
|
|
211
|
+
data?: DataConstraint;
|
|
212
|
+
computed?: ComputedConstraint;
|
|
213
|
+
store?: StoreConstraint;
|
|
214
|
+
events?: EventsConstraint;
|
|
215
|
+
methods?: MethodsConstraint;
|
|
216
|
+
// behaviors?: string[];
|
|
217
|
+
observers?: Record<string, Func>;
|
|
213
218
|
watch?: Record<string, Func>;
|
|
214
|
-
lifetimes?:
|
|
215
|
-
pageLifetimes?:
|
|
219
|
+
lifetimes?: LifetimesConstraint;
|
|
220
|
+
pageLifetimes?:
|
|
221
|
+
| PageLifetimesOption<false, object>["pageLifetimes"]
|
|
222
|
+
| PageLifetimesOption<true, object>["pageLifetimes"];
|
|
216
223
|
};
|
package/src/behaviors/BStore.ts
CHANGED
|
@@ -15,7 +15,6 @@ export const BStore = Behavior({
|
|
|
15
15
|
options.data[key] = toJS(storeConfig[key]());
|
|
16
16
|
|
|
17
17
|
// 把响应式数据配置保留在methods的__storeConfig__字段下带入到组件实例中(不用函数返回方式也可以,但不符合methods字段类型),后续再从原型上删除。
|
|
18
|
-
/* istanbul ignore next */
|
|
19
18
|
options.methods ||= {};
|
|
20
19
|
|
|
21
20
|
options.methods.__storeConfig__ = () => storeConfig;
|
|
@@ -23,7 +22,6 @@ export const BStore = Behavior({
|
|
|
23
22
|
delete options.store;
|
|
24
23
|
}
|
|
25
24
|
},
|
|
26
|
-
|
|
27
25
|
lifetimes: {
|
|
28
26
|
created(this: Instance) {
|
|
29
27
|
// 取出通过addStoreConfigToMethods函数带入的storeConfig
|
|
@@ -50,9 +48,9 @@ export const BStore = Behavior({
|
|
|
50
48
|
}
|
|
51
49
|
deleteProtoField(this, "__storeConfig__");
|
|
52
50
|
},
|
|
51
|
+
/* istanbul ignore next */
|
|
53
52
|
detached(this: Instance) {
|
|
54
|
-
// 清除store数据 test中模拟了测试,所以忽略
|
|
55
|
-
/* istanbul ignore next */
|
|
53
|
+
// 清除store数据 test中模拟了测试,所以忽略 框架(1.6.1)不支持 issue {@link https://github.com/wechat-miniprogram/miniprogram-simulate/issues/110}
|
|
56
54
|
for (const key in this.disposer) {
|
|
57
55
|
this.disposer[key]();
|
|
58
56
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import { navigateTo } from "./api/navigateTo";
|
|
2
|
-
|
|
3
1
|
import { DefineComponent } from "./api/DefineComponent";
|
|
4
|
-
|
|
2
|
+
import { navigateTo } from "./api/navigateTo";
|
|
5
3
|
import { RootComponent } from "./api/RootComponent";
|
|
6
|
-
|
|
7
4
|
import { SubComponent } from "./api/SubComponent";
|
|
8
|
-
|
|
9
|
-
import type { DetailedType } from "./types/DetailedType";
|
|
10
|
-
|
|
11
5
|
import type { ComponentDocExtension } from "./types/ComponentDocExtension";
|
|
6
|
+
import type { DetailedType } from "./types/DetailedType";
|
|
12
7
|
import type { GenerateDoc } from "./types/GenerateDoc";
|
|
13
8
|
import type { ParamsEqual } from "./types/TwoParamsEqual";
|
|
14
9
|
export type { Vant, Wm } from "./thirdLib";
|
|
@@ -28,6 +23,7 @@ export {
|
|
|
28
23
|
DefineComponent,
|
|
29
24
|
type DetailedType,
|
|
30
25
|
type GenerateDoc,
|
|
26
|
+
/* istanbul ignore next */
|
|
31
27
|
navigateTo,
|
|
32
28
|
type ParamsEqual,
|
|
33
29
|
RootComponent,
|
package/src/utils/InnerMarker.ts
CHANGED
package/src/utils/deepClone.ts
CHANGED