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
76 changes: 62 additions & 14 deletions plugins/clipboard/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,70 @@
# Clipboard registration plugin
# @ohos-rs/ability-plugin-clipboard

`ClipboardPlugin` retains `ohos.clipboard` / async / `["ability"]` identity for paired
registration. All clipboard data operations use the Rust facade's native
`OH_Pasteboard` path. The HAR contains no pasteboard import, data transport,
permission prompt, image conversion, observer or legacy fallback.
English | [简体中文](README.zh-CN.md)

This HAR pairs with `openharmony-ability-plugin-clipboard`. It supplies registration
identity only: clipboard data operations all run through the Rust facade's native
`OH_Pasteboard` path. The HAR imports no pasteboard, transports no clipboard data,
shows no permission prompt, converts no images and installs no change observer.

## Install

```bash
ohpm install @ohos-rs/ability-plugin-clipboard
```

## Assembly

Add the HAR to the application's `oh-package.json5`:

```json5
{
"dependencies": {
"@ohos-rs/ability": "1.0.0-beta.4",
"@ohos-rs/ability-plugin-clipboard": "1.0.0-beta.4"
}
}
```

```ts
import { LazyPlugin } from "@ohos-rs/ability";
import { LazyPlugin, NativeAbility } from "@ohos-rs/ability";
import { ClipboardPlugin } from "@ohos-rs/ability-plugin-clipboard";

new LazyPlugin(() => new ClipboardPlugin());
export default class EntryAbility extends NativeAbility {
public bridgePlugins = [new LazyPlugin(() => new ClipboardPlugin())];
}
```

**Breaking:** remove `ClipboardPluginOptions` and the constructor options argument.
Configure metadata in Rust using `ClipboardClient::with_metadata_mime_type`.
All former ArkTS clipboard actions explicitly fail. Upgrade the Rust package and
HAR from the **same source revision**; do not mix old and new data contracts.
Register `ClipboardBridgePlugin` in Rust and call the clipboard facade there. See the
[Rust facade README](../../crates/plugin-clipboard/README.md).

## Plugin contract

| Field | Value |
| --- | --- |
| `id` | `ohos.clipboard` |
| `execution` | `async` |
| `requires` | `["ability"]` |

The HAR has no clipboard actions. `invokeAsync` rejects every action with an error
directing the caller to the native Rust facade; this is intentional, not a fallback
path. Read and write text, HTML, encoded images, URIs and multi-MIME records through
`ClipboardClient`.

## Runtime constraints

- Configure the metadata MIME in Rust with
`ClipboardClient::with_metadata_mime_type`; the HAR constructor takes no options.
- Upgrade the Rust crate and the HAR from the **same source revision**.
- `read_authorized_records` never prompts. Obtain native paste access or
`ohos.permission.READ_PASTEBOARD` through the application's permission flow, then
call `read_records`.
- Revision reading is a native pull query (crate feature `api-18`); there is no bridge
subscription or change event.

See the [plugin development standard](../../docs/plugin-development-standard.md) for
threading, lifecycle and contract acceptance rules.

## License

See the [Rust README](../../crates/plugin-clipboard/README.md) for MIME mapping,
typed empty-binary errors, explicit application-owned authorization, caller-owned
scheduling and the API-18 pull revision contract. There is no change subscription.
Choose either [MIT](LICENSE-MIT) or [Apache-2.0](LICENSE-APACHE).
66 changes: 64 additions & 2 deletions plugins/clipboard/README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,65 @@
# Clipboard registration plugin
# @ohos-rs/ability-plugin-clipboard

`ClipboardPlugin` 保留 `ohos.clipboard` / async / `["ability"]` 的成对注册身份,剪贴板数据操作均通过 Rust 原生 `OH_Pasteboard` 完成。详细说明见 [README](README.md)。
[English](README.md) | 简体中文

这是 `openharmony-ability-plugin-clipboard` 的 ArkTS HAR。它只提供成对注册身份,剪贴板数据
操作全部通过 Rust facade 的原生 `OH_Pasteboard` 完成;HAR 不导入 pasteboard、不传输剪贴板
数据、不弹出权限提示、不做图片转换,也不安装变更监听。

## Install

```bash
ohpm install @ohos-rs/ability-plugin-clipboard
```

## 装配

在应用 `oh-package.json5` 中添加同版本依赖:

```json5
{
"dependencies": {
"@ohos-rs/ability": "1.0.0-beta.4",
"@ohos-rs/ability-plugin-clipboard": "1.0.0-beta.4"
}
}
```

```ts
import { LazyPlugin, NativeAbility } from "@ohos-rs/ability";
import { ClipboardPlugin } from "@ohos-rs/ability-plugin-clipboard";

export default class EntryAbility extends NativeAbility {
public bridgePlugins = [new LazyPlugin(() => new ClipboardPlugin())];
}
```

Rust 侧需注册 `ClipboardBridgePlugin` 并直接调用剪贴板 facade,示例见
[Rust facade README](../../crates/plugin-clipboard/README.zh-CN.md)。

## Plugin 契约

| 字段 | 值 |
| --- | --- |
| `id` | `ohos.clipboard` |
| `execution` | `async` |
| `requires` | `["ability"]` |

HAR 不包含任何剪贴板 action。`invokeAsync` 对所有 action 直接报错并指向 Rust 原生 facade,
这是有意设计,不存在回退路径。文本、HTML、编码图片、URI 和多 MIME record 的读写都通过
`ClipboardClient` 完成。

## 运行限制

- metadata MIME 在 Rust 侧通过 `ClipboardClient::with_metadata_mime_type` 配置;HAR
构造函数不接受任何选项。
- Rust crate 与 HAR 必须来自**同一个源码版本**。
- `read_authorized_records` 不会弹出授权提示。需通过应用自身的权限流程获取原生粘贴访问权或
`ohos.permission.READ_PASTEBOARD`,再调用 `read_records`。
- revision 是原生拉取查询(crate feature `api-18`),桥接层没有订阅或变更事件。

线程、生命周期与契约验收规则见[插件开发规范](../../docs/plugin-development-standard.md)。

## License

可选择 [MIT](LICENSE-MIT) 或 [Apache-2.0](LICENSE-APACHE)。
Loading