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
2 changes: 1 addition & 1 deletion packages/hap-compiler/src/style/mediaquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const featureValidator = {
if (sizeStr[0] === '"' || sizeStr[0] === "'") {
sizeStr = sizeStr.slice(1, sizeStr.length - 1)
}
const reg = /^(1|2|4|8|AUTO|FULL)x(1|2|4|8|AUTO|FULL)$/
const reg = /^(1|2|4|8|AUTO|FULL)x(1|2|4|8|AUTO|FULL|N)$/
if (reg.test(sizeStr)) {
return { value: sizeStr }
}
Expand Down
4 changes: 2 additions & 2 deletions packages/hap-compiler/src/template/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ function initParser(code, options, filePath) {
const selfClosable = validator.isSupportedSelfClosing(tagName)
if (selfClosing && !selfClosable) {
colorconsole.error(
`${tagName}标签,禁止使用自闭合 ${filePath}@${token.location.line}:${token.location.col}`
`${tagName}标签,禁止使用自闭合 ${filePath} @${token.location.line}:${token.location.col}`
)
}

Expand Down Expand Up @@ -285,7 +285,7 @@ function initParser(code, options, filePath) {
(pos !== parser.__m['pos'] && token.type === Tokenizer.START_TAG_TOKEN)
) {
colorconsole.warn(
`${parser.__m['tagName']}标签要闭合,请遵循XML规范 ${filePath}@${parser.__m['pos']}`
`${parser.__m['tagName']}标签要闭合,请遵循XML规范 ${filePath} @${parser.__m['pos']}`
)
parser.__m = {}
}
Expand Down
20 changes: 16 additions & 4 deletions packages/hap-compiler/src/template/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const tagNatives = {
},
web: {
atomic: true,
events: ['pagestart', 'pagefinish', 'titlereceive', 'error', 'message', 'progress'],
events: ['pagestart', 'pagefinish', 'titlereceive', 'error', 'message', 'progress', 'intercepturl'],
attrs: {
src: {},
trustedurl: {},
Expand All @@ -232,7 +232,8 @@ const tagNatives = {
},
supportzoom: {
enum: ['true', 'false']
}
},
intercepturl:{}
}
},
list: {
Expand Down Expand Up @@ -603,6 +604,9 @@ const tagNatives = {
empty: true,
attrs: {
src: {},
loop: {
enum: ['true', 'false']
},
muted: {
enum: ['false', 'true']
},
Expand All @@ -623,6 +627,9 @@ const tagNatives = {
playcount: {},
speed: {
def: 1
},
'object-fit': {
enum: ['contain', 'cover', 'fill', 'none', 'scale-down']
}
},
events: [
Expand All @@ -634,7 +641,10 @@ const tagNatives = {
'seeking',
'seeked',
'timeupdate',
'fullscreenchange'
'fullscreenchange',
'firstframe',
'buffering',
'error'
]
},
camera: {
Expand Down Expand Up @@ -866,6 +876,8 @@ const tagNatives = {
},
progress: {},
speed: {},
'start-frame': {},
'end-frame': {},
loop: {
enum: [true, false]
},
Expand All @@ -876,7 +888,7 @@ const tagNatives = {
enum: [`AUTOMATIC`, `HARDWARE`, `SOFTWARE`]
}
},
events: ['complete', 'error', 'change']
events: ['complete', 'error', 'change', 'loaded']
},
'drawer-navigation': {
parents: ['drawer'],
Expand Down
90 changes: 83 additions & 7 deletions packages/hap-packager/src/common/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ function frameworkInit() {
// 基本名
base: 'system',
// 扩展名
ext: 'service'
ext: 'service',
// nearme新增扩展名
nearme: 'nearme',
// hap扩展名
hap: 'hap'
},
// 保留的features,保持与runtime_config.xml同步
reservedFeatures: [],
Expand Down Expand Up @@ -80,7 +84,14 @@ function frameworkInit() {
'nfc',
'uploadtask',
'downloadtask',
'requesttask'
'requesttask',
'minormode',
'nfc',
'localconnection',
'hostconnection',
'permission',
'audiolite',
'page'
]
const serviceFeatures = [
'account',
Expand All @@ -100,7 +111,10 @@ function frameworkInit() {
'wxaccount',
'wxpay',
'biometriverify',
'texttoaudio'
'texttoaudio',
'oppoinneraccount',
'simCalibration',
'quickappservice'
]
systemFeatures.forEach((feature) => {
// system
Expand All @@ -117,7 +131,7 @@ function frameworkInit() {
})

// 卡片中支持的feature
const supportInCard = [
const systemSupportInCard = [
'share',
'prompt',
'vibrator',
Expand All @@ -131,11 +145,73 @@ function frameworkInit() {
'calendar',
'package',
'app',
'router'
'router',
'media',
'cipher',
'permission',
'badge',
'localconnection',
'hostconnection',
'audio',
'audiolite',
'barcode',
'configuration',
'model',
'bluetooth'
]
supportInCard.forEach((feature) => {
systemSupportInCard.forEach((feature) => {
global.framework.supportInCard.push(`${global.framework.module.base}.${feature}`)
})
const nearmeSupportInCard = [
'media',
'history',
'http',
'shortcut',
'stats',
'router',
'package',
'device',
'theme',
'browser',
'feedback',
'navigator',
'note',
'miniprogram',
'downloadtask',
'sceneservice',
'marketbook',
'permission',
'account',
'applist',
'contentresolver',
'receiver',
'settings',
'preload',
'logger',
'network',
'system',
'nearby',
'batchanimator'
]
nearmeSupportInCard.forEach((feature) => {
global.framework.supportInCard.push(`${global.framework.module.nearme}.${feature}`)
})
const serviceSupportInCard = [
'account',
'push',
'simCalibration',
'oppoinneraccount'
]
serviceSupportInCard.forEach((feature) => {
global.framework.supportInCard.push(`${global.framework.module.ext}.${feature}`)
})
const hapSupportInCard = [
'io.MessageChannel',
'sharedStorage'
]
hapSupportInCard.forEach((feature) => {
global.framework.supportInCard.push(`${global.framework.module.hap}.${feature}`)
})
}

/**
Expand Down Expand Up @@ -197,7 +273,7 @@ function searchModuleImport(fileCont, options = {}) {
function checkFeatureInCard(obj = {}) {
Object.keys(obj).forEach((key) => {
obj[key].features &&
obj[key].features.every((item) => {
obj[key].features.forEach((item) => {
if (global.framework.supportInCard.indexOf(item.name) === -1) {
// 不支持的native模块
colorconsole.error(
Expand Down
35 changes: 26 additions & 9 deletions packages/hap-packager/src/plugins/resource-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,6 @@ ResourcePlugin.prototype.apply = function (compiler) {

let runned = false
compiler.hooks.emit.tapAsync('ResourcePlugin', function (compilation, callback) {
if (runned) {
setTimeout(() => {
// 此节点即可通知预览刷新,打 rpk 错误不显示在预览界面
eventBus.emit(PACKAGER_BUILD_DONE)
// 必须在定时器中调用 callback
callback()
}, 0)
return
}
runned = true
const sourceDir = options.src
const targetDir = options.dest
Expand Down Expand Up @@ -330,6 +321,32 @@ ResourcePlugin.prototype.apply = function (compiler) {
return true
}
})
// watch 模式下增量构建:仅复制新增或变更的静态资源,保留 HMR 性能优化
if (runned) {
pairs = pairs.filter((pair) => {
const { srcFile, destFile } = pair
if (compiler.modifiedFiles && compiler.modifiedFiles.has(srcFile)) {
return true
}
if (!fs.existsSync(destFile)) {
return true
}
try {
return fs.statSync(srcFile).mtimeMs > fs.statSync(destFile).mtimeMs
} catch (err) {
return true
}
})
if (pairs.length === 0) {
setTimeout(() => {
// 此节点即可通知预览刷新,打 rpk 错误不显示在预览界面
eventBus.emit(PACKAGER_BUILD_DONE)
// 必须在定时器中调用 callback
callback()
}, 0)
return
}
}
const promises = pairs.map((pair) => {
return new Promise((resolve, reject) => {
const { srcFile, destFile } = pair
Expand Down
Loading