@mpxjs/webpack-plugin 2.9.55 → 2.9.57
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 +2 -0
- package/lib/json-compiler/index.js +2 -1
- package/lib/platform/json/wx/index.js +0 -1
- package/lib/runtime/base.styl +27 -0
- package/lib/runtime/components/react/dist/event.config.js +27 -0
- package/lib/runtime/components/react/dist/getInnerListeners.js +230 -0
- package/lib/runtime/components/react/dist/mpx-button.jsx +270 -0
- package/lib/runtime/components/react/dist/mpx-image/index.jsx +229 -0
- package/lib/runtime/components/react/dist/mpx-image/svg.jsx +6 -0
- package/lib/runtime/components/react/dist/mpx-input.jsx +203 -0
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +294 -0
- package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +353 -0
- package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +57 -0
- package/lib/runtime/components/react/dist/mpx-swiper/type.js +1 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +25 -0
- package/lib/runtime/components/react/dist/mpx-text.jsx +67 -0
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +27 -0
- package/lib/runtime/components/react/dist/mpx-view.jsx +307 -0
- package/lib/runtime/components/react/dist/types/getInnerListeners.js +1 -0
- package/lib/runtime/components/react/dist/useNodesRef.js +25 -0
- package/lib/runtime/components/react/dist/utils.js +80 -0
- package/lib/runtime/components/react/getInnerListeners.ts +1 -1
- package/lib/runtime/components/react/mpx-button.tsx +1 -2
- package/lib/runtime/components/react/mpx-image/svg.tsx +0 -1
- package/lib/runtime/components/react/{getInnerListeners.type.ts → types/getInnerListeners.ts} +2 -2
- package/lib/runtime/components/react/types/global.d.ts +15 -0
- package/lib/runtime/optionProcessor.js +27 -1
- package/lib/template-compiler/compiler.js +72 -25
- package/lib/template-compiler/index.js +2 -1
- package/lib/web/processTemplate.js +1 -1
- package/package.json +7 -4
|
@@ -75,7 +75,32 @@ registered in parent context!`)
|
|
|
75
75
|
if (outputPath) {
|
|
76
76
|
option.componentPath = '/' + outputPath
|
|
77
77
|
}
|
|
78
|
+
if (ctorType === 'app') {
|
|
79
|
+
option.data = function () {
|
|
80
|
+
return {
|
|
81
|
+
transitionName: ''
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
option.watch = {
|
|
85
|
+
$route: {
|
|
86
|
+
handler () {
|
|
87
|
+
const actionType = global.__mpxRouter.currentActionType
|
|
78
88
|
|
|
89
|
+
switch (actionType) {
|
|
90
|
+
case 'to':
|
|
91
|
+
this.transitionName = 'mpx-slide-left'
|
|
92
|
+
break
|
|
93
|
+
case 'back':
|
|
94
|
+
this.transitionName = 'mpx-slide-right'
|
|
95
|
+
break
|
|
96
|
+
default:
|
|
97
|
+
this.transitionName = ''
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
immediate: true
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
79
104
|
return option
|
|
80
105
|
}
|
|
81
106
|
|
|
@@ -160,6 +185,7 @@ function createApp ({ componentsMap, Vue, pagesMap, firstPage, VueRouter, App, t
|
|
|
160
185
|
global.__mpxRouter.needCache = null
|
|
161
186
|
global.__mpxRouter.needRemove = []
|
|
162
187
|
global.__mpxRouter.eventChannelMap = {}
|
|
188
|
+
global.__mpxRouter.currentActionType = null
|
|
163
189
|
// 处理reLaunch中传递的url并非首页时的replace逻辑
|
|
164
190
|
global.__mpxRouter.beforeEach(function (to, from, next) {
|
|
165
191
|
let action = global.__mpxRouter.__mpxAction
|
|
@@ -178,7 +204,7 @@ function createApp ({ componentsMap, Vue, pagesMap, firstPage, VueRouter, App, t
|
|
|
178
204
|
}
|
|
179
205
|
}
|
|
180
206
|
}
|
|
181
|
-
|
|
207
|
+
global.__mpxRouter.currentActionType = action.type
|
|
182
208
|
const pageInRoutes = routes.some(item => item.path === to.path)
|
|
183
209
|
if (!pageInRoutes) {
|
|
184
210
|
if (stack.length < 1) {
|
|
@@ -1094,6 +1094,33 @@ function processStyleReact (el) {
|
|
|
1094
1094
|
}
|
|
1095
1095
|
}
|
|
1096
1096
|
|
|
1097
|
+
function getModelConfig (el, match) {
|
|
1098
|
+
const modelProp = getAndRemoveAttr(el, config[mode].directive.modelProp).val || config[mode].event.defaultModelProp
|
|
1099
|
+
const modelEvent = getAndRemoveAttr(el, config[mode].directive.modelEvent).val || config[mode].event.defaultModelEvent
|
|
1100
|
+
const modelValuePathRaw = getAndRemoveAttr(el, config[mode].directive.modelValuePath).val
|
|
1101
|
+
const modelValuePath = modelValuePathRaw === undefined ? config[mode].event.defaultModelValuePath : modelValuePathRaw
|
|
1102
|
+
const modelFilter = getAndRemoveAttr(el, config[mode].directive.modelFilter).val
|
|
1103
|
+
let modelValuePathArr
|
|
1104
|
+
try {
|
|
1105
|
+
modelValuePathArr = JSON5.parse(modelValuePath)
|
|
1106
|
+
} catch (e) {
|
|
1107
|
+
if (modelValuePath === '') {
|
|
1108
|
+
modelValuePathArr = []
|
|
1109
|
+
} else {
|
|
1110
|
+
modelValuePathArr = modelValuePath.split('.')
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
const modelValue = match[1].trim()
|
|
1114
|
+
const stringifiedModelValue = stringifyWithResolveComputed(modelValue)
|
|
1115
|
+
return {
|
|
1116
|
+
modelProp,
|
|
1117
|
+
modelEvent,
|
|
1118
|
+
modelFilter,
|
|
1119
|
+
modelValuePathArr,
|
|
1120
|
+
stringifiedModelValue
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1097
1124
|
function processEventReact (el, options, meta) {
|
|
1098
1125
|
const eventConfigMap = {}
|
|
1099
1126
|
el.attrsList.forEach(function ({ name, value }) {
|
|
@@ -1112,7 +1139,39 @@ function processEventReact (el, options, meta) {
|
|
|
1112
1139
|
}
|
|
1113
1140
|
})
|
|
1114
1141
|
|
|
1115
|
-
|
|
1142
|
+
const modelExp = getAndRemoveAttr(el, config[mode].directive.model).val
|
|
1143
|
+
if (modelExp) {
|
|
1144
|
+
const match = tagRE.exec(modelExp)
|
|
1145
|
+
if (match) {
|
|
1146
|
+
const { modelProp, modelEvent, modelFilter, modelValuePathArr, stringifiedModelValue } = getModelConfig(el, match)
|
|
1147
|
+
if (!isValidIdentifierStr(modelEvent)) {
|
|
1148
|
+
warn$1(`EventName ${modelEvent} which is used in ${config[mode].directive.model} must be a valid identifier!`)
|
|
1149
|
+
return
|
|
1150
|
+
}
|
|
1151
|
+
// if (forScopes.length) {
|
|
1152
|
+
// stringifiedModelValue = stringifyWithResolveComputed(modelValue)
|
|
1153
|
+
// } else {
|
|
1154
|
+
// stringifiedModelValue = stringify(modelValue)
|
|
1155
|
+
// }
|
|
1156
|
+
if (!eventConfigMap[modelEvent]) {
|
|
1157
|
+
eventConfigMap[modelEvent] = {
|
|
1158
|
+
configs: []
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
eventConfigMap[modelEvent].configs.unshift({
|
|
1162
|
+
hasArgs: true,
|
|
1163
|
+
expStr: `[${stringify('__model')},${stringifiedModelValue},${stringify(eventIdentifier)},${stringify(modelValuePathArr)}${modelFilter ? `,${stringify(modelFilter)}` : ''}]`
|
|
1164
|
+
})
|
|
1165
|
+
addAttrs(el, [
|
|
1166
|
+
{
|
|
1167
|
+
name: modelProp,
|
|
1168
|
+
value: modelExp
|
|
1169
|
+
}
|
|
1170
|
+
])
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
// let wrapper
|
|
1116
1175
|
|
|
1117
1176
|
for (const type in eventConfigMap) {
|
|
1118
1177
|
let { configs } = eventConfigMap[type]
|
|
@@ -1166,12 +1225,12 @@ function processEventReact (el, options, meta) {
|
|
|
1166
1225
|
// }
|
|
1167
1226
|
}
|
|
1168
1227
|
|
|
1169
|
-
if (wrapper) {
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
}
|
|
1228
|
+
// if (wrapper) {
|
|
1229
|
+
// replaceNode(el, wrapper, true)
|
|
1230
|
+
// addChild(wrapper, el)
|
|
1231
|
+
// processAttrs(wrapper, options)
|
|
1232
|
+
// postMoveBaseDirective(wrapper, el)
|
|
1233
|
+
// }
|
|
1175
1234
|
}
|
|
1176
1235
|
|
|
1177
1236
|
function processEvent (el, options) {
|
|
@@ -1204,27 +1263,11 @@ function processEvent (el, options) {
|
|
|
1204
1263
|
if (modelExp) {
|
|
1205
1264
|
const match = tagRE.exec(modelExp)
|
|
1206
1265
|
if (match) {
|
|
1207
|
-
const modelProp =
|
|
1208
|
-
const modelEvent = getAndRemoveAttr(el, config[mode].directive.modelEvent).val || config[mode].event.defaultModelEvent
|
|
1209
|
-
const modelValuePathRaw = getAndRemoveAttr(el, config[mode].directive.modelValuePath).val
|
|
1210
|
-
const modelValuePath = modelValuePathRaw === undefined ? config[mode].event.defaultModelValuePath : modelValuePathRaw
|
|
1211
|
-
const modelFilter = getAndRemoveAttr(el, config[mode].directive.modelFilter).val
|
|
1212
|
-
let modelValuePathArr
|
|
1213
|
-
try {
|
|
1214
|
-
modelValuePathArr = JSON5.parse(modelValuePath)
|
|
1215
|
-
} catch (e) {
|
|
1216
|
-
if (modelValuePath === '') {
|
|
1217
|
-
modelValuePathArr = []
|
|
1218
|
-
} else {
|
|
1219
|
-
modelValuePathArr = modelValuePath.split('.')
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1266
|
+
const { modelProp, modelEvent, modelFilter, modelValuePathArr, stringifiedModelValue } = getModelConfig(el, match)
|
|
1222
1267
|
if (!isValidIdentifierStr(modelEvent)) {
|
|
1223
1268
|
warn$1(`EventName ${modelEvent} which is used in ${config[mode].directive.model} must be a valid identifier!`)
|
|
1224
1269
|
return
|
|
1225
1270
|
}
|
|
1226
|
-
const modelValue = match[1].trim()
|
|
1227
|
-
const stringifiedModelValue = stringifyWithResolveComputed(modelValue)
|
|
1228
1271
|
// if (forScopes.length) {
|
|
1229
1272
|
// stringifiedModelValue = stringifyWithResolveComputed(modelValue)
|
|
1230
1273
|
// } else {
|
|
@@ -2173,7 +2216,7 @@ function processBuiltInComponents (el, meta) {
|
|
|
2173
2216
|
const tag = el.tag
|
|
2174
2217
|
if (!meta.builtInComponentsMap[tag]) {
|
|
2175
2218
|
if (isReact(mode)) {
|
|
2176
|
-
meta.builtInComponentsMap[tag] = `${builtInComponentsPrefix}/react/${tag}`
|
|
2219
|
+
meta.builtInComponentsMap[tag] = `${builtInComponentsPrefix}/react/dist/${tag}`
|
|
2177
2220
|
} else {
|
|
2178
2221
|
meta.builtInComponentsMap[tag] = `${builtInComponentsPrefix}/${mode}/${tag}`
|
|
2179
2222
|
}
|
|
@@ -2492,6 +2535,10 @@ function processElement (el, root, options, meta) {
|
|
|
2492
2535
|
return
|
|
2493
2536
|
}
|
|
2494
2537
|
|
|
2538
|
+
if (runtimeCompile && options.dynamicTemplateRuleRunner) {
|
|
2539
|
+
options.dynamicTemplateRuleRunner(el, options, config[mode])
|
|
2540
|
+
}
|
|
2541
|
+
|
|
2495
2542
|
if (rulesRunner && el._atModeStatus !== 'match') {
|
|
2496
2543
|
currentEl = el
|
|
2497
2544
|
rulesRunner(el)
|
|
@@ -76,7 +76,8 @@ module.exports = function (raw) {
|
|
|
76
76
|
checkUsingComponents: matchCondition(resourcePath, mpx.checkUsingComponentsRules),
|
|
77
77
|
globalComponents: Object.keys(mpx.usingComponents),
|
|
78
78
|
forceProxyEvent: matchCondition(resourcePath, mpx.forceProxyEventRules) || runtimeCompile,
|
|
79
|
-
hasVirtualHost: matchCondition(resourcePath, mpx.autoVirtualHostRules)
|
|
79
|
+
hasVirtualHost: matchCondition(resourcePath, mpx.autoVirtualHostRules),
|
|
80
|
+
dynamicTemplateRuleRunner: mpx.dynamicTemplateRuleRunner
|
|
80
81
|
})
|
|
81
82
|
|
|
82
83
|
if (meta.wxsContentMap) {
|
|
@@ -38,7 +38,7 @@ module.exports = function (template, {
|
|
|
38
38
|
const idName = (el && el.match(/#(.*)/) && el.match(/#(.*)/)[1]) || 'app'
|
|
39
39
|
template = {
|
|
40
40
|
tag: 'template',
|
|
41
|
-
content: `<div id="${idName}"><mpx-keep-alive><router-view></router-view></mpx-keep-alive></div>`
|
|
41
|
+
content: `<div id="${idName}"><transition :name="transitionName"><mpx-keep-alive><router-view></router-view></mpx-keep-alive></transition></div>`
|
|
42
42
|
}
|
|
43
43
|
builtInComponentsMap['mpx-keep-alive'] = {
|
|
44
44
|
resource: addQuery('@mpxjs/webpack-plugin/lib/runtime/components/web/mpx-keep-alive.vue', { isComponent: true })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.57",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -76,15 +76,18 @@
|
|
|
76
76
|
"url": "https://github.com/didi/mpx/issues"
|
|
77
77
|
},
|
|
78
78
|
"scripts": {
|
|
79
|
-
"test": "jest"
|
|
79
|
+
"test": "jest",
|
|
80
|
+
"build": "rimraf ./lib/runtime/components/react/dist && tsc"
|
|
80
81
|
},
|
|
81
82
|
"devDependencies": {
|
|
82
83
|
"@types/babel-traverse": "^6.25.4",
|
|
83
84
|
"@types/babel-types": "^7.0.4",
|
|
84
|
-
"@types/react": "^18.2.79"
|
|
85
|
+
"@types/react": "^18.2.79",
|
|
86
|
+
"react-native": "^0.74.5",
|
|
87
|
+
"rimraf": "^6.0.1"
|
|
85
88
|
},
|
|
86
89
|
"engines": {
|
|
87
90
|
"node": ">=14.14.0"
|
|
88
91
|
},
|
|
89
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "f52627676fd798818980c2d1a6890c5ea99e2862"
|
|
90
93
|
}
|