@mpxjs/core 2.9.27 → 2.9.33
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.9.
|
|
3
|
+
"version": "2.9.33",
|
|
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": "5a8b6accc9462d4c9a35e06689a6a84903d47c52"
|
|
51
51
|
}
|
|
@@ -6,36 +6,39 @@ function getEl (ref) {
|
|
|
6
6
|
if (ref && ref.$options && ref.$options.__mpxBuiltIn) return ref.$el
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
function processRefs (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
function processRefs (target) {
|
|
10
|
+
const refs = target.$refs
|
|
11
|
+
if (refs) {
|
|
12
|
+
Object.keys(refs).forEach((key) => {
|
|
13
|
+
const matched = /^__mpx_ref_(.+)__$/.exec(key)
|
|
14
|
+
const rKey = matched && matched[1]
|
|
15
|
+
if (rKey) {
|
|
16
|
+
const ref = refs[key]
|
|
17
|
+
if (Array.isArray(ref)) {
|
|
18
|
+
if (getEl(ref[0])) {
|
|
19
|
+
refs[rKey] = createSelectorQuery().in(target).selectAll(ref.map(getEl))
|
|
20
|
+
} else {
|
|
21
|
+
refs[rKey] = ref
|
|
22
|
+
}
|
|
18
23
|
} else {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} else {
|
|
25
|
-
refs[rKey] = ref
|
|
24
|
+
if (getEl(ref)) {
|
|
25
|
+
refs[rKey] = createSelectorQuery().in(target).select(getEl(ref))
|
|
26
|
+
} else {
|
|
27
|
+
refs[rKey] = ref
|
|
28
|
+
}
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
31
|
+
})
|
|
32
|
+
}
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
export default function getRefsMixin () {
|
|
33
36
|
return {
|
|
34
37
|
[BEFOREMOUNT] () {
|
|
35
|
-
processRefs(this
|
|
38
|
+
processRefs(this)
|
|
36
39
|
},
|
|
37
40
|
[UPDATED] () {
|
|
38
|
-
processRefs(this
|
|
41
|
+
processRefs(this)
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
}
|
|
@@ -1,61 +1,3 @@
|
|
|
1
|
-
import { EffectScope } from 'vue'
|
|
2
|
-
import { hasOwn } from '@mpxjs/utils'
|
|
3
|
-
import { PausedState } from '../../helper/const'
|
|
4
|
-
|
|
5
|
-
const hackEffectScope = () => {
|
|
6
|
-
EffectScope.prototype.pause = function () {
|
|
7
|
-
if (this.active) {
|
|
8
|
-
let i, l
|
|
9
|
-
for (i = 0, l = this.effects.length; i < l; i++) {
|
|
10
|
-
const effect = this.effects[i]
|
|
11
|
-
// vue2.7中存在对于watcher实例方法的重写(doWatch),因此无法通过修改Watcher.prototype统一实现pause和resume,只能逐个实例修改实现
|
|
12
|
-
if (!hasOwn(effect, 'pausedState')) {
|
|
13
|
-
effect.pausedState = PausedState.resumed
|
|
14
|
-
const rawUpdate = effect.update
|
|
15
|
-
effect.update = function () {
|
|
16
|
-
if (effect.pausedState !== PausedState.resumed) {
|
|
17
|
-
effect.pausedState = PausedState.dirty
|
|
18
|
-
} else {
|
|
19
|
-
rawUpdate.call(effect)
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (effect.pausedState !== PausedState.dirty) {
|
|
24
|
-
effect.pausedState = PausedState.paused
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (this.scopes) {
|
|
28
|
-
for (i = 0, l = this.scopes.length; i < l; i++) {
|
|
29
|
-
this.scopes[i].pause()
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
EffectScope.prototype.resume = function (ignoreDirty = false) {
|
|
36
|
-
if (this.active) {
|
|
37
|
-
let i, l
|
|
38
|
-
for (i = 0, l = this.effects.length; i < l; i++) {
|
|
39
|
-
const effect = this.effects[i]
|
|
40
|
-
if (hasOwn(effect, 'pausedState')) {
|
|
41
|
-
const lastPausedState = effect.pausedState
|
|
42
|
-
effect.pausedState = PausedState.resumed
|
|
43
|
-
if (!ignoreDirty && lastPausedState === PausedState.dirty) {
|
|
44
|
-
effect.update()
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (this.scopes) {
|
|
49
|
-
for (i = 0, l = this.scopes.length; i < l; i++) {
|
|
50
|
-
this.scopes[i].resume(ignoreDirty)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
hackEffectScope()
|
|
58
|
-
|
|
59
1
|
export {
|
|
60
2
|
// watch
|
|
61
3
|
watchEffect,
|
package/src/vuePlugin.js
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
import { walkChildren, parseSelector, error, hasOwn } from '@mpxjs/utils'
|
|
2
2
|
import { createSelectorQuery, createIntersectionObserver } from '@mpxjs/api-proxy'
|
|
3
|
+
import { EffectScope } from 'vue'
|
|
4
|
+
import { PausedState } from './helper/const'
|
|
5
|
+
|
|
6
|
+
const hackEffectScope = () => {
|
|
7
|
+
EffectScope.prototype.pause = function () {
|
|
8
|
+
if (this.active) {
|
|
9
|
+
let i, l
|
|
10
|
+
for (i = 0, l = this.effects.length; i < l; i++) {
|
|
11
|
+
const effect = this.effects[i]
|
|
12
|
+
// vue2.7中存在对于watcher实例方法的重写(doWatch),因此无法通过修改Watcher.prototype统一实现pause和resume,只能逐个实例修改实现
|
|
13
|
+
if (!hasOwn(effect, 'pausedState')) {
|
|
14
|
+
effect.pausedState = PausedState.resumed
|
|
15
|
+
const rawUpdate = effect.update
|
|
16
|
+
effect.update = function () {
|
|
17
|
+
if (effect.pausedState !== PausedState.resumed) {
|
|
18
|
+
effect.pausedState = PausedState.dirty
|
|
19
|
+
} else {
|
|
20
|
+
rawUpdate.call(effect)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (effect.pausedState !== PausedState.dirty) {
|
|
25
|
+
effect.pausedState = PausedState.paused
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (this.scopes) {
|
|
29
|
+
for (i = 0, l = this.scopes.length; i < l; i++) {
|
|
30
|
+
this.scopes[i].pause()
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
EffectScope.prototype.resume = function (ignoreDirty = false) {
|
|
37
|
+
if (this.active) {
|
|
38
|
+
let i, l
|
|
39
|
+
for (i = 0, l = this.effects.length; i < l; i++) {
|
|
40
|
+
const effect = this.effects[i]
|
|
41
|
+
if (hasOwn(effect, 'pausedState')) {
|
|
42
|
+
const lastPausedState = effect.pausedState
|
|
43
|
+
effect.pausedState = PausedState.resumed
|
|
44
|
+
if (!ignoreDirty && lastPausedState === PausedState.dirty) {
|
|
45
|
+
effect.update()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (this.scopes) {
|
|
50
|
+
for (i = 0, l = this.scopes.length; i < l; i++) {
|
|
51
|
+
this.scopes[i].resume(ignoreDirty)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
3
58
|
const datasetReg = /^data-(.+)$/
|
|
4
59
|
|
|
5
60
|
function collectDataset (attrs) {
|
|
@@ -55,4 +110,5 @@ export default function install (Vue) {
|
|
|
55
110
|
Vue.prototype.createIntersectionObserver = function (options) {
|
|
56
111
|
return createIntersectionObserver(this, options)
|
|
57
112
|
}
|
|
113
|
+
hackEffectScope()
|
|
58
114
|
}
|