@mpxjs/webpack-plugin 2.9.70-alpha.0 → 2.9.71
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/LICENSE +433 -0
- package/README.md +1 -1
- package/lib/config.js +0 -14
- package/lib/dependencies/ResolveDependency.js +0 -5
- package/lib/index.js +7 -38
- package/lib/json-compiler/helper.js +3 -3
- package/lib/loader.js +0 -53
- package/lib/parser.js +1 -1
- package/lib/platform/json/wx/index.js +21 -8
- package/lib/platform/style/wx/index.js +51 -54
- package/lib/platform/template/wx/component-config/button.js +2 -14
- package/lib/platform/template/wx/component-config/fix-component-name.js +15 -12
- package/lib/platform/template/wx/component-config/image.js +0 -4
- package/lib/platform/template/wx/component-config/index.js +1 -1
- package/lib/platform/template/wx/component-config/input.js +0 -4
- package/lib/platform/template/wx/component-config/movable-view.js +8 -1
- package/lib/platform/template/wx/component-config/picker-view.js +1 -5
- package/lib/platform/template/wx/component-config/rich-text.js +6 -2
- package/lib/platform/template/wx/component-config/scroll-view.js +1 -5
- package/lib/platform/template/wx/component-config/switch.js +0 -4
- package/lib/platform/template/wx/component-config/text.js +0 -4
- package/lib/platform/template/wx/component-config/textarea.js +0 -5
- package/lib/platform/template/wx/component-config/unsupported.js +1 -1
- package/lib/platform/template/wx/component-config/view.js +0 -4
- package/lib/platform/template/wx/index.js +1 -131
- package/lib/resolve-loader.js +1 -4
- package/lib/runtime/components/react/context.ts +8 -0
- package/lib/runtime/components/react/dist/context.js +2 -0
- package/lib/runtime/components/react/dist/getInnerListeners.js +39 -37
- package/lib/runtime/components/react/dist/mpx-button.jsx +16 -44
- package/lib/runtime/components/react/dist/mpx-canvas/html.js +2 -4
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +5 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +93 -58
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +10 -14
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +94 -81
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +19 -16
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +10 -11
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +11 -4
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +31 -8
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +435 -371
- package/lib/runtime/components/react/dist/mpx-view.jsx +18 -53
- package/lib/runtime/components/react/dist/pickerFaces.js +3 -8
- package/lib/runtime/components/react/dist/pickerVIewContext.js +5 -0
- package/lib/runtime/components/react/dist/{pickerViewOverlay.jsx → pickerViewIndicator.jsx} +6 -6
- package/lib/runtime/components/react/dist/pickerViewMask.jsx +2 -2
- package/lib/runtime/components/react/dist/useAnimationHooks.js +27 -10
- package/lib/runtime/components/react/dist/utils.jsx +162 -70
- package/lib/runtime/components/react/event.config.ts +25 -26
- package/lib/runtime/components/react/getInnerListeners.ts +236 -182
- package/lib/runtime/components/react/mpx-button.tsx +27 -69
- package/lib/runtime/components/react/mpx-canvas/html.ts +2 -4
- package/lib/runtime/components/react/mpx-canvas/index.tsx +44 -46
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +15 -13
- package/lib/runtime/components/react/mpx-checkbox.tsx +20 -21
- package/lib/runtime/components/react/mpx-form.tsx +15 -20
- package/lib/runtime/components/react/mpx-icon.tsx +2 -2
- package/lib/runtime/components/react/mpx-image.tsx +87 -47
- package/lib/runtime/components/react/mpx-input.tsx +24 -32
- package/lib/runtime/components/react/mpx-label.tsx +12 -14
- package/lib/runtime/components/react/mpx-movable-area.tsx +10 -16
- package/lib/runtime/components/react/mpx-movable-view.tsx +133 -92
- package/lib/runtime/components/react/mpx-navigator.tsx +3 -9
- package/lib/runtime/components/react/mpx-picker-view-column-item.tsx +76 -0
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +206 -183
- package/lib/runtime/components/react/mpx-picker-view.tsx +49 -48
- package/lib/runtime/components/react/mpx-radio-group.tsx +13 -15
- package/lib/runtime/components/react/mpx-radio.tsx +19 -25
- package/lib/runtime/components/react/mpx-rich-text/html.ts +40 -0
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +115 -0
- package/lib/runtime/components/react/mpx-root-portal.tsx +3 -5
- package/lib/runtime/components/react/mpx-scroll-view.tsx +53 -43
- package/lib/runtime/components/react/mpx-swiper-item.tsx +45 -11
- package/lib/runtime/components/react/mpx-swiper.tsx +742 -0
- package/lib/runtime/components/react/mpx-switch.tsx +19 -15
- package/lib/runtime/components/react/mpx-text.tsx +8 -16
- package/lib/runtime/components/react/mpx-textarea.tsx +11 -10
- package/lib/runtime/components/react/mpx-view.tsx +28 -77
- package/lib/runtime/components/react/mpx-web-view.tsx +94 -59
- package/lib/runtime/components/react/pickerFaces.ts +10 -7
- package/lib/runtime/components/react/pickerVIewContext.ts +27 -0
- package/lib/runtime/components/react/pickerViewIndicator.tsx +34 -0
- package/lib/runtime/components/react/pickerViewMask.tsx +30 -0
- package/lib/runtime/components/react/types/{getInnerListeners.ts → getInnerListeners.d.ts} +4 -5
- package/lib/runtime/components/react/types/global.d.ts +12 -1
- package/lib/runtime/components/react/useAnimationHooks.ts +60 -15
- package/lib/runtime/components/react/utils.tsx +175 -71
- package/lib/runtime/components/web/mpx-checkbox.vue +1 -1
- package/lib/runtime/components/web/mpx-picker-view-column.vue +9 -4
- package/lib/runtime/components/web/mpx-web-view.vue +34 -20
- package/lib/runtime/optionProcessor.js +0 -22
- package/lib/style-compiler/index.js +1 -1
- package/lib/style-compiler/plugins/scope-id.js +30 -2
- package/lib/template-compiler/compiler.js +91 -39
- package/lib/utils/env.js +1 -6
- package/lib/utils/pre-process-json.js +9 -5
- package/lib/wxss/loader.js +15 -2
- package/package.json +4 -7
- package/lib/dependencies/AddEntryDependency.js +0 -24
- package/lib/runtime/components/react/dist/types/common.js +0 -1
- package/lib/runtime/components/react/dist/types/getInnerListeners.js +0 -1
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +0 -527
- package/lib/runtime/components/react/mpx-swiper/index.tsx +0 -80
- package/lib/runtime/components/react/mpx-swiper/type.ts +0 -87
- package/lib/runtime/components/react/pickerOverlay.tsx +0 -32
- package/lib/runtime/components/tenon/getInnerListeners.js +0 -334
- package/lib/runtime/components/tenon/tenon-button.vue +0 -309
- package/lib/runtime/components/tenon/tenon-image.vue +0 -66
- package/lib/runtime/components/tenon/tenon-input.vue +0 -171
- package/lib/runtime/components/tenon/tenon-rich-text.vue +0 -26
- package/lib/runtime/components/tenon/tenon-scroll-view.vue +0 -127
- package/lib/runtime/components/tenon/tenon-switch.vue +0 -96
- package/lib/runtime/components/tenon/tenon-text.vue +0 -70
- package/lib/runtime/components/tenon/tenon-textarea.vue +0 -86
- package/lib/runtime/components/tenon/tenon-view.vue +0 -93
- package/lib/runtime/components/web/event.js +0 -105
- package/lib/runtime/optionProcessor.tenon.js +0 -84
- package/lib/style-compiler/plugins/hm.js +0 -20
- package/lib/tenon/index.js +0 -117
- package/lib/tenon/processJSON.js +0 -352
- package/lib/tenon/processScript.js +0 -203
- package/lib/tenon/processStyles.js +0 -21
- package/lib/tenon/processTemplate.js +0 -126
- package/lib/tenon/script-helper.js +0 -223
- package/lib/utils/get-relative-path.js +0 -25
- /package/lib/runtime/components/react/types/{common.ts → common.d.ts} +0 -0
|
@@ -40,14 +40,14 @@ export default {
|
|
|
40
40
|
this.wheels[0].wheelTo(newVal[0])
|
|
41
41
|
})
|
|
42
42
|
}
|
|
43
|
-
}
|
|
43
|
+
},
|
|
44
44
|
},
|
|
45
45
|
mounted () {
|
|
46
46
|
this.wheels = []
|
|
47
47
|
this.refresh()
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
},
|
|
49
|
+
updated () {
|
|
50
|
+
this.refresh()
|
|
51
51
|
},
|
|
52
52
|
beforeDestroy () {
|
|
53
53
|
this.wheels.forEach((wheel) => {
|
|
@@ -58,11 +58,16 @@ export default {
|
|
|
58
58
|
methods: {
|
|
59
59
|
refresh () {
|
|
60
60
|
if (this.refreshing) return
|
|
61
|
+
|
|
61
62
|
this.refreshing = true
|
|
63
|
+
for (let i = 0; i < this.$refs.wheelScroll.children.length; i++) {
|
|
64
|
+
this.$refs.wheelScroll.children[i].style.height = `${this.$parent.$refs.indicatorMask.offsetHeight}px`
|
|
65
|
+
}
|
|
62
66
|
this.$nextTick(() => {
|
|
63
67
|
const wheelWrapper = this.$refs.wheelWrapper
|
|
64
68
|
if (this.wheels[0]) {
|
|
65
69
|
this.wheels[0].refresh()
|
|
70
|
+
this.refreshing = false
|
|
66
71
|
return
|
|
67
72
|
}
|
|
68
73
|
this.wheels[0] = new BScroll(wheelWrapper, extend({
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
<script>
|
|
6
6
|
import { getCustomEvent } from './getInnerListeners'
|
|
7
7
|
import { promisify, redirectTo, navigateTo, navigateBack, reLaunch, switchTab } from '@mpxjs/api-proxy'
|
|
8
|
-
import { extend } from '
|
|
8
|
+
import { extend, isFunction } from '@mpxjs/utils'
|
|
9
|
+
|
|
9
10
|
const navObj = promisify({ redirectTo, navigateTo, navigateBack, reLaunch, switchTab })
|
|
10
11
|
const eventLoad = 'load'
|
|
11
12
|
const eventError = 'error'
|
|
@@ -102,58 +103,71 @@ export default {
|
|
|
102
103
|
methods: {
|
|
103
104
|
messageCallback (event) {
|
|
104
105
|
const hostValidate = this.hostValidate(event.origin)
|
|
105
|
-
|
|
106
|
+
let data = {}
|
|
107
|
+
try {
|
|
108
|
+
const eventData = event.data
|
|
109
|
+
data = typeof eventData === 'string' ? JSON.parse(eventData) : eventData
|
|
110
|
+
} catch(e){}
|
|
106
111
|
// 判断number类型,防止undefined导致触发return逻辑
|
|
107
112
|
if (data.clientUid !== undefined && +data.clientUid !== this._uid) {
|
|
108
113
|
return
|
|
109
114
|
}
|
|
110
115
|
let value = data.payload
|
|
116
|
+
const args = data.args
|
|
117
|
+
const params = Array.isArray(args) ? args : [value]
|
|
111
118
|
if (!hostValidate) {
|
|
112
119
|
return
|
|
113
120
|
}
|
|
114
121
|
let asyncCallback = null
|
|
115
|
-
|
|
122
|
+
const type = data.type
|
|
123
|
+
switch (type) {
|
|
116
124
|
case 'postMessage':
|
|
117
|
-
|
|
125
|
+
let data = {
|
|
126
|
+
type: 'message',
|
|
127
|
+
data: params[0]?.data
|
|
128
|
+
}
|
|
129
|
+
this.$emit(eventMessage, getCustomEvent(eventMessage, data, this))
|
|
118
130
|
asyncCallback = Promise.resolve({
|
|
119
131
|
errMsg: 'invokeWebappApi:ok'
|
|
120
132
|
})
|
|
121
133
|
break
|
|
122
134
|
case 'navigateTo':
|
|
123
|
-
asyncCallback = navObj.navigateTo(
|
|
135
|
+
asyncCallback = navObj.navigateTo(...params)
|
|
124
136
|
break
|
|
125
137
|
case 'navigateBack':
|
|
126
|
-
asyncCallback = navObj.navigateBack(
|
|
138
|
+
asyncCallback = navObj.navigateBack(...params)
|
|
127
139
|
break
|
|
128
140
|
case 'redirectTo':
|
|
129
|
-
asyncCallback = navObj.redirectTo(
|
|
141
|
+
asyncCallback = navObj.redirectTo(...params)
|
|
130
142
|
break
|
|
131
143
|
case 'switchTab':
|
|
132
|
-
asyncCallback = navObj.switchTab(
|
|
144
|
+
asyncCallback = navObj.switchTab(...params)
|
|
133
145
|
break
|
|
134
146
|
case 'reLaunch':
|
|
135
|
-
asyncCallback = navObj.reLaunch(
|
|
147
|
+
asyncCallback = navObj.reLaunch(...params)
|
|
136
148
|
break
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
149
|
+
default:
|
|
150
|
+
if (type) {
|
|
151
|
+
const implement = mpx.config.webviewConfig.apiImplementations && mpx.config.webviewConfig.apiImplementations[type]
|
|
152
|
+
if (isFunction(implement)) {
|
|
153
|
+
asyncCallback = Promise.resolve(implement(...params))
|
|
154
|
+
} else {
|
|
155
|
+
asyncCallback = Promise.reject({
|
|
156
|
+
errMsg: `未在apiImplementations中配置${type}方法`
|
|
157
|
+
})
|
|
158
|
+
}
|
|
145
159
|
}
|
|
146
160
|
break
|
|
147
161
|
}
|
|
148
162
|
asyncCallback && asyncCallback.then((res) => {
|
|
149
163
|
this.mpxIframe && this.mpxIframe.contentWindow && this.mpxIframe.contentWindow.postMessage && this.mpxIframe.contentWindow.postMessage({
|
|
150
|
-
type:
|
|
164
|
+
type: type,
|
|
151
165
|
callbackId: data.callbackId,
|
|
152
166
|
result: res
|
|
153
167
|
}, event.origin)
|
|
154
168
|
}).catch((error) => {
|
|
155
169
|
this.mpxIframe && this.mpxIframe.contentWindow && this.mpxIframe.contentWindow.postMessage && this.mpxIframe.contentWindow.postMessage({
|
|
156
|
-
type:
|
|
170
|
+
type: type,
|
|
157
171
|
callbackId: data.callbackId,
|
|
158
172
|
error
|
|
159
173
|
}, event.origin)
|
|
@@ -183,4 +197,4 @@ export default {
|
|
|
183
197
|
right: 0;
|
|
184
198
|
bottom: 0;
|
|
185
199
|
}
|
|
186
|
-
</style>
|
|
200
|
+
</style>
|
|
@@ -2,9 +2,6 @@ import { hasOwn, isEmptyObject, extend } from './utils'
|
|
|
2
2
|
import { isBrowser } from './env'
|
|
3
3
|
import transRpxStyle from './transRpxStyle'
|
|
4
4
|
import animation from './animation'
|
|
5
|
-
import { createEvent } from './components/web/event'
|
|
6
|
-
|
|
7
|
-
createEvent()
|
|
8
5
|
|
|
9
6
|
export function processComponentOption (
|
|
10
7
|
{
|
|
@@ -309,25 +306,6 @@ function createApp ({ componentsMap, Vue, pagesMap, firstPage, VueRouter, App, t
|
|
|
309
306
|
})
|
|
310
307
|
// 处理visibilitychange时触发当前活跃页面组件的onshow/onhide
|
|
311
308
|
if (isBrowser) {
|
|
312
|
-
const errorHandler = function (args, fromVue) {
|
|
313
|
-
if (global.__mpxAppCbs && global.__mpxAppCbs.error && global.__mpxAppCbs.error.length) {
|
|
314
|
-
global.__mpxAppCbs.error.forEach((cb) => {
|
|
315
|
-
cb.apply(null, args)
|
|
316
|
-
})
|
|
317
|
-
console.error(...args)
|
|
318
|
-
} else if (fromVue) {
|
|
319
|
-
throw args[0]
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
Vue.config.errorHandler = (...args) => {
|
|
323
|
-
return errorHandler(args, true)
|
|
324
|
-
}
|
|
325
|
-
window.addEventListener('error', (event) => {
|
|
326
|
-
return errorHandler([event.error, event])
|
|
327
|
-
})
|
|
328
|
-
window.addEventListener('unhandledrejection', (event) => {
|
|
329
|
-
return errorHandler([event.reason, event])
|
|
330
|
-
})
|
|
331
309
|
document.addEventListener('visibilitychange', function () {
|
|
332
310
|
const vnode = global.__mpxRouter && global.__mpxRouter.__mpxActiveVnode
|
|
333
311
|
if (vnode && vnode.componentInstance) {
|
|
@@ -30,7 +30,7 @@ module.exports = function (css, map) {
|
|
|
30
30
|
const index = queryObj.index || 0
|
|
31
31
|
const packageName = queryObj.packageRoot || mpx.currentPackageRoot || 'main'
|
|
32
32
|
|
|
33
|
-
const transRpxFn = mpx.webConfig
|
|
33
|
+
const transRpxFn = mpx.webConfig.transRpxFn
|
|
34
34
|
const testResolveRange = (include = () => true, exclude) => {
|
|
35
35
|
return matchCondition(this.resourcePath, { include, exclude })
|
|
36
36
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const selectorParser = require('postcss-selector-parser')
|
|
2
2
|
// scope-id
|
|
3
|
-
|
|
3
|
+
function isSpaceCombinator (node) {
|
|
4
|
+
return node.type === 'combinator' && /^\s+$/.test(node.value)
|
|
5
|
+
}
|
|
4
6
|
module.exports = ({ id }) => {
|
|
5
7
|
return {
|
|
6
8
|
postcssPlugin: 'scope-id',
|
|
@@ -31,10 +33,36 @@ module.exports = ({ id }) => {
|
|
|
31
33
|
n.spaces.before = n.spaces.after = ''
|
|
32
34
|
return false
|
|
33
35
|
}
|
|
36
|
+
if (n.type === 'pseudo' && n.value === ':deep') {
|
|
37
|
+
if (n.nodes.length) {
|
|
38
|
+
let last = n
|
|
39
|
+
n.nodes[0].each((ss) => {
|
|
40
|
+
selector.insertAfter(last, ss)
|
|
41
|
+
last = ss
|
|
42
|
+
})
|
|
43
|
+
const prev = n.prev()
|
|
44
|
+
if (!prev || !isSpaceCombinator(prev)) {
|
|
45
|
+
selector.insertAfter(
|
|
46
|
+
n,
|
|
47
|
+
selectorParser.combinator({
|
|
48
|
+
value: ' '
|
|
49
|
+
})
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
n.remove()
|
|
53
|
+
} else {
|
|
54
|
+
const prev = n.prev()
|
|
55
|
+
if (prev && isSpaceCombinator(prev)) {
|
|
56
|
+
prev.remove()
|
|
57
|
+
}
|
|
58
|
+
n.remove()
|
|
59
|
+
}
|
|
60
|
+
return false
|
|
61
|
+
}
|
|
34
62
|
// /deep/ alias for >>>, since >>> doesn't work in SASS
|
|
35
63
|
if (n.type === 'tag' && n.value === '/deep/') {
|
|
36
64
|
const prev = n.prev()
|
|
37
|
-
if (prev && prev
|
|
65
|
+
if (prev && isSpaceCombinator(prev)) {
|
|
38
66
|
prev.remove()
|
|
39
67
|
}
|
|
40
68
|
n.remove()
|
|
@@ -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, isWeb
|
|
18
|
+
const { isReact, isWeb } = require('../utils/env')
|
|
19
19
|
|
|
20
20
|
const no = function () {
|
|
21
21
|
return false
|
|
@@ -38,7 +38,7 @@ const endTag = new RegExp(('^<\\/' + qnameCapture + '[^>]*>'))
|
|
|
38
38
|
const doctype = /^<!DOCTYPE [^>]+>/i
|
|
39
39
|
const comment = /^<!--/
|
|
40
40
|
const conditionalComment = /^<!\[/
|
|
41
|
-
const
|
|
41
|
+
const specialClassReg = /^mpx-((cover-)?view|button|navigator|picker-view)$/
|
|
42
42
|
let IS_REGEX_CAPTURING_BROKEN = false
|
|
43
43
|
'x'.replace(/x(.)?/g, function (m, g) {
|
|
44
44
|
IS_REGEX_CAPTURING_BROKEN = g === ''
|
|
@@ -117,6 +117,7 @@ let hasOptionalChaining = false
|
|
|
117
117
|
let processingTemplate = false
|
|
118
118
|
const rulesResultMap = new Map()
|
|
119
119
|
let usingComponents = []
|
|
120
|
+
let usingComponentsInfo = {}
|
|
120
121
|
|
|
121
122
|
function updateForScopesMap () {
|
|
122
123
|
forScopesMap = {}
|
|
@@ -636,6 +637,7 @@ function parse (template, options) {
|
|
|
636
637
|
|
|
637
638
|
if (typeof options.usingComponentsInfo === 'string') options.usingComponentsInfo = JSON.parse(options.usingComponentsInfo)
|
|
638
639
|
usingComponents = Object.keys(options.usingComponentsInfo)
|
|
640
|
+
usingComponentsInfo = options.usingComponentsInfo
|
|
639
641
|
|
|
640
642
|
const _warn = content => {
|
|
641
643
|
const currentElementRuleResult = rulesResultMap.get(currentEl) || rulesResultMap.set(currentEl, {
|
|
@@ -1071,12 +1073,6 @@ function processStyleReact (el, options) {
|
|
|
1071
1073
|
let staticClass = getAndRemoveAttr(el, 'class').val || ''
|
|
1072
1074
|
staticClass = staticClass.replace(/\s+/g, ' ')
|
|
1073
1075
|
|
|
1074
|
-
let staticHoverClass = ''
|
|
1075
|
-
if (hoverClassReg.test(el.tag)) {
|
|
1076
|
-
staticHoverClass = el.attrsMap['hover-class'] || ''
|
|
1077
|
-
staticHoverClass = staticHoverClass.replace(/\s+/g, ' ')
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
1076
|
const dynamicStyle = getAndRemoveAttr(el, config[mode].directive.dynamicStyle).val
|
|
1081
1077
|
let staticStyle = getAndRemoveAttr(el, 'style').val || ''
|
|
1082
1078
|
staticStyle = staticStyle.replace(/\s+/g, ' ')
|
|
@@ -1100,12 +1096,22 @@ function processStyleReact (el, options) {
|
|
|
1100
1096
|
}])
|
|
1101
1097
|
}
|
|
1102
1098
|
|
|
1103
|
-
if (
|
|
1104
|
-
const
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1099
|
+
if (specialClassReg.test(el.tag)) {
|
|
1100
|
+
const staticClassNames = ['hover', 'indicator', 'mask']
|
|
1101
|
+
staticClassNames.forEach((className) => {
|
|
1102
|
+
let staticClass = el.attrsMap[className + '-class'] || ''
|
|
1103
|
+
let staticStyle = getAndRemoveAttr(el, className + '-style').val || ''
|
|
1104
|
+
staticClass = staticClass.replace(/\s+/g, ' ')
|
|
1105
|
+
staticStyle = staticStyle.replace(/\s+/g, ' ')
|
|
1106
|
+
if ((staticClass && staticClass !== 'none') || staticStyle) {
|
|
1107
|
+
const staticClassExp = parseMustacheWithContext(staticClass).result
|
|
1108
|
+
const staticStyleExp = parseMustacheWithContext(staticStyle).result
|
|
1109
|
+
addAttrs(el, [{
|
|
1110
|
+
name: className + '-style',
|
|
1111
|
+
value: `{{this.__getStyle(${staticClassExp}, null, ${staticStyleExp})}}`
|
|
1112
|
+
}])
|
|
1113
|
+
}
|
|
1114
|
+
})
|
|
1109
1115
|
}
|
|
1110
1116
|
|
|
1111
1117
|
// 处理externalClasses,将其转换为style作为props传递
|
|
@@ -1151,6 +1157,49 @@ function getModelConfig (el, match) {
|
|
|
1151
1157
|
}
|
|
1152
1158
|
}
|
|
1153
1159
|
|
|
1160
|
+
function processEventWeb (el) {
|
|
1161
|
+
const eventConfigMap = {}
|
|
1162
|
+
el.attrsList.forEach(function ({ name, value }) {
|
|
1163
|
+
if (/^@[a-zA-Z]+$/.test(name)) {
|
|
1164
|
+
const parsedFunc = parseFuncStr(value)
|
|
1165
|
+
if (parsedFunc) {
|
|
1166
|
+
if (!eventConfigMap[name]) {
|
|
1167
|
+
eventConfigMap[name] = {
|
|
1168
|
+
configs: []
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
eventConfigMap[name].configs.push(
|
|
1172
|
+
Object.assign({ name, value }, parsedFunc)
|
|
1173
|
+
)
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
})
|
|
1177
|
+
|
|
1178
|
+
// let wrapper
|
|
1179
|
+
for (const name in eventConfigMap) {
|
|
1180
|
+
const { configs } = eventConfigMap[name]
|
|
1181
|
+
if (!configs.length) continue
|
|
1182
|
+
configs.forEach(({ name }) => {
|
|
1183
|
+
if (name) {
|
|
1184
|
+
// 清空原始事件绑定
|
|
1185
|
+
let has
|
|
1186
|
+
do {
|
|
1187
|
+
has = getAndRemoveAttr(el, name).has
|
|
1188
|
+
} while (has)
|
|
1189
|
+
}
|
|
1190
|
+
})
|
|
1191
|
+
const value = `(e)=>__invoke(e, [${configs.map(
|
|
1192
|
+
(item) => item.expStr
|
|
1193
|
+
)}])`
|
|
1194
|
+
addAttrs(el, [
|
|
1195
|
+
{
|
|
1196
|
+
name,
|
|
1197
|
+
value
|
|
1198
|
+
}
|
|
1199
|
+
])
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1154
1203
|
function processEventReact (el) {
|
|
1155
1204
|
const eventConfigMap = {}
|
|
1156
1205
|
el.attrsList.forEach(function ({ name, value }) {
|
|
@@ -1227,7 +1276,8 @@ function processEventReact (el) {
|
|
|
1227
1276
|
])
|
|
1228
1277
|
} else {
|
|
1229
1278
|
const { name, value } = configs[0]
|
|
1230
|
-
|
|
1279
|
+
const { result } = parseMustacheWithContext(value)
|
|
1280
|
+
modifyAttr(el, name, `{{this[${result}]}}`)
|
|
1231
1281
|
}
|
|
1232
1282
|
|
|
1233
1283
|
// 非button的情况下,press/longPress时间需要包裹TouchableWithoutFeedback进行响应,后续可支持配置
|
|
@@ -1927,7 +1977,7 @@ function postProcessFor (el) {
|
|
|
1927
1977
|
function postProcessForReact (el) {
|
|
1928
1978
|
if (el.for) {
|
|
1929
1979
|
if (el.for.key) {
|
|
1930
|
-
addExp(el, `this.__getWxKey(${el.for.item || 'item'}, ${stringify(el.for.key)})`, false, 'key')
|
|
1980
|
+
addExp(el, `this.__getWxKey(${el.for.item || 'item'}, ${stringify(el.for.key)}, ${el.for.index || 'index'})`, false, 'key')
|
|
1931
1981
|
addAttrs(el, [{
|
|
1932
1982
|
name: 'key',
|
|
1933
1983
|
value: el.for.key
|
|
@@ -2063,16 +2113,22 @@ function processWrapTextReact (el, options, meta) {
|
|
|
2063
2113
|
if (parentTag !== 'mpx-text' && parentTag !== 'Text' && parentTag !== 'wxs') {
|
|
2064
2114
|
const wrapper = createASTElement('mpx-simple-text')
|
|
2065
2115
|
wrapper.isBuiltIn = true
|
|
2066
|
-
const
|
|
2116
|
+
const inheritAttrs = []
|
|
2067
2117
|
parent.attrsList.forEach(({ name, value }) => {
|
|
2068
2118
|
if (/^data-/.test(name)) {
|
|
2069
|
-
|
|
2119
|
+
inheritAttrs.push({
|
|
2070
2120
|
name,
|
|
2071
2121
|
value
|
|
2072
2122
|
})
|
|
2073
2123
|
}
|
|
2124
|
+
if (/^id$/.test(name)) {
|
|
2125
|
+
inheritAttrs.push({
|
|
2126
|
+
name: 'parentId',
|
|
2127
|
+
value
|
|
2128
|
+
})
|
|
2129
|
+
}
|
|
2074
2130
|
})
|
|
2075
|
-
addAttrs(wrapper,
|
|
2131
|
+
addAttrs(wrapper, inheritAttrs)
|
|
2076
2132
|
replaceNode(el, wrapper, true)
|
|
2077
2133
|
addChild(wrapper, el)
|
|
2078
2134
|
processBuiltInComponents(wrapper, meta)
|
|
@@ -2094,7 +2150,7 @@ function processWrapTextReact (el, options, meta) {
|
|
|
2094
2150
|
// }
|
|
2095
2151
|
|
|
2096
2152
|
function injectWxs (meta, module, src) {
|
|
2097
|
-
if (runtimeCompile || addWxsModule(meta, module, src) || isReact(mode) || isWeb(mode)
|
|
2153
|
+
if (runtimeCompile || addWxsModule(meta, module, src) || isReact(mode) || isWeb(mode)) {
|
|
2098
2154
|
return
|
|
2099
2155
|
}
|
|
2100
2156
|
|
|
@@ -2178,16 +2234,20 @@ function isRealNode (el) {
|
|
|
2178
2234
|
return !virtualNodeTagMap[el.tag]
|
|
2179
2235
|
}
|
|
2180
2236
|
|
|
2181
|
-
function isComponentNode (el
|
|
2237
|
+
function isComponentNode (el) {
|
|
2182
2238
|
return usingComponents.indexOf(el.tag) !== -1 || el.tag === 'component'
|
|
2183
2239
|
}
|
|
2184
2240
|
|
|
2185
|
-
function
|
|
2186
|
-
return
|
|
2241
|
+
function getComponentInfo (el) {
|
|
2242
|
+
return usingComponentsInfo[el.tag] || {}
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
function isReactComponent (el) {
|
|
2246
|
+
return !isComponentNode(el) && isRealNode(el) && !el.isBuiltIn
|
|
2187
2247
|
}
|
|
2188
2248
|
|
|
2189
2249
|
function processExternalClasses (el, options) {
|
|
2190
|
-
const isComponent = isComponentNode(el
|
|
2250
|
+
const isComponent = isComponentNode(el)
|
|
2191
2251
|
const classLikeAttrNames = isComponent ? ['class'].concat(options.externalClasses) : ['class']
|
|
2192
2252
|
|
|
2193
2253
|
classLikeAttrNames.forEach((classLikeAttrName) => {
|
|
@@ -2301,8 +2361,7 @@ function postProcessAliComponentRootView (el, options, meta) {
|
|
|
2301
2361
|
{ condition: /^style$/, action: 'move' },
|
|
2302
2362
|
{ condition: /^slot$/, action: 'move' }
|
|
2303
2363
|
]
|
|
2304
|
-
const
|
|
2305
|
-
const mid = options.usingComponentsInfo[tagName]?.mid || moduleId
|
|
2364
|
+
const mid = getComponentInfo(el).mid
|
|
2306
2365
|
const processAppendAttrsRules = [
|
|
2307
2366
|
{ name: 'class', value: `${MPX_ROOT_VIEW} host-${mid}` }
|
|
2308
2367
|
]
|
|
@@ -2409,7 +2468,7 @@ function processShow (el, options, root) {
|
|
|
2409
2468
|
show = has ? `{{${parseMustacheWithContext(show).result}&&mpxShow}}` : '{{mpxShow}}'
|
|
2410
2469
|
}
|
|
2411
2470
|
if (show === undefined) return
|
|
2412
|
-
if (isComponentNode(el
|
|
2471
|
+
if (isComponentNode(el) && getComponentInfo(el).hasVirtualHost) {
|
|
2413
2472
|
if (show === '') {
|
|
2414
2473
|
show = '{{false}}'
|
|
2415
2474
|
}
|
|
@@ -2626,20 +2685,12 @@ function processElement (el, root, options, meta) {
|
|
|
2626
2685
|
// 预处理代码维度条件编译
|
|
2627
2686
|
processIfWeb(el)
|
|
2628
2687
|
processScoped(el)
|
|
2688
|
+
processEventWeb(el)
|
|
2629
2689
|
// processWebExternalClassesHack(el, options)
|
|
2630
2690
|
processExternalClasses(el, options)
|
|
2631
2691
|
processComponentGenericsWeb(el, options, meta)
|
|
2632
2692
|
return
|
|
2633
2693
|
}
|
|
2634
|
-
if (mode === 'tenon') {
|
|
2635
|
-
// 收集内建组件
|
|
2636
|
-
processBuiltInComponents(el, meta)
|
|
2637
|
-
// 预处理代码维度条件编译
|
|
2638
|
-
processIfWeb(el)
|
|
2639
|
-
// processWebExternalClassesHack(el, options)
|
|
2640
|
-
// processComponentGenericsForWeb(el, options, meta)
|
|
2641
|
-
return
|
|
2642
|
-
}
|
|
2643
2694
|
|
|
2644
2695
|
if (isReact(mode)) {
|
|
2645
2696
|
const pass = isReactComponent(el, options)
|
|
@@ -2695,7 +2746,7 @@ function closeElement (el, options, meta) {
|
|
|
2695
2746
|
postProcessAtMode(el)
|
|
2696
2747
|
postProcessWxs(el, meta)
|
|
2697
2748
|
|
|
2698
|
-
if (isWeb(mode)
|
|
2749
|
+
if (isWeb(mode)) {
|
|
2699
2750
|
// 处理代码维度条件编译移除死分支
|
|
2700
2751
|
postProcessIf(el)
|
|
2701
2752
|
return
|
|
@@ -2710,14 +2761,14 @@ function closeElement (el, options, meta) {
|
|
|
2710
2761
|
if (!isTemplate) {
|
|
2711
2762
|
if (!isNative) {
|
|
2712
2763
|
postProcessComponentIs(el, (child) => {
|
|
2713
|
-
if (!hasVirtualHost && mode === 'ali') {
|
|
2764
|
+
if (!getComponentInfo(el).hasVirtualHost && mode === 'ali') {
|
|
2714
2765
|
postProcessAliComponentRootView(child, options)
|
|
2715
2766
|
} else {
|
|
2716
2767
|
postProcessIf(child)
|
|
2717
2768
|
}
|
|
2718
2769
|
})
|
|
2719
2770
|
}
|
|
2720
|
-
if (isComponentNode(el
|
|
2771
|
+
if (isComponentNode(el) && !getComponentInfo(el).hasVirtualHost && mode === 'ali' && el.tag !== 'component') {
|
|
2721
2772
|
postProcessAliComponentRootView(el, options, meta)
|
|
2722
2773
|
}
|
|
2723
2774
|
}
|
|
@@ -2828,6 +2879,7 @@ function serialize (root) {
|
|
|
2828
2879
|
result += node.text
|
|
2829
2880
|
}
|
|
2830
2881
|
}
|
|
2882
|
+
|
|
2831
2883
|
if (node.type === 1) {
|
|
2832
2884
|
if (node.tag !== 'temp-node') {
|
|
2833
2885
|
result += '<' + node.tag
|
package/lib/utils/env.js
CHANGED
|
@@ -6,17 +6,12 @@ function isWeb (mode) {
|
|
|
6
6
|
return mode === 'web'
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
function isTenon (mode) {
|
|
10
|
-
return mode === 'tenon'
|
|
11
|
-
}
|
|
12
|
-
|
|
13
9
|
function isMiniProgram (mode) {
|
|
14
|
-
return !isWeb(mode) && !isReact(mode)
|
|
10
|
+
return !isWeb(mode) && !isReact(mode)
|
|
15
11
|
}
|
|
16
12
|
|
|
17
13
|
module.exports = {
|
|
18
14
|
isWeb,
|
|
19
15
|
isReact,
|
|
20
|
-
isTenon,
|
|
21
16
|
isMiniProgram
|
|
22
17
|
}
|
|
@@ -6,6 +6,7 @@ const addQuery = require('./add-query')
|
|
|
6
6
|
const resolve = require('./resolve')
|
|
7
7
|
const getJSONContent = require('./get-json-content')
|
|
8
8
|
const getRulesRunner = require('../platform')
|
|
9
|
+
const { matchCondition } = require('./match-condition')
|
|
9
10
|
const async = require('async')
|
|
10
11
|
|
|
11
12
|
module.exports = function ({
|
|
@@ -19,8 +20,7 @@ module.exports = function ({
|
|
|
19
20
|
}, callback) {
|
|
20
21
|
const mpx = loaderContext.getMpx()
|
|
21
22
|
const context = loaderContext.context
|
|
22
|
-
const mode = mpx
|
|
23
|
-
const pagesMap = mpx.pagesMap
|
|
23
|
+
const { mode, pagesMap, autoVirtualHostRules } = mpx
|
|
24
24
|
async.waterfall([
|
|
25
25
|
(callback) => {
|
|
26
26
|
getJSONContent(json, null, loaderContext, callback)
|
|
@@ -78,8 +78,8 @@ module.exports = function ({
|
|
|
78
78
|
componentGenerics = Object.assign({}, ret.componentGenerics)
|
|
79
79
|
}
|
|
80
80
|
if (usingComponents) {
|
|
81
|
-
const setUsingComponentInfo = (name,
|
|
82
|
-
usingComponentsInfo[name] =
|
|
81
|
+
const setUsingComponentInfo = (name, info) => {
|
|
82
|
+
usingComponentsInfo[name] = info
|
|
83
83
|
}
|
|
84
84
|
async.eachOf(usingComponents, (component, name, callback) => {
|
|
85
85
|
if (ctorType === 'app') {
|
|
@@ -96,7 +96,11 @@ module.exports = function ({
|
|
|
96
96
|
if (err) return callback(err)
|
|
97
97
|
const { rawResourcePath } = parseRequest(resource)
|
|
98
98
|
const moduleId = mpx.getModuleId(rawResourcePath, ctorType === 'app')
|
|
99
|
-
|
|
99
|
+
const hasVirtualHost = matchCondition(rawResourcePath, autoVirtualHostRules)
|
|
100
|
+
setUsingComponentInfo(name, {
|
|
101
|
+
mid: moduleId,
|
|
102
|
+
hasVirtualHost
|
|
103
|
+
})
|
|
100
104
|
callback()
|
|
101
105
|
})
|
|
102
106
|
}, (err) => {
|
package/lib/wxss/loader.js
CHANGED
|
@@ -32,6 +32,13 @@ const {
|
|
|
32
32
|
} = require('./utils')
|
|
33
33
|
const createHelpers = require('../helpers')
|
|
34
34
|
|
|
35
|
+
const RN_PRESET_OPTIMISATION = {
|
|
36
|
+
reduceInitial: false,
|
|
37
|
+
normalizeWhitespace: false,
|
|
38
|
+
minifyFontValues: false,
|
|
39
|
+
convertValues: false
|
|
40
|
+
}
|
|
41
|
+
|
|
35
42
|
module.exports = async function loader (content, map, meta) {
|
|
36
43
|
const rawOptions = this.getOptions(schema)
|
|
37
44
|
const plugins = []
|
|
@@ -41,6 +48,7 @@ module.exports = async function loader (content, map, meta) {
|
|
|
41
48
|
const externals = mpx.externals
|
|
42
49
|
const root = mpx.projectRoot
|
|
43
50
|
const sourceMap = mpx.cssSourceMap || false
|
|
51
|
+
const isRN = ['ios', 'android', 'harmony'].includes(mpx.mode)
|
|
44
52
|
|
|
45
53
|
let options
|
|
46
54
|
|
|
@@ -152,12 +160,17 @@ module.exports = async function loader (content, map, meta) {
|
|
|
152
160
|
if (this.minimize) {
|
|
153
161
|
const cssnano = require('cssnano')
|
|
154
162
|
const minimizeOptions = rawOptions.minimize || {}
|
|
163
|
+
const presetOptimisation = Object.assign(
|
|
164
|
+
{},
|
|
165
|
+
isRN ? RN_PRESET_OPTIMISATION : {},
|
|
166
|
+
minimizeOptions.optimisation
|
|
167
|
+
)
|
|
155
168
|
let cssnanoConfig = {
|
|
156
|
-
preset: ['cssnano-preset-default',
|
|
169
|
+
preset: ['cssnano-preset-default', presetOptimisation]
|
|
157
170
|
}
|
|
158
171
|
if (minimizeOptions.advanced) {
|
|
159
172
|
cssnanoConfig = {
|
|
160
|
-
preset: ['cssnano-preset-advanced',
|
|
173
|
+
preset: ['cssnano-preset-advanced', presetOptimisation]
|
|
161
174
|
}
|
|
162
175
|
}
|
|
163
176
|
plugins.push(cssnano(cssnanoConfig))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.71",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -27,11 +27,8 @@
|
|
|
27
27
|
"@better-scroll/slide": "^2.5.1",
|
|
28
28
|
"@better-scroll/wheel": "^2.5.1",
|
|
29
29
|
"@better-scroll/zoom": "^2.5.1",
|
|
30
|
-
"@hummer/tenon-dev-server-webpack-plugin": "0.0.2",
|
|
31
|
-
"@hummer/tenon-loader": "^1.2.0",
|
|
32
|
-
"@hummer/tenon-style-loader": "^0.2.0",
|
|
33
30
|
"@mpxjs/template-engine": "^2.8.7",
|
|
34
|
-
"@mpxjs/utils": "
|
|
31
|
+
"@mpxjs/utils": "^2.9.70",
|
|
35
32
|
"acorn": "^8.11.3",
|
|
36
33
|
"acorn-walk": "^7.2.0",
|
|
37
34
|
"async": "^2.6.0",
|
|
@@ -86,7 +83,7 @@
|
|
|
86
83
|
"devDependencies": {
|
|
87
84
|
"@ant-design/react-native": "^5.2.2",
|
|
88
85
|
"@d11/react-native-fast-image": "^8.6.12",
|
|
89
|
-
"@mpxjs/api-proxy": "^2.9.
|
|
86
|
+
"@mpxjs/api-proxy": "^2.9.71",
|
|
90
87
|
"@types/babel-traverse": "^6.25.4",
|
|
91
88
|
"@types/babel-types": "^7.0.4",
|
|
92
89
|
"@types/react": "^18.2.79",
|
|
@@ -102,5 +99,5 @@
|
|
|
102
99
|
"engines": {
|
|
103
100
|
"node": ">=14.14.0"
|
|
104
101
|
},
|
|
105
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "38446f301a17e78dbe3ca7dacd771c79eb7a8ede"
|
|
106
103
|
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const NullDependency = require('webpack/lib/dependencies/NullDependency')
|
|
2
|
-
|
|
3
|
-
class AddEntryDependency extends NullDependency {
|
|
4
|
-
constructor ({ context, dep, name }) {
|
|
5
|
-
super()
|
|
6
|
-
this.__addEntryParams = [context, dep, name]
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
get type () {
|
|
10
|
-
return 'mpx add entry'
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// updateHash (hash) {
|
|
14
|
-
// super.updateHash(hash)
|
|
15
|
-
// hash.update(this.childCompileEntryModule.identifier())
|
|
16
|
-
// }
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
AddEntryDependency.Template = class AddEntryDependencyTemplate {
|
|
20
|
-
apply () {
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = AddEntryDependency
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|