Skip to content

Commit eb55140

Browse files
fix widget rpk name error & update lite card custom component path for windows (#66)
* fix: widget rpk name error Signed-off-by: Yingchun <zhangyingchun@oppo.com> * fix: component path for lite card bundle json file Signed-off-by: Yingchun <zhangyingchun@oppo.com> --------- Signed-off-by: Yingchun <zhangyingchun@oppo.com>
1 parent 9f907b5 commit eb55140

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

packages/hap-packager/src/plugins/lite-card-plugin.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class LiteCardPlugin {
3030
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL
3131
},
3232
() => {
33-
const { pathSrc } = this.options
33+
let { pathSrc } = this.options
34+
pathSrc = pathSrc.replace(/\\/g, '/')
3435
const moduleGraph = compilation.moduleGraph
3536
for (const chunk of compilation.chunks) {
3637
const entryModule = chunk.entryModule
@@ -194,23 +195,27 @@ class LiteCardPlugin {
194195
const reqArr = reqPath.split('!')
195196
const lastItem = reqArr[reqArr.length - 1]
196197
const pathArr = lastItem.split('?')
198+
const uxPath = pathArr[0]
199+
const relativeSrcPath = this.getRelativeCompPath(pathSrc, uxPath)
197200
const paramStr = pathArr[1]
198201
const compUxType = 'uxType=comp'
199202
const namePrefix = 'name='
203+
let compName = relativeSrcPath
200204
if (paramStr && paramStr.includes(compUxType) && paramStr.includes(namePrefix)) {
201205
const paramArr = paramStr.split('&')
202206
const nameStr = paramArr.find((item) => item.indexOf(namePrefix) === 0)
203-
const compName = nameStr && nameStr.substring(namePrefix.length)
204-
const uxPath = pathArr[0]
205-
const relativeSrcPath = this.getRelativeCompPath(pathSrc, uxPath)
206-
return { compName, relativeSrcPath }
207+
if (nameStr) {
208+
compName = nameStr.substring(namePrefix.length)
209+
}
207210
}
211+
return { compName, relativeSrcPath }
208212
}
209213
return {}
210214
}
211215

212216
getRelativeCompPath(pathSrc, uxPath) {
213-
const relativeSrcPathStr = path.relative(pathSrc, uxPath)
217+
let relativeSrcPathStr = path.relative(pathSrc, uxPath)
218+
relativeSrcPathStr = relativeSrcPathStr.replace(/\\/g, '/')
214219
if (relativeSrcPathStr && relativeSrcPathStr.endsWith('.ux')) {
215220
return relativeSrcPathStr.substring(0, relativeSrcPathStr.length - SUFFIX_UX.length)
216221
}
@@ -233,7 +238,7 @@ class LiteCardPlugin {
233238
throw new Error(`Invalid request path or src path:\n${requestPath}\n${pathSrc}`)
234239
}
235240
requestPath = requestPath.replace(/\\/g, '/')
236-
pathSrc = pathSrc.replace(/\\/g, '/')
241+
// pathSrc = pathSrc.replace(/\\/g, '/')
237242
// const requestPathNormal = path.normalize(requestPath)
238243
const reqPathArr = requestPath.split('!')
239244
let uxPathStr = reqPathArr[reqPathArr.length - 1]

packages/hap-packager/src/plugins/zip-plugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ ZipPlugin.prototype.apply = function (compiler) {
316316
const widgets = manifest?.router?.widgets || {}
317317
Object.keys(widgets).forEach((key) => {
318318
subpackageOptions.push({
319-
name: key.replace('/', '.'),
319+
name: key.replaceAll('/', '.'),
320320
resource: key,
321321
_widget: true
322322
})

0 commit comments

Comments
 (0)