@mpxjs/webpack-plugin 2.10.24 → 2.11.0

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 (151) hide show
  1. package/lib/index.js +4 -1
  2. package/lib/platform/style/wx/index.js +417 -120
  3. package/lib/platform/template/wx/component-config/picker.js +0 -6
  4. package/lib/react/style-helper.js +6 -6
  5. package/lib/resolver/AddEnvPlugin.js +1 -1
  6. package/lib/resolver/AddModePlugin.js +1 -1
  7. package/lib/resolver/ExtendComponentsPlugin.js +68 -0
  8. package/lib/runtime/components/extends/section-list.mpx +14 -0
  9. package/lib/runtime/components/react/animationHooks/index.ts +7 -3
  10. package/lib/runtime/components/react/dist/animationHooks/index.d.ts +0 -2
  11. package/lib/runtime/components/react/dist/animationHooks/index.js +6 -1
  12. package/lib/runtime/components/react/dist/event.config.d.ts +2 -6
  13. package/lib/runtime/components/react/dist/event.config.js +28 -24
  14. package/lib/runtime/components/react/dist/getInnerListeners.d.ts +1 -1
  15. package/lib/runtime/components/react/dist/getInnerListeners.js +74 -56
  16. package/lib/runtime/components/react/dist/mpx-button.d.ts +1 -2
  17. package/lib/runtime/components/react/dist/mpx-button.jsx +16 -9
  18. package/lib/runtime/components/react/dist/mpx-camera.d.ts +0 -2
  19. package/lib/runtime/components/react/dist/mpx-camera.jsx +36 -5
  20. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -2
  21. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +1 -3
  22. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +1 -1
  23. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -2
  24. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +3 -4
  25. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +1 -2
  26. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +8 -9
  27. package/lib/runtime/components/react/dist/mpx-form.d.ts +1 -2
  28. package/lib/runtime/components/react/dist/mpx-form.jsx +5 -5
  29. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -2
  30. package/lib/runtime/components/react/dist/mpx-icon/index.jsx +2 -2
  31. package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -2
  32. package/lib/runtime/components/react/dist/mpx-image.jsx +59 -43
  33. package/lib/runtime/components/react/dist/mpx-inline-text.jsx +13 -4
  34. package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -2
  35. package/lib/runtime/components/react/dist/mpx-input.jsx +16 -8
  36. package/lib/runtime/components/react/dist/mpx-label.d.ts +1 -2
  37. package/lib/runtime/components/react/dist/mpx-label.jsx +5 -6
  38. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -2
  39. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +3 -3
  40. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +1 -2
  41. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +6 -6
  42. package/lib/runtime/components/react/dist/mpx-nav.jsx +1 -1
  43. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +72 -23
  44. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +2 -2
  45. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +4 -0
  46. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +1 -1
  47. package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +10 -14
  48. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -2
  49. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.js +0 -5
  50. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +1 -1
  51. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +34 -14
  52. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -2
  53. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.jsx +4 -5
  54. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -2
  55. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +3 -5
  56. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +5 -4
  57. package/lib/runtime/components/react/dist/mpx-popup/index.jsx +2 -2
  58. package/lib/runtime/components/react/dist/mpx-popup/popupBase.jsx +3 -2
  59. package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -2
  60. package/lib/runtime/components/react/dist/mpx-progress.jsx +1 -3
  61. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -2
  62. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +3 -4
  63. package/lib/runtime/components/react/dist/mpx-radio.d.ts +1 -2
  64. package/lib/runtime/components/react/dist/mpx-radio.jsx +8 -9
  65. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -2
  66. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +1 -3
  67. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +1 -2
  68. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -6
  69. package/lib/runtime/components/react/dist/mpx-section-list.d.ts +51 -0
  70. package/lib/runtime/components/react/dist/mpx-section-list.jsx +376 -0
  71. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +37 -19
  72. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +4 -1
  73. package/lib/runtime/components/react/dist/mpx-simple-view.jsx +11 -4
  74. package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -2
  75. package/lib/runtime/components/react/dist/mpx-slider.jsx +6 -7
  76. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +1 -2
  77. package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +5 -5
  78. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +1 -2
  79. package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +6 -6
  80. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +1 -2
  81. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +5 -5
  82. package/lib/runtime/components/react/dist/mpx-swiper.d.ts +1 -2
  83. package/lib/runtime/components/react/dist/mpx-swiper.jsx +4 -8
  84. package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -2
  85. package/lib/runtime/components/react/dist/mpx-switch.jsx +1 -3
  86. package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -2
  87. package/lib/runtime/components/react/dist/mpx-text.jsx +43 -25
  88. package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -2
  89. package/lib/runtime/components/react/dist/mpx-video.jsx +4 -5
  90. package/lib/runtime/components/react/dist/mpx-view.d.ts +2 -2
  91. package/lib/runtime/components/react/dist/mpx-view.jsx +214 -114
  92. package/lib/runtime/components/react/dist/mpx-web-view.d.ts +2 -1
  93. package/lib/runtime/components/react/dist/mpx-web-view.jsx +5 -1
  94. package/lib/runtime/components/react/dist/namedColorSet.d.ts +2 -0
  95. package/lib/runtime/components/react/dist/namedColorSet.js +149 -0
  96. package/lib/runtime/components/react/dist/utils.d.ts +71 -70
  97. package/lib/runtime/components/react/dist/utils.jsx +1295 -456
  98. package/lib/runtime/components/react/event.config.ts +32 -25
  99. package/lib/runtime/components/react/getInnerListeners.ts +84 -60
  100. package/lib/runtime/components/react/mpx-button.tsx +18 -18
  101. package/lib/runtime/components/react/mpx-camera.tsx +40 -8
  102. package/lib/runtime/components/react/mpx-canvas/index.tsx +5 -7
  103. package/lib/runtime/components/react/mpx-canvas/utils.tsx +3 -1
  104. package/lib/runtime/components/react/mpx-checkbox-group.tsx +2 -8
  105. package/lib/runtime/components/react/mpx-checkbox.tsx +9 -13
  106. package/lib/runtime/components/react/mpx-form.tsx +6 -8
  107. package/lib/runtime/components/react/mpx-icon/index.tsx +1 -5
  108. package/lib/runtime/components/react/mpx-image.tsx +66 -58
  109. package/lib/runtime/components/react/mpx-inline-text.tsx +13 -4
  110. package/lib/runtime/components/react/mpx-input.tsx +19 -12
  111. package/lib/runtime/components/react/mpx-label.tsx +6 -10
  112. package/lib/runtime/components/react/mpx-movable-area.tsx +3 -5
  113. package/lib/runtime/components/react/mpx-movable-view.tsx +7 -9
  114. package/lib/runtime/components/react/mpx-nav.tsx +1 -1
  115. package/lib/runtime/components/react/mpx-picker/index.tsx +100 -29
  116. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +3 -3
  117. package/lib/runtime/components/react/mpx-picker/selector.tsx +1 -1
  118. package/lib/runtime/components/react/mpx-picker/type.ts +4 -0
  119. package/lib/runtime/components/react/mpx-picker-view/index.tsx +17 -24
  120. package/lib/runtime/components/react/mpx-picker-view/pickerVIewContext.ts +0 -9
  121. package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +44 -23
  122. package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItem.tsx +1 -9
  123. package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItemLite.tsx +0 -9
  124. package/lib/runtime/components/react/mpx-popup/index.tsx +7 -3
  125. package/lib/runtime/components/react/mpx-popup/popupBase.tsx +3 -2
  126. package/lib/runtime/components/react/mpx-progress.tsx +0 -6
  127. package/lib/runtime/components/react/mpx-radio-group.tsx +2 -8
  128. package/lib/runtime/components/react/mpx-radio.tsx +9 -13
  129. package/lib/runtime/components/react/mpx-rich-text/index.tsx +0 -6
  130. package/lib/runtime/components/react/mpx-scroll-view.tsx +7 -9
  131. package/lib/runtime/components/react/mpx-section-list.tsx +557 -0
  132. package/lib/runtime/components/react/mpx-simple-text.tsx +36 -25
  133. package/lib/runtime/components/react/mpx-simple-view.tsx +17 -5
  134. package/lib/runtime/components/react/mpx-slider.tsx +15 -13
  135. package/lib/runtime/components/react/mpx-sticky-header.tsx +6 -8
  136. package/lib/runtime/components/react/mpx-sticky-section.tsx +7 -9
  137. package/lib/runtime/components/react/mpx-swiper-item.tsx +6 -7
  138. package/lib/runtime/components/react/mpx-swiper.tsx +5 -11
  139. package/lib/runtime/components/react/mpx-switch.tsx +0 -6
  140. package/lib/runtime/components/react/mpx-text.tsx +45 -36
  141. package/lib/runtime/components/react/mpx-video.tsx +3 -8
  142. package/lib/runtime/components/react/mpx-view.tsx +235 -129
  143. package/lib/runtime/components/react/mpx-web-view.tsx +12 -6
  144. package/lib/runtime/components/react/namedColorSet.ts +150 -0
  145. package/lib/runtime/components/react/types/getInnerListeners.d.ts +21 -1
  146. package/lib/runtime/components/react/types/global.d.ts +1 -0
  147. package/lib/runtime/components/react/utils.tsx +1352 -550
  148. package/lib/runtime/i18n.wxs +15 -9
  149. package/lib/style-compiler/strip-conditional.js +19 -4
  150. package/lib/template-compiler/compiler.js +6 -0
  151. package/package.json +6 -6
@@ -217,15 +217,16 @@ function parsePath (pathStr) {
217
217
  property = ''
218
218
  }
219
219
 
220
+ if (pathStr.indexOf('[') === -1 && pathStr.indexOf(']') === -1) {
221
+ // 对于简单数据路径,直接分割,避免无意义的解析
222
+ return pathStr.split('.')
223
+ }
224
+
220
225
  var curStack = genStack()
221
226
  var targetStacks = []
222
227
  var property = ''
223
228
  var index = 0
224
229
 
225
- if (genRegExp('^[^[]]+$').test(pathStr)) {
226
- // 对于简单数据路径,直接分割,避免无意义的解析
227
- return pathStr.split('.')
228
- }
229
230
  while (index < pathStr.length) {
230
231
  var char = pathStr[index]
231
232
  // 当前遍历引号内的字符串时
@@ -271,11 +272,16 @@ function getMessage (messages, locale, fallbackLocale, key) {
271
272
 
272
273
  function resolve (messages, locale, key) {
273
274
  if (messages && messages[locale] && key) {
274
- var format = getPathValue(messages[locale], key)
275
- if (format == null) {
276
- format = messages[locale][key]
277
- }
278
- return format
275
+ var localeMessages = messages[locale]
276
+ // 优先按「字面量 key」直查:形如 "1000+ reviews" 的扁平 key 含 '+',若先走 getPathValue
277
+ // 会被 parsePath 当成算术表达式求值('1000' + undefined = NaN),导致翻译失败。
278
+ // 字面量命中即返回,未命中再交给 getPathValue 解析嵌套路径(如 "nav.home")。
279
+ // 注意:这会让「扁平 key 与同名嵌套路径冲突」时由 nested 优先变为 flat 优先。
280
+ if (isDef(localeMessages[key])) return localeMessages[key]
281
+ var format = getPathValue(localeMessages, key)
282
+ // 含 '+' 的 key 在当前语言缺失时,getPathValue 仍可能返回 NaN。NaN 会被 isDef 当成
283
+ // 「已定义」而中断 getMessage 的 fallback,故归一成 undefined 以保留回退(format !== format 仅 NaN 成立)。
284
+ return format !== format ? undefined : format
279
285
  }
280
286
  }
281
287
 
@@ -13,11 +13,26 @@ class Node {
13
13
  function keepLines(content) {
14
14
  return content.replace(/([^\r\n]*)(\r\n|\r|\n|$)/g, (all, line, lineBreak) => {
15
15
  if (!all) return ''
16
+ // 空行 / 纯空白行直接保留换行:directive 自身被 blankDirective 抹平后,
17
+ // 其前后 text token 里夹缝 \n 形成的"空行"如果再放占位注释,会变成 col 0 的
18
+ // /* mpx-style-pad-placeholder */,破坏 stylus / sass 的 indent 结构。
19
+ // 这里产生的连续空行最多只有 directive 链长度量级(个位数),远低于 stylus
20
+ // lexer 栈溢出阈值,安全。
21
+ if (!line.trim()) return lineBreak
16
22
  const indent = (/^[ \t]*/.exec(line) || [''])[0]
17
23
  return `${indent}/* ${STYLE_PAD_PLACEHOLDER} */${lineBreak}`
18
24
  })
19
25
  }
20
26
 
27
+ // 仅保留换行、清掉所有非换行字符,让条件编译指令本身的列位置在
28
+ // 缩进敏感的预处理器(stylus / sass)中完全透明。
29
+ // 不能直接把整段都换成空行 —— stylus 的 lexer 在遇到大量连续空行时
30
+ // 会递归判定 outdent 层级,触发调用栈溢出;因此被剥离的"内容"仍走
31
+ // keepLines 走占位注释,只让"指令"这一行(通常 1 行)变成空行。
32
+ function blankDirective(content) {
33
+ return content.replace(/[^\r\n]+/g, '')
34
+ }
35
+
21
36
  // 提取 css string 为 token
22
37
  function tokenize(cssString) {
23
38
  // Support /* ... */, // ..., and <!-- ... --> styles
@@ -123,22 +138,22 @@ function traverseAndEvaluate(ast, defs) {
123
138
  output += active ? node.value : keepLines(node.value)
124
139
  } else if (node.type === 'If') {
125
140
  // 直接判断 If 节点
126
- output += keepLines(node.value)
141
+ output += blankDirective(node.value)
127
142
  const currentMatched = active && evaluateCondition(node.condition, defs)
128
143
  output += traverse(node.children, currentMatched)
129
144
  batchedIf = currentMatched
130
145
  } else if (node.type === 'ElseIf') {
131
- output += keepLines(node.value)
146
+ output += blankDirective(node.value)
132
147
  const currentMatched = active && !batchedIf && evaluateCondition(node.condition, defs)
133
148
  output += traverse(node.children, currentMatched)
134
149
  batchedIf = batchedIf || currentMatched
135
150
  } else if (node.type === 'Else') {
136
- output += keepLines(node.value)
151
+ output += blankDirective(node.value)
137
152
  const currentMatched = active && !batchedIf
138
153
  output += traverse(node.children, currentMatched)
139
154
  batchedIf = true
140
155
  } else if (node.type === 'EndIf') {
141
- output += keepLines(node.value)
156
+ output += blankDirective(node.value)
142
157
  }
143
158
  }
144
159
  return output
@@ -20,6 +20,8 @@ const { capitalToHyphen } = require('../utils/string')
20
20
  const { isNativeMiniTag } = require('../utils/dom-tag-config')
21
21
  const { offsetToLoc } = require('../utils/source-location')
22
22
 
23
+ const MPX_HOST_REF = '__mpxHost'
24
+
23
25
  const no = function () {
24
26
  return false
25
27
  }
@@ -2816,6 +2818,10 @@ function getVirtualHostRoot (options, meta) {
2816
2818
  {
2817
2819
  name: 'ishost',
2818
2820
  value: '{{true}}'
2821
+ },
2822
+ {
2823
+ name: config[mode].directive.ref,
2824
+ value: MPX_HOST_REF
2819
2825
  }
2820
2826
  ])
2821
2827
  processElement(rootView, rootView, options, meta)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.10.24",
3
+ "version": "2.11.0",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
@@ -29,9 +29,9 @@
29
29
  "@better-scroll/wheel": "^2.5.1",
30
30
  "@better-scroll/zoom": "^2.5.1",
31
31
  "@jridgewell/trace-mapping": "^0.3.25",
32
- "@mpxjs/perf": "^2.10.24",
32
+ "@mpxjs/perf": "^2.11.0",
33
33
  "@mpxjs/template-engine": "^2.8.7",
34
- "@mpxjs/utils": "^2.10.21",
34
+ "@mpxjs/utils": "^2.11.0",
35
35
  "acorn": "^8.11.3",
36
36
  "acorn-walk": "^7.2.0",
37
37
  "async": "^2.6.0",
@@ -93,7 +93,7 @@
93
93
  },
94
94
  "devDependencies": {
95
95
  "@d11/react-native-fast-image": "^8.6.12",
96
- "@mpxjs/api-proxy": "^2.10.21",
96
+ "@mpxjs/api-proxy": "^2.11.0",
97
97
  "@types/babel-traverse": "^6.25.4",
98
98
  "@types/babel-types": "^7.0.4",
99
99
  "@types/glob": "^8.1.0",
@@ -107,7 +107,7 @@
107
107
  "react-native-svg": "^15.8.0",
108
108
  "react-native-video": "^6.9.0",
109
109
  "react-native-vision-camera": "^4.7.2",
110
- "react-native-webview": "^13.12.2",
110
+ "react-native-webview": "^13.17.0",
111
111
  "rimraf": "^6.0.1",
112
112
  "vue": "^2.7.16",
113
113
  "webpack": "^5.75.0"
@@ -115,5 +115,5 @@
115
115
  "engines": {
116
116
  "node": ">=14.14.0"
117
117
  },
118
- "gitHead": "0fd557e03e51d93231c063f9145ec0ff0746c935"
118
+ "gitHead": "14548ee8e1f00f6be64f848e4fbdab194d642bf6"
119
119
  }