@mpxjs/webpack-plugin 2.6.110 → 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/components/web/mpx-swiper.vue +19 -5
- package/lib/runtime/components/web/mpx-textarea.vue +1 -1
- package/lib/runtime/optionProcessor.tenon.js +386 -0
- package/lib/runtime/stringify.wxs +3 -1
- package/lib/style-compiler/index.js +2 -1
- package/lib/style-compiler/plugins/vw.js +5 -4
- package/lib/template-compiler/compiler.js +14 -3
- package/lib/template-compiler/trans-dynamic-class-expr.js +25 -20
- 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/lib/web/processScript.js +0 -6
- package/lib/wxs/wxs-pre-loader.js +6 -1
- 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
|
+
}
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
easingFunction: {
|
|
37
37
|
type: String,
|
|
38
38
|
default: 'default'
|
|
39
|
-
}
|
|
39
|
+
},
|
|
40
|
+
scrollOptions: Object
|
|
40
41
|
},
|
|
41
42
|
data () {
|
|
42
43
|
return {
|
|
@@ -90,11 +91,21 @@
|
|
|
90
91
|
this.goto(val)
|
|
91
92
|
}
|
|
92
93
|
},
|
|
94
|
+
activated () {
|
|
95
|
+
if (this.bs && this.autoplay) {
|
|
96
|
+
this.bs.startPlay()
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
deactivated () {
|
|
100
|
+
if (this.bs && this.autoplay) {
|
|
101
|
+
this.bs.pausePlay()
|
|
102
|
+
}
|
|
103
|
+
},
|
|
93
104
|
beforeCreate () {
|
|
94
105
|
this.itemIds = []
|
|
95
106
|
},
|
|
96
107
|
mounted () {
|
|
97
|
-
|
|
108
|
+
const originBsOptions = {
|
|
98
109
|
scrollX: !this.vertical,
|
|
99
110
|
scrollY: this.vertical,
|
|
100
111
|
slide: {
|
|
@@ -103,14 +114,17 @@
|
|
|
103
114
|
speed: this.duration,
|
|
104
115
|
easing: this.easing,
|
|
105
116
|
interval: this.interval,
|
|
106
|
-
autoplay: this.autoplay
|
|
117
|
+
autoplay: this.autoplay,
|
|
118
|
+
startPageXIndex: this.vertical ? 0 : this.current,
|
|
119
|
+
startPageYIndex: this.vertical? this.current : 0
|
|
107
120
|
},
|
|
108
121
|
momentum: false,
|
|
109
122
|
bounce: false,
|
|
110
123
|
probeType: 3,
|
|
111
124
|
stopPropagation: true
|
|
112
|
-
}
|
|
113
|
-
|
|
125
|
+
}
|
|
126
|
+
const bsOptions = Object.assign({}, originBsOptions, this.scrollOptions)
|
|
127
|
+
this.bs = new BScroll(this.$refs.wrapper, bsOptions)
|
|
114
128
|
this.bs.on('slideWillChange', (page) => {
|
|
115
129
|
this.currentIndex = this.vertical ? page.pageY : page.pageX
|
|
116
130
|
this.$emit('change', getCustomEvent('change', {
|