annil 1.1.2 → 1.2.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/api/DefineComponent/collectOptionsForComponent.js +18 -71
- 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 -119
- 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,13 @@
|
|
|
4
4
|
|
|
5
5
|
* 解决DetailedType不接收接口类型的错误 ([ae8acbf](https://github.com/missannil/annil/commit/ae8acbfc2e62f99db565c448ad9253aa549e78bb))
|
|
6
6
|
|
|
7
|
+
## [1.2.0-beta.0](https://github.com/missannil/annil/compare/v1.1.2...v1.2.0-beta.0) (2023-12-07)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* 页面onLoad和组件pageLifetimes.load周期参数使用encodeURI加密和解析 ([8b5cc6e](https://github.com/missannil/annil/commit/8b5cc6ee65abb0def005126c9382a07b8affc0ca))
|
|
13
|
+
|
|
7
14
|
## [1.1.2](https://github.com/missannil/annil/compare/v1.1.1...v1.1.2) (2023-12-06)
|
|
8
15
|
|
|
9
16
|
|
|
@@ -2,47 +2,26 @@ 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
9
|
if (innerData === undefined)
|
|
11
10
|
return;
|
|
12
|
-
const
|
|
13
|
-
for (const key in
|
|
14
|
-
option[key] =
|
|
11
|
+
const decodeOption = JSON.parse(decodeURIComponent(innerData));
|
|
12
|
+
for (const key in decodeOption) {
|
|
13
|
+
option[key] = decodeOption[key];
|
|
15
14
|
}
|
|
16
|
-
this.setData(option);
|
|
17
15
|
delete option[INNERMARKER.url];
|
|
18
|
-
Reflect.deleteProperty(this.data, INNERMARKER.url);
|
|
19
16
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function attachedHijack(options, before, after = []) {
|
|
35
|
-
options.lifetimes || (options.lifetimes = {});
|
|
36
|
-
const originalAttached = options.lifetimes.attached;
|
|
37
|
-
options.lifetimes.attached = function () {
|
|
38
|
-
before.forEach((func) => {
|
|
39
|
-
func.call(this, options);
|
|
40
|
-
});
|
|
41
|
-
originalAttached === null || originalAttached === void 0 ? void 0 : originalAttached.call(this);
|
|
42
|
-
after.forEach((func) => {
|
|
43
|
-
func.call(this, options);
|
|
44
|
-
});
|
|
17
|
+
function hijack(config, field, before = [], after = []) {
|
|
18
|
+
const originalFunc = config[field];
|
|
19
|
+
config[field] = function (...args) {
|
|
20
|
+
before.forEach(func => func.call(this, ...args));
|
|
21
|
+
originalFunc && originalFunc.apply(this, args);
|
|
22
|
+
after.forEach(func => func.call(this, ...args));
|
|
45
23
|
};
|
|
24
|
+
return;
|
|
46
25
|
}
|
|
47
26
|
function InternalFieldProtection(config, keys) {
|
|
48
27
|
if (!config)
|
|
@@ -124,40 +103,7 @@ function customEventsHandle(componentOptions, customEventsConfig) {
|
|
|
124
103
|
}
|
|
125
104
|
}
|
|
126
105
|
}
|
|
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
106
|
function collectRootComponentOption(finalOptions, funcOptions, rootComponentOptions) {
|
|
157
|
-
console.log("-------------------------");
|
|
158
|
-
InternalFieldProtection(rootComponentOptions.customEvents, ["load"]);
|
|
159
|
-
InternalFieldProtection(rootComponentOptions.methods, ["load"]);
|
|
160
|
-
InternalFieldProtection(rootComponentOptions.events, ["load"]);
|
|
161
107
|
rootComponentOptions.customEvents && customEventsHandle(finalOptions, rootComponentOptions.customEvents);
|
|
162
108
|
delete rootComponentOptions.customEvents;
|
|
163
109
|
rootComponentOptions.events && eventsHandle(finalOptions, rootComponentOptions.events);
|
|
@@ -166,8 +112,10 @@ function collectRootComponentOption(finalOptions, funcOptions, rootComponentOpti
|
|
|
166
112
|
otherFieldsHandle(finalOptions, rootComponentOptions);
|
|
167
113
|
}
|
|
168
114
|
export function collectOptionsForComponent(rootComponentOption, subComponentsList) {
|
|
115
|
+
var _a, _b;
|
|
169
116
|
const finalOptionsForComponent = {
|
|
170
117
|
options: {
|
|
118
|
+
addGlobalClass: true,
|
|
171
119
|
multipleSlots: true,
|
|
172
120
|
pureDataPattern: /^_/,
|
|
173
121
|
virtualHost: true,
|
|
@@ -185,17 +133,16 @@ export function collectOptionsForComponent(rootComponentOption, subComponentsLis
|
|
|
185
133
|
if (subComponentsList && !isEmptyObject(subComponentsList)) {
|
|
186
134
|
subComponentsHandle(finalOptionsForComponent, subComponentsList, funcOptions);
|
|
187
135
|
}
|
|
188
|
-
|
|
189
|
-
funcConfigHandle(finalOptionsForComponent, rootComponentOption === null || rootComponentOption === void 0 ? void 0 : rootComponentOption.isPage, funcOptions);
|
|
190
|
-
}
|
|
136
|
+
funcConfigHandle(finalOptionsForComponent, rootComponentOption === null || rootComponentOption === void 0 ? void 0 : rootComponentOption.isPage, funcOptions);
|
|
191
137
|
finalOptionsForComponent.methods && InternalFieldProtection(finalOptionsForComponent.methods, ["disposer"]);
|
|
192
|
-
finalOptionsForComponent.
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
138
|
+
((_a = finalOptionsForComponent.methods) === null || _a === void 0 ? void 0 : _a.onLoad)
|
|
139
|
+
&& hijack(finalOptionsForComponent.methods, "onLoad", [onLoadReceivedDataHandle, initComputed], []);
|
|
140
|
+
((_b = finalOptionsForComponent.pageLifetimes) === null || _b === void 0 ? void 0 : _b.load)
|
|
141
|
+
&& hijack(finalOptionsForComponent.pageLifetimes, "load", [onLoadReceivedDataHandle], []);
|
|
196
142
|
if (finalOptionsForComponent.isPage) {
|
|
197
143
|
Reflect.deleteProperty(finalOptionsForComponent.options, "virtualHost");
|
|
198
144
|
}
|
|
145
|
+
finalOptionsForComponent.behaviors.push(BBeforeCreate);
|
|
199
146
|
return finalOptionsForComponent;
|
|
200
147
|
}
|
|
201
148
|
//# 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/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AC,wBAAwB,EAAE,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IAErF,wBAAwB,CAAC,OAAO,IAAI,uBAAuB,CAAC,wBAAwB,CAAC,OAAO,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAG5G,CAAA,MAAA,wBAAwB,CAAC,OAAO,0CAAE,MAAM;WACnC,MAAM,CAAC,wBAAwB,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,wBAAwB,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC;IAGtG,CAAA,MAAA,wBAAwB,CAAC,aAAa,0CAAE,IAAI;WACvC,MAAM,CAAC,wBAAwB,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC,wBAAwB,CAAC,EAAE,EAAE,CAAC,CAAC;IAG5F,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,IAA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ACzB,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAgB,CAAC;YAEpE,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;YAEnB,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;gBAE9B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,QAAQ,CAC3B,WAAW,CAAC,GAAG,CAAC,EAChB,CAAC,KAAc,EAAE,EAAE;oBAEjB,IAAI,CAAC,OAAO,CAAC;wBACX,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC;qBACnB,CAAC,CAAC;gBACL,CAAC,EACD;oBACE,MAAM,EAAE,QAAQ,CAAC,UAAU;iBAC5B,CACF,CAAC;YACJ,CAAC;YACD,gBAAgB,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,128 @@ import type { PageInstance } from "../RootComponent/Instance/RootComponentInstan
|
|
|
18
17
|
import type { SubComponentTrueOptions } from "../SubComponent";
|
|
19
18
|
import type { FinalOptionsOfComponent, FuncOptions } from ".";
|
|
20
19
|
/**
|
|
21
|
-
* 针对通过 navigateTo
|
|
20
|
+
* 针对通过 navigateTo传过来的数据对页面onLoad周期传入数据解析
|
|
22
21
|
* @param option - option中的url是拼接了encodeURIComponent转码的data对象的,key为INNERMARKER.url
|
|
23
22
|
*/
|
|
24
|
-
/* istanbul ignore next */
|
|
23
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
25
24
|
function onLoadReceivedDataHandle(
|
|
26
25
|
this: PageInstance,
|
|
27
26
|
option: Record<typeof INNERMARKER.url, string>,
|
|
28
27
|
) {
|
|
29
28
|
const innerData: string | undefined = option[INNERMARKER.url];
|
|
30
|
-
//
|
|
29
|
+
// 未使用navigateTo API
|
|
31
30
|
if (innerData === undefined) return;
|
|
32
|
-
const
|
|
31
|
+
const decodeOption = JSON.parse(decodeURIComponent(innerData));
|
|
33
32
|
|
|
34
33
|
// 使用navigateTo
|
|
35
|
-
for (const key in
|
|
36
|
-
option[key] =
|
|
34
|
+
for (const key in decodeOption) {
|
|
35
|
+
option[key] = decodeOption[key];
|
|
37
36
|
}
|
|
38
|
-
|
|
39
|
-
// setData会触发计算属性 继承属性等 。
|
|
40
|
-
this.setData(option as any);
|
|
41
|
-
|
|
42
37
|
delete option[INNERMARKER.url];
|
|
43
38
|
|
|
44
|
-
|
|
39
|
+
// 默认生命周期不会把接收的数据setData,为了更方便setData.注: 此时计算属性还未初始化。
|
|
40
|
+
// this.setData(option);
|
|
45
41
|
}
|
|
46
|
-
|
|
47
42
|
/**
|
|
48
|
-
*
|
|
43
|
+
* 针对通过 navigateTo传过来的数据对组件load周期传入数据解析
|
|
44
|
+
* @param option - option中的url是拼接了encodeURIComponent转码的data对象的,key为INNERMARKER.url
|
|
49
45
|
*/
|
|
50
|
-
/* istanbul ignore next */
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
46
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
47
|
+
// function loadReceivedDataHandle(
|
|
48
|
+
// this: PageInstance,
|
|
49
|
+
// option: Record<typeof INNERMARKER.url, string>,
|
|
50
|
+
// ) {
|
|
51
|
+
// const innerData: string | undefined = option[INNERMARKER.url];
|
|
52
|
+
// // 未使用自定义的navigateTo
|
|
53
|
+
// if (innerData === undefined) return;
|
|
54
|
+
// const decodeOption = JSON.parse(decodeURIComponent(innerData));
|
|
55
|
+
|
|
56
|
+
// // 使用navigateTo
|
|
57
|
+
// for (const key in decodeOption) {
|
|
58
|
+
// option[key] = decodeOption[key];
|
|
59
|
+
// }
|
|
60
|
+
// delete option[INNERMARKER.url];
|
|
61
|
+
// }
|
|
62
|
+
/**
|
|
63
|
+
* 劫持指定配置字段
|
|
64
|
+
*/
|
|
65
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
66
|
+
function hijack(config: object, field: string, before: Func[] = [], after: Func[] = []) {
|
|
67
|
+
const originalFunc: Func | undefined = config[field];
|
|
60
68
|
|
|
61
|
-
|
|
62
|
-
before.forEach(
|
|
63
|
-
func.call(this, props, cloneOpt);
|
|
64
|
-
});
|
|
69
|
+
config[field] = function(...args: any[]) {
|
|
70
|
+
before.forEach(func => func.call(this, ...args));
|
|
65
71
|
|
|
66
|
-
|
|
72
|
+
originalFunc && originalFunc.apply(this, args);
|
|
67
73
|
|
|
68
|
-
after.forEach(
|
|
69
|
-
func.call(this, props, cloneOpt);
|
|
70
|
-
});
|
|
74
|
+
after.forEach(func => func.call(this, ...args));
|
|
71
75
|
};
|
|
76
|
+
|
|
77
|
+
return;
|
|
72
78
|
}
|
|
79
|
+
|
|
73
80
|
/**
|
|
74
|
-
*
|
|
81
|
+
* onLoad生命周期劫持函数
|
|
82
|
+
*/
|
|
83
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
84
|
+
// function onLoadHijack(
|
|
85
|
+
// options: FinalOptionsOfComponent,
|
|
86
|
+
// before: Func[],
|
|
87
|
+
// after: Func[] = [],
|
|
88
|
+
// ) {
|
|
89
|
+
// options.methods ||= {};
|
|
90
|
+
|
|
91
|
+
// const cloneOpt = deepClone(options);
|
|
92
|
+
// const originalOnLoad: Func | undefined = options.methods.onLoad;
|
|
93
|
+
|
|
94
|
+
// options.methods.onLoad = function(props: unknown) {
|
|
95
|
+
// before.forEach((func) => {
|
|
96
|
+
// func.call(this, props, cloneOpt);
|
|
97
|
+
// });
|
|
98
|
+
|
|
99
|
+
// originalOnLoad?.call(this, props);
|
|
100
|
+
|
|
101
|
+
// after.forEach((func) => {
|
|
102
|
+
// func.call(this, props, cloneOpt);
|
|
103
|
+
// });
|
|
104
|
+
// };
|
|
105
|
+
// }
|
|
106
|
+
/**
|
|
107
|
+
* 劫持pageLifetimes中的load字段
|
|
75
108
|
*/
|
|
76
109
|
/* istanbul ignore next */
|
|
77
|
-
function
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
110
|
+
// function loadHijack(
|
|
111
|
+
// options: FinalOptionsOfComponent,
|
|
112
|
+
// before: Func[],
|
|
113
|
+
// after: Func[] = [],
|
|
114
|
+
// ) {
|
|
115
|
+
// /* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
116
|
+
// options.lifetimes ||= {};
|
|
117
|
+
|
|
118
|
+
// const originalAttached: Func | undefined = options.lifetimes.attached;
|
|
119
|
+
|
|
120
|
+
// options.lifetimes.attached = function() {
|
|
121
|
+
// before.forEach((func) => {
|
|
122
|
+
// func.call(this, options);
|
|
123
|
+
// });
|
|
124
|
+
|
|
125
|
+
// originalAttached?.call(this);
|
|
126
|
+
|
|
127
|
+
// /* istanbul ignore next */
|
|
128
|
+
// after.forEach((func) => {
|
|
129
|
+
// func.call(this, options);
|
|
130
|
+
// });
|
|
131
|
+
// };
|
|
132
|
+
// }
|
|
100
133
|
/**
|
|
101
134
|
* 内部保护字段 即不允许配置的字段名(所有方法下)
|
|
102
135
|
*/
|
|
103
136
|
// const INNERFIELDS = ["disposer"];
|
|
104
137
|
|
|
105
138
|
/**
|
|
106
|
-
*
|
|
107
|
-
* 保护config下不被配置keys包含的内部预定字段
|
|
139
|
+
* 报错的形式避免输入字段和内部字段冲突,保证config下不包含内部预定字段(列表)
|
|
108
140
|
*/
|
|
109
|
-
/* istanbul ignore next */
|
|
141
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
110
142
|
function InternalFieldProtection(config: object | undefined, keys: string[]) {
|
|
111
143
|
if (!config) return;
|
|
112
144
|
const methodsConfigKeys = Object.keys(config);
|
|
@@ -126,14 +158,16 @@ function _funcConfigHandle(methodsConfig: object, configList: Record<string, Fun
|
|
|
126
158
|
};
|
|
127
159
|
}
|
|
128
160
|
}
|
|
129
|
-
|
|
161
|
+
/**
|
|
162
|
+
* 把函数列表配置放入一个配置中循环一次运行
|
|
163
|
+
*/
|
|
130
164
|
function funcConfigHandle(
|
|
131
165
|
finalOptionsForComponent: FinalOptionsOfComponent,
|
|
132
166
|
isPage: boolean | undefined,
|
|
133
167
|
funcOptions: FuncOptions,
|
|
134
168
|
) {
|
|
135
169
|
// 测试框架无法测试page情形
|
|
136
|
-
/* istanbul ignore next */
|
|
170
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
137
171
|
if (isPage) {
|
|
138
172
|
// 页面时 生命周期方法(即 on 开头的方法),(https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/component.html)
|
|
139
173
|
funcOptions.pageLifetimes && _funcConfigHandle(finalOptionsForComponent.methods ||= {}, funcOptions.pageLifetimes);
|
|
@@ -165,7 +199,9 @@ function funcFieldsCollect(
|
|
|
165
199
|
}
|
|
166
200
|
}
|
|
167
201
|
|
|
168
|
-
|
|
202
|
+
/**
|
|
203
|
+
* 其他字段加入到componentOptions对应字段配置中
|
|
204
|
+
*/
|
|
169
205
|
function otherFieldsHandle(
|
|
170
206
|
finalOptions: FinalOptionsOfComponent,
|
|
171
207
|
rootComponentOptions: RootComponentTrueOptions,
|
|
@@ -174,7 +210,7 @@ function otherFieldsHandle(
|
|
|
174
210
|
const config = rootComponentOptions[key];
|
|
175
211
|
if (Array.isArray(config)) {
|
|
176
212
|
// 好像只有behaviors是数组吧.
|
|
177
|
-
/* istanbul ignore next */
|
|
213
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
178
214
|
(finalOptions[key] ||= []).push(...config);
|
|
179
215
|
} else {
|
|
180
216
|
Object.assign(finalOptions[key] ||= {}, config);
|
|
@@ -182,10 +218,10 @@ function otherFieldsHandle(
|
|
|
182
218
|
}
|
|
183
219
|
}
|
|
184
220
|
/**
|
|
185
|
-
* 把events
|
|
221
|
+
* 把events字段放入到componentOptions.methods中
|
|
186
222
|
*/
|
|
187
223
|
function eventsHandle(componentOptions: FinalOptionsOfComponent, eventsConfig: EventsConstraint) {
|
|
188
|
-
/* istanbul ignore next */
|
|
224
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
189
225
|
componentOptions.methods ||= {};
|
|
190
226
|
|
|
191
227
|
Object.assign(componentOptions.methods, eventsConfig);
|
|
@@ -218,7 +254,7 @@ function customEventsHandle(
|
|
|
218
254
|
componentOptions: FinalOptionsOfComponent,
|
|
219
255
|
customEventsConfig: CustomEventConstraint,
|
|
220
256
|
) {
|
|
221
|
-
/* istanbul ignore next */
|
|
257
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
222
258
|
componentOptions.methods ||= {};
|
|
223
259
|
|
|
224
260
|
for (const key in customEventsConfig) {
|
|
@@ -239,45 +275,45 @@ function customEventsHandle(
|
|
|
239
275
|
* 触发各个组件的页面load事件
|
|
240
276
|
*/
|
|
241
277
|
/* istanbul ignore next */
|
|
242
|
-
function triggerCompLoad(this: Instance, props: object) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
278
|
+
// function triggerCompLoad(this: Instance, props: object) {
|
|
279
|
+
// if (!this.__compLoadList__) return;
|
|
280
|
+
// this.__compLoadList__.forEach((loadFunc) => {
|
|
281
|
+
// loadFunc(props);
|
|
282
|
+
// });
|
|
283
|
+
// }
|
|
248
284
|
/* istanbul ignore next */
|
|
249
|
-
function getPageInstance(pageId: string): Instance {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
}
|
|
285
|
+
// function getPageInstance(pageId: string): Instance {
|
|
286
|
+
// const pagestack = getCurrentPages() as unknown as Instance[];
|
|
287
|
+
// let pageInstance: Instance;
|
|
288
|
+
// pagestack.some((instance) => {
|
|
289
|
+
// if (instance.getPageId() === pageId) {
|
|
290
|
+
// pageInstance = instance;
|
|
291
|
+
|
|
292
|
+
// return true;
|
|
293
|
+
// }
|
|
294
|
+
|
|
295
|
+
// return false;
|
|
296
|
+
// });
|
|
297
|
+
|
|
298
|
+
// // @ts-ignore pagestack中一定赋值了
|
|
299
|
+
// return pageInstance;
|
|
300
|
+
// }
|
|
265
301
|
/**
|
|
266
302
|
* 收集组件pageLifetimes下的load周期函数到页面实例的__loadFunList__
|
|
267
303
|
*/
|
|
268
304
|
/* istanbul ignore next */
|
|
269
|
-
function collectLoadLifetimesOfComponent(this: Instance, finalOptionsForComponent: FinalOptionsOfComponent) {
|
|
270
|
-
|
|
305
|
+
// function collectLoadLifetimesOfComponent(this: Instance, finalOptionsForComponent: FinalOptionsOfComponent) {
|
|
306
|
+
// const loadFunc = finalOptionsForComponent.pageLifetimes?.load;
|
|
271
307
|
|
|
272
|
-
|
|
308
|
+
// console.log(loadFunc, finalOptionsForComponent);
|
|
273
309
|
|
|
274
|
-
|
|
310
|
+
// if (!loadFunc) return;
|
|
275
311
|
|
|
276
|
-
|
|
277
|
-
|
|
312
|
+
// const pageInstance = getPageInstance(this.getPageId());
|
|
313
|
+
// const __compLoadList__: Function[] = (pageInstance.__compLoadList__ ||= []);
|
|
278
314
|
|
|
279
|
-
|
|
280
|
-
}
|
|
315
|
+
// __compLoadList__.push(loadFunc.bind(this));
|
|
316
|
+
// }
|
|
281
317
|
/**
|
|
282
318
|
* 收集 rootComponentOptions 配置到 finalOptions 和 funcOptions 中
|
|
283
319
|
* @param finalOptions - 收集配置对象
|
|
@@ -289,14 +325,6 @@ function collectRootComponentOption(
|
|
|
289
325
|
funcOptions: FuncOptions,
|
|
290
326
|
rootComponentOptions: RootComponentTrueOptions,
|
|
291
327
|
) {
|
|
292
|
-
console.log("-------------------------");
|
|
293
|
-
|
|
294
|
-
InternalFieldProtection(rootComponentOptions.customEvents, ["load"]);
|
|
295
|
-
|
|
296
|
-
InternalFieldProtection(rootComponentOptions.methods, ["load"]);
|
|
297
|
-
|
|
298
|
-
InternalFieldProtection(rootComponentOptions.events, ["load"]);
|
|
299
|
-
|
|
300
328
|
rootComponentOptions.customEvents && customEventsHandle(finalOptions, rootComponentOptions.customEvents);
|
|
301
329
|
|
|
302
330
|
delete rootComponentOptions.customEvents;
|
|
@@ -322,7 +350,7 @@ export function collectOptionsForComponent(
|
|
|
322
350
|
const finalOptionsForComponent: FinalOptionsOfComponent = {
|
|
323
351
|
// default options
|
|
324
352
|
options: {
|
|
325
|
-
|
|
353
|
+
addGlobalClass: true, // "styleIsolation": "apply-shared"
|
|
326
354
|
multipleSlots: true,
|
|
327
355
|
pureDataPattern: /^_/,
|
|
328
356
|
virtualHost: true,
|
|
@@ -346,28 +374,27 @@ export function collectOptionsForComponent(
|
|
|
346
374
|
if (subComponentsList && !isEmptyObject(subComponentsList)) {
|
|
347
375
|
subComponentsHandle(finalOptionsForComponent, subComponentsList, funcOptions);
|
|
348
376
|
}
|
|
349
|
-
//
|
|
350
|
-
/* istanbul ignore next */
|
|
351
|
-
|
|
352
|
-
funcConfigHandle(finalOptionsForComponent, rootComponentOption?.isPage, funcOptions);
|
|
353
|
-
}
|
|
377
|
+
// miniprogram-simulate(当前版本 1.6.1) 无法测试页面
|
|
378
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
379
|
+
funcConfigHandle(finalOptionsForComponent, rootComponentOption?.isPage, funcOptions);
|
|
354
380
|
|
|
355
381
|
finalOptionsForComponent.methods && InternalFieldProtection(finalOptionsForComponent.methods, ["disposer"]);
|
|
356
382
|
|
|
357
|
-
|
|
358
|
-
finalOptionsForComponent.
|
|
359
|
-
|
|
360
|
-
console.log(finalOptionsForComponent, 999, funcOptions);
|
|
383
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
384
|
+
finalOptionsForComponent.methods?.onLoad
|
|
385
|
+
&& hijack(finalOptionsForComponent.methods, "onLoad", [onLoadReceivedDataHandle, initComputed], []);
|
|
361
386
|
|
|
362
|
-
|
|
387
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
388
|
+
finalOptionsForComponent.pageLifetimes?.load
|
|
389
|
+
&& hijack(finalOptionsForComponent.pageLifetimes, "load", [onLoadReceivedDataHandle], []);
|
|
363
390
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
// 框架无法测试页面
|
|
367
|
-
/* istanbul ignore next */
|
|
391
|
+
/* istanbul ignore next: miniprogram-simulate(当前版本 1.6.1) 无法测试页面 */
|
|
368
392
|
if (finalOptionsForComponent.isPage) {
|
|
393
|
+
// 页面时删除预设的虚拟组件字段
|
|
369
394
|
Reflect.deleteProperty(finalOptionsForComponent.options!, "virtualHost");
|
|
370
395
|
}
|
|
396
|
+
// BBeforeCreate在最后面,让BeforeCreate生命周期运行在最终建立组件时。
|
|
397
|
+
finalOptionsForComponent.behaviors!.push(BBeforeCreate);
|
|
371
398
|
|
|
372
399
|
return finalOptionsForComponent;
|
|
373
400
|
}
|
|
@@ -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