@oh-expo/expo-constants
v55.0.17-harmony.1
Published
expo-constants 的 HarmonyOS 适配包(ExpoModule 原生模块,expo-modules-core 体系)
Maintainers
Readme
@oh-expo/expo-constants
让 expo-constants(Expo 常量/系统信息)在 HarmonyOS / OpenHarmony 上运行的适配包。
通过 expo-modules-core 体系提供 ExpoConstantsModule 原生模块(模块名 ExponentConstants,
与 JS 侧约定一致:constants 字段链 + getWebViewUserAgentAsync)。
支持基线
| 项 | 值 |
| --- | --- |
| 适配目标 | [email protected] |
| 运行时底座 | @expo-harmony/[email protected](本地 HAR) |
| 鸿蒙 SDK | API 26(SDK 26.0.0 锚定) |
| 权限 | 无(只读系统/bundle 信息) |
实现字段(constants 链)
appOwnership / debugMode / deviceName / deviceYearClass / executionEnvironment /
isHeadless / manifest(rawfile app.config 读取)/ manifest2 / sessionId /
statusBarHeight / systemFonts / systemVersion / platform(bundle 信息 + 设备信息)
getWebViewUserAgentAsync(WebView 默认 UA)。
快速开始(宿主接入)
- 安装(npm):
npm install @oh-expo/expo-constants(peer 自动带 expo-constants 原包与 expo-modules-core); - 从
node_modules/@oh-expo/expo-constants/local-hars/拷贝expo_constants.har到宿主harmony/local-hars/,宿主oh-package.json5依赖"@oh-expo/expo-constants": "file:local-hars/expo_constants.har"(ohpm 公共源无 @oh-expo scope,本地 HAR 必须用相对路径); - expo-modules 体系模块经 expo-modules-core 运行时注册(无需改 RNOHPackagesFactory);
- JS 侧直接
import Constants from 'expo-constants'(对外契约由原包提供)。
构建与校验
pnpm har:prepare # hvigorw assembleHar → local-hars/expo_constants.har
pnpm har:prepack # 发布前校验(必需文件 / scope / -harmony.N 版本 / HAR 产物)状态与来源
- ⚠️ 实现已落盘(参照 renbaoshuo/expo-harmony 的 expo-constants 适配,MIT,来源致谢); 编译与宿主接入验证状态见 expo-harmony 主仓 [acceptance/ledger.md](S4 前置门口径)。
- 适配细节与接口规格:expo-harmony 主仓
docs/adaptations/expo-constants.md。
