@mpxjs/webpack-plugin 2.10.15 → 2.10.16-beta.11

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 (274) hide show
  1. package/lib/config.js +60 -0
  2. package/lib/dependencies/AppEntryDependency.js +2 -2
  3. package/lib/dependencies/DynamicEntryDependency.js +1 -1
  4. package/lib/dependencies/ImportDependency.js +102 -0
  5. package/lib/dependencies/RecordModuleIdMapDependency.js +49 -0
  6. package/lib/dependencies/ResolveDependency.js +1 -1
  7. package/lib/{retry-runtime-module.js → dependencies/RetryRuntimeModule.js} +1 -1
  8. package/lib/file-loader.js +13 -3
  9. package/lib/helpers.js +2 -0
  10. package/lib/index.js +51 -25
  11. package/lib/json-compiler/helper.js +72 -2
  12. package/lib/json-compiler/index.js +16 -56
  13. package/lib/json-compiler/plugin.js +2 -2
  14. package/lib/loader.js +10 -4
  15. package/lib/native-loader.js +6 -3
  16. package/lib/platform/json/wx/index.js +30 -29
  17. package/lib/platform/style/wx/index.js +8 -1
  18. package/lib/platform/template/wx/component-config/ad.js +5 -0
  19. package/lib/platform/template/wx/component-config/button.js +21 -5
  20. package/lib/platform/template/wx/component-config/camera.js +25 -3
  21. package/lib/platform/template/wx/component-config/canvas.js +8 -1
  22. package/lib/platform/template/wx/component-config/component.js +31 -33
  23. package/lib/platform/template/wx/component-config/cover-image.js +7 -2
  24. package/lib/platform/template/wx/component-config/cover-view.js +3 -1
  25. package/lib/platform/template/wx/component-config/fix-component-name.js +2 -2
  26. package/lib/platform/template/wx/component-config/form.js +27 -2
  27. package/lib/platform/template/wx/component-config/image.js +5 -0
  28. package/lib/platform/template/wx/component-config/input.js +10 -0
  29. package/lib/platform/template/wx/component-config/label.js +10 -2
  30. package/lib/platform/template/wx/component-config/map.js +11 -0
  31. package/lib/platform/template/wx/component-config/movable-area.js +4 -1
  32. package/lib/platform/template/wx/component-config/movable-view.js +17 -2
  33. package/lib/platform/template/wx/component-config/navigator.js +26 -0
  34. package/lib/platform/template/wx/component-config/picker-view.js +12 -0
  35. package/lib/platform/template/wx/component-config/picker.js +3 -1
  36. package/lib/platform/template/wx/component-config/progress.js +11 -1
  37. package/lib/platform/template/wx/component-config/rich-text.js +5 -0
  38. package/lib/platform/template/wx/component-config/scroll-view.js +12 -1
  39. package/lib/platform/template/wx/component-config/slider.js +20 -0
  40. package/lib/platform/template/wx/component-config/swiper-item.js +5 -2
  41. package/lib/platform/template/wx/component-config/swiper.js +10 -0
  42. package/lib/platform/template/wx/component-config/text.js +5 -0
  43. package/lib/platform/template/wx/component-config/textarea.js +19 -2
  44. package/lib/platform/template/wx/component-config/unsupported.js +10 -1
  45. package/lib/platform/template/wx/component-config/video.js +10 -0
  46. package/lib/platform/template/wx/index.js +21 -1
  47. package/lib/react/index.js +2 -0
  48. package/lib/react/processJSON.js +39 -71
  49. package/lib/react/processStyles.js +3 -2
  50. package/lib/react/processTemplate.js +8 -6
  51. package/lib/react/script-helper.js +6 -16
  52. package/lib/react/style-helper.js +10 -2
  53. package/lib/resolver/AddEnvPlugin.js +13 -0
  54. package/lib/resolver/AddModePlugin.js +18 -0
  55. package/lib/runtime/components/react/context.ts +13 -6
  56. package/lib/runtime/components/react/dist/context.d.ts +76 -0
  57. package/lib/runtime/components/react/dist/context.d.ts.map +1 -0
  58. package/lib/runtime/components/react/dist/context.js +1 -0
  59. package/lib/runtime/components/react/dist/event.config.d.ts +8 -0
  60. package/lib/runtime/components/react/dist/event.config.d.ts.map +1 -0
  61. package/lib/runtime/components/react/dist/getInnerListeners.d.ts +8 -0
  62. package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +1 -0
  63. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +13 -0
  64. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +1 -0
  65. package/lib/runtime/components/react/dist/mpx-button.d.ts +69 -0
  66. package/lib/runtime/components/react/dist/mpx-button.d.ts.map +1 -0
  67. package/lib/runtime/components/react/dist/mpx-camera.d.ts +27 -0
  68. package/lib/runtime/components/react/dist/mpx-camera.d.ts.map +1 -0
  69. package/lib/runtime/components/react/dist/mpx-camera.jsx +197 -0
  70. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +24 -0
  71. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +1 -0
  72. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +8 -0
  73. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +1 -0
  74. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +7 -0
  75. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +1 -0
  76. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +21 -0
  77. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +1 -0
  78. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +9 -0
  79. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +1 -0
  80. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +11 -0
  81. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +1 -0
  82. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +3 -0
  83. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +1 -0
  84. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +33 -0
  85. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +1 -0
  86. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +53 -0
  87. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +1 -0
  88. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +21 -0
  89. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +1 -0
  90. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +33 -0
  91. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +1 -0
  92. package/lib/runtime/components/react/dist/mpx-form.d.ts +28 -0
  93. package/lib/runtime/components/react/dist/mpx-form.d.ts.map +1 -0
  94. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +19 -0
  95. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +1 -0
  96. package/lib/runtime/components/react/dist/mpx-image.d.ts +22 -0
  97. package/lib/runtime/components/react/dist/mpx-image.d.ts.map +1 -0
  98. package/lib/runtime/components/react/dist/mpx-image.jsx +81 -37
  99. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +8 -0
  100. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +1 -0
  101. package/lib/runtime/components/react/dist/mpx-input.d.ts +51 -0
  102. package/lib/runtime/components/react/dist/mpx-input.d.ts.map +1 -0
  103. package/lib/runtime/components/react/dist/mpx-input.jsx +40 -12
  104. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +13 -0
  105. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +1 -0
  106. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +61 -50
  107. package/lib/runtime/components/react/dist/mpx-label.d.ts +21 -0
  108. package/lib/runtime/components/react/dist/mpx-label.d.ts.map +1 -0
  109. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +21 -0
  110. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +1 -0
  111. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +66 -0
  112. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +1 -0
  113. package/lib/runtime/components/react/dist/mpx-nav.d.ts +9 -0
  114. package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +1 -0
  115. package/lib/runtime/components/react/dist/mpx-nav.jsx +132 -0
  116. package/lib/runtime/components/react/dist/mpx-navigator.d.ts +10 -0
  117. package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +1 -0
  118. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +7 -0
  119. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +1 -0
  120. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +8 -0
  121. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +1 -0
  122. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +7 -0
  123. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +1 -0
  124. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +7 -0
  125. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +1 -0
  126. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +7 -0
  127. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +1 -0
  128. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +3 -0
  129. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +1 -0
  130. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +7 -0
  131. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +1 -0
  132. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +7 -0
  133. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +1 -0
  134. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +107 -0
  135. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +1 -0
  136. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +33 -0
  137. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +1 -0
  138. package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +4 -3
  139. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +9 -0
  140. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +1 -0
  141. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +24 -0
  142. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +1 -0
  143. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +12 -18
  144. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +15 -0
  145. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +1 -0
  146. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.jsx +8 -11
  147. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +14 -0
  148. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +1 -0
  149. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +20 -0
  150. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +17 -0
  151. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +1 -0
  152. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +13 -0
  153. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +1 -0
  154. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +12 -0
  155. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +1 -0
  156. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +23 -0
  157. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +1 -0
  158. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +17 -0
  159. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +1 -0
  160. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +16 -0
  161. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +1 -0
  162. package/lib/runtime/components/react/dist/mpx-portal/index.jsx +5 -1
  163. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +30 -0
  164. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +1 -0
  165. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +10 -0
  166. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +1 -0
  167. package/lib/runtime/components/react/dist/mpx-progress.d.ts +24 -0
  168. package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +1 -0
  169. package/lib/runtime/components/react/dist/mpx-progress.jsx +26 -22
  170. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +21 -0
  171. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +1 -0
  172. package/lib/runtime/components/react/dist/mpx-radio.d.ts +27 -0
  173. package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +1 -0
  174. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +2 -0
  175. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +1 -0
  176. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +25 -0
  177. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +1 -0
  178. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +15 -0
  179. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +1 -0
  180. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +55 -0
  181. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +1 -0
  182. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -14
  183. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +8 -0
  184. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +1 -0
  185. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +8 -0
  186. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +1 -0
  187. package/lib/runtime/components/react/dist/mpx-slider.d.ts +31 -0
  188. package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +1 -0
  189. package/lib/runtime/components/react/dist/mpx-slider.jsx +321 -0
  190. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +18 -0
  191. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +1 -0
  192. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +16 -0
  193. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +1 -0
  194. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +19 -0
  195. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +1 -0
  196. package/lib/runtime/components/react/dist/mpx-swiper.d.ts +53 -0
  197. package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +1 -0
  198. package/lib/runtime/components/react/dist/mpx-swiper.jsx +9 -5
  199. package/lib/runtime/components/react/dist/mpx-switch.d.ts +27 -0
  200. package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +1 -0
  201. package/lib/runtime/components/react/dist/mpx-text.d.ts +23 -0
  202. package/lib/runtime/components/react/dist/mpx-text.d.ts.map +1 -0
  203. package/lib/runtime/components/react/dist/mpx-text.jsx +33 -5
  204. package/lib/runtime/components/react/dist/mpx-textarea.d.ts +8 -0
  205. package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +1 -0
  206. package/lib/runtime/components/react/dist/mpx-video.d.ts +102 -0
  207. package/lib/runtime/components/react/dist/mpx-video.d.ts.map +1 -0
  208. package/lib/runtime/components/react/dist/mpx-view.d.ts +35 -0
  209. package/lib/runtime/components/react/dist/mpx-view.d.ts.map +1 -0
  210. package/lib/runtime/components/react/dist/mpx-view.jsx +8 -11
  211. package/lib/runtime/components/react/dist/mpx-web-view.d.ts +23 -0
  212. package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +1 -0
  213. package/lib/runtime/components/react/dist/mpx-web-view.jsx +1 -1
  214. package/lib/runtime/components/react/dist/parser.d.ts +40 -0
  215. package/lib/runtime/components/react/dist/parser.d.ts.map +1 -0
  216. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +33 -0
  217. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts.map +1 -0
  218. package/lib/runtime/components/react/dist/useNodesRef.d.ts +12 -0
  219. package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +1 -0
  220. package/lib/runtime/components/react/dist/utils.d.ts +123 -0
  221. package/lib/runtime/components/react/dist/utils.d.ts.map +1 -0
  222. package/lib/runtime/components/react/dist/utils.jsx +16 -6
  223. package/lib/runtime/components/react/mpx-camera.tsx +275 -0
  224. package/lib/runtime/components/react/mpx-image.tsx +89 -42
  225. package/lib/runtime/components/react/mpx-input.tsx +50 -18
  226. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +69 -49
  227. package/lib/runtime/components/react/mpx-nav.tsx +155 -0
  228. package/lib/runtime/components/react/mpx-picker-view/index.tsx +5 -2
  229. package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +26 -21
  230. package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItem.tsx +8 -12
  231. package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItemLite.tsx +55 -0
  232. package/lib/runtime/components/react/mpx-portal/index.tsx +8 -2
  233. package/lib/runtime/components/react/mpx-progress.tsx +26 -24
  234. package/lib/runtime/components/react/mpx-scroll-view.tsx +6 -17
  235. package/lib/runtime/components/react/mpx-slider.tsx +444 -0
  236. package/lib/runtime/components/react/mpx-swiper.tsx +9 -5
  237. package/lib/runtime/components/react/mpx-text.tsx +38 -5
  238. package/lib/runtime/components/react/mpx-view.tsx +8 -11
  239. package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
  240. package/lib/runtime/components/react/types/common.d.ts +19 -0
  241. package/lib/runtime/components/react/utils.tsx +15 -6
  242. package/lib/runtime/components/web/mpx-input.vue +1 -1
  243. package/lib/runtime/components/web/mpx-scroll-view.vue +7 -1
  244. package/lib/runtime/components/web/mpx-video.vue +12 -1
  245. package/lib/runtime/optionProcessor.js +3 -1
  246. package/lib/runtime/optionProcessorReact.js +4 -2
  247. package/lib/runtime/stringify.wxs +2 -2
  248. package/lib/script-setup-compiler/index.js +2 -2
  249. package/lib/style-compiler/index.js +3 -2
  250. package/lib/style-compiler/load-postcss-config.js +1 -1
  251. package/lib/style-compiler/plugins/trans-special.js +10 -2
  252. package/lib/style-compiler/strip-conditional-loader.js +178 -15
  253. package/lib/template-compiler/bind-this.js +2 -2
  254. package/lib/template-compiler/compiler.js +277 -77
  255. package/lib/template-compiler/gen-node-react.js +18 -6
  256. package/lib/template-compiler/index.js +12 -10
  257. package/lib/template-compiler/parse-exps.js +1 -1
  258. package/lib/utils/chain-assign.js +47 -0
  259. package/lib/utils/check-core-version-match.js +75 -15
  260. package/lib/utils/const.js +2 -1
  261. package/lib/utils/dom-tag-config.js +6 -6
  262. package/lib/utils/env.js +6 -1
  263. package/lib/utils/get-build-tag-component.js +35 -0
  264. package/lib/utils/pre-process-json.js +5 -0
  265. package/lib/web/index.js +2 -0
  266. package/lib/web/processJSON.js +44 -16
  267. package/lib/web/processScript.js +1 -1
  268. package/lib/web/processTemplate.js +6 -4
  269. package/lib/web/script-helper.js +19 -9
  270. package/lib/wxs/pre-loader.js +6 -6
  271. package/lib/wxss/loader.js +1 -9
  272. package/package.json +17 -5
  273. package/LICENSE +0 -433
  274. package/lib/dependencies/ImportDependencyTemplate.js +0 -50
@@ -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', 'slider', '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]
@@ -21,6 +21,7 @@ module.exports = function ({
21
21
  hasComment,
22
22
  isNative,
23
23
  usingComponentsInfo,
24
+ originalUsingComponents,
24
25
  componentGenerics,
25
26
  autoScope,
26
27
  callback
@@ -53,6 +54,7 @@ module.exports = function ({
53
54
  moduleId,
54
55
  ctorType,
55
56
  usingComponentsInfo,
57
+ originalUsingComponents,
56
58
  componentGenerics
57
59
  }, callback)
58
60
  },
@@ -12,11 +12,8 @@ const { transSubpackage } = require('../utils/trans-async-sub-rules')
12
12
  const createJSONHelper = require('../json-compiler/helper')
13
13
  const getRulesRunner = require('../platform/index')
14
14
  const { RESOLVE_IGNORED_ERR } = require('../utils/const')
15
- const normalize = require('../utils/normalize')
16
15
  const RecordResourceMapDependency = require('../dependencies/RecordResourceMapDependency')
17
16
  const RecordPageConfigsMapDependency = require('../dependencies/RecordPageConfigsMapDependency')
18
- const mpxViewPath = normalize.lib('runtime/components/react/dist/mpx-view.jsx')
19
- const mpxTextPath = normalize.lib('runtime/components/react/dist/mpx-text.jsx')
20
17
 
21
18
  module.exports = function (jsonContent, {
22
19
  loaderContext,
@@ -42,23 +39,38 @@ module.exports = function (jsonContent, {
42
39
 
43
40
  const emitWarning = (msg) => {
44
41
  loaderContext.emitWarning(
45
- new Error('[json processor][' + loaderContext.resource + ']: ' + msg)
42
+ new Error('[Mpx json warning][' + loaderContext.resource + ']: ' + msg)
46
43
  )
47
44
  }
48
45
 
49
46
  const emitError = (msg) => {
50
47
  loaderContext.emitError(
51
- new Error('[json compiler][' + loaderContext.resource + ']: ' + msg)
48
+ new Error('[Mpx json error][' + loaderContext.resource + ']: ' + msg)
52
49
  )
53
50
  }
54
51
 
55
52
  const stringifyRequest = r => loaderUtils.stringifyRequest(loaderContext, r)
56
53
 
54
+ function fillInComponentsMap (name, entry, tarRoot) {
55
+ const { resource, outputPath } = entry
56
+ const { resourcePath } = parseRequest(resource)
57
+ componentsMap[resourcePath] = outputPath
58
+ loaderContext._module && loaderContext._module.addPresentationalDependency(new RecordResourceMapDependency(resourcePath, 'component', outputPath))
59
+ localComponentsMap[name] = {
60
+ resource: addQuery(resource, {
61
+ isComponent: true,
62
+ outputPath
63
+ }),
64
+ async: tarRoot
65
+ }
66
+ }
67
+
57
68
  const {
58
69
  isUrlRequest,
59
70
  urlToRequest,
60
71
  processPage,
61
- processComponent
72
+ processComponent,
73
+ processPlaceholder
62
74
  } = createJSONHelper({
63
75
  loaderContext,
64
76
  emitWarning,
@@ -137,45 +149,6 @@ module.exports = function (jsonContent, {
137
149
  isShow: true
138
150
  }
139
151
 
140
- const fillInComponentPlaceholder = (name, placeholder, placeholderEntry) => {
141
- const componentPlaceholder = jsonObj.componentPlaceholder || {}
142
- if (componentPlaceholder[name]) return
143
- componentPlaceholder[name] = placeholder
144
- jsonObj.componentPlaceholder = componentPlaceholder
145
- if (placeholderEntry && !jsonObj.usingComponents[placeholder]) jsonObj.usingComponents[placeholder] = placeholderEntry
146
- }
147
-
148
- const fillInComponentsMap = (name, entry, tarRoot) => {
149
- const { resource, outputPath } = entry
150
- const { resourcePath } = parseRequest(resource)
151
- tarRoot = transSubpackage(mpx.transSubpackageRules, tarRoot)
152
- componentsMap[resourcePath] = outputPath
153
- loaderContext._module && loaderContext._module.addPresentationalDependency(new RecordResourceMapDependency(resourcePath, 'component', outputPath))
154
- localComponentsMap[name] = {
155
- resource: addQuery(resource, {
156
- isComponent: true,
157
- outputPath
158
- }),
159
- async: tarRoot
160
- }
161
- }
162
-
163
- const normalizePlaceholder = (placeholder) => {
164
- if (typeof placeholder === 'string') {
165
- const placeholderMap = mode === 'ali'
166
- ? {
167
- view: { name: 'mpx-view', resource: mpxViewPath },
168
- text: { name: 'mpx-text', resource: mpxTextPath }
169
- }
170
- : {}
171
- placeholder = placeholderMap[placeholder] || { name: placeholder }
172
- }
173
- if (!placeholder.name) {
174
- emitError('The asyncSubpackageRules configuration format of @mpxjs/webpack-plugin a is incorrect')
175
- }
176
- return placeholder
177
- }
178
-
179
152
  const processTabBar = (tabBar, callback) => {
180
153
  if (tabBar) {
181
154
  tabBar = Object.assign({}, defaultTabbar, tabBar)
@@ -345,38 +318,34 @@ module.exports = function (jsonContent, {
345
318
 
346
319
  const processComponents = (components, context, callback) => {
347
320
  if (components) {
321
+ const asyncComponents = []
322
+ const resolveResourcePathMap = new Map()
348
323
  async.eachOf(components, (component, name, callback) => {
349
- processComponent(component, context, {}, (err, entry = {}, { tarRoot, placeholder } = {}) => {
324
+ processComponent(component, context, {}, (err, entry = {}, { tarRoot, placeholder, resourcePath } = {}) => {
350
325
  if (err) return callback(err === RESOLVE_IGNORED_ERR ? null : err)
351
- fillInComponentsMap(name, entry, tarRoot)
352
326
  const { relativePath } = entry
353
327
 
354
- if (tarRoot) {
328
+ tarRoot = transSubpackage(mpx.transSubpackageRules, tarRoot)
329
+
330
+ resolveResourcePathMap.set(name, resourcePath)
331
+ if (tarRoot) asyncComponents.push({ name, tarRoot, placeholder, relativePath })
332
+
333
+ fillInComponentsMap(name, entry, tarRoot)
334
+ callback()
335
+ })
336
+ }, (err) => {
337
+ if (err) return callback(err)
338
+ async.each(asyncComponents, ({ name, tarRoot, placeholder, relativePath }, callback) => {
339
+ processPlaceholder({ jsonObj, context, name, tarRoot, placeholder, relativePath, resolveResourcePathMap }, (err, placeholder) => {
340
+ if (err) return callback(err)
355
341
  if (placeholder) {
356
- placeholder = normalizePlaceholder(placeholder)
357
- if (placeholder.resource) {
358
- processComponent(placeholder.resource, projectRoot, { relativePath }, (err, entry) => {
359
- if (err) return callback(err)
360
- fillInComponentPlaceholder(name, placeholder.name, entry)
361
- fillInComponentsMap(placeholder.name, entry, '')
362
- callback()
363
- })
364
- } else {
365
- fillInComponentPlaceholder(name, placeholder.name)
366
- callback()
367
- }
368
- } else {
369
- if (!jsonObj.componentPlaceholder || !jsonObj.componentPlaceholder[name]) {
370
- const errMsg = `componentPlaceholder of "${name}" doesn't exist! \n\r`
371
- emitError(errMsg)
372
- }
373
- callback()
342
+ const { name, entry } = placeholder
343
+ fillInComponentsMap(name, entry, '')
374
344
  }
375
- } else {
376
345
  callback()
377
- }
378
- })
379
- }, callback)
346
+ })
347
+ }, callback)
348
+ })
380
349
  } else {
381
350
  callback()
382
351
  }
@@ -394,7 +363,6 @@ module.exports = function (jsonContent, {
394
363
  callback()
395
364
  }
396
365
  }
397
-
398
366
  async.parallel([
399
367
  (callback) => {
400
368
  // 添加首页标识
@@ -15,12 +15,12 @@ module.exports = function (styles, {
15
15
  if (styles.length) {
16
16
  const warn = (msg) => {
17
17
  loaderContext.emitWarning(
18
- new Error('[style compiler][' + loaderContext.resource + ']: ' + msg)
18
+ new Error('[Mpx style warning][' + loaderContext.resource + ']: ' + msg)
19
19
  )
20
20
  }
21
21
  const error = (msg) => {
22
22
  loaderContext.emitError(
23
- new Error('[style compiler][' + loaderContext.resource + ']: ' + msg)
23
+ new Error('[Mpx style error][' + loaderContext.resource + ']: ' + msg)
24
24
  )
25
25
  }
26
26
  const { mode, srcMode } = loaderContext.getMpx()
@@ -52,6 +52,7 @@ module.exports = function (styles, {
52
52
  filename: loaderContext.resourcePath,
53
53
  mode,
54
54
  srcMode,
55
+ ctorType,
55
56
  warn,
56
57
  error
57
58
  })
@@ -17,6 +17,7 @@ module.exports = function (template, {
17
17
  moduleId,
18
18
  ctorType,
19
19
  usingComponentsInfo,
20
+ originalUsingComponents,
20
21
  componentGenerics
21
22
  }, callback) {
22
23
  const mpx = loaderContext.getMpx()
@@ -46,28 +47,29 @@ module.exports = function (template, {
46
47
  if (template) {
47
48
  // 由于远端src template资源引用的相对路径可能发生变化,暂时不支持。
48
49
  if (template.src) {
49
- return callback(new Error('[mpx loader][' + loaderContext.resource + ']: ' + 'template content must be inline in .mpx files!'))
50
+ return callback(new Error('[Mpx template error][' + loaderContext.resource + ']: ' + 'template content must be inline in .mpx files!'))
50
51
  }
51
52
  if (template.lang) {
52
- return callback(new Error('[mpx loader][' + loaderContext.resource + ']: ' + 'template lang is not supported in trans react native mode temporarily, we will support it in the future!'))
53
+ return callback(new Error('[Mpx template error][' + loaderContext.resource + ']: ' + 'template lang is not supported in trans react native mode temporarily, we will support it in the future!'))
53
54
  }
54
55
 
55
56
  if (template.content) {
56
57
  const templateSrcMode = template.mode || srcMode
57
58
  const warn = (msg) => {
58
59
  loaderContext.emitWarning(
59
- new Error('[template compiler][' + loaderContext.resource + ']: ' + msg)
60
+ new Error('[Mpx template warning][' + loaderContext.resource + ']: ' + msg)
60
61
  )
61
62
  }
62
63
  const error = (msg) => {
63
64
  loaderContext.emitError(
64
- new Error('[template compiler][' + loaderContext.resource + ']: ' + msg)
65
+ new Error('[mpx template error][' + loaderContext.resource + ']: ' + msg)
65
66
  )
66
67
  }
67
68
  const { root, meta } = templateCompiler.parse(template.content, {
68
69
  warn,
69
70
  error,
70
71
  usingComponentsInfo, // processTemplate中无其他地方使用,直接透传 string 类型
72
+ originalUsingComponents,
71
73
  hasComment,
72
74
  isNative,
73
75
  ctorType,
@@ -113,7 +115,7 @@ module.exports = function (template, {
113
115
  output += `var ${module} = require(${loaderUtils.stringifyRequest(this, src)});\n`
114
116
  }
115
117
 
116
- const rawCode = genNode(root)
118
+ const rawCode = genNode(root, true)
117
119
  if (rawCode) {
118
120
  try {
119
121
  const ignoreMap = Object.assign({
@@ -130,7 +132,7 @@ module.exports = function (template, {
130
132
  return ${bindResult.code}
131
133
  };\n`
132
134
  } catch (e) {
133
- error(`Invalid render function generated by the template, please check!
135
+ error(`[Mpx template error]: Invalid render function generated by the template, please check!
134
136
  Error code:
135
137
  ${rawCode}
136
138
  Error Detail:
@@ -4,16 +4,11 @@ const parseRequest = require('../utils/parse-request')
4
4
  const shallowStringify = require('../utils/shallow-stringify')
5
5
  const normalize = require('../utils/normalize')
6
6
  const addQuery = require('../utils/add-query')
7
- const { isBuildInReactTag } = require('../utils/dom-tag-config')
8
7
 
9
8
  function stringifyRequest (loaderContext, request) {
10
9
  return loaderUtils.stringifyRequest(loaderContext, request)
11
10
  }
12
11
 
13
- function getBuiltInComponentRequest (component) {
14
- return JSON.stringify(addQuery(`@mpxjs/webpack-plugin/lib/runtime/components/react/dist/${component}`, { isComponent: true }))
15
- }
16
-
17
12
  function getAsyncChunkName (chunkName) {
18
13
  if (chunkName && typeof chunkName !== 'boolean') {
19
14
  return `/* webpackChunkName: "${chunkName}/index" */`
@@ -26,8 +21,8 @@ function getAsyncSuspense (type, moduleId, componentRequest, componentName, chun
26
21
  type: ${JSON.stringify(type)},
27
22
  moduleId: ${JSON.stringify(moduleId)},
28
23
  chunkName: ${JSON.stringify(chunkName)},
29
- getFallback: ${getFallback},
30
- getLoading: ${getLoading},
24
+ ${getFallback ? `getFallback: ${getFallback},` : ''}
25
+ ${getLoading ? `getLoading: ${getLoading},` : ''}
31
26
  getChildren () {
32
27
  return import(${getAsyncChunkName(chunkName)}${componentRequest}).then(function (res) {
33
28
  return getComponent(res, {displayName: ${JSON.stringify(componentName)}})
@@ -95,22 +90,17 @@ function buildComponentsMap ({ localComponentsMap, builtInComponentsMap, loaderC
95
90
  if (placeholder) {
96
91
  if (localComponentsMap[placeholder]) {
97
92
  const placeholderCfg = localComponentsMap[placeholder]
98
- const placeholderRequest = stringifyRequest(loaderContext, placeholderCfg.resource)
99
93
  if (placeholderCfg.async) {
100
94
  loaderContext.emitWarning(
101
95
  new Error(`[json processor][${loaderContext.resource}]: componentPlaceholder ${placeholder} should not be a async component, please check!`)
102
96
  )
103
97
  }
98
+ const placeholderRequest = stringifyRequest(loaderContext, placeholderCfg.resource)
104
99
  getFallback = getComponentGetter(getComponent(placeholderRequest, placeholder))
105
100
  } else {
106
- const tag = `mpx-${placeholder}`
107
- if (isBuildInReactTag(tag)) {
108
- getFallback = getComponentGetter(getBuiltInComponent(getBuiltInComponentRequest(tag)))
109
- } else {
110
- loaderContext.emitError(
111
- new Error(`[json processor][${loaderContext.resource}]: componentPlaceholder ${placeholder} is not built-in component, please check!`)
112
- )
113
- }
101
+ loaderContext.emitError(
102
+ new Error(`[json processor][${loaderContext.resource}]: componentPlaceholder ${placeholder} is not built-in component or custom component, please check!`)
103
+ )
114
104
  }
115
105
  } else {
116
106
  loaderContext.emitError(
@@ -1,5 +1,6 @@
1
1
  const postcss = require('postcss')
2
2
  const selectorParser = require('postcss-selector-parser')
3
+ const { MPX_TAG_PAGE_SELECTOR } = require('../utils/const')
3
4
  const getRulesRunner = require('../platform/index')
4
5
  const dash2hump = require('../utils/hump-dash').dash2hump
5
6
  const unitRegExp = /^\s*(-?\d+(?:\.\d+)?)(rpx|vw|vh)\s*$/
@@ -7,8 +8,8 @@ const numberRegExp = /^\s*(-?\d+(\.\d+)?)(px)?\s*$/
7
8
  const hairlineRegExp = /^\s*hairlineWidth\s*$/
8
9
  const varRegExp = /^--/
9
10
  const cssPrefixExp = /^-(webkit|moz|ms|o)-/
10
- function getClassMap ({ content, filename, mode, srcMode, warn, error }) {
11
- const classMap = {}
11
+ function getClassMap ({ content, filename, mode, srcMode, ctorType, warn, error }) {
12
+ const classMap = ctorType === 'page' ? { [MPX_TAG_PAGE_SELECTOR]: { flex: 1 } } : {}
12
13
 
13
14
  const root = postcss.parse(content, {
14
15
  from: filename
@@ -36,6 +37,13 @@ function getClassMap ({ content, filename, mode, srcMode, warn, error }) {
36
37
  error
37
38
  })
38
39
 
40
+ // 目前所有 AtRule 只支持 @media,其他全部给出错误提示
41
+ root.walkAtRules(rule => {
42
+ if (rule.name !== 'media') {
43
+ warn(`Only @media rule is supported in react native mode temporarily, but got @${rule.name}`)
44
+ }
45
+ })
46
+
39
47
  root.walkRules(rule => {
40
48
  const classMapValue = {}
41
49
  rule.walkDecls(({ prop, value }) => {
@@ -16,6 +16,8 @@ module.exports = class AddEnvPlugin {
16
16
  apply (resolver) {
17
17
  const target = resolver.ensureHook(this.target)
18
18
  const env = this.env
19
+ const envPattern = new RegExp(`\\.${env}(\\.|$)`)
20
+
19
21
  resolver.getHook(this.source).tapAsync('AddEnvPlugin', (request, resolveContext, callback) => {
20
22
  if (request.env) {
21
23
  return callback()
@@ -32,11 +34,22 @@ module.exports = class AddEnvPlugin {
32
34
  }
33
35
  // 当前资源没有后缀名或者路径不符合fileConditionRules规则时,直接返回
34
36
  if (!extname || !matchCondition(resourcePath, this.fileConditionRules)) return callback()
37
+
35
38
  const queryObj = parseQuery(request.query || '?')
36
39
  queryObj.infix = `${queryObj.infix || ''}.${env}`
40
+
41
+ const resourceBasename = path.basename(resourcePath)
42
+ // 如果 infix 与 resourcePath 无法匹配,则认为未命中env
43
+ if (envPattern.test(resourceBasename) && resourceBasename.includes(queryObj.infix)) {
44
+ request.query = stringifyQuery(queryObj)
45
+ request.env = obj.env
46
+ return callback()
47
+ }
48
+
37
49
  obj.query = stringifyQuery(queryObj)
38
50
  obj.path = addInfix(resourcePath, env, extname)
39
51
  obj.relativePath = request.relativePath && addInfix(request.relativePath, env, extname)
52
+
40
53
  resolver.doResolve(target, Object.assign({}, request, obj), 'add env: ' + env, resolveContext, callback)
41
54
  })
42
55
  }
@@ -17,6 +17,9 @@ module.exports = class AddModePlugin {
17
17
  const target = resolver.ensureHook(this.target)
18
18
  const { options = {}, mode } = this
19
19
  const { defaultMode, fileConditionRules, implicitMode } = options
20
+ const modePattern = new RegExp(`\\.${mode}(\\.|$)`)
21
+ const defaultModePattern = new RegExp(`\\.${defaultMode}(\\.|$)`)
22
+
20
23
  resolver.getHook(this.source).tapAsync('AddModePlugin', (request, resolveContext, callback) => {
21
24
  if (request.mode || request.env) {
22
25
  return callback()
@@ -33,13 +36,28 @@ module.exports = class AddModePlugin {
33
36
  }
34
37
  // 当前资源没有后缀名或者路径不符合fileConditionRules规则时,直接返回
35
38
  if (!extname || !matchCondition(resourcePath, fileConditionRules)) return callback()
39
+
36
40
  const queryObj = parseQuery(request.query || '?')
37
41
  const queryInfix = queryObj.infix
38
42
  if (!implicitMode) queryObj.mode = mode
39
43
  queryObj.infix = `${queryInfix || ''}.${mode}`
44
+
45
+ // 如果已经确认是mode后缀的文件,添加query与mode后直接返回
46
+ if (modePattern.test(path.basename(resourcePath))) {
47
+ request.query = stringifyQuery(queryObj)
48
+ request.mode = obj.mode
49
+ return callback()
50
+ } else if (defaultMode && defaultModePattern.test(path.basename(resourcePath))) {
51
+ queryObj.infix = `${queryInfix || ''}.${defaultMode}`
52
+ request.query = stringifyQuery(queryObj)
53
+ request.mode = obj.mode
54
+ return callback()
55
+ }
56
+
40
57
  obj.query = stringifyQuery(queryObj)
41
58
  obj.path = addInfix(resourcePath, mode, extname)
42
59
  obj.relativePath = request.relativePath && addInfix(request.relativePath, mode, extname)
60
+
43
61
  resolver.doResolve(target, Object.assign({}, request, obj), 'add mode: ' + mode, resolveContext, (err, result) => {
44
62
  if (defaultMode && !result) {
45
63
  queryObj.infix = `${queryInfix || ''}.${defaultMode}`
@@ -6,9 +6,14 @@ export type LabelContextValue = MutableRefObject<{
6
6
  triggerChange: (evt: NativeSyntheticEvent<TouchEvent>) => void
7
7
  }>
8
8
 
9
- export type KeyboardAvoidContextValue = MutableRefObject<
10
- { cursorSpacing: number, ref: MutableRefObject<any> } | null
11
- >
9
+ export type KeyboardAvoidContextValue = MutableRefObject<{
10
+ cursorSpacing: number
11
+ ref: MutableRefObject<any>
12
+ adjustPosition: boolean
13
+ holdKeyboard?: boolean
14
+ keyboardHeight?: number
15
+ onKeyboardShow?: () => void
16
+ } | null>
12
17
 
13
18
  export interface GroupValue {
14
19
  [key: string]: { checked: boolean; setValue: Dispatch<SetStateAction<boolean>> }
@@ -37,13 +42,13 @@ export interface IntersectionObserver {
37
42
  }
38
43
 
39
44
  export interface PortalContextValue {
40
- mount: (children: React.ReactNode, key?: number | null, id?: number| null) => number| undefined
45
+ mount: (children: React.ReactNode, key?: number | null, id?: number | null) => number | undefined
41
46
  update: (key: number, children: React.ReactNode) => void
42
47
  unmount: (key: number) => void
43
48
  }
44
49
 
45
50
  export interface ScrollViewContextValue {
46
- gestureRef: React.RefObject<any> | null,
51
+ gestureRef: React.RefObject<any> | null
47
52
  scrollOffset: Animated.Value
48
53
  }
49
54
 
@@ -53,7 +58,7 @@ export interface RouteContextValue {
53
58
  }
54
59
 
55
60
  export interface StickyContextValue {
56
- registerStickyHeader: Function,
61
+ registerStickyHeader: Function
57
62
  unregisterStickyHeader: Function
58
63
  }
59
64
 
@@ -84,3 +89,5 @@ export const ScrollViewContext = createContext<ScrollViewContextValue>({ gesture
84
89
  export const PortalContext = createContext<PortalContextValue>(null as any)
85
90
 
86
91
  export const StickyContext = createContext<StickyContextValue>({ registerStickyHeader: noop, unregisterStickyHeader: noop })
92
+
93
+ export const ProviderContext = createContext(null)