@unif/react-native-hms-scan 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +29 -12
  2. package/package.json +11 -1
package/README.md CHANGED
@@ -2,13 +2,18 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@unif/react-native-hms-scan.svg?color=cb3837&logo=npm)](https://www.npmjs.com/package/@unif/react-native-hms-scan)
4
4
  [![CI](https://github.com/unif-design/react-native-hms-scan/actions/workflows/ci.yml/badge.svg)](https://github.com/unif-design/react-native-hms-scan/actions/workflows/ci.yml)
5
- [![License](https://img.shields.io/npm/l/@unif/react-native-hms-scan.svg?color=blue)](https://github.com/unif-design/react-native-hms-scan/blob/main/LICENSE)
5
+ [![License](https://img.shields.io/npm/l/@unif/react-native-hms-scan.svg?color=blue)](LICENSE)
6
6
  [![Docs](https://img.shields.io/badge/docs-unif--design.github.io-orange.svg)](https://unif-design.github.io/react-native-hms-scan/)
7
7
 
8
- 华为 **HMS 统一扫码**(HUAWEI Scan Kit)的 React Native 封装(新架构):定制视图扫码(成品页 `<Scanner>` / headless `<HmsScanView>`)+ 图片识别(`decodeImage`)。Android 用 Scan SDK-Plus(内置引擎,**不依赖 HMS Core APK**,非华为机型可用),iOS 用 ScanKitFrameWork;两端均无需 AppGallery Connect / API Key。
8
+ 华为 **HMS 统一扫码(HUAWEI Scan Kit)** 的 React Native 封装,面向 RN 0.85 新架构(Fabric + TurboModule):成品扫一扫页、headless 自定义扫码 UI、从图片识别条码 / 二维码。
9
9
 
10
- > 📖 **完整文档**(安装 · 平台配置 · API · 平台差异 · 故障排查):
11
- > **https://unif-design.github.io/react-native-hms-scan/**
10
+ ## 特性
11
+
12
+ - **三种用法** — 成品 `<Scanner>` 扫一扫页(自带权限流 / 状态机 / 主题)、headless `<HmsScanView>` 相机组件(自定义 UI)、`decodeImage(uri)` 从本地图片识别。
13
+ - **Android 内置引擎** — 用 Scan SDK-Plus,**非华为机型可用**,不依赖设备装 HMS Core APK;华为 maven 与依赖已内置在库里,宿主无需改 gradle。
14
+ - **零云端配置** — 两端**都不需要 AppGallery Connect / agconnect / API Key**。
15
+ - **14 种码制** — `QR_CODE` / `EAN_13` / `CODE_128` / `PDF417` / `DATA_MATRIX` 等,默认识别全部。
16
+ - 仅支持 **RN 新架构**;`@unif/react-native-design` 风格统一。
12
17
 
13
18
  ## 安装
14
19
 
@@ -17,9 +22,11 @@ yarn add @unif/react-native-hms-scan react-native-svg
17
22
  cd ios && pod install
18
23
  ```
19
24
 
20
- 本库为新架构(TurboModule + Fabric)库,宿主需开启新架构。Android 权限、iOS `ScanKitFrameWork`(arm64-only 静态库,模拟器排除 / 建议真机)等见[文档站 · 安装](https://unif-design.github.io/react-native-hms-scan/docs/getting-started/installation)。
25
+ `react-native-svg` 是 peer 依赖(`<Scanner>` 图标用它绘制);`<Scanner>` 还依赖 peer `@unif/react-native-design`。宿主需开启新架构。Android 权限、iOS `NSCameraUsageDescription` 等见[文档站 · 安装](https://unif-design.github.io/react-native-hms-scan/docs/getting-started/installation)。
26
+
27
+ ## 快速开始
21
28
 
22
- ## 用法
29
+ 成品「扫一扫」页 —— 扫到条码后由宿主解析商品、确认带回:
23
30
 
24
31
  ```tsx
25
32
  import { Scanner, type ScanResult, type ScanProduct } from '@unif/react-native-hms-scan';
@@ -30,18 +37,28 @@ function ScanScreen({ navigation }) {
30
37
  title="扫一扫"
31
38
  onClose={() => navigation.goBack()}
32
39
  resolveProduct={async (r: ScanResult): Promise<ScanProduct | null> => {
33
- const p = await api.lookupByBarcode(r.value);
34
- return p
35
- ? { name: p.name, brand: p.brand, price: `¥${p.price}`, barcode: r.value }
36
- : null;
40
+ const p = await api.lookupByBarcode(r.value); // 你来解析;返回 null = 未识别
41
+ return p ? { name: p.name, brand: p.brand, price: `¥${p.price}`, barcode: r.value } : null;
37
42
  }}
38
- onConfirm={(product, result) => navigation.navigate('Order', { product })}
43
+ onConfirm={(product, result) => navigation.navigate('Order', { product, barcode: result.value })}
39
44
  />
40
45
  );
41
46
  }
42
47
  ```
43
48
 
44
- headless `<HmsScanView>`、图片识别 `decodeImage`、权限、平台差异 —— 见[文档站](https://unif-design.github.io/react-native-hms-scan/)。
49
+ headless `<HmsScanView>`(完全自定义 UI)、图片识别 `decodeImage`、权限、平台差异 —— 见[文档站](https://unif-design.github.io/react-native-hms-scan/)。
50
+
51
+ ## 文档
52
+
53
+ - **完整文档**(安装 · 平台配置 · API · 平台差异 · 故障排查):https://unif-design.github.io/react-native-hms-scan/
54
+ - **AI / Agent**(按需 fetch,别凭记忆猜 API):[llms.txt](https://unif-design.github.io/react-native-hms-scan/llms.txt) · [llms-full.txt](https://unif-design.github.io/react-native-hms-scan/llms-full.txt)
55
+ - **Agent Skill** `using-unif-hms-scan`(`unif-react-native` plugin):`/plugin marketplace add unif-design/react-native-skills` → `/plugin install unif-react-native@unif-react-native-skills`
56
+
57
+ ## 兼容性
58
+
59
+ - **React Native** 新架构(Fabric + TurboModule)**必须开启**;在 RN 0.85 上开发与验证。
60
+ - **Android** minSdkVersion ≥ 24(Android 7.0)。
61
+ - **iOS** `ScanKitFrameWork` 扫码功能**仅真机**(模拟器可编译,相机要真机)。
45
62
 
46
63
  ## 许可
47
64
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unif/react-native-hms-scan",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "华为 HMS 统一扫码服务 React Native bridge:定制视图扫码 + 图片识别 (Scan SDK-Plus / ScanKitFrameWork,@unif 私有)",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -127,6 +127,11 @@
127
127
  "name": "ReactNativeHmsScanSpec",
128
128
  "type": "all",
129
129
  "jsSrcsDir": "src",
130
+ "ios": {
131
+ "componentProvider": {
132
+ "HmsScanView": "HmsScanView"
133
+ }
134
+ },
130
135
  "android": {
131
136
  "javaPackageName": "com.unif.reactnativehmsscan"
132
137
  }
@@ -184,6 +189,11 @@
184
189
  ],
185
190
  "setupFiles": [
186
191
  "./jest.setup.ts"
192
+ ],
193
+ "testPathIgnorePatterns": [
194
+ "<rootDir>/node_modules/",
195
+ "<rootDir>/website/",
196
+ "<rootDir>/lib/"
187
197
  ]
188
198
  },
189
199
  "prettier": {