@mpxjs/webpack-plugin 2.10.17-beta.3 → 2.10.17-beta.6

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 (228) hide show
  1. package/lib/config.js +60 -0
  2. package/lib/file-loader.js +4 -1
  3. package/lib/global.d.ts +245 -0
  4. package/lib/index.js +29 -2
  5. package/lib/json-compiler/index.js +13 -4
  6. package/lib/loader.js +4 -0
  7. package/lib/platform/json/wx/index.js +6 -0
  8. package/lib/platform/style/wx/index.js +57 -33
  9. package/lib/platform/template/wx/component-config/ad.js +5 -0
  10. package/lib/platform/template/wx/component-config/button.js +10 -3
  11. package/lib/platform/template/wx/component-config/camera.js +25 -3
  12. package/lib/platform/template/wx/component-config/canvas.js +8 -1
  13. package/lib/platform/template/wx/component-config/cover-image.js +7 -2
  14. package/lib/platform/template/wx/component-config/cover-view.js +3 -1
  15. package/lib/platform/template/wx/component-config/form.js +27 -2
  16. package/lib/platform/template/wx/component-config/image.js +5 -0
  17. package/lib/platform/template/wx/component-config/input.js +11 -1
  18. package/lib/platform/template/wx/component-config/label.js +10 -2
  19. package/lib/platform/template/wx/component-config/map.js +11 -0
  20. package/lib/platform/template/wx/component-config/movable-area.js +4 -1
  21. package/lib/platform/template/wx/component-config/movable-view.js +17 -2
  22. package/lib/platform/template/wx/component-config/navigator.js +26 -0
  23. package/lib/platform/template/wx/component-config/picker-view.js +12 -0
  24. package/lib/platform/template/wx/component-config/picker.js +3 -1
  25. package/lib/platform/template/wx/component-config/progress.js +11 -1
  26. package/lib/platform/template/wx/component-config/rich-text.js +5 -0
  27. package/lib/platform/template/wx/component-config/scroll-view.js +12 -1
  28. package/lib/platform/template/wx/component-config/slider.js +8 -0
  29. package/lib/platform/template/wx/component-config/swiper-item.js +5 -2
  30. package/lib/platform/template/wx/component-config/swiper.js +10 -0
  31. package/lib/platform/template/wx/component-config/text.js +5 -0
  32. package/lib/platform/template/wx/component-config/textarea.js +20 -3
  33. package/lib/platform/template/wx/component-config/unsupported.js +10 -1
  34. package/lib/platform/template/wx/component-config/video.js +10 -0
  35. package/lib/platform/template/wx/index.js +21 -1
  36. package/lib/react/LoadAsyncChunkModule.js +1 -1
  37. package/lib/react/processStyles.js +21 -9
  38. package/lib/react/style-helper.js +76 -13
  39. package/lib/resolver/AddModePlugin.js +23 -8
  40. package/lib/runtime/components/react/animationHooks/index.ts +75 -0
  41. package/lib/runtime/components/react/animationHooks/useAnimationAPIHooks.ts +198 -0
  42. package/lib/runtime/components/react/animationHooks/useTransitionHooks.ts +297 -0
  43. package/lib/runtime/components/react/animationHooks/utils.ts +196 -0
  44. package/lib/runtime/components/react/context.ts +7 -1
  45. package/lib/runtime/components/react/dist/animationHooks/index.d.ts +15 -0
  46. package/lib/runtime/components/react/dist/animationHooks/index.js +67 -0
  47. package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.d.ts +3 -0
  48. package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.js +182 -0
  49. package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.d.ts +3 -0
  50. package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.js +274 -0
  51. package/lib/runtime/components/react/dist/animationHooks/utils.d.ts +109 -0
  52. package/lib/runtime/components/react/dist/animationHooks/utils.js +150 -0
  53. package/lib/runtime/components/react/dist/context.d.ts +6 -2
  54. package/lib/runtime/components/react/dist/event.config.d.ts +0 -1
  55. package/lib/runtime/components/react/dist/getInnerListeners.d.ts +0 -1
  56. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +0 -1
  57. package/lib/runtime/components/react/dist/mpx-button.d.ts +0 -1
  58. package/lib/runtime/components/react/dist/mpx-camera.d.ts +31 -0
  59. package/lib/runtime/components/react/dist/mpx-camera.jsx +236 -0
  60. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +0 -1
  61. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +0 -1
  62. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +0 -1
  63. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +0 -1
  64. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +0 -1
  65. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +0 -1
  66. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +0 -1
  67. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -1
  68. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +0 -1
  69. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -1
  70. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +0 -1
  71. package/lib/runtime/components/react/dist/mpx-form.d.ts +0 -1
  72. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -1
  73. package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -1
  74. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +0 -1
  75. package/lib/runtime/components/react/dist/mpx-input.d.ts +2 -1
  76. package/lib/runtime/components/react/dist/mpx-input.jsx +10 -9
  77. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +0 -1
  78. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +7 -2
  79. package/lib/runtime/components/react/dist/mpx-label.d.ts +0 -1
  80. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -1
  81. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +0 -1
  82. package/lib/runtime/components/react/dist/mpx-nav.d.ts +0 -1
  83. package/lib/runtime/components/react/dist/mpx-navigator.d.ts +0 -1
  84. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +0 -1
  85. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +0 -1
  86. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +0 -1
  87. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +0 -1
  88. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +0 -1
  89. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +0 -1
  90. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +0 -1
  91. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +0 -1
  92. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +0 -1
  93. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +0 -1
  94. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -1
  95. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +0 -1
  96. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -1
  97. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -1
  98. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +0 -1
  99. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +0 -1
  100. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +0 -1
  101. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +0 -1
  102. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +0 -1
  103. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +0 -1
  104. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +0 -1
  105. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +0 -1
  106. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +2 -2
  107. package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -1
  108. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -1
  109. package/lib/runtime/components/react/dist/mpx-radio.d.ts +0 -1
  110. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +0 -1
  111. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -1
  112. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +0 -1
  113. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +0 -1
  114. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +0 -1
  115. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +0 -1
  116. package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -1
  117. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +0 -1
  118. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +0 -1
  119. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +0 -1
  120. package/lib/runtime/components/react/dist/mpx-swiper.d.ts +11 -1
  121. package/lib/runtime/components/react/dist/mpx-swiper.jsx +71 -39
  122. package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -1
  123. package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -1
  124. package/lib/runtime/components/react/dist/mpx-textarea.d.ts +0 -1
  125. package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -1
  126. package/lib/runtime/components/react/dist/mpx-view.d.ts +3 -3
  127. package/lib/runtime/components/react/dist/mpx-view.jsx +22 -8
  128. package/lib/runtime/components/react/dist/mpx-web-view.d.ts +0 -1
  129. package/lib/runtime/components/react/dist/mpx-web-view.jsx +1 -1
  130. package/lib/runtime/components/react/dist/parser.d.ts +0 -1
  131. package/lib/runtime/components/react/dist/useNodesRef.d.ts +0 -1
  132. package/lib/runtime/components/react/dist/utils.d.ts +1 -1
  133. package/lib/runtime/components/react/dist/utils.jsx +34 -13
  134. package/lib/runtime/components/react/mpx-camera.tsx +327 -0
  135. package/lib/runtime/components/react/mpx-input.tsx +15 -9
  136. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +7 -2
  137. package/lib/runtime/components/react/mpx-portal/portal-manager.tsx +2 -2
  138. package/lib/runtime/components/react/mpx-swiper.tsx +86 -37
  139. package/lib/runtime/components/react/mpx-view.tsx +27 -12
  140. package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
  141. package/lib/runtime/components/react/tsconfig.json +26 -0
  142. package/lib/runtime/components/react/types/global.d.ts +1 -0
  143. package/lib/runtime/components/react/utils.tsx +34 -16
  144. package/lib/runtime/optionProcessor.js +5 -0
  145. package/lib/runtime/optionProcessorReact.js +7 -0
  146. package/lib/runtime/stringify.wxs +2 -2
  147. package/lib/style-compiler/strip-conditional-loader/rebaseUrl.js +225 -0
  148. package/lib/style-compiler/strip-conditional-loader.js +76 -185
  149. package/lib/template-compiler/compiler.js +1 -3
  150. package/lib/utils/dom-tag-config.js +1 -1
  151. package/lib/utils/string.js +25 -1
  152. package/package.json +6 -4
  153. package/lib/runtime/components/react/dist/context.d.ts.map +0 -1
  154. package/lib/runtime/components/react/dist/event.config.d.ts.map +0 -1
  155. package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +0 -1
  156. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +0 -1
  157. package/lib/runtime/components/react/dist/mpx-button.d.ts.map +0 -1
  158. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +0 -1
  159. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +0 -1
  160. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +0 -1
  161. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +0 -1
  162. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +0 -1
  163. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +0 -1
  164. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +0 -1
  165. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +0 -1
  166. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +0 -1
  167. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +0 -1
  168. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +0 -1
  169. package/lib/runtime/components/react/dist/mpx-form.d.ts.map +0 -1
  170. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +0 -1
  171. package/lib/runtime/components/react/dist/mpx-image.d.ts.map +0 -1
  172. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +0 -1
  173. package/lib/runtime/components/react/dist/mpx-input.d.ts.map +0 -1
  174. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +0 -1
  175. package/lib/runtime/components/react/dist/mpx-label.d.ts.map +0 -1
  176. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +0 -1
  177. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +0 -1
  178. package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +0 -1
  179. package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +0 -1
  180. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +0 -1
  181. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +0 -1
  182. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +0 -1
  183. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +0 -1
  184. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +0 -1
  185. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +0 -1
  186. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +0 -1
  187. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +0 -1
  188. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +0 -1
  189. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +0 -1
  190. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +0 -1
  191. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +0 -1
  192. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +0 -1
  193. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +0 -1
  194. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +0 -1
  195. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +0 -1
  196. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +0 -1
  197. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +0 -1
  198. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +0 -1
  199. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +0 -1
  200. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +0 -1
  201. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +0 -1
  202. package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +0 -1
  203. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +0 -1
  204. package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +0 -1
  205. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +0 -1
  206. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +0 -1
  207. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +0 -1
  208. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +0 -1
  209. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +0 -1
  210. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +0 -1
  211. package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +0 -1
  212. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +0 -1
  213. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +0 -1
  214. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +0 -1
  215. package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +0 -1
  216. package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +0 -1
  217. package/lib/runtime/components/react/dist/mpx-text.d.ts.map +0 -1
  218. package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +0 -1
  219. package/lib/runtime/components/react/dist/mpx-video.d.ts.map +0 -1
  220. package/lib/runtime/components/react/dist/mpx-view.d.ts.map +0 -1
  221. package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +0 -1
  222. package/lib/runtime/components/react/dist/parser.d.ts.map +0 -1
  223. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +0 -33
  224. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts.map +0 -1
  225. package/lib/runtime/components/react/dist/useAnimationHooks.js +0 -289
  226. package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +0 -1
  227. package/lib/runtime/components/react/dist/utils.d.ts.map +0 -1
  228. package/lib/runtime/components/react/useAnimationHooks.ts +0 -320
@@ -23,6 +23,8 @@ module.exports = function ({ print }) {
23
23
  const harmonyValueLogError = print({ platform: 'harmony', tag: TAG_NAME, isError: true, type: 'value' })
24
24
  const harmonyPropLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false })
25
25
  const harmonyEventLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false, type: 'event' })
26
+ const ksPropLog = print({ platform: 'ks', tag: TAG_NAME, isError: false })
27
+ const ksEventLog = print({ platform: 'ks', tag: TAG_NAME, isError: false, type: 'event' })
26
28
 
27
29
  return {
28
30
  test: TAG_NAME,
@@ -91,16 +93,21 @@ module.exports = function ({ print }) {
91
93
  }
92
94
  },
93
95
  {
94
- test: /^(always-embed|hold-keyboard|disable-default-padding|adjust-keyboard-to|fixed|show-confirm-bar)$/,
96
+ test: /^(always-embed|disable-default-padding|adjust-keyboard-to|fixed|show-confirm-bar)$/,
95
97
  ios: iosPropLog,
96
98
  android: androidPropLog,
97
99
  harmony: harmonyPropLog
100
+ },
101
+ {
102
+ test: /^(cursor-spacing|cursor|selection-start|selection-end|adjust-position|hold-keyboard|disable-default-padding|confirm-hold|adjust-keyboard-to|placeholder-class|show-confirm-bar)$/,
103
+ ks: ksPropLog
98
104
  }
99
105
  ],
100
106
  event: [
101
107
  {
102
108
  test: /^(confirm|linechange)$/,
103
- web: webEventLog
109
+ web: webEventLog,
110
+ ks: ksEventLog
104
111
  },
105
112
  {
106
113
  test: /^keyboardheightchange$/,
@@ -124,7 +131,17 @@ module.exports = function ({ print }) {
124
131
  test: /^keyboard.+$/,
125
132
  ios: iosEventLog,
126
133
  android: androidEventLog,
127
- harmony: harmonyEventLog
134
+ harmony: harmonyEventLog,
135
+ ks: ksEventLog
136
+ },
137
+ {
138
+ test: /^(selectionchange)$/,
139
+ ks: ksEventLog,
140
+ ali: aliEventLog,
141
+ jd: jdEventLog,
142
+ qq: qqEventLog,
143
+ tt: ttEventLog,
144
+ web: webEventLog
128
145
  }
129
146
  ]
130
147
  }
@@ -6,12 +6,14 @@ const BAIDU_UNSUPPORTED_TAG_NAME_ARR = ['functional-page-navigator', 'live-pushe
6
6
  const QQ_UNSUPPORTED_TAG_NAME_ARR = ['functional-page-navigator', 'official-account', 'editor']
7
7
  // 头条小程序不支持的标签集合
8
8
  const TT_UNSUPPORTED_TAG_NAME_ARR = ['movable-view', 'cover-image', 'cover-view', 'movable-area', 'open-data', 'official-account', 'editor', 'functional-page-navigator', 'audio', 'live-pusher']
9
+ // 快手小程序不支持的标签集合
10
+ const KS_UNSUPPORTED_TAG_NAME_ARR = ['match-media', 'page-container', 'root-portal', 'selection', 'functional-page-navigator', 'editor', 'editor-portal', 'keyboard-accessory', 'live-player', 'live-pusher', 'voip-room', 'channel-live', 'channel-video', 'ad-custom', 'official-account', 'official-account-publisher', 'open-data', 'store-coupon', 'store-gift', 'store-home', 'store-product']
9
11
  // 京东小程序不支持的标签集合
10
12
  const JD_UNSUPPORTED_TAG_NAME_ARR = ['functional-page-navigator', 'live-pusher', 'live-player', 'rich-text', 'audio', 'video', 'camera']
11
13
  // 快应用不支持的标签集合
12
14
  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
15
  // RN不支持的标签集合
14
- const RN_UNSUPPORTED_TAG_NAME_ARR = ['open-data', 'official-account', 'editor', 'functional-page-navigator', 'live-player', 'live-pusher', 'ad', 'audio', 'camera', 'match-media', 'page-container', 'editor', 'keyboard-accessory', 'map']
16
+ const RN_UNSUPPORTED_TAG_NAME_ARR = ['open-data', 'official-account', 'editor', 'functional-page-navigator', 'live-player', 'live-pusher', 'ad', 'audio', 'match-media', 'page-container', 'editor', 'keyboard-accessory', 'map']
15
17
 
16
18
  /**
17
19
  * @param {function(object): function} print
@@ -22,6 +24,7 @@ module.exports = function ({ print }) {
22
24
  const baiduUnsupportedTagError = print({ platform: 'baidu', isError: true, type: 'tag' })
23
25
  const qqUnsupportedTagError = print({ platform: 'qq', isError: true, type: 'tag' })
24
26
  const ttUnsupportedTagError = print({ platform: 'bytedance', isError: true, type: 'tag' })
27
+ const ksUnsupportedTagError = print({ platform: 'ks', isError: true, type: 'tag' })
25
28
  const jdUnsupportedTagError = print({ platform: 'jd', isError: true, type: 'tag' })
26
29
  const qaUnsupportedTagError = print({ platform: 'qa', isError: true, type: 'tag' })
27
30
  const iosUnsupportedTagError = print({ platform: 'ios', isError: true, type: 'tag' })
@@ -32,6 +35,7 @@ module.exports = function ({ print }) {
32
35
  const baiduUnsupportedExp = new RegExp('^(' + BAIDU_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
33
36
  const qqUnsupportedExp = new RegExp('^(' + QQ_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
34
37
  const ttUnsupportedExp = new RegExp('^(' + TT_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
38
+ const ksUnsupportedExp = new RegExp('^(' + KS_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
35
39
  const jdUnsupportedExp = new RegExp('^(' + JD_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
36
40
  const qaUnsupportedExp = new RegExp('^(' + QA_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
37
41
  const iosUnsupportedExp = new RegExp('^(' + RN_UNSUPPORTED_TAG_NAME_ARR.join('|') + ')$')
@@ -59,6 +63,11 @@ module.exports = function ({ print }) {
59
63
  test: ttUnsupportedExp,
60
64
  tt: ttUnsupportedTagError
61
65
  },
66
+ {
67
+ supportedModes: ['ks'],
68
+ test: ksUnsupportedExp,
69
+ ks: ksUnsupportedTagError
70
+ },
62
71
  {
63
72
  supportedModes: ['jd'],
64
73
  test: jdUnsupportedExp,
@@ -17,6 +17,8 @@ module.exports = function ({ print }) {
17
17
  const androidEventLogError = print({ platform: 'android', tag: TAG_NAME, isError: false, type: 'event' })
18
18
  const harmonyPropLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false })
19
19
  const harmonyEventLogError = print({ platform: 'harmony', tag: TAG_NAME, isError: false, type: 'event' })
20
+ const ksPropLog = print({ platform: 'ks', tag: TAG_NAME, isError: false })
21
+ const ksEventLogError = print({ platform: 'ks', tag: TAG_NAME, isError: false, type: 'event' })
20
22
  return {
21
23
  test: TAG_NAME,
22
24
  web (tag, { el }) {
@@ -74,6 +76,10 @@ module.exports = function ({ print }) {
74
76
  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)$/,
75
77
  android: androidPropLog,
76
78
  harmony: harmonyPropLog
79
+ },
80
+ {
81
+ test: /^(duration|danmu-list|enable-danmu|danmu-btn|auto-pause-if-navigate|auto-pause-if-open-native|ad-unit-id|poster-for-crawler|picture-in-picture-mode|picture-in-picture-show-progress|picture-in-picture-init-position|enable-auto-rotation|show-snapshot-button|show-background-playback-button|background-poster|is-drm|is-live|provision-url|certificate-url|license-url|preferred-peak-bit-rate)$/,
82
+ ks: ksPropLog
77
83
  }
78
84
  ],
79
85
  event: [
@@ -117,6 +123,10 @@ module.exports = function ({ print }) {
117
123
  test: /^(progress|enterpictureinpicture|leavepictureinpicture|castinguserselect|castingstatechange|castinginterrupt)$/,
118
124
  android: androidEventLogError,
119
125
  harmony: harmonyEventLogError
126
+ },
127
+ {
128
+ test: /^(waiting|controlstoggle|enterpictureinpicture|leavepictureinpicture|seekcomplete|castinguserselect)$/,
129
+ ks: ksEventLogError
120
130
  }
121
131
  ]
122
132
  }
@@ -62,7 +62,7 @@ module.exports = function getSpec ({ warn, error }) {
62
62
  }
63
63
 
64
64
  const spec = {
65
- supportedModes: ['ali', 'swan', 'qq', 'tt', 'web', 'qa', 'jd', 'dd', 'ios', 'android', 'harmony'],
65
+ supportedModes: ['ali', 'swan', 'qq', 'tt', 'ks', 'web', 'qa', 'jd', 'dd', 'ios', 'android', 'harmony'],
66
66
  // props预处理
67
67
  preProps: [],
68
68
  // props后处理
@@ -325,6 +325,13 @@ module.exports = function getSpec ({ warn, error }) {
325
325
  value
326
326
  }
327
327
  },
328
+ ks ({ name, value }) {
329
+ const dir = this.test.exec(name)[1]
330
+ return {
331
+ name: 'ks:' + dir,
332
+ value
333
+ }
334
+ },
328
335
  dd ({ name, value }) {
329
336
  const dir = this.test.exec(name)[1]
330
337
  return {
@@ -413,6 +420,19 @@ module.exports = function getSpec ({ warn, error }) {
413
420
  value
414
421
  }
415
422
  },
423
+ ks ({ name, value }, { eventRules }) {
424
+ const match = this.test.exec(name)
425
+ const prefix = match[1]
426
+ const eventName = match[2]
427
+ const modifierStr = match[3] || ''
428
+ let rPrefix = runRules(spec.event.prefix, prefix, { mode: 'ks' })
429
+ const rEventName = runRules(eventRules, eventName, { mode: 'ks' })
430
+ if (rEventName.includes('-')) rPrefix += ':'
431
+ return {
432
+ name: rPrefix + rEventName + modifierStr,
433
+ value
434
+ }
435
+ },
416
436
  dd ({ name, value }, { eventRules }) {
417
437
  const match = this.test.exec(name)
418
438
  const prefix = match[1]
@@ -54,7 +54,7 @@ class LoadAsyncChunkRuntimeModule extends HelperRuntimeModule {
54
54
  ]),
55
55
  '}',
56
56
  `var timeout = setTimeout(callback.bind(null, 'timeout'), ${this.timeout})`,
57
- 'var loadChunkAsyncFn = global.__mpx.config.rnConfig && global.__mpx.config.rnConfig.loadChunkAsync',
57
+ `var loadChunkAsyncFn = ${RuntimeGlobals.global}.__mpx.config.rnConfig && ${RuntimeGlobals.global}.__mpx.config.rnConfig.loadChunkAsync`,
58
58
  'try {',
59
59
  Template.indent([
60
60
  'loadChunkAsyncFn(config).then(callback).catch(callback)'
@@ -2,6 +2,7 @@ const createHelpers = require('../helpers')
2
2
  const async = require('async')
3
3
  const getClassMap = require('./style-helper').getClassMap
4
4
  const shallowStringify = require('../utils/shallow-stringify')
5
+ const isValidIdentifierStr = require('../utils/is-valid-identifier-str')
5
6
 
6
7
  module.exports = function (styles, {
7
8
  loaderContext,
@@ -47,6 +48,11 @@ module.exports = function (styles, {
47
48
  }, (err) => {
48
49
  if (err) return callback(err)
49
50
  try {
51
+ output += `
52
+ global.__classCaches = global.__classCaches || []
53
+ var __classCache = new Map()
54
+ global.__classCaches.push(__classCache)`
55
+ const formatValueName = '_f'
50
56
  const classMap = getClassMap({
51
57
  content,
52
58
  filename: loaderContext.resourcePath,
@@ -54,26 +60,32 @@ module.exports = function (styles, {
54
60
  srcMode,
55
61
  ctorType,
56
62
  warn,
57
- error
63
+ error,
64
+ formatValueName
58
65
  })
66
+ const classMapCode = Object.entries(classMap).reduce((result, [key, value]) => {
67
+ result !== '' && (result += ',')
68
+ result += `${isValidIdentifierStr(key) ? `${key}` : `['${key}']`}: function(${formatValueName}){return ${shallowStringify(value)};}`
69
+ return result
70
+ }, '')
59
71
  if (ctorType === 'app') {
60
72
  output += `
61
- let __appClassMap
62
- global.__getAppClassMap = function() {
73
+ var __appClassMap
74
+ global.__getAppClassStyle = function(className) {
63
75
  if(!__appClassMap) {
64
- __appClassMap = ${shallowStringify(classMap)};
76
+ __appClassMap = {${classMapCode}};
65
77
  }
66
- return __appClassMap;
78
+ return global.__GCC(className, __appClassMap, __classCache);
67
79
  };\n`
68
80
  } else {
69
81
  output += `
70
- let __classMap
82
+ var __classMap
71
83
  global.currentInject.injectMethods = {
72
- __getClassMap: function() {
84
+ __getClassStyle: function(className) {
73
85
  if(!__classMap) {
74
- __classMap = ${shallowStringify(classMap)};
86
+ __classMap = {${classMapCode}};
75
87
  }
76
- return __classMap;
88
+ return global.__GCC(className, __classMap, __classCache);
77
89
  }
78
90
  };\n`
79
91
  }
@@ -3,31 +3,70 @@ const selectorParser = require('postcss-selector-parser')
3
3
  const { MPX_TAG_PAGE_SELECTOR } = require('../utils/const')
4
4
  const getRulesRunner = require('../platform/index')
5
5
  const dash2hump = require('../utils/hump-dash').dash2hump
6
- const unitRegExp = /^\s*(-?\d+(?:\.\d+)?)(rpx|vw|vh)\s*$/
7
- const numberRegExp = /^\s*(-?\d+(\.\d+)?)(px)?\s*$/
6
+ const parseValues = require('../utils/string').parseValues
7
+ const unitRegExp = /^\s*(-?\d+(?:\.\d+)?)(rpx|vw|vh|px)?\s*$/
8
8
  const hairlineRegExp = /^\s*hairlineWidth\s*$/
9
9
  const varRegExp = /^--/
10
10
  const cssPrefixExp = /^-(webkit|moz|ms|o)-/
11
- function getClassMap ({ content, filename, mode, srcMode, ctorType, warn, error }) {
12
- const classMap = ctorType === 'page' ? { [MPX_TAG_PAGE_SELECTOR]: { flex: 1 } } : {}
11
+ function getClassMap ({ content, filename, mode, srcMode, ctorType, formatValueName, warn, error }) {
12
+ const classMap = ctorType === 'page'
13
+ ? { [MPX_TAG_PAGE_SELECTOR]: { flex: 1, height: "'100%'" } }
14
+ : {}
13
15
 
14
16
  const root = postcss.parse(content, {
15
17
  from: filename
16
18
  })
17
19
 
18
20
  function formatValue (value) {
19
- let matched
20
21
  let needStringify = true
21
- if ((matched = numberRegExp.exec(value))) {
22
- value = matched[1]
23
- needStringify = false
24
- } else if (unitRegExp.test(value) || hairlineRegExp.test(value)) {
25
- value = `global.__formatValue(${JSON.stringify(value)})`
22
+ const matched = unitRegExp.exec(value)
23
+ if (matched) {
24
+ if (!matched[2] || matched[2] === 'px') {
25
+ value = matched[1]
26
+ needStringify = false
27
+ } else {
28
+ value = `${formatValueName}(${+matched[1]}, '${matched[2]}')`
29
+ needStringify = false
30
+ }
31
+ }
32
+ if (hairlineRegExp.test(value)) {
33
+ value = `${formatValueName}(${JSON.stringify(value)}, 'hairlineWidth')`
26
34
  needStringify = false
27
35
  }
28
36
  return needStringify ? JSON.stringify(value) : value
29
37
  }
30
38
 
39
+ function getMediaOptions (params) {
40
+ return parseValues(params).reduce((option, item) => {
41
+ if (['all', 'print'].includes(item)) {
42
+ if (item === 'media') {
43
+ option.type = item
44
+ } else {
45
+ error('not supported ', item)
46
+ return option
47
+ }
48
+ }
49
+ if (['not', 'only', 'or', ','].includes(item)) {
50
+ if (item === 'and') {
51
+ option.logical_operators = item
52
+ } else {
53
+ error('not supported ', item)
54
+ return option
55
+ }
56
+ }
57
+ const bracketsExp = /\((.+?)\)/
58
+ if (bracketsExp.test(item)) {
59
+ const range = parseValues((item.match(bracketsExp)?.[1] || ''), ':')
60
+ if (range.length < 2) {
61
+ return option
62
+ } else {
63
+ option[dash2hump(range[0])] = +formatValue(range[1])
64
+ }
65
+ }
66
+ return option
67
+ }, {})
68
+ }
69
+
31
70
  const rulesRunner = getRulesRunner({
32
71
  mode,
33
72
  srcMode,
@@ -41,13 +80,15 @@ function getClassMap ({ content, filename, mode, srcMode, ctorType, warn, error
41
80
  root.walkAtRules(rule => {
42
81
  if (rule.name !== 'media') {
43
82
  warn(`Only @media rule is supported in react native mode temporarily, but got @${rule.name}`)
83
+ // 删除不支持的 AtRule,防止其影响后续解析
84
+ rule.remove()
44
85
  }
45
86
  })
46
87
 
47
88
  root.walkRules(rule => {
48
89
  const classMapValue = {}
49
90
  rule.walkDecls(({ prop, value }) => {
50
- if (cssPrefixExp.test(prop) || cssPrefixExp.test(value)) return
91
+ if (value === 'undefined' || cssPrefixExp.test(prop) || cssPrefixExp.test(value)) return
51
92
  let newData = rulesRunner({ prop, value, selector: rule.selector })
52
93
  if (!newData) return
53
94
  if (!Array.isArray(newData)) {
@@ -79,7 +120,8 @@ function getClassMap ({ content, filename, mode, srcMode, ctorType, warn, error
79
120
  })
80
121
 
81
122
  const classMapKeys = []
82
-
123
+ const options = getMediaOptions(rule.parent.params || '')
124
+ const isMedia = options.maxWidth || options.minWidth
83
125
  selectorParser(selectors => {
84
126
  selectors.each(selector => {
85
127
  if (selector.nodes.length === 1 && selector.nodes[0].type === 'class') {
@@ -93,7 +135,28 @@ function getClassMap ({ content, filename, mode, srcMode, ctorType, warn, error
93
135
  if (classMapKeys.length) {
94
136
  classMapKeys.forEach((key) => {
95
137
  if (Object.keys(classMapValue).length) {
96
- classMap[key] = Object.assign(classMap[key] || {}, classMapValue)
138
+ let _default = classMap[key]?._default
139
+ let _media = classMap[key]?._media
140
+ if (isMedia) {
141
+ // 当前是媒体查询
142
+ _default = _default || {}
143
+ _media = _media || []
144
+ _media.push({
145
+ options,
146
+ value: classMapValue
147
+ })
148
+ classMap[key] = {
149
+ _media,
150
+ _default
151
+ }
152
+ } else if (_default) {
153
+ // 已有媒体查询数据,此次非媒体查询
154
+ Object.assign(_default, classMapValue)
155
+ } else {
156
+ // 无媒体查询
157
+ const val = classMap[key] || {}
158
+ classMap[key] = Object.assign(val, classMapValue)
159
+ }
97
160
  }
98
161
  })
99
162
  }
@@ -24,6 +24,12 @@ module.exports = class AddModePlugin {
24
24
  if (request.mode || request.env) {
25
25
  return callback()
26
26
  }
27
+
28
+ const queryObj = parseQuery(request.query || '?')
29
+ if (queryObj.mode) {
30
+ return callback()
31
+ }
32
+
27
33
  const obj = {
28
34
  mode
29
35
  }
@@ -37,23 +43,32 @@ module.exports = class AddModePlugin {
37
43
  // 当前资源没有后缀名或者路径不符合fileConditionRules规则时,直接返回
38
44
  if (!extname || !matchCondition(resourcePath, fileConditionRules)) return callback()
39
45
 
40
- const queryObj = parseQuery(request.query || '?')
41
46
  const queryInfix = queryObj.infix
42
- if (!implicitMode) queryObj.mode = mode
43
- queryObj.infix = `${queryInfix || ''}.${mode}`
44
47
 
45
48
  // 如果已经确认是mode后缀的文件,添加query与mode后直接返回
46
49
  if (modePattern.test(path.basename(resourcePath))) {
47
- request.query = stringifyQuery(queryObj)
48
- request.mode = obj.mode
50
+ // 已经被resolved到对应mode的文件,避免重复添加mode
51
+ const isResolved = (implicitMode || queryObj.mode === mode) && modePattern.test(queryObj.infix)
52
+ if (!isResolved) {
53
+ queryObj.infix = `${queryInfix || ''}.${mode}`
54
+ if (!implicitMode) queryObj.mode = mode
55
+ request.query = stringifyQuery(queryObj)
56
+ request.mode = obj.mode
57
+ }
49
58
  return callback()
50
59
  } else if (defaultMode && defaultModePattern.test(path.basename(resourcePath))) {
51
- queryObj.infix = `${queryInfix || ''}.${defaultMode}`
52
- request.query = stringifyQuery(queryObj)
53
- request.mode = obj.mode
60
+ const isResolved = (implicitMode || queryObj.mode === mode) && defaultModePattern.test(queryObj.infix)
61
+ if (!isResolved) {
62
+ queryObj.infix = `${queryInfix || ''}.${defaultMode}`
63
+ if (!implicitMode) queryObj.mode = mode
64
+ request.query = stringifyQuery(queryObj)
65
+ request.mode = obj.mode
66
+ }
54
67
  return callback()
55
68
  }
56
69
 
70
+ if (!implicitMode) queryObj.mode = mode
71
+ queryObj.infix = `${queryInfix || ''}.${mode}`
57
72
  obj.query = stringifyQuery(queryObj)
58
73
  obj.path = addInfix(resourcePath, mode, extname)
59
74
  obj.relativePath = request.relativePath && addInfix(request.relativePath, mode, extname)
@@ -0,0 +1,75 @@
1
+ import { error, collectDataset, hasOwn } from '@mpxjs/utils'
2
+ import { useRef } from 'react'
3
+ import useAnimationAPIHooks from './useAnimationAPIHooks'
4
+ import useTransitionHooks from './useTransitionHooks'
5
+ import type { AnimatableValue } from 'react-native-reanimated'
6
+ import type { MutableRefObject } from 'react'
7
+ import type { NativeSyntheticEvent } from 'react-native'
8
+ import type { _ViewProps } from '../mpx-view'
9
+
10
+ // 动画类型
11
+ export type AnimationType = 'api'|'animation'|'transition'|'none'
12
+
13
+ export default function useAnimationHooks<T, P> (props: _ViewProps & { enableAnimation?: boolean | AnimationType, layoutRef: MutableRefObject<any>, transitionend?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void }) {
14
+ const { style: originalStyle = {}, enableAnimation, animation, transitionend, layoutRef } = props
15
+ // 记录动画类型
16
+ let animationType = ''
17
+ if (hasOwn(originalStyle, 'animation') || (hasOwn(originalStyle, 'animationName') && hasOwn(originalStyle, 'animationDuration'))) {
18
+ // css animation 只做检测提示
19
+ animationType = 'animation'
20
+ }
21
+ if (!!animation || enableAnimation === true) {
22
+ animationType = 'api'
23
+ }
24
+ // 优先级 css transition > API
25
+ if (hasOwn(originalStyle, 'transition') || (hasOwn(originalStyle, 'transitionProperty') && hasOwn(originalStyle, 'transitionDuration'))) {
26
+ animationType = 'transition'
27
+ }
28
+ // 优先以 enableAnimation 定义类型为准
29
+ if (enableAnimation === 'api' || enableAnimation === 'transition' || enableAnimation === 'animation') {
30
+ animationType = enableAnimation
31
+ }
32
+ const animationTypeRef = useRef(animationType)
33
+ if (animationType! && animationTypeRef.current !== animationType) {
34
+ // 允许 API、CssTransition 到 none,不允许 API、CssTransition 互切,不允许 none 到 API、CssTransition
35
+ error('[Mpx runtime error]: The animation type should be stable in the component lifecycle, or you can set animation type with [enable-animation].')
36
+ }
37
+ if (animationType === 'animation') {
38
+ // 暂不支持 CssAnimation 提示
39
+ error('[Mpx runtime error]: CSS animation is not supported yet')
40
+ return { enableStyleAnimation: false }
41
+ }
42
+ if (!animationTypeRef.current) return { enableStyleAnimation: false }
43
+
44
+ const hooksProps = { style: originalStyle }
45
+ if (transitionend && typeof transitionend === 'function') {
46
+ function withTimingCallback (finished?: boolean, current?: AnimatableValue, duration?: number) {
47
+ const target = {
48
+ id: animation?.id || -1,
49
+ dataset: collectDataset(props),
50
+ offsetLeft: layoutRef?.current?.offsetLeft || 0,
51
+ offsetTop: layoutRef?.current?.offsetTop || 0
52
+ }
53
+ transitionend!({
54
+ type: 'transitionend',
55
+ // elapsedTime 对齐wx 单位s
56
+ detail: { elapsedTime: duration ? duration / 1000 : 0, finished, current },
57
+ target,
58
+ currentTarget: target,
59
+ timeStamp: Date.now()
60
+ })
61
+ }
62
+ Object.assign(hooksProps, { transitionend: withTimingCallback })
63
+ }
64
+ if (animationTypeRef.current === 'api') {
65
+ Object.assign(hooksProps, { animation })
66
+ }
67
+ return {
68
+ enableStyleAnimation: !!animationTypeRef.current,
69
+ animationStyle: animationTypeRef.current === 'api'
70
+ // eslint-disable-next-line react-hooks/rules-of-hooks
71
+ ? useAnimationAPIHooks(hooksProps)
72
+ // eslint-disable-next-line react-hooks/rules-of-hooks
73
+ : useTransitionHooks(hooksProps)
74
+ }
75
+ }