Skip to content

Add MessagePack support and LibsLoader-based data loading - #3

Merged
composable-tu merged 3 commits into
mainfrom
message-pack
Aug 9, 2026
Merged

composable-tu merged 3 commits into
mainfrom
message-pack

Conversation

@composable-tu

@composable-tu composable-tu commented Aug 8, 2026

Copy link
Copy Markdown
Owner
  • 新增 MessagePack 解析能力,支持 osslibraries.msgpack 格式
  • 添加 LibsLoader.fromRawfile 方法,优先读取 msgpack 文件
  • 更新依赖版本至 0.0.4,包括 osslibraries_ui 和 osslibraries_ui_wear
  • 修改入口文件配置,启用 MessagePack 输出格式
  • 添加混淆规则保留 msgpack 相关模块
  • 更新文档说明数据加载方式变更

Summary by Sourcery

在核心库中新增基于 MessagePack 的许可证数据加载功能,并更新 UI 包和构建配置以使用新的加载器和二进制格式。

新功能:

  • 在核心解析器中引入 MessagePack 解析支持,并新增 Libs.fromMsgpack,从二进制数据构建许可证模型。
  • 新增 LibsLoader.fromRawfile(context) 助手方法,从 rawfile 加载许可证数据,优先使用 osslibraries.msgpack,若不存在则回退到 JSON。

增强:

  • 重构预定义的手机和可穿戴设备许可证列表页面,使用共享的 LibsLoader 进行数据加载,替代手动读取 JSON。
  • 编写文档说明统一的数据加载流程、双格式 JSON / MessagePack 支持,以及在各技能和 README 中共享的文件结构。

构建:

  • 在应用 hvigorfiles 中配置 osslibraries-hvigor-plugin,默认输出 MessagePack 格式。
  • 提升核心、手机 UI 和可穿戴 UI HAR 包版本,并将插件依赖更新到 0.0.7。

文档:

  • 更新英文和中文 README 文件、核心包 README 以及 SKILL 指南,说明对 MessagePack 的支持、LibsLoader 的使用方式和共享数据格式。
  • 明确空白列表页面的排障指南,涵盖 JSON 和 MessagePack 两种数据文件情形。

杂项:

  • 扩展工作区的 release-age 配置和锁定文件,以适配新的插件和包版本。
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:

  • Introduce MessagePack parsing support in the core parser and Libs.fromMsgpack to build license models from binary data.
  • Add LibsLoader.fromRawfile(context) helper to load license data from rawfile, preferring osslibraries.msgpack and falling back to JSON.

Enhancements:

  • Refactor predefined phone and wearable license list pages to use the shared LibsLoader for data loading instead of manual JSON reads.
  • Document the unified data loading flow, dual JSON / MessagePack support, and shared file structure across skills and READMEs.

Build:

  • Configure osslibraries-hvigor-plugin in app hvigorfiles to emit MessagePack output format by default.
  • Bump core, phone UI, and wearable UI HAR package versions and update the plugin dependency to 0.0.7.

Documentation:

  • Update English and Chinese README files, the core package README, and SKILL guide to describe MessagePack support, LibsLoader usage, and the shared data format.
  • Clarify troubleshooting guidance for blank list pages to cover both JSON and MessagePack data files.

Chores:

  • Extend workspace release-age configuration and lockfiles for the new plugin and package versions.

@sourcery-ai

sourcery-ai Bot commented Aug 8, 2026

Copy link
Copy Markdown
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
Loading

File-Level Changes

Change Details Files
在核心库中引入 MessagePack 解析,并通过 LibsLoader 实现数据加载的集中化。
  • 扩展 Parser,使用 @ohos/msgpack 解码 MessagePack 字节数据,并通过新的 parseRoot 辅助函数共享逻辑。
  • 添加 Libs.fromMsgpack(bytes),以从 MessagePack 数据构建 Libs,同时保持按名称排序。
  • 实现 LibsLoader.fromRawfile(context),优先加载 osslibraries.msgpack 并在必要时回退到 osslibraries.json,并输出日志。
  • 从核心索引导出 LibsLoader,使 UI 和自定义代码可以使用单一的高级加载器 API。
osslibraries/src/main/ets/util/Parser.ets
osslibraries/src/main/ets/Libs.ets
osslibraries/src/main/ets/util/LibsLoader.ets
osslibraries/Index.ets
将构建和运行时资源从 JSON 切换到 MessagePack,并更新插件配置。
  • 在 hvigorfile.ts 中配置 ossScanPlugin,使手机和穿戴入口模块都使用 OutputFormat.MessagePack。
  • 在 entry 和 entry_wear 资源中,用 osslibraries.msgpack 原始文件替换 osslibraries.json。
  • 将对 osslibraries-hvigor-plugin 的开发依赖更新到 0.0.7,并扩展 minimumReleaseAgeExclude 以包含 0.0.7。
  • 提升核心、手机 UI 和穿戴 UI 包的 HAR_VERSION,以反映新版本发布。
entry/hvigorfile.ts
entry_wear/hvigorfile.ts
entry/src/main/resources/rawfile/osslibraries.msgpack
entry_wear/src/main/resources/rawfile/osslibraries.msgpack
entry/src/main/resources/rawfile/osslibraries.json
entry_wear/src/main/resources/rawfile/osslibraries.json
package.json
pnpm-workspace.yaml
osslibraries/BuildProfile.ets
osslibraries_ui/BuildProfile.ets
osslibraries_ui_wear/BuildProfile.ets
pnpm-lock.yaml
重构手机和穿戴 UI 的列表页面,使其使用 LibsLoader 而非手动读取 JSON。
  • 更新手机列表页,导入 LibsLoader,并调用 LibsLoader.fromRawfile(context) 来替代手动读取和解码 osslibraries.json。
  • 更新穿戴列表页,使用 LibsLoader.fromRawfile(context) 替代自定义的原始文件 JSON 加载逻辑。
  • 调整这些页面上的内联文档,说明通过 LibsLoader 实现“MessagePack 优先、JSON 回退”的加载方式。
osslibraries_ui/src/main/ets/pages/OSSLibrariesLicenseListPage.ets
osslibraries_ui_wear/src/main/ets/pages/OSSLibrariesLicenseListPageWear.ets
更新文档和技能说明,以描述新的数据加载流程、MessagePack 支持以及相关 API。
  • 修订 SKILL.md,提及 osslibraries.msgpack,说明 LibsLoader.fromRawfile,并记录 Libs.fromMsgpack 和 Parser.parseMsgpack。
  • 更新英文和中文 README,展示使用 LibsLoader.fromRawfile 而非手动读取 JSON,并说明统一的数据加载与解析方式。
  • 更新 OSSLibraries 包的 README,使其与新的加载器模式保持一致,并从示例中移除底层 JSON 解码逻辑。
  • 澄清 JSON 和 MessagePack 共享相同的数据结构,且预定义页面依赖 LibsLoader 进行加载,并优先使用 msgpack。
  • 调整故障排查文档,使其同时考虑 osslibraries.json 和 osslibraries.msgpack 的存在情况。
skills/osslibraries-usage/SKILL.md
README.md
README_zh.md
osslibraries/README.md
osslibraries_ui/README.md
osslibraries_ui_wear/README.md
更新变更日志和打包元数据,以反映新版本及其能力。
  • 在核心库的变更日志中添加 v0.0.4 项目,描述 MessagePack 解析和 LibsLoader.fromRawfile。
  • 在 osslibraries_ui 中添加 v0.0.7 变更日志条目,说明采用 LibsLoader 以及核心依赖版本提升。
  • 在 osslibraries_ui_wear 中添加 v0.0.3 变更日志条目,记录类似变更。
  • 刷新核心和 UI 模块的 oh-package.json5 / oh-package-lock.json5,以与新版本及依赖对齐。
  • 调整混淆/消费者规则,以保留与 msgpack 相关的模块(细节见 obfuscation-rules.txt 和 consumer-rules.txt)。
osslibraries/changelog.md
osslibraries_ui/changelog.md
osslibraries_ui_wear/changelog.md
osslibraries/oh-package.json5
osslibraries/oh-package-lock.json5
osslibraries_ui/oh-package.json5
osslibraries_ui_wear/oh-package.json5
osslibraries/consumer-rules.txt
osslibraries/obfuscation-rules.txt
oh-package.json5
entry/oh-package-lock.json5
entry_wear/oh-package-lock.json5

Tips and commands

Interacting with Sourcery

  • 触发新评审: 在 Pull Request 上评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的评审评论。
  • 从评审评论生成 GitHub Issue: 通过回复评审评论请求 Sourcery 以该评论创建一个 issue。你也可以在评审评论中回复 @sourcery-ai issue 来从该评论创建 issue。
  • 生成 Pull Request 标题: 在 Pull Request 标题中任意位置写入 @sourcery-ai,即可随时生成标题。你也可以在 Pull Request 中评论 @sourcery-ai title 以随时(重新)生成标题。
  • 生成 Pull Request 摘要: 在 Pull Request 正文中任意位置写入 @sourcery-ai summary,即可在该位置生成 PR 摘要。你也可以在 Pull Request 中评论 @sourcery-ai summary 以随时(重新)生成摘要。
  • 生成评审者指南: 在 Pull Request 中评论 @sourcery-ai guide,即可随时(重新)生成评审者指南。
  • 解决所有 Sourcery 评论: 在 Pull Request 中评论 @sourcery-ai resolve,即可将所有 Sourcery 评论标记为已解决。如果你已经处理了所有评论且不希望再看到它们,这会很有用。
  • 关闭所有 Sourcery 评审: 在 Pull Request 中评论 @sourcery-ai dismiss,即可关闭所有现有的 Sourcery 评审。特别适用于你希望从一次全新的评审开始——别忘了评论 @sourcery-ai review 以触发新评审!

Customizing Your Experience

访问你的 dashboard 来:

  • 启用或禁用评审功能,例如 Sourcery 生成的 Pull Request 摘要、评审者指南等。
  • 更改评审语言。
  • 添加、移除或编辑自定义评审说明。
  • 调整其他评审设置。

Getting Help

Original review guide in English

Reviewer's Guide

Adds 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 loading

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
Loading

File-Level Changes

Change Details Files
Introduce MessagePack parsing in the core library and centralize data loading via LibsLoader.
  • Extend Parser to decode MessagePack bytes using @ohos/msgpack and share logic via a new parseRoot helper.
  • Add Libs.fromMsgpack(bytes) to build Libs from MessagePack data while preserving name-based sorting.
  • Implement LibsLoader.fromRawfile(context) to prefer osslibraries.msgpack and fall back to osslibraries.json, with logging.
  • Export LibsLoader from the core index so UI and custom code can consume a single high-level loader API.
osslibraries/src/main/ets/util/Parser.ets
osslibraries/src/main/ets/Libs.ets
osslibraries/src/main/ets/util/LibsLoader.ets
osslibraries/Index.ets
Switch build and runtime resources from JSON to MessagePack and update plugin configuration.
  • Configure ossScanPlugin in hvigorfile.ts to use OutputFormat.MessagePack for both phone and wear entry modules.
  • Replace osslibraries.json rawfiles with osslibraries.msgpack in entry and entry_wear resources.
  • Update dev dependency on osslibraries-hvigor-plugin to 0.0.7 and extend minimumReleaseAgeExclude to include 0.0.7.
  • Bump HAR_VERSIONs for core, phone UI, and wear UI packages to reflect new releases.
entry/hvigorfile.ts
entry_wear/hvigorfile.ts
entry/src/main/resources/rawfile/osslibraries.msgpack
entry_wear/src/main/resources/rawfile/osslibraries.msgpack
entry/src/main/resources/rawfile/osslibraries.json
entry_wear/src/main/resources/rawfile/osslibraries.json
package.json
pnpm-workspace.yaml
osslibraries/BuildProfile.ets
osslibraries_ui/BuildProfile.ets
osslibraries_ui_wear/BuildProfile.ets
pnpm-lock.yaml
Refactor UI list pages to consume LibsLoader instead of manual JSON reading, across phone and wear UIs.
  • Update phone list page to import LibsLoader and call LibsLoader.fromRawfile(context) instead of reading and decoding osslibraries.json manually.
  • Update wear list page to use LibsLoader.fromRawfile(context) in place of custom rawfile JSON loading.
  • Adjust inline documentation on these pages to describe msgpack-first loading and JSON fallback via LibsLoader.
osslibraries_ui/src/main/ets/pages/OSSLibrariesLicenseListPage.ets
osslibraries_ui_wear/src/main/ets/pages/OSSLibrariesLicenseListPageWear.ets
Update documentation and skills to describe the new data loading flow, MessagePack support, and APIs.
  • Revise SKILL.md to mention osslibraries.msgpack, describe LibsLoader.fromRawfile, and document Libs.fromMsgpack and Parser.parseMsgpack.
  • Update English and Chinese READMEs to show LibsLoader.fromRawfile usage instead of manual JSON reading, and to describe unified data loading and parsing.
  • Update OSSLibraries package README to align with the new loader pattern and remove low-level JSON decoding from examples.
  • Clarify that JSON and MessagePack share the same data structure and that predefined pages rely on LibsLoader for loading with msgpack preference.
  • Adjust troubleshooting docs to consider both osslibraries.json and osslibraries.msgpack presence.
skills/osslibraries-usage/SKILL.md
README.md
README_zh.md
osslibraries/README.md
osslibraries_ui/README.md
osslibraries_ui_wear/README.md
Update changelogs and packaging metadata for the new versions and capabilities.
  • Add v0.0.4 changelog entry for core describing MessagePack parsing and LibsLoader.fromRawfile.
  • Add v0.0.7 changelog entry for osslibraries_ui noting LibsLoader adoption and core dependency bump.
  • Add v0.0.3 changelog entry for osslibraries_ui_wear with similar changes.
  • Refresh oh-package.json5 / oh-package-lock.json5 files for core and UI modules to align with new versions and dependencies.
  • Adjust obfuscation/consumer rules to preserve msgpack-related modules (details in obfuscation-rules.txt and consumer-rules.txt).
osslibraries/changelog.md
osslibraries_ui/changelog.md
osslibraries_ui_wear/changelog.md
osslibraries/oh-package.json5
osslibraries/oh-package-lock.json5
osslibraries_ui/oh-package.json5
osslibraries_ui_wear/oh-package.json5
osslibraries/consumer-rules.txt
osslibraries/obfuscation-rules.txt
oh-package.json5
entry/oh-package-lock.json5
entry_wear/oh-package-lock.json5

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot changed the title feat(core): 添加 MessagePack 支持并优化数据加载 @sourcery-ai Add MessagePack support and LibsLoader-based data loading Aug 8, 2026
- 新增 MessagePack 解析能力,支持 osslibraries.msgpack 格式
- 添加 LibsLoader.fromRawfile 方法,优先读取 msgpack 文件
- 更新依赖版本至 0.0.4,包括 osslibraries_ui 和 osslibraries_ui_wear
- 修改入口文件配置,启用 MessagePack 输出格式
- 添加混淆规则保留 msgpack 相关模块
- 更新文档说明数据加载方式变更

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出了一些整体层面的反馈:

  • LibsLoader.fromRawfile 中,建议在 MessagePack 加载失败时记录底层的 BusinessError,或者在回退日志中包含该错误,这样在排查问题时,使用者可以更容易区分“文件缺失”和“解码错误”。
  • entry/hvigorfile.tsentry_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`;请更新这些注释以与新的默认输出格式保持一致。

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据反馈改进后续评审。
Original comment in English

Hey - I've left some high level feedback:

  • 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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
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版本规范符
- 所有相关模块同步更新依赖版本以保持一致性
@composable-tu
composable-tu merged commit 3a8a539 into main Aug 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant