Skip to content
Merged
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
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ An open source license scanning and display library for HarmonyOS.

- **End-to-end** — scans your dependencies at build time and displays the license list in your app. No manual JSON editing, no drift.
- **Prebuilt UI pages** — drop-in list and detail pages built on ArkUI & UI Design Kit components.
- **Custom UI, no problem** — use the core package alone to read `osslibraries.json` and render the license list in any UI you build.
- **Custom UI, no problem** — use the core package alone to load and parse the license data and render it in any UI you build.
- **Always up to date** — the Hvigor plugin scans `oh_modules/` on every build. The license list always matches what you ship.
- **AI-assisted integration** — ships an Agent Skill so an AI can wire the library into your project for you.

Expand Down Expand Up @@ -141,20 +141,15 @@ You can skip the predefined OSSLibraries UI pages and use the `core` module dire
ohpm install osslibraries
```

Then read `osslibraries.json` in your custom page as follows:
The core package handles data loading and parsing. In your custom page, call `LibsLoader.fromRawfile(context)` to get a sorted `Libs` instance:

```ets
import { util } from '@kit.ArkTS';
import { common } from '@kit.AbilityKit';
import { Libs, LibsHolder } from 'osslibraries';
import { Libs, LibsHolder, LibsLoader } from 'osslibraries';

// Read osslibraries.json
const context: common.Context = this.getUIContext().getHostContext() as common.Context;
const content: Uint8Array = await context.resourceManager.getRawFileContent('osslibraries.json');
const json: string = util.TextDecoder.create('utf-8').decode(content);

// Parse JSON
const libs: Libs = Libs.fromJson(json);
const libs: Libs = await LibsLoader.fromRawfile(context);

// Find a library
const lib = libs.findLibrary('@ohos/hypium');
Expand Down
13 changes: 4 additions & 9 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

- **端到端** — 从构建时扫描依赖到应用内展示 License 列表,一条链路走通,无需手动维护 JSON。
- **预定义 UI 页面** — 提供开箱即用的列表页与详情页,基于 ArkUI 和 UI Design Kit 组件。
- **自定义 UI 亦可** — 可单独使用 Core 包读取 `osslibraries.json`,License 列表的渲染方式完全由你决定。
- **自定义 UI 亦可** — 可单独使用 Core 包加载并解析许可证数据,License 列表的渲染方式完全由你决定。
- **始终同步** — Hvigor 插件在每次构建时扫描 `oh_modules/`,License 列表永远跟随实际发布的依赖。
- **AI 辅助集成** — 提供 Agent Skill,可由 AI 代为完成项目接入。

Expand Down Expand Up @@ -141,20 +141,15 @@ this.getUIContext().getRouter().pushNamedRoute({
ohpm install osslibraries
```

然后,在自定义页面中按以下方法读取 `osslibraries.json`:
`osslibraries` 包负责数据加载与解析。在自定义页面中调用 `LibsLoader.fromRawfile(context)` 即可拿到排好序的 `Libs` 实例:

```ets
import { util } from '@kit.ArkTS';
import { common } from '@kit.AbilityKit';
import { Libs, LibsHolder } from 'osslibraries';
import { Libs, LibsHolder, LibsLoader } from 'osslibraries';

// 读 osslibraries.json
const context: common.Context = this.getUIContext().getHostContext() as common.Context;
const content: Uint8Array = await context.resourceManager.getRawFileContent('osslibraries.json');
const json: string = util.TextDecoder.create('utf-8').decode(content);

// 解析 JSON
const libs: Libs = Libs.fromJson(json);
const libs: Libs = await LibsLoader.fromRawfile(context);

// 查找某个库
const lib = libs.findLibrary('@ohos/hypium');
Expand Down
6 changes: 4 additions & 2 deletions entry/hvigorfile.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { hapTasks } from "@ohos/hvigor-ohos-plugin";
import { ossScanPlugin } from "osslibraries-hvigor-plugin";
import { ossScanPlugin, OutputFormat } from "osslibraries-hvigor-plugin";

export default {
system: hapTasks /* Built-in plugin of Hvigor. It cannot be modified. */,
plugins: [ossScanPlugin()] /* Scan OHPM deps and generate osslibraries.json at build time. */,
plugins: [
ossScanPlugin({ format: OutputFormat.MessagePack }),
] /* Scan OHPM deps and generate osslibraries.msgpack at build time. */,
};
27 changes: 19 additions & 8 deletions entry/oh-package-lock.json5

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion entry/src/main/resources/rawfile/osslibraries.json

This file was deleted.

Loading
Loading