@mpxjs/webpack-plugin 2.9.62 → 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/index.js +1 -3
- package/lib/platform/style/wx/index.js +115 -66
- package/lib/platform/template/wx/index.js +12 -8
- package/lib/react/processStyles.js +1 -0
- package/lib/react/processTemplate.js +2 -3
- package/lib/react/style-helper.js +9 -7
- package/lib/runtime/components/react/context.ts +9 -7
- package/lib/runtime/components/react/dist/context.js +1 -0
- package/lib/runtime/components/react/dist/getInnerListeners.js +12 -1
- package/lib/runtime/components/react/dist/mpx-button.jsx +53 -74
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +20 -18
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +30 -42
- package/lib/runtime/components/react/dist/mpx-form.jsx +18 -15
- package/lib/runtime/components/react/dist/mpx-icon.jsx +15 -17
- package/lib/runtime/components/react/dist/mpx-image/index.jsx +36 -34
- package/lib/runtime/components/react/dist/mpx-image/svg.jsx +3 -1
- package/lib/runtime/components/react/dist/mpx-input.jsx +36 -31
- package/lib/runtime/components/react/dist/mpx-label.jsx +30 -37
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +15 -19
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +10 -9
- package/lib/runtime/components/react/dist/mpx-picker/date.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +11 -10
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +9 -5
- package/lib/runtime/components/react/dist/mpx-picker/region.jsx +13 -8
- package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +3 -2
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +22 -20
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +103 -10
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +149 -54
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +20 -18
- package/lib/runtime/components/react/dist/mpx-radio.jsx +29 -43
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +8 -4
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +36 -27
- package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +141 -75
- package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +16 -7
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +20 -11
- package/lib/runtime/components/react/dist/mpx-switch.jsx +18 -14
- package/lib/runtime/components/react/dist/mpx-text.jsx +20 -35
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-view.jsx +296 -210
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +11 -7
- package/lib/runtime/components/react/dist/parser.js +218 -0
- package/lib/runtime/components/react/dist/useNodesRef.js +1 -5
- package/lib/runtime/components/react/dist/utils.jsx +445 -0
- package/lib/runtime/components/react/getInnerListeners.ts +18 -8
- package/lib/runtime/components/react/mpx-button.tsx +83 -91
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +50 -43
- package/lib/runtime/components/react/mpx-checkbox.tsx +56 -64
- package/lib/runtime/components/react/mpx-form.tsx +51 -22
- package/lib/runtime/components/react/mpx-icon.tsx +31 -27
- package/lib/runtime/components/react/mpx-image/index.tsx +54 -47
- package/lib/runtime/components/react/mpx-image/svg.tsx +5 -3
- package/lib/runtime/components/react/mpx-input.tsx +59 -38
- package/lib/runtime/components/react/mpx-label.tsx +55 -59
- package/lib/runtime/components/react/mpx-movable-area.tsx +40 -25
- package/lib/runtime/components/react/mpx-movable-view.tsx +29 -29
- package/lib/runtime/components/react/mpx-navigator.tsx +2 -2
- package/lib/runtime/components/react/mpx-picker/date.tsx +4 -4
- package/lib/runtime/components/react/mpx-picker/index.tsx +12 -11
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +17 -13
- package/lib/runtime/components/react/mpx-picker/region.tsx +23 -19
- package/lib/runtime/components/react/mpx-picker/selector.tsx +7 -7
- package/lib/runtime/components/react/mpx-picker/time.tsx +29 -31
- package/lib/runtime/components/react/mpx-picker/type.ts +1 -1
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +149 -20
- package/lib/runtime/components/react/mpx-picker-view.tsx +180 -63
- package/lib/runtime/components/react/mpx-radio-group.tsx +51 -47
- package/lib/runtime/components/react/mpx-radio.tsx +57 -72
- package/lib/runtime/components/react/mpx-root-portal.tsx +10 -8
- package/lib/runtime/components/react/mpx-scroll-view.tsx +136 -104
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +175 -96
- package/lib/runtime/components/react/mpx-swiper/index.tsx +21 -9
- package/lib/runtime/components/react/mpx-swiper/type.ts +16 -5
- package/lib/runtime/components/react/mpx-swiper-item.tsx +48 -14
- package/lib/runtime/components/react/mpx-switch.tsx +46 -24
- package/lib/runtime/components/react/mpx-text.tsx +38 -45
- package/lib/runtime/components/react/mpx-textarea.tsx +1 -1
- package/lib/runtime/components/react/mpx-view.tsx +401 -241
- package/lib/runtime/components/react/mpx-web-view.tsx +22 -22
- package/lib/runtime/components/react/parser.ts +245 -0
- package/lib/runtime/components/react/types/common.ts +4 -4
- package/lib/runtime/components/react/types/global.d.ts +24 -2
- package/lib/runtime/components/react/useNodesRef.ts +1 -7
- package/lib/runtime/components/react/utils.tsx +524 -0
- 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 +133 -161
- package/lib/template-compiler/gen-node-react.js +1 -3
- package/lib/utils/const.js +2 -1
- package/lib/web/processStyles.js +2 -1
- package/lib/web/processTemplate.js +2 -3
- package/lib/wxml/loader.js +1 -1
- package/package.json +7 -4
- package/lib/runtime/components/react/dist/utils.js +0 -148
- package/lib/runtime/components/react/utils.ts +0 -170
|
@@ -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
|
|
|
@@ -1068,7 +1068,10 @@ function processStyleReact (el, options) {
|
|
|
1068
1068
|
let staticStyle = getAndRemoveAttr(el, 'style').val || ''
|
|
1069
1069
|
staticStyle = staticStyle.replace(/\s+/g, ' ')
|
|
1070
1070
|
|
|
1071
|
-
const show = getAndRemoveAttr(el, config[mode].directive.show)
|
|
1071
|
+
const { val: show, has } = getAndRemoveAttr(el, config[mode].directive.show)
|
|
1072
|
+
if (has && show === undefined) {
|
|
1073
|
+
error$1(`Attrs ${config[mode].directive.show} should have a value `)
|
|
1074
|
+
}
|
|
1072
1075
|
|
|
1073
1076
|
if (dynamicClass || staticClass || dynamicStyle || staticStyle || show) {
|
|
1074
1077
|
const staticClassExp = parseMustacheWithContext(staticClass).result
|
|
@@ -1080,14 +1083,14 @@ function processStyleReact (el, options) {
|
|
|
1080
1083
|
addAttrs(el, [{
|
|
1081
1084
|
name: 'style',
|
|
1082
1085
|
// runtime helper
|
|
1083
|
-
value: `{{this.__getStyle(${staticClassExp}, ${dynamicClassExp}, ${staticStyleExp}, ${dynamicStyleExp}
|
|
1086
|
+
value: `{{this.__getStyle(${staticClassExp}, ${dynamicClassExp}, ${staticStyleExp}, ${dynamicStyleExp}${show === undefined ? '' : `, !(${showExp})`})}}`
|
|
1084
1087
|
}])
|
|
1085
1088
|
}
|
|
1086
1089
|
|
|
1087
1090
|
if (staticHoverClass && staticHoverClass !== 'none') {
|
|
1088
1091
|
const staticClassExp = parseMustacheWithContext(staticHoverClass).result
|
|
1089
1092
|
addAttrs(el, [{
|
|
1090
|
-
name: '
|
|
1093
|
+
name: 'hover-style',
|
|
1091
1094
|
value: `{{this.__getStyle(${staticClassExp})}}`
|
|
1092
1095
|
}])
|
|
1093
1096
|
}
|
|
@@ -1355,11 +1358,13 @@ function processEvent (el, options) {
|
|
|
1355
1358
|
}
|
|
1356
1359
|
}
|
|
1357
1360
|
|
|
1358
|
-
function processSlotReact (el) {
|
|
1361
|
+
function processSlotReact (el, meta) {
|
|
1359
1362
|
if (el.tag === 'slot') {
|
|
1360
1363
|
el.slot = {
|
|
1361
1364
|
name: getAndRemoveAttr(el, 'name').val
|
|
1362
1365
|
}
|
|
1366
|
+
meta.options = meta.options || {}
|
|
1367
|
+
meta.options.disableMemo = true
|
|
1363
1368
|
}
|
|
1364
1369
|
}
|
|
1365
1370
|
|
|
@@ -1720,34 +1725,33 @@ function processRefReact (el, meta) {
|
|
|
1720
1725
|
type
|
|
1721
1726
|
}
|
|
1722
1727
|
|
|
1728
|
+
const selectors = []
|
|
1729
|
+
|
|
1730
|
+
/**
|
|
1731
|
+
* selectorsConf: [type, [[prefix, selector], [prefix, selector]]]
|
|
1732
|
+
*/
|
|
1723
1733
|
if (!val) {
|
|
1724
|
-
refConf.key = `ref_rn_${++refId}`
|
|
1725
|
-
refConf.sKeys = []
|
|
1726
1734
|
const rawId = el.attrsMap.id
|
|
1727
1735
|
const rawClass = el.attrsMap.class
|
|
1728
1736
|
const rawDynamicClass = el.attrsMap[config[mode].directive.dynamicClass]
|
|
1729
1737
|
|
|
1730
|
-
meta.computed = meta.computed || []
|
|
1731
1738
|
if (rawId) {
|
|
1732
1739
|
const staticId = parseMustacheWithContext(rawId).result
|
|
1733
|
-
|
|
1734
|
-
refConf.sKeys.push({ key: computedIdKey, prefix: '#' })
|
|
1735
|
-
meta.computed.push(`${computedIdKey}() {\n return ${staticId}}`)
|
|
1740
|
+
selectors.push({ prefix: '#', selector: `${staticId}` })
|
|
1736
1741
|
}
|
|
1737
1742
|
if (rawClass || rawDynamicClass) {
|
|
1738
1743
|
const staticClass = parseMustacheWithContext(rawClass).result
|
|
1739
1744
|
const dynamicClass = parseMustacheWithContext(rawDynamicClass).result
|
|
1740
|
-
|
|
1741
|
-
refConf.sKeys.push({ key: computedClassKey, prefix: '.' })
|
|
1742
|
-
meta.computed.push(`${computedClassKey}() {\n return this.__getClass(${staticClass}, ${dynamicClass})}`)
|
|
1745
|
+
selectors.push({ prefix: '.', selector: `this.__getClass(${staticClass}, ${dynamicClass})` })
|
|
1743
1746
|
}
|
|
1747
|
+
} else {
|
|
1748
|
+
meta.refs.push(refConf)
|
|
1749
|
+
selectors.push({ prefix: '', selector: `"${refConf.key}"` })
|
|
1744
1750
|
}
|
|
1745
|
-
|
|
1746
|
-
meta.refs.push(refConf)
|
|
1747
|
-
|
|
1751
|
+
const selectorsConf = selectors.map(item => `["${item.prefix}", ${item.selector}]`)
|
|
1748
1752
|
addAttrs(el, [{
|
|
1749
1753
|
name: 'ref',
|
|
1750
|
-
value: `{{ this.__getRefVal('${
|
|
1754
|
+
value: `{{ this.__getRefVal('${type}', [${selectorsConf}]) }}`
|
|
1751
1755
|
}])
|
|
1752
1756
|
}
|
|
1753
1757
|
}
|
|
@@ -2047,7 +2051,7 @@ function processWrapTextReact (el) {
|
|
|
2047
2051
|
// }
|
|
2048
2052
|
|
|
2049
2053
|
function injectWxs (meta, module, src) {
|
|
2050
|
-
if (runtimeCompile || addWxsModule(meta, module, src) || isReact(mode)) {
|
|
2054
|
+
if (runtimeCompile || addWxsModule(meta, module, src) || isReact(mode) || isWeb(mode)) {
|
|
2051
2055
|
return
|
|
2052
2056
|
}
|
|
2053
2057
|
|
|
@@ -2135,96 +2139,76 @@ function isComponentNode (el, options) {
|
|
|
2135
2139
|
return options.usingComponents.indexOf(el.tag) !== -1 || el.tag === 'component'
|
|
2136
2140
|
}
|
|
2137
2141
|
|
|
2138
|
-
function
|
|
2142
|
+
function processExternalClasses (el, options) {
|
|
2139
2143
|
const isComponent = isComponentNode(el, options)
|
|
2140
|
-
// 处理组件externalClass多层传递
|
|
2141
2144
|
const classLikeAttrNames = isComponent ? ['class'].concat(options.externalClasses) : ['class']
|
|
2145
|
+
|
|
2142
2146
|
classLikeAttrNames.forEach((classLikeAttrName) => {
|
|
2143
|
-
|
|
2147
|
+
const classLikeAttrValue = getAndRemoveAttr(el, classLikeAttrName).val
|
|
2144
2148
|
if (classLikeAttrValue) {
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
}
|
|
2150
|
-
addAttrs(el, [{
|
|
2151
|
-
name: classLikeAttrName,
|
|
2152
|
-
value: classLikeAttrValue
|
|
2153
|
-
}])
|
|
2149
|
+
if (mode === 'web') {
|
|
2150
|
+
processWebClass(classLikeAttrName, classLikeAttrValue, el, options)
|
|
2151
|
+
} else {
|
|
2152
|
+
processAliClass(classLikeAttrName, classLikeAttrValue, el, options)
|
|
2153
|
+
}
|
|
2154
2154
|
}
|
|
2155
2155
|
})
|
|
2156
2156
|
|
|
2157
2157
|
if (hasScoped && isComponent) {
|
|
2158
|
-
options.externalClasses.
|
|
2159
|
-
|
|
2160
|
-
if (externalClass) {
|
|
2161
|
-
addAttrs(el, [{
|
|
2162
|
-
name: className,
|
|
2163
|
-
value: `${externalClass} ${moduleId}`
|
|
2164
|
-
}])
|
|
2165
|
-
}
|
|
2166
|
-
})
|
|
2167
|
-
}
|
|
2168
|
-
}
|
|
2169
|
-
|
|
2170
|
-
// externalClasses只能模拟静态传递
|
|
2171
|
-
function processWebExternalClassesHack (el, options) {
|
|
2172
|
-
const staticClass = getAndRemoveAttr(el, 'class').val
|
|
2173
|
-
if (staticClass) {
|
|
2174
|
-
const classNames = staticClass.split(/\s+/)
|
|
2175
|
-
const replacements = []
|
|
2176
|
-
options.externalClasses.forEach((className) => {
|
|
2177
|
-
const index = classNames.indexOf(className)
|
|
2178
|
-
if (index > -1) {
|
|
2179
|
-
replacements.push(`$attrs[${stringify(className)}]`)
|
|
2180
|
-
classNames.splice(index, 1)
|
|
2181
|
-
}
|
|
2158
|
+
const needAddModuleId = options.externalClasses.some((className) => {
|
|
2159
|
+
return el.attrsMap[className] || (mode === 'web' && el.attrsMap[':' + className])
|
|
2182
2160
|
})
|
|
2183
2161
|
|
|
2184
|
-
if (
|
|
2162
|
+
if (needAddModuleId) {
|
|
2185
2163
|
addAttrs(el, [{
|
|
2186
|
-
name:
|
|
2187
|
-
value:
|
|
2164
|
+
name: PARENT_MODULE_ID,
|
|
2165
|
+
value: `${moduleId}`
|
|
2188
2166
|
}])
|
|
2189
2167
|
}
|
|
2190
|
-
|
|
2191
|
-
|
|
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') {
|
|
2192
2183
|
const dynamicClass = getAndRemoveAttr(el, ':class').val
|
|
2193
|
-
if (dynamicClass)
|
|
2194
|
-
|
|
2184
|
+
if (dynamicClass) classNames.push(dynamicClass)
|
|
2195
2185
|
addAttrs(el, [{
|
|
2196
2186
|
name: ':class',
|
|
2197
|
-
value: `[${
|
|
2187
|
+
value: `[${classNames}]`
|
|
2188
|
+
}])
|
|
2189
|
+
} else {
|
|
2190
|
+
addAttrs(el, [{
|
|
2191
|
+
name: ':' + classLikeAttrName,
|
|
2192
|
+
value: `[${classNames}].join(' ')`
|
|
2198
2193
|
}])
|
|
2199
2194
|
}
|
|
2200
2195
|
}
|
|
2201
2196
|
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
const
|
|
2207
|
-
if (classLikeAttrValue)
|
|
2208
|
-
|
|
2209
|
-
const replacements = []
|
|
2210
|
-
options.externalClasses.forEach((className) => {
|
|
2211
|
-
const index = classNames.indexOf(className)
|
|
2212
|
-
if (index > -1) {
|
|
2213
|
-
replacements.push(`$attrs[${stringify(className)}]`)
|
|
2214
|
-
classNames.splice(index, 1)
|
|
2215
|
-
}
|
|
2216
|
-
})
|
|
2217
|
-
|
|
2218
|
-
if (classNames.length) {
|
|
2219
|
-
replacements.unshift(stringify(classNames.join(' ')))
|
|
2220
|
-
}
|
|
2221
|
-
|
|
2222
|
-
addAttrs(el, [{
|
|
2223
|
-
name: ':' + classLikeAttrName,
|
|
2224
|
-
value: `[${replacements}].join(' ')`
|
|
2225
|
-
}])
|
|
2226
|
-
}
|
|
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} || ''}}`)
|
|
2227
2204
|
})
|
|
2205
|
+
if (hasExternalClass) {
|
|
2206
|
+
classLikeAttrValue += ` {{${PARENT_MODULE_ID} || ''}}`
|
|
2207
|
+
}
|
|
2208
|
+
addAttrs(el, [{
|
|
2209
|
+
name: classLikeAttrName,
|
|
2210
|
+
value: classLikeAttrValue
|
|
2211
|
+
}])
|
|
2228
2212
|
}
|
|
2229
2213
|
}
|
|
2230
2214
|
|
|
@@ -2329,10 +2313,10 @@ function getVirtualHostRoot (options, meta) {
|
|
|
2329
2313
|
if (ctorType === 'component') {
|
|
2330
2314
|
if (mode === 'wx' && hasVirtualHost) {
|
|
2331
2315
|
// wx组件注入virtualHost配置
|
|
2332
|
-
|
|
2316
|
+
meta.options = meta.options || {}
|
|
2333
2317
|
meta.options.virtualHost = true
|
|
2334
2318
|
}
|
|
2335
|
-
if (mode
|
|
2319
|
+
if (isWeb(mode) && !hasVirtualHost) {
|
|
2336
2320
|
// ali组件根节点实体化
|
|
2337
2321
|
const rootView = createASTElement('view', [
|
|
2338
2322
|
{
|
|
@@ -2353,13 +2337,17 @@ function getVirtualHostRoot (options, meta) {
|
|
|
2353
2337
|
name: 'class',
|
|
2354
2338
|
value: `${MPX_ROOT_VIEW} host-${moduleId}`
|
|
2355
2339
|
}
|
|
2340
|
+
// todo 运行时通过root标识确定是否合并rootProps
|
|
2341
|
+
// {
|
|
2342
|
+
// name: 'is-root',
|
|
2343
|
+
// value: '{{true}}'
|
|
2344
|
+
// }
|
|
2356
2345
|
])
|
|
2357
|
-
rootView.isRoot = true
|
|
2358
2346
|
processElement(rootView, rootView, options, meta)
|
|
2359
2347
|
return rootView
|
|
2360
2348
|
}
|
|
2361
2349
|
}
|
|
2362
|
-
if (mode
|
|
2350
|
+
if (isWeb(mode) && ctorType === 'page') {
|
|
2363
2351
|
return createASTElement('page')
|
|
2364
2352
|
}
|
|
2365
2353
|
}
|
|
@@ -2367,36 +2355,24 @@ function getVirtualHostRoot (options, meta) {
|
|
|
2367
2355
|
}
|
|
2368
2356
|
|
|
2369
2357
|
function processShow (el, options, root) {
|
|
2370
|
-
// 开启 virtualhost 全部走 props 传递处理
|
|
2371
|
-
// 未开启 virtualhost 直接绑定 display:none 到节点上
|
|
2372
2358
|
let { val: show, has } = getAndRemoveAttr(el, config[mode].directive.show)
|
|
2373
2359
|
if (mode === 'swan') show = wrapMustache(show)
|
|
2374
2360
|
if (has && show === undefined) {
|
|
2375
2361
|
error$1(`Attrs ${config[mode].directive.show} should have a value `)
|
|
2362
|
+
return
|
|
2376
2363
|
}
|
|
2377
|
-
if (
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
}
|
|
2384
|
-
}
|
|
2385
|
-
if (isComponentNode(el, options) && show !== undefined) {
|
|
2386
|
-
if (show === '') {
|
|
2387
|
-
show = '{{false}}'
|
|
2388
|
-
}
|
|
2389
|
-
addAttrs(el, [{
|
|
2390
|
-
name: 'mpxShow',
|
|
2391
|
-
value: show
|
|
2392
|
-
}])
|
|
2393
|
-
} else {
|
|
2394
|
-
if (runtimeCompile) {
|
|
2395
|
-
processShowStyleDynamic(el, show)
|
|
2396
|
-
} else {
|
|
2397
|
-
processShowStyle(el, show)
|
|
2398
|
-
}
|
|
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}}'
|
|
2399
2371
|
}
|
|
2372
|
+
addAttrs(el, [{
|
|
2373
|
+
name: 'mpxShow',
|
|
2374
|
+
value: show
|
|
2375
|
+
}])
|
|
2400
2376
|
} else {
|
|
2401
2377
|
if (runtimeCompile) {
|
|
2402
2378
|
processShowStyleDynamic(el, show)
|
|
@@ -2407,15 +2383,13 @@ function processShow (el, options, root) {
|
|
|
2407
2383
|
}
|
|
2408
2384
|
|
|
2409
2385
|
function processShowStyle (el, show) {
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
}])
|
|
2418
|
-
}
|
|
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
|
+
}])
|
|
2419
2393
|
}
|
|
2420
2394
|
|
|
2421
2395
|
function processTemplate (el) {
|
|
@@ -2602,12 +2576,14 @@ function processElement (el, root, options, meta) {
|
|
|
2602
2576
|
|
|
2603
2577
|
const transAli = mode === 'ali' && srcMode === 'wx'
|
|
2604
2578
|
|
|
2605
|
-
if (mode
|
|
2579
|
+
if (isWeb(mode)) {
|
|
2606
2580
|
// 收集内建组件
|
|
2607
2581
|
processBuiltInComponents(el, meta)
|
|
2608
2582
|
// 预处理代码维度条件编译
|
|
2609
2583
|
processIfWeb(el)
|
|
2610
|
-
|
|
2584
|
+
processScoped(el)
|
|
2585
|
+
// processWebExternalClassesHack(el, options)
|
|
2586
|
+
processExternalClasses(el, options)
|
|
2611
2587
|
processComponentGenericsWeb(el, options, meta)
|
|
2612
2588
|
return
|
|
2613
2589
|
}
|
|
@@ -2622,12 +2598,12 @@ function processElement (el, root, options, meta) {
|
|
|
2622
2598
|
processStyleReact(el, options)
|
|
2623
2599
|
processEventReact(el)
|
|
2624
2600
|
processComponentIs(el, options)
|
|
2625
|
-
processSlotReact(el)
|
|
2601
|
+
processSlotReact(el, meta)
|
|
2626
2602
|
processAttrs(el, options)
|
|
2627
2603
|
return
|
|
2628
2604
|
}
|
|
2629
2605
|
|
|
2630
|
-
const
|
|
2606
|
+
const isTemplate = processTemplate(el) || processingTemplate
|
|
2631
2607
|
|
|
2632
2608
|
// 仅ali平台需要scoped模拟样式隔离
|
|
2633
2609
|
if (mode === 'ali') {
|
|
@@ -2635,24 +2611,25 @@ function processElement (el, root, options, meta) {
|
|
|
2635
2611
|
}
|
|
2636
2612
|
|
|
2637
2613
|
if (transAli) {
|
|
2638
|
-
processAliExternalClassesHack(el, options)
|
|
2614
|
+
// processAliExternalClassesHack(el, options)
|
|
2615
|
+
processExternalClasses(el, options)
|
|
2639
2616
|
}
|
|
2640
2617
|
|
|
2641
2618
|
processIf(el)
|
|
2642
2619
|
processFor(el)
|
|
2643
2620
|
|
|
2644
|
-
if (!
|
|
2645
|
-
processRef(el, options, meta)
|
|
2621
|
+
if (!isNative) {
|
|
2622
|
+
if (!isTemplate) processRef(el, options, meta)
|
|
2646
2623
|
if (runtimeCompile) {
|
|
2647
|
-
processClassDynamic(el
|
|
2648
|
-
processStyleDynamic(el
|
|
2624
|
+
processClassDynamic(el)
|
|
2625
|
+
processStyleDynamic(el)
|
|
2649
2626
|
} else {
|
|
2650
2627
|
processClass(el, meta)
|
|
2651
2628
|
processStyle(el, meta)
|
|
2652
2629
|
}
|
|
2653
2630
|
processShow(el, options, root)
|
|
2654
2631
|
processEvent(el, options)
|
|
2655
|
-
processComponentIs(el, options)
|
|
2632
|
+
if (!isTemplate) processComponentIs(el, options)
|
|
2656
2633
|
}
|
|
2657
2634
|
|
|
2658
2635
|
processAttrs(el, options)
|
|
@@ -2660,23 +2637,21 @@ function processElement (el, root, options, meta) {
|
|
|
2660
2637
|
|
|
2661
2638
|
function closeElement (el, meta, options) {
|
|
2662
2639
|
postProcessAtMode(el)
|
|
2663
|
-
|
|
2640
|
+
postProcessWxs(el, meta)
|
|
2664
2641
|
|
|
2665
|
-
if (mode
|
|
2666
|
-
postProcessWxs(el, meta)
|
|
2642
|
+
if (isWeb(mode)) {
|
|
2667
2643
|
// 处理代码维度条件编译移除死分支
|
|
2668
2644
|
postProcessIf(el)
|
|
2669
2645
|
return
|
|
2670
2646
|
}
|
|
2671
2647
|
if (isReact(mode)) {
|
|
2672
|
-
postProcessWxs(el, meta)
|
|
2673
2648
|
postProcessForReact(el)
|
|
2674
2649
|
postProcessIfReact(el)
|
|
2675
2650
|
return
|
|
2676
2651
|
}
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
if (!
|
|
2652
|
+
|
|
2653
|
+
const isTemplate = postProcessTemplate(el) || processingTemplate
|
|
2654
|
+
if (!isNative && !isTemplate) {
|
|
2680
2655
|
if (isComponentNode(el, options) && !hasVirtualHost && mode === 'ali') {
|
|
2681
2656
|
postProcessAliComponentRootView(el, options, meta)
|
|
2682
2657
|
}
|
|
@@ -2686,6 +2661,7 @@ function closeElement (el, meta, options) {
|
|
|
2686
2661
|
if (runtimeCompile) {
|
|
2687
2662
|
postProcessForDynamic(el, config[mode])
|
|
2688
2663
|
postProcessIfDynamic(el, config[mode])
|
|
2664
|
+
collectDynamicInfo(el, options, meta)
|
|
2689
2665
|
postProcessAttrsDynamic(el, config[mode])
|
|
2690
2666
|
} else {
|
|
2691
2667
|
postProcessFor(el)
|
|
@@ -2788,9 +2764,7 @@ function serialize (root) {
|
|
|
2788
2764
|
result += node.text
|
|
2789
2765
|
}
|
|
2790
2766
|
}
|
|
2791
|
-
|
|
2792
|
-
return result
|
|
2793
|
-
}
|
|
2767
|
+
|
|
2794
2768
|
if (node.type === 1) {
|
|
2795
2769
|
if (node.tag !== 'temp-node') {
|
|
2796
2770
|
result += '<' + node.tag
|
|
@@ -2960,11 +2934,11 @@ function processIfConditionsDynamic (el) {
|
|
|
2960
2934
|
block: el,
|
|
2961
2935
|
__exp: el.elseif ? parseExp(el.elseif.exp) : ''
|
|
2962
2936
|
})
|
|
2963
|
-
removeNode(el)
|
|
2937
|
+
removeNode(el, true)
|
|
2964
2938
|
}
|
|
2965
2939
|
}
|
|
2966
2940
|
|
|
2967
|
-
function processClassDynamic (el
|
|
2941
|
+
function processClassDynamic (el) {
|
|
2968
2942
|
const type = 'class'
|
|
2969
2943
|
const targetType = type
|
|
2970
2944
|
const dynamicClass = getAndRemoveAttr(el, config[mode].directive.dynamicClass).val
|
|
@@ -2987,7 +2961,7 @@ function processClassDynamic (el, meta) {
|
|
|
2987
2961
|
}
|
|
2988
2962
|
}
|
|
2989
2963
|
|
|
2990
|
-
function processStyleDynamic (el
|
|
2964
|
+
function processStyleDynamic (el) {
|
|
2991
2965
|
const type = 'style'
|
|
2992
2966
|
const targetType = type
|
|
2993
2967
|
const dynamicStyle = getAndRemoveAttr(el, config[mode].directive.dynamicStyle).val
|
|
@@ -3076,17 +3050,15 @@ function postProcessAttrsDynamic (vnode, config) {
|
|
|
3076
3050
|
}
|
|
3077
3051
|
|
|
3078
3052
|
function processShowStyleDynamic (el, show) {
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
}])
|
|
3089
|
-
}
|
|
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
|
+
}])
|
|
3090
3062
|
}
|
|
3091
3063
|
|
|
3092
3064
|
module.exports = {
|
|
@@ -60,9 +60,7 @@ function genNode (node) {
|
|
|
60
60
|
exp += `__getSlot(${name ? s(name) : ''})`
|
|
61
61
|
} else {
|
|
62
62
|
exp += `createElement(${`getComponent(${node.is || s(node.tag)})`}`
|
|
63
|
-
if (node.
|
|
64
|
-
exp += `, Object.assign({}, rootProps, {style: Object.assign({}, ${attrExpMap.style}, rootProps.style)})`
|
|
65
|
-
} else if (node.attrsList.length) {
|
|
63
|
+
if (node.attrsList.length) {
|
|
66
64
|
const attrs = []
|
|
67
65
|
node.attrsList && node.attrsList.forEach(({ name, value }) => {
|
|
68
66
|
const attrExp = attrExpMap[name] ? attrExpMap[name] : s(value)
|
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
|
@@ -9,10 +9,11 @@ module.exports = function (styles, options, callback) {
|
|
|
9
9
|
const attrs = Object.assign({}, style.attrs)
|
|
10
10
|
if (options.autoScope) attrs.scoped = true
|
|
11
11
|
attrs.mpxStyleOptions = JSON.stringify({
|
|
12
|
-
|
|
12
|
+
scoped: attrs.scoped,
|
|
13
13
|
// query中包含module字符串会被新版vue-cli中的默认rules当做css-module处理
|
|
14
14
|
mid: options.moduleId
|
|
15
15
|
})
|
|
16
|
+
delete attrs.scoped
|
|
16
17
|
return attrs
|
|
17
18
|
}
|
|
18
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,16 +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
|
+
"react-native-linear-gradient": "^2.8.3",
|
|
92
|
+
"react-native-safe-area-context": "^4.12.0",
|
|
93
|
+
"react-native-webview": "^13.12.2",
|
|
91
94
|
"rimraf": "^6.0.1"
|
|
92
95
|
},
|
|
93
96
|
"engines": {
|
|
94
97
|
"node": ">=14.14.0"
|
|
95
98
|
},
|
|
96
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "24efa90e90b4d42c285ca61739cb9e4d0696976c"
|
|
97
100
|
}
|