Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 45 additions & 3 deletions packages/hap-compiler/src/style/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2648,8 +2648,28 @@ const validatorMap = {
backgroundPosition: validator.backgroundPosition,
display: validator.display,
visibility: makeEnumValidator(['visible', 'hidden']),
objectFit: makeEnumValidator(['fill', 'contain', 'cover', 'none', 'scale-down', 'fit-start', 'fit-end', 'cover-start', 'cover-end']),
altObjectFit: makeEnumValidator(['fill', 'contain', 'cover', 'none', 'scale-down', 'fit-start', 'fit-end', 'cover-start', 'cover-end']),
objectFit: makeEnumValidator([
'fill',
'contain',
'cover',
'none',
'scale-down',
'fit-start',
'fit-end',
'cover-start',
'cover-end'
]),
altObjectFit: makeEnumValidator([
'fill',
'contain',
'cover',
'none',
'scale-down',
'fit-start',
'fit-end',
'cover-start',
'cover-end'
]),
// text
lines: validator.integer,
color: validator.color,
Expand Down Expand Up @@ -2712,7 +2732,29 @@ const validatorMap = {
themeTrackColor: makeEnumValidator(themeColors),
themeSelectedColor: makeEnumValidator(themeColors),
themeBlockColor: makeEnumValidator(themeColors), */
letterSpacing: validator.letterSpacing
letterSpacing: validator.letterSpacing,
// legacy card styles
textWeight: validator.fontWeight,
textSize: validator.length,
fillet: validator.length,
lineColor: validator.color,
lineWidth: validator.length,
faceColor: validator.color,
titleColor: validator.color,
titleSize: validator.length,
titleStyle: validator.fontWeight,
itemColor: validator.color,
itemSize: validator.length,
selectItemColor: validator.color,
unitStyle: validator.fontWeight,
unitColor: validator.color,
size: validator.length,
bgBeginColor: validator.color,
bgEndColor: validator.color,
ringBeginColor: validator.color,
ringEndColor: validator.color,
thumbBeginColor: validator.color,
thumbEndColor: validator.color
}

/**
Expand Down
183 changes: 159 additions & 24 deletions packages/hap-compiler/src/template/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ const tagCommon = {
},
overflow: {
enum: ['visible', 'hidden']
},
followcorner: {
enum: ['true', 'false']
}
},
children: ['block', 'slot', 'component'], // 通用控制组件
Expand Down Expand Up @@ -181,6 +184,7 @@ const tagNatives = {
attrs: {
src: {},
alt: {},
symbolcode: {},
enablenightmode: {
enum: ['true', 'false']
},
Expand Down Expand Up @@ -217,7 +221,15 @@ const tagNatives = {
},
web: {
atomic: true,
events: ['pagestart', 'pagefinish', 'titlereceive', 'error', 'message', 'progress', 'intercepturl'],
events: [
'pagestart',
'pagefinish',
'titlereceive',
'error',
'message',
'progress',
'intercepturl'
],
attrs: {
src: {},
trustedurl: {},
Expand All @@ -233,7 +245,7 @@ const tagNatives = {
supportzoom: {
enum: ['true', 'false']
},
intercepturl:{}
intercepturl: {}
}
},
list: {
Expand Down Expand Up @@ -354,6 +366,20 @@ const tagNatives = {
textContent: true,
atomic: true
},
vbutton: {
supportCard: true,
textContent: true,
atomic: true,
attrs: {
enablecolor: {},
enableanim: {},
animtype: {},
loading: {},
drawtype: {},
text: {},
disable: {}
}
},
refresh: {
attrs: {
offset: {
Expand Down Expand Up @@ -577,6 +603,68 @@ const tagNatives = {
},
events: ['change', 'columnchange', 'cancel']
},
vcustompicker: {
supportCard: true,
selfClosing: true,
atomic: true,
empty: true,
attrs: {
mode: {},
defaultvalue: {},
itemcycle: {},
visibleitemcount: {}
},
events: ['change']
},
vtimepicker: {
supportCard: true,
selfClosing: true,
atomic: true,
empty: true,
attrs: {
defaultvalue: {},
itemcycle: {},
visibleitemcount: {}
},
events: ['change']
},
vdatepicker: {
supportCard: true,
selfClosing: true,
atomic: true,
empty: true,
attrs: {
defaultvalue: {},
itemcycle: {},
yearrange: {},
visibleitemcount: {}
},
events: ['change']
},
vdatepicker2: {
supportCard: true,
selfClosing: true,
atomic: true,
empty: true,
attrs: {
defaultvalue: {},
itemcycle: {},
yearrange: {},
visibleitemcount: {}
},
events: ['change']
},
vcalendardatepicker: {
supportCard: true,
selfClosing: true,
atomic: true,
empty: true,
attrs: {
defaultvalue: {},
yearrange: {}
},
events: ['change']
},
switch: {
supportCard: true,
selfClosing: true,
Expand All @@ -588,6 +676,50 @@ const tagNatives = {
},
events: ['change']
},
vswitch: {
supportCard: true,
selfClosing: true,
atomic: true,
empty: true,
attrs: {
checked: {},
blurmaterial: {},
disable: {},
loading: {}
},
events: ['change']
},
vcheckbox: {
supportCard: true,
selfClosing: true,
atomic: true,
empty: true,
attrs: {
text: {},
checked: {},
groupid: {},
type: {},
tickcolor: {},
framecolor: {},
fillcolor: {},
checkstatus: {}
},
events: ['change']
},
vradiobutton: {
supportCard: true,
selfClosing: true,
atomic: true,
empty: true,
attrs: {
text: {},
checked: {},
groupid: {},
radiocolor: {},
framecolor: {}
},
events: ['change']
},
textarea: {
supportCard: true,
atomic: true,
Expand Down Expand Up @@ -1328,7 +1460,7 @@ function checkTagName(node, output, options = {}) {
log.push({
line: location.line || 1,
column: location.col || 1,
reason: 'WARN: 组件 `' + tagName + '` 不支持属性 `' + item
reason: 'WARN: 组件 `' + tagName + '` 不支持属性 `' + item + '`'
})
}
}
Expand Down Expand Up @@ -1869,12 +2001,12 @@ function checkEvent(name, value, output, options) {
// 如果表达式形式为XXX(xxxx)
const paramsMatch = value.match(/(.*)\((.*)\)/)
if (paramsMatch) {
if (options.lite) {
const err = new Error('轻卡不支持带参数的事件')
err.isExpressionError = true
err.expression = value
throw err
}
// if (options.lite) {
// const err = new Error('轻卡不支持带参数的事件')
// err.isExpressionError = true
// err.expression = value
// throw err
// }
const funcName = paramsMatch[1]
let params = paramsMatch[2]
// 解析','分隔的参数
Expand All @@ -1888,22 +2020,25 @@ function checkEvent(name, value, output, options) {
// 否则默认有一个参数'$evt'
params = ['evt']
}
value = '{{' + funcName + '(' + params.join(',') + ')}}'
try {
// 将事件转换为函数对象
if (options.newJSCard) {
value = 'function (evt) { return ' + exp(value, false).replace('this.evt', 'evt') + '}'
} else {
/* eslint-disable no-eval */
value = eval(
'(function (evt) { return ' + exp(value, false).replace('this.evt', 'evt') + '})'
)
/* eslint-enable no-eval */
value = funcName + '(' + params.join(',') + ')'
if (!options.lite) {
value = '{{' + value + '}}'
try {
// 将事件转换为函数对象
if (options.newJSCard) {
value = 'function (evt) { return ' + exp(value, false).replace('this.evt', 'evt') + '}'
} else {
/* eslint-disable no-eval */
value = eval(
'(function (evt) { return ' + exp(value, false).replace('this.evt', 'evt') + '})'
)
/* eslint-enable no-eval */
}
} catch (err) {
err.isExpressionError = true
err.expression = originValue
throw err
}
} catch (err) {
err.isExpressionError = true
err.expression = originValue
throw err
}
}
output.result.events = output.result.events || {}
Expand Down
18 changes: 6 additions & 12 deletions packages/hap-packager/src/common/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ function frameworkInit() {
'hostconnection',
'permission',
'audiolite',
'page'
'page',
'skill'
]
const serviceFeatures = [
'account',
Expand Down Expand Up @@ -157,7 +158,8 @@ function frameworkInit() {
'barcode',
'configuration',
'model',
'bluetooth'
'bluetooth',
'skill'
]
systemSupportInCard.forEach((feature) => {
global.framework.supportInCard.push(`${global.framework.module.base}.${feature}`)
Expand Down Expand Up @@ -196,19 +198,11 @@ function frameworkInit() {
nearmeSupportInCard.forEach((feature) => {
global.framework.supportInCard.push(`${global.framework.module.nearme}.${feature}`)
})
const serviceSupportInCard = [
'account',
'push',
'simCalibration',
'oppoinneraccount'
]
const serviceSupportInCard = ['account', 'push', 'simCalibration', 'oppoinneraccount']
serviceSupportInCard.forEach((feature) => {
global.framework.supportInCard.push(`${global.framework.module.ext}.${feature}`)
})
const hapSupportInCard = [
'io.MessageChannel',
'sharedStorage'
]
const hapSupportInCard = ['io.MessageChannel', 'sharedStorage']
hapSupportInCard.forEach((feature) => {
global.framework.supportInCard.push(`${global.framework.module.hap}.${feature}`)
})
Expand Down
Loading
Loading