@mpxjs/webpack-plugin 2.9.67 → 2.9.69-beta.0
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 +13 -8
- package/lib/platform/json/wx/index.js +21 -8
- package/lib/platform/style/wx/index.js +35 -38
- package/lib/platform/template/wx/component-config/canvas.js +8 -0
- package/lib/platform/template/wx/component-config/fix-component-name.js +15 -12
- package/lib/platform/template/wx/component-config/index.js +1 -1
- package/lib/platform/template/wx/component-config/input.js +1 -1
- package/lib/platform/template/wx/component-config/rich-text.js +8 -0
- package/lib/platform/template/wx/component-config/swiper.js +1 -1
- package/lib/platform/template/wx/component-config/textarea.js +1 -1
- package/lib/platform/template/wx/component-config/unsupported.js +1 -1
- package/lib/react/processStyles.js +14 -4
- package/lib/react/processTemplate.js +3 -0
- package/lib/resolver/AddModePlugin.js +8 -8
- package/lib/runtime/components/react/context.ts +6 -0
- package/lib/runtime/components/react/dist/context.js +2 -0
- package/lib/runtime/components/react/dist/event.config.js +24 -24
- package/lib/runtime/components/react/dist/getInnerListeners.js +183 -174
- package/lib/runtime/components/react/dist/mpx-button.jsx +77 -49
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.js +60 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.js +15 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.js +84 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Image.js +87 -0
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.js +15 -0
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.js +28 -0
- package/lib/runtime/components/react/dist/mpx-canvas/html.js +343 -0
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +232 -0
- package/lib/runtime/components/react/dist/mpx-canvas/utils.jsx +89 -0
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +13 -19
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +29 -38
- package/lib/runtime/components/react/dist/mpx-form.jsx +16 -19
- package/lib/runtime/components/react/dist/mpx-icon.jsx +8 -16
- package/lib/runtime/components/react/dist/mpx-image.jsx +291 -0
- package/lib/runtime/components/react/dist/mpx-input.jsx +54 -27
- package/lib/runtime/components/react/dist/mpx-label.jsx +15 -22
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -16
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +13 -13
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +2 -4
- package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -15
- package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +39 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +160 -88
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +80 -121
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +11 -19
- package/lib/runtime/components/react/dist/mpx-radio.jsx +27 -42
- package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +63 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +6 -4
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +47 -41
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -2
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +606 -0
- package/lib/runtime/components/react/dist/mpx-switch.jsx +20 -10
- package/lib/runtime/components/react/dist/mpx-text.jsx +11 -10
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +8 -3
- package/lib/runtime/components/react/dist/mpx-view.jsx +65 -61
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +112 -35
- package/lib/runtime/components/react/dist/pickerFaces.js +81 -0
- package/lib/runtime/components/react/dist/pickerVIewContext.js +9 -0
- package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
- package/lib/runtime/components/react/dist/pickerViewOverlay.jsx +23 -0
- package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -9
- package/lib/runtime/components/react/dist/utils.jsx +70 -23
- package/lib/runtime/components/react/event.config.ts +25 -26
- package/lib/runtime/components/react/getInnerListeners.ts +237 -199
- package/lib/runtime/components/react/mpx-button.tsx +104 -57
- package/lib/runtime/components/react/mpx-canvas/Bus.ts +70 -0
- package/lib/runtime/components/react/mpx-canvas/CanvasGradient.ts +18 -0
- package/lib/runtime/components/react/mpx-canvas/CanvasRenderingContext2D.ts +87 -0
- package/lib/runtime/components/react/mpx-canvas/Image.ts +102 -0
- package/lib/runtime/components/react/mpx-canvas/ImageData.ts +23 -0
- package/lib/runtime/components/react/mpx-canvas/constructorsRegistry.ts +38 -0
- package/lib/runtime/components/react/mpx-canvas/html.ts +343 -0
- package/lib/runtime/components/react/mpx-canvas/index.tsx +296 -0
- package/lib/runtime/components/react/mpx-canvas/utils.tsx +150 -0
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +28 -25
- package/lib/runtime/components/react/mpx-checkbox.tsx +48 -49
- package/lib/runtime/components/react/mpx-form.tsx +25 -28
- package/lib/runtime/components/react/mpx-icon.tsx +12 -17
- package/lib/runtime/components/react/mpx-image.tsx +436 -0
- package/lib/runtime/components/react/mpx-input.tsx +77 -57
- package/lib/runtime/components/react/mpx-label.tsx +26 -27
- package/lib/runtime/components/react/mpx-movable-area.tsx +18 -23
- package/lib/runtime/components/react/mpx-movable-view.tsx +21 -25
- package/lib/runtime/components/react/mpx-navigator.tsx +2 -8
- package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
- package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +236 -104
- package/lib/runtime/components/react/mpx-picker-view.tsx +132 -122
- package/lib/runtime/components/react/mpx-radio-group.tsx +24 -27
- package/lib/runtime/components/react/mpx-radio.tsx +45 -54
- package/lib/runtime/components/react/mpx-rich-text/html.ts +40 -0
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +121 -0
- package/lib/runtime/components/react/mpx-root-portal.tsx +3 -5
- package/lib/runtime/components/react/mpx-scroll-view.tsx +72 -71
- package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +4 -2
- package/lib/runtime/components/react/mpx-swiper-item.tsx +3 -2
- package/lib/runtime/components/react/mpx-switch.tsx +29 -23
- package/lib/runtime/components/react/mpx-text.tsx +14 -18
- package/lib/runtime/components/react/mpx-textarea.tsx +11 -10
- package/lib/runtime/components/react/mpx-view.tsx +92 -76
- package/lib/runtime/components/react/mpx-web-view.tsx +116 -54
- package/lib/runtime/components/react/pickerFaces.ts +104 -0
- package/lib/runtime/components/react/pickerOverlay.tsx +32 -0
- package/lib/runtime/components/react/types/common.ts +2 -0
- package/lib/runtime/components/react/types/global.d.ts +5 -17
- package/lib/runtime/components/react/useAnimationHooks.ts +36 -11
- package/lib/runtime/components/react/utils.tsx +99 -28
- package/lib/runtime/components/web/getInnerListeners.js +6 -6
- package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
- package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
- package/lib/runtime/components/web/mpx-picker.vue +382 -385
- package/lib/runtime/components/web/mpx-web-view.vue +175 -161
- package/lib/runtime/optionProcessor.js +7 -38
- package/lib/runtime/utils.js +2 -0
- package/lib/style-compiler/plugins/scope-id.js +30 -2
- package/lib/template-compiler/bind-this.js +7 -2
- package/lib/template-compiler/compiler.js +79 -47
- package/lib/template-compiler/gen-node-react.js +3 -3
- package/lib/utils/pre-process-json.js +9 -5
- package/package.json +6 -4
- package/LICENSE +0 -433
- package/lib/runtime/components/react/dist/mpx-image/index.jsx +0 -226
- package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -7
- package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +0 -478
- package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +0 -68
- package/lib/runtime/components/react/dist/mpx-swiper/type.js +0 -1
- package/lib/runtime/components/react/mpx-image/index.tsx +0 -345
- package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
- package/lib/runtime/components/web/event.js +0 -105
package/lib/index.js
CHANGED
|
@@ -348,14 +348,19 @@ class MpxWebpackPlugin {
|
|
|
348
348
|
compiler.options.node.global = true
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
// 'android' | 'harmony' 下 使用mode = 'ios' 进行兼容兜底
|
|
354
|
-
addModePlugin = new AddModePlugin('before-file', this.options.mode, this.options.fileConditionRules, 'file', 'ios')
|
|
355
|
-
} else {
|
|
356
|
-
addModePlugin = new AddModePlugin('before-file', this.options.mode, this.options.fileConditionRules, 'file')
|
|
351
|
+
const addModeOptions = {
|
|
352
|
+
fileConditionRules: this.options.fileConditionRules
|
|
357
353
|
}
|
|
358
|
-
|
|
354
|
+
const mode = this.options.mode
|
|
355
|
+
if (mode === 'web' || mode === 'ios' || mode === 'android' || mode === 'harmony') {
|
|
356
|
+
// 'web' | 'ios' | 'android' | 'harmony' 下,使用implicitMode强制进行平台转换
|
|
357
|
+
addModeOptions.implicitMode = true
|
|
358
|
+
}
|
|
359
|
+
if (mode === 'android' || mode === 'harmony') {
|
|
360
|
+
// 'android' | 'harmony' 下,使用 mode = 'ios' 进行兼容兜底
|
|
361
|
+
addModeOptions.defaultMode = 'ios'
|
|
362
|
+
}
|
|
363
|
+
const addModePlugin = new AddModePlugin('before-file', this.options.mode, addModeOptions, 'file')
|
|
359
364
|
const addEnvPlugin = new AddEnvPlugin('before-file', this.options.env, this.options.fileConditionRules, 'file')
|
|
360
365
|
const packageEntryPlugin = new PackageEntryPlugin('before-file', this.options.miniNpmPackages, 'file')
|
|
361
366
|
const dynamicPlugin = new DynamicPlugin('result', this.options.dynamicComponentRules)
|
|
@@ -775,7 +780,7 @@ class MpxWebpackPlugin {
|
|
|
775
780
|
const hash = mpx.pathHash(resourcePath)
|
|
776
781
|
const customOutputPath = this.options.customOutputPath
|
|
777
782
|
if (conflictPath) return conflictPath.replace(/(\.[^\\/]+)?$/, match => hash + match)
|
|
778
|
-
if (typeof customOutputPath === 'function') return customOutputPath(type, name, hash, ext).replace(/^\//, '')
|
|
783
|
+
if (typeof customOutputPath === 'function') return customOutputPath(type, name, hash, ext, resourcePath).replace(/^\//, '')
|
|
779
784
|
if (type === 'component' || type === 'page') return path.join(type + 's', name + hash, 'index' + ext)
|
|
780
785
|
return path.join(type, name + hash + ext)
|
|
781
786
|
},
|
|
@@ -156,7 +156,9 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
156
156
|
},
|
|
157
157
|
{
|
|
158
158
|
test: 'usingComponents',
|
|
159
|
-
web: fixComponentName('usingComponents')
|
|
159
|
+
web: fixComponentName('usingComponents'),
|
|
160
|
+
ios: fixComponentName('usingComponents'),
|
|
161
|
+
android: fixComponentName('usingComponents')
|
|
160
162
|
},
|
|
161
163
|
{
|
|
162
164
|
test: 'usingComponents',
|
|
@@ -256,12 +258,21 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
256
258
|
}
|
|
257
259
|
|
|
258
260
|
const spec = {
|
|
259
|
-
supportedModes: [
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
261
|
+
supportedModes: [
|
|
262
|
+
'ali',
|
|
263
|
+
'swan',
|
|
264
|
+
'qq',
|
|
265
|
+
'tt',
|
|
266
|
+
'jd',
|
|
267
|
+
'qa',
|
|
268
|
+
'dd',
|
|
269
|
+
'web',
|
|
270
|
+
'ios',
|
|
271
|
+
'android'
|
|
264
272
|
],
|
|
273
|
+
|
|
274
|
+
normalizeTest,
|
|
275
|
+
page: [...windowRules, ...componentRules],
|
|
265
276
|
component: componentRules,
|
|
266
277
|
window: windowRules,
|
|
267
278
|
tabBar: {
|
|
@@ -297,7 +308,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
297
308
|
ali (input) {
|
|
298
309
|
const value = input.list
|
|
299
310
|
delete input.list
|
|
300
|
-
input.items = value.map(item => {
|
|
311
|
+
input.items = value.map((item) => {
|
|
301
312
|
return runRules(spec.tabBar.list, item, {
|
|
302
313
|
mode: 'ali',
|
|
303
314
|
normalizeTest,
|
|
@@ -361,7 +372,9 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
361
372
|
},
|
|
362
373
|
{
|
|
363
374
|
test: 'usingComponents',
|
|
364
|
-
web: fixComponentName('usingComponents')
|
|
375
|
+
web: fixComponentName('usingComponents'),
|
|
376
|
+
ios: fixComponentName('usingComponents'),
|
|
377
|
+
android: fixComponentName('usingComponents')
|
|
365
378
|
},
|
|
366
379
|
{
|
|
367
380
|
test: 'usingComponents',
|
|
@@ -373,7 +373,8 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
373
373
|
|
|
374
374
|
// transform 转换
|
|
375
375
|
const formatTransform = ({ prop, value, selector }, { mode }) => {
|
|
376
|
-
|
|
376
|
+
// css var & 数组直接返回
|
|
377
|
+
if (Array.isArray(value) || calcExp.test(value)) return { prop, value }
|
|
377
378
|
const values = parseValues(value)
|
|
378
379
|
const transform = []
|
|
379
380
|
values.forEach(item => {
|
|
@@ -398,7 +399,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
398
399
|
break
|
|
399
400
|
case 'matrix':
|
|
400
401
|
case 'matrix3d':
|
|
401
|
-
transform.push({ [key]: val
|
|
402
|
+
transform.push({ [key]: parseValues(val, ',').map(val => +val) })
|
|
402
403
|
break
|
|
403
404
|
case 'translate':
|
|
404
405
|
case 'scale':
|
|
@@ -409,7 +410,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
409
410
|
{
|
|
410
411
|
// 2 个以上的值处理
|
|
411
412
|
key = key.replace('3d', '')
|
|
412
|
-
const vals = val
|
|
413
|
+
const vals = parseValues(val, ',').splice(0, key === 'rotate' ? 4 : 3)
|
|
413
414
|
// scale(.5) === scaleX(.5) scaleY(.5)
|
|
414
415
|
if (vals.length === 1 && key === 'scale') {
|
|
415
416
|
vals.push(vals[0])
|
|
@@ -455,14 +456,17 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
455
456
|
|
|
456
457
|
const formatFlex = ({ prop, value, selector }) => {
|
|
457
458
|
let values = parseValues(value)
|
|
459
|
+
// 值大于3 去前三
|
|
458
460
|
if (values.length > 3) {
|
|
459
|
-
|
|
461
|
+
warn(`Value of [flex] in ${selector} supports up to three values, received [${value}], please check again!`)
|
|
460
462
|
values = values.splice(0, 3)
|
|
461
463
|
}
|
|
462
464
|
const cssMap = []
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
465
|
+
// 单个css var 直接设置 flex 属性
|
|
466
|
+
if (values.length === 1 && cssVariableExp.test(value)) {
|
|
467
|
+
return { prop, value }
|
|
468
|
+
}
|
|
469
|
+
// 包含枚举值 none initial
|
|
466
470
|
if (values.includes('initial') || values.includes('none')) {
|
|
467
471
|
// css flex: initial ===> flex: 0 1 ===> rn flex 0 1
|
|
468
472
|
// css flex: none ===> css flex: 0 0 ===> rn flex 0 0
|
|
@@ -475,38 +479,31 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
475
479
|
}
|
|
476
480
|
return cssMap
|
|
477
481
|
}
|
|
478
|
-
//
|
|
479
|
-
//
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
482
|
+
// 只有1-2个值且最后的值是flexBasis 的有效值(auto或者有单位百分比、px等)
|
|
483
|
+
// 在设置 flex basis 有效值的场景下,如果没有设置 grow 和 shrink,则默认为1
|
|
484
|
+
// 单值 flex: 1 1 <flex-basis>
|
|
485
|
+
// 双值 flex: <flex-grow> 1 <flex-basis>
|
|
486
|
+
// 三值 flex: <flex-grow> <flex-shrink> <flex-basis>
|
|
487
|
+
for (let i = 0; i < 3; i++) {
|
|
488
|
+
if (i < 2) {
|
|
489
|
+
// 添加 grow 和 shrink
|
|
490
|
+
const isValid = isNumber(values[0]) || cssVariableExp.test(values[0])
|
|
491
|
+
// 兜底 1
|
|
492
|
+
const val = isValid ? values[0] : 1
|
|
493
|
+
const item = getIntegersFlex({ prop: AbbreviationMap[prop][i], value: val, selector })
|
|
488
494
|
item && cssMap.push(item)
|
|
495
|
+
isValid && values.shift()
|
|
496
|
+
} else {
|
|
497
|
+
// 添加 flexBasis
|
|
498
|
+
// 有单位(百分比、px等) 的 value 赋值 flexBasis,auto 不处理,兜底 0
|
|
499
|
+
const val = values[0] || 0
|
|
500
|
+
if (val !== 'auto') {
|
|
501
|
+
cssMap.push({
|
|
502
|
+
prop: 'flexBasis',
|
|
503
|
+
value: val
|
|
504
|
+
})
|
|
505
|
+
}
|
|
489
506
|
}
|
|
490
|
-
if (!isAuto) {
|
|
491
|
-
// 有单位(百分比、px等) 的 value 赋值 flexBasis,auto 不处理
|
|
492
|
-
cssMap.push({
|
|
493
|
-
prop: 'flexBasis',
|
|
494
|
-
value: lastOne
|
|
495
|
-
})
|
|
496
|
-
}
|
|
497
|
-
return cssMap
|
|
498
|
-
}
|
|
499
|
-
// 纯数值:value 按flex-grow flex-shrink flex-basis 顺序赋值
|
|
500
|
-
// 兜底 shrink & basis
|
|
501
|
-
if (values.length === 1) {
|
|
502
|
-
values.push(...[1, 0])
|
|
503
|
-
} else if (values.length === 2) {
|
|
504
|
-
values.push(0)
|
|
505
|
-
}
|
|
506
|
-
// 循环赋值
|
|
507
|
-
for (let i = 0; i < values.length; i++) {
|
|
508
|
-
const item = getIntegersFlex({ prop: AbbreviationMap[prop][i], value: values[i] })
|
|
509
|
-
item && cssMap.push(item)
|
|
510
507
|
}
|
|
511
508
|
return cssMap
|
|
512
509
|
}
|
|
@@ -514,7 +511,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
514
511
|
const formatFontFamily = ({ prop, value, selector }) => {
|
|
515
512
|
// 去掉引号 取逗号分隔后的第一个
|
|
516
513
|
const newVal = value.replace(/"|'/g, '').trim()
|
|
517
|
-
const values = newVal
|
|
514
|
+
const values = parseValues(newVal, ',')
|
|
518
515
|
if (!newVal || !values.length) {
|
|
519
516
|
error(`Value of [${prop}] is invalid in ${selector}, received [${value}], please check again!`)
|
|
520
517
|
return false
|
|
@@ -8,6 +8,14 @@ module.exports = function ({ print }) {
|
|
|
8
8
|
const qaEventLog = print({ platform: 'qa', tag: TAG_NAME, isError: false, type: 'event' })
|
|
9
9
|
return {
|
|
10
10
|
test: TAG_NAME,
|
|
11
|
+
android (tag, { el }) {
|
|
12
|
+
el.isBuiltIn = true
|
|
13
|
+
return 'mpx-canvas'
|
|
14
|
+
},
|
|
15
|
+
ios (tag, { el }) {
|
|
16
|
+
el.isBuiltIn = true
|
|
17
|
+
return 'mpx-canvas'
|
|
18
|
+
},
|
|
11
19
|
props: [
|
|
12
20
|
{
|
|
13
21
|
test: /^canvas-id$/,
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
const { isOriginTag, isBuildInTag } = require('../../../../utils/dom-tag-config')
|
|
2
2
|
|
|
3
3
|
module.exports = function () {
|
|
4
|
+
const handleComponentTag = (el, data) => {
|
|
5
|
+
const newTag = `mpx-com-${el.tag}`
|
|
6
|
+
const usingComponents = data.usingComponents || []
|
|
7
|
+
// 当前组件名与原生tag或内建tag同名,对组件名进行转义
|
|
8
|
+
// json转义见:platform/json/wx/index.js fixComponentName
|
|
9
|
+
if (usingComponents.includes(newTag)) {
|
|
10
|
+
el.tag = newTag
|
|
11
|
+
}
|
|
12
|
+
return el
|
|
13
|
+
}
|
|
14
|
+
|
|
4
15
|
return {
|
|
5
16
|
waterfall: true,
|
|
6
17
|
skipNormalize: true,
|
|
7
|
-
supportedModes: ['web'],
|
|
18
|
+
supportedModes: ['web', 'ios', 'android'],
|
|
8
19
|
test: (input) => isOriginTag(input) || isBuildInTag(input),
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const usingComponents = data.usingComponents || []
|
|
13
|
-
// 当前组件名与原生tag或内建tag同名,对组件名进行转义
|
|
14
|
-
// json转义见:platform/json/wx/index.js fixComponentName
|
|
15
|
-
if (usingComponents.includes(newTag)) {
|
|
16
|
-
el.tag = newTag
|
|
17
|
-
}
|
|
18
|
-
return el
|
|
19
|
-
}
|
|
20
|
+
web: handleComponentTag,
|
|
21
|
+
ios: handleComponentTag,
|
|
22
|
+
android: handleComponentTag
|
|
20
23
|
}
|
|
21
24
|
}
|
|
@@ -82,8 +82,8 @@ module.exports = function getComponentConfigs ({ warn, error }) {
|
|
|
82
82
|
|
|
83
83
|
// 转换规则只需以微信为基准配置微信和支付宝的差异部分,比如微信和支付宝都支持但是写法不一致,或者微信支持而支付宝不支持的部分(抛出错误或警告)
|
|
84
84
|
return [
|
|
85
|
-
...unsupported({ print }),
|
|
86
85
|
fixComponentName({ print }),
|
|
86
|
+
...unsupported({ print }),
|
|
87
87
|
ad({ print }),
|
|
88
88
|
view({ print }),
|
|
89
89
|
scrollView({ print }),
|
|
@@ -92,7 +92,7 @@ module.exports = function ({ print }) {
|
|
|
92
92
|
qa: qaPropLog
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
|
-
test: /^(placeholder-style|placeholder-class|cursor-spacing|always-embed|
|
|
95
|
+
test: /^(placeholder-style|placeholder-class|cursor-spacing|always-embed|hold-keyboard|safe-password-.+)$/,
|
|
96
96
|
ios: iosPropLog,
|
|
97
97
|
android: androidPropLog
|
|
98
98
|
}
|
|
@@ -12,6 +12,14 @@ module.exports = function ({ print }) {
|
|
|
12
12
|
el.isBuiltIn = true
|
|
13
13
|
return 'mpx-rich-text'
|
|
14
14
|
},
|
|
15
|
+
ios (tag, { el }) {
|
|
16
|
+
el.isBuiltIn = true
|
|
17
|
+
return 'mpx-rich-text'
|
|
18
|
+
},
|
|
19
|
+
android (tag, { el }) {
|
|
20
|
+
el.isBuiltIn = true
|
|
21
|
+
return 'mpx-rich-text'
|
|
22
|
+
},
|
|
15
23
|
props: [
|
|
16
24
|
{
|
|
17
25
|
test: /^(space)$/,
|
|
@@ -78,7 +78,7 @@ module.exports = function ({ print }) {
|
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
|
-
test: /^(placeholder-style|placeholder-class|cursor-spacing|always-embed|
|
|
81
|
+
test: /^(placeholder-style|placeholder-class|cursor-spacing|always-embed|hold-keyboard|disable-default-padding|adjust-keyboard-to|fixed|show-confirm-bar)$/,
|
|
82
82
|
ios: iosPropLog,
|
|
83
83
|
android: androidPropLog
|
|
84
84
|
}
|
|
@@ -11,7 +11,7 @@ const JD_UNSUPPORTED_TAG_NAME_ARR = ['functional-page-navigator', 'live-pusher',
|
|
|
11
11
|
// 快应用不支持的标签集合
|
|
12
12
|
const QA_UNSUPPORTED_TAG_NAME_ARR = ['movable-view', 'movable-area', 'open-data', 'official-account', 'editor', 'functional-page-navigator', 'live-player', 'live-pusher', 'ad', 'cover-image']
|
|
13
13
|
// RN不支持的标签集合
|
|
14
|
-
const RN_UNSUPPORTED_TAG_NAME_ARR = ['open-data', 'official-account', 'editor', 'functional-page-navigator', 'live-player', 'live-pusher', 'ad', 'progress', '
|
|
14
|
+
const RN_UNSUPPORTED_TAG_NAME_ARR = ['open-data', 'official-account', 'editor', 'functional-page-navigator', 'live-player', 'live-pusher', 'ad', 'progress', 'slider', 'audio', 'camera', 'video', 'match-media', 'page-container', 'editor', 'keyboard-accessory', 'map']
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* @param {function(object): function} print
|
|
@@ -56,13 +56,23 @@ module.exports = function (styles, {
|
|
|
56
56
|
error
|
|
57
57
|
})
|
|
58
58
|
if (ctorType === 'app') {
|
|
59
|
-
output += `
|
|
60
|
-
|
|
59
|
+
output += `
|
|
60
|
+
let __appClassMap
|
|
61
|
+
global.__getAppClassMap = function() {
|
|
62
|
+
if(!__appClassMap) {
|
|
63
|
+
__appClassMap = ${shallowStringify(classMap)};
|
|
64
|
+
}
|
|
65
|
+
return __appClassMap;
|
|
61
66
|
};\n`
|
|
62
67
|
} else {
|
|
63
|
-
output += `
|
|
68
|
+
output += `
|
|
69
|
+
let __classMap
|
|
70
|
+
global.currentInject.injectMethods = {
|
|
64
71
|
__getClassMap: function() {
|
|
65
|
-
|
|
72
|
+
if(!__classMap) {
|
|
73
|
+
__classMap = ${shallowStringify(classMap)};
|
|
74
|
+
}
|
|
75
|
+
return __classMap;
|
|
66
76
|
}
|
|
67
77
|
};\n`
|
|
68
78
|
}
|
|
@@ -119,6 +119,9 @@ module.exports = function (template, {
|
|
|
119
119
|
}, meta.wxsModuleMap)
|
|
120
120
|
const bindResult = bindThis.transform(rawCode, {
|
|
121
121
|
ignoreMap
|
|
122
|
+
// customBindThis (path, t) {
|
|
123
|
+
// path.replaceWith(t.callExpression(t.identifier('getValue'), [t.stringLiteral(path.node.name)]))
|
|
124
|
+
// }
|
|
122
125
|
})
|
|
123
126
|
output += `global.currentInject.render = function (createElement, getComponent) {
|
|
124
127
|
return ${bindResult.code}
|
|
@@ -6,17 +6,17 @@ const addInfix = require('../utils/add-infix')
|
|
|
6
6
|
const { JSON_JS_EXT } = require('../utils/const')
|
|
7
7
|
|
|
8
8
|
module.exports = class AddModePlugin {
|
|
9
|
-
constructor (source, mode,
|
|
9
|
+
constructor (source, mode, options, target) {
|
|
10
10
|
this.source = source
|
|
11
11
|
this.target = target
|
|
12
12
|
this.mode = mode
|
|
13
|
-
this.
|
|
14
|
-
this.defaultMode = defaultMode
|
|
13
|
+
this.options = options
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
apply (resolver) {
|
|
18
17
|
const target = resolver.ensureHook(this.target)
|
|
19
|
-
const {
|
|
18
|
+
const { options = {}, mode } = this
|
|
19
|
+
const { defaultMode, fileConditionRules, implicitMode } = options
|
|
20
20
|
resolver.getHook(this.source).tapAsync('AddModePlugin', (request, resolveContext, callback) => {
|
|
21
21
|
if (request.mode || request.env) {
|
|
22
22
|
return callback()
|
|
@@ -32,20 +32,20 @@ module.exports = class AddModePlugin {
|
|
|
32
32
|
extname = path.extname(resourcePath)
|
|
33
33
|
}
|
|
34
34
|
// 当前资源没有后缀名或者路径不符合fileConditionRules规则时,直接返回
|
|
35
|
-
if (!extname || !matchCondition(resourcePath,
|
|
35
|
+
if (!extname || !matchCondition(resourcePath, fileConditionRules)) return callback()
|
|
36
36
|
const queryObj = parseQuery(request.query || '?')
|
|
37
37
|
const queryInfix = queryObj.infix
|
|
38
|
-
queryObj.mode = mode
|
|
38
|
+
if (!implicitMode) queryObj.mode = mode
|
|
39
39
|
queryObj.infix = `${queryInfix || ''}.${mode}`
|
|
40
40
|
obj.query = stringifyQuery(queryObj)
|
|
41
41
|
obj.path = addInfix(resourcePath, mode, extname)
|
|
42
42
|
obj.relativePath = request.relativePath && addInfix(request.relativePath, mode, extname)
|
|
43
43
|
resolver.doResolve(target, Object.assign({}, request, obj), 'add mode: ' + mode, resolveContext, (err, result) => {
|
|
44
|
-
if (
|
|
44
|
+
if (defaultMode && !result) {
|
|
45
45
|
queryObj.infix = `${queryInfix || ''}.${defaultMode}`
|
|
46
46
|
obj.query = stringifyQuery(queryObj)
|
|
47
47
|
obj.path = addInfix(resourcePath, defaultMode, extname)
|
|
48
|
-
resolver.doResolve(target, Object.assign({}, request, obj), 'add mode: ' +
|
|
48
|
+
resolver.doResolve(target, Object.assign({}, request, obj), 'add mode: ' + defaultMode, resolveContext, (err, result) => {
|
|
49
49
|
callback(err, result)
|
|
50
50
|
})
|
|
51
51
|
return
|
|
@@ -5,6 +5,8 @@ export type LabelContextValue = MutableRefObject<{
|
|
|
5
5
|
triggerChange: (evt: NativeSyntheticEvent<TouchEvent>) => void
|
|
6
6
|
}>
|
|
7
7
|
|
|
8
|
+
export type KeyboardAvoidContextValue = (enabled: boolean) => void
|
|
9
|
+
|
|
8
10
|
export interface GroupValue {
|
|
9
11
|
[key: string]: { checked: boolean; setValue: Dispatch<SetStateAction<boolean>> }
|
|
10
12
|
}
|
|
@@ -46,3 +48,7 @@ export const PickerContext = createContext(null)
|
|
|
46
48
|
export const VarContext = createContext({})
|
|
47
49
|
|
|
48
50
|
export const IntersectionObserverContext = createContext<IntersectionObserver | null>(null)
|
|
51
|
+
|
|
52
|
+
export const RouteContext = createContext<number | null>(null)
|
|
53
|
+
|
|
54
|
+
export const KeyboardAvoidContext = createContext<KeyboardAvoidContextValue | null>(null)
|
|
@@ -7,3 +7,5 @@ export const LabelContext = createContext(null);
|
|
|
7
7
|
export const PickerContext = createContext(null);
|
|
8
8
|
export const VarContext = createContext({});
|
|
9
9
|
export const IntersectionObserverContext = createContext(null);
|
|
10
|
+
export const RouteContext = createContext(null);
|
|
11
|
+
export const KeyboardAvoidContext = createContext(null);
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
const eventConfigMap = {
|
|
2
|
-
bindtap: ['onTouchStart', 'onTouchMove', 'onTouchEnd'],
|
|
3
|
-
bindlongpress: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'],
|
|
4
|
-
bindtouchstart: ['onTouchStart'],
|
|
5
|
-
bindtouchmove: ['onTouchMove'],
|
|
6
|
-
bindtouchend: ['onTouchEnd'],
|
|
7
|
-
bindtouchcancel: ['onTouchCancel'],
|
|
8
|
-
catchtap: ['onTouchStart', 'onTouchMove', 'onTouchEnd'],
|
|
9
|
-
catchlongpress: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'],
|
|
10
|
-
catchtouchstart: ['onTouchStart'],
|
|
11
|
-
catchtouchmove: ['onTouchMove'],
|
|
12
|
-
catchtouchend: ['onTouchEnd'],
|
|
13
|
-
catchtouchcancel: ['onTouchCancel'],
|
|
14
|
-
'capture-bindtap': ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'],
|
|
15
|
-
'capture-bindlongpress': ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'],
|
|
16
|
-
'capture-bindtouchstart': ['onTouchStartCapture'],
|
|
17
|
-
'capture-bindtouchmove': ['onTouchMoveCapture'],
|
|
18
|
-
'capture-bindtouchend': ['onTouchEndCapture'],
|
|
19
|
-
'capture-bindtouchcancel': ['onTouchCancelCapture'],
|
|
20
|
-
'capture-catchtap': ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'],
|
|
21
|
-
'capture-catchlongpress': ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'],
|
|
22
|
-
'capture-catchtouchstart': ['onTouchStartCapture'],
|
|
23
|
-
'capture-catchtouchmove': ['onTouchMoveCapture'],
|
|
24
|
-
'capture-catchtouchend': ['onTouchEndCapture'],
|
|
25
|
-
'capture-catchtouchcancel': ['onTouchCancelCapture']
|
|
2
|
+
bindtap: { bitFlag: '0', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd'] },
|
|
3
|
+
bindlongpress: { bitFlag: '1', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'] },
|
|
4
|
+
bindtouchstart: { bitFlag: '2', events: ['onTouchStart'] },
|
|
5
|
+
bindtouchmove: { bitFlag: '3', events: ['onTouchMove'] },
|
|
6
|
+
bindtouchend: { bitFlag: '4', events: ['onTouchEnd'] },
|
|
7
|
+
bindtouchcancel: { bitFlag: '5', events: ['onTouchCancel'] },
|
|
8
|
+
catchtap: { bitFlag: '6', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd'] },
|
|
9
|
+
catchlongpress: { bitFlag: '7', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'] },
|
|
10
|
+
catchtouchstart: { bitFlag: '8', events: ['onTouchStart'] },
|
|
11
|
+
catchtouchmove: { bitFlag: '9', events: ['onTouchMove'] },
|
|
12
|
+
catchtouchend: { bitFlag: 'a', events: ['onTouchEnd'] },
|
|
13
|
+
catchtouchcancel: { bitFlag: 'b', events: ['onTouchCancel'] },
|
|
14
|
+
'capture-bindtap': { bitFlag: 'c', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'] },
|
|
15
|
+
'capture-bindlongpress': { bitFlag: 'd', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'] },
|
|
16
|
+
'capture-bindtouchstart': { bitFlag: 'e', events: ['onTouchStartCapture'] },
|
|
17
|
+
'capture-bindtouchmove': { bitFlag: 'f', events: ['onTouchMoveCapture'] },
|
|
18
|
+
'capture-bindtouchend': { bitFlag: 'g', events: ['onTouchEndCapture'] },
|
|
19
|
+
'capture-bindtouchcancel': { bitFlag: 'h', events: ['onTouchCancelCapture'] },
|
|
20
|
+
'capture-catchtap': { bitFlag: 'i', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'] },
|
|
21
|
+
'capture-catchlongpress': { bitFlag: 'j', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'] },
|
|
22
|
+
'capture-catchtouchstart': { bitFlag: 'k', events: ['onTouchStartCapture'] },
|
|
23
|
+
'capture-catchtouchmove': { bitFlag: 'l', events: ['onTouchMoveCapture'] },
|
|
24
|
+
'capture-catchtouchend': { bitFlag: 'm', events: ['onTouchEndCapture'] },
|
|
25
|
+
'capture-catchtouchcancel': { bitFlag: 'n', events: ['onTouchCancelCapture'] }
|
|
26
26
|
};
|
|
27
27
|
export default eventConfigMap;
|