Skip to content

Commit bb22685

Browse files
committed
feat: 提升aiottoolkit依赖版本,优化marquee等组件打包提示
Signed-off-by: lilei946 <snowinter2008@gmail.com>
1 parent b52b5e9 commit bb22685

File tree

8 files changed

+176
-64
lines changed

8 files changed

+176
-64
lines changed

examples/sample/yarn.lock

Lines changed: 133 additions & 44 deletions
Large diffs are not rendered by default.

packages/hap-compiler/src/template/validator.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,15 +1118,27 @@ function checkTagName(node, output, options = {}) {
11181118
) {
11191119
const locationAddr =
11201120
location.line && location.column ? '@' + location.line + ':' + location.column : ''
1121-
colorconsole.throw(
1122-
'ERROR: ' +
1123-
locationAddr +
1124-
' 使用 `' +
1125-
tagName +
1126-
'` 组件,要求卡片配置 minCardPlatformVersion 或 minPlatformVersion 不低于 ' +
1127-
tagNatives[tagName].minRequiredRuntimeVersion +
1128-
', 请修改'
1129-
)
1121+
if (options.isTargetVivo) {
1122+
colorconsole.throw(
1123+
'ERROR: ' +
1124+
locationAddr +
1125+
' 使用 `' +
1126+
tagName +
1127+
'` 组件,要求卡片配置 minCardPlatformVersion 或 minPlatformVersion 不低于 ' +
1128+
tagNatives[tagName].minRequiredRuntimeVersion +
1129+
', 请修改'
1130+
)
1131+
} else {
1132+
colorconsole.warn(
1133+
'ERROR: ' +
1134+
locationAddr +
1135+
' 使用 `' +
1136+
tagName +
1137+
'` 组件,要求卡片配置 minCardPlatformVersion 或 minPlatformVersion 不低于 ' +
1138+
tagNatives[tagName].minRequiredRuntimeVersion +
1139+
', 请修改'
1140+
)
1141+
}
11301142
}
11311143

11321144
// 检测根组件合法性

packages/hap-dsl-xvm/src/loaders/ux-fragment-utils.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ function makeLoaderString(type, config, newJSCard, uxType) {
269269
* @returns {string}
270270
*/
271271
function processImportFrag($loader, imports, importNames, queryOptions = {}) {
272-
const { newJSCard, lite, cardEntry, minCardRuntimeVersion } = queryOptions
272+
const { newJSCard, lite, cardEntry, minCardRuntimeVersion, isTargetVivo } = queryOptions
273273
let retStr = ''
274274
if (imports.length) {
275275
const newJSCardParam = newJSCard ? `&newJSCard=${newJSCard}` : ''
@@ -278,6 +278,7 @@ function processImportFrag($loader, imports, importNames, queryOptions = {}) {
278278
const minCardRuntimeVersionParam = minCardRuntimeVersion
279279
? `&minCardRuntimeVersion=${minCardRuntimeVersion}`
280280
: ''
281+
const isTargetVivoParam = isTargetVivo ? `&isTargetVivo=${isTargetVivo}` : ''
281282
for (let i = 0; i < imports.length; i++) {
282283
const imp = imports[i]
283284
let importSrc = imp.attrs.src
@@ -314,7 +315,7 @@ function processImportFrag($loader, imports, importNames, queryOptions = {}) {
314315
let reqStr = makeRequireString(
315316
$loader,
316317
makeLoaderString(FRAG_TYPE.IMPORT, null, newJSCard),
317-
`${importSrc}?uxType=${ENTRY_TYPE.COMP}&name=${importName}${newJSCardParam}${liteParam}${cardEntryParam}${minCardRuntimeVersionParam}`
318+
`${importSrc}?uxType=${ENTRY_TYPE.COMP}&name=${importName}${newJSCardParam}${liteParam}${cardEntryParam}${minCardRuntimeVersionParam}${isTargetVivoParam}`
318319
)
319320

320321
if (compileOptionsObject.stats) {
@@ -338,7 +339,7 @@ function processImportFrag($loader, imports, importNames, queryOptions = {}) {
338339
* @param {number} lite 轻卡
339340
*/
340341
function processTemplateFrag($loader, templates, importNames, queryOptions = {}) {
341-
const { uxType, newJSCard, lite, cardEntry, minCardRuntimeVersion } = queryOptions
342+
const { uxType, newJSCard, lite, cardEntry, minCardRuntimeVersion, isTargetVivo } = queryOptions
342343
let retStr = '{}'
343344
if (!templates.length) {
344345
$loader.emitError(new Error('需要模板 <template> 片段'))
@@ -360,6 +361,7 @@ function processTemplateFrag($loader, templates, importNames, queryOptions = {})
360361
const minCardRuntimeVersionParam = minCardRuntimeVersion
361362
? `&minCardRuntimeVersion=${minCardRuntimeVersion}`
362363
: ''
364+
const isTargetVivoParam = isTargetVivo ? `&isTargetVivo=${isTargetVivo}` : ''
363365
// 解析成类似url中key[]=xxx 的形式,便于loader-utils解析
364366
importNames = importNames.map((item) => 'importNames[]=' + item)
365367
retStr = makeRequireString(
@@ -373,7 +375,7 @@ function processTemplateFrag($loader, templates, importNames, queryOptions = {})
373375
),
374376
`${src}?uxType=${uxType}&${importNames.join(
375377
','
376-
)}${newJSCardParam}${liteParam}${pathParam}${cardEntryParam}${minCardRuntimeVersionParam}`
378+
)}${newJSCardParam}${liteParam}${pathParam}${cardEntryParam}${minCardRuntimeVersionParam}${isTargetVivoParam}`
377379
)
378380
}
379381
return retStr

packages/hap-dsl-xvm/src/loaders/ux-loader.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ export default function uxLoader(source) {
139139
newJSCard: resourceQuery.newJSCard, // 新打包格式的 JS卡
140140
lite: resourceQuery.lite, // 轻卡
141141
cardEntry: resourceQuery.cardEntry, // 卡片入口
142-
minCardRuntimeVersion: resourceQuery.minCardRuntimeVersion // 卡片配置的最小平台版本
142+
minCardRuntimeVersion: resourceQuery.minCardRuntimeVersion, // 卡片配置的最小平台版本
143+
isTargetVivo: resourceQuery.isTargetVivo // 厂商是否包含vivo
143144
}
144145
// 使用原有文件名(不包含扩展名)
145146
const name = resourceQuery.name || getNameByPath(resourcePath)

packages/hap-packager/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"babel.tree.config.js"
3636
],
3737
"dependencies": {
38-
"@aiot-toolkit/card-expression": "^1.0.13",
38+
"@aiot-toolkit/card-expression": "^1.0.14",
3939
"@babel/core": "^7.9.6",
4040
"@babel/generator": "^7.9.6",
4141
"@babel/parser": "^7.9.6",

packages/hap-toolkit/__tests__/__snapshots__/compile.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ Array [
355355
356356
exports[`测试compile generate webpack config 1`] = `
357357
Object {
358-
"CardDemo/index": "./src/CardDemo/index.ux?uxType=card&minCardRuntimeVersion=2000&cardEntry=CardDemo",
358+
"CardDemo/index": "./src/CardDemo/index.ux?uxType=card&minCardRuntimeVersion=2000&cardEntry=CardDemo&isTargetVivo=false",
359359
"Demo/index": "./src/Demo/index.ux?uxType=page",
360360
"app": "./src/app.ux?uxType=app",
361361
"workers/request/index": "./src/workers/request/index.js",

packages/hap-toolkit/src/utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export function resolveEntries(manifest, basedir, cwd) {
104104
`编译失败:请确认manifest.json中router.pages配置的 '${routePath}' 为目录名`
105105
)
106106
}
107+
const isTargetVivo = (conf.targetManufacturers || []).includes('vivo')
107108
let sourceFile = path.relative(cwd, filepath)
108109
sourceFile = './' + sourceFile + `?uxType=${type}`
109110
sourceFile = sourceFile.replace(/\\/g, '/')
@@ -117,6 +118,7 @@ export function resolveEntries(manifest, basedir, cwd) {
117118
conf.minCardPlatformVersion || conf.minPlatformVersion || 0
118119
}` // 卡片配置的最小运行时版本
119120
sourceFile += `&cardEntry=${routePath}` // card 入口,lite 和 js 卡(新旧打包格式)都带该参数
121+
sourceFile += `&isTargetVivo=${isTargetVivo}` // 厂商是否包含vivo
120122
}
121123
entries[entryKey] = sourceFile
122124
})

yarn.lock

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
# yarn lockfile v1
33

44

5-
"@aiot-toolkit/card-expression@^1.0.13":
6-
version "1.0.13"
7-
resolved "https://registry.npmmirror.com/@aiot-toolkit/card-expression/-/card-expression-1.0.13.tgz#6649204e181fc46d21e8a7afef8ab82fff1bf2ab"
8-
integrity sha512-5FhFSgh598fHRFMcF4g20V0PnGh0GhEzbGeK89DOSbe/2f4PPs75N4l1TmiwIBbT2zEDXe/1oFBIgIruoFqFUQ==
5+
"@aiot-toolkit/card-expression@^1.0.14":
6+
version "1.0.14"
7+
resolved "https://registry.npmmirror.com/@aiot-toolkit/card-expression/-/card-expression-1.0.14.tgz#2ca54ddb69d5dd3a1fbb58c594e963f0b9842ba2"
8+
integrity sha512-xv6rnpQP4XE+vQ7FxErcCetqLsjsob43FXFvoDvC5UyiJFEsglg0bOxP0l0OJ/D72ikboeHbONTZJ4CRkd8/OA==
99
dependencies:
1010
"@babel/generator" "^7.25.6"
1111
"@babel/parser" "^7.25.6"
1212
"@babel/types" "^7.25.6"
13+
husky "^9.1.7"
1314

1415
"@ampproject/remapping@^2.2.0":
1516
version "2.2.1"
@@ -7053,6 +7054,11 @@ husky@^8.0.0:
70537054
resolved "https://registry.npmmirror.com/husky/-/husky-8.0.3.tgz#4936d7212e46d1dea28fef29bb3a108872cd9184"
70547055
integrity sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==
70557056

7057+
husky@^9.1.7:
7058+
version "9.1.7"
7059+
resolved "https://registry.npmmirror.com/husky/-/husky-9.1.7.tgz#d46a38035d101b46a70456a850ff4201344c0b2d"
7060+
integrity sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==
7061+
70567062
hybrid-chai@0.0.1:
70577063
version "0.0.1"
70587064
resolved "https://registry.npmmirror.com/hybrid-chai/-/hybrid-chai-0.0.1.tgz#3b0cbc07869f13e567719e0adfe9bbd18cfd9cad"

0 commit comments

Comments
 (0)