@mpxjs/webpack-plugin 2.9.64 → 2.9.65
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/config.js +38 -10
- package/lib/platform/style/wx/index.js +52 -17
- package/lib/platform/template/wx/index.js +12 -8
- package/lib/react/style-helper.js +2 -5
- package/lib/runtime/components/react/dist/mpx-button.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +3 -2
- package/lib/runtime/components/react/dist/mpx-form.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-icon.jsx +3 -2
- package/lib/runtime/components/react/dist/mpx-image/index.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-input.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-label.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +3 -2
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-picker/date.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-picker/region.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +4 -2
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +3 -2
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-radio.jsx +3 -2
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +3 -1
- package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +3 -2
- package/lib/runtime/components/react/dist/mpx-switch.jsx +3 -2
- package/lib/runtime/components/react/dist/mpx-text.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-view.jsx +15 -4
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +3 -2
- package/lib/runtime/components/react/dist/useNodesRef.js +1 -5
- package/lib/runtime/components/react/dist/utils.jsx +48 -36
- package/lib/runtime/components/react/mpx-button.tsx +3 -1
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +3 -1
- package/lib/runtime/components/react/mpx-checkbox.tsx +4 -1
- package/lib/runtime/components/react/mpx-form.tsx +2 -1
- package/lib/runtime/components/react/mpx-icon.tsx +3 -2
- package/lib/runtime/components/react/mpx-image/index.tsx +2 -1
- package/lib/runtime/components/react/mpx-input.tsx +2 -1
- package/lib/runtime/components/react/mpx-label.tsx +2 -1
- package/lib/runtime/components/react/mpx-movable-area.tsx +3 -2
- package/lib/runtime/components/react/mpx-movable-view.tsx +2 -1
- package/lib/runtime/components/react/mpx-picker/date.tsx +2 -1
- package/lib/runtime/components/react/mpx-picker/index.tsx +2 -1
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +2 -1
- package/lib/runtime/components/react/mpx-picker/region.tsx +2 -1
- package/lib/runtime/components/react/mpx-picker/selector.tsx +2 -1
- package/lib/runtime/components/react/mpx-picker/time.tsx +4 -2
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +3 -2
- package/lib/runtime/components/react/mpx-picker-view.tsx +2 -1
- package/lib/runtime/components/react/mpx-radio-group.tsx +2 -1
- package/lib/runtime/components/react/mpx-radio.tsx +3 -2
- package/lib/runtime/components/react/mpx-scroll-view.tsx +3 -1
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +2 -1
- package/lib/runtime/components/react/mpx-swiper/index.tsx +4 -1
- package/lib/runtime/components/react/mpx-swiper-item.tsx +2 -1
- package/lib/runtime/components/react/mpx-switch.tsx +2 -1
- package/lib/runtime/components/react/mpx-text.tsx +2 -1
- package/lib/runtime/components/react/mpx-view.tsx +16 -4
- package/lib/runtime/components/react/mpx-web-view.tsx +3 -2
- package/lib/runtime/components/react/types/global.d.ts +11 -1
- package/lib/runtime/components/react/useNodesRef.ts +1 -6
- package/lib/runtime/components/react/utils.tsx +65 -46
- package/lib/runtime/components/web/mpx-scroll-view.vue +25 -5
- package/lib/style-compiler/index.js +5 -4
- package/lib/template-compiler/compiler.js +105 -141
- package/lib/utils/const.js +2 -1
- package/lib/web/processStyles.js +6 -2
- package/lib/web/processTemplate.js +2 -3
- package/lib/wxml/loader.js +1 -1
- package/package.json +5 -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 } = require('../utils/const')
|
|
4
|
+
const { MPX_ROOT_VIEW, MPX_APP_MODULE_ID, PARENT_MODULE_ID } = 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,7 @@ 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 } = require('../utils/env')
|
|
18
|
+
const { isReact, isWeb } = require('../utils/env')
|
|
19
19
|
|
|
20
20
|
const no = function () {
|
|
21
21
|
return false
|
|
@@ -887,7 +887,7 @@ function postMoveBaseDirective (target, source, isDelete = true) {
|
|
|
887
887
|
}
|
|
888
888
|
|
|
889
889
|
function stringify (str) {
|
|
890
|
-
if (mode
|
|
890
|
+
if (isWeb(mode)) str = str.replace(/'/g, '"')
|
|
891
891
|
return JSON.stringify(str)
|
|
892
892
|
}
|
|
893
893
|
|
|
@@ -2051,7 +2051,7 @@ function processWrapTextReact (el) {
|
|
|
2051
2051
|
// }
|
|
2052
2052
|
|
|
2053
2053
|
function injectWxs (meta, module, src) {
|
|
2054
|
-
if (runtimeCompile || addWxsModule(meta, module, src) || isReact(mode)) {
|
|
2054
|
+
if (runtimeCompile || addWxsModule(meta, module, src) || isReact(mode) || isWeb(mode)) {
|
|
2055
2055
|
return
|
|
2056
2056
|
}
|
|
2057
2057
|
|
|
@@ -2139,96 +2139,76 @@ function isComponentNode (el, options) {
|
|
|
2139
2139
|
return options.usingComponents.indexOf(el.tag) !== -1 || el.tag === 'component'
|
|
2140
2140
|
}
|
|
2141
2141
|
|
|
2142
|
-
function
|
|
2142
|
+
function processExternalClasses (el, options) {
|
|
2143
2143
|
const isComponent = isComponentNode(el, options)
|
|
2144
|
-
// 处理组件externalClass多层传递
|
|
2145
2144
|
const classLikeAttrNames = isComponent ? ['class'].concat(options.externalClasses) : ['class']
|
|
2145
|
+
|
|
2146
2146
|
classLikeAttrNames.forEach((classLikeAttrName) => {
|
|
2147
|
-
|
|
2147
|
+
const classLikeAttrValue = getAndRemoveAttr(el, classLikeAttrName).val
|
|
2148
2148
|
if (classLikeAttrValue) {
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
}
|
|
2154
|
-
addAttrs(el, [{
|
|
2155
|
-
name: classLikeAttrName,
|
|
2156
|
-
value: classLikeAttrValue
|
|
2157
|
-
}])
|
|
2149
|
+
if (mode === 'web') {
|
|
2150
|
+
processWebClass(classLikeAttrName, classLikeAttrValue, el, options)
|
|
2151
|
+
} else {
|
|
2152
|
+
processAliClass(classLikeAttrName, classLikeAttrValue, el, options)
|
|
2153
|
+
}
|
|
2158
2154
|
}
|
|
2159
2155
|
})
|
|
2160
2156
|
|
|
2161
2157
|
if (hasScoped && isComponent) {
|
|
2162
|
-
options.externalClasses.
|
|
2163
|
-
|
|
2164
|
-
if (externalClass) {
|
|
2165
|
-
addAttrs(el, [{
|
|
2166
|
-
name: className,
|
|
2167
|
-
value: `${externalClass} ${moduleId}`
|
|
2168
|
-
}])
|
|
2169
|
-
}
|
|
2170
|
-
})
|
|
2171
|
-
}
|
|
2172
|
-
}
|
|
2173
|
-
|
|
2174
|
-
// externalClasses只能模拟静态传递
|
|
2175
|
-
function processWebExternalClassesHack (el, options) {
|
|
2176
|
-
const staticClass = getAndRemoveAttr(el, 'class').val
|
|
2177
|
-
if (staticClass) {
|
|
2178
|
-
const classNames = staticClass.split(/\s+/)
|
|
2179
|
-
const replacements = []
|
|
2180
|
-
options.externalClasses.forEach((className) => {
|
|
2181
|
-
const index = classNames.indexOf(className)
|
|
2182
|
-
if (index > -1) {
|
|
2183
|
-
replacements.push(`$attrs[${stringify(className)}]`)
|
|
2184
|
-
classNames.splice(index, 1)
|
|
2185
|
-
}
|
|
2158
|
+
const needAddModuleId = options.externalClasses.some((className) => {
|
|
2159
|
+
return el.attrsMap[className] || (mode === 'web' && el.attrsMap[':' + className])
|
|
2186
2160
|
})
|
|
2187
2161
|
|
|
2188
|
-
if (
|
|
2162
|
+
if (needAddModuleId) {
|
|
2189
2163
|
addAttrs(el, [{
|
|
2190
|
-
name:
|
|
2191
|
-
value:
|
|
2164
|
+
name: PARENT_MODULE_ID,
|
|
2165
|
+
value: `${moduleId}`
|
|
2192
2166
|
}])
|
|
2193
2167
|
}
|
|
2194
|
-
|
|
2195
|
-
|
|
2168
|
+
}
|
|
2169
|
+
function processWebClass (classLikeAttrName, classLikeAttrValue, el, options) {
|
|
2170
|
+
let classNames = classLikeAttrValue.split(/\s+/)
|
|
2171
|
+
let hasExternalClass = false
|
|
2172
|
+
classNames = classNames.map((className) => {
|
|
2173
|
+
if (options.externalClasses.includes(className)) {
|
|
2174
|
+
hasExternalClass = true
|
|
2175
|
+
return `($attrs[${stringify(className)}] || '')`
|
|
2176
|
+
}
|
|
2177
|
+
return stringify(className)
|
|
2178
|
+
})
|
|
2179
|
+
if (hasExternalClass) {
|
|
2180
|
+
classNames.push(`($attrs[${stringify(PARENT_MODULE_ID)}] || '')`)
|
|
2181
|
+
}
|
|
2182
|
+
if (classLikeAttrName === 'class') {
|
|
2196
2183
|
const dynamicClass = getAndRemoveAttr(el, ':class').val
|
|
2197
|
-
if (dynamicClass)
|
|
2198
|
-
|
|
2184
|
+
if (dynamicClass) classNames.push(dynamicClass)
|
|
2199
2185
|
addAttrs(el, [{
|
|
2200
2186
|
name: ':class',
|
|
2201
|
-
value: `[${
|
|
2187
|
+
value: `[${classNames}]`
|
|
2188
|
+
}])
|
|
2189
|
+
} else {
|
|
2190
|
+
addAttrs(el, [{
|
|
2191
|
+
name: ':' + classLikeAttrName,
|
|
2192
|
+
value: `[${classNames}].join(' ')`
|
|
2202
2193
|
}])
|
|
2203
2194
|
}
|
|
2204
2195
|
}
|
|
2205
2196
|
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
const
|
|
2211
|
-
if (classLikeAttrValue)
|
|
2212
|
-
|
|
2213
|
-
const replacements = []
|
|
2214
|
-
options.externalClasses.forEach((className) => {
|
|
2215
|
-
const index = classNames.indexOf(className)
|
|
2216
|
-
if (index > -1) {
|
|
2217
|
-
replacements.push(`$attrs[${stringify(className)}]`)
|
|
2218
|
-
classNames.splice(index, 1)
|
|
2219
|
-
}
|
|
2220
|
-
})
|
|
2221
|
-
|
|
2222
|
-
if (classNames.length) {
|
|
2223
|
-
replacements.unshift(stringify(classNames.join(' ')))
|
|
2224
|
-
}
|
|
2225
|
-
|
|
2226
|
-
addAttrs(el, [{
|
|
2227
|
-
name: ':' + classLikeAttrName,
|
|
2228
|
-
value: `[${replacements}].join(' ')`
|
|
2229
|
-
}])
|
|
2230
|
-
}
|
|
2197
|
+
function processAliClass (classLikeAttrName, classLikeAttrValue, el, options) {
|
|
2198
|
+
let hasExternalClass = false
|
|
2199
|
+
options.externalClasses.forEach((className) => {
|
|
2200
|
+
const reg = new RegExp('\\b' + className + '\\b', 'g')
|
|
2201
|
+
const replacementClassName = dash2hump(className)
|
|
2202
|
+
if (classLikeAttrValue.includes(className)) hasExternalClass = true
|
|
2203
|
+
classLikeAttrValue = classLikeAttrValue.replace(reg, `{{${replacementClassName} || ''}}`)
|
|
2231
2204
|
})
|
|
2205
|
+
if (hasExternalClass) {
|
|
2206
|
+
classLikeAttrValue += ` {{${PARENT_MODULE_ID} || ''}}`
|
|
2207
|
+
}
|
|
2208
|
+
addAttrs(el, [{
|
|
2209
|
+
name: classLikeAttrName,
|
|
2210
|
+
value: classLikeAttrValue
|
|
2211
|
+
}])
|
|
2232
2212
|
}
|
|
2233
2213
|
}
|
|
2234
2214
|
|
|
@@ -2336,7 +2316,7 @@ function getVirtualHostRoot (options, meta) {
|
|
|
2336
2316
|
meta.options = meta.options || {}
|
|
2337
2317
|
meta.options.virtualHost = true
|
|
2338
2318
|
}
|
|
2339
|
-
if (mode
|
|
2319
|
+
if (isWeb(mode) && !hasVirtualHost) {
|
|
2340
2320
|
// ali组件根节点实体化
|
|
2341
2321
|
const rootView = createASTElement('view', [
|
|
2342
2322
|
{
|
|
@@ -2367,7 +2347,7 @@ function getVirtualHostRoot (options, meta) {
|
|
|
2367
2347
|
return rootView
|
|
2368
2348
|
}
|
|
2369
2349
|
}
|
|
2370
|
-
if (mode
|
|
2350
|
+
if (isWeb(mode) && ctorType === 'page') {
|
|
2371
2351
|
return createASTElement('page')
|
|
2372
2352
|
}
|
|
2373
2353
|
}
|
|
@@ -2375,36 +2355,24 @@ function getVirtualHostRoot (options, meta) {
|
|
|
2375
2355
|
}
|
|
2376
2356
|
|
|
2377
2357
|
function processShow (el, options, root) {
|
|
2378
|
-
// 开启 virtualhost 全部走 props 传递处理
|
|
2379
|
-
// 未开启 virtualhost 直接绑定 display:none 到节点上
|
|
2380
2358
|
let { val: show, has } = getAndRemoveAttr(el, config[mode].directive.show)
|
|
2381
2359
|
if (mode === 'swan') show = wrapMustache(show)
|
|
2382
2360
|
if (has && show === undefined) {
|
|
2383
2361
|
error$1(`Attrs ${config[mode].directive.show} should have a value `)
|
|
2362
|
+
return
|
|
2384
2363
|
}
|
|
2385
|
-
if (
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
}
|
|
2392
|
-
}
|
|
2393
|
-
if (isComponentNode(el, options) && show !== undefined) {
|
|
2394
|
-
if (show === '') {
|
|
2395
|
-
show = '{{false}}'
|
|
2396
|
-
}
|
|
2397
|
-
addAttrs(el, [{
|
|
2398
|
-
name: 'mpxShow',
|
|
2399
|
-
value: show
|
|
2400
|
-
}])
|
|
2401
|
-
} else {
|
|
2402
|
-
if (runtimeCompile) {
|
|
2403
|
-
processShowStyleDynamic(el, show)
|
|
2404
|
-
} else {
|
|
2405
|
-
processShowStyle(el, show)
|
|
2406
|
-
}
|
|
2364
|
+
if (ctorType === 'component' && el.parent === root && isRealNode(el)) {
|
|
2365
|
+
show = has ? `{{${parseMustacheWithContext(show).result}&&mpxShow}}` : '{{mpxShow}}'
|
|
2366
|
+
}
|
|
2367
|
+
if (show === undefined) return
|
|
2368
|
+
if (isComponentNode(el, options)) {
|
|
2369
|
+
if (show === '') {
|
|
2370
|
+
show = '{{false}}'
|
|
2407
2371
|
}
|
|
2372
|
+
addAttrs(el, [{
|
|
2373
|
+
name: 'mpxShow',
|
|
2374
|
+
value: show
|
|
2375
|
+
}])
|
|
2408
2376
|
} else {
|
|
2409
2377
|
if (runtimeCompile) {
|
|
2410
2378
|
processShowStyleDynamic(el, show)
|
|
@@ -2415,15 +2383,13 @@ function processShow (el, options, root) {
|
|
|
2415
2383
|
}
|
|
2416
2384
|
|
|
2417
2385
|
function processShowStyle (el, show) {
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
}])
|
|
2426
|
-
}
|
|
2386
|
+
const showExp = parseMustacheWithContext(show).result
|
|
2387
|
+
let oldStyle = getAndRemoveAttr(el, 'style').val
|
|
2388
|
+
oldStyle = oldStyle ? oldStyle + ';' : ''
|
|
2389
|
+
addAttrs(el, [{
|
|
2390
|
+
name: 'style',
|
|
2391
|
+
value: `${oldStyle}{{${showExp}?'':'display:none;'}}`
|
|
2392
|
+
}])
|
|
2427
2393
|
}
|
|
2428
2394
|
|
|
2429
2395
|
function processTemplate (el) {
|
|
@@ -2610,12 +2576,14 @@ function processElement (el, root, options, meta) {
|
|
|
2610
2576
|
|
|
2611
2577
|
const transAli = mode === 'ali' && srcMode === 'wx'
|
|
2612
2578
|
|
|
2613
|
-
if (mode
|
|
2579
|
+
if (isWeb(mode)) {
|
|
2614
2580
|
// 收集内建组件
|
|
2615
2581
|
processBuiltInComponents(el, meta)
|
|
2616
2582
|
// 预处理代码维度条件编译
|
|
2617
2583
|
processIfWeb(el)
|
|
2618
|
-
|
|
2584
|
+
processScoped(el)
|
|
2585
|
+
// processWebExternalClassesHack(el, options)
|
|
2586
|
+
processExternalClasses(el, options)
|
|
2619
2587
|
processComponentGenericsWeb(el, options, meta)
|
|
2620
2588
|
return
|
|
2621
2589
|
}
|
|
@@ -2635,7 +2603,7 @@ function processElement (el, root, options, meta) {
|
|
|
2635
2603
|
return
|
|
2636
2604
|
}
|
|
2637
2605
|
|
|
2638
|
-
const
|
|
2606
|
+
const isTemplate = processTemplate(el) || processingTemplate
|
|
2639
2607
|
|
|
2640
2608
|
// 仅ali平台需要scoped模拟样式隔离
|
|
2641
2609
|
if (mode === 'ali') {
|
|
@@ -2643,24 +2611,25 @@ function processElement (el, root, options, meta) {
|
|
|
2643
2611
|
}
|
|
2644
2612
|
|
|
2645
2613
|
if (transAli) {
|
|
2646
|
-
processAliExternalClassesHack(el, options)
|
|
2614
|
+
// processAliExternalClassesHack(el, options)
|
|
2615
|
+
processExternalClasses(el, options)
|
|
2647
2616
|
}
|
|
2648
2617
|
|
|
2649
2618
|
processIf(el)
|
|
2650
2619
|
processFor(el)
|
|
2651
2620
|
|
|
2652
|
-
if (!
|
|
2653
|
-
processRef(el, options, meta)
|
|
2621
|
+
if (!isNative) {
|
|
2622
|
+
if (!isTemplate) processRef(el, options, meta)
|
|
2654
2623
|
if (runtimeCompile) {
|
|
2655
|
-
processClassDynamic(el
|
|
2656
|
-
processStyleDynamic(el
|
|
2624
|
+
processClassDynamic(el)
|
|
2625
|
+
processStyleDynamic(el)
|
|
2657
2626
|
} else {
|
|
2658
2627
|
processClass(el, meta)
|
|
2659
2628
|
processStyle(el, meta)
|
|
2660
2629
|
}
|
|
2661
2630
|
processShow(el, options, root)
|
|
2662
2631
|
processEvent(el, options)
|
|
2663
|
-
processComponentIs(el, options)
|
|
2632
|
+
if (!isTemplate) processComponentIs(el, options)
|
|
2664
2633
|
}
|
|
2665
2634
|
|
|
2666
2635
|
processAttrs(el, options)
|
|
@@ -2668,23 +2637,21 @@ function processElement (el, root, options, meta) {
|
|
|
2668
2637
|
|
|
2669
2638
|
function closeElement (el, meta, options) {
|
|
2670
2639
|
postProcessAtMode(el)
|
|
2671
|
-
|
|
2640
|
+
postProcessWxs(el, meta)
|
|
2672
2641
|
|
|
2673
|
-
if (mode
|
|
2674
|
-
postProcessWxs(el, meta)
|
|
2642
|
+
if (isWeb(mode)) {
|
|
2675
2643
|
// 处理代码维度条件编译移除死分支
|
|
2676
2644
|
postProcessIf(el)
|
|
2677
2645
|
return
|
|
2678
2646
|
}
|
|
2679
2647
|
if (isReact(mode)) {
|
|
2680
|
-
postProcessWxs(el, meta)
|
|
2681
2648
|
postProcessForReact(el)
|
|
2682
2649
|
postProcessIfReact(el)
|
|
2683
2650
|
return
|
|
2684
2651
|
}
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
if (!
|
|
2652
|
+
|
|
2653
|
+
const isTemplate = postProcessTemplate(el) || processingTemplate
|
|
2654
|
+
if (!isNative && !isTemplate) {
|
|
2688
2655
|
if (isComponentNode(el, options) && !hasVirtualHost && mode === 'ali') {
|
|
2689
2656
|
postProcessAliComponentRootView(el, options, meta)
|
|
2690
2657
|
}
|
|
@@ -2694,6 +2661,7 @@ function closeElement (el, meta, options) {
|
|
|
2694
2661
|
if (runtimeCompile) {
|
|
2695
2662
|
postProcessForDynamic(el, config[mode])
|
|
2696
2663
|
postProcessIfDynamic(el, config[mode])
|
|
2664
|
+
collectDynamicInfo(el, options, meta)
|
|
2697
2665
|
postProcessAttrsDynamic(el, config[mode])
|
|
2698
2666
|
} else {
|
|
2699
2667
|
postProcessFor(el)
|
|
@@ -2796,9 +2764,7 @@ function serialize (root) {
|
|
|
2796
2764
|
result += node.text
|
|
2797
2765
|
}
|
|
2798
2766
|
}
|
|
2799
|
-
|
|
2800
|
-
return result
|
|
2801
|
-
}
|
|
2767
|
+
|
|
2802
2768
|
if (node.type === 1) {
|
|
2803
2769
|
if (node.tag !== 'temp-node') {
|
|
2804
2770
|
result += '<' + node.tag
|
|
@@ -2968,11 +2934,11 @@ function processIfConditionsDynamic (el) {
|
|
|
2968
2934
|
block: el,
|
|
2969
2935
|
__exp: el.elseif ? parseExp(el.elseif.exp) : ''
|
|
2970
2936
|
})
|
|
2971
|
-
removeNode(el)
|
|
2937
|
+
removeNode(el, true)
|
|
2972
2938
|
}
|
|
2973
2939
|
}
|
|
2974
2940
|
|
|
2975
|
-
function processClassDynamic (el
|
|
2941
|
+
function processClassDynamic (el) {
|
|
2976
2942
|
const type = 'class'
|
|
2977
2943
|
const targetType = type
|
|
2978
2944
|
const dynamicClass = getAndRemoveAttr(el, config[mode].directive.dynamicClass).val
|
|
@@ -2995,7 +2961,7 @@ function processClassDynamic (el, meta) {
|
|
|
2995
2961
|
}
|
|
2996
2962
|
}
|
|
2997
2963
|
|
|
2998
|
-
function processStyleDynamic (el
|
|
2964
|
+
function processStyleDynamic (el) {
|
|
2999
2965
|
const type = 'style'
|
|
3000
2966
|
const targetType = type
|
|
3001
2967
|
const dynamicStyle = getAndRemoveAttr(el, config[mode].directive.dynamicStyle).val
|
|
@@ -3084,17 +3050,15 @@ function postProcessAttrsDynamic (vnode, config) {
|
|
|
3084
3050
|
}
|
|
3085
3051
|
|
|
3086
3052
|
function processShowStyleDynamic (el, show) {
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
}])
|
|
3097
|
-
}
|
|
3053
|
+
const showExp = parseMustacheWithContext(show).result
|
|
3054
|
+
const oldStyle = getAndRemoveAttr(el, 'style').val
|
|
3055
|
+
const displayExp = `${showExp}? '' : "display:none;"`
|
|
3056
|
+
const isArray = oldStyle?.endsWith(']}}')
|
|
3057
|
+
const value = isArray ? oldStyle?.replace(']}}', `,${displayExp}]}}`) : `${oldStyle ? `${oldStyle};` : ''}{{${displayExp}}}`
|
|
3058
|
+
addAttrs(el, [{
|
|
3059
|
+
name: 'style',
|
|
3060
|
+
value: value
|
|
3061
|
+
}])
|
|
3098
3062
|
}
|
|
3099
3063
|
|
|
3100
3064
|
module.exports = {
|
package/lib/utils/const.js
CHANGED
|
@@ -5,5 +5,6 @@ module.exports = {
|
|
|
5
5
|
RESOLVE_IGNORED_ERR: new Error('Resolve ignored!'),
|
|
6
6
|
JSON_JS_EXT: '.json.js',
|
|
7
7
|
MPX_ROOT_VIEW: 'mpx-root-view', // 根节点类名
|
|
8
|
-
MPX_APP_MODULE_ID: 'mpx-app-scope' // app文件moduleId
|
|
8
|
+
MPX_APP_MODULE_ID: 'mpx-app-scope', // app文件moduleId
|
|
9
|
+
PARENT_MODULE_ID: '__pid'
|
|
9
10
|
}
|
package/lib/web/processStyles.js
CHANGED
|
@@ -8,8 +8,12 @@ module.exports = function (styles, options, callback) {
|
|
|
8
8
|
attrs (style) {
|
|
9
9
|
const attrs = Object.assign({}, style.attrs)
|
|
10
10
|
if (options.autoScope) attrs.scoped = true
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
attrs.mpxStyleOptions = JSON.stringify({
|
|
12
|
+
scoped: attrs.scoped,
|
|
13
|
+
// query中包含module字符串会被新版vue-cli中的默认rules当做css-module处理
|
|
14
|
+
mid: options.moduleId
|
|
15
|
+
})
|
|
16
|
+
delete attrs.scoped
|
|
13
17
|
return attrs
|
|
14
18
|
}
|
|
15
19
|
})
|
|
@@ -6,7 +6,7 @@ const { matchCondition } = require('../utils/match-condition')
|
|
|
6
6
|
|
|
7
7
|
module.exports = function (template, {
|
|
8
8
|
loaderContext,
|
|
9
|
-
|
|
9
|
+
hasScoped,
|
|
10
10
|
hasComment,
|
|
11
11
|
isNative,
|
|
12
12
|
srcMode,
|
|
@@ -83,8 +83,7 @@ module.exports = function (template, {
|
|
|
83
83
|
defs,
|
|
84
84
|
decodeHTMLText,
|
|
85
85
|
externalClasses,
|
|
86
|
-
|
|
87
|
-
hasScoped: false,
|
|
86
|
+
hasScoped,
|
|
88
87
|
moduleId,
|
|
89
88
|
filePath: resourcePath,
|
|
90
89
|
i18n: null,
|
package/lib/wxml/loader.js
CHANGED
|
@@ -22,7 +22,7 @@ module.exports = function (content) {
|
|
|
22
22
|
const { queryObj } = parseRequest(this.resource)
|
|
23
23
|
const hasScoped = false
|
|
24
24
|
const hasComment = false
|
|
25
|
-
const isNative =
|
|
25
|
+
const isNative = false
|
|
26
26
|
|
|
27
27
|
const mode = mpx.mode
|
|
28
28
|
const localSrcMode = queryObj.mode
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.65",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@better-scroll/wheel": "^2.5.1",
|
|
29
29
|
"@better-scroll/zoom": "^2.5.1",
|
|
30
30
|
"@mpxjs/template-engine": "^2.8.7",
|
|
31
|
-
"@mpxjs/utils": "^2.9.
|
|
31
|
+
"@mpxjs/utils": "^2.9.65",
|
|
32
32
|
"acorn": "^8.11.3",
|
|
33
33
|
"acorn-walk": "^7.2.0",
|
|
34
34
|
"async": "^2.6.0",
|
|
@@ -82,18 +82,19 @@
|
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
84
|
"@ant-design/react-native": "^5.2.2",
|
|
85
|
-
"@mpxjs/api-proxy": "^2.9.
|
|
85
|
+
"@mpxjs/api-proxy": "^2.9.65",
|
|
86
86
|
"@types/babel-traverse": "^6.25.4",
|
|
87
87
|
"@types/babel-types": "^7.0.4",
|
|
88
88
|
"@types/react": "^18.2.79",
|
|
89
89
|
"react-native": "^0.74.5",
|
|
90
90
|
"react-native-gesture-handler": "^2.18.1",
|
|
91
91
|
"react-native-linear-gradient": "^2.8.3",
|
|
92
|
+
"react-native-safe-area-context": "^4.12.0",
|
|
92
93
|
"react-native-webview": "^13.12.2",
|
|
93
94
|
"rimraf": "^6.0.1"
|
|
94
95
|
},
|
|
95
96
|
"engines": {
|
|
96
97
|
"node": ">=14.14.0"
|
|
97
98
|
},
|
|
98
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "24efa90e90b4d42c285ca61739cb9e4d0696976c"
|
|
99
100
|
}
|