@mpxjs/core 2.6.94 → 2.6.98
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
|
@@ -146,7 +146,6 @@ interface ComponentOpt<D, P, C, M, Mi extends Array<any>> extends Partial<Wechat
|
|
|
146
146
|
|
|
147
147
|
externalClasses?: string[]
|
|
148
148
|
|
|
149
|
-
|
|
150
149
|
lifetimes?: Partial<WechatMiniprogram.Component.Lifetimes>
|
|
151
150
|
|
|
152
151
|
pageLifetimes?: Partial<WechatMiniprogram.Component.PageLifetimes>
|
|
@@ -164,7 +163,6 @@ type ThisTypedPageOpt<D, P, C, M, Mi extends Array<any>, O = {}> =
|
|
|
164
163
|
PageOpt<D, P, C, M, Mi>
|
|
165
164
|
& ThisType<ComponentIns<D, P, C, M, Mi, O>> & O
|
|
166
165
|
|
|
167
|
-
|
|
168
166
|
type ThisTypedComponentOpt<D, P, C, M, Mi extends Array<any>, O = {}> =
|
|
169
167
|
ComponentOpt<D, P, C, M, Mi>
|
|
170
168
|
& ThisType<ComponentIns<D, P, C, M, Mi, O>> & O
|
|
@@ -236,11 +234,11 @@ type ComponentIns<D, P, C, M, Mi extends Array<any>, O = {}> =
|
|
|
236
234
|
GetComputedType<C & UnboxMixinsField<Mi, 'computed'>> &
|
|
237
235
|
WxComponentIns<D> & MpxComponentIns & MpxComProps<O>
|
|
238
236
|
|
|
239
|
-
interface
|
|
237
|
+
interface CreateConfig {
|
|
240
238
|
customCtor: any
|
|
241
239
|
}
|
|
242
240
|
|
|
243
|
-
export function createComponent<D extends Data = {}, P extends Properties = {}, C = {}, M extends Methods = {}, Mi extends Array<any> = [], O = {}> (opt: ThisTypedComponentOpt<D, P, C, M, Mi, O>, config?:
|
|
241
|
+
export function createComponent<D extends Data = {}, P extends Properties = {}, C = {}, M extends Methods = {}, Mi extends Array<any> = [], O = {}> (opt: ThisTypedComponentOpt<D, P, C, M, Mi, O>, config?: CreateConfig): void
|
|
244
242
|
|
|
245
243
|
export function getMixin<D extends Data = {}, P extends Properties = {}, C = {}, M extends Methods = {}, Mi extends Array<any> = [], O = {}> (opt: ThisTypedComponentOpt<D, P, C, M, Mi, O>): {
|
|
246
244
|
data: GetDataType<D> & UnboxMixinsField<Mi, 'data'>
|
|
@@ -250,9 +248,9 @@ export function getMixin<D extends Data = {}, P extends Properties = {}, C = {},
|
|
|
250
248
|
[index: string]: any
|
|
251
249
|
}
|
|
252
250
|
|
|
253
|
-
export function createPage<D extends Data = {}, P extends Properties = {}, C = {}, M extends Methods = {}, Mi extends Array<any> = [], O = {}> (opt: ThisTypedPageOpt<D, P, C, M, Mi, O>, config?:
|
|
251
|
+
export function createPage<D extends Data = {}, P extends Properties = {}, C = {}, M extends Methods = {}, Mi extends Array<any> = [], O = {}> (opt: ThisTypedPageOpt<D, P, C, M, Mi, O>, config?: CreateConfig): void
|
|
254
252
|
|
|
255
|
-
export function createApp<T extends WechatMiniprogram.IAnyObject> (opt: WechatMiniprogram.App.Options<T>, config?:
|
|
253
|
+
export function createApp<T extends WechatMiniprogram.IAnyObject> (opt: WechatMiniprogram.App.Options<T>, config?: CreateConfig): void
|
|
256
254
|
|
|
257
255
|
export function createStore<S, G extends Getters<S>, M extends Mutations<S>, A extends Actions<S, G>, D extends Deps = {}> (option: StoreOpt<S, G, M, A, D>): Store<S, G, M, A, D>
|
|
258
256
|
|
|
@@ -286,19 +284,9 @@ export function createActionsWithThis<S = {}, G = {}, M extends MutationsAndActi
|
|
|
286
284
|
deps?: D
|
|
287
285
|
}): A
|
|
288
286
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
declare class Watcher {
|
|
292
|
-
constructor (context: any, expr: string | (() => any), handler: WatchHandler | WatchOptWithHandler, options?: WatchOpt)
|
|
293
|
-
|
|
294
|
-
getValue (): any
|
|
287
|
+
type MixinType = 'app' | 'page' | 'component'
|
|
295
288
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
run (): void
|
|
299
|
-
|
|
300
|
-
destroy (): void
|
|
301
|
-
}
|
|
289
|
+
export function injectMixins (mixins: object | Array<object>, options?: MixinType | MixinType[] | { types?: MixinType | MixinType[], stage?: number }): void
|
|
302
290
|
|
|
303
291
|
export function watch (expr: string | (() => any), handler: WatchHandler | WatchOptWithHandler, options?: WatchOpt): () => void
|
|
304
292
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/core",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.98",
|
|
4
4
|
"description": "mpx runtime core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"miniprogram",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"url": "https://github.com/didi/mpx/issues"
|
|
41
41
|
},
|
|
42
42
|
"sideEffects": false,
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "c92623625bb16ba8d73c6795fbb36de34570ee51"
|
|
44
44
|
}
|
package/src/convertor/wxToAli.js
CHANGED
|
@@ -5,7 +5,6 @@ import { mergeToArray } from '../core/mergeOptions'
|
|
|
5
5
|
import { error } from '../helper/log'
|
|
6
6
|
import { implemented } from '../core/implement'
|
|
7
7
|
import { hasOwn } from '../helper/utils'
|
|
8
|
-
import { CREATED } from '../core/innerLifecycle'
|
|
9
8
|
|
|
10
9
|
const unsupported = ['moved', 'definitionFilter']
|
|
11
10
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { error } from '../helper/log'
|
|
2
2
|
import { implemented } from '../core/implement'
|
|
3
|
-
import { CREATED } from '../core/innerLifecycle'
|
|
4
3
|
import { mergeLifecycle } from './mergeLifecycle'
|
|
5
4
|
import * as wxLifecycle from '../platform/patch/wx/lifecycle'
|
|
6
5
|
import * as swanLifecycle from '../platform/patch/swan/lifecycle'
|
package/src/convertor/wxToWeb.js
CHANGED
|
@@ -4,7 +4,6 @@ import { mergeLifecycle } from './mergeLifecycle'
|
|
|
4
4
|
import { error } from '../helper/log'
|
|
5
5
|
import { isObject, diffAndCloneA, hasOwn } from '../helper/utils'
|
|
6
6
|
import { implemented } from '../core/implement'
|
|
7
|
-
import { CREATED } from '../core/innerLifecycle'
|
|
8
7
|
|
|
9
8
|
// 暂不支持的wx选项,后期需要各种花式支持
|
|
10
9
|
const unsupported = ['moved', 'definitionFilter', 'onShareAppMessage', 'pageShow', 'pageHide']
|
package/src/core/injectMixins.js
CHANGED
|
@@ -1,38 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import flatten from 'lodash/flatten.js'
|
|
2
|
+
|
|
3
|
+
const mixinsQueueMap = {
|
|
4
|
+
app: [[], []],
|
|
5
|
+
page: [[], []],
|
|
6
|
+
component: [[], []]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function clearInjectMixins () {
|
|
10
|
+
mixinsQueueMap.app = [[], []]
|
|
11
|
+
mixinsQueueMap.page = [[], []]
|
|
12
|
+
mixinsQueueMap.component = [[], []]
|
|
5
13
|
}
|
|
6
14
|
|
|
7
|
-
export function injectMixins (mixins,
|
|
8
|
-
if (typeof
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
export function injectMixins (mixins, options = {}) {
|
|
16
|
+
if (typeof options === 'string' || Array.isArray(options)) {
|
|
17
|
+
options = {
|
|
18
|
+
types: options
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let types = options.types || ['app', 'page', 'component']
|
|
23
|
+
let stage = options.stage || -1
|
|
24
|
+
|
|
25
|
+
if (typeof types === 'string') {
|
|
26
|
+
types = [types]
|
|
12
27
|
}
|
|
13
28
|
|
|
14
29
|
if (!Array.isArray(mixins)) {
|
|
15
30
|
mixins = [mixins]
|
|
16
31
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
32
|
+
|
|
33
|
+
mixins.stage = stage
|
|
34
|
+
|
|
35
|
+
types.forEach(type => {
|
|
36
|
+
const mixinsQueue = stage < 0 ? mixinsQueueMap[type][0] : mixinsQueueMap[type][1]
|
|
37
|
+
for (let i = 0; i <= mixinsQueue.length; i++) {
|
|
38
|
+
if (i === mixinsQueue.length) {
|
|
39
|
+
mixinsQueue.push(mixins)
|
|
40
|
+
break
|
|
41
|
+
}
|
|
42
|
+
const item = mixinsQueue[i]
|
|
43
|
+
if (mixins === item) break
|
|
44
|
+
if (stage < item.stage) {
|
|
45
|
+
mixinsQueue.splice(i, 0, mixins)
|
|
46
|
+
break
|
|
22
47
|
}
|
|
23
48
|
}
|
|
24
49
|
})
|
|
25
|
-
return this
|
|
26
|
-
}
|
|
27
50
|
|
|
28
|
-
|
|
29
|
-
return MIXINS_MAPS[type].slice(0)
|
|
51
|
+
return this
|
|
30
52
|
}
|
|
31
53
|
|
|
32
54
|
export function mergeInjectedMixins (options, type) {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
55
|
+
const before = flatten(mixinsQueueMap[type][0])
|
|
56
|
+
const middle = options.mixins || []
|
|
57
|
+
const after = flatten(mixinsQueueMap[type][1])
|
|
58
|
+
const mixins = before.concat(middle).concat(after)
|
|
59
|
+
if (mixins.length) {
|
|
60
|
+
options.mixins = mixins
|
|
36
61
|
}
|
|
37
62
|
return options
|
|
38
63
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { error } from '../../helper/log'
|
|
2
1
|
import { getOffsetTop, getElement, getScrollTop, preventDefault } from './dom'
|
|
3
2
|
import EventEmitter from './EventEmitter'
|
|
4
3
|
import EventRegister from './EventRegister'
|
|
@@ -197,11 +196,13 @@ export default class MpxScroll {
|
|
|
197
196
|
)
|
|
198
197
|
}
|
|
199
198
|
|
|
200
|
-
pageScrollTo (
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
199
|
+
pageScrollTo (
|
|
200
|
+
{
|
|
201
|
+
scrollTop,
|
|
202
|
+
selector,
|
|
203
|
+
duration = 300
|
|
204
|
+
}
|
|
205
|
+
) {
|
|
205
206
|
let _scrollTop
|
|
206
207
|
|
|
207
208
|
if (isDef(scrollTop)) {
|
|
@@ -209,7 +210,7 @@ export default class MpxScroll {
|
|
|
209
210
|
} else if (isDef(selector)) {
|
|
210
211
|
_scrollTop = getOffsetTop(getElement(selector))
|
|
211
212
|
} else {
|
|
212
|
-
return error('[pageScrollTo error]: scrollTop and selector are not defined')
|
|
213
|
+
return console.error('[pageScrollTo error]: scrollTop and selector are not defined')
|
|
213
214
|
}
|
|
214
215
|
|
|
215
216
|
if (duration === 0) {
|