@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.
- package/lib/index.js +4 -1
- package/lib/platform/style/wx/index.js +417 -120
- package/lib/platform/template/wx/component-config/picker.js +0 -6
- package/lib/react/style-helper.js +6 -6
- package/lib/resolver/AddEnvPlugin.js +1 -1
- package/lib/resolver/AddModePlugin.js +1 -1
- package/lib/resolver/ExtendComponentsPlugin.js +68 -0
- package/lib/runtime/components/extends/section-list.mpx +14 -0
- package/lib/runtime/components/react/animationHooks/index.ts +7 -3
- package/lib/runtime/components/react/dist/animationHooks/index.d.ts +0 -2
- package/lib/runtime/components/react/dist/animationHooks/index.js +6 -1
- package/lib/runtime/components/react/dist/event.config.d.ts +2 -6
- package/lib/runtime/components/react/dist/event.config.js +28 -24
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts +1 -1
- package/lib/runtime/components/react/dist/getInnerListeners.js +74 -56
- package/lib/runtime/components/react/dist/mpx-button.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-button.jsx +16 -9
- package/lib/runtime/components/react/dist/mpx-camera.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-camera.jsx +36 -5
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +1 -3
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +3 -4
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +8 -9
- package/lib/runtime/components/react/dist/mpx-form.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-form.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-icon/index.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-image.jsx +59 -43
- package/lib/runtime/components/react/dist/mpx-inline-text.jsx +13 -4
- package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-input.jsx +16 -8
- package/lib/runtime/components/react/dist/mpx-label.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-label.jsx +5 -6
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +3 -3
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-nav.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +72 -23
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +4 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +10 -14
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.js +0 -5
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +34 -14
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.jsx +4 -5
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +3 -5
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +5 -4
- package/lib/runtime/components/react/dist/mpx-popup/index.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.jsx +3 -2
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-progress.jsx +1 -3
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +3 -4
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-radio.jsx +8 -9
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +1 -3
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-section-list.d.ts +51 -0
- package/lib/runtime/components/react/dist/mpx-section-list.jsx +376 -0
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +37 -19
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +4 -1
- package/lib/runtime/components/react/dist/mpx-simple-view.jsx +11 -4
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-slider.jsx +6 -7
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +4 -8
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-switch.jsx +1 -3
- package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-text.jsx +43 -25
- package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-video.jsx +4 -5
- package/lib/runtime/components/react/dist/mpx-view.d.ts +2 -2
- package/lib/runtime/components/react/dist/mpx-view.jsx +214 -114
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts +2 -1
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +5 -1
- package/lib/runtime/components/react/dist/namedColorSet.d.ts +2 -0
- package/lib/runtime/components/react/dist/namedColorSet.js +149 -0
- package/lib/runtime/components/react/dist/utils.d.ts +71 -70
- package/lib/runtime/components/react/dist/utils.jsx +1295 -456
- package/lib/runtime/components/react/event.config.ts +32 -25
- package/lib/runtime/components/react/getInnerListeners.ts +84 -60
- package/lib/runtime/components/react/mpx-button.tsx +18 -18
- package/lib/runtime/components/react/mpx-camera.tsx +40 -8
- package/lib/runtime/components/react/mpx-canvas/index.tsx +5 -7
- package/lib/runtime/components/react/mpx-canvas/utils.tsx +3 -1
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +2 -8
- package/lib/runtime/components/react/mpx-checkbox.tsx +9 -13
- package/lib/runtime/components/react/mpx-form.tsx +6 -8
- package/lib/runtime/components/react/mpx-icon/index.tsx +1 -5
- package/lib/runtime/components/react/mpx-image.tsx +66 -58
- package/lib/runtime/components/react/mpx-inline-text.tsx +13 -4
- package/lib/runtime/components/react/mpx-input.tsx +19 -12
- package/lib/runtime/components/react/mpx-label.tsx +6 -10
- package/lib/runtime/components/react/mpx-movable-area.tsx +3 -5
- package/lib/runtime/components/react/mpx-movable-view.tsx +7 -9
- package/lib/runtime/components/react/mpx-nav.tsx +1 -1
- package/lib/runtime/components/react/mpx-picker/index.tsx +100 -29
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +3 -3
- package/lib/runtime/components/react/mpx-picker/selector.tsx +1 -1
- package/lib/runtime/components/react/mpx-picker/type.ts +4 -0
- package/lib/runtime/components/react/mpx-picker-view/index.tsx +17 -24
- package/lib/runtime/components/react/mpx-picker-view/pickerVIewContext.ts +0 -9
- package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +44 -23
- package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItem.tsx +1 -9
- package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItemLite.tsx +0 -9
- package/lib/runtime/components/react/mpx-popup/index.tsx +7 -3
- package/lib/runtime/components/react/mpx-popup/popupBase.tsx +3 -2
- package/lib/runtime/components/react/mpx-progress.tsx +0 -6
- package/lib/runtime/components/react/mpx-radio-group.tsx +2 -8
- package/lib/runtime/components/react/mpx-radio.tsx +9 -13
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +0 -6
- package/lib/runtime/components/react/mpx-scroll-view.tsx +7 -9
- package/lib/runtime/components/react/mpx-section-list.tsx +557 -0
- package/lib/runtime/components/react/mpx-simple-text.tsx +36 -25
- package/lib/runtime/components/react/mpx-simple-view.tsx +17 -5
- package/lib/runtime/components/react/mpx-slider.tsx +15 -13
- package/lib/runtime/components/react/mpx-sticky-header.tsx +6 -8
- package/lib/runtime/components/react/mpx-sticky-section.tsx +7 -9
- package/lib/runtime/components/react/mpx-swiper-item.tsx +6 -7
- package/lib/runtime/components/react/mpx-swiper.tsx +5 -11
- package/lib/runtime/components/react/mpx-switch.tsx +0 -6
- package/lib/runtime/components/react/mpx-text.tsx +45 -36
- package/lib/runtime/components/react/mpx-video.tsx +3 -8
- package/lib/runtime/components/react/mpx-view.tsx +235 -129
- package/lib/runtime/components/react/mpx-web-view.tsx +12 -6
- package/lib/runtime/components/react/namedColorSet.ts +150 -0
- package/lib/runtime/components/react/types/getInnerListeners.d.ts +21 -1
- package/lib/runtime/components/react/types/global.d.ts +1 -0
- package/lib/runtime/components/react/utils.tsx +1352 -550
- package/lib/runtime/i18n.wxs +15 -9
- package/lib/style-compiler/strip-conditional.js +19 -4
- package/lib/template-compiler/compiler.js +6 -0
- package/package.json +6 -6
package/lib/runtime/i18n.wxs
CHANGED
|
@@ -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
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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 +=
|
|
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 +=
|
|
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 +=
|
|
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 +=
|
|
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.
|
|
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.
|
|
32
|
+
"@mpxjs/perf": "^2.11.0",
|
|
33
33
|
"@mpxjs/template-engine": "^2.8.7",
|
|
34
|
-
"@mpxjs/utils": "^2.
|
|
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.
|
|
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.
|
|
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": "
|
|
118
|
+
"gitHead": "14548ee8e1f00f6be64f848e4fbdab194d642bf6"
|
|
119
119
|
}
|