@mpxjs/webpack-plugin 2.10.15-prelease.1 → 2.10.16-beta.10

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 (257) hide show
  1. package/lib/config.js +60 -0
  2. package/lib/dependencies/AppEntryDependency.js +2 -2
  3. package/lib/dependencies/RecordModuleIdMapDependency.js +49 -0
  4. package/lib/dependencies/ResolveDependency.js +1 -1
  5. package/lib/file-loader.js +13 -3
  6. package/lib/helpers.js +2 -0
  7. package/lib/index.js +40 -15
  8. package/lib/json-compiler/helper.js +72 -2
  9. package/lib/json-compiler/index.js +16 -56
  10. package/lib/json-compiler/plugin.js +2 -2
  11. package/lib/loader.js +10 -4
  12. package/lib/native-loader.js +6 -3
  13. package/lib/platform/json/wx/index.js +30 -29
  14. package/lib/platform/style/wx/index.js +8 -1
  15. package/lib/platform/template/wx/component-config/ad.js +5 -0
  16. package/lib/platform/template/wx/component-config/button.js +21 -5
  17. package/lib/platform/template/wx/component-config/camera.js +25 -3
  18. package/lib/platform/template/wx/component-config/canvas.js +8 -1
  19. package/lib/platform/template/wx/component-config/component.js +31 -33
  20. package/lib/platform/template/wx/component-config/cover-image.js +7 -2
  21. package/lib/platform/template/wx/component-config/cover-view.js +3 -1
  22. package/lib/platform/template/wx/component-config/fix-component-name.js +2 -2
  23. package/lib/platform/template/wx/component-config/form.js +27 -2
  24. package/lib/platform/template/wx/component-config/image.js +5 -0
  25. package/lib/platform/template/wx/component-config/input.js +10 -0
  26. package/lib/platform/template/wx/component-config/label.js +10 -2
  27. package/lib/platform/template/wx/component-config/map.js +11 -0
  28. package/lib/platform/template/wx/component-config/movable-area.js +4 -1
  29. package/lib/platform/template/wx/component-config/movable-view.js +17 -2
  30. package/lib/platform/template/wx/component-config/navigator.js +26 -0
  31. package/lib/platform/template/wx/component-config/picker-view.js +12 -0
  32. package/lib/platform/template/wx/component-config/picker.js +3 -1
  33. package/lib/platform/template/wx/component-config/progress.js +11 -1
  34. package/lib/platform/template/wx/component-config/rich-text.js +5 -0
  35. package/lib/platform/template/wx/component-config/scroll-view.js +12 -1
  36. package/lib/platform/template/wx/component-config/slider.js +8 -0
  37. package/lib/platform/template/wx/component-config/swiper-item.js +5 -2
  38. package/lib/platform/template/wx/component-config/swiper.js +10 -0
  39. package/lib/platform/template/wx/component-config/text.js +5 -0
  40. package/lib/platform/template/wx/component-config/textarea.js +19 -2
  41. package/lib/platform/template/wx/component-config/unsupported.js +10 -1
  42. package/lib/platform/template/wx/component-config/video.js +10 -0
  43. package/lib/platform/template/wx/index.js +21 -1
  44. package/lib/react/index.js +2 -0
  45. package/lib/react/processJSON.js +39 -71
  46. package/lib/react/processStyles.js +3 -2
  47. package/lib/react/processTemplate.js +8 -6
  48. package/lib/react/script-helper.js +6 -16
  49. package/lib/react/style-helper.js +10 -2
  50. package/lib/runtime/components/react/context.ts +13 -6
  51. package/lib/runtime/components/react/dist/context.d.ts +76 -0
  52. package/lib/runtime/components/react/dist/context.d.ts.map +1 -0
  53. package/lib/runtime/components/react/dist/context.js +1 -0
  54. package/lib/runtime/components/react/dist/event.config.d.ts +8 -0
  55. package/lib/runtime/components/react/dist/event.config.d.ts.map +1 -0
  56. package/lib/runtime/components/react/dist/getInnerListeners.d.ts +8 -0
  57. package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +1 -0
  58. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +13 -0
  59. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +1 -0
  60. package/lib/runtime/components/react/dist/mpx-button.d.ts +69 -0
  61. package/lib/runtime/components/react/dist/mpx-button.d.ts.map +1 -0
  62. package/lib/runtime/components/react/dist/mpx-camera.d.ts +27 -0
  63. package/lib/runtime/components/react/dist/mpx-camera.d.ts.map +1 -0
  64. package/lib/runtime/components/react/dist/mpx-camera.jsx +197 -0
  65. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +24 -0
  66. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +1 -0
  67. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +8 -0
  68. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +1 -0
  69. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +7 -0
  70. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +1 -0
  71. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +21 -0
  72. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +1 -0
  73. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +9 -0
  74. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +1 -0
  75. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +11 -0
  76. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +1 -0
  77. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +3 -0
  78. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +1 -0
  79. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +33 -0
  80. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +1 -0
  81. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +53 -0
  82. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +1 -0
  83. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +21 -0
  84. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +1 -0
  85. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +33 -0
  86. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +1 -0
  87. package/lib/runtime/components/react/dist/mpx-form.d.ts +28 -0
  88. package/lib/runtime/components/react/dist/mpx-form.d.ts.map +1 -0
  89. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +19 -0
  90. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +1 -0
  91. package/lib/runtime/components/react/dist/mpx-image.d.ts +22 -0
  92. package/lib/runtime/components/react/dist/mpx-image.d.ts.map +1 -0
  93. package/lib/runtime/components/react/dist/mpx-image.jsx +81 -37
  94. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +8 -0
  95. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +1 -0
  96. package/lib/runtime/components/react/dist/mpx-input.d.ts +51 -0
  97. package/lib/runtime/components/react/dist/mpx-input.d.ts.map +1 -0
  98. package/lib/runtime/components/react/dist/mpx-input.jsx +37 -11
  99. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +13 -0
  100. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +1 -0
  101. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +61 -50
  102. package/lib/runtime/components/react/dist/mpx-label.d.ts +21 -0
  103. package/lib/runtime/components/react/dist/mpx-label.d.ts.map +1 -0
  104. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +21 -0
  105. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +1 -0
  106. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +66 -0
  107. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +1 -0
  108. package/lib/runtime/components/react/dist/mpx-nav.d.ts +9 -0
  109. package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +1 -0
  110. package/lib/runtime/components/react/dist/mpx-nav.jsx +132 -0
  111. package/lib/runtime/components/react/dist/mpx-navigator.d.ts +10 -0
  112. package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +1 -0
  113. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +7 -0
  114. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +1 -0
  115. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +8 -0
  116. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +1 -0
  117. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +7 -0
  118. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +1 -0
  119. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +7 -0
  120. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +1 -0
  121. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +7 -0
  122. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +1 -0
  123. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +3 -0
  124. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +1 -0
  125. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +7 -0
  126. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +1 -0
  127. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +7 -0
  128. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +1 -0
  129. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +107 -0
  130. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +1 -0
  131. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +33 -0
  132. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +1 -0
  133. package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +4 -3
  134. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +9 -0
  135. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +1 -0
  136. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +24 -0
  137. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +1 -0
  138. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +12 -18
  139. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +15 -0
  140. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +1 -0
  141. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.jsx +8 -11
  142. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +14 -0
  143. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +1 -0
  144. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +20 -0
  145. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +17 -0
  146. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +1 -0
  147. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +13 -0
  148. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +1 -0
  149. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +12 -0
  150. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +1 -0
  151. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +23 -0
  152. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +1 -0
  153. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +17 -0
  154. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +1 -0
  155. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +16 -0
  156. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +1 -0
  157. package/lib/runtime/components/react/dist/mpx-portal/index.jsx +5 -1
  158. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +30 -0
  159. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +1 -0
  160. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +10 -0
  161. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +1 -0
  162. package/lib/runtime/components/react/dist/mpx-progress.d.ts +24 -0
  163. package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +1 -0
  164. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +21 -0
  165. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +1 -0
  166. package/lib/runtime/components/react/dist/mpx-radio.d.ts +27 -0
  167. package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +1 -0
  168. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +2 -0
  169. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +1 -0
  170. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +25 -0
  171. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +1 -0
  172. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +15 -0
  173. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +1 -0
  174. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +55 -0
  175. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +1 -0
  176. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -14
  177. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +8 -0
  178. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +1 -0
  179. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +8 -0
  180. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +1 -0
  181. package/lib/runtime/components/react/dist/mpx-slider.d.ts +31 -0
  182. package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +1 -0
  183. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +18 -0
  184. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +1 -0
  185. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +16 -0
  186. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +1 -0
  187. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +19 -0
  188. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +1 -0
  189. package/lib/runtime/components/react/dist/mpx-swiper.d.ts +53 -0
  190. package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +1 -0
  191. package/lib/runtime/components/react/dist/mpx-swiper.jsx +9 -5
  192. package/lib/runtime/components/react/dist/mpx-switch.d.ts +27 -0
  193. package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +1 -0
  194. package/lib/runtime/components/react/dist/mpx-text.d.ts +23 -0
  195. package/lib/runtime/components/react/dist/mpx-text.d.ts.map +1 -0
  196. package/lib/runtime/components/react/dist/mpx-text.jsx +33 -5
  197. package/lib/runtime/components/react/dist/mpx-textarea.d.ts +8 -0
  198. package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +1 -0
  199. package/lib/runtime/components/react/dist/mpx-video.d.ts +102 -0
  200. package/lib/runtime/components/react/dist/mpx-video.d.ts.map +1 -0
  201. package/lib/runtime/components/react/dist/mpx-view.d.ts +35 -0
  202. package/lib/runtime/components/react/dist/mpx-view.d.ts.map +1 -0
  203. package/lib/runtime/components/react/dist/mpx-view.jsx +1 -1
  204. package/lib/runtime/components/react/dist/mpx-web-view.d.ts +23 -0
  205. package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +1 -0
  206. package/lib/runtime/components/react/dist/mpx-web-view.jsx +1 -1
  207. package/lib/runtime/components/react/dist/parser.d.ts +40 -0
  208. package/lib/runtime/components/react/dist/parser.d.ts.map +1 -0
  209. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +33 -0
  210. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts.map +1 -0
  211. package/lib/runtime/components/react/dist/useNodesRef.d.ts +12 -0
  212. package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +1 -0
  213. package/lib/runtime/components/react/dist/utils.d.ts +123 -0
  214. package/lib/runtime/components/react/dist/utils.d.ts.map +1 -0
  215. package/lib/runtime/components/react/dist/utils.jsx +16 -6
  216. package/lib/runtime/components/react/mpx-camera.tsx +275 -0
  217. package/lib/runtime/components/react/mpx-image.tsx +89 -42
  218. package/lib/runtime/components/react/mpx-input.tsx +44 -17
  219. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +69 -49
  220. package/lib/runtime/components/react/mpx-nav.tsx +155 -0
  221. package/lib/runtime/components/react/mpx-picker-view/index.tsx +5 -2
  222. package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +26 -21
  223. package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItem.tsx +8 -12
  224. package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItemLite.tsx +55 -0
  225. package/lib/runtime/components/react/mpx-portal/index.tsx +8 -2
  226. package/lib/runtime/components/react/mpx-scroll-view.tsx +6 -17
  227. package/lib/runtime/components/react/mpx-swiper.tsx +9 -5
  228. package/lib/runtime/components/react/mpx-text.tsx +38 -5
  229. package/lib/runtime/components/react/mpx-view.tsx +1 -1
  230. package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
  231. package/lib/runtime/components/react/types/common.d.ts +19 -0
  232. package/lib/runtime/components/react/utils.tsx +15 -6
  233. package/lib/runtime/components/web/mpx-input.vue +0 -14
  234. package/lib/runtime/stringify.wxs +2 -2
  235. package/lib/script-setup-compiler/index.js +2 -2
  236. package/lib/style-compiler/index.js +3 -2
  237. package/lib/style-compiler/load-postcss-config.js +1 -1
  238. package/lib/style-compiler/plugins/trans-special.js +10 -2
  239. package/lib/style-compiler/strip-conditional-loader.js +178 -15
  240. package/lib/template-compiler/bind-this.js +2 -2
  241. package/lib/template-compiler/compiler.js +267 -71
  242. package/lib/template-compiler/gen-node-react.js +18 -6
  243. package/lib/template-compiler/index.js +12 -10
  244. package/lib/template-compiler/parse-exps.js +1 -1
  245. package/lib/utils/const.js +2 -1
  246. package/lib/utils/dom-tag-config.js +6 -6
  247. package/lib/utils/env.js +6 -1
  248. package/lib/utils/get-build-tag-component.js +35 -0
  249. package/lib/utils/pre-process-json.js +5 -0
  250. package/lib/web/index.js +2 -0
  251. package/lib/web/processJSON.js +44 -16
  252. package/lib/web/processScript.js +1 -1
  253. package/lib/web/processTemplate.js +6 -4
  254. package/lib/web/script-helper.js +19 -9
  255. package/lib/wxs/pre-loader.js +1 -1
  256. package/lib/wxss/loader.js +1 -9
  257. package/package.json +15 -4
@@ -159,9 +159,6 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
159
159
  const simultaneousHandlers = flatGesture(originSimultaneousHandlers)
160
160
  const waitForHandlers = flatGesture(waitFor)
161
161
 
162
- const snapScrollTop = useRef(0)
163
- const snapScrollLeft = useRef(0)
164
-
165
162
  const [refreshing, setRefreshing] = useState(false)
166
163
 
167
164
  const [enableScroll, setEnableScroll] = useState(true)
@@ -268,16 +265,12 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
268
265
  warn('scroll-x and scroll-y cannot be set to true at the same time, Mpx will use the value of scroll-y as the criterion')
269
266
  }
270
267
  useEffect(() => {
271
- if (
272
- snapScrollTop.current !== scrollTop || snapScrollLeft.current !== scrollLeft
273
- ) {
274
- initialTimeout.current = setTimeout(() => {
275
- scrollToOffset(scrollLeft, scrollTop)
276
- }, 0)
277
-
278
- return () => {
279
- initialTimeout.current && clearTimeout(initialTimeout.current)
280
- }
268
+ initialTimeout.current = setTimeout(() => {
269
+ scrollToOffset(scrollLeft, scrollTop)
270
+ }, 0)
271
+
272
+ return () => {
273
+ initialTimeout.current && clearTimeout(initialTimeout.current)
281
274
  }
282
275
  }, [scrollTop, scrollLeft])
283
276
 
@@ -481,10 +474,6 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
481
474
  function scrollToOffset (x = 0, y = 0, animated = scrollWithAnimation) {
482
475
  if (scrollViewRef.current) {
483
476
  scrollViewRef.current.scrollTo({ x, y, animated })
484
- scrollOptions.current.scrollLeft = x
485
- scrollOptions.current.scrollTop = y
486
- snapScrollLeft.current = x
487
- snapScrollTop.current = y
488
477
  }
489
478
  }
490
479
 
@@ -148,7 +148,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
148
148
  autoplay = false,
149
149
  circular = false,
150
150
  disableGesture = false,
151
- current: propCurrent = 0,
151
+ current: propCurrent,
152
152
  bindchange
153
153
  } = props
154
154
  const easeingFunc = props['easing-function'] || 'default'
@@ -199,10 +199,10 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
199
199
  // 每个元素的宽度 or 高度,有固定值直接初始化无则0
200
200
  const step = useSharedValue(initStep)
201
201
  // 记录选中元素的索引值
202
- const currentIndex = useSharedValue(propCurrent)
202
+ const currentIndex = useSharedValue(propCurrent || 0)
203
203
  // const initOffset = getOffset(props.current || 0, initStep)
204
204
  // 记录元素的偏移量
205
- const offset = useSharedValue(getOffset(propCurrent, initStep))
205
+ const offset = useSharedValue(getOffset(propCurrent || 0, initStep))
206
206
  const strAbso = 'absolute' + dir.toUpperCase() as StrAbsoType
207
207
  const strVelocity = 'velocity' + dir.toUpperCase() as StrVelocityType
208
208
  // 标识手指触摸和抬起, 起点在onBegin
@@ -271,7 +271,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
271
271
  const iStep = dir === 'x' ? realWidth : realHeight
272
272
  if (iStep !== step.value) {
273
273
  step.value = iStep
274
- updateCurrent(propCurrent, iStep)
274
+ updateCurrent(propCurrent || 0, iStep)
275
275
  updateAutoplay()
276
276
  }
277
277
  }
@@ -520,7 +520,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
520
520
  // 1. 如果用户在touch的过程中, 外部更新了current以外部为准(小程序表现)
521
521
  // 2. 手指滑动过程中更新索引,外部会把current再传入进来,导致offset直接更新,增加判断不同才更新
522
522
  if (propCurrent !== currentIndex.value) {
523
- updateCurrent(propCurrent, step.value)
523
+ updateCurrent(propCurrent || 0, step.value)
524
524
  }
525
525
  }, [propCurrent])
526
526
 
@@ -790,6 +790,10 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
790
790
  }
791
791
  preAbsolutePos.value = e[strAbso]
792
792
  })
793
+ .onEnd((e) => {
794
+ // 修复部分安卓机型下onFinalize拿到的absolute值 和 onUpdate不一致的情况,通过onEnd进行修正为最终的位置
795
+ preAbsolutePos.value = e[strAbso]
796
+ })
793
797
  .onFinalize((e: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => {
794
798
  'worklet'
795
799
  if (touchfinish.value) return
@@ -2,15 +2,41 @@
2
2
  /**
3
3
  * ✔ selectable
4
4
  * ✘ space
5
- * decode
5
+ * decode
6
6
  */
7
7
  import { Text, TextStyle, TextProps } from 'react-native'
8
- import { useRef, forwardRef, ReactNode, JSX, createElement } from 'react'
8
+ import { useRef, forwardRef, ReactNode, JSX, createElement, Children } from 'react'
9
9
  import Portal from './mpx-portal'
10
10
  import useInnerProps from './getInnerListeners'
11
11
  import useNodesRef, { HandlerRef } from './useNodesRef' // 引入辅助函数
12
12
  import { useTransformStyle, wrapChildren, extendObject } from './utils'
13
13
 
14
+ const decodeMap = {
15
+ '&lt;': '<',
16
+ '&gt;': '>',
17
+ '&quot;': '"',
18
+ '&amp;': '&',
19
+ '&#39;': '\'',
20
+ '&nbsp;': ' '
21
+ }
22
+
23
+ const encodedRe = /&(?:lt|gt|quot|amp|#39|nbsp);/g
24
+ function decode (value: string) {
25
+ if (value != null) {
26
+ return value.replace(encodedRe, function (match) {
27
+ return decodeMap[match as keyof typeof decodeMap]
28
+ })
29
+ }
30
+ }
31
+
32
+ function getDecodedChildren (children: ReactNode) {
33
+ return Children.map(children, (child) => {
34
+ if (typeof child === 'string') {
35
+ return decode(child)
36
+ }
37
+ return child
38
+ })
39
+ }
14
40
  interface _TextProps extends TextProps {
15
41
  style?: TextStyle
16
42
  children?: ReactNode
@@ -21,6 +47,7 @@ interface _TextProps extends TextProps {
21
47
  'parent-font-size'?: number
22
48
  'parent-width'?: number
23
49
  'parent-height'?: number
50
+ decode?: boolean
24
51
  }
25
52
 
26
53
  const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref): JSX.Element => {
@@ -33,7 +60,8 @@ const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref):
33
60
  'user-select': userSelect,
34
61
  'parent-font-size': parentFontSize,
35
62
  'parent-width': parentWidth,
36
- 'parent-height': parentHeight
63
+ 'parent-height': parentHeight,
64
+ decode
37
65
  } = props
38
66
 
39
67
  const {
@@ -66,12 +94,17 @@ const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref):
66
94
  }
67
95
  ),
68
96
  [
69
- 'user-select'
97
+ 'user-select',
98
+ 'decode'
70
99
  ]
71
100
  )
72
101
 
102
+ const children = decode ? getDecodedChildren(props.children) : props.children
103
+
73
104
  let finalComponent:JSX.Element = createElement(Text, innerProps, wrapChildren(
74
- props,
105
+ extendObject({}, props, {
106
+ children
107
+ }),
75
108
  {
76
109
  hasVarDec,
77
110
  varContext: varContextRef.current
@@ -501,7 +501,7 @@ function parseBgImage (text: string): {
501
501
  type?: 'image' | 'linear'
502
502
  src?: string
503
503
  } {
504
- if (!text) return {}
504
+ if (!text || text === 'none') return {}
505
505
 
506
506
  const src = parseUrl(text)
507
507
  if (src) return { src, type: 'image' }
@@ -226,7 +226,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
226
226
  }
227
227
  break
228
228
  case 'postMessage':
229
- bindmessage && bindmessage(getCustomEvent('messsage', {}, { // RN组件销毁顺序与小程序不一致,所以改成和支付宝消息一致
229
+ bindmessage && bindmessage(getCustomEvent('message', {}, { // RN组件销毁顺序与小程序不一致,所以改成和支付宝消息一致
230
230
  detail: {
231
231
  data: params[0]?.data
232
232
  }
@@ -18,3 +18,22 @@ export type ExtendedFunctionComponent = FunctionComponent & {
18
18
  }
19
19
 
20
20
  export type AnyFunc = (...args: ReadonlyArray<any>) => any
21
+
22
+ declare global {
23
+ interface PageConfig {
24
+ /**
25
+ * 是否自定义导航栏
26
+ */
27
+ navigationStyle?: 'custom'
28
+ /**
29
+ * 标题栏样式
30
+ */
31
+ navigationBarTextStyle?: 'white' | 'black' | '#ffffff' | '#000000'
32
+ /**
33
+ * 页面标题
34
+ */
35
+ navigationBarTitleText?: string
36
+
37
+ [key: string]: any
38
+ }
39
+ }
@@ -215,24 +215,33 @@ function resolveVar (input: string, varContext: Record<string, any>) {
215
215
  const parsed = parseFunc(input, 'var')
216
216
  const replaced = new ReplaceSource(input)
217
217
 
218
- parsed.forEach(({ start, end, args }) => {
218
+ for (const { start, end, args } of parsed) {
219
219
  const varName = args[0]
220
- const fallback = args[1] || ''
220
+ const fallback = args[1]
221
221
  let varValue = hasOwn(varContext, varName) ? varContext[varName] : fallback
222
+ if (varValue === undefined) return
222
223
  if (varUseRegExp.test(varValue)) {
223
- varValue = '' + resolveVar(varValue, varContext)
224
+ varValue = resolveVar(varValue, varContext)
225
+ if (varValue === undefined) return
224
226
  } else {
225
- varValue = '' + global.__formatValue(varValue)
227
+ varValue = global.__formatValue(varValue)
226
228
  }
227
229
  replaced.replace(start, end - 1, varValue)
228
- })
230
+ }
231
+
229
232
  return global.__formatValue(replaced.source())
230
233
  }
231
234
 
232
235
  function transformVar (styleObj: Record<string, any>, varKeyPaths: Array<Array<string>>, varContext: Record<string, any>, visitOther: (arg: VisitorArg) => void) {
233
236
  varKeyPaths.forEach((varKeyPath) => {
234
237
  setStyle(styleObj, varKeyPath, ({ target, key, value }) => {
235
- target[key] = resolveVar(value, varContext)
238
+ const resolved = resolveVar(value, varContext)
239
+ if (resolved === undefined) {
240
+ delete target[key]
241
+ error(`Can not resolve css var at ${varKeyPath.join('.')}:${value}.`)
242
+ return
243
+ }
244
+ target[key] = resolved
236
245
  visitOther({ target, key, value: target[key], keyPath: varKeyPath })
237
246
  })
238
247
  })
@@ -57,20 +57,6 @@
57
57
  },
58
58
  immediate: true
59
59
  },
60
- focus: {
61
- handler (val) {
62
- if (val) {
63
- this.$nextTick(() => {
64
- this.$refs.input.focus()
65
- })
66
- } else {
67
- this.$nextTick(() => {
68
- this.$refs.input.blur()
69
- })
70
- }
71
- },
72
- immediate: true
73
- }
74
60
  },
75
61
  render (createElement) {
76
62
  const mergeBefore = {
@@ -45,7 +45,7 @@ function objectKeys (obj) {
45
45
  }
46
46
 
47
47
  function genRegExp (str, flags) {
48
- if (!__mpx_wxs__) {
48
+ if (!__mpx_wxs__ || __mpx_mode__ === 'ks') {
49
49
  return new RegExp(str, flags)
50
50
  } else {
51
51
  return getRegExp(str, flags)
@@ -234,4 +234,4 @@ module.exports = {
234
234
  var parsedStaticStyle = typeof staticStyle === 'string' ? parseStyleText(staticStyle) : {}
235
235
  return genStyleText(extend(parsedStaticStyle, normalizedDynamicStyle))
236
236
  }
237
- }
237
+ }
@@ -98,7 +98,7 @@ function compileScriptSetup (
98
98
  ) {
99
99
  if (node) {
100
100
  throw new Error(
101
- `[@mpxjs/webpack-plugin script-setup-compiler] ${msg}\n\n${filePath}\n${formatCodeFrame(
101
+ `[Mpx script error]: ${msg}\n\n${filePath}\n${formatCodeFrame(
102
102
  content,
103
103
  node.start + startOffset,
104
104
  end
@@ -106,7 +106,7 @@ function compileScriptSetup (
106
106
  )
107
107
  } else {
108
108
  throw new Error(
109
- `[@mpxjs/webpack-plugin script-setup-compiler] ${msg}\n\n${filePath}\n`
109
+ `[Mpx script error]: ${msg}\n\n${filePath}\n`
110
110
  )
111
111
  }
112
112
  }
@@ -18,7 +18,8 @@ module.exports = function (css, map) {
18
18
  const { resourcePath, queryObj } = parseRequest(this.resource)
19
19
  const mpx = this.getMpx()
20
20
  const mpxStyleOptions = (queryObj.mpxStyleOptions && JSON.parse(queryObj.mpxStyleOptions)) || {}
21
- const id = queryObj.moduleId || mpxStyleOptions.mid || mpx.getModuleId(resourcePath)
21
+ const id = queryObj.moduleId || mpxStyleOptions.mid || mpx.getModuleId(resourcePath, false, (queryObj.moduleId || mpxStyleOptions.mid) ? null : this)
22
+
22
23
  const appInfo = mpx.appInfo
23
24
  const defs = mpx.defs
24
25
  const mode = mpx.mode
@@ -55,7 +56,7 @@ module.exports = function (css, map) {
55
56
  }
56
57
 
57
58
  if (isReact(mode)) {
58
- plugins.push(transSpecial({ id }))
59
+ plugins.push(transSpecial({ id, transPage: true }))
59
60
  }
60
61
 
61
62
  // plugins.push(pluginCondStrip({
@@ -29,7 +29,7 @@ module.exports = function loadPostcssConfig (loaderContext, inlineConfig = {}) {
29
29
  if (err.message.indexOf('No PostCSS Config found') >= 0) {
30
30
  return
31
31
  }
32
- loaderContext.emitWarning(`Error loading PostCSS config: ${err.message}`)
32
+ loaderContext.emitWarning(`[Mpx style warning]: Error loading PostCSS config: ${err.message}`)
33
33
  })
34
34
  }
35
35
 
@@ -1,7 +1,8 @@
1
1
  const selectorParser = require('postcss-selector-parser')
2
+ const { MPX_TAG_PAGE_SELECTOR } = require('../../utils/const')
2
3
  // trans-special
3
4
 
4
- module.exports = ({ id }) => {
5
+ module.exports = ({ id, transPage = false }) => {
5
6
  return {
6
7
  postcssPlugin: 'trans-special',
7
8
  Once: (root) => {
@@ -13,7 +14,14 @@ module.exports = ({ id }) => {
13
14
  if (/^:host$/.test(n.value)) {
14
15
  const compoundSelectors = n.nodes
15
16
  n.replaceWith(selectorParser.className({
16
- value: 'host-' + id
17
+ value: `host-${id}`
18
+ }))
19
+ selector.insertAfter(n, compoundSelectors)
20
+ }
21
+ if (transPage && /^page$/.test(n.value)) {
22
+ const compoundSelectors = n.nodes || []
23
+ n.replaceWith(selectorParser.className({
24
+ value: MPX_TAG_PAGE_SELECTOR
17
25
  }))
18
26
  selector.insertAfter(n, compoundSelectors)
19
27
  }
@@ -1,5 +1,10 @@
1
+ const fs = require('fs/promises')
2
+ const parseRequest = require('../utils/parse-request')
3
+ const atImport = require('postcss-import')
4
+ const { default: postcss } = require('postcss')
5
+
1
6
  class Node {
2
- constructor (type, condition = null) {
7
+ constructor(type, condition = null) {
3
8
  this.type = type // 'If', 'ElseIf', 'Else' 或 'Text'
4
9
  this.condition = condition // If 或 Elif 的条件
5
10
  this.children = []
@@ -8,7 +13,7 @@ class Node {
8
13
  }
9
14
 
10
15
  // 提取 css string 为 token
11
- function tokenize (cssString) {
16
+ function tokenize(cssString) {
12
17
  const regex = /\/\*\s*@mpx-(if|elif|else|endif)(?:\s*\((.*?)\))?\s*\*\//g
13
18
  const tokens = []
14
19
  let lastIndex = 0
@@ -37,12 +42,12 @@ function tokenize (cssString) {
37
42
  }
38
43
 
39
44
  // parse:将生成的 token 数组构造成嵌套的 AST
40
- function parse (cssString) {
45
+ function parse(cssString) {
41
46
  const tokens = tokenize(cssString)
42
47
  const ast = []
43
48
  const nodeStack = []
44
49
  let currentChildren = ast
45
- tokens.forEach(token => {
50
+ tokens.forEach((token) => {
46
51
  if (token.type === 'text') {
47
52
  const node = new Node('Text')
48
53
  node.value = token.content
@@ -54,7 +59,7 @@ function parse (cssString) {
54
59
  currentChildren = node.children
55
60
  } else if (token.type === 'elif') {
56
61
  if (nodeStack.length === 0) {
57
- throw new Error('elif without a preceding if')
62
+ throw new Error('[Mpx style error]: elif without a preceding if')
58
63
  }
59
64
  currentChildren = nodeStack[nodeStack.length - 1]
60
65
  const node = new Node('ElseIf', token.condition)
@@ -62,7 +67,7 @@ function parse (cssString) {
62
67
  currentChildren = node.children
63
68
  } else if (token.type === 'else') {
64
69
  if (nodeStack.length === 0) {
65
- throw new Error('else without a preceding if')
70
+ throw new Error('[Mpx style error]: else without a preceding if')
66
71
  }
67
72
  currentChildren = nodeStack[nodeStack.length - 1]
68
73
  const node = new Node('Else')
@@ -77,23 +82,23 @@ function parse (cssString) {
77
82
  return ast
78
83
  }
79
84
 
80
- function evaluateCondition (condition, defs) {
85
+ function evaluateCondition(condition, defs) {
81
86
  try {
82
87
  const keys = Object.keys(defs)
83
- const values = keys.map(key => defs[key])
88
+ const values = keys.map((key) => defs[key])
84
89
  /* eslint-disable no-new-func */
85
90
  const func = new Function(...keys, `return (${condition});`)
86
91
  return func(...values)
87
92
  } catch (e) {
88
- console.error(`Error evaluating condition: ${condition}`, e)
93
+ console.error(`[Mpx style error]:Error evaluating condition: ${condition}`, e)
89
94
  return false
90
95
  }
91
96
  }
92
97
 
93
- function traverseAndEvaluate (ast, defs) {
98
+ function traverseAndEvaluate(ast, defs) {
94
99
  let output = ''
95
100
  let batchedIf = false
96
- function traverse (nodes) {
101
+ function traverse(nodes) {
97
102
  for (const node of nodes) {
98
103
  if (node.type === 'Text') {
99
104
  output += node.value
@@ -118,10 +123,168 @@ function traverseAndEvaluate (ast, defs) {
118
123
  return output
119
124
  }
120
125
 
121
- module.exports = function (css) {
126
+ /**
127
+ *
128
+ * @param {string} content
129
+ * @param {Record<string, any>} defs
130
+ * @returns
131
+ */
132
+ function stripCondition(content, defs) {
133
+ const ast = parse(content)
134
+ const result = traverseAndEvaluate(ast, defs)
135
+ return result
136
+ }
137
+
138
+ /**
139
+ * @typedef {Object} StripByPostcssOption
140
+ * @property {string} lang 样式语法格式
141
+ * @property {string} resourcePath 文件路径
142
+ * @property {string} css 源文件
143
+ * @property {Record<string, any>} defs 条件定义
144
+ * @property {import('webpack').LoaderContext<any>['resolve']} resolve webpack resolve 方法
145
+ */
146
+
147
+ /**
148
+ * @typedef {Object} AtImportConfig
149
+ * @property {string} from 当前文件路径
150
+ * @property {(filename: string) => Promise<string> | string;} load 加载文件内容的函数
151
+ * @property {(id: string, base: string) => Promise<string | null> | string | null;} resolve 解析文件路径的函数
152
+ */
153
+
154
+ /**
155
+ *
156
+ * @param {Function} callback
157
+ * @param {string} name
158
+ * @returns
159
+ */
160
+ const shouldInstallWarning = (callback, name) => {
161
+ return () => {
162
+ try {
163
+ return callback()
164
+ } catch (error) {
165
+ throw new Error(
166
+ `[mpx-strip-conditional-loader]: ${name} is not installed, please install it first.\norginal Error: ${
167
+ error?.message ?? error.toString()
168
+ }`,
169
+ {
170
+ cause: error
171
+ }
172
+ )
173
+ }
174
+ }
175
+ }
176
+ /**
177
+ *
178
+ * @typedef {import('postcss').ProcessOptions} ProcessOptions
179
+ * @typedef {import('postcss').Root} Root
180
+ *
181
+ * @type {Record<string, ProcessOptions['syntax']>}
182
+ */
183
+ const styleSyntaxProcesserMap = {
184
+ stylus: shouldInstallWarning(() => require('postcss-styl'), 'postcss-styl'),
185
+ less: shouldInstallWarning(() => require('postcss-less'), 'postcss-less'),
186
+ scss: shouldInstallWarning(() => require('postcss-scss'), 'postcss-scss')
187
+ }
188
+
189
+ /**
190
+ * @param {StripByPostcssOption} options
191
+ */
192
+ async function stripByPostcss(options) {
193
+ const syntax = styleSyntaxProcesserMap[options.lang]?.()
194
+ const defs = options.defs ?? {}
195
+
196
+ function stripContentCondition(content) {
197
+ content = stripCondition(content, defs)
198
+
199
+ if (options.lang === 'stylus') {
200
+ content = content.replace(/\t/g, ' ')
201
+ }
202
+
203
+ return content
204
+ }
205
+
206
+ const afterConditionStrip = stripContentCondition(options.css, defs)
207
+
208
+ /**
209
+ * @type {import('postcss').AcceptedPlugin[]}
210
+ */
211
+ const plugins = [
212
+ atImport({
213
+ async load(filename) {
214
+ let content = await fs.readFile(filename, 'utf-8')
215
+ const processer = postcss(plugins)
216
+
217
+ content = stripContentCondition(content, defs)
218
+
219
+ const { css } = await processer.process(content, {
220
+ syntax,
221
+ from: filename,
222
+ to: options.resourcePath
223
+ })
224
+ return css
225
+ },
226
+ resolve: (id, base) => {
227
+ return new Promise((resolve, reject) => {
228
+ options.resolve(base, id, (err, res) => {
229
+ if (err) return reject(err)
230
+ if (typeof res !== 'string') {
231
+ return reject(
232
+ new Error(
233
+ `[mpx-strip-conditional-loader]: Cannot resolve ${id} from ${base}`
234
+ )
235
+ )
236
+ }
237
+ resolve(res)
238
+ })
239
+ })
240
+ }
241
+ }),
242
+ {
243
+ // less/scss syntax 在 postcss 重新生成 css 后,`//` 注释后面不会保留换行,会和后续的 css 语句和注释连在一起,导致后续语法错误
244
+ postcssPlugin: 'mpx-strip-conditional-loader-append-command',
245
+ CommentExit(comment) {
246
+ if (!comment.raws.right) {
247
+ comment.raws.right = '\n'
248
+ return
249
+ }
250
+
251
+ if (!comment.raws.right.startsWith('\n')) {
252
+ comment.raws.right = '\n' + comment.raws.right
253
+ }
254
+ }
255
+ }
256
+ ]
257
+
258
+ const processer = postcss(plugins)
259
+ return processer.process(afterConditionStrip, {
260
+ from: options.resourcePath,
261
+ syntax
262
+ })
263
+ }
264
+
265
+ /**
266
+ *
267
+ * @this {import('webpack').LoaderContext<any>}
268
+ * @param {string} css
269
+ */
270
+ module.exports = async function (css) {
122
271
  this.cacheable()
272
+
273
+ const callback = this.async()
274
+
123
275
  const mpx = this.getMpx()
124
- const defs = mpx.defs
125
- const ast = parse(css)
126
- return traverseAndEvaluate(ast, defs)
276
+ const { resourcePath, queryObj } = parseRequest(this.resource)
277
+
278
+ const result = await stripByPostcss({
279
+ lang: queryObj.lang,
280
+ resourcePath,
281
+ css,
282
+ defs: mpx.defs,
283
+ resolve: this.resolve.bind(this)
284
+ })
285
+
286
+ callback(null, result.css, result.map)
127
287
  }
288
+
289
+ module.exports.stripByPostcss = stripByPostcss
290
+ module.exports.stripCondition = stripCondition
@@ -258,7 +258,7 @@ module.exports = {
258
258
  })
259
259
  return {
260
260
  code: pCollectKeys.map((key) => {
261
- return isSimpleKey(key) ? `_sc(${JSON.stringify(key)});` : `_c(${JSON.stringify(key)});`
261
+ return isSimpleKey(key) ? `mpx_sc(${JSON.stringify(key)});` : `mpx_c(${JSON.stringify(key)});`
262
262
  }).join('\n'),
263
263
  propKeys: [...propKeySet]
264
264
  }
@@ -436,7 +436,7 @@ module.exports = {
436
436
  exit (path) {
437
437
  if (path.collectInfo) {
438
438
  const { isSimple, key } = path.collectInfo
439
- const callee = isSimple ? t.identifier('_sc') : t.identifier('_c')
439
+ const callee = isSimple ? t.identifier('mpx_sc') : t.identifier('mpx_c')
440
440
  const replaceNode = renderReduce
441
441
  ? t.callExpression(callee, [key])
442
442
  : t.callExpression(callee, [key, path.node])