@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
@@ -1,7 +1,7 @@
1
1
  const JSON5 = require('json5')
2
2
  const he = require('he')
3
3
  const config = require('../config')
4
- const { MPX_ROOT_VIEW, MPX_APP_MODULE_ID, PARENT_MODULE_ID } = require('../utils/const')
4
+ const { MPX_ROOT_VIEW, MPX_APP_MODULE_ID, PARENT_MODULE_ID, MPX_TAG_PAGE_SELECTOR } = require('../utils/const')
5
5
  const normalize = require('../utils/normalize')
6
6
  const { normalizeCondition } = require('../utils/match-condition')
7
7
  const isValidIdentifierStr = require('../utils/is-valid-identifier-str')
@@ -15,7 +15,8 @@ const { isNonPhrasingTag } = require('../utils/dom-tag-config')
15
15
  const setBaseWxml = require('../runtime-render/base-wxml')
16
16
  const { parseExp } = require('./parse-exps')
17
17
  const shallowStringify = require('../utils/shallow-stringify')
18
- const { isReact, isWeb } = require('../utils/env')
18
+ const { isReact, isWeb, isNoMode } = require('../utils/env')
19
+ const { capitalToHyphen } = require('../utils/string')
19
20
 
20
21
  const no = function () {
21
22
  return false
@@ -119,6 +120,8 @@ const rulesResultMap = new Map()
119
120
  let usingComponents = []
120
121
  let usingComponentsInfo = {}
121
122
  let componentGenerics = {}
123
+ // 跨平台语法检测的配置,在模块加载时初始化一次
124
+ let crossPlatformConfig = null
122
125
 
123
126
  function updateForScopesMap () {
124
127
  forScopesMap = {}
@@ -147,11 +150,11 @@ const deleteErrorInResultMap = (node) => {
147
150
  }
148
151
 
149
152
  function baseWarn (msg) {
150
- console.warn(('[template compiler]: ' + msg))
153
+ console.warn(('[Mpx template warning]: ' + msg))
151
154
  }
152
155
 
153
156
  function baseError (msg) {
154
- console.error(('[template compiler]: ' + msg))
157
+ console.error(('[Mpx template error]: ' + msg))
155
158
  }
156
159
 
157
160
  const decodeMap = {
@@ -637,8 +640,9 @@ function parse (template, options) {
637
640
  processingTemplate = false
638
641
  rulesResultMap.clear()
639
642
  componentGenerics = options.componentGenerics || {}
643
+ // 初始化跨平台语法检测配置(每次解析时只初始化一次)
644
+ crossPlatformConfig = initCrossPlatformConfig()
640
645
 
641
- if (typeof options.usingComponentsInfo === 'string') options.usingComponentsInfo = JSON.parse(options.usingComponentsInfo)
642
646
  usingComponents = Object.keys(options.usingComponentsInfo)
643
647
  usingComponentsInfo = options.usingComponentsInfo
644
648
 
@@ -681,7 +685,6 @@ function parse (template, options) {
681
685
  meta.options.virtualHost = true
682
686
  }
683
687
  let currentParent
684
- let multiRootError
685
688
  // 用于记录模板用到的组件,匹配引用组件,看是否有冗余
686
689
  const tagNames = new Set()
687
690
 
@@ -760,6 +763,7 @@ function parse (template, options) {
760
763
  if (!currentParent) genTempRoot()
761
764
 
762
765
  const children = currentParent.children
766
+
763
767
  if (currentParent.tag !== 'text') {
764
768
  text = text.trim()
765
769
  } else {
@@ -793,9 +797,10 @@ function parse (template, options) {
793
797
  }
794
798
  })
795
799
 
796
- if (multiRootError) {
797
- error$1('Template fields should has one single root, considering wrapping your template content with <view> or <text> tag!')
798
- }
800
+ // multiRoot
801
+ // if (root.tag === 'temp-node' && root.children && root.children.filter(node => node.tag !== 'temp-node').length > 1) {
802
+ // error$1('Template fields should has one single root, considering wrapping your template content with <view> or <text> tag!')
803
+ // }
799
804
 
800
805
  if (hasI18n) {
801
806
  if (i18nInjectableComputed.length) {
@@ -1000,12 +1005,34 @@ function processComponentIs (el, options) {
1000
1005
  }
1001
1006
 
1002
1007
  const range = getAndRemoveAttr(el, 'range').val
1003
- const isInRange = makeMap(range || '')
1004
- el.components = (usingComponents).filter(i => {
1005
- if (!range) return true
1006
- return isInRange(i)
1008
+
1009
+ // Map<CurrentName, SourceName>
1010
+ let ranges
1011
+ if (range) {
1012
+ ranges = range.split(',').map(i => i.trim()).filter(i => i)
1013
+ } else {
1014
+ // 根据原始用户写的usingComponents字段生成ranges
1015
+ ranges = options.originalUsingComponents
1016
+ }
1017
+
1018
+ const rangeMap = new Map()
1019
+ ranges.forEach(name => {
1020
+ rangeMap.set(['ali', 'swan'].includes(mode) ? capitalToHyphen(name) : name, name)
1021
+ })
1022
+
1023
+ // Map<CurrentName, SourceName>
1024
+ el.componentMap = new Map()
1025
+ usingComponents.forEach((name) => {
1026
+ if (rangeMap.size === 0) {
1027
+ el.componentMap.set(name, name)
1028
+ } else {
1029
+ if (rangeMap.has(name)) {
1030
+ el.componentMap.set(name, rangeMap.get(name))
1031
+ }
1032
+ }
1007
1033
  })
1008
- if (!el.components.length) {
1034
+
1035
+ if (el.componentMap.size === 0) {
1009
1036
  warn$1('Component in which <component> tag is used must have a non blank usingComponents field')
1010
1037
  }
1011
1038
 
@@ -1592,7 +1619,7 @@ function parseOptionalChaining (str) {
1592
1619
  }
1593
1620
  if (grammarMap.checkState() && haveNotGetValue) {
1594
1621
  // 值查找结束但是语法未闭合或者处理到边界还未结束,抛异常
1595
- throw new Error('[optionChain] option value illegal!!!')
1622
+ throw new Error('[Mpx template error]: optionChain option value illegal!!!')
1596
1623
  }
1597
1624
  haveNotGetValue = true
1598
1625
  let keyValue = ''
@@ -1642,7 +1669,7 @@ function parseOptionalChaining (str) {
1642
1669
  }
1643
1670
  if (grammarMap.checkState() && haveNotGetValue) {
1644
1671
  // key值查找结束但是语法未闭合或者处理到边界还未结束,抛异常
1645
- throw new Error('[optionChain] option key illegal!!!')
1672
+ throw new Error('[Mpx template error]: optionChain option key illegal!!!')
1646
1673
  }
1647
1674
  if (keyValue) {
1648
1675
  chainKey += `,'${keyValue}'`
@@ -1855,24 +1882,25 @@ function processRefReact (el, meta) {
1855
1882
  /**
1856
1883
  * selectorsConf: [type, [[prefix, selector], [prefix, selector]]]
1857
1884
  */
1858
- if (!val) {
1859
- const rawId = el.attrsMap.id
1860
- const rawClass = el.attrsMap.class
1861
- const rawDynamicClass = el.attrsMap[config[mode].directive.dynamicClass]
1862
-
1863
- if (rawId) {
1864
- const staticId = parseMustacheWithContext(rawId).result
1865
- selectors.push({ prefix: '#', selector: `${staticId}` })
1866
- }
1867
- if (rawClass || rawDynamicClass) {
1868
- const staticClass = parseMustacheWithContext(rawClass).result
1869
- const dynamicClass = parseMustacheWithContext(rawDynamicClass).result
1870
- selectors.push({ prefix: '.', selector: `this.__getClass(${staticClass}, ${dynamicClass})` })
1871
- }
1872
- } else {
1885
+ if (val) {
1873
1886
  meta.refs.push(refConf)
1874
1887
  selectors.push({ prefix: '', selector: `"${refConf.key}"` })
1875
1888
  }
1889
+
1890
+ const rawId = el.attrsMap.id
1891
+ const rawClass = el.attrsMap.class
1892
+ const rawDynamicClass = el.attrsMap[config[mode].directive.dynamicClass]
1893
+
1894
+ if (rawId) {
1895
+ const staticId = parseMustacheWithContext(rawId).result
1896
+ selectors.push({ prefix: '#', selector: `${staticId}` })
1897
+ }
1898
+ if (rawClass || rawDynamicClass) {
1899
+ const staticClass = parseMustacheWithContext(rawClass).result
1900
+ const dynamicClass = parseMustacheWithContext(rawDynamicClass).result
1901
+ selectors.push({ prefix: '.', selector: `this.__getClass(${staticClass}, ${dynamicClass})` })
1902
+ }
1903
+
1876
1904
  const selectorsConf = selectors.map(item => `["${item.prefix}", ${item.selector}]`)
1877
1905
  const refFnId = forScopes.reduce((preV, curV) => {
1878
1906
  return `${preV} + "_" + ${curV.index}`
@@ -2084,13 +2112,24 @@ function postProcessIf (el) {
2084
2112
  replaceNode(el, getTempNode())._if = false
2085
2113
  }
2086
2114
  } else {
2115
+ el._if = null
2087
2116
  attrs = [{
2088
2117
  name: config[mode].directive.if,
2089
2118
  value: el.if.raw
2090
2119
  }]
2091
2120
  }
2092
2121
  } else if (el.elseif) {
2122
+ if (el.for) {
2123
+ error$1(`wx:elif (wx:elif="${el.elseif.raw}") invalidly used on the for-list <"${el.tag}"> which has a wx:for directive, please create a block element to wrap the for-list and move the elif-directive to it`)
2124
+ return
2125
+ }
2126
+
2093
2127
  prevNode = findPrevNode(el)
2128
+ if (!prevNode || prevNode._if === undefined) {
2129
+ error$1(`wx:elif="${el.elseif.raw}" used on element [${el.tag}] without corresponding wx:if or wx:elif.`)
2130
+ return
2131
+ }
2132
+
2094
2133
  if (prevNode._if === true) {
2095
2134
  removeNode(el)
2096
2135
  } else if (prevNode._if === false) {
@@ -2110,6 +2149,7 @@ function postProcessIf (el) {
2110
2149
  removeNode(el)
2111
2150
  }
2112
2151
  } else {
2152
+ el._if = null
2113
2153
  attrs = [{
2114
2154
  name: config[mode].directive.elseif,
2115
2155
  value: el.elseif.raw
@@ -2117,7 +2157,17 @@ function postProcessIf (el) {
2117
2157
  }
2118
2158
  }
2119
2159
  } else if (el.else) {
2160
+ if (el.for) {
2161
+ error$1(`wx:else invalidly used on the for-list <"${el.tag}"> which has a wx:for directive, please create a block element to wrap the for-list and move the else-directive to it`)
2162
+ return
2163
+ }
2164
+
2120
2165
  prevNode = findPrevNode(el)
2166
+ if (!prevNode || prevNode._if === undefined) {
2167
+ error$1(`wx:else used on element [${el.tag}] without corresponding wx:if or wx:elif.`)
2168
+ return
2169
+ }
2170
+
2121
2171
  if (prevNode._if === true) {
2122
2172
  removeNode(el)
2123
2173
  } else if (prevNode._if === false) {
@@ -2141,23 +2191,100 @@ function addIfCondition (el, condition) {
2141
2191
  el.ifConditions.push(condition)
2142
2192
  }
2143
2193
 
2194
+ function getIfConditions (el) {
2195
+ return el?.ifConditions || []
2196
+ }
2197
+
2144
2198
  function postProcessIfReact (el) {
2145
- let prevNode
2199
+ let prevNode, ifNode, result, ifConditions
2146
2200
  if (el.if) {
2147
- addIfCondition(el, {
2148
- exp: el.if.exp,
2149
- block: el
2150
- })
2151
- } else if (el.elseif || el.else) {
2152
- prevNode = findPrevNode(el)
2153
- if (prevNode && prevNode.if) {
2154
- addIfCondition(prevNode, {
2155
- exp: el.elseif && el.elseif.exp,
2201
+ // 取值
2202
+ // false -> 节点变为temp-node,并添加_if=false
2203
+ // true -> 添加_if=true,移除if
2204
+ // dynamic -> addIfCondition
2205
+ result = evalExp(el.if.exp)
2206
+ if (result.success) {
2207
+ if (result.result) {
2208
+ el._if = true
2209
+ delete el.if
2210
+ } else {
2211
+ replaceNode(el, getTempNode())._if = false
2212
+ }
2213
+ } else {
2214
+ el._if = null
2215
+ addIfCondition(el, {
2216
+ exp: el.if.exp,
2156
2217
  block: el
2157
2218
  })
2158
- removeNode(el, true)
2219
+ }
2220
+ } else if (el.elseif) {
2221
+ if (el.for) {
2222
+ error$1(`wx:elif (wx:elif="${el.elseif.raw}") invalidly used on the for-list <"${el.tag}"> which has a wx:for directive, please create a block element to wrap the for-list and move the elif-directive to it`)
2223
+ return
2224
+ }
2225
+
2226
+ ifNode = findPrevNode(el)
2227
+ ifConditions = getIfConditions(ifNode)
2228
+ prevNode = ifConditions.length > 0 ? ifConditions[ifConditions.length - 1].block : ifNode
2229
+
2230
+ if (!prevNode || prevNode._if === undefined) {
2231
+ error$1(`wx:elif="${el.elseif.raw}" used on element [${el.tag}] without corresponding wx:if or wx:elif.`)
2232
+ return
2233
+ }
2234
+
2235
+ if (prevNode._if === true) {
2236
+ removeNode(el)
2237
+ } else if (prevNode._if === false) {
2238
+ el.if = el.elseif
2239
+ delete el.elseif
2240
+ postProcessIfReact(el)
2241
+ } else {
2242
+ result = evalExp(el.elseif.exp)
2243
+ if (result.success) {
2244
+ if (result.result) {
2245
+ delete el.elseif
2246
+ el._if = true
2247
+ addIfCondition(ifNode, {
2248
+ exp: el.elseif.exp,
2249
+ block: el
2250
+ })
2251
+ removeNode(el, true)
2252
+ } else {
2253
+ removeNode(el)
2254
+ }
2255
+ } else {
2256
+ el._if = null
2257
+ addIfCondition(ifNode, {
2258
+ exp: el.elseif.exp,
2259
+ block: el
2260
+ })
2261
+ removeNode(el, true)
2262
+ }
2263
+ }
2264
+ } else if (el.else) {
2265
+ if (el.for) {
2266
+ error$1(`wx:else invalidly used on the for-list <"${el.tag}"> which has a wx:for directive, please create a block element to wrap the for-list and move the else-directive to it`)
2267
+ return
2268
+ }
2269
+
2270
+ ifNode = findPrevNode(el)
2271
+ ifConditions = getIfConditions(ifNode)
2272
+ prevNode = ifConditions.length > 0 ? ifConditions[ifConditions.length - 1].block : ifNode
2273
+
2274
+ if (!prevNode || prevNode._if === undefined) {
2275
+ error$1(`wx:else used on element [${el.tag}] without corresponding wx:if or wx:elif.`)
2276
+ return
2277
+ }
2278
+
2279
+ if (prevNode._if === true) {
2280
+ removeNode(el)
2281
+ } else if (prevNode._if === false) {
2282
+ delete el.else
2159
2283
  } else {
2160
- warn$1(`wx:${el.elseif ? `elif="${el.elseif.raw}"` : 'else'} used on element [${el.tag}] without corresponding wx:if.`)
2284
+ addIfCondition(ifNode, {
2285
+ block: el
2286
+ })
2287
+ removeNode(el, true)
2161
2288
  }
2162
2289
  }
2163
2290
  }
@@ -2524,6 +2651,16 @@ function getVirtualHostRoot (options, meta) {
2524
2651
  if (isWeb(mode) && ctorType === 'page') {
2525
2652
  return createASTElement('page')
2526
2653
  }
2654
+ if (isReact(mode) && ctorType === 'page') {
2655
+ const rootView = createASTElement('view', [
2656
+ {
2657
+ name: 'class',
2658
+ value: MPX_TAG_PAGE_SELECTOR
2659
+ }
2660
+ ])
2661
+ processElement(rootView, rootView, options, meta)
2662
+ return rootView
2663
+ }
2527
2664
  }
2528
2665
  return getTempNode()
2529
2666
  }
@@ -2581,7 +2718,7 @@ function postProcessTemplate (el) {
2581
2718
  }
2582
2719
  }
2583
2720
 
2584
- const isValidMode = makeMap('wx,ali,swan,tt,qq,web,qa,jd,dd,tenon,ios,android,harmony,noMode')
2721
+ const isValidMode = makeMap('wx,ali,swan,tt,qq,web,qa,jd,dd,tenon,ios,android,harmony,ks,noMode')
2585
2722
 
2586
2723
  function isValidModeP (i) {
2587
2724
  return isValidMode(i[0] === '_' ? i.slice(1) : i)
@@ -2717,6 +2854,78 @@ function processNoTransAttrs (el) {
2717
2854
  }
2718
2855
  }
2719
2856
 
2857
+ function initCrossPlatformConfig () {
2858
+ // 定义平台与前缀的双向映射关系
2859
+ const platformPrefixMap = {
2860
+ wx: 'wx:',
2861
+ ali: 'a:',
2862
+ swan: 's-',
2863
+ qq: 'qq:',
2864
+ tt: 'tt:',
2865
+ dd: 'dd:',
2866
+ jd: 'jd:',
2867
+ qa: 'qa:',
2868
+ web: 'v-'
2869
+ }
2870
+
2871
+ if (isNoMode(mode)) {
2872
+ return null
2873
+ }
2874
+
2875
+ return {
2876
+ currentPrefix: platformPrefixMap[mode] || 'wx:',
2877
+ platformPrefixMap
2878
+ }
2879
+ }
2880
+
2881
+ // 检测跨平台语法使用情况并给出警告
2882
+ function processCrossPlatformSyntaxWarning (el) {
2883
+ // 使用转换后的属性列表进行检查
2884
+ if (!el.attrsList || el.attrsList.length === 0) {
2885
+ return
2886
+ }
2887
+
2888
+ // 如果配置为空,说明不需要检测
2889
+ if (!crossPlatformConfig) {
2890
+ return
2891
+ }
2892
+
2893
+ const { currentPrefix, platformPrefixMap } = crossPlatformConfig
2894
+
2895
+ // 检查转换后的属性列表
2896
+ el.attrsList.forEach(attr => {
2897
+ const attrName = attr.name
2898
+
2899
+ // 检查是否使用了平台前缀
2900
+ for (const [platformName, prefix] of Object.entries(platformPrefixMap)) {
2901
+ if (attrName.startsWith(prefix)) {
2902
+ if (isReact(mode)) {
2903
+ // React Native 平台:只允许使用 wx: 前缀,其他前缀报错
2904
+ if (prefix !== 'wx:') {
2905
+ error$1(
2906
+ `React Native mode "${mode}" does not support "${prefix}" prefix. ` +
2907
+ `Use "wx:" prefix instead. Found: "${attrName}"`
2908
+ )
2909
+ }
2910
+ } else {
2911
+ // 小程序平台:检测跨平台语法使用
2912
+ if (platformName !== mode) {
2913
+ // 构建建议的正确属性名
2914
+ const suffixPart = attrName.substring(prefix.length)
2915
+ const suggestedAttr = currentPrefix + suffixPart
2916
+
2917
+ warn$1(
2918
+ `Your target mode is "${mode}", but used "${attrName}". ` +
2919
+ `Did you mean "${suggestedAttr}"?`
2920
+ )
2921
+ }
2922
+ }
2923
+ break
2924
+ }
2925
+ }
2926
+ })
2927
+ }
2928
+
2720
2929
  function processMpxTagName (el) {
2721
2930
  const mpxTagName = getAndRemoveAttr(el, 'mpxTagName').val
2722
2931
  if (mpxTagName) {
@@ -2746,6 +2955,9 @@ function processElement (el, root, options, meta) {
2746
2955
 
2747
2956
  processDuplicateAttrsList(el)
2748
2957
 
2958
+ // 检测跨平台语法使用情况并给出警告
2959
+ processCrossPlatformSyntaxWarning(el)
2960
+
2749
2961
  processInjectWxs(el, meta, options)
2750
2962
 
2751
2963
  const transAli = mode === 'ali' && srcMode === 'wx'
@@ -2890,7 +3102,7 @@ function cloneAttrsList (attrsList) {
2890
3102
  }
2891
3103
 
2892
3104
  function postProcessComponentIs (el, postProcessChild) {
2893
- if (el.is && el.components) {
3105
+ if (el.is && el.componentMap && el.componentMap.size > 0) {
2894
3106
  let tempNode
2895
3107
  if (el.for || el.if || el.elseif || el.else) {
2896
3108
  tempNode = createASTElement('block')
@@ -2900,11 +3112,12 @@ function postProcessComponentIs (el, postProcessChild) {
2900
3112
  replaceNode(el, tempNode, true)
2901
3113
  postMoveBaseDirective(tempNode, el)
2902
3114
 
2903
- el.components.forEach(function (component) {
2904
- const newChild = createASTElement(component, cloneAttrsList(el.attrsList), tempNode)
3115
+ // Map<CurrentName, SourceName>
3116
+ el.componentMap.forEach((source, name) => {
3117
+ const newChild = createASTElement(name, cloneAttrsList(el.attrsList), tempNode)
2905
3118
  newChild.if = {
2906
- raw: `{{${el.is} === ${stringify(component)}}}`,
2907
- exp: `${el.is} === ${stringify(component)}`
3119
+ raw: `{{${el.is} === ${stringify(source)}}}`,
3120
+ exp: `${el.is} === ${stringify(source)}`
2908
3121
  }
2909
3122
  el.children.forEach((child) => {
2910
3123
  addChild(newChild, cloneNode(child))
@@ -3029,30 +3242,12 @@ function genIf (node) {
3029
3242
 
3030
3243
  function genElseif (node) {
3031
3244
  node.elseifProcessed = true
3032
- if (node.for) {
3033
- error$1(`wx:elif (wx:elif="${node.elseif.raw}") invalidly used on the for-list <"${node.tag}"> which has a wx:for directive, please create a block element to wrap the for-list and move the if-directive to it`)
3034
- return
3035
- }
3036
- const preNode = findPrevNode(node)
3037
- if (preNode && (preNode.if || preNode.elseif)) {
3038
- return `else if(${node.elseif.exp}){\n${genNode(node)}}\n`
3039
- } else {
3040
- error$1(`wx:elif (wx:elif="${node.elseif.raw}") invalidly used on the element <"${node.tag}"> without corresponding wx:if or wx:elif.`)
3041
- }
3245
+ return `else if(${node.elseif.exp}){\n${genNode(node)}}\n`
3042
3246
  }
3043
3247
 
3044
3248
  function genElse (node) {
3045
3249
  node.elseProcessed = true
3046
- if (node.for) {
3047
- error$1(`wx:else invalidly used on the for-list <"${node.tag}"> which has a wx:for directive, please create a block element to wrap the for-list and move the if-directive to it`)
3048
- return
3049
- }
3050
- const preNode = findPrevNode(node)
3051
- if (preNode && (preNode.if || preNode.elseif)) {
3052
- return `else{\n${genNode(node)}}\n`
3053
- } else {
3054
- error$1(`wx:else invalidly used on the element <"${node.tag}"> without corresponding wx:if or wx:elif.`)
3055
- }
3250
+ return `else{\n${genNode(node)}}\n`
3056
3251
  }
3057
3252
 
3058
3253
  function genExps (node) {
@@ -3065,7 +3260,7 @@ function genFor (node) {
3065
3260
  node.forProcessed = true
3066
3261
  const index = node.for.index || 'index'
3067
3262
  const item = node.for.item || 'item'
3068
- return `_i(${node.for.exp}, function(${item},${index}){\n${genNode(node)}});\n`
3263
+ return `mpx_i(${node.for.exp}, function(${item},${index}){\n${genNode(node)}});\n`
3069
3264
  }
3070
3265
 
3071
3266
  function genNode (node) {
@@ -3263,5 +3458,6 @@ module.exports = {
3263
3458
  findPrevNode,
3264
3459
  removeNode,
3265
3460
  replaceNode,
3266
- createASTElement
3461
+ createASTElement,
3462
+ evalExp
3267
3463
  }
@@ -9,7 +9,8 @@ function genIfConditions (conditions) {
9
9
  if (!conditions.length) return 'null'
10
10
  const condition = conditions.shift()
11
11
  if (condition.exp) {
12
- return `(${condition.exp})?${genNode(condition.block)}:${genIfConditions(conditions)}`
12
+ // 此处 condition.exp 无需括号包裹,condition.exp本身已经包含括号
13
+ return `${condition.exp}?${genNode(condition.block)}:${genIfConditions(conditions)}`
13
14
  } else {
14
15
  return genNode(condition.block)
15
16
  }
@@ -30,7 +31,7 @@ function mapAttrName (name) {
30
31
  return name
31
32
  }
32
33
 
33
- function genNode (node) {
34
+ function genNode (node, isRoot = false) {
34
35
  let exp = ''
35
36
  if (node) {
36
37
  if (node.type === 3) {
@@ -72,18 +73,29 @@ function genNode (node) {
72
73
  }
73
74
 
74
75
  if (!node.unary && node.children.length) {
75
- exp += ','
76
- exp += node.children.map((child) => {
76
+ const childNode = node.children.map((child) => {
77
77
  return genNode(child)
78
78
  }).filter(fragment => fragment).join(',')
79
+
80
+ // child可能为temp-node等无效节点,所以增加判断确保存在childNode再添加逗号
81
+ if (childNode) {
82
+ exp += ','
83
+ exp += childNode
84
+ }
79
85
  }
80
86
  exp += ')'
81
87
  }
82
88
  }
83
89
  } else {
84
- exp += node.children.map((child) => {
90
+ const nodes = node.children.map((child) => {
85
91
  return genNode(child)
86
- }).filter(fragment => fragment).join(',')
92
+ }).filter(fragment => fragment && fragment !== 'null')
93
+ if (isRoot && nodes.length > 1) {
94
+ // 如果存在多个根节点,使用 block 包裹
95
+ exp = `createElement(getComponent("block"), null, ${nodes.join(',')})`
96
+ } else {
97
+ exp += nodes.join(',')
98
+ }
87
99
  }
88
100
  }
89
101
  }
@@ -24,14 +24,15 @@ module.exports = function (raw) {
24
24
  const packageName = queryObj.packageRoot || mpx.currentPackageRoot || 'main'
25
25
  const wxsContentMap = mpx.wxsContentMap
26
26
  const optimizeRenderRules = mpx.optimizeRenderRules
27
- const usingComponentsInfo = queryObj.usingComponentsInfo || {}
27
+ const usingComponentsInfo = queryObj.usingComponentsInfo ? JSON.parse(queryObj.usingComponentsInfo) : {}
28
+ const originalUsingComponents = queryObj.originalUsingComponents ? JSON.parse(queryObj.originalUsingComponents) : []
28
29
  const componentPlaceholder = queryObj.componentPlaceholder || []
29
30
  const hasComment = queryObj.hasComment
30
31
  const isNative = queryObj.isNative
31
32
  const ctorType = queryObj.ctorType
32
33
  const hasScoped = queryObj.hasScoped
33
34
  const runtimeCompile = queryObj.isDynamic
34
- const moduleId = queryObj.moduleId || mpx.getModuleId(resourcePath)
35
+ const moduleId = queryObj.moduleId || mpx.getModuleId(resourcePath, false, queryObj.moduleId ? null : this)
35
36
 
36
37
  let optimizeRenderLevel = 0
37
38
  for (const rule of optimizeRenderRules) {
@@ -43,13 +44,13 @@ module.exports = function (raw) {
43
44
 
44
45
  const warn = (msg) => {
45
46
  this.emitWarning(
46
- new Error('[template compiler][' + this.resource + ']: ' + msg)
47
+ new Error('[Mpx template warning][' + this.resource + ']: ' + msg)
47
48
  )
48
49
  }
49
50
 
50
51
  const error = (msg) => {
51
52
  this.emitError(
52
- new Error('[template compiler][' + this.resource + ']: ' + msg)
53
+ new Error('[Mpx template error][' + this.resource + ']: ' + msg)
53
54
  )
54
55
  }
55
56
 
@@ -70,6 +71,7 @@ module.exports = function (raw) {
70
71
  hasScoped,
71
72
  moduleId,
72
73
  usingComponentsInfo,
74
+ originalUsingComponents,
73
75
  // 这里需传递rawResourcePath和wxsContentMap保持一致
74
76
  filePath: rawResourcePath,
75
77
  i18n,
@@ -110,10 +112,10 @@ module.exports = function (raw) {
110
112
  if (rawCode) {
111
113
  try {
112
114
  const ignoreMap = Object.assign({
113
- _i: true,
114
- _c: true,
115
- _sc: true,
116
- _r: true
115
+ mpx_i: true,
116
+ mpx_c: true,
117
+ mpx_sc: true,
118
+ mpx_r: true
117
119
  }, meta.wxsModuleMap)
118
120
  const bindResult = optimizeRenderLevel === 2
119
121
  ? bindThis.transformSimple(rawCode, {
@@ -124,9 +126,9 @@ module.exports = function (raw) {
124
126
  renderReduce: optimizeRenderLevel === 1,
125
127
  ignoreMap
126
128
  })
127
- resultSource += `global.currentInject.render = function (_i, _c, _r, _sc) {
129
+ resultSource += `global.currentInject.render = function (mpx_i, mpx_c, mpx_r, mpx_sc) {
128
130
  ${bindResult.code}
129
- _r(${optimizeRenderLevel === 2 ? 'true' : ''});
131
+ mpx_r(${optimizeRenderLevel === 2 ? 'true' : ''});
130
132
  };\n`
131
133
  if ((mode === 'tt' || mode === 'swan') && bindResult.propKeys) {
132
134
  resultSource += `global.currentInject.propKeys = ${JSON.stringify(bindResult.propKeys)};\n`
@@ -23,7 +23,7 @@ const NODE_TYPE = {
23
23
  }
24
24
 
25
25
  const error = function (msg) {
26
- throw new Error(`[Mpx dynamic expression parser error]: ${msg}`)
26
+ throw new Error(`[Mpx template error]: ${msg}`)
27
27
  }
28
28
 
29
29
  walk.full = function full (node, baseVisitor, state, override) {
@@ -6,5 +6,6 @@ module.exports = {
6
6
  JSON_JS_EXT: '.json.js',
7
7
  MPX_ROOT_VIEW: 'mpx-root-view', // 根节点类名
8
8
  MPX_APP_MODULE_ID: 'mpx-app-scope', // app文件moduleId
9
- PARENT_MODULE_ID: '__pid'
9
+ PARENT_MODULE_ID: '__pid',
10
+ MPX_TAG_PAGE_SELECTOR: 'mpx-page'
10
11
  }