@mpxjs/webpack-plugin 2.10.2 → 2.10.3-beta.4

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 (76) hide show
  1. package/lib/config.js +2 -1
  2. package/lib/dependencies/RecordPageConfigsMapDependency.js +45 -0
  3. package/lib/index.js +13 -1
  4. package/lib/platform/json/wx/index.js +6 -3
  5. package/lib/platform/style/wx/index.js +29 -16
  6. package/lib/platform/template/wx/component-config/button.js +19 -2
  7. package/lib/platform/template/wx/component-config/canvas.js +4 -0
  8. package/lib/platform/template/wx/component-config/checkbox-group.js +4 -0
  9. package/lib/platform/template/wx/component-config/checkbox.js +4 -0
  10. package/lib/platform/template/wx/component-config/cover-image.js +7 -1
  11. package/lib/platform/template/wx/component-config/cover-view.js +4 -0
  12. package/lib/platform/template/wx/component-config/fix-component-name.js +3 -2
  13. package/lib/platform/template/wx/component-config/form.js +7 -1
  14. package/lib/platform/template/wx/component-config/icon.js +4 -0
  15. package/lib/platform/template/wx/component-config/image.js +7 -1
  16. package/lib/platform/template/wx/component-config/input.js +17 -2
  17. package/lib/platform/template/wx/component-config/label.js +4 -0
  18. package/lib/platform/template/wx/component-config/movable-area.js +7 -1
  19. package/lib/platform/template/wx/component-config/movable-view.js +12 -3
  20. package/lib/platform/template/wx/component-config/navigator.js +4 -0
  21. package/lib/platform/template/wx/component-config/picker-view-column.js +4 -0
  22. package/lib/platform/template/wx/component-config/picker-view.js +7 -1
  23. package/lib/platform/template/wx/component-config/picker.js +7 -1
  24. package/lib/platform/template/wx/component-config/radio-group.js +4 -0
  25. package/lib/platform/template/wx/component-config/radio.js +4 -0
  26. package/lib/platform/template/wx/component-config/rich-text.js +4 -0
  27. package/lib/platform/template/wx/component-config/root-portal.js +4 -0
  28. package/lib/platform/template/wx/component-config/scroll-view.js +10 -2
  29. package/lib/platform/template/wx/component-config/swiper-item.js +7 -1
  30. package/lib/platform/template/wx/component-config/swiper.js +12 -3
  31. package/lib/platform/template/wx/component-config/switch.js +4 -0
  32. package/lib/platform/template/wx/component-config/text.js +7 -1
  33. package/lib/platform/template/wx/component-config/textarea.js +17 -2
  34. package/lib/platform/template/wx/component-config/unsupported.js +7 -0
  35. package/lib/platform/template/wx/component-config/video.js +10 -2
  36. package/lib/platform/template/wx/component-config/view.js +24 -2
  37. package/lib/platform/template/wx/component-config/web-view.js +4 -0
  38. package/lib/platform/template/wx/index.js +32 -13
  39. package/lib/react/index.js +0 -1
  40. package/lib/react/processJSON.js +13 -2
  41. package/lib/react/processScript.js +5 -3
  42. package/lib/react/processTemplate.js +18 -3
  43. package/lib/react/script-helper.js +18 -4
  44. package/lib/runtime/components/react/dist/mpx-input.jsx +1 -11
  45. package/lib/runtime/components/react/dist/{KeyboardAvoidingView.jsx → mpx-keyboard-avoiding-view.jsx} +4 -3
  46. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +2 -2
  47. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +1 -2
  48. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +10 -5
  49. package/lib/runtime/components/react/dist/mpx-simple-view.jsx +22 -0
  50. package/lib/runtime/components/react/dist/mpx-swiper.jsx +2 -2
  51. package/lib/runtime/components/react/dist/mpx-view.jsx +10 -5
  52. package/lib/runtime/components/react/dist/mpx-web-view.jsx +10 -7
  53. package/lib/runtime/components/react/dist/useAnimationHooks.js +46 -48
  54. package/lib/runtime/components/react/dist/utils.jsx +18 -7
  55. package/lib/runtime/components/react/mpx-input.tsx +1 -19
  56. package/lib/runtime/components/react/{KeyboardAvoidingView.tsx → mpx-keyboard-avoiding-view.tsx} +4 -2
  57. package/lib/runtime/components/react/mpx-picker-view-column.tsx +2 -2
  58. package/lib/runtime/components/react/mpx-portal/portal-manager.tsx +1 -2
  59. package/lib/runtime/components/react/mpx-scroll-view.tsx +13 -4
  60. package/lib/runtime/components/react/mpx-simple-view.tsx +32 -0
  61. package/lib/runtime/components/react/mpx-swiper.tsx +4 -2
  62. package/lib/runtime/components/react/mpx-view.tsx +17 -10
  63. package/lib/runtime/components/react/mpx-web-view.tsx +15 -12
  64. package/lib/runtime/components/react/types/getInnerListeners.d.ts +1 -1
  65. package/lib/runtime/components/react/types/global.d.ts +1 -1
  66. package/lib/runtime/components/react/useAnimationHooks.ts +46 -48
  67. package/lib/runtime/components/react/utils.tsx +23 -11
  68. package/lib/runtime/components/web/mini-video-controls.min.js +1 -1
  69. package/lib/runtime/optionProcessor.js +3 -2
  70. package/lib/style-compiler/index.js +8 -6
  71. package/lib/template-compiler/compiler.js +21 -13
  72. package/lib/utils/env.js +1 -1
  73. package/lib/utils/match-condition.js +14 -8
  74. package/lib/web/processJSON.js +1 -3
  75. package/package.json +3 -3
  76. package/LICENSE +0 -433
@@ -8,6 +8,7 @@ module.exports = function ({ print }) {
8
8
  const jdEventLog = print({ platform: 'jd', tag: TAG_NAME, isError: false, type: 'event' })
9
9
  const iosEventLog = print({ platform: 'ios', tag: TAG_NAME, isError: false, type: 'event' })
10
10
  const androidEventLog = print({ platform: 'android', tag: TAG_NAME, isError: false, type: 'event' })
11
+ const harmonyEventLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false, type: 'event' })
11
12
 
12
13
  return {
13
14
  test: TAG_NAME,
@@ -23,6 +24,10 @@ module.exports = function ({ print }) {
23
24
  el.isBuiltIn = true
24
25
  return 'mpx-picker-view'
25
26
  },
27
+ harmony (tag, { el }) {
28
+ el.isBuiltIn = true
29
+ return 'mpx-picker-view'
30
+ },
26
31
  props: [
27
32
  {
28
33
  test: /^(indicator-class|mask-class)$/,
@@ -37,7 +42,8 @@ module.exports = function ({ print }) {
37
42
  tt: ttEventLog,
38
43
  jd: jdEventLog,
39
44
  ios: iosEventLog,
40
- android: androidEventLog
45
+ android: androidEventLog,
46
+ harmony: harmonyEventLog
41
47
  }
42
48
  ]
43
49
  }
@@ -10,6 +10,7 @@ module.exports = function ({ print }) {
10
10
  const qaPropLog = print({ platform: 'qa', tag: TAG_NAME, isError: false })
11
11
  const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
12
12
  const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
13
+ const harmonyPropLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false })
13
14
 
14
15
  return {
15
16
  test: TAG_NAME,
@@ -25,6 +26,10 @@ module.exports = function ({ print }) {
25
26
  el.isBuiltIn = true
26
27
  return 'mpx-picker'
27
28
  },
29
+ harmony (tag, { el }) {
30
+ el.isBuiltIn = true
31
+ return 'mpx-picker'
32
+ },
28
33
  props: [
29
34
  {
30
35
  test: 'mode',
@@ -43,7 +48,8 @@ module.exports = function ({ print }) {
43
48
  jd: jdPropLog,
44
49
  qa: qaPropLog,
45
50
  ios: iosPropLog,
46
- android: androidPropLog
51
+ android: androidPropLog,
52
+ harmony: harmonyPropLog
47
53
  }
48
54
  ],
49
55
  event: [
@@ -14,6 +14,10 @@ module.exports = function () {
14
14
  android (tag, { el }) {
15
15
  el.isBuiltIn = true
16
16
  return 'mpx-radio-group'
17
+ },
18
+ harmony (tag, { el }) {
19
+ el.isBuiltIn = true
20
+ return 'mpx-radio-group'
17
21
  }
18
22
  }
19
23
  }
@@ -15,6 +15,10 @@ module.exports = function () {
15
15
  el.isBuiltIn = true
16
16
  return 'mpx-radio'
17
17
  },
18
+ harmony (tag, { el }) {
19
+ el.isBuiltIn = true
20
+ return 'mpx-radio'
21
+ },
18
22
  event: [
19
23
  {
20
24
  test: 'tap',
@@ -20,6 +20,10 @@ module.exports = function ({ print }) {
20
20
  el.isBuiltIn = true
21
21
  return 'mpx-rich-text'
22
22
  },
23
+ harmony (tag, { el }) {
24
+ el.isBuiltIn = true
25
+ return 'mpx-rich-text'
26
+ },
23
27
  props: [
24
28
  {
25
29
  test: /^(space)$/,
@@ -10,6 +10,10 @@ module.exports = function ({ print }) {
10
10
  android (tag, { el }) {
11
11
  el.isBuiltIn = true
12
12
  return 'mpx-root-portal'
13
+ },
14
+ harmony (tag, { el }) {
15
+ el.isBuiltIn = true
16
+ return 'mpx-root-portal'
13
17
  }
14
18
  }
15
19
  }
@@ -14,6 +14,8 @@ module.exports = function ({ print }) {
14
14
  const qqPropLog = print({ platform: 'qq', tag: TAG_NAME, isError: false })
15
15
  const androidEventLog = print({ platform: 'android', tag: TAG_NAME, isError: false, type: 'event' })
16
16
  const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
17
+ const harmonyEventLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false, type: 'event' })
18
+ const harmonyPropLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false })
17
19
  const iosEventLog = print({ platform: 'ios', tag: TAG_NAME, isError: false, type: 'event' })
18
20
  const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
19
21
 
@@ -27,6 +29,10 @@ module.exports = function ({ print }) {
27
29
  el.isBuiltIn = true
28
30
  return 'mpx-scroll-view'
29
31
  },
32
+ harmony (tag, { el }) {
33
+ el.isBuiltIn = true
34
+ return 'mpx-scroll-view'
35
+ },
30
36
  ios (tag, { el }) {
31
37
  el.isBuiltIn = true
32
38
  return 'mpx-scroll-view'
@@ -55,7 +61,8 @@ module.exports = function ({ print }) {
55
61
  {
56
62
  test: /^(refresher-threshold|enable-passive|scroll-anchoring|using-sticky|fast-deceleration|enable-flex)$/,
57
63
  android: androidPropLog,
58
- ios: iosPropLog
64
+ ios: iosPropLog,
65
+ harmony: harmonyPropLog
59
66
  },
60
67
  {
61
68
  test: /^(refresher-default-style|refresher-background)$/,
@@ -88,7 +95,8 @@ module.exports = function ({ print }) {
88
95
  {
89
96
  test: /^(refresherpulling|refresherrestore|refresherabort)$/,
90
97
  android: androidEventLog,
91
- ios: iosEventLog
98
+ ios: iosEventLog,
99
+ harmony: harmonyEventLog
92
100
  }
93
101
  ]
94
102
  }
@@ -8,6 +8,7 @@ module.exports = function ({ print }) {
8
8
  const qqPropLog = print({ platform: 'qq', tag: TAG_NAME, isError: false })
9
9
  const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
10
10
  const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
11
+ const harmonyPropLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false })
11
12
 
12
13
  return {
13
14
  test: TAG_NAME,
@@ -23,12 +24,17 @@ module.exports = function ({ print }) {
23
24
  el.isBuiltIn = true
24
25
  return 'mpx-swiper-item'
25
26
  },
27
+ harmony (tag, { el }) {
28
+ el.isBuiltIn = true
29
+ return 'mpx-swiper-item'
30
+ },
26
31
  props: [
27
32
  {
28
33
  test: /^(item-id)$/,
29
34
  ali: aliPropLog,
30
35
  ios: iosPropLog,
31
- android: androidPropLog
36
+ android: androidPropLog,
37
+ harmony: harmonyPropLog
32
38
  },
33
39
  {
34
40
  test: /^(skip-hidden-item-layout)$/,
@@ -14,6 +14,8 @@ module.exports = function ({ print }) {
14
14
  const iosEventLog = print({ platform: 'ios', tag: TAG_NAME, isError: false, type: 'event' })
15
15
  const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
16
16
  const androidEventLog = print({ platform: 'android', tag: TAG_NAME, isError: false, type: 'event' })
17
+ const harmonyPropLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false })
18
+ const harmonyEventLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false, type: 'event' })
17
19
 
18
20
  return {
19
21
  test: TAG_NAME,
@@ -29,6 +31,10 @@ module.exports = function ({ print }) {
29
31
  el.isBuiltIn = true
30
32
  return 'mpx-swiper'
31
33
  },
34
+ harmony (tag, { el }) {
35
+ el.isBuiltIn = true
36
+ return 'mpx-swiper'
37
+ },
32
38
  props: [
33
39
  {
34
40
  test: /^(display-multiple-items|skip-hidden-item-layout)$/,
@@ -61,7 +67,8 @@ module.exports = function ({ print }) {
61
67
  {
62
68
  test: /^(display-multiple-items|snap-to-edge|easing-function)$/,
63
69
  ios: iosPropLog,
64
- android: androidPropLog
70
+ android: androidPropLog,
71
+ harmony: harmonyPropLog
65
72
  }
66
73
  ],
67
74
  event: [
@@ -80,12 +87,14 @@ module.exports = function ({ print }) {
80
87
  swan: baiduEventLog,
81
88
  jd: jdEventLog,
82
89
  ios: iosEventLog,
83
- android: androidEventLog
90
+ android: androidEventLog,
91
+ harmony: harmonyEventLog
84
92
  },
85
93
  {
86
94
  test: /^(animationfinish)$/,
87
95
  ios: iosEventLog,
88
- android: androidEventLog
96
+ android: androidEventLog,
97
+ harmony: harmonyEventLog
89
98
  }
90
99
  ]
91
100
  }
@@ -18,6 +18,10 @@ module.exports = function ({ print }) {
18
18
  el.isBuiltIn = true
19
19
  return 'mpx-switch'
20
20
  },
21
+ harmony (tag, { el }) {
22
+ el.isBuiltIn = true
23
+ return 'mpx-switch'
24
+ },
21
25
  props: [
22
26
  {
23
27
  test: /^type$/,
@@ -8,6 +8,7 @@ module.exports = function ({ print }) {
8
8
  const qqPropLog = print({ platform: 'qq', tag: TAG_NAME, isError: false })
9
9
  const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
10
10
  const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
11
+ const harmonyPropLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false })
11
12
 
12
13
  return {
13
14
  test: TAG_NAME,
@@ -30,6 +31,10 @@ module.exports = function ({ print }) {
30
31
  el.isBuiltIn = true
31
32
  return 'mpx-text'
32
33
  },
34
+ harmony (tag, { el }) {
35
+ el.isBuiltIn = true
36
+ return 'mpx-text'
37
+ },
33
38
  props: [
34
39
  {
35
40
  test: /^(decode|user-select)$/,
@@ -45,7 +50,8 @@ module.exports = function ({ print }) {
45
50
  {
46
51
  test: /^(space|decode)$/,
47
52
  ios: iosPropLog,
48
- android: androidPropLog
53
+ android: androidPropLog,
54
+ harmony: harmonyPropLog
49
55
  },
50
56
  {
51
57
  test: /^(selectable|space|decode|use-built-in)$/,
@@ -20,6 +20,9 @@ module.exports = function ({ print }) {
20
20
  const androidValueLogError = print({ platform: 'android', tag: TAG_NAME, isError: true, type: 'value' })
21
21
  const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
22
22
  const androidEventLog = print({ platform: 'android', tag: TAG_NAME, isError: false, type: 'event' })
23
+ const harmonyValueLogError = print({ platform: 'harmony', tag: TAG_NAME, isError: true, type: 'value' })
24
+ const harmonyPropLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false })
25
+ const harmonyEventLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false, type: 'event' })
23
26
 
24
27
  return {
25
28
  test: TAG_NAME,
@@ -36,6 +39,10 @@ module.exports = function ({ print }) {
36
39
  el.isBuiltIn = true
37
40
  return 'mpx-textarea'
38
41
  },
42
+ harmony (tag, { el }) {
43
+ el.isBuiltIn = true
44
+ return 'mpx-textarea'
45
+ },
39
46
  props: [
40
47
  {
41
48
  test: /^(auto-focus|fixed|cursor-spacing|cursor|show-confirm-bar|selection-start|selection-end|adjust-position|hold-keyboard|disable-default-padding|confirm-type)$/,
@@ -75,12 +82,19 @@ module.exports = function ({ print }) {
75
82
  if (notSupported.includes(value)) {
76
83
  androidValueLogError({ name, value })
77
84
  }
85
+ },
86
+ harmony ({ name, value }) {
87
+ const notSupported = ['return']
88
+ if (notSupported.includes(value)) {
89
+ harmonyValueLogError({ name, value })
90
+ }
78
91
  }
79
92
  },
80
93
  {
81
94
  test: /^(always-embed|hold-keyboard|disable-default-padding|adjust-keyboard-to|fixed|show-confirm-bar)$/,
82
95
  ios: iosPropLog,
83
- android: androidPropLog
96
+ android: androidPropLog,
97
+ harmony: harmonyPropLog
84
98
  }
85
99
  ],
86
100
  event: [
@@ -109,7 +123,8 @@ module.exports = function ({ print }) {
109
123
  {
110
124
  test: /^keyboard.+$/,
111
125
  ios: iosEventLog,
112
- android: androidEventLog
126
+ android: androidEventLog,
127
+ harmony: harmonyEventLog
113
128
  }
114
129
  ]
115
130
  }
@@ -26,6 +26,7 @@ module.exports = function ({ print }) {
26
26
  const qaUnsupportedTagError = print({ platform: 'qa', isError: true, type: 'tag' })
27
27
  const iosUnsupportedTagError = print({ platform: 'ios', isError: true, type: 'tag' })
28
28
  const androidUnsupportedTagError = print({ platform: 'android', isError: true, type: 'tag' })
29
+ const harmonyUnsupportedTagError = print({ platform: 'harmony', isError: true, type: 'tag' })
29
30
 
30
31
  const aliUnsupportedExp = new RegExp('^(' + ALI_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
31
32
  const baiduUnsupportedExp = new RegExp('^(' + BAIDU_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
@@ -35,6 +36,7 @@ module.exports = function ({ print }) {
35
36
  const qaUnsupportedExp = new RegExp('^(' + QA_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
36
37
  const iosUnsupportedExp = new RegExp('^(' + RN_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
37
38
  const androidUnsupportedExp = new RegExp('^(' + RN_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
39
+ const harmonyUnsupportedExp = new RegExp('^(' + RN_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
38
40
 
39
41
  return [
40
42
  {
@@ -76,6 +78,11 @@ module.exports = function ({ print }) {
76
78
  supportedModes: ['android'],
77
79
  test: androidUnsupportedExp,
78
80
  android: androidUnsupportedTagError
81
+ },
82
+ {
83
+ supportedModes: ['harmony'],
84
+ test: harmonyUnsupportedExp,
85
+ harmony: harmonyUnsupportedTagError
79
86
  }
80
87
  ]
81
88
  }
@@ -15,6 +15,8 @@ module.exports = function ({ print }) {
15
15
  const iosEventLogError = print({ platform: 'ios', tag: TAG_NAME, isError: false, type: 'event' })
16
16
  const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
17
17
  const androidEventLogError = print({ platform: 'android', tag: TAG_NAME, isError: false, type: 'event' })
18
+ const harmonyPropLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false })
19
+ const harmonyEventLogError = print({ platform: 'harmony', tag: TAG_NAME, isError: false, type: 'event' })
18
20
  return {
19
21
  test: TAG_NAME,
20
22
  web (tag, { el }) {
@@ -25,6 +27,10 @@ module.exports = function ({ print }) {
25
27
  el.isBuiltIn = true
26
28
  return 'mpx-video'
27
29
  },
30
+ harmony (tag, { el }) {
31
+ el.isBuiltIn = true
32
+ return 'mpx-video'
33
+ },
28
34
  ios (tag, { el }) {
29
35
  el.isBuiltIn = true
30
36
  return 'mpx-video'
@@ -66,7 +72,8 @@ module.exports = function ({ print }) {
66
72
  },
67
73
  {
68
74
  test: /^(duration|enable-danmu|danmu-btn|page-gesture|direction|show-progress|show-fullscreen-btn|show-center-play-btn|enable-progress-gesture|show-mute-btn|title|play-btn-position|enable-play-gesture|auto-pause-if-navigate|auto-pause-if-open-native|vslide-gesture|vslide-gesture-in-fullscreen|show-bottom-progress|ad-unit-id|poster-for-crawler|show-casting-button|picture-in-picture-mode|picture-in-picture-show-progress| picture-in-picture-init-position|enable-auto-rotation|show-snapshot-button|show-screen-lock-button|show-background-playback-button|background-poster|referrer-policy|is-live)$/,
69
- android: androidPropLog
75
+ android: androidPropLog,
76
+ harmony: harmonyPropLog
70
77
  }
71
78
  ],
72
79
  event: [
@@ -108,7 +115,8 @@ module.exports = function ({ print }) {
108
115
  },
109
116
  {
110
117
  test: /^(progress|enterpictureinpicture|leavepictureinpicture|castinguserselect|castingstatechange|castinginterrupt)$/,
111
- android: androidEventLogError
118
+ android: androidEventLogError,
119
+ harmony: harmonyEventLogError
112
120
  }
113
121
  ]
114
122
  }
@@ -5,6 +5,7 @@ module.exports = function ({ print }) {
5
5
  const qaEventLogError = print({ platform: 'qa', tag: TAG_NAME, isError: false, type: 'event' })
6
6
  const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
7
7
  const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
8
+ const harmonyPropLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false })
8
9
 
9
10
  return {
10
11
  // 匹配标签名,可传递正则
@@ -25,10 +26,16 @@ module.exports = function ({ print }) {
25
26
  },
26
27
  ios (tag, { el }) {
27
28
  el.isBuiltIn = true
28
- return 'mpx-view'
29
+ return el.isSimple ? 'mpx-simple-view' : 'mpx-view'
29
30
  },
30
31
  android (tag, { el }) {
31
32
  el.isBuiltIn = true
33
+ return el.isSimple ? 'mpx-simple-view' : 'mpx-view'
34
+ return 'mpx-view'
35
+ },
36
+ harmony (tag, { el }) {
37
+ el.isBuiltIn = true
38
+ return el.isSimple ? 'mpx-simple-view' : 'mpx-view'
32
39
  return 'mpx-view'
33
40
  },
34
41
  qa (tag) {
@@ -46,7 +53,22 @@ module.exports = function ({ print }) {
46
53
  }, {
47
54
  test: /^(hover-stop-propagation)$/,
48
55
  android: androidPropLog,
49
- ios: iosPropLog
56
+ ios: iosPropLog,
57
+ harmony: harmonyPropLog
58
+ }, {
59
+ test: /^(is-simple)$/,
60
+ android (prop, { el }) {
61
+ el.isSimple = true
62
+ return false
63
+ },
64
+ harmony (prop, { el }) {
65
+ el.isSimple = true
66
+ return false
67
+ },
68
+ ios (prop, { el }) {
69
+ el.isSimple = true
70
+ return false
71
+ }
50
72
  }
51
73
  ],
52
74
  // 组件事件中的差异部分
@@ -14,6 +14,10 @@ module.exports = function () {
14
14
  android (tag, { el }) {
15
15
  el.isBuiltIn = true
16
16
  return 'mpx-web-view'
17
+ },
18
+ harmony (tag, { el }) {
19
+ el.isBuiltIn = true
20
+ return 'mpx-web-view'
17
21
  }
18
22
  }
19
23
  }
@@ -9,7 +9,7 @@ const { dash2hump } = require('../../../utils/hump-dash')
9
9
 
10
10
  module.exports = function getSpec ({ warn, error }) {
11
11
  const spec = {
12
- supportedModes: ['ali', 'swan', 'qq', 'tt', 'web', 'qa', 'jd', 'dd', 'ios', 'android'],
12
+ supportedModes: ['ali', 'swan', 'qq', 'tt', 'web', 'qa', 'jd', 'dd', 'ios', 'android', 'harmony'],
13
13
  // props预处理
14
14
  preProps: [],
15
15
  // props后处理
@@ -347,18 +347,6 @@ module.exports = function getSpec ({ warn, error }) {
347
347
  value
348
348
  }
349
349
  },
350
- // tt ({ name, value }, { eventRules }) {
351
- // const match = this.test.exec(name)
352
- // const prefix = match[1]
353
- // const eventName = match[2]
354
- // const modifierStr = match[3] || ''
355
- // const rEventName = runRules(eventRules, eventName, { mode: 'tt' })
356
- // return {
357
- // // 字节将所有事件转为小写
358
- // name: prefix + rEventName.toLowerCase() + modifierStr,
359
- // value
360
- // }
361
- // },
362
350
  tt ({ name, value }, { eventRules }) {
363
351
  const match = this.test.exec(name)
364
352
  const prefix = match[1]
@@ -430,6 +418,21 @@ module.exports = function getSpec ({ warn, error }) {
430
418
  name: rPrefix + rEventName + meta.modifierStr,
431
419
  value
432
420
  }
421
+ },
422
+ harmony ({ name, value }, { eventRules, el }) {
423
+ const match = this.test.exec(name)
424
+ const prefix = match[1]
425
+ const eventName = match[2]
426
+ const modifierStr = match[3] || ''
427
+ const meta = {
428
+ modifierStr
429
+ }
430
+ const rPrefix = runRules(spec.event.prefix, prefix, { mode: 'harmony' })
431
+ const rEventName = runRules(eventRules, eventName, { mode: 'harmony', data: { el } })
432
+ return {
433
+ name: rPrefix + rEventName + meta.modifierStr,
434
+ value
435
+ }
433
436
  }
434
437
  },
435
438
  // 无障碍
@@ -565,6 +568,22 @@ module.exports = function getSpec ({ warn, error }) {
565
568
  } else {
566
569
  error(`React native environment does not support [${eventName}] event!`)
567
570
  }
571
+ },
572
+ harmony (eventName) {
573
+ const eventMap = {
574
+ tap: 'tap',
575
+ longtap: 'longpress',
576
+ longpress: 'longpress',
577
+ touchstart: 'touchstart',
578
+ touchmove: 'touchmove',
579
+ touchend: 'touchend',
580
+ touchcancel: 'touchcancel'
581
+ }
582
+ if (eventMap[eventName]) {
583
+ return eventMap[eventName]
584
+ } else {
585
+ error(`React native environment does not support [${eventName}] event!`)
586
+ }
568
587
  }
569
588
  },
570
589
  // web event escape
@@ -85,7 +85,6 @@ module.exports = function ({
85
85
  srcMode,
86
86
  moduleId,
87
87
  isProduction,
88
- componentGenerics,
89
88
  jsonConfig: jsonRes.jsonObj,
90
89
  outputPath: queryObj.outputPath || '',
91
90
  builtInComponentsMap: templateRes.builtInComponentsMap,
@@ -12,6 +12,7 @@ const createJSONHelper = require('../json-compiler/helper')
12
12
  const getRulesRunner = require('../platform/index')
13
13
  const { RESOLVE_IGNORED_ERR } = require('../utils/const')
14
14
  const RecordResourceMapDependency = require('../dependencies/RecordResourceMapDependency')
15
+ const RecordPageConfigsMapDependency = require('../dependencies/RecordPageConfigsMapDependency')
15
16
 
16
17
  module.exports = function (jsonContent, {
17
18
  loaderContext,
@@ -79,7 +80,6 @@ module.exports = function (jsonContent, {
79
80
  })
80
81
  }
81
82
 
82
- const isApp = ctorType === 'app'
83
83
  if (!jsonContent) {
84
84
  return callback()
85
85
  }
@@ -99,7 +99,7 @@ module.exports = function (jsonContent, {
99
99
  }
100
100
  }
101
101
 
102
- if (!isApp) {
102
+ if (ctorType !== 'app') {
103
103
  rulesRunnerOptions.mainKey = ctorType
104
104
  }
105
105
 
@@ -112,6 +112,17 @@ module.exports = function (jsonContent, {
112
112
  return callback(e)
113
113
  }
114
114
 
115
+ if (ctorType === 'page') {
116
+ const keysToExtract = ['navigationStyle']
117
+ const configObj = {}
118
+ keysToExtract.forEach(key => {
119
+ if (jsonObj[key]) {
120
+ configObj[key] = jsonObj[key]
121
+ }
122
+ })
123
+ loaderContext._module.addPresentationalDependency(new RecordPageConfigsMapDependency(parseRequest(loaderContext.resource).resourcePath, configObj))
124
+ }
125
+
115
126
  const fs = loaderContext._compiler.inputFileSystem
116
127
 
117
128
  const defaultTabbar = {
@@ -12,7 +12,9 @@ module.exports = function (script, {
12
12
  outputPath,
13
13
  builtInComponentsMap,
14
14
  localComponentsMap,
15
- localPagesMap
15
+ localPagesMap,
16
+ componentGenerics,
17
+ genericsInfo
16
18
  }, callback) {
17
19
  let scriptSrcMode = srcMode
18
20
  const mode = loaderContext.getMpx().mode
@@ -27,7 +29,7 @@ module.exports = function (script, {
27
29
  output += `
28
30
  import { getComponent } from ${stringifyRequest(loaderContext, optionProcessorPath)}
29
31
  import { NavigationContainer, StackActions } from '@react-navigation/native'
30
- ${mode === 'ios' ? "import { createNativeStackNavigator as createStackNavigator } from '@react-navigation/native-stack'" : "import { createStackNavigator } from '@react-navigation/stack'"}
32
+ ${mode === 'ios' || mode === 'harmony' ? "import { createNativeStackNavigator as createStackNavigator } from '@react-navigation/native-stack'" : "import { createStackNavigator } from '@react-navigation/stack'"}
31
33
  import PortalHost from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/mpx-portal/portal-host'
32
34
  import { useHeaderHeight } from '@react-navigation/elements';
33
35
  import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context'
@@ -68,7 +70,7 @@ global.__navigationHelper = {
68
70
  jsonConfig
69
71
  })
70
72
 
71
- output += buildGlobalParams({ moduleId, scriptSrcMode, loaderContext, isProduction, ctorType, jsonConfig, componentsMap, outputPath })
73
+ output += buildGlobalParams({ moduleId, scriptSrcMode, loaderContext, isProduction, ctorType, jsonConfig, componentsMap, outputPath, genericsInfo, componentGenerics })
72
74
  output += getRequireScript({ ctorType, script, loaderContext })
73
75
  output += `export default global.__mpxOptionsMap[${JSON.stringify(moduleId)}]\n`
74
76
  }
@@ -5,6 +5,8 @@ const loaderUtils = require('loader-utils')
5
5
  const templateCompiler = require('../template-compiler/compiler')
6
6
  const genNode = require('../template-compiler/gen-node-react')
7
7
  const bindThis = require('../template-compiler/bind-this')
8
+ const isEmptyObject = require('../utils/is-empty-object')
9
+ const dash2hump = require('../utils/hump-dash').dash2hump
8
10
 
9
11
  module.exports = function (template, {
10
12
  loaderContext,
@@ -75,16 +77,15 @@ module.exports = function (template, {
75
77
  defs,
76
78
  decodeHTMLText,
77
79
  externalClasses,
78
- // todo 后续输出web也采用mpx的scoped处理
79
80
  hasScoped: false,
80
81
  moduleId,
81
82
  filePath: rawResourcePath,
82
83
  // react中模版i18n不需要特殊处理
83
84
  i18n: null,
84
85
  checkUsingComponents,
85
- // web模式下全局组件不会被合入usingComponents中,故globalComponents可以传空
86
+ // rn模式下全局组件不会被合入usingComponents中,故globalComponents可以传空
86
87
  globalComponents: [],
87
- // web模式下实现抽象组件
88
+ // rn模式下实现抽象组件
88
89
  componentGenerics,
89
90
  hasVirtualHost: matchCondition(resourcePath, autoVirtualHostRules),
90
91
  forceProxyEvent: matchCondition(resourcePath, forceProxyEventRules),
@@ -148,6 +149,20 @@ ${e.stack}`)
148
149
  if (meta.options) {
149
150
  output += `global.currentInject.injectOptions = ${JSON.stringify(meta.options)};\n`
150
151
  }
152
+ if (!isEmptyObject(componentGenerics)) {
153
+ output += 'global.currentInject.injectProperties = {\n'
154
+ output += ' generichash: String,\n'
155
+
156
+ Object.keys(componentGenerics).forEach(genericName => {
157
+ const defaultValue = componentGenerics[genericName].default
158
+ if (defaultValue) {
159
+ output += ` generic${dash2hump(genericName)}: { type: String, value: '${genericName}default' },\n`
160
+ } else {
161
+ output += ` generic${dash2hump(genericName)}: String,\n`
162
+ }
163
+ })
164
+ output += '}\n'
165
+ }
151
166
  }
152
167
  }
153
168