@oh-expo/expo-sharing
v55.0.20-harmony.0
Published
expo-sharing 的 HarmonyOS 适配包(ExpoModule 原生模块,expo-modules-core 体系)
Maintainers
Readme
@oh-expo/expo-sharing
让
expo-sharing(系统分享)在 HarmonyOS / OpenHarmony 上运行的适配包。
通过 expo-modules-core 体系提供 ExpoSharingModule 原生模块(模块名 ExpoSharing),
接口收口自 [email protected] 权威 d.ts。
支持基线
| 项 | 值 |
| --- | --- |
| 适配目标 | [email protected] |
| 运行时底座 | @expo-harmony/[email protected](本地 HAR) |
| 鸿蒙 SDK | API 26(SDK 26.0.0 锚定,@kit.ShareKit + @kit.CoreFileKit + @kit.ArkData uniformTypeDescriptor) |
| 权限 | 无(系统分享面板) |
实现面
shareAsync(url, options)(ShareController.show:SINGLE 选择 + UTD 预览模式 + anchor)/isAvailableAsync(SystemCapability.Collaboration.SystemShare);- 接收分享:
getSharedPayloads/getResolvedSharedPayloadsAsync/clearSharedPayloads+onSharedPayloadsChanged事件(onNewWant 分发、世代取消/清理、50 记录/100MB 单文件/250MB 总量上限); - URL 载荷流式请求头解析(content-type/content-disposition/content-length)、文件载荷物化 (fileIo.copyFile + fileUriFromPath);
- 诚实分级:仅支持 file:// 分享(其余 scheme 报 ERR_SHARING_INVALID_URL);dialogTitle 不支持 (warn 忽略,HarmonyOS Share Kit 无自定义面板标题)。
快速开始
安装 npm 包(peer 依赖
expo-sharing原包与 expo-modules-core 自动安装):npm install @oh-expo/expo-sharing拷贝 HAR 到宿主并声明 ohpm 依赖:
cp node_modules/@oh-expo/expo-sharing/local-hars/expo_sharing.har harmony/local-hars/// harmony/oh-package.json5 { "dependencies": { "@oh-expo/expo-sharing": "file:local-hars/expo_sharing.har" } }JS 侧使用(对外契约由原包提供):
import * as Sharing from 'expo-sharing';
构建与校验
pnpm har:prepare # hvigorw assembleHar → local-hars/expo_sharing.har
pnpm har:prepack # 发布前校验(必需文件 / scope / -harmony.N 版本 / HAR 产物)状态与来源
- ⚠️ 实现已落盘并经 assembleHar / 宿主接入编译验证(真机功能验证 ⏳);
- 接口契约锚定
[email protected]权威 d.ts,规格见主仓docs/adaptations/expo-sharing.md与acceptance/ledger.md(S4 前置门口径)。
