@mpxjs/webpack-plugin 2.9.17 → 2.9.19-react.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.
Files changed (66) hide show
  1. package/lib/config.js +59 -97
  2. package/lib/dependencies/ResolveDependency.js +2 -2
  3. package/lib/helpers.js +5 -1
  4. package/lib/index.js +27 -19
  5. package/lib/loader.js +56 -118
  6. package/lib/native-loader.js +43 -20
  7. package/lib/platform/index.js +3 -0
  8. package/lib/platform/style/wx/index.js +413 -0
  9. package/lib/platform/template/wx/component-config/button.js +36 -0
  10. package/lib/platform/template/wx/component-config/cover-view.js +1 -1
  11. package/lib/platform/template/wx/component-config/image.js +15 -0
  12. package/lib/platform/template/wx/component-config/input.js +36 -0
  13. package/lib/platform/template/wx/component-config/scroll-view.js +27 -1
  14. package/lib/platform/template/wx/component-config/swiper-item.js +13 -1
  15. package/lib/platform/template/wx/component-config/swiper.js +25 -1
  16. package/lib/platform/template/wx/component-config/text.js +17 -1
  17. package/lib/platform/template/wx/component-config/textarea.js +39 -0
  18. package/lib/platform/template/wx/component-config/unsupported.js +18 -0
  19. package/lib/platform/template/wx/component-config/view.js +15 -1
  20. package/lib/platform/template/wx/index.js +89 -7
  21. package/lib/react/index.js +92 -0
  22. package/lib/react/processJSON.js +362 -0
  23. package/lib/react/processScript.js +40 -0
  24. package/lib/react/processStyles.js +63 -0
  25. package/lib/react/processTemplate.js +151 -0
  26. package/lib/react/script-helper.js +79 -0
  27. package/lib/react/style-helper.js +91 -0
  28. package/lib/runtime/components/react/event.config.ts +32 -0
  29. package/lib/runtime/components/react/getInnerListeners.ts +289 -0
  30. package/lib/runtime/components/react/getInnerListeners.type.ts +68 -0
  31. package/lib/runtime/components/react/mpx-button.tsx +402 -0
  32. package/lib/runtime/components/react/mpx-image/index.tsx +351 -0
  33. package/lib/runtime/components/react/mpx-image/svg.tsx +21 -0
  34. package/lib/runtime/components/react/mpx-input.tsx +389 -0
  35. package/lib/runtime/components/react/mpx-scroll-view.tsx +412 -0
  36. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +407 -0
  37. package/lib/runtime/components/react/mpx-swiper/index.tsx +68 -0
  38. package/lib/runtime/components/react/mpx-swiper/type.ts +69 -0
  39. package/lib/runtime/components/react/mpx-swiper-item.tsx +42 -0
  40. package/lib/runtime/components/react/mpx-text.tsx +106 -0
  41. package/lib/runtime/components/react/mpx-textarea.tsx +46 -0
  42. package/lib/runtime/components/react/mpx-view.tsx +397 -0
  43. package/lib/runtime/components/react/utils.ts +92 -0
  44. package/lib/runtime/components/web/event.js +100 -0
  45. package/lib/runtime/components/web/getInnerListeners.js +0 -78
  46. package/lib/runtime/components/web/mpx-button.vue +1 -1
  47. package/lib/runtime/components/web/mpx-navigator.vue +1 -1
  48. package/lib/runtime/components/web/mpx-scroll-view.vue +113 -37
  49. package/lib/runtime/oc.wxs +16 -0
  50. package/lib/runtime/optionProcessor.js +1 -1
  51. package/lib/runtime/stringify.wxs +3 -7
  52. package/lib/runtime/useNodesRef.ts +39 -0
  53. package/lib/style-compiler/index.js +2 -1
  54. package/lib/template-compiler/compiler.js +544 -121
  55. package/lib/template-compiler/gen-node-react.js +95 -0
  56. package/lib/template-compiler/index.js +19 -31
  57. package/lib/utils/env.js +17 -0
  58. package/lib/utils/make-map.js +1 -1
  59. package/lib/utils/shallow-stringify.js +17 -0
  60. package/lib/utils/ts-loader-watch-run-loader-filter.js +4 -1
  61. package/lib/web/index.js +122 -0
  62. package/lib/web/processMainScript.js +6 -4
  63. package/lib/web/processScript.js +9 -5
  64. package/lib/web/processTemplate.js +14 -14
  65. package/lib/web/script-helper.js +11 -19
  66. package/package.json +7 -3
@@ -13,6 +13,12 @@ module.exports = function ({ print }) {
13
13
  const webEventLog = print({ platform: 'web', tag: TAG_NAME, isError: false, type: 'event' })
14
14
  const webValueLog = print({ platform: 'web', tag: TAG_NAME, isError: false, type: 'value' })
15
15
  const qaPropLog = print({ platform: 'qa', tag: TAG_NAME, isError: false })
16
+ const iosValueLogError = print({ platform: 'ios', tag: TAG_NAME, isError: true, type: 'value' })
17
+ const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
18
+ const iosEventLog = print({ platform: 'ios', tag: TAG_NAME, isError: false, type: 'event' })
19
+ const androidValueLogError = print({ platform: 'android', tag: TAG_NAME, isError: true, type: 'value' })
20
+ const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
21
+ const androidEventLog = print({ platform: 'android', tag: TAG_NAME, isError: false, type: 'event' })
16
22
 
17
23
  return {
18
24
  test: TAG_NAME,
@@ -20,6 +26,14 @@ module.exports = function ({ print }) {
20
26
  el.isBuiltIn = true
21
27
  return 'mpx-input'
22
28
  },
29
+ ios (tag, { el }) {
30
+ el.isBuiltIn = true
31
+ return 'mpx-input'
32
+ },
33
+ android (tag, { el }) {
34
+ el.isBuiltIn = true
35
+ return 'mpx-input'
36
+ },
23
37
  props: [
24
38
  {
25
39
  test: /^(cursor-spacing|auto-focus|adjust-position|hold-keyboard)$/,
@@ -49,6 +63,18 @@ module.exports = function ({ print }) {
49
63
  name,
50
64
  value
51
65
  }
66
+ },
67
+ ios ({ name, value }) {
68
+ const notSupported = ['safe-password', 'nickname']
69
+ if (notSupported.includes(value)) {
70
+ iosValueLogError({ name, value })
71
+ }
72
+ },
73
+ android ({ name, value }) {
74
+ const notSupported = ['safe-password', 'nickname']
75
+ if (notSupported.includes(value)) {
76
+ androidValueLogError({ name, value })
77
+ }
52
78
  }
53
79
  },
54
80
  {
@@ -64,6 +90,11 @@ module.exports = function ({ print }) {
64
90
  {
65
91
  test: /^(always-embed|bindkeyboardheightchange)$/,
66
92
  qa: qaPropLog
93
+ },
94
+ {
95
+ test: /^(placeholder-style|placeholder-class|cursor-spacing|always-embed|adjust-position|hold-keyboard|safe-password-.+)$/,
96
+ ios: iosPropLog,
97
+ android: androidPropLog
67
98
  }
68
99
  ],
69
100
  event: [
@@ -78,6 +109,11 @@ module.exports = function ({ print }) {
78
109
  {
79
110
  test: 'confirm',
80
111
  web: webEventLog
112
+ },
113
+ {
114
+ test: /^(nicknamereview|onkeyboardheightchange|keyboard.+)$/,
115
+ ios: iosEventLog,
116
+ android: androidEventLog
81
117
  }
82
118
  ]
83
119
  }
@@ -12,6 +12,10 @@ module.exports = function ({ print }) {
12
12
  const aliEventLog = print({ platform: 'ali', tag: TAG_NAME, isError: false, type: 'event' })
13
13
  const qqEventLog = print({ platform: 'qq', tag: TAG_NAME, isError: false, type: 'event' })
14
14
  const qqPropLog = print({ platform: 'qq', tag: TAG_NAME, isError: false })
15
+ const androidEventLog = print({ platform: 'android', tag: TAG_NAME, isError: false, type: 'event' })
16
+ const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
17
+ const iosEventLog = print({ platform: 'ios', tag: TAG_NAME, isError: false, type: 'event' })
18
+ const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
15
19
 
16
20
  return {
17
21
  test: TAG_NAME,
@@ -19,9 +23,17 @@ module.exports = function ({ print }) {
19
23
  el.isBuiltIn = true
20
24
  return 'mpx-scroll-view'
21
25
  },
26
+ android (tag, { el }) {
27
+ el.isBuiltIn = true
28
+ return 'mpx-scroll-view'
29
+ },
30
+ ios (tag, { el }) {
31
+ el.isBuiltIn = true
32
+ return 'mpx-scroll-view'
33
+ },
22
34
  props: [
23
35
  {
24
- test: /^(enable-flex|scroll-anchorin|refresher-enabled|refresher-threshold|refresher-default-style|refresher-background|refresher-triggered|enhanced|bounces|show-scrollbar|paging-enabled|fast-deceleratio)$/,
36
+ test: /^(enable-flex|scroll-anchoring|refresher-enabled|refresher-threshold|refresher-default-style|refresher-background|refresher-triggered|enhanced|bounces|show-scrollbar|paging-enabled|fast-deceleration)$/,
25
37
  ali: aliPropLog,
26
38
  tt: ttPropLog,
27
39
  qq: qqPropLog,
@@ -39,6 +51,15 @@ module.exports = function ({ print }) {
39
51
  {
40
52
  test: /^(enable-back-to-top|enable-flex|scroll-anchoring|enhanced|bounces|show-scrollbar|paging-enabled|fast-deceleration|binddragstart|binddragging|binddragend)$/,
41
53
  qa: qaPropLog
54
+ },
55
+ {
56
+ test: /^(scroll-into-view|refresher-threshold|enable-passive|scroll-anchoring|using-sticky|fast-deceleration|enable-flex)$/,
57
+ android: androidPropLog,
58
+ ios: iosPropLog
59
+ },
60
+ {
61
+ test: /^(refresher-default-style|refresher-background)$/,
62
+ ios: iosPropLog
42
63
  }
43
64
  ],
44
65
  event: [
@@ -63,6 +84,11 @@ module.exports = function ({ print }) {
63
84
  tt: ttEventLog,
64
85
  qq: qqEventLog,
65
86
  swan: baiduEventLog
87
+ },
88
+ {
89
+ test: /^(refresherpulling|refresherrestore|refresherabort)$/,
90
+ android: androidEventLog,
91
+ ios: iosEventLog
66
92
  }
67
93
  ]
68
94
  }
@@ -6,6 +6,8 @@ module.exports = function ({ print }) {
6
6
  const ttPropLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false })
7
7
  const baiduPropLog = print({ platform: 'baidu', tag: TAG_NAME, isError: false })
8
8
  const qqPropLog = print({ platform: 'qq', tag: TAG_NAME, isError: false })
9
+ const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
10
+ const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
9
11
 
10
12
  return {
11
13
  test: TAG_NAME,
@@ -13,10 +15,20 @@ module.exports = function ({ print }) {
13
15
  el.isBuiltIn = true
14
16
  return 'mpx-swiper-item'
15
17
  },
18
+ ios (tag, { el }) {
19
+ el.isBuiltIn = true
20
+ return 'mpx-swiper-item'
21
+ },
22
+ android (tag, { el }) {
23
+ el.isBuiltIn = true
24
+ return 'mpx-swiper-item'
25
+ },
16
26
  props: [
17
27
  {
18
28
  test: /^(item-id)$/,
19
- ali: aliPropLog
29
+ ali: aliPropLog,
30
+ ios: iosPropLog,
31
+ android: androidPropLog
20
32
  },
21
33
  {
22
34
  test: /^(skip-hidden-item-layout)$/,
@@ -10,6 +10,10 @@ module.exports = function ({ print }) {
10
10
  const jdEventLog = print({ platform: 'jd', tag: TAG_NAME, isError: false, type: 'event' })
11
11
  const jdPropLog = print({ platform: 'jd', tag: TAG_NAME, isError: false })
12
12
  const qaPropLog = print({ platform: 'qa', tag: TAG_NAME, isError: false })
13
+ const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
14
+ const iosEventLog = print({ platform: 'ios', tag: TAG_NAME, isError: false, type: 'event' })
15
+ const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
16
+ const androidEventLog = print({ platform: 'android', tag: TAG_NAME, isError: false, type: 'event' })
13
17
 
14
18
  return {
15
19
  test: TAG_NAME,
@@ -17,6 +21,14 @@ module.exports = function ({ print }) {
17
21
  el.isBuiltIn = true
18
22
  return 'mpx-swiper'
19
23
  },
24
+ ios (tag, { el }) {
25
+ el.isBuiltIn = true
26
+ return 'mpx-swiper'
27
+ },
28
+ android (tag, { el }) {
29
+ el.isBuiltIn = true
30
+ return 'mpx-swiper'
31
+ },
20
32
  props: [
21
33
  {
22
34
  test: /^(display-multiple-items|skip-hidden-item-layout|easing-function)$/,
@@ -45,6 +57,11 @@ module.exports = function ({ print }) {
45
57
  {
46
58
  test: /^(snap-to-edge|easing-function)$/,
47
59
  qa: qaPropLog
60
+ },
61
+ {
62
+ test: /^(display-multiple-items|snap-to-edge|easing-function)$/,
63
+ ios: iosPropLog,
64
+ android: androidPropLog
48
65
  }
49
66
  ],
50
67
  event: [
@@ -61,7 +78,14 @@ module.exports = function ({ print }) {
61
78
  {
62
79
  test: /^(transition)$/,
63
80
  swan: baiduEventLog,
64
- jd: jdEventLog
81
+ jd: jdEventLog,
82
+ ios: iosEventLog,
83
+ android: androidEventLog
84
+ },
85
+ {
86
+ test: /^(animationfinish)$/,
87
+ ios: iosEventLog,
88
+ android: androidEventLog
65
89
  }
66
90
  ]
67
91
  }
@@ -6,19 +6,30 @@ module.exports = function ({ print }) {
6
6
  const aliPropLog = print({ platform: 'ali', tag: TAG_NAME, isError: false })
7
7
  const ttPropLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false })
8
8
  const qqPropLog = print({ platform: 'qq', tag: TAG_NAME, isError: false })
9
+ const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
10
+ const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
9
11
 
10
12
  return {
11
13
  test: TAG_NAME,
12
14
  web (tag, { el }) {
13
- if (el.hasEvent) {
15
+ if (el.hasModel) {
14
16
  el.isBuiltIn = true
15
17
  }
18
+
16
19
  if (el.isBuiltIn) {
17
20
  return 'mpx-text'
18
21
  } else {
19
22
  return 'span'
20
23
  }
21
24
  },
25
+ ios (tag, { el }) {
26
+ el.isBuiltIn = true
27
+ return 'mpx-text'
28
+ },
29
+ android (tag, { el }) {
30
+ el.isBuiltIn = true
31
+ return 'mpx-text'
32
+ },
22
33
  props: [
23
34
  {
24
35
  test: /^(decode|user-select)$/,
@@ -31,6 +42,11 @@ module.exports = function ({ print }) {
31
42
  qq: qqPropLog,
32
43
  qa: qaPropLog
33
44
  },
45
+ {
46
+ test: /^(space|decode)$/,
47
+ ios: iosPropLog,
48
+ android: androidPropLog
49
+ },
34
50
  {
35
51
  test: /^(selectable|space|decode|use-built-in)$/,
36
52
  web (prop, { el }) {
@@ -14,6 +14,12 @@ module.exports = function ({ print }) {
14
14
  const qqEventLog = print({ platform: 'qq', tag: TAG_NAME, isError: false, type: 'event' })
15
15
  const qqPropLog = print({ platform: 'qq', tag: TAG_NAME, isError: false })
16
16
  const baiduPropLog = print({ platform: 'baidu', tag: TAG_NAME, isError: false })
17
+ const iosValueLogError = print({ platform: 'ios', tag: TAG_NAME, isError: true, type: 'value' })
18
+ const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
19
+ const iosEventLog = print({ platform: 'ios', tag: TAG_NAME, isError: false, type: 'event' })
20
+ const androidValueLogError = print({ platform: 'android', tag: TAG_NAME, isError: true, type: 'value' })
21
+ const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
22
+ const androidEventLog = print({ platform: 'android', tag: TAG_NAME, isError: false, type: 'event' })
17
23
 
18
24
  return {
19
25
  test: TAG_NAME,
@@ -22,6 +28,14 @@ module.exports = function ({ print }) {
22
28
  el.isBuiltIn = true
23
29
  return 'mpx-textarea'
24
30
  },
31
+ ios (tag, { el }) {
32
+ el.isBuiltIn = true
33
+ return 'mpx-textarea'
34
+ },
35
+ android (tag, { el }) {
36
+ el.isBuiltIn = true
37
+ return 'mpx-textarea'
38
+ },
25
39
  props: [
26
40
  {
27
41
  test: /^(auto-focus|fixed|cursor-spacing|cursor|show-confirm-bar|selection-start|selection-end|adjust-position|hold-keyboard|disable-default-padding|confirm-type)$/,
@@ -47,6 +61,26 @@ module.exports = function ({ print }) {
47
61
  {
48
62
  test: /^(fixed|cursor-spacing|show-confirm-bar|adjust-position|hold-keyboard|auto-height)$/,
49
63
  qa: qaPropLog
64
+ },
65
+ {
66
+ test: 'confirm-type',
67
+ ios ({ name, value }) {
68
+ const notSupported = ['return']
69
+ if (notSupported.includes(value)) {
70
+ iosValueLogError({ name, value })
71
+ }
72
+ },
73
+ android ({ name, value }) {
74
+ const notSupported = ['return']
75
+ if (notSupported.includes(value)) {
76
+ androidValueLogError({ name, value })
77
+ }
78
+ }
79
+ },
80
+ {
81
+ test: /^(placeholder-style|placeholder-class|cursor-spacing|always-embed|adjust-position|hold-keyboard|disable-default-padding|adjust-keyboard-to|fixed|show-confirm-bar)$/,
82
+ ios: iosPropLog,
83
+ android: androidPropLog
50
84
  }
51
85
  ],
52
86
  event: [
@@ -71,6 +105,11 @@ module.exports = function ({ print }) {
71
105
  {
72
106
  test: /^(linechange|keyboardheightchange)$/,
73
107
  tt: ttEventLog
108
+ },
109
+ {
110
+ test: /^keyboard.+$/,
111
+ ios: iosEventLog,
112
+ android: androidEventLog
74
113
  }
75
114
  ]
76
115
  }
@@ -10,6 +10,10 @@ const TT_UNSUPPORTED_TAG_NAME_ARR = ['movable-view', 'cover-image', 'cover-view'
10
10
  const JD_UNSUPPORTED_TAG_NAME_ARR = ['functional-page-navigator', 'live-pusher', 'live-player', 'rich-text', 'audio', 'video', 'camera']
11
11
  // 快应用不支持的标签集合
12
12
  const QA_UNSUPPORTED_TAG_NAME_ARR = ['movable-view', 'movable-area', 'open-data', 'official-account', 'editor', 'functional-page-navigator', 'live-player', 'live-pusher', 'ad', 'cover-image']
13
+ // RN不支持的标签集合
14
+ const RN_UNSUPPORTED_TAG_NAME_ARR = ['movable-view', 'movable-area', 'open-data', 'official-account', 'editor', 'functional-page-navigator', 'live-player', 'live-pusher', 'ad', 'cover-image',
15
+ 'checkbox', 'checkbox-group', 'radio', 'radio-group', 'switch', 'movable-area', 'movable-view', 'icon', 'progress', 'rich-text', 'form', 'label', 'picker', 'picker-view', 'picker-view-column', 'slider',
16
+ 'audio', 'camera', 'video', 'canvas', 'cover-image', 'cover-view', 'match-media', 'page-container', 'root-portal', 'editor', 'keyboard-accessory', 'navigator', 'map']
13
17
 
14
18
  /**
15
19
  * @param {function(object): function} print
@@ -22,6 +26,8 @@ module.exports = function ({ print }) {
22
26
  const ttUnsupportedTagError = print({ platform: 'bytedance', isError: true, type: 'tag' })
23
27
  const jdUnsupportedTagError = print({ platform: 'jd', isError: true, type: 'tag' })
24
28
  const qaUnsupportedTagError = print({ platform: 'qa', isError: true, type: 'tag' })
29
+ const iosUnsupportedTagError = print({ platform: 'ios', isError: true, type: 'tag' })
30
+ const androidUnsupportedTagError = print({ platform: 'android', isError: true, type: 'tag' })
25
31
 
26
32
  const aliUnsupportedExp = new RegExp('^(' + ALI_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
27
33
  const baiduUnsupportedExp = new RegExp('^(' + BAIDU_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
@@ -29,6 +35,8 @@ module.exports = function ({ print }) {
29
35
  const ttUnsupportedExp = new RegExp('^(' + TT_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
30
36
  const jdUnsupportedExp = new RegExp('^(' + JD_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
31
37
  const qaUnsupportedExp = new RegExp('^(' + QA_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
38
+ const iosUnsupportedExp = new RegExp('^(' + RN_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
39
+ const androidUnsupportedExp = new RegExp('^(' + RN_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
32
40
 
33
41
  return [
34
42
  {
@@ -60,6 +68,16 @@ module.exports = function ({ print }) {
60
68
  supportedModes: ['qa'],
61
69
  test: qaUnsupportedExp,
62
70
  qa: qaUnsupportedTagError
71
+ },
72
+ {
73
+ supportedModes: ['ios'],
74
+ test: iosUnsupportedExp,
75
+ ios: iosUnsupportedTagError
76
+ },
77
+ {
78
+ supportedModes: ['android'],
79
+ test: androidUnsupportedExp,
80
+ android: androidUnsupportedTagError
63
81
  }
64
82
  ]
65
83
  }
@@ -3,6 +3,8 @@ const TAG_NAME = 'view'
3
3
  module.exports = function ({ print }) {
4
4
  const qaPropLog = print({ platform: 'qa', tag: TAG_NAME, isError: false })
5
5
  const qaEventLogError = print({ platform: 'qa', tag: TAG_NAME, isError: false, type: 'event' })
6
+ const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
7
+ const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
6
8
 
7
9
  return {
8
10
  // 匹配标签名,可传递正则
@@ -12,7 +14,7 @@ module.exports = function ({ print }) {
12
14
  // return 'a:view'
13
15
  // },
14
16
  web (tag, { el }) {
15
- if (el.hasEvent) {
17
+ if (el.hasModel) {
16
18
  el.isBuiltIn = true
17
19
  }
18
20
  if (el.isBuiltIn) {
@@ -21,6 +23,14 @@ module.exports = function ({ print }) {
21
23
  return 'div'
22
24
  }
23
25
  },
26
+ ios (tag, { el }) {
27
+ el.isBuiltIn = true
28
+ return 'mpx-view'
29
+ },
30
+ android (tag, { el }) {
31
+ el.isBuiltIn = true
32
+ return 'mpx-view'
33
+ },
24
34
  qa (tag) {
25
35
  return 'div'
26
36
  },
@@ -33,6 +43,10 @@ module.exports = function ({ print }) {
33
43
  el.isBuiltIn = true
34
44
  },
35
45
  qa: qaPropLog
46
+ }, {
47
+ test: /^(hover-stop-propagation)$/,
48
+ android: androidPropLog,
49
+ ios: iosPropLog
36
50
  }
37
51
  ],
38
52
  // 组件事件中的差异部分
@@ -8,7 +8,7 @@ const normalize = require('../../../utils/normalize')
8
8
 
9
9
  module.exports = function getSpec ({ warn, error }) {
10
10
  const spec = {
11
- supportedModes: ['ali', 'swan', 'qq', 'tt', 'web', 'qa', 'jd', 'dd'],
11
+ supportedModes: ['ali', 'swan', 'qq', 'tt', 'web', 'qa', 'jd', 'dd', 'ios', 'android'],
12
12
  // props预处理
13
13
  preProps: [],
14
14
  // props后处理
@@ -124,7 +124,7 @@ module.exports = function getSpec ({ warn, error }) {
124
124
  {
125
125
  test: 'wx:model',
126
126
  web ({ value }, { el }) {
127
- el.hasEvent = true
127
+ el.hasModel = true
128
128
  const attrsMap = el.attrsMap
129
129
  const tagRE = /\{\{((?:.|\n|\r)+?)\}\}(?!})/
130
130
  const stringify = JSON.stringify
@@ -387,14 +387,42 @@ module.exports = function getSpec ({ warn, error }) {
387
387
  modifierStr
388
388
  }
389
389
  const isComponent = usingComponents.indexOf(el.tag) !== -1 || el.tag === 'component'
390
- // 记录event监听信息用于后续判断是否需要使用内置基础组件
391
- el.hasEvent = true
392
390
  const rPrefix = runRules(spec.event.prefix, prefix, { mode: 'web', meta })
393
391
  const rEventName = runRules(eventRules, eventName, { mode: 'web', data: { isComponent } })
394
392
  return {
395
393
  name: rPrefix + rEventName + meta.modifierStr,
396
394
  value
397
395
  }
396
+ },
397
+ ios ({ name, value }, { eventRules, el }) {
398
+ const match = this.test.exec(name)
399
+ const prefix = match[1]
400
+ const eventName = match[2]
401
+ const modifierStr = match[3] || ''
402
+ const meta = {
403
+ modifierStr
404
+ }
405
+ const rPrefix = runRules(spec.event.prefix, prefix, { mode: 'ios' })
406
+ const rEventName = runRules(eventRules, eventName, { mode: 'ios', data: { el } })
407
+ return {
408
+ name: rPrefix + rEventName + meta.modifierStr,
409
+ value
410
+ }
411
+ },
412
+ android ({ name, value }, { eventRules, el }) {
413
+ const match = this.test.exec(name)
414
+ const prefix = match[1]
415
+ const eventName = match[2]
416
+ const modifierStr = match[3] || ''
417
+ const meta = {
418
+ modifierStr
419
+ }
420
+ const rPrefix = runRules(spec.event.prefix, prefix, { mode: 'android' })
421
+ const rEventName = runRules(eventRules, eventName, { mode: 'android', data: { el } })
422
+ return {
423
+ name: rPrefix + rEventName + meta.modifierStr,
424
+ value
425
+ }
398
426
  }
399
427
  },
400
428
  // 无障碍
@@ -446,6 +474,28 @@ module.exports = function getSpec ({ warn, error }) {
446
474
  meta.modifierStr = tempModifierStr ? '.' + tempModifierStr : ''
447
475
  return '@'
448
476
  }
477
+ // ios (prefix) {
478
+ // const prefixMap = {
479
+ // bind: 'on',
480
+ // catch: 'catch'
481
+ // }
482
+ // if (!prefixMap[prefix]) {
483
+ // error(`React native environment does not support [${prefix}] event handling!`)
484
+ // return
485
+ // }
486
+ // return prefixMap[prefix]
487
+ // },
488
+ // android (prefix) {
489
+ // const prefixMap = {
490
+ // bind: 'on',
491
+ // catch: 'catch'
492
+ // }
493
+ // if (!prefixMap[prefix]) {
494
+ // error(`React native environment does not support [${prefix}] event handling!`)
495
+ // return
496
+ // }
497
+ // return prefixMap[prefix]
498
+ // }
449
499
  }
450
500
  ],
451
501
  rules: [
@@ -476,14 +526,46 @@ module.exports = function getSpec ({ warn, error }) {
476
526
  if (eventName === 'touchforcechange') {
477
527
  error(`Web environment does not support [${eventName}] event!`)
478
528
  }
529
+ },
530
+ ios (eventName) {
531
+ const eventMap = {
532
+ tap: 'tap',
533
+ longtap: 'longpress',
534
+ longpress: 'longpress',
535
+ touchstart: 'touchstart',
536
+ touchmove: 'touchmove',
537
+ touchend: 'touchend',
538
+ touchcancel: 'touchcancel'
539
+ }
540
+ if (eventMap[eventName]) {
541
+ return eventMap[eventName]
542
+ } else {
543
+ error(`React native environment does not support [${eventName}] event!`)
544
+ }
545
+ },
546
+ android (eventName) {
547
+ const eventMap = {
548
+ tap: 'tap',
549
+ longtap: 'longpress',
550
+ longpress: 'longpress',
551
+ touchstart: 'touchstart',
552
+ touchmove: 'touchmove',
553
+ touchend: 'touchend',
554
+ touchcancel: 'touchcancel'
555
+ }
556
+ if (eventMap[eventName]) {
557
+ return eventMap[eventName]
558
+ } else {
559
+ error(`React native environment does not support [${eventName}] event!`)
560
+ }
479
561
  }
480
562
  },
481
- // 特殊web事件
563
+ // web event escape
482
564
  {
483
565
  test: /^click$/,
484
- web (eventName, data) {
566
+ web (eventName, { isComponent }) {
485
567
  // 自定义组件根节点
486
- if (data.isComponent) {
568
+ if (isComponent) {
487
569
  return '_' + eventName
488
570
  }
489
571
  }
@@ -0,0 +1,92 @@
1
+ const async = require('async')
2
+ const processJSON = require('./processJSON')
3
+ const processTemplate = require('./processTemplate')
4
+ const processStyles = require('./processStyles')
5
+ const processScript = require('./processScript')
6
+ const RecordVueContentDependency = require('../dependencies/RecordVueContentDependency')
7
+
8
+ module.exports = function ({
9
+ parts,
10
+ loaderContext,
11
+ pagesMap,
12
+ componentsMap,
13
+ queryObj,
14
+ ctorType,
15
+ srcMode,
16
+ moduleId,
17
+ isProduction,
18
+ hasScoped,
19
+ hasComment,
20
+ isNative,
21
+ usingComponents,
22
+ componentGenerics,
23
+ autoScope,
24
+ callback
25
+ }) {
26
+ const mpx = loaderContext.getMpx()
27
+ // 通过RecordVueContentDependency和vueContentCache确保子request不再重复生成vueContent
28
+ const cacheContent = mpx.vueContentCache.get(loaderContext.resourcePath)
29
+ if (cacheContent) return callback(null, cacheContent)
30
+ let output = ''
31
+ return async.waterfall([
32
+ (callback) => {
33
+ async.parallel([
34
+ (callback) => {
35
+ processTemplate(parts.template, {
36
+ loaderContext,
37
+ hasScoped,
38
+ hasComment,
39
+ isNative,
40
+ srcMode,
41
+ moduleId,
42
+ ctorType,
43
+ usingComponents,
44
+ componentGenerics
45
+ }, callback)
46
+ },
47
+ (callback) => {
48
+ processStyles(parts.styles, {
49
+ loaderContext,
50
+ srcMode,
51
+ ctorType,
52
+ autoScope,
53
+ moduleId
54
+ }, callback)
55
+ },
56
+ (callback) => {
57
+ processJSON(parts.json, {
58
+ loaderContext,
59
+ pagesMap,
60
+ componentsMap
61
+ }, callback)
62
+ }
63
+ ], (err, res) => {
64
+ callback(err, res)
65
+ })
66
+ },
67
+ ([templateRes, stylesRes, jsonRes], callback) => {
68
+ output += templateRes.output
69
+ output += stylesRes.output
70
+ output += jsonRes.output
71
+ processScript(parts.script, {
72
+ loaderContext,
73
+ ctorType,
74
+ srcMode,
75
+ moduleId,
76
+ isProduction,
77
+ componentGenerics,
78
+ jsonConfig: jsonRes.jsonObj,
79
+ outputPath: queryObj.outputPath || '',
80
+ builtInComponentsMap: templateRes.builtInComponentsMap,
81
+ genericsInfo: templateRes.genericsInfo,
82
+ wxsModuleMap: templateRes.wxsModuleMap,
83
+ localComponentsMap: jsonRes.localComponentsMap
84
+ }, callback)
85
+ }
86
+ ], (err, scriptRes) => {
87
+ if (err) return callback(err)
88
+ output += scriptRes.output
89
+ loaderContext._module.addPresentationalDependency(new RecordVueContentDependency(loaderContext.resourcePath, output))
90
+ callback(null, output)
91
+ })
92
+ }