@mpxjs/core 2.9.0-beta.0 → 2.9.0-beta.2
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 +23 -16
- package/@types/node.d.ts +10 -8
- package/package.json +5 -5
- package/src/platform/builtInMixins/pageRouteMixin.js +13 -0
- package/src/platform/builtInMixins/proxyEventMixin.web.js +0 -5
- package/src/platform/patch/web/getDefaultOptions.js +1 -1
- package/src/vuePlugin.js +2 -2
package/@types/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
/// <reference path="./node.d.ts" />
|
|
9
9
|
|
|
10
10
|
// @ts-ignore
|
|
11
|
-
import
|
|
11
|
+
import { GetComputedType } from '@mpxjs/store'
|
|
12
12
|
|
|
13
13
|
// @ts-ignore
|
|
14
14
|
export * from '@mpxjs/store'
|
|
@@ -42,7 +42,7 @@ interface PropOpt {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
interface Properties {
|
|
45
|
-
[key: string]:
|
|
45
|
+
[key: string]: WechatMiniprogram.Component.AllProperty
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
interface Methods {
|
|
@@ -96,6 +96,7 @@ interface Mixin<D, P, C, M> {
|
|
|
96
96
|
properties?: P
|
|
97
97
|
computed?: C
|
|
98
98
|
methods?: M
|
|
99
|
+
|
|
99
100
|
[index: string]: any
|
|
100
101
|
}
|
|
101
102
|
|
|
@@ -108,14 +109,16 @@ interface Context {
|
|
|
108
109
|
triggerEvent: WechatMiniprogram.Component.InstanceMethods<Record<string, any>>['triggerEvent']
|
|
109
110
|
refs: ObjectOf<WechatMiniprogram.NodesRef & ComponentIns<{}, {}, {}, {}, []>>
|
|
110
111
|
asyncRefs: ObjectOf<Promise<WechatMiniprogram.NodesRef & ComponentIns<{}, {}, {}, {}, []>>>
|
|
112
|
+
|
|
111
113
|
forceUpdate (params?: object, callback?: () => void): void
|
|
114
|
+
|
|
112
115
|
selectComponent: ReplaceWxComponentIns['selectComponent']
|
|
113
116
|
selectAllComponents: ReplaceWxComponentIns['selectAllComponents']
|
|
114
117
|
createSelectorQuery: WechatMiniprogram.Component.InstanceMethods<Record<string, any>>['createSelectorQuery']
|
|
115
118
|
createIntersectionObserver: WechatMiniprogram.Component.InstanceMethods<Record<string, any>>['createIntersectionObserver']
|
|
116
119
|
}
|
|
117
120
|
|
|
118
|
-
interface ComponentOpt<D, P, C, M, Mi extends Array<any>, S extends Record<any, any>> extends Partial<WechatMiniprogram.Component.Lifetimes & WechatMiniprogram.Component.OtherOption>{
|
|
121
|
+
interface ComponentOpt<D, P, C, M, Mi extends Array<any>, S extends Record<any, any>> extends Partial<WechatMiniprogram.Component.Lifetimes & WechatMiniprogram.Component.OtherOption> {
|
|
119
122
|
data?: D
|
|
120
123
|
properties?: P
|
|
121
124
|
computed?: C
|
|
@@ -137,11 +140,11 @@ type PageOpt<D, P, C, M, Mi extends Array<any>, S extends Record<any, any>> =
|
|
|
137
140
|
ComponentOpt<D, P, C, M, Mi, S>
|
|
138
141
|
& Partial<WechatMiniprogram.Page.ILifetime>
|
|
139
142
|
|
|
140
|
-
type ThisTypedPageOpt<D extends
|
|
143
|
+
type ThisTypedPageOpt<D extends Data, P extends Properties, C, M extends Methods, Mi extends Array<any>, S extends Record<any, any>, O = {}> =
|
|
141
144
|
PageOpt<D, P, C, M, Mi, S>
|
|
142
145
|
& ThisType<ComponentIns<D, P, C, M, Mi, S, O>> & O
|
|
143
146
|
|
|
144
|
-
type ThisTypedComponentOpt<D extends
|
|
147
|
+
type ThisTypedComponentOpt<D extends Data, P extends Properties, C, M extends Methods, Mi extends Array<any>, S extends Record<any, any>, O = {}> =
|
|
145
148
|
ComponentOpt<D, P, C, M, Mi, S>
|
|
146
149
|
& ThisType<ComponentIns<D, P, C, M, Mi, S, O>> & O
|
|
147
150
|
|
|
@@ -169,13 +172,17 @@ type MpxComProps<O> = { $rawOptions: O }
|
|
|
169
172
|
|
|
170
173
|
export interface MpxComponentIns {
|
|
171
174
|
$refs: ObjectOf<WechatMiniprogram.NodesRef & ComponentIns<{}, {}, {}, {}, []>>
|
|
172
|
-
$asyncRefs
|
|
175
|
+
$asyncRefs: ObjectOf<Promise<WechatMiniprogram.NodesRef & ComponentIns<{}, {}, {}, {}, []>>>
|
|
173
176
|
$set: typeof set
|
|
174
177
|
$remove: typeof del
|
|
175
178
|
$delete: typeof del
|
|
179
|
+
|
|
176
180
|
$watch (expr: string | (() => any), handler: WatchHandler | WatchOptWithHandler, options?: WatchOpt): () => void
|
|
181
|
+
|
|
177
182
|
$forceUpdate (params?: object, callback?: () => void): void
|
|
183
|
+
|
|
178
184
|
$nextTick (fn: () => void): void
|
|
185
|
+
|
|
179
186
|
$i18n: {
|
|
180
187
|
locale: string
|
|
181
188
|
fallbackLocale: string
|
|
@@ -184,6 +191,7 @@ export interface MpxComponentIns {
|
|
|
184
191
|
$tc: typeof tc
|
|
185
192
|
$te: typeof te
|
|
186
193
|
$tm: typeof tm
|
|
194
|
+
|
|
187
195
|
[k: string]: any
|
|
188
196
|
}
|
|
189
197
|
|
|
@@ -193,17 +201,16 @@ interface ReplaceWxComponentIns {
|
|
|
193
201
|
selectAllComponents (selector: string): Array<ComponentIns<{}, {}, {}, {}, []>>
|
|
194
202
|
}
|
|
195
203
|
|
|
196
|
-
type WxComponentIns<D extends
|
|
197
|
-
|
|
198
|
-
&
|
|
199
|
-
& WechatMiniprogram.Component.InstanceMethods<D>
|
|
204
|
+
type WxComponentIns<D extends Data = {}, P extends Properties = {}, M extends Methods = {}> =
|
|
205
|
+
Omit<WechatMiniprogram.Component.Instance<D, P, M>, 'selectComponent' | 'selectAllComponents'>
|
|
206
|
+
& ReplaceWxComponentIns
|
|
200
207
|
|
|
201
|
-
type ComponentIns<D extends
|
|
208
|
+
type ComponentIns<D extends Data = {}, P extends Properties = {}, C = {}, M extends Methods = {}, Mi extends Array<any> = [], S extends Record<any, any> = {}, O = {}> =
|
|
202
209
|
GetDataType<D> & UnboxMixinsField<Mi, 'data'> &
|
|
203
210
|
M & UnboxMixinsField<Mi, 'methods'> & { [K in keyof S]: S[K] extends Ref<infer V> ? V : S[K] } &
|
|
204
211
|
GetPropsType<P & UnboxMixinsField<Mi, 'properties'>> &
|
|
205
212
|
GetComputedType<C & UnboxMixinsField<Mi, 'computed'>> &
|
|
206
|
-
WxComponentIns<D> & MpxComponentIns & MpxComProps<O>
|
|
213
|
+
WxComponentIns<D, P, M> & MpxComponentIns & MpxComProps<O>
|
|
207
214
|
|
|
208
215
|
interface CreateConfig {
|
|
209
216
|
customCtor: any
|
|
@@ -486,7 +493,7 @@ export function reactive<T extends object> (target: T): Reactive<T>
|
|
|
486
493
|
|
|
487
494
|
export function isReactive (value: unknown): boolean
|
|
488
495
|
|
|
489
|
-
export function markRaw<T extends object>(value: T): T
|
|
496
|
+
export function markRaw<T extends object> (value: T): T
|
|
490
497
|
|
|
491
498
|
export function shallowReactive<T extends object> (target: T): ShallowReactive<T>
|
|
492
499
|
|
|
@@ -566,6 +573,7 @@ export function onBeforeUnmount (callback: () => void): void
|
|
|
566
573
|
export function onUnmounted (callback: () => void): void
|
|
567
574
|
|
|
568
575
|
export function onLoad<T extends Record<string, string | undefined>> (callback: (query: T) => void): void
|
|
576
|
+
|
|
569
577
|
// wechat dose not have generics
|
|
570
578
|
// export function onLoad (callback: WechatMiniprogram.Page.ILifetime['onLoad']): void
|
|
571
579
|
|
|
@@ -592,7 +600,7 @@ export function onTabItemTap (callback: WechatMiniprogram.Page.ILifetime['onTabI
|
|
|
592
600
|
export function onSaveExitState (callback: () => void): void
|
|
593
601
|
|
|
594
602
|
// get instance
|
|
595
|
-
export function getCurrentInstance<T extends
|
|
603
|
+
export function getCurrentInstance<T extends ComponentIns<{}, {}, {}>> (): T
|
|
596
604
|
|
|
597
605
|
// I18n
|
|
598
606
|
export function useI18n<Options extends {
|
|
@@ -612,8 +620,7 @@ type InferDefaults<T> = {
|
|
|
612
620
|
[K in keyof T]?: InferDefault<T, NotUndefined<T[K]>>
|
|
613
621
|
}
|
|
614
622
|
|
|
615
|
-
type InferDefault<P, T> = T extends
|
|
616
|
-
| null
|
|
623
|
+
type InferDefault<P, T> = T extends | null
|
|
617
624
|
| number
|
|
618
625
|
| string
|
|
619
626
|
| boolean
|
package/@types/node.d.ts
CHANGED
|
@@ -12,19 +12,21 @@ declare let process: {
|
|
|
12
12
|
env: EnvType
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
declare namespace __WebpackModuleApi {
|
|
17
16
|
interface RequireContext {
|
|
18
|
-
keys(): string[];
|
|
17
|
+
keys (): string[];
|
|
18
|
+
|
|
19
19
|
(id: string): any;
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
|
|
21
|
+
<T> (id: string): T;
|
|
22
|
+
|
|
23
|
+
resolve (id: string): string;
|
|
24
|
+
|
|
22
25
|
/** The module id of the context module. This may be useful for module.hot.accept. */
|
|
23
26
|
id: string;
|
|
24
27
|
}
|
|
25
28
|
}
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export function async<T>(path: string): Promise<T>
|
|
30
|
+
interface Require {
|
|
31
|
+
context (path: string, deep?: boolean, filter?: RegExp, mode?: 'sync' | 'eager' | 'weak' | 'lazy' | 'lazy-once'): __WebpackModuleApi.RequireContext
|
|
30
32
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/core",
|
|
3
|
-
"version": "2.9.0-beta.
|
|
3
|
+
"version": "2.9.0-beta.2",
|
|
4
4
|
"description": "mpx runtime core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"miniprogram",
|
|
7
7
|
"mpx"
|
|
8
8
|
],
|
|
9
9
|
"author": "donghongping",
|
|
10
|
-
"license": "Apache",
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
11
|
"module": "src/index.js",
|
|
12
12
|
"types": "@types/index.d.ts",
|
|
13
13
|
"directories": {
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
],
|
|
20
20
|
"main": "src/index.js",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@mpxjs/utils": "^2.
|
|
22
|
+
"@mpxjs/utils": "^2.9.0-beta.1",
|
|
23
23
|
"lodash": "^4.1.1",
|
|
24
|
-
"miniprogram-api-typings": "^3.0
|
|
24
|
+
"miniprogram-api-typings": "^3.10.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@mpxjs/api-proxy": "^2.7.44",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"url": "https://github.com/didi/mpx/issues"
|
|
48
48
|
},
|
|
49
49
|
"sideEffects": false,
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "2d61bab77c50eccb7470b9b9bd644e7bd6510467"
|
|
51
51
|
}
|
|
@@ -4,6 +4,19 @@ export default function pageRouteMixin (mixinType) {
|
|
|
4
4
|
return {
|
|
5
5
|
beforeCreate () {
|
|
6
6
|
this.route = this.$options.__mpxPageRoute || ''
|
|
7
|
+
},
|
|
8
|
+
methods: {
|
|
9
|
+
getOpenerEventChannel () {
|
|
10
|
+
const router = global.__mpxRouter
|
|
11
|
+
const eventChannel = router && router.eventChannelMap[this.route]
|
|
12
|
+
return eventChannel || {}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
methods: {
|
|
19
|
+
getOpenerEventChannel () {
|
|
7
20
|
}
|
|
8
21
|
}
|
|
9
22
|
}
|
|
@@ -18,11 +18,6 @@ export default function proxyEventMixin () {
|
|
|
18
18
|
const originValue = valuePath.reduce((acc, cur) => acc[cur], $event.detail)
|
|
19
19
|
const value = filterMethod ? (innerFilter[filterMethod] ? innerFilter[filterMethod](originValue) : typeof this[filterMethod] === 'function' && this[filterMethod]) : originValue
|
|
20
20
|
setByPath(this, expr, value)
|
|
21
|
-
},
|
|
22
|
-
getOpenerEventChannel () {
|
|
23
|
-
const router = this.$root.$options && this.$root.$options.router
|
|
24
|
-
const eventChannel = router && router.__mpxAction && router.__mpxAction.eventChannel
|
|
25
|
-
return eventChannel
|
|
26
21
|
}
|
|
27
22
|
}
|
|
28
23
|
}
|
|
@@ -81,7 +81,7 @@ export function getDefaultOptions (type, { rawOptions = {} }) {
|
|
|
81
81
|
if (this.__mpxProxy) this.__mpxProxy.callHook(UNMOUNTED)
|
|
82
82
|
},
|
|
83
83
|
serverPrefetch () {
|
|
84
|
-
if (this.__mpxProxy) this.__mpxProxy.callHook(SERVERPREFETCH)
|
|
84
|
+
if (this.__mpxProxy) return this.__mpxProxy.callHook(SERVERPREFETCH)
|
|
85
85
|
}
|
|
86
86
|
}]
|
|
87
87
|
// 为了在builtMixin中可以使用某些rootMixin实现的特性(如数据响应等),此处builtInMixin在rootMixin之后执行,但是当builtInMixin使用存在对应内建生命周期的目标平台声明周期写法时,可能会出现用户生命周期比builtInMixin中的生命周期先执行的情况,为了避免这种情况发生,builtInMixin应该尽可能使用内建生命周期来编写
|
package/src/vuePlugin.js
CHANGED
|
@@ -25,7 +25,7 @@ export default function install (Vue) {
|
|
|
25
25
|
Vue.prototype.createSelectorQuery = function () {
|
|
26
26
|
return webApi.createSelectorQuery().in(this)
|
|
27
27
|
}
|
|
28
|
-
Vue.prototype.createIntersectionObserver = function (
|
|
29
|
-
return webApi.createIntersectionObserver(
|
|
28
|
+
Vue.prototype.createIntersectionObserver = function (options) {
|
|
29
|
+
return webApi.createIntersectionObserver(this, options)
|
|
30
30
|
}
|
|
31
31
|
}
|