Skip to content

Commit

Permalink
Merge pull request #681 from didi/fix-component-conversion-rules
Browse files Browse the repository at this point in the history
Fix component conversion rules
  • Loading branch information
hiyuki authored Jan 13, 2021
2 parents af01156 + 90e9a84 commit a617705
Show file tree
Hide file tree
Showing 23 changed files with 326 additions and 166 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ const TAG_NAME = 'ad'

module.exports = function ({ print }) {
const ttValueWarningLog = print({ platform: 'bytedance', type: 'value', tag: TAG_NAME, isError: false })

const ttPropLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false })
const baiduValueWarningLog = print({ platform: 'baidu', type: 'value', tag: TAG_NAME, isError: false })
const baiduPropLog = print({ platform: 'baidu', tag: TAG_NAME, isError: false })
const qqValueWarningLog = print({ platform: 'qq', type: 'value', tag: TAG_NAME, isError: false })
const qqPropLog = print({ platform: 'qq', tag: TAG_NAME, isError: false })
const qqEventLog = print({ platform: 'qq', tag: TAG_NAME, isError: false, type: 'event' })
return {
test: TAG_NAME,
props: [
Expand All @@ -11,10 +16,39 @@ module.exports = function ({ print }) {
tt (obj) {
obj.name = 'type'
if (obj.value === 'grid') {
ttValueWarningLog({ name: 'type', value: 'grid' })
ttValueWarningLog({ name: 'type', value: obj.value })
}
return obj
},
qq (obj) {
obj.name = 'type'
if (obj.value === 'grid' || obj.value === 'video') {
qqValueWarningLog({ name: 'type', value: obj.value })
}
return obj
},
swan (obj) {
obj.name = 'type'
if (obj.value === 'grid' || obj.value === 'video') {
baiduValueWarningLog({ name: 'type', value: obj.value })
}
return obj
}
},
{
test: /^ad-theme$/,
tt: ttPropLog
},
{
test: /^(ad-intervals|ad-theme)$/,
qq: qqPropLog,
swan: baiduPropLog
}
],
event: [
{
test: /^(close)$/,
qq: qqEventLog
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ const { isMustache } = require('../../../../utils/string')

const TAG_NAME = 'button'

// 微信支持的属性及其值
const wxSupportPropsValue = {
'open-type': ['contact', 'share', 'getPhoneNumber', 'getUserInfo', 'launchApp', 'openSetting', 'feedback']
}

module.exports = function ({ print }) {
const aliValueLogError = print({ platform: 'ali', tag: TAG_NAME, isError: true, type: 'value' })
const aliValueLog = print({ platform: 'ali', tag: TAG_NAME, isError: false, type: 'value' })
Expand All @@ -11,6 +16,8 @@ module.exports = function ({ print }) {
const baiduValueLog = print({ platform: 'baidu', tag: TAG_NAME, isError: false, type: 'value' })
const baiduPropLog = print({ platform: 'baidu', tag: TAG_NAME, isError: false })
const baiduEventLog = print({ platform: 'baidu', tag: TAG_NAME, isError: false })
const qqValueLogError = print({ platform: 'qq', tag: TAG_NAME, isError: true, type: 'value' })
const qqValueLog = print({ platform: 'qq', tag: TAG_NAME, isError: false, type: 'value' })
const qqPropLog = print({ platform: 'qq', tag: TAG_NAME, isError: false })
const qqEventLog = print({ platform: 'qq', tag: TAG_NAME, isError: false, type: 'event' })
const ttPropLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false })
Expand All @@ -19,6 +26,7 @@ module.exports = function ({ print }) {
const ttEventLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false, type: 'event' })
const webPropLog = print({ platform: 'web', tag: TAG_NAME, isError: false })
const webEventLog = print({ platform: 'web', tag: TAG_NAME, isError: false, type: 'event' })
const wxPropValueLog = print({ platform: 'wx', tag: TAG_NAME, isError: false, type: 'value' })
return {
test: TAG_NAME,
web (tag, { el }) {
Expand Down Expand Up @@ -60,19 +68,37 @@ module.exports = function ({ print }) {
}
},
swan ({ name, value }) {
const supportList = ['contact', 'share', 'getUserInfo', 'getPhoneNumber', 'openSetting']
const supportList = ['contact', 'share', 'getUserInfo', 'getPhoneNumber', 'openSetting', 'chooseAddress', 'chooseInvoiceTitle', 'login']
if (wxSupportPropsValue[name] && wxSupportPropsValue[name].indexOf(value) === -1) {
wxPropValueLog({ name, value })
}
if (isMustache(value)) {
// 如果是个变量,报warning
baiduValueLog({ name, value })
} else if (supportList.indexOf(value) === -1) {
baiduValueLogError({ name, value })
}
},
qq ({ name, value }) {
const supportList = ['share', 'getUserInfo', 'launchApp', 'openSetting', 'contact', 'feedback', 'openGroupProfile', 'addFriend', 'addColorSign', 'openPublicProfile', 'addGroupApp', 'shareMessageToFriend', 'addToFavorites']
if (wxSupportPropsValue[name] && wxSupportPropsValue[name].indexOf(value) === -1) {
wxPropValueLog({ name, value })
}
if (isMustache(value)) {
// 如果是个变量,报warning
qqValueLog({ name, value })
} else if (supportList.indexOf(value) === -1) {
qqValueLogError({ name, value })
}
},
tt ({ name, value }) {
if (wxSupportPropsValue[name] && wxSupportPropsValue[name].indexOf(value) === -1) {
wxPropValueLog({ name, value })
}
if (isMustache(value)) {
ttValueLog({ name, value })
} else {
const supportList = ['share', 'getPhoneNumber']
const supportList = ['share', 'getPhoneNumber', 'contact']
if (supportList.indexOf(value) === -1) {
ttValueLogError({ name, value })
}
Expand Down Expand Up @@ -109,7 +135,7 @@ module.exports = function ({ print }) {
],
event: [
{
test: /^(getphonenumber|getuserinfo)/,
test: /^(getphonenumber|getuserinfo)$/,
ali () {
return 'getAuthorize'
}
Expand All @@ -123,12 +149,15 @@ module.exports = function ({ print }) {
swan: baiduEventLog
},
{
test: /^(contact)$/,
test: /^(getphonenumber)$/,
qq: qqEventLog
},
{
test: /^(getuserinfo|contact|getphonenumbe|error|launchapp|opensetting)$/,
tt: ttEventLog,
test: /^(getuserinfo|contact|error|launchapp|opensetting)$/,
tt: ttEventLog
},
{
test: /^(getuserinfo|contact|error|launchapp|opensetting|getphonenumber)$/,
web: webEventLog
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
const { isMustache } = require('../../../../utils/string')

const TAG_NAME = 'camera'

module.exports = function ({ print }) {
const ttValueLogError = print({ platform: 'bytedance', tag: TAG_NAME, isError: true, type: 'value' })
const ttEventLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false })
const ttPropLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false })
const baiduValueLogError = print({ platform: 'baidu', tag: TAG_NAME, isError: true, type: 'value' })
const baiduEventLog = print({ platform: 'baidu', tag: TAG_NAME, isError: false })

const qqValueLog = print({ platform: 'qq', tag: TAG_NAME, isError: false, type: 'value' })
const qqPropLog = print({ platform: 'qq', tag: TAG_NAME, isError: false })
const qqEventLog = print({ platform: 'qq', tag: TAG_NAME, isError: false, type: 'event' })
return {
test: TAG_NAME,
props: [
Expand All @@ -15,13 +22,39 @@ module.exports = function ({ print }) {
baiduValueLogError({ name, value })
}
return false
},
tt ({ name, value }) {
if (value !== 'normal') {
ttValueLogError({ name, value })
}
return false
}
},
{
test: 'flash',
qq ({ name, value }) {
const supportList = ['auto', 'on', 'off']
if (isMustache(value) || supportList.indexOf(value) === -1) {
// 如果是个变量,或者是不支持的属性值,报warning
qqValueLog({ name, value })
}
},
tt: ttPropLog
},
{
test: /^(resolution|frame-size)$/,
qq: qqPropLog
}
],
event: [
{
test: /^(scancode)$/,
swan: baiduEventLog
swan: baiduEventLog,
tt: ttEventLog
},
{
test: /^(initdone)$/,
qq: qqEventLog
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const TAG_NAME = 'canvas'
module.exports = function ({ print }) {
const aliEventLog = print({ platform: 'ali', tag: TAG_NAME, isError: false, type: 'event' })
const ttPropLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false })
const ttEventLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false, type: 'event' })
return {
test: TAG_NAME,
props: [
Expand Down Expand Up @@ -40,6 +41,10 @@ module.exports = function ({ print }) {
{
test: /^(error)$/,
ali: aliEventLog
},
{
test: /^(longtap|error)$/,
tt: ttEventLog
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ const TAG_NAME = 'cover-view'

module.exports = function ({ print }) {
const aliPropLog = print({ platform: 'ali', tag: TAG_NAME, isError: false })
const baiduPropLog = print({ platform: 'baidu', tag: TAG_NAME, isError: false })
const baiduValueLogError = print({ platform: 'baidu', tag: TAG_NAME, isError: true, type: 'value' })
const webPropLog = print({ platform: 'web', tag: TAG_NAME, isError: false })

return {
test: TAG_NAME,
web (tag, { el }) {
Expand All @@ -21,7 +20,11 @@ module.exports = function ({ print }) {
{
test: 'scroll-top',
ali: aliPropLog,
swan: baiduPropLog,
swan ({ name, value }) {
if (typeof value === 'string') {
baiduValueLogError({ name, value })
}
},
web: webPropLog
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
const ad = require('./ad')
const view = require('./view')
const scrollView = require('./scroll-view')
const swiper = require('./swiper')
const swiperItem = require('./swiper-item')
const movableView = require('./movable-view')
const movableArea = require('./movable-area')
const coverView = require('./cover-view')
const coverImage = require('./cover-image')
const text = require('./text')
const richText = require('./rich-text')
const progress = require('./progress')
const block = require('./block')
const button = require('./button')
const camera = require('./camera')
const canvas = require('./canvas')
const checkboxGroup = require('./checkbox-group')
const checkbox = require('./checkbox')
const radioGroup = require('./radio-group')
const radio = require('./radio')
const coverImage = require('./cover-image')
const coverView = require('./cover-view')
const form = require('./form')
const HyphenTagName = require('./hypen-tag-name')
const icon = require('./icon')
const image = require('./image')
const input = require('./input')
const picker = require('./picker')
const pickerView = require('./picker-view')
const livePlayer = require('./live-player')
const livePusher = require('./live-pusher')
const map = require('./map')
const movableArea = require('./movable-area')
const movableView = require('./movable-view')
const navigator = require('./navigator')
const pickerViewColumn = require('./picker-view-column')
const pickerView = require('./picker-view')
const picker = require('./picker')
const progress = require('./progress')
const radioGroup = require('./radio-group')
const radio = require('./radio')
const richText = require('./rich-text')
const scrollView = require('./scroll-view')
const slider = require('./slider')
const swiperItem = require('./swiper-item')
const swiper = require('./swiper')
const switchComponent = require('./switch')
const textarea = require('./textarea')
const navigator = require('./navigator')
const image = require('./image')
const map = require('./map')
const canvas = require('./canvas')
const wxs = require('./wxs')
const template = require('./template')
const block = require('./block')
const icon = require('./icon')
const text = require('./text')
const textarea = require('./textarea')
const Nonsupport = require('./unsupported')
const HyphenTagName = require('./hypen-tag-name')
const webView = require('./web-view')
const video = require('./video')
const view = require('./view')
const webView = require('./web-view')
const wxs = require('./wxs')

module.exports = function getComponentConfigs ({ warn, error }) {
/**
Expand Down Expand Up @@ -64,6 +67,9 @@ module.exports = function getComponentConfigs ({ warn, error }) {
case 'tagRequiredProps':
msg = `<${tag}> should have '${arg}' attr in ali environment!`
break
case 'value-attr-uniform':
msg = `The internal attribute name of the <${tag}>'s attribute '${arg && arg.value}' is not supported in the ali environment, Please check!`
break
default:
msg = `<${tag}>'s transform has some error happened!`
}
Expand Down Expand Up @@ -106,8 +112,11 @@ module.exports = function getComponentConfigs ({ warn, error }) {
template(),
block(),
icon(),
HyphenTagName({ print }),
webView({ print }),
video({ print })
video({ print }),
camera({ print }),
livePlayer({ print }),
livePusher({ print }),
HyphenTagName({ print })
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ const TAG_NAME = 'live-player'
module.exports = function ({ print }) {
const baiduValueLogError = print({ platform: 'baidu', tag: TAG_NAME, isError: true, type: 'value' })
const baiduPropLog = print({ platform: 'baidu', tag: TAG_NAME, isError: false })

const baiduEventLog = print({ platform: 'baidu', tag: TAG_NAME, isError: false, type: 'event' })
const qqPropLog = print({ platform: 'qq', tag: TAG_NAME, isError: false })
const qqEventLog = print({ platform: 'qq', tag: TAG_NAME, isError: false, type: 'event' })
const ttEventLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false, type: 'event' })
const ttPropLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false })
return {
test: TAG_NAME,
props: [
Expand All @@ -20,6 +24,25 @@ module.exports = function ({ print }) {
{
test: /^(sound-mode|auto-pause-if-navigate|auto-pause-if-open-native)$/,
swan: baiduPropLog
},
{
test: /^(background-mute|picture-in-picture-mode)$/,
qq: qqPropLog
},
{
test: /^(mode|background-mute|min-cache|max-cache|sound-mode|auto-pause-if-navigate|auto-pause-if-open-native)$/,
tt: ttPropLog
}
],
event: [
{
test: /^(audiovolumenotify|enterpictureinpicture|leavepictureinpicture)$/,
qq: qqEventLog,
swan: baiduEventLog
},
{
test: /^(netstatus|audiovolumenotify|enterpictureinpicture|leavepictureinpicture)$/,
tt: ttEventLog
}
]
}
Expand Down
Loading

0 comments on commit a617705

Please sign in to comment.