@mpxjs/core 2.8.25-alpha → 2.8.25-alpha.16
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/core",
|
|
3
|
-
"version": "2.8.25-alpha",
|
|
3
|
+
"version": "2.8.25-alpha.16",
|
|
4
4
|
"description": "mpx runtime core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"miniprogram",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"miniprogram-api-typings": "^3.0.2"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@hummer/tenon-store": "^1.
|
|
27
|
+
"@hummer/tenon-store": "^1.7.0",
|
|
28
28
|
"@hummer/tenon-vue": "^1.5.1",
|
|
29
|
-
"@mpxjs/api-proxy": "^2.
|
|
29
|
+
"@mpxjs/api-proxy": "^2.8.25-alpha.9",
|
|
30
30
|
"@mpxjs/store": "^2.8.0",
|
|
31
31
|
"vue": "^2.7.10",
|
|
32
32
|
"vue-demi": "^0.13.11",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"url": "https://github.com/didi/mpx/issues"
|
|
50
50
|
},
|
|
51
51
|
"sideEffects": false,
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "789c7a66f35f64ba4a631d3ead693f6a302d96bb"
|
|
53
53
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
effectScope as vueEffectScope,
|
|
3
|
+
getCurrentScope as getCurrentVueScope,
|
|
4
|
+
onScopeDispose
|
|
5
|
+
} from '@hummer/tenon-vue'
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
hasOwn,
|
|
9
|
+
isValidArrayIndex
|
|
10
|
+
} from '@mpxjs/utils'
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
// watch
|
|
14
|
+
watchEffect,
|
|
15
|
+
watchSyncEffect,
|
|
16
|
+
watchPostEffect,
|
|
17
|
+
watch,
|
|
18
|
+
// reactive
|
|
19
|
+
reactive,
|
|
20
|
+
isReactive,
|
|
21
|
+
shallowReactive,
|
|
22
|
+
markRaw,
|
|
23
|
+
// ref
|
|
24
|
+
ref,
|
|
25
|
+
unref,
|
|
26
|
+
toRef,
|
|
27
|
+
toRefs,
|
|
28
|
+
isRef,
|
|
29
|
+
customRef,
|
|
30
|
+
shallowRef,
|
|
31
|
+
triggerRef,
|
|
32
|
+
// computed
|
|
33
|
+
computed,
|
|
34
|
+
// instance
|
|
35
|
+
getCurrentInstance
|
|
36
|
+
} from '@hummer/tenon-vue'
|
|
37
|
+
|
|
38
|
+
export function set (target, key, val) {
|
|
39
|
+
if (Array.isArray(target) && isValidArrayIndex(key)) {
|
|
40
|
+
target.length = Math.max(target.length, key)
|
|
41
|
+
target.splice(key, 1, val)
|
|
42
|
+
return val
|
|
43
|
+
}
|
|
44
|
+
target[key] = val
|
|
45
|
+
return val
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function del (target, key) {
|
|
49
|
+
if (Array.isArray(target) && isValidArrayIndex(key)) {
|
|
50
|
+
target.splice(key, 1)
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
if (!hasOwn(target, key)) {
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
delete target[key]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const noop = () => {
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const fixEffectScope = (scope) => {
|
|
63
|
+
scope.pause = noop
|
|
64
|
+
scope.resume = noop
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const effectScope = (detached) => fixEffectScope(vueEffectScope(detached))
|
|
68
|
+
const getCurrentScope = () => fixEffectScope(getCurrentVueScope())
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
// effectScope
|
|
72
|
+
effectScope,
|
|
73
|
+
getCurrentScope,
|
|
74
|
+
onScopeDispose
|
|
75
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import builtInKeysMap from '../builtInKeysMap'
|
|
2
2
|
import mergeOptions from '../../../core/mergeOptions'
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
3
|
+
import { getCurrentInstance as getCurrentVueInstance } from '../../export/index'
|
|
4
|
+
import MpxProxy, { setCurrentInstance, unsetCurrentInstance } from '../../../core/proxy'
|
|
5
|
+
import { diffAndCloneA, warn } from '@mpxjs/utils'
|
|
5
6
|
import { UPDATED, CREATED, MOUNTED, UNMOUNTED } from '../../../core/innerLifecycle'
|
|
6
7
|
|
|
7
8
|
function filterOptions (options) {
|
|
@@ -25,20 +26,59 @@ function filterOptions (options) {
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
function initProxy (context, rawOptions) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
if (!context.__mpxProxy) {
|
|
30
|
+
// 缓存options
|
|
31
|
+
context.$rawOptions = rawOptions
|
|
32
|
+
// 创建proxy对象
|
|
33
|
+
context.__mpxProxy = new MpxProxy(rawOptions, context)
|
|
34
|
+
// todo 待问题修复后需要还原
|
|
35
|
+
// context.__mpxProxy.callHook(CREATED, Hummer.pageInfo && Hummer.pageInfo.params && [Hummer.pageInfo.params])
|
|
36
|
+
}
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
export function getDefaultOptions (type, { rawOptions = {}, currentInject }) {
|
|
40
|
+
const rawSetup = rawOptions.setup
|
|
41
|
+
if (rawSetup) {
|
|
42
|
+
rawOptions.setup = (props) => {
|
|
43
|
+
const { proxy: instance } = getCurrentVueInstance()
|
|
44
|
+
initProxy(instance, rawOptions)
|
|
45
|
+
setCurrentInstance(instance.__mpxProxy)
|
|
46
|
+
const newContext = {
|
|
47
|
+
triggerEvent: (eventName, eventDetail) => {
|
|
48
|
+
return instance.$emit(eventName, {
|
|
49
|
+
type: eventName,
|
|
50
|
+
detail: eventDetail
|
|
51
|
+
})
|
|
52
|
+
},
|
|
53
|
+
get refs () { return instance.$refs },
|
|
54
|
+
forceUpdate: instance.$forceUpdate.bind(instance),
|
|
55
|
+
selectComponent: () => {
|
|
56
|
+
warn('selectComponent is not supported in Tenon')
|
|
57
|
+
},
|
|
58
|
+
selectAllComponents: () => {
|
|
59
|
+
warn('selectAllComponents is not supported in Tenon')
|
|
60
|
+
},
|
|
61
|
+
createSelectorQuery: () => {
|
|
62
|
+
warn('createSelectorQuery is not supported in Tenon')
|
|
63
|
+
},
|
|
64
|
+
createIntersectionObserver: () => {
|
|
65
|
+
warn('createIntersectionObserver is not supported in Tenon')
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const setupRes = rawSetup(props, newContext)
|
|
69
|
+
unsetCurrentInstance(instance.__mpxProxy)
|
|
70
|
+
return setupRes
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
36
74
|
const hookNames = type === 'page' ? ['onLoad', 'onReady', 'onUnload'] : ['created', 'mounted', 'unmounted']
|
|
37
75
|
const rootMixins = [{
|
|
38
76
|
[hookNames[0]] (...params) {
|
|
39
77
|
if (!this.__mpxProxy) {
|
|
40
78
|
initProxy(this, rawOptions, currentInject, params)
|
|
41
79
|
}
|
|
80
|
+
// todo 待问题修复后需要移除,目前逻辑是已经创建实例的情况下依旧会重复执行
|
|
81
|
+
this.__mpxProxy.callHook(CREATED, Hummer.pageInfo && Hummer.pageInfo.params && [Hummer.pageInfo.params])
|
|
42
82
|
},
|
|
43
83
|
[hookNames[1]] () {
|
|
44
84
|
this.__mpxProxy && this.__mpxProxy.callHook(MOUNTED, Hummer.pageInfo && Hummer.pageInfo.params && [Hummer.pageInfo.params])
|