@mpxjs/core 2.9.5 → 2.9.9
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/@types/index.d.ts
CHANGED
|
@@ -24,25 +24,33 @@ type UnionToIntersection<U> = (U extends any
|
|
|
24
24
|
? (k: U) => void
|
|
25
25
|
: never) extends ((k: infer I) => void)
|
|
26
26
|
? I
|
|
27
|
-
: never
|
|
27
|
+
: never
|
|
28
28
|
|
|
29
|
-
type ArrayType<T extends any[]> = T extends Array<infer R> ? R : never
|
|
29
|
+
type ArrayType<T extends any[]> = T extends Array<infer R> ? R : never
|
|
30
30
|
|
|
31
31
|
// Mpx types
|
|
32
32
|
type Data = object | (() => object)
|
|
33
33
|
|
|
34
|
-
type
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
export type PropType<T> = {
|
|
35
|
+
__type: T
|
|
36
|
+
} & (
|
|
37
|
+
T extends String
|
|
38
|
+
? StringConstructor
|
|
39
|
+
: T extends number
|
|
40
|
+
? NumberConstructor
|
|
41
|
+
: T extends boolean
|
|
42
|
+
? BooleanConstructor
|
|
43
|
+
: T extends any[]
|
|
44
|
+
? ArrayConstructor
|
|
45
|
+
: T extends object
|
|
46
|
+
? ObjectConstructor
|
|
47
|
+
: never
|
|
48
|
+
)
|
|
41
49
|
|
|
42
50
|
type FullPropType<T> = {
|
|
43
|
-
type: PropType<T
|
|
44
|
-
value?: T
|
|
45
|
-
optionalTypes?:
|
|
51
|
+
type: PropType<T>
|
|
52
|
+
value?: T
|
|
53
|
+
optionalTypes?: WechatMiniprogram.Component.ShortProperty[]
|
|
46
54
|
}
|
|
47
55
|
|
|
48
56
|
interface Properties {
|
|
@@ -75,27 +83,17 @@ interface WatchField {
|
|
|
75
83
|
|
|
76
84
|
type GetDataType<T> = T extends () => any ? ReturnType<T> : T
|
|
77
85
|
|
|
78
|
-
type
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
: Def extends (...args: any[]) => infer T
|
|
85
|
-
? T
|
|
86
|
-
: Def extends FullPropType<infer T>
|
|
87
|
-
? T
|
|
88
|
-
: Def extends PropType<infer T>
|
|
89
|
-
? T
|
|
90
|
-
: any;
|
|
91
|
-
|
|
92
|
-
type GetPropsType<T> = {
|
|
93
|
-
readonly [K in keyof T]: PropValueType<T[K]>
|
|
86
|
+
type GetPropsType<T extends Properties> = {
|
|
87
|
+
readonly [K in keyof T]: T[K] extends FullPropType<infer V>
|
|
88
|
+
? V
|
|
89
|
+
: T[K] extends PropType<infer V>
|
|
90
|
+
? V
|
|
91
|
+
: WechatMiniprogram.Component.PropertyToData<T[K]>
|
|
94
92
|
}
|
|
95
93
|
|
|
96
94
|
type RequiredPropertyNames<T> = {
|
|
97
95
|
[K in keyof T]-?: T[K] extends undefined ? never : K
|
|
98
|
-
}[keyof T]
|
|
96
|
+
}[keyof T]
|
|
99
97
|
|
|
100
98
|
type RequiredPropertiesForUnion<T> = T extends object ? Pick<T, RequiredPropertyNames<T>> : never
|
|
101
99
|
|
|
@@ -126,7 +124,7 @@ interface Context {
|
|
|
126
124
|
createIntersectionObserver: WechatMiniprogram.Component.InstanceMethods<Record<string, any>>['createIntersectionObserver']
|
|
127
125
|
}
|
|
128
126
|
|
|
129
|
-
interface ComponentOpt<D, P, C, M, Mi extends Array<any>, S extends Record<any, any>> extends Partial<WechatMiniprogram.Component.Lifetimes & WechatMiniprogram.Component.OtherOption> {
|
|
127
|
+
interface ComponentOpt<D extends Data, P extends Properties, C, M extends Methods, Mi extends Array<any>, S extends Record<any, any>> extends Partial<WechatMiniprogram.Component.Lifetimes & WechatMiniprogram.Component.OtherOption> {
|
|
130
128
|
data?: D
|
|
131
129
|
properties?: P
|
|
132
130
|
computed?: C
|
|
@@ -144,7 +142,7 @@ interface ComponentOpt<D, P, C, M, Mi extends Array<any>, S extends Record<any,
|
|
|
144
142
|
[index: string]: any
|
|
145
143
|
}
|
|
146
144
|
|
|
147
|
-
type PageOpt<D, P, C, M, Mi extends Array<any>, S extends Record<any, any>> =
|
|
145
|
+
type PageOpt<D extends Data, P extends Properties, C, M extends Methods, Mi extends Array<any>, S extends Record<any, any>> =
|
|
148
146
|
ComponentOpt<D, P, C, M, Mi, S>
|
|
149
147
|
& Partial<WechatMiniprogram.Page.ILifetime>
|
|
150
148
|
|
|
@@ -281,11 +279,15 @@ interface ImplementOptions {
|
|
|
281
279
|
|
|
282
280
|
export function toPureObject<T extends object> (obj: T): T
|
|
283
281
|
|
|
284
|
-
declare type PluginInstallFunction = (app: Mpx, ...options: any[]) => any
|
|
282
|
+
declare type PluginInstallFunction = (app: Mpx, ...options: any[]) => any
|
|
285
283
|
|
|
286
284
|
export type Plugin = PluginInstallFunction | {
|
|
287
|
-
install: PluginInstallFunction
|
|
288
|
-
}
|
|
285
|
+
install: PluginInstallFunction
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export type PluginFunction<T extends Plugin> = T extends PluginInstallFunction ? T : T extends { install: infer U } ? U : never;
|
|
289
|
+
|
|
290
|
+
export type PluginFunctionParams<T extends PluginInstallFunction> = T extends (app: any, ...args: infer P) => any ? P : [];
|
|
289
291
|
|
|
290
292
|
export interface Mpx {
|
|
291
293
|
getMixin: typeof getMixin
|
|
@@ -295,7 +297,7 @@ export interface Mpx {
|
|
|
295
297
|
observable: typeof observable
|
|
296
298
|
watch: typeof watch
|
|
297
299
|
|
|
298
|
-
use (plugin:
|
|
300
|
+
use <T extends Plugin = Plugin>(plugin: T, ...rest: PluginFunctionParams<PluginFunction<T>>): Mpx
|
|
299
301
|
|
|
300
302
|
implement (name: string, options?: ImplementOptions): void
|
|
301
303
|
|
|
@@ -317,6 +319,8 @@ export interface Mpx {
|
|
|
317
319
|
te: typeof te
|
|
318
320
|
tm: typeof tm
|
|
319
321
|
}
|
|
322
|
+
|
|
323
|
+
__vue: any
|
|
320
324
|
}
|
|
321
325
|
|
|
322
326
|
type GetFunctionKey<T> = {
|
|
@@ -670,7 +674,7 @@ export const ONHIDE: string
|
|
|
670
674
|
export const ONRESIZE: string
|
|
671
675
|
|
|
672
676
|
declare global {
|
|
673
|
-
const defineProps: (<T>(props: T) => Readonly<GetPropsType<T>>) & (<T>() => Readonly<T>)
|
|
677
|
+
const defineProps: (<T extends Properties = {}>(props: T) => Readonly<GetPropsType<T>>) & (<T>() => Readonly<T>)
|
|
674
678
|
const defineOptions: <D extends Data = {}, P extends Properties = {}, C = {}, M extends Methods = {}, Mi extends Array<any> = [], S extends AnyObject = {}, O extends AnyObject = {}> (opt: ThisTypedComponentOpt<D, P, C, M, Mi, S, O>) => void
|
|
675
679
|
const defineExpose: <E extends AnyObject = AnyObject>(exposed?: E) => void
|
|
676
680
|
const useContext: () => Context
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/core",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.9",
|
|
4
4
|
"description": "mpx runtime core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"miniprogram",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"url": "https://github.com/didi/mpx/issues"
|
|
48
48
|
},
|
|
49
49
|
"sideEffects": false,
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "7ec6526f024c00f9c6b935c631bfdc61be27b69b"
|
|
51
51
|
}
|
|
@@ -41,6 +41,7 @@ export default function pageScrollMixin (mixinType) {
|
|
|
41
41
|
return {
|
|
42
42
|
mounted () {
|
|
43
43
|
this.__lastScrollY = 0
|
|
44
|
+
this.__originalOverflow = document.body.style.overflow
|
|
44
45
|
},
|
|
45
46
|
activated () {
|
|
46
47
|
if (!refreshMs()) {
|
|
@@ -72,19 +73,22 @@ export default function pageScrollMixin (mixinType) {
|
|
|
72
73
|
}
|
|
73
74
|
},
|
|
74
75
|
deactivated () {
|
|
75
|
-
if (ms) {
|
|
76
|
+
if (ms) { // 保存滚动位置, 用于 keep-alive
|
|
76
77
|
this.__lastScrollY = getScrollTop()
|
|
77
|
-
ms.destroy()
|
|
78
|
-
hideLoading(this)
|
|
79
78
|
}
|
|
79
|
+
this.__uninstallMpxScroll()
|
|
80
80
|
},
|
|
81
81
|
beforeDestroy () {
|
|
82
|
-
|
|
83
|
-
ms.destroy()
|
|
84
|
-
hideLoading(this)
|
|
85
|
-
}
|
|
82
|
+
this.__uninstallMpxScroll()
|
|
86
83
|
},
|
|
87
84
|
methods: {
|
|
85
|
+
__uninstallMpxScroll () {
|
|
86
|
+
if (ms) {
|
|
87
|
+
ms.destroy()
|
|
88
|
+
hideLoading(this)
|
|
89
|
+
document.body.style.overflow = this.__originalOverflow // 恢复原有 overflow, 避免影响其他页面
|
|
90
|
+
}
|
|
91
|
+
},
|
|
88
92
|
__mpxPullDownHandler (autoStop = false, isRefresh = false) {
|
|
89
93
|
this.__pullingDown = true
|
|
90
94
|
// 同微信保持一致
|