@mpxjs/webpack-plugin 2.6.113 → 2.6.114-alpha.0
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/lib/config.js +14 -0
- package/lib/dependency/AddEntryDependency.js +24 -0
- package/lib/dependency/ResolveDependency.js +4 -0
- package/lib/index.js +44 -3
- package/lib/json-compiler/index.js +3 -0
- package/lib/loader.js +43 -2
- package/lib/path-loader.js +4 -1
- package/lib/platform/template/wx/component-config/button.js +14 -2
- package/lib/platform/template/wx/component-config/image.js +4 -0
- package/lib/platform/template/wx/component-config/input.js +4 -0
- package/lib/platform/template/wx/component-config/rich-text.js +4 -0
- package/lib/platform/template/wx/component-config/scroll-view.js +4 -0
- package/lib/platform/template/wx/component-config/switch.js +4 -0
- package/lib/platform/template/wx/component-config/text.js +4 -0
- package/lib/platform/template/wx/component-config/textarea.js +5 -0
- package/lib/platform/template/wx/component-config/view.js +4 -0
- package/lib/platform/template/wx/index.js +114 -1
- package/lib/runtime/components/tenon/filterTag.js +402 -0
- package/lib/runtime/components/tenon/getInnerListeners.js +292 -0
- package/lib/runtime/components/tenon/tenon-button.vue +305 -0
- package/lib/runtime/components/tenon/tenon-image.vue +61 -0
- package/lib/runtime/components/tenon/tenon-input.vue +95 -0
- package/lib/runtime/components/tenon/tenon-rich-text.vue +30 -0
- package/lib/runtime/components/tenon/tenon-scroll-view.vue +118 -0
- package/lib/runtime/components/tenon/tenon-switch.vue +91 -0
- package/lib/runtime/components/tenon/tenon-text-area.vue +64 -0
- package/lib/runtime/components/tenon/tenon-text.vue +64 -0
- package/lib/runtime/components/tenon/tenon-view.vue +89 -0
- package/lib/runtime/components/tenon/util.js +44 -0
- package/lib/runtime/optionProcessor.tenon.js +386 -0
- package/lib/template-compiler/compiler.js +11 -2
- package/lib/template-compiler/trans-dynamic-class-expr.js +1 -1
- package/lib/tenon/index.js +108 -0
- package/lib/tenon/processJSON.js +361 -0
- package/lib/tenon/processScript.js +260 -0
- package/lib/tenon/processStyles.js +21 -0
- package/lib/tenon/processTemplate.js +133 -0
- package/lib/utils/get-relative-path.js +24 -0
- package/package.json +7 -3
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
|
|
2
|
+
<script>
|
|
3
|
+
import { h } from "@hummer/tenon-vue";
|
|
4
|
+
import getInnerListeners from "./getInnerListeners";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
name: "mpx-textarea",
|
|
8
|
+
props: {
|
|
9
|
+
name: String,
|
|
10
|
+
value: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: "",
|
|
13
|
+
},
|
|
14
|
+
placeholder: String,
|
|
15
|
+
disabled: Boolean,
|
|
16
|
+
maxlength: {
|
|
17
|
+
type: Number,
|
|
18
|
+
default: 140,
|
|
19
|
+
},
|
|
20
|
+
autoFocus: Boolean,
|
|
21
|
+
focus: Boolean,
|
|
22
|
+
cursor: {
|
|
23
|
+
type: Number,
|
|
24
|
+
default: -1,
|
|
25
|
+
},
|
|
26
|
+
selectionStart: {
|
|
27
|
+
type: Number,
|
|
28
|
+
default: -1,
|
|
29
|
+
},
|
|
30
|
+
selectionEnd: {
|
|
31
|
+
type: Number,
|
|
32
|
+
default: -1,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
render() {
|
|
37
|
+
const data = {
|
|
38
|
+
class: "mpx-textarea",
|
|
39
|
+
value: this.value,
|
|
40
|
+
focus: this.focus,
|
|
41
|
+
placeholder: this.placeholder,
|
|
42
|
+
maxLength: this.maxLength,
|
|
43
|
+
disabled: this.disabled,
|
|
44
|
+
...getInnerListeners(this),
|
|
45
|
+
};
|
|
46
|
+
return h("textarea", data);
|
|
47
|
+
},
|
|
48
|
+
pageConfig: {
|
|
49
|
+
canScroll: false,
|
|
50
|
+
},
|
|
51
|
+
methods: {},
|
|
52
|
+
};
|
|
53
|
+
</script>
|
|
54
|
+
<style lang="stylus">
|
|
55
|
+
.mpx-textarea
|
|
56
|
+
font inherit
|
|
57
|
+
cursor auto
|
|
58
|
+
width 300hm
|
|
59
|
+
height 150hm
|
|
60
|
+
display block
|
|
61
|
+
position relative
|
|
62
|
+
resize none
|
|
63
|
+
|
|
64
|
+
</style>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
|
|
2
|
+
<script>
|
|
3
|
+
import { h } from "@hummer/tenon-vue";
|
|
4
|
+
import getInnerListeners from "./getInnerListeners";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
name: "mpx-text",
|
|
8
|
+
props: {
|
|
9
|
+
selectable: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
default: false,
|
|
12
|
+
},
|
|
13
|
+
space: {
|
|
14
|
+
type: String,
|
|
15
|
+
},
|
|
16
|
+
decode: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: false,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
render() {
|
|
22
|
+
let text = "";
|
|
23
|
+
let classNames = ["mpx-text"];
|
|
24
|
+
const nodes = this.$slots.default();
|
|
25
|
+
nodes.forEach((item) => {
|
|
26
|
+
if (item.shapeFlag === 8 && item.children) {
|
|
27
|
+
text += item.children;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
// hummer不支持 暂时注释
|
|
31
|
+
// switch (this.space) {
|
|
32
|
+
// case "ensp":
|
|
33
|
+
// case "emsp":
|
|
34
|
+
// case "nbsp":
|
|
35
|
+
// text = text.replace(/ /g, `&${this.space};`);
|
|
36
|
+
// break;
|
|
37
|
+
// }
|
|
38
|
+
return h(
|
|
39
|
+
"text",
|
|
40
|
+
{
|
|
41
|
+
class: classNames,
|
|
42
|
+
...getInnerListeners(this),
|
|
43
|
+
},
|
|
44
|
+
text
|
|
45
|
+
);
|
|
46
|
+
},
|
|
47
|
+
data() {
|
|
48
|
+
return {};
|
|
49
|
+
},
|
|
50
|
+
beforeCreate() {},
|
|
51
|
+
pageConfig: {
|
|
52
|
+
canScroll: false,
|
|
53
|
+
},
|
|
54
|
+
methods: {
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
</script>
|
|
58
|
+
<style lang="stylus">
|
|
59
|
+
.mpx-text
|
|
60
|
+
user-select none
|
|
61
|
+
&.selectable
|
|
62
|
+
user-select text
|
|
63
|
+
|
|
64
|
+
</style>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { h } from "@hummer/tenon-vue";
|
|
3
|
+
import getInnerListeners from "./getInnerListeners";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
name: "mpx-view",
|
|
7
|
+
props: {
|
|
8
|
+
hoverClass: {
|
|
9
|
+
type: String,
|
|
10
|
+
default: "none",
|
|
11
|
+
},
|
|
12
|
+
hoverStopPropagation: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
default: false,
|
|
15
|
+
},
|
|
16
|
+
hoverStartTime: {
|
|
17
|
+
type: Number,
|
|
18
|
+
default: 50,
|
|
19
|
+
},
|
|
20
|
+
hoverStayTime: {
|
|
21
|
+
type: Number,
|
|
22
|
+
default: 400,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
render() {
|
|
26
|
+
let mergeAfter;
|
|
27
|
+
if (this.hoverClass && this.hoverClass !== "none") {
|
|
28
|
+
mergeAfter = {
|
|
29
|
+
listeners: {
|
|
30
|
+
onTouchstart: this.handleTouchstart,
|
|
31
|
+
onTouchend: this.handleTouchend,
|
|
32
|
+
},
|
|
33
|
+
force: true,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return h(
|
|
37
|
+
"view",
|
|
38
|
+
{
|
|
39
|
+
class: this.className,
|
|
40
|
+
...getInnerListeners(this, { mergeAfter }),
|
|
41
|
+
},
|
|
42
|
+
this.$slots.default()
|
|
43
|
+
);
|
|
44
|
+
},
|
|
45
|
+
data() {
|
|
46
|
+
return {
|
|
47
|
+
hover: false,
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
computed: {
|
|
51
|
+
className() {
|
|
52
|
+
let result = {};
|
|
53
|
+
if (this.hoverClass && this.hoverClass !== "none" && this.hover) {
|
|
54
|
+
result = {
|
|
55
|
+
"mpx-view": true,
|
|
56
|
+
[this.hoverClass]: true,
|
|
57
|
+
};
|
|
58
|
+
} else {
|
|
59
|
+
result = {
|
|
60
|
+
"mpx-view": true,
|
|
61
|
+
[this.hoverClass]: false,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
pageConfig: {
|
|
68
|
+
canScroll: false,
|
|
69
|
+
},
|
|
70
|
+
methods: {
|
|
71
|
+
handleTouchstart(e) {
|
|
72
|
+
if (e.__hoverStopPropagation) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
e.__hoverStopPropagation = this.hoverStopPropagation;
|
|
76
|
+
clearTimeout(this.startTimer);
|
|
77
|
+
this.startTimer = setTimeout(() => {
|
|
78
|
+
this.hover = true;
|
|
79
|
+
}, this.hoverStartTime);
|
|
80
|
+
},
|
|
81
|
+
handleTouchend() {
|
|
82
|
+
clearTimeout(this.endTimer);
|
|
83
|
+
this.endTimer = setTimeout(() => {
|
|
84
|
+
this.hover = false;
|
|
85
|
+
}, this.hoverStayTime);
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
</script>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file web运行时组件抹平中需要用到的一些工具方法
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 处理字符串类型的宽高数值,兼容rpx
|
|
7
|
+
* @param {object | number} size 宽高
|
|
8
|
+
* @param {object} option 配置项,目前仅支持配置默认值
|
|
9
|
+
* @param {number} option.default 默认值,当传入的size有问题时返回
|
|
10
|
+
* @returns {number} 处理后的数字宽高,单位px
|
|
11
|
+
*/
|
|
12
|
+
export function processSize (size, option = {}) {
|
|
13
|
+
const defaultValue = option.default || 0
|
|
14
|
+
if (typeof size === 'number') {
|
|
15
|
+
return size
|
|
16
|
+
} else if (typeof size === 'string') {
|
|
17
|
+
const rs = parseInt(size, 10)
|
|
18
|
+
if (size.indexOf('rpx') !== -1) {
|
|
19
|
+
// 计算rpx折算回px
|
|
20
|
+
const width = window.screen.width
|
|
21
|
+
const finalRs = Math.floor(rs / 750 * width)
|
|
22
|
+
return finalRs
|
|
23
|
+
} else {
|
|
24
|
+
return isNaN(rs) ? defaultValue : rs
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
return defaultValue
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 判断对象类型
|
|
32
|
+
export function type (n) {
|
|
33
|
+
return Object.prototype.toString.call(n).slice(8, -1)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function isEmptyObject (obj) {
|
|
37
|
+
if (!obj) {
|
|
38
|
+
return true
|
|
39
|
+
}
|
|
40
|
+
for (let key in obj) {
|
|
41
|
+
return false
|
|
42
|
+
}
|
|
43
|
+
return true
|
|
44
|
+
}
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
// import { inBrowser } from '../utils/env'
|
|
2
|
+
|
|
3
|
+
export default function processOption (
|
|
4
|
+
option,
|
|
5
|
+
ctorType,
|
|
6
|
+
firstPage,
|
|
7
|
+
componentId,
|
|
8
|
+
pageConfig,
|
|
9
|
+
pagesMap,
|
|
10
|
+
componentsMap,
|
|
11
|
+
tabBarMap,
|
|
12
|
+
componentGenerics,
|
|
13
|
+
genericsInfo,
|
|
14
|
+
mixin,
|
|
15
|
+
Vue,
|
|
16
|
+
VueRouter,
|
|
17
|
+
i18n
|
|
18
|
+
) {
|
|
19
|
+
if (ctorType === 'app') {
|
|
20
|
+
// 对于app中的组件需要全局注册
|
|
21
|
+
for (const componentName in componentsMap) {
|
|
22
|
+
if (componentsMap.hasOwnProperty(componentName)) {
|
|
23
|
+
const component = componentsMap[componentName]
|
|
24
|
+
Vue.component(componentName, component)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// 注册v-ex-classes自定义指令处理externalClasses
|
|
29
|
+
// Vue.directive('ex-classes', (el, binding, vnode) => {
|
|
30
|
+
// const context = vnode.context
|
|
31
|
+
// if (context) {
|
|
32
|
+
// const externalClasses = context.$options.externalClasses || []
|
|
33
|
+
// const classList = el.classList
|
|
34
|
+
// binding.value.forEach((className) => {
|
|
35
|
+
// const actualExternalClassNames = context.$attrs[className]
|
|
36
|
+
// if (externalClasses.indexOf(className) !== -1 && actualExternalClassNames) {
|
|
37
|
+
// classList.remove(className)
|
|
38
|
+
// actualExternalClassNames.split(/\s+/).forEach((actualExternalClassName) => {
|
|
39
|
+
// if (actualExternalClassName) classList.add(actualExternalClassName)
|
|
40
|
+
// })
|
|
41
|
+
// }
|
|
42
|
+
// })
|
|
43
|
+
// }
|
|
44
|
+
// })
|
|
45
|
+
// Vue.directive('animation', (el, binding) => {
|
|
46
|
+
// const newActions = binding?.value?.actions
|
|
47
|
+
// if (el.actions === newActions) {
|
|
48
|
+
// Promise.resolve().then(() => {
|
|
49
|
+
// Object.assign(el.style, el.lastDynamicStyle)
|
|
50
|
+
// })
|
|
51
|
+
// return
|
|
52
|
+
// }
|
|
53
|
+
// el.actions = newActions
|
|
54
|
+
// if (typeof el.setAnimation === 'function') {
|
|
55
|
+
// el.removeEventListener('transitionend', el.setAnimation, false)
|
|
56
|
+
// el.setAnimation = undefined
|
|
57
|
+
// }
|
|
58
|
+
// el.dynamicStyleQueue = []
|
|
59
|
+
// el.lastDynamicStyle = undefined
|
|
60
|
+
// if (Array.isArray(newActions) && newActions.length) {
|
|
61
|
+
// newActions.forEach((item) => {
|
|
62
|
+
// const property = []
|
|
63
|
+
// const { animates, option } = item
|
|
64
|
+
// // 存储动画需要改变的样式属性
|
|
65
|
+
// const dynamicStyle = {
|
|
66
|
+
// transform: ''
|
|
67
|
+
// }
|
|
68
|
+
// animates.forEach((itemAnimation) => {
|
|
69
|
+
// switch (itemAnimation.type) {
|
|
70
|
+
// case 'style':
|
|
71
|
+
// const [key, value] = itemAnimation.args
|
|
72
|
+
// dynamicStyle[key] = value
|
|
73
|
+
// property.push(key)
|
|
74
|
+
// break
|
|
75
|
+
// default:
|
|
76
|
+
// dynamicStyle.transform += `${itemAnimation.type}(${itemAnimation.args}) `
|
|
77
|
+
// if (!property.includes('transform')) {
|
|
78
|
+
// property.push('transform')
|
|
79
|
+
// }
|
|
80
|
+
// }
|
|
81
|
+
// })
|
|
82
|
+
// Object.assign(dynamicStyle, {
|
|
83
|
+
// transition: `${parseInt(option.duration)}ms ${option.timingFunction} ${parseInt(option.delay)}ms`,
|
|
84
|
+
// transitionProperty: `${property}`,
|
|
85
|
+
// transformOrigin: option.transformOrigin
|
|
86
|
+
// })
|
|
87
|
+
// el.dynamicStyleQueue.push(dynamicStyle)
|
|
88
|
+
// })
|
|
89
|
+
// el.setAnimation = function () {
|
|
90
|
+
// if (!el.dynamicStyleQueue.length) {
|
|
91
|
+
// el.removeEventListener('transitionend', el.setAnimation, false)
|
|
92
|
+
// return
|
|
93
|
+
// }
|
|
94
|
+
// const dynamicStyle = el.dynamicStyleQueue.shift()
|
|
95
|
+
// Object.assign(el.style, dynamicStyle)
|
|
96
|
+
// el.lastDynamicStyle = dynamicStyle
|
|
97
|
+
// }
|
|
98
|
+
// // 首次动画属性设置
|
|
99
|
+
// setTimeout(el.setAnimation, 0)
|
|
100
|
+
// // 在transitionend事件内设置动画样式
|
|
101
|
+
// el.addEventListener('transitionend', el.setAnimation, false)
|
|
102
|
+
// }
|
|
103
|
+
// })
|
|
104
|
+
|
|
105
|
+
// const routes = []
|
|
106
|
+
|
|
107
|
+
// for (const pagePath in pagesMap) {
|
|
108
|
+
// if (pagesMap.hasOwnProperty(pagePath)) {
|
|
109
|
+
// const page = pagesMap[pagePath]
|
|
110
|
+
// routes.push({
|
|
111
|
+
// path: '/' + pagePath,
|
|
112
|
+
// component: page
|
|
113
|
+
// })
|
|
114
|
+
// }
|
|
115
|
+
// }
|
|
116
|
+
|
|
117
|
+
// if (routes.length) {
|
|
118
|
+
// if (firstPage) {
|
|
119
|
+
// routes.push({
|
|
120
|
+
// path: '/',
|
|
121
|
+
// redirect: '/' + firstPage
|
|
122
|
+
// })
|
|
123
|
+
// }
|
|
124
|
+
// global.__mpxRouter = option.router = new VueRouter({
|
|
125
|
+
// routes: routes
|
|
126
|
+
// })
|
|
127
|
+
// global.__mpxRouter.stack = []
|
|
128
|
+
// global.__mpxRouter.needCache = null
|
|
129
|
+
// global.__mpxRouter.needRemove = []
|
|
130
|
+
// // 处理reLaunch中传递的url并非首页时的replace逻辑
|
|
131
|
+
// global.__mpxRouter.beforeEach(function (to, from, next) {
|
|
132
|
+
// let action = global.__mpxRouter.__mpxAction
|
|
133
|
+
// const stack = global.__mpxRouter.stack
|
|
134
|
+
|
|
135
|
+
// // 处理人为操作
|
|
136
|
+
// if (!action) {
|
|
137
|
+
// if (stack.length > 1 && stack[stack.length - 2].path === to.path) {
|
|
138
|
+
// action = {
|
|
139
|
+
// type: 'back',
|
|
140
|
+
// delta: 1
|
|
141
|
+
// }
|
|
142
|
+
// } else {
|
|
143
|
+
// action = {
|
|
144
|
+
// type: 'to'
|
|
145
|
+
// }
|
|
146
|
+
// }
|
|
147
|
+
// }
|
|
148
|
+
|
|
149
|
+
// const pageInRoutes = routes.some(item => item.path === to.path)
|
|
150
|
+
// if (!pageInRoutes) {
|
|
151
|
+
// if (stack.length < 1) {
|
|
152
|
+
// if (global.__mpxRouter.app.$options.onPageNotFound) {
|
|
153
|
+
// // onPageNotFound,仅首次进入时生效
|
|
154
|
+
// global.__mpxRouter.app.$options.onPageNotFound({
|
|
155
|
+
// path: to.path,
|
|
156
|
+
// query: to.query,
|
|
157
|
+
// isEntryPage: true
|
|
158
|
+
// })
|
|
159
|
+
// return
|
|
160
|
+
// } else {
|
|
161
|
+
// console.warn(`[Mpx runtime warn]: the ${to.path} path does not exist in the application,will redirect to the home page path ${firstPage}`)
|
|
162
|
+
// return next({
|
|
163
|
+
// path: firstPage,
|
|
164
|
+
// replace: true
|
|
165
|
+
// })
|
|
166
|
+
// }
|
|
167
|
+
// } else {
|
|
168
|
+
// let methods = ''
|
|
169
|
+
// switch (action.type) {
|
|
170
|
+
// case 'to':
|
|
171
|
+
// methods = 'navigateTo'
|
|
172
|
+
// break
|
|
173
|
+
// case 'redirect':
|
|
174
|
+
// methods = 'redirectTo'
|
|
175
|
+
// break
|
|
176
|
+
// case 'back':
|
|
177
|
+
// methods = 'navigateBack'
|
|
178
|
+
// break
|
|
179
|
+
// case 'reLaunch':
|
|
180
|
+
// methods = 'reLaunch'
|
|
181
|
+
// break
|
|
182
|
+
// default:
|
|
183
|
+
// methods = 'navigateTo'
|
|
184
|
+
// }
|
|
185
|
+
// throw new Error(`${methods}:fail page "${to.path}" is not found`)
|
|
186
|
+
// }
|
|
187
|
+
// }
|
|
188
|
+
|
|
189
|
+
// const insertItem = {
|
|
190
|
+
// path: to.path
|
|
191
|
+
// }
|
|
192
|
+
// // 构建历史栈
|
|
193
|
+
// switch (action.type) {
|
|
194
|
+
// case 'to':
|
|
195
|
+
// stack.push(insertItem)
|
|
196
|
+
// global.__mpxRouter.needCache = insertItem
|
|
197
|
+
// break
|
|
198
|
+
// case 'back':
|
|
199
|
+
// global.__mpxRouter.needRemove = stack.splice(stack.length - action.delta, action.delta)
|
|
200
|
+
// break
|
|
201
|
+
// case 'redirect':
|
|
202
|
+
// global.__mpxRouter.needRemove = stack.splice(stack.length - 1, 1, insertItem)
|
|
203
|
+
// global.__mpxRouter.needCache = insertItem
|
|
204
|
+
// break
|
|
205
|
+
// case 'switch':
|
|
206
|
+
// if (!action.replaced) {
|
|
207
|
+
// action.replaced = true
|
|
208
|
+
// return next({
|
|
209
|
+
// path: action.path,
|
|
210
|
+
// replace: true
|
|
211
|
+
// })
|
|
212
|
+
// } else {
|
|
213
|
+
// // 将非tabBar页面remove
|
|
214
|
+
// let tabItem = null
|
|
215
|
+
// global.__mpxRouter.needRemove = stack.filter((item) => {
|
|
216
|
+
// if (tabBarMap[item.path.slice(1)]) {
|
|
217
|
+
// tabItem = item
|
|
218
|
+
// return false
|
|
219
|
+
// }
|
|
220
|
+
// return true
|
|
221
|
+
// })
|
|
222
|
+
// if (tabItem) {
|
|
223
|
+
// global.__mpxRouter.stack = [tabItem]
|
|
224
|
+
// } else {
|
|
225
|
+
// global.__mpxRouter.stack = [insertItem]
|
|
226
|
+
// global.__mpxRouter.needCache = insertItem
|
|
227
|
+
// }
|
|
228
|
+
// }
|
|
229
|
+
// break
|
|
230
|
+
// case 'reLaunch':
|
|
231
|
+
// if (!action.replaced) {
|
|
232
|
+
// action.replaced = true
|
|
233
|
+
// return next({
|
|
234
|
+
// path: action.path,
|
|
235
|
+
// query: {
|
|
236
|
+
// reLaunchCount: action.reLaunchCount
|
|
237
|
+
// },
|
|
238
|
+
// replace: true
|
|
239
|
+
// })
|
|
240
|
+
// } else {
|
|
241
|
+
// global.__mpxRouter.needRemove = stack
|
|
242
|
+
// global.__mpxRouter.stack = [insertItem]
|
|
243
|
+
// global.__mpxRouter.needCache = insertItem
|
|
244
|
+
// }
|
|
245
|
+
// }
|
|
246
|
+
// next()
|
|
247
|
+
// })
|
|
248
|
+
// // 处理visibilitychange时触发当前活跃页面组件的onshow/onhide
|
|
249
|
+
// if (inBrowser) {
|
|
250
|
+
// // const errorHandler = function (e) {
|
|
251
|
+
// // if (global.__mpxAppCbs && global.__mpxAppCbs.error) {
|
|
252
|
+
// // global.__mpxAppCbs.error.forEach((cb) => {
|
|
253
|
+
// // cb(e)
|
|
254
|
+
// // })
|
|
255
|
+
// // }
|
|
256
|
+
// // }
|
|
257
|
+
// // Vue.config.errorHandler = errorHandler
|
|
258
|
+
// // window.addEventListener('error', errorHandler)
|
|
259
|
+
// // window.addEventListener('unhandledrejection', event => {
|
|
260
|
+
// // errorHandler(event.reason)
|
|
261
|
+
// // })
|
|
262
|
+
// // document.addEventListener('visibilitychange', function () {
|
|
263
|
+
// // const vnode = global.__mpxRouter && global.__mpxRouter.__mpxActiveVnode
|
|
264
|
+
// // if (vnode && vnode.componentInstance) {
|
|
265
|
+
// // const currentPage = vnode.tag.endsWith('mpx-tab-bar-container') ? vnode.componentInstance.$refs.tabBarPage : vnode.componentInstance
|
|
266
|
+
// // if (document.hidden) {
|
|
267
|
+
// // if (global.__mpxAppCbs && global.__mpxAppCbs.hide) {
|
|
268
|
+
// // global.__mpxAppCbs.hide.forEach((cb) => {
|
|
269
|
+
// // cb()
|
|
270
|
+
// // })
|
|
271
|
+
// // }
|
|
272
|
+
// // if (currentPage) {
|
|
273
|
+
// // currentPage.mpxPageStatus = 'hide'
|
|
274
|
+
// // currentPage.onHide && currentPage.onHide()
|
|
275
|
+
// // }
|
|
276
|
+
// // } else {
|
|
277
|
+
// // if (global.__mpxAppCbs && global.__mpxAppCbs.show) {
|
|
278
|
+
// // global.__mpxAppCbs.show.forEach((cb) => {
|
|
279
|
+
// // // todo 实现app.onShow参数
|
|
280
|
+
// // /* eslint-disable standard/no-callback-literal */
|
|
281
|
+
// // cb({})
|
|
282
|
+
// // })
|
|
283
|
+
// // }
|
|
284
|
+
// // if (currentPage) {
|
|
285
|
+
// // currentPage.mpxPageStatus = 'show'
|
|
286
|
+
// // currentPage.onShow && currentPage.onShow()
|
|
287
|
+
// // }
|
|
288
|
+
// // }
|
|
289
|
+
// // }
|
|
290
|
+
// // })
|
|
291
|
+
// // 初始化length
|
|
292
|
+
// // global.__mpxRouter.__mpxHistoryLength = global.history.length
|
|
293
|
+
// }
|
|
294
|
+
// }
|
|
295
|
+
|
|
296
|
+
// if (i18n) {
|
|
297
|
+
// option.i18n = i18n
|
|
298
|
+
// }
|
|
299
|
+
} else {
|
|
300
|
+
// 局部注册页面和组件中依赖的组件
|
|
301
|
+
for (const componentName in componentsMap) {
|
|
302
|
+
if (componentsMap.hasOwnProperty(componentName)) {
|
|
303
|
+
const component = componentsMap[componentName]
|
|
304
|
+
if (!option.components) {
|
|
305
|
+
option.components = {}
|
|
306
|
+
}
|
|
307
|
+
option.components[componentName] = component
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// if (genericsInfo) {
|
|
312
|
+
// const genericHash = genericsInfo.hash
|
|
313
|
+
// global.__mpxGenericsMap[genericHash] = {}
|
|
314
|
+
// Object.keys(genericsInfo.map).forEach((genericValue) => {
|
|
315
|
+
// if (componentsMap[genericValue]) {
|
|
316
|
+
// global.__mpxGenericsMap[genericHash][genericValue] = componentsMap[genericValue]
|
|
317
|
+
// } else {
|
|
318
|
+
// console.log(option)
|
|
319
|
+
// console.warn(`[Mpx runtime warn]: generic value "${genericValue}" must be
|
|
320
|
+
// registered in parent context!`)
|
|
321
|
+
// }
|
|
322
|
+
// })
|
|
323
|
+
// }
|
|
324
|
+
|
|
325
|
+
// if (componentGenerics) {
|
|
326
|
+
// option.props = option.props || {}
|
|
327
|
+
// option.props.generichash = String
|
|
328
|
+
// Object.keys(componentGenerics).forEach((genericName) => {
|
|
329
|
+
// if (componentGenerics[genericName].default) {
|
|
330
|
+
// option.props[`generic${genericName}`] = {
|
|
331
|
+
// type: String,
|
|
332
|
+
// default: `${genericName}default`
|
|
333
|
+
// }
|
|
334
|
+
// } else {
|
|
335
|
+
// option.props[`generic${genericName}`] = String
|
|
336
|
+
// }
|
|
337
|
+
// })
|
|
338
|
+
// }
|
|
339
|
+
|
|
340
|
+
if (ctorType === 'page') {
|
|
341
|
+
(option.mixins ? option.mixins : (option.mixins = [])).push({
|
|
342
|
+
// cache page instance in tenon
|
|
343
|
+
created () {
|
|
344
|
+
global.__currentPageInstance = this
|
|
345
|
+
}
|
|
346
|
+
})
|
|
347
|
+
option.__mpxPageConfig = Object.assign({}, global.__mpxPageConfig, pageConfig)
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (mixin) {
|
|
352
|
+
if (option.mixins) {
|
|
353
|
+
option.mixins.push(mixin)
|
|
354
|
+
} else {
|
|
355
|
+
option.mixins = [mixin]
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (componentId) {
|
|
360
|
+
option.componentPath = '/' + componentId
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return option
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export function getComponent (component, extendOptions) {
|
|
367
|
+
component = component.__esModule ? component.default : component
|
|
368
|
+
// eslint-disable-next-line
|
|
369
|
+
if (extendOptions) Object.assign(component, extendOptions)
|
|
370
|
+
return component
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export function getWxsMixin (wxsModules) {
|
|
374
|
+
if (!wxsModules) return {}
|
|
375
|
+
return {
|
|
376
|
+
created () {
|
|
377
|
+
Object.keys(wxsModules).forEach((key) => {
|
|
378
|
+
if (key in this) {
|
|
379
|
+
console.error(`[Mpx runtime error]: The wxs module key [${key}] exist in the component/page instance already, please check and rename it!`)
|
|
380
|
+
} else {
|
|
381
|
+
this[key] = wxsModules[key]
|
|
382
|
+
}
|
|
383
|
+
})
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
@@ -2180,6 +2180,15 @@ function processElement (el, root, options, meta) {
|
|
|
2180
2180
|
processComponentGenericsForWeb(el, options, meta)
|
|
2181
2181
|
return
|
|
2182
2182
|
}
|
|
2183
|
+
if (mode === 'tenon') {
|
|
2184
|
+
// 收集内建组件
|
|
2185
|
+
processBuiltInComponents(el, meta)
|
|
2186
|
+
// 预处理代码维度条件编译
|
|
2187
|
+
processIfForWeb(el)
|
|
2188
|
+
// processWebExternalClassesHack(el, options)
|
|
2189
|
+
// processComponentGenericsForWeb(el, options, meta)
|
|
2190
|
+
return
|
|
2191
|
+
}
|
|
2183
2192
|
|
|
2184
2193
|
const pass = isNative || processTemplate(el) || processingTemplate
|
|
2185
2194
|
|
|
@@ -2214,7 +2223,7 @@ function processElement (el, root, options, meta) {
|
|
|
2214
2223
|
|
|
2215
2224
|
function closeElement (el, meta) {
|
|
2216
2225
|
postProcessAtMode(el)
|
|
2217
|
-
if (mode === 'web') {
|
|
2226
|
+
if (mode === 'web' || mode === 'tenon') {
|
|
2218
2227
|
postProcessWxs(el, meta)
|
|
2219
2228
|
// 处理代码维度条件编译移除死分支
|
|
2220
2229
|
postProcessIf(el)
|
|
@@ -2321,7 +2330,7 @@ function serialize (root) {
|
|
|
2321
2330
|
result += node.text
|
|
2322
2331
|
}
|
|
2323
2332
|
}
|
|
2324
|
-
if (node.tag === 'wxs' && mode === 'web') {
|
|
2333
|
+
if (node.tag === 'wxs' && (mode === 'web' || mode === 'tenon')) {
|
|
2325
2334
|
return result
|
|
2326
2335
|
}
|
|
2327
2336
|
if (node.type === 1) {
|
|
@@ -15,7 +15,7 @@ module.exports = function transDynamicClassExpr (expr, { error } = {}) {
|
|
|
15
15
|
const propertyName = property.key.name || property.key.value
|
|
16
16
|
if (/-/.test(propertyName)) {
|
|
17
17
|
if (/\$/.test(propertyName)) {
|
|
18
|
-
error(`Dynamic classname [${propertyName}] is not supported, which includes [-] char and [$] char at the same time.`)
|
|
18
|
+
error && error(`Dynamic classname [${propertyName}] is not supported, which includes [-] char and [$] char at the same time.`)
|
|
19
19
|
} else {
|
|
20
20
|
property.key = t.identifier(propertyName.replace(/-/g, '$$') + 'MpxDash')
|
|
21
21
|
}
|