@mpxjs/webpack-plugin 2.10.15-4 → 2.10.15

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.
Files changed (27) hide show
  1. package/LICENSE +433 -0
  2. package/lib/index.js +2 -5
  3. package/lib/platform/template/wx/component-config/progress.js +12 -0
  4. package/lib/platform/template/wx/component-config/unsupported.js +1 -1
  5. package/lib/platform/template/wx/index.js +3 -1
  6. package/lib/runtime/components/react/dist/getInnerListeners.js +35 -21
  7. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +102 -34
  8. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +3 -5
  9. package/lib/runtime/components/react/dist/mpx-progress.jsx +159 -0
  10. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +51 -9
  11. package/lib/runtime/components/react/dist/mpx-swiper.jsx +9 -16
  12. package/lib/runtime/components/react/dist/mpx-web-view.jsx +20 -1
  13. package/lib/runtime/components/react/getInnerListeners.ts +41 -22
  14. package/lib/runtime/components/react/mpx-movable-view.tsx +156 -48
  15. package/lib/runtime/components/react/mpx-portal/portal-manager.tsx +4 -8
  16. package/lib/runtime/components/react/mpx-progress.tsx +257 -0
  17. package/lib/runtime/components/react/mpx-scroll-view.tsx +54 -9
  18. package/lib/runtime/components/react/mpx-swiper.tsx +9 -16
  19. package/lib/runtime/components/react/mpx-web-view.tsx +22 -1
  20. package/lib/runtime/components/react/types/getInnerListeners.d.ts +7 -2
  21. package/lib/runtime/components/web/mpx-movable-area.vue +43 -19
  22. package/lib/runtime/components/web/mpx-movable-view.vue +93 -3
  23. package/lib/runtime/components/web/mpx-swiper.vue +1 -2
  24. package/lib/runtime/components/web/mpx-web-view.vue +3 -3
  25. package/lib/template-compiler/compiler.js +61 -31
  26. package/lib/wxss/utils.js +1 -1
  27. package/package.json +3 -3
@@ -1333,8 +1333,35 @@ function processEventReact (el, options) {
1333
1333
  // }
1334
1334
  }
1335
1335
 
1336
+ function isNeedBind (configs, isProxy) {
1337
+ if (isProxy) return true
1338
+ if (configs.length > 1) return true
1339
+ if (configs.length === 1) return configs[0].hasArgs
1340
+ return false
1341
+ }
1342
+
1343
+ function processEventBinding (el, configs) {
1344
+ let resultName
1345
+ configs.forEach(({ name }) => {
1346
+ if (name) {
1347
+ // 清空原始事件绑定
1348
+ let has
1349
+ do {
1350
+ has = getAndRemoveAttr(el, name).has
1351
+ } while (has)
1352
+
1353
+ if (!resultName) {
1354
+ // 清除修饰符
1355
+ resultName = name.replace(/\..*/, '')
1356
+ }
1357
+ }
1358
+ })
1359
+ return { resultName }
1360
+ }
1361
+
1336
1362
  function processEvent (el, options) {
1337
1363
  const eventConfigMap = {}
1364
+ const finalEventsMap = {}
1338
1365
  el.attrsList.forEach(function ({ name, value }) {
1339
1366
  const parsedEvent = config[mode].event.parseEvent(name)
1340
1367
 
@@ -1346,12 +1373,15 @@ function processEvent (el, options) {
1346
1373
  const extraStr = runtimeCompile && prefix === 'catch' ? `, "__mpx_${prefix}"` : ''
1347
1374
  const parsedFunc = parseFuncStr(value, extraStr)
1348
1375
  if (parsedFunc) {
1376
+ const isCapture = /^capture/.test(prefix)
1349
1377
  if (!eventConfigMap[type]) {
1350
1378
  eventConfigMap[type] = {
1351
- configs: []
1379
+ configs: [],
1380
+ captureConfigs: []
1352
1381
  }
1353
1382
  }
1354
- eventConfigMap[type].configs.push(Object.assign({ name }, parsedFunc))
1383
+ const targetConfigs = isCapture ? eventConfigMap[type].captureConfigs : eventConfigMap[type].configs
1384
+ targetConfigs.push(Object.assign({ name }, parsedFunc))
1355
1385
  if (modifiers.indexOf('proxy') > -1 || options.forceProxyEvent) {
1356
1386
  eventConfigMap[type].proxy = true
1357
1387
  }
@@ -1393,57 +1423,57 @@ function processEvent (el, options) {
1393
1423
  }
1394
1424
 
1395
1425
  for (const type in eventConfigMap) {
1396
- let needBind = false
1397
- const { configs, proxy } = eventConfigMap[type]
1398
- delete eventConfigMap[type]
1399
- if (proxy) {
1400
- needBind = true
1401
- } else if (configs.length > 1) {
1402
- needBind = true
1403
- } else if (configs.length === 1) {
1404
- needBind = !!configs[0].hasArgs
1405
- }
1426
+ const { configs = [], captureConfigs = [], proxy } = eventConfigMap[type]
1427
+
1428
+ let needBubblingBind = isNeedBind(configs, proxy)
1429
+ let needCaptureBind = isNeedBind(captureConfigs, proxy)
1406
1430
 
1407
1431
  const escapedType = dash2hump(type)
1408
1432
  // 排除特殊情况
1409
1433
  if (!isValidIdentifierStr(escapedType)) {
1410
1434
  warn$1(`EventName ${type} which need be framework proxy processed must be a valid identifier!`)
1411
- needBind = false
1435
+ needBubblingBind = false
1436
+ needCaptureBind = false
1412
1437
  }
1413
1438
 
1414
- if (needBind) {
1415
- let resultName
1416
- configs.forEach(({ name }) => {
1417
- if (name) {
1418
- // 清空原始事件绑定
1419
- let has
1420
- do {
1421
- has = getAndRemoveAttr(el, name).has
1422
- } while (has)
1439
+ if (needBubblingBind) {
1440
+ const { resultName } = processEventBinding(el, configs)
1423
1441
 
1424
- if (!resultName) {
1425
- // 清除修饰符
1426
- resultName = name.replace(/\..*/, '')
1427
- }
1442
+ addAttrs(el, [
1443
+ {
1444
+ name: resultName || config[mode].event.getEvent(type),
1445
+ value: '__invoke'
1428
1446
  }
1447
+ ])
1448
+ if (!finalEventsMap.bubble) {
1449
+ finalEventsMap.bubble = {}
1450
+ }
1451
+ finalEventsMap.bubble[escapedType] = configs.map((item) => {
1452
+ return item.expStr
1429
1453
  })
1454
+ }
1430
1455
 
1456
+ if (needCaptureBind) {
1457
+ const { resultName } = processEventBinding(el, captureConfigs)
1431
1458
  addAttrs(el, [
1432
1459
  {
1433
1460
  name: resultName || config[mode].event.getEvent(type),
1434
- value: '__invoke'
1461
+ value: '__captureInvoke'
1435
1462
  }
1436
1463
  ])
1437
- eventConfigMap[escapedType] = configs.map((item) => {
1464
+ if (!finalEventsMap.capture) {
1465
+ finalEventsMap.capture = {}
1466
+ }
1467
+ finalEventsMap.capture[escapedType] = captureConfigs.map((item) => {
1438
1468
  return item.expStr
1439
1469
  })
1440
1470
  }
1441
1471
  }
1442
1472
 
1443
- if (!isEmptyObject(eventConfigMap)) {
1473
+ if (!isEmptyObject(finalEventsMap)) {
1444
1474
  addAttrs(el, [{
1445
1475
  name: 'data-eventconfigs',
1446
- value: `{{${shallowStringify(eventConfigMap, true)}}}`
1476
+ value: `{{${shallowStringify(finalEventsMap, true)}}}`
1447
1477
  }])
1448
1478
  }
1449
1479
  }
@@ -2737,8 +2767,8 @@ function processElement (el, root, options, meta) {
2737
2767
  processIf(el)
2738
2768
  processFor(el)
2739
2769
  processRefReact(el, meta)
2770
+ processStyleReact(el, options)
2740
2771
  if (!pass) {
2741
- processStyleReact(el, options)
2742
2772
  processEventReact(el, options)
2743
2773
  processComponentGenerics(el, meta)
2744
2774
  processComponentIs(el, options)
package/lib/wxss/utils.js CHANGED
@@ -1052,7 +1052,7 @@ function getModuleCode (
1052
1052
  `@import url(${url});`
1053
1053
  )}${printedParam.length > 0 ? `, ${printedParam}` : ''}]);\n`
1054
1054
  } else {
1055
- // 符合css后缀名的文件经过mpx处理后会带上相应的后缀防止使用 WebPack 的默认解析规则,此时 require/import 相应路径时,导出的不是一段 css 代码了,事实上是一个文件路径。
1055
+ // 符合css后缀名的文件经过mpx处理后会带上相应的后缀防止使用 webpack 的默认解析规则,此时 require/import 相应路径时,导出的不是一段 css 代码了,事实上是一个文件路径。
1056
1056
  const printedParam = printParams(media, dedupe, supports, layer)
1057
1057
  const otherParams = printedParam.length > 0 ? printedParam : ''
1058
1058
  beforeCode += `___CSS_LOADER_EXPORT___.push([module.id, '@import "' + ${item.importName} + '";', ${JSON.stringify(otherParams)} ]);\n`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.10.15-4",
3
+ "version": "2.10.15",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
@@ -83,7 +83,7 @@
83
83
  },
84
84
  "devDependencies": {
85
85
  "@d11/react-native-fast-image": "^8.6.12",
86
- "@mpxjs/api-proxy": "^2.10.13",
86
+ "@mpxjs/api-proxy": "^2.10.15",
87
87
  "@types/babel-traverse": "^6.25.4",
88
88
  "@types/babel-types": "^7.0.4",
89
89
  "@types/react": "^18.2.79",
@@ -100,5 +100,5 @@
100
100
  "engines": {
101
101
  "node": ">=14.14.0"
102
102
  },
103
- "gitHead": "2d37697869b9bdda3efab92dda8c910b68fd05c0"
103
+ "gitHead": "4ea4a54f55aa938ad139e080827cffbbf7bb82db"
104
104
  }