@mpxjs/core 2.7.52 → 2.8.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 +342 -27
- package/package.json +10 -5
- package/src/convertor/convertor.js +2 -2
- package/src/convertor/mergeLifecycle.js +4 -4
- package/src/convertor/wxToAli.js +3 -4
- package/src/convertor/wxToSwan.js +2 -2
- package/src/convertor/wxToTt.js +1 -10
- package/src/convertor/wxToWeb.js +14 -7
- package/src/core/implement.js +2 -2
- package/src/core/injectMixins.js +1 -1
- package/src/core/innerLifecycle.js +15 -2
- package/src/core/mergeOptions.js +11 -5
- package/src/core/proxy.js +343 -229
- package/src/core/transferOptions.js +5 -2
- package/src/helper/const.js +10 -0
- package/src/index.js +73 -147
- package/src/observer/array.js +12 -17
- package/src/observer/computed.js +27 -56
- package/src/observer/dep.js +1 -1
- package/src/observer/effect.js +113 -0
- package/src/observer/effectScope.js +109 -0
- package/src/observer/{index.js → reactive.js} +74 -70
- package/src/observer/ref.js +97 -0
- package/src/observer/scheduler.js +171 -56
- package/src/observer/watch.js +163 -39
- package/src/platform/builtInMixins/i18nMixin.js +238 -31
- package/src/platform/builtInMixins/pageScrollMixin.web.js +4 -5
- package/src/platform/builtInMixins/pageStatusMixin.js +76 -54
- package/src/platform/builtInMixins/pageStatusMixin.web.js +35 -22
- package/src/platform/builtInMixins/proxyEventMixin.js +40 -22
- package/src/platform/builtInMixins/proxyEventMixin.web.js +16 -24
- package/src/platform/builtInMixins/refsMixin.js +82 -73
- package/src/platform/builtInMixins/refsMixin.web.js +0 -47
- package/src/platform/builtInMixins/relationsMixin.js +10 -9
- package/src/platform/builtInMixins/renderHelperMixin.js +1 -1
- package/src/platform/builtInMixins/showMixin.js +1 -1
- package/src/platform/createApp.js +5 -5
- package/src/platform/export/api.js +23 -0
- package/src/platform/export/api.web.js +26 -0
- package/src/platform/export/index.js +45 -0
- package/src/platform/export/index.web.js +36 -0
- package/src/platform/index.js +1 -5
- package/src/platform/patch/ali/getDefaultOptions.js +33 -31
- package/src/platform/patch/ali/lifecycle.js +21 -13
- package/src/platform/patch/builtInKeysMap.js +2 -1
- package/src/platform/patch/index.js +4 -9
- package/src/platform/patch/swan/getDefaultOptions.js +3 -3
- package/src/platform/patch/swan/lifecycle.js +17 -14
- package/src/platform/patch/web/getDefaultOptions.js +40 -16
- package/src/platform/patch/web/lifecycle.js +6 -3
- package/src/platform/patch/wx/getDefaultOptions.js +38 -31
- package/src/platform/patch/wx/lifecycle.js +18 -11
- package/src/runtime/createFactory.js +6 -2
- package/src/vue.web.js +3 -0
- package/src/vuePlugin.js +31 -0
- package/src/core/createStore.js +0 -241
- package/src/core/mapStore.js +0 -94
- package/src/helper/env.js +0 -20
- package/src/helper/getByPath.js +0 -127
- package/src/helper/log.js +0 -31
- package/src/helper/utils.js +0 -652
- package/src/observer/watcher.js +0 -244
package/src/helper/getByPath.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
let curStack
|
|
2
|
-
let targetStacks
|
|
3
|
-
let property
|
|
4
|
-
|
|
5
|
-
class Stack {
|
|
6
|
-
constructor (mark) {
|
|
7
|
-
this.mark = mark
|
|
8
|
-
// 字符串stack需要特殊处理
|
|
9
|
-
this.type = /['"]/.test(mark) ? 'string' : 'normal'
|
|
10
|
-
this.value = []
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
push (data) {
|
|
14
|
-
this.value.push(data)
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function startStack (mark) {
|
|
19
|
-
// 开启栈或关闭栈都意味着前面的字符拼接截止
|
|
20
|
-
propertyJoinOver()
|
|
21
|
-
curStack && targetStacks.push(curStack)
|
|
22
|
-
curStack = new Stack(mark)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function endStack () {
|
|
26
|
-
// 开启栈或关闭栈都意味着前面的字符拼接截止
|
|
27
|
-
propertyJoinOver()
|
|
28
|
-
// 字符串栈直接拼接
|
|
29
|
-
const result = curStack.type === 'string' ? '__mpx_str_' + curStack.value.join('') : curStack.value
|
|
30
|
-
curStack = targetStacks.pop()
|
|
31
|
-
// 将当前stack结果保存到父级stack里
|
|
32
|
-
curStack.push(result)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function propertyJoinOver () {
|
|
36
|
-
property = property.trim()
|
|
37
|
-
if (property) curStack.push(property)
|
|
38
|
-
property = ''
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function init () {
|
|
42
|
-
property = ''
|
|
43
|
-
// 根stack
|
|
44
|
-
curStack = new Stack()
|
|
45
|
-
targetStacks = []
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function parse (str) {
|
|
49
|
-
init()
|
|
50
|
-
for (const char of str) {
|
|
51
|
-
// 当前遍历引号内的字符串时
|
|
52
|
-
if (curStack.type === 'string') {
|
|
53
|
-
// 若为对应的结束flag,则出栈,反之直接push
|
|
54
|
-
curStack.mark === char ? endStack() : curStack.push(char)
|
|
55
|
-
} else if (/['"[]/.test(char)) {
|
|
56
|
-
startStack(char)
|
|
57
|
-
} else if (char === ']') {
|
|
58
|
-
endStack()
|
|
59
|
-
} else if (char === '.' || char === '+') {
|
|
60
|
-
propertyJoinOver()
|
|
61
|
-
if (char === '+') curStack.push(char)
|
|
62
|
-
} else {
|
|
63
|
-
property += char
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
// 字符解析收尾
|
|
67
|
-
propertyJoinOver()
|
|
68
|
-
return curStack.value
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function outPutByPath (context, path, isSimple, transfer) {
|
|
72
|
-
let result = context
|
|
73
|
-
const len = path.length
|
|
74
|
-
const meta = {
|
|
75
|
-
isEnd: false,
|
|
76
|
-
stop: false
|
|
77
|
-
}
|
|
78
|
-
for (let index = 0; index < len; index++) {
|
|
79
|
-
if (index === len - 1) meta.isEnd = true
|
|
80
|
-
let key
|
|
81
|
-
const item = path[index]
|
|
82
|
-
if (result) {
|
|
83
|
-
if (isSimple) {
|
|
84
|
-
key = item
|
|
85
|
-
} else if (Array.isArray(item)) {
|
|
86
|
-
// 获取子数组的输出结果作为当前key
|
|
87
|
-
key = outPutByPath(context, item, isSimple, transfer)
|
|
88
|
-
} else if (/^__mpx_str_/.test(item)) {
|
|
89
|
-
// 字符串一定会被[]包裹,一定在子数组中
|
|
90
|
-
result = item.replace('__mpx_str_', '')
|
|
91
|
-
} else if (/^\d+$/.test(item)) {
|
|
92
|
-
// 数字一定会被[]包裹,一定在子数组中
|
|
93
|
-
result = +item
|
|
94
|
-
} else if (item === '+') {
|
|
95
|
-
// 获取加号后面所有path最终的结果
|
|
96
|
-
result += outPutByPath(context, path.slice(index + 1), isSimple, transfer)
|
|
97
|
-
break
|
|
98
|
-
} else {
|
|
99
|
-
key = item
|
|
100
|
-
}
|
|
101
|
-
if (key !== undefined) {
|
|
102
|
-
result = transfer ? transfer(result, key, meta) : result[key]
|
|
103
|
-
if (meta.stop) break
|
|
104
|
-
}
|
|
105
|
-
} else {
|
|
106
|
-
break
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return result
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export default function getByPath (context, pathStrOrArr, transfer) {
|
|
113
|
-
if (!pathStrOrArr) {
|
|
114
|
-
return context
|
|
115
|
-
}
|
|
116
|
-
let isSimple = false
|
|
117
|
-
if (Array.isArray(pathStrOrArr)) {
|
|
118
|
-
isSimple = true
|
|
119
|
-
} else if (!/[[\]]/.test(pathStrOrArr)) {
|
|
120
|
-
pathStrOrArr = pathStrOrArr.split('.')
|
|
121
|
-
isSimple = true
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (!isSimple) pathStrOrArr = parse(pathStrOrArr)
|
|
125
|
-
|
|
126
|
-
return outPutByPath(context, pathStrOrArr, isSimple, transfer)
|
|
127
|
-
}
|
package/src/helper/log.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import EXPORT_MPX from '../index'
|
|
2
|
-
|
|
3
|
-
export function warn (msg, location, e) {
|
|
4
|
-
const condition = EXPORT_MPX.config.ignoreWarning
|
|
5
|
-
let ignore = false
|
|
6
|
-
if (typeof condition === 'boolean') {
|
|
7
|
-
ignore = condition
|
|
8
|
-
} else if (typeof condition === 'string') {
|
|
9
|
-
ignore = msg.indexOf(condition) !== -1
|
|
10
|
-
} else if (typeof condition === 'function') {
|
|
11
|
-
ignore = condition(msg, location, e)
|
|
12
|
-
} else if (condition instanceof RegExp) {
|
|
13
|
-
ignore = condition.test(msg)
|
|
14
|
-
}
|
|
15
|
-
if (!ignore) return log('warn', msg, location, e)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function error (msg, location, e) {
|
|
19
|
-
return log('error', msg, location, e)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function log (type, msg, location, e) {
|
|
23
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
24
|
-
let header = `[Mpx runtime ${type}]: `
|
|
25
|
-
if (location) {
|
|
26
|
-
header = `[Mpx runtime ${type} at ${location}]: `
|
|
27
|
-
}
|
|
28
|
-
console[type](header + msg)
|
|
29
|
-
if (e) console[type](e)
|
|
30
|
-
}
|
|
31
|
-
}
|