Add MessagePack support and LibsLoader-based data loading - #3
Merged
Merged
Conversation
Contributor
Reviewer's Guide为 OSSLibraries 核心库添加基于 MessagePack 的数据加载功能,引入 LibsLoader 辅助工具以优先使用 msgpack 并在必要时回退到 JSON,更新 UI 包以使用该辅助工具,将 hvigor 扫描插件切换为输出 MessagePack,并相应刷新文档、变更日志和混淆规则。 LibsLoader.fromRawfile 基于 MessagePack 优先的数据加载顺序图sequenceDiagram
actor UIPage
participant LibsLoader
participant Context as common.Context
participant ResourceManager as resourceManager
participant Libs
UIPage->>LibsLoader: fromRawfile(context)
LibsLoader->>Context: getHostContext()
LibsLoader->>ResourceManager: getRawFileContent(osslibraries.msgpack)
alt msgpack available
LibsLoader->>Libs: fromMsgpack(bytes)
LibsLoader->>LibsLoader: hilog.info(..., MSGPACK_FILE)
LibsLoader-->>UIPage: Libs
else msgpack not available
LibsLoader->>LibsLoader: hilog.info(..., fallback JSON_FILE)
LibsLoader->>ResourceManager: getRawFileContent(osslibraries.json)
LibsLoader->>LibsLoader: util.TextDecoder.create('utf-8')
LibsLoader->>LibsLoader: decoder.decode(content)
LibsLoader->>Libs: fromJson(json)
LibsLoader->>LibsLoader: hilog.info(..., JSON_FILE)
LibsLoader-->>UIPage: Libs
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your Experience访问你的 dashboard 来:
Getting HelpOriginal review guide in EnglishReviewer's GuideAdds MessagePack-based data loading to the OSSLibraries core, introduces a LibsLoader helper that prefers msgpack and falls back to JSON, updates UI packages to use this helper, switches the hvigor scan plugin to MessagePack output, and refreshes docs, changelogs, and obfuscation rules accordingly. Sequence diagram for LibsLoader.fromRawfile MessagePack-first data loadingsequenceDiagram
actor UIPage
participant LibsLoader
participant Context as common.Context
participant ResourceManager as resourceManager
participant Libs
UIPage->>LibsLoader: fromRawfile(context)
LibsLoader->>Context: getHostContext()
LibsLoader->>ResourceManager: getRawFileContent(osslibraries.msgpack)
alt msgpack available
LibsLoader->>Libs: fromMsgpack(bytes)
LibsLoader->>LibsLoader: hilog.info(..., MSGPACK_FILE)
LibsLoader-->>UIPage: Libs
else msgpack not available
LibsLoader->>LibsLoader: hilog.info(..., fallback JSON_FILE)
LibsLoader->>ResourceManager: getRawFileContent(osslibraries.json)
LibsLoader->>LibsLoader: util.TextDecoder.create('utf-8')
LibsLoader->>LibsLoader: decoder.decode(content)
LibsLoader->>Libs: fromJson(json)
LibsLoader->>LibsLoader: hilog.info(..., JSON_FILE)
LibsLoader-->>UIPage: Libs
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
- 新增 MessagePack 解析能力,支持 osslibraries.msgpack 格式 - 添加 LibsLoader.fromRawfile 方法,优先读取 msgpack 文件 - 更新依赖版本至 0.0.4,包括 osslibraries_ui 和 osslibraries_ui_wear - 修改入口文件配置,启用 MessagePack 输出格式 - 添加混淆规则保留 msgpack 相关模块 - 更新文档说明数据加载方式变更
composable-tu
force-pushed
the
message-pack
branch
from
August 8, 2026 12:41
1439f7c to
1ebb246
Compare
Contributor
There was a problem hiding this comment.
Hey - 我在这里给出了一些整体层面的反馈:
- 在
LibsLoader.fromRawfile中,建议在 MessagePack 加载失败时记录底层的BusinessError,或者在回退日志中包含该错误,这样在排查问题时,使用者可以更容易区分“文件缺失”和“解码错误”。 entry/hvigorfile.ts和entry_wear/hvigorfile.ts中 hvigorfile 插件的注释仍然写着它们会生成osslibraries.json,但实际上已经配置为OutputFormat.MessagePack;请更新这些注释以与新的默认输出格式保持一致。
提供给 AI Agent 的提示
Please address the comments from this code review:
## Overall Comments
- 在 `LibsLoader.fromRawfile` 中,建议在 MessagePack 加载失败时记录底层的 `BusinessError`,或者在回退日志中包含该错误,这样在排查问题时,使用者可以更容易区分“文件缺失”和“解码错误”。
- `entry/hvigorfile.ts` 和 `entry_wear/hvigorfile.ts` 中 hvigorfile 插件的注释仍然写着它们会生成 `osslibraries.json`,但实际上已经配置为 `OutputFormat.MessagePack`;请更新这些注释以与新的默认输出格式保持一致。帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据反馈改进后续评审。
Original comment in English
Hey - I've left some high level feedback:
- In
LibsLoader.fromRawfile, consider logging the underlyingBusinessErroror including it in the fallback log when MessagePack loading fails, so consumers can distinguish “file missing” from “decode error” more easily when diagnosing issues. - The hvigorfile plugin comments in
entry/hvigorfile.tsandentry_wear/hvigorfile.tsstill say they generateosslibraries.jsoneven thoughOutputFormat.MessagePackis configured; update these comments to match the new default output format.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `LibsLoader.fromRawfile`, consider logging the underlying `BusinessError` or including it in the fallback log when MessagePack loading fails, so consumers can distinguish “file missing” from “decode error” more easily when diagnosing issues.
- The hvigorfile plugin comments in `entry/hvigorfile.ts` and `entry_wear/hvigorfile.ts` still say they generate `osslibraries.json` even though `OutputFormat.MessagePack` is configured; update these comments to match the new default output format.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
- 将osslibraries.json输出格式更改为osslibraries.msgpack - 添加BusinessError类型导入用于错误处理 - 改进msgpack解析失败时的错误日志记录,包含错误代码和消息 - 优化fallback到JSON文件时的错误区分机制
- 将osslibraries依赖从0.0.3升级到0.0.4版本 - 在所有package-lock文件中添加@ohos/msgpack 1.0.2依赖 - 更新osslibraries包的完整性校验和解析地址 - 修复pnpm-lock.yaml中的osslibraries-hvigor-plugin版本规范符 - 所有相关模块同步更新依赖版本以保持一致性
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
在核心库中新增基于 MessagePack 的许可证数据加载功能,并更新 UI 包和构建配置以使用新的加载器和二进制格式。
新功能:
Libs.fromMsgpack,从二进制数据构建许可证模型。LibsLoader.fromRawfile(context)助手方法,从 rawfile 加载许可证数据,优先使用osslibraries.msgpack,若不存在则回退到 JSON。增强:
LibsLoader进行数据加载,替代手动读取 JSON。构建:
osslibraries-hvigor-plugin,默认输出 MessagePack 格式。文档:
LibsLoader的使用方式和共享数据格式。杂项:
Original summary in English
Summary by Sourcery
Add MessagePack-based license data loading to the core library and update UI packages and build configuration to consume the new loader and binary format.
New Features:
Libs.fromMsgpackto build license models from binary data.LibsLoader.fromRawfile(context)helper to load license data from rawfile, preferringosslibraries.msgpackand falling back to JSON.Enhancements:
LibsLoaderfor data loading instead of manual JSON reads.Build:
osslibraries-hvigor-pluginin app hvigorfiles to emit MessagePack output format by default.Documentation:
LibsLoaderusage, and the shared data format.Chores: