@mpxjs/webpack-plugin 2.8.22 → 2.8.23-alpha

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.
Files changed (38) hide show
  1. package/README.md +1 -1
  2. package/lib/config.js +14 -0
  3. package/lib/dependencies/AddEntryDependency.js +24 -0
  4. package/lib/dependencies/ResolveDependency.js +4 -0
  5. package/lib/index.js +35 -5
  6. package/lib/loader.js +40 -0
  7. package/lib/platform/template/wx/component-config/button.js +14 -2
  8. package/lib/platform/template/wx/component-config/image.js +4 -0
  9. package/lib/platform/template/wx/component-config/input.js +4 -0
  10. package/lib/platform/template/wx/component-config/rich-text.js +4 -0
  11. package/lib/platform/template/wx/component-config/scroll-view.js +4 -0
  12. package/lib/platform/template/wx/component-config/switch.js +4 -0
  13. package/lib/platform/template/wx/component-config/text.js +4 -0
  14. package/lib/platform/template/wx/component-config/textarea.js +5 -0
  15. package/lib/platform/template/wx/component-config/view.js +4 -0
  16. package/lib/platform/template/wx/index.js +121 -1
  17. package/lib/resolve-loader.js +4 -1
  18. package/lib/runtime/components/tenon/getInnerListeners.js +314 -0
  19. package/lib/runtime/components/tenon/tenon-button.vue +305 -0
  20. package/lib/runtime/components/tenon/tenon-image.vue +61 -0
  21. package/lib/runtime/components/tenon/tenon-input.vue +104 -0
  22. package/lib/runtime/components/tenon/tenon-rich-text.vue +21 -0
  23. package/lib/runtime/components/tenon/tenon-scroll-view.vue +124 -0
  24. package/lib/runtime/components/tenon/tenon-switch.vue +91 -0
  25. package/lib/runtime/components/tenon/tenon-text-area.vue +77 -0
  26. package/lib/runtime/components/tenon/tenon-text.vue +64 -0
  27. package/lib/runtime/components/tenon/tenon-view.vue +93 -0
  28. package/lib/runtime/optionProcessor.tenon.js +388 -0
  29. package/lib/style-compiler/index.js +1 -1
  30. package/lib/style-compiler/plugins/hm.js +20 -0
  31. package/lib/template-compiler/compiler.js +11 -2
  32. package/lib/tenon/index.js +104 -0
  33. package/lib/tenon/processJSON.js +356 -0
  34. package/lib/tenon/processScript.js +262 -0
  35. package/lib/tenon/processStyles.js +21 -0
  36. package/lib/tenon/processTemplate.js +133 -0
  37. package/lib/utils/get-relative-path.js +25 -0
  38. package/package.json +5 -2
@@ -0,0 +1,104 @@
1
+ <script>
2
+ import { h } from "@hummer/tenon-vue";
3
+ import getInnerListeners from "./getInnerListeners";
4
+ export default {
5
+ name: "mpx-input",
6
+ props: {
7
+ name: String,
8
+ value: {
9
+ type: String,
10
+ default: "",
11
+ },
12
+ type: {
13
+ type: String,
14
+ default: "text",
15
+ },
16
+ password: Boolean,
17
+ placeholder: String,
18
+ disabled: Boolean,
19
+ maxlength: {
20
+ type: Number,
21
+ default: 140,
22
+ },
23
+ autoFocus: Boolean,
24
+ focus: {
25
+ type: Boolean,
26
+ default: false,
27
+ },
28
+ cursor: {
29
+ type: Number,
30
+ default: -1,
31
+ },
32
+ selectionStart: {
33
+ type: Number,
34
+ default: -1,
35
+ },
36
+ selectionEnd: {
37
+ type: Number,
38
+ default: -1,
39
+ },
40
+ },
41
+ computed: {
42
+ originRef() {
43
+ return this.$refs["mpx-input"]
44
+ }
45
+ },
46
+ watch: {
47
+ value: function(newVal, oldVal) {
48
+ if(this.originRef && newVal !== this.originRef.value){
49
+ this.originRef.value = newVal;
50
+ }
51
+ }
52
+ },
53
+ render() {
54
+ let inputType = "";
55
+ if (this.password) {
56
+ inputType = "password";
57
+ } else {
58
+ switch (this.type) {
59
+ case "text":
60
+ inputType = "default";
61
+ break;
62
+ case "number":
63
+ inputType = "number";
64
+ break;
65
+ default:
66
+ inputType = "text";
67
+ }
68
+ }
69
+
70
+ const data = {
71
+ class: "mpx-input",
72
+ focus: this.focus,
73
+ ref: "mpx-input",
74
+ placeholder: this.placeholder,
75
+ maxLength: this.maxLength,
76
+ type: inputType,
77
+ disabled: this.disabled,
78
+ ...getInnerListeners(this),
79
+ };
80
+ return h("input", data, []);
81
+ },
82
+ data() {
83
+ return {};
84
+ },
85
+ pageConfig: {
86
+ canScroll: false,
87
+ },
88
+ methods: {},
89
+ };
90
+ </script>
91
+ <style lang="stylus" scoped>
92
+ .mpx-input
93
+ cursor auto
94
+ width 100%
95
+ padding 0
96
+ border 0
97
+ font inherit
98
+ display block
99
+ text-overflow clip
100
+ overflow hidden
101
+ white-space nowrap
102
+ font-family UICTFontTextStyleBody
103
+
104
+ </style>
@@ -0,0 +1,21 @@
1
+ <script>
2
+ import getInnerListeners from './getInnerListeners'
3
+ import { h } from '@hummer/tenon-vue'
4
+ export default {
5
+ name: 'mpx-rich-text',
6
+ props: {
7
+ richText: {
8
+ type: Object,
9
+ value: {}
10
+ }
11
+ },
12
+ render () {
13
+
14
+ const data = {
15
+ richText: this.richText,
16
+ ...getInnerListeners(this)
17
+ }
18
+ return h('text', data)
19
+ }
20
+ }
21
+ </script>
@@ -0,0 +1,124 @@
1
+ <script>
2
+ import getInnerListeners from "./getInnerListeners";
3
+ import { processSize } from '../../utils';
4
+ import { h } from "@hummer/tenon-vue";
5
+ export default {
6
+ name: "mpx-scroll-view",
7
+ props: {
8
+ // 允许横向滚动
9
+ scrollX: Boolean,
10
+ // 允许纵向滚动
11
+ scrollY: Boolean,
12
+ // 滚动方向
13
+ scrollDirection: {
14
+ type: String,
15
+ default: "horizontal",
16
+ },
17
+ // 距顶部/左边多远时,触发 scrolltoupper 事件
18
+ upperThreshold: {
19
+ type: [Number, String],
20
+ default: 50,
21
+ },
22
+ // 距底部/右边多远时,触发 scrolltolower 事件
23
+ lowerThreshold: {
24
+ type: [Number, String],
25
+ default: 50,
26
+ },
27
+ // 设置竖向滚动条位置
28
+ scrollTop: {
29
+ type: [Number, String],
30
+ default: 0,
31
+ },
32
+ // 设置横向滚动条位置
33
+ scrollLeft: {
34
+ type: [Number, String],
35
+ default: 0,
36
+ },
37
+ scrollOptions: Object,
38
+ // 更新refresh
39
+ updateRefresh: {
40
+ type: Boolean,
41
+ default: true,
42
+ },
43
+ // 值应为某子元素id(id不能以数字开头)。设置哪个方向可滚动,则在哪个方向滚动到该元素
44
+ scrollIntoView: String,
45
+ // 在设置滚动条位置时使用动画过渡
46
+ scrollWithAnimation: Boolean,
47
+ // 启用 flexbox 布局。开启后,当前节点声明了 display: flex 就会成为 flex container,并作用于其孩子节点。
48
+ enableFlex: Boolean,
49
+ // 启用 scroll-view 增强特性,启用后可通过 ScrollViewContext 操作 scroll-view
50
+ enhanced: Boolean,
51
+ // 开启自定义下拉刷新
52
+ refresherEnabled: Boolean,
53
+ // 设置当前下拉刷新状态,true 表示下拉刷新已经被触发,false 表示下拉刷新未被触发
54
+ refresherTriggered: Boolean,
55
+ // 设置自定义下拉刷新阈值
56
+ refresherThreshold: {
57
+ type: Number,
58
+ default: 45,
59
+ },
60
+ // 设置自定义下拉刷新默认样式,支持设置 black | white | none, none 表示不使用默认样式
61
+ refresherDefaultStyle: {
62
+ type: String,
63
+ default: "black",
64
+ },
65
+ // 设置自定义下拉刷新区域背景颜色
66
+ refresherBackground: {
67
+ type: String,
68
+ default: "",
69
+ },
70
+ },
71
+ data() {
72
+ return {};
73
+ },
74
+ computed: {
75
+ _scrollTop() {
76
+ // return 1
77
+ return processSize(this.scrollTop);
78
+ },
79
+ _scrollLeft() {
80
+ // return 1
81
+ return processSize(this.scrollLeft);
82
+ },
83
+ },
84
+ mounted() {
85
+ if (this.scrollTop) {
86
+ setTimeout(() => {
87
+ this.$refs.scroll && this.$refs.scroll.scrollTo(0, this._scrollTop);
88
+ }, 100);
89
+
90
+ }
91
+ if (this.scrollLeft) {
92
+ setTimeout(() => {
93
+ this.$refs.scroll && this.$refs.scroll.scrollTo(this._scrollLeft, 0);
94
+ }, 100);
95
+ }
96
+ },
97
+ watch: {
98
+ _scrollTop(val) {
99
+ console.log('触发')
100
+ this.$refs.scroll && this.$refs.scroll.scrollTo(0, val);
101
+ },
102
+ _scrollLeft(val) {
103
+ this.$refs.scroll && this.$refs.scroll.scrollTo(val, 0);
104
+ },
105
+ },
106
+ methods: {},
107
+ render() {
108
+ let scrollDirection = this.scrollDirection;
109
+ if (!this.scrollY && this.scrollX) {
110
+ scrollDirection = "horizontal";
111
+ }
112
+ return h(
113
+ "scroller",
114
+ {
115
+ ref: "scroll",
116
+ scrollDirection,
117
+ showScrollBar: false,
118
+ ...getInnerListeners(this, {})
119
+ },
120
+ this.$slots.default()
121
+ );
122
+ },
123
+ };
124
+ </script>
@@ -0,0 +1,91 @@
1
+ <script>
2
+ import { getCustomEvent } from "./getInnerListeners";
3
+ import { h } from "@hummer/tenon-vue";
4
+ export default {
5
+ name: "mpx-switch",
6
+ props: {
7
+ name: String,
8
+ type: {
9
+ type: String,
10
+ default: "switch",
11
+ },
12
+ checked: {
13
+ type: Boolean,
14
+ default: false,
15
+ },
16
+ disabled: {
17
+ type: Boolean,
18
+ default: false,
19
+ },
20
+ color: {
21
+ type: String,
22
+ default: "#04BE02",
23
+ },
24
+ },
25
+ watch: {
26
+ checked(newVal) {
27
+ this.switchChecked = newVal;
28
+ },
29
+ },
30
+ data() {
31
+ return {
32
+ switchChecked: this.checked,
33
+ };
34
+ },
35
+ render() {
36
+ let children = [];
37
+
38
+ const switchElem = h("switch", {
39
+ value: this.switchChecked,
40
+ class: [
41
+ "mpx-switch-label",
42
+ this.switchChecked ? "checked-switch-label" : "uncheck-switch-label",
43
+ ],
44
+ });
45
+ children.push(switchElem);
46
+
47
+ // children.push(...(this.$slots.default() || []));
48
+ const data = {
49
+ class: ["mpx-switch-wrap"],
50
+ ref: "switch",
51
+ onClick: (e) => {
52
+ if (this.disabled) {
53
+ return;
54
+ }
55
+ this.switchChecked = !this.switchChecked;
56
+ this.notifyChange();
57
+ },
58
+ };
59
+ return h("view", data, children);
60
+ },
61
+ methods: {
62
+ getValue() {
63
+ return this.switchChecked;
64
+ },
65
+ setValue(value) {
66
+ this.switchChecked = value;
67
+ },
68
+ notifyChange(value) {
69
+ if (value !== undefined) {
70
+ this.setValue(value);
71
+ } else {
72
+ value = this.getValue();
73
+ }
74
+ this.$emit(
75
+ "change",
76
+ getCustomEvent("change", { value }, this.$refs.switch)
77
+ );
78
+ },
79
+ },
80
+ };
81
+ </script>
82
+
83
+ <style lang="stylus" scoped>
84
+ .mpx-switch-wrap
85
+ .mpx-switch-label
86
+ border-radius 16hm
87
+ width 52hm
88
+ height 32hm
89
+ border none
90
+
91
+ </style>
@@ -0,0 +1,77 @@
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
+ computed: {
37
+ originRef() {
38
+ return this.$refs["mpx-textarea"]
39
+ }
40
+ },
41
+ watch: {
42
+ value: function(newVal, oldVal) {
43
+ if(this.originRef && newVal !== this.originRef.value){
44
+ this.originRef.value = newVal;
45
+ }
46
+ }
47
+ },
48
+
49
+ render() {
50
+ const data = {
51
+ class: "mpx-textarea",
52
+ ref: "mpx-textarea",
53
+ focus: this.focus,
54
+ placeholder: this.placeholder,
55
+ maxLength: this.maxLength,
56
+ disabled: this.disabled,
57
+ ...getInnerListeners(this),
58
+ };
59
+ return h("textarea", data);
60
+ },
61
+ pageConfig: {
62
+ canScroll: false,
63
+ },
64
+ methods: {},
65
+ };
66
+ </script>
67
+ <style lang="stylus" scoped>
68
+ .mpx-textarea
69
+ font inherit
70
+ cursor auto
71
+ width 300hm
72
+ height 150hm
73
+ display block
74
+ position relative
75
+ resize none
76
+
77
+ </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 && 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" scoped>
59
+ .mpx-text
60
+ user-select none
61
+ &.selectable
62
+ user-select text
63
+
64
+ </style>
@@ -0,0 +1,93 @@
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
+ ref: "mpx-view"
42
+ },
43
+ this.$slots.default && this.$slots.default() || ''
44
+ );
45
+ },
46
+ data() {
47
+ return {
48
+ hover: false,
49
+ };
50
+ },
51
+ computed: {
52
+ className() {
53
+ let result = {};
54
+ if (this.hoverClass && this.hoverClass !== "none" && this.hover) {
55
+ result = {
56
+ "mpx-view": true,
57
+ [this.hoverClass]: true,
58
+ };
59
+ } else {
60
+ result = {
61
+ "mpx-view": true,
62
+ [this.hoverClass]: false,
63
+ };
64
+ }
65
+ return result;
66
+ },
67
+ originRef() {
68
+ return this.$refs["mpx-view"]
69
+ }
70
+ },
71
+ pageConfig: {
72
+ canScroll: false,
73
+ },
74
+ methods: {
75
+ handleTouchstart(e) {
76
+ if (e.__hoverStopPropagation) {
77
+ return;
78
+ }
79
+ e.__hoverStopPropagation = this.hoverStopPropagation;
80
+ clearTimeout(this.startTimer);
81
+ this.startTimer = setTimeout(() => {
82
+ this.hover = true;
83
+ }, this.hoverStartTime);
84
+ },
85
+ handleTouchend() {
86
+ clearTimeout(this.endTimer);
87
+ this.endTimer = setTimeout(() => {
88
+ this.hover = false;
89
+ }, this.hoverStayTime);
90
+ },
91
+ },
92
+ };
93
+ </script>