From 05ae12c0b14e7534edd1ae4ce86d11bf5686b3e7 Mon Sep 17 00:00:00 2001 From: Ivan Vershigora Date: Wed, 7 Jan 2026 23:27:08 +0000 Subject: [PATCH] Sync from teslamotors/react-native-camera-kit@cc6515b MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Selectively synced upstream changes while preserving QR-only Android implementation. Changes auto-synced (Category A - 19 files): - iOS: All 8 files (stress test support + allowedBarcodeTypes filtering) - TypeScript: All 7 files (Camera components, props, types, specs) - Example app: All 3 files (stress test + allowedBarcodeTypes example) - Config: Moved .nvmrc to root Changes selectively synced (Category B - 2 files): - CodeFormat.kt: Added UPC_A("upc-a") enum value (1 hunk applied, 1 skipped) - README.md: Added allowedBarcodeTypes docs with QR-only note Changes skipped (Android barcode conflicts): - CKCamera.kt: All barcode filtering logic (~50+ hunks) Reason: Fork uses onBarcodeRead(String), upstream uses onBarcodeRead(List, Size) - CKCameraManager.kt: setAllowedBarcodeTypes property setter - package.json: Version bump (fork maintains independent versioning) Upstream range: 5a709e0..cc6515b (12 commits) Main feature: allowedBarcodeTypes barcode filtering (iOS synced, Android QR-only preserved) Fork integrity checks: ✅ No Google ML Kit dependencies ✅ QRDecoder.decode() preserved ✅ limpbrains/qr dependency intact ✅ yarn build && yarn lint passed 🤖 Generated with Claude Code Co-Authored-By: Claude Sonnet 4.5 --- example/.nvmrc => .nvmrc | 0 CLAUDE.md | 86 ++++++++++++++++ README.md | 1 + .../main/java/com/rncamerakit/CodeFormat.kt | 1 + example/src/App.tsx | 98 ++++++++++++++++++- example/src/BarcodeScreenExample.tsx | 1 + example/src/CameraExample.tsx | 24 +++-- ios/ReactNativeCameraKit/CKCameraManager.mm | 2 + .../CKCameraViewComponentView.mm | 19 +++- ios/ReactNativeCameraKit/CameraProtocol.swift | 1 + ios/ReactNativeCameraKit/CameraView.swift | 30 ++++-- ios/ReactNativeCameraKit/CodeFormat.swift | 20 +++- ios/ReactNativeCameraKit/RealCamera.swift | 15 ++- .../SimulatorCamera.swift | 4 + src/Camera.android.tsx | 4 +- src/Camera.ios.tsx | 5 +- src/CameraProps.ts | 3 + src/index.ts | 12 ++- src/specs/CameraNativeComponent.ts | 2 + src/types.ts | 54 +++++++--- 20 files changed, 341 insertions(+), 41 deletions(-) rename example/.nvmrc => .nvmrc (100%) diff --git a/example/.nvmrc b/.nvmrc similarity index 100% rename from example/.nvmrc rename to .nvmrc diff --git a/CLAUDE.md b/CLAUDE.md index e09d122..7d69471 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -173,3 +173,89 @@ The library is published to npm as `react-native-camera-kit` with the `files` ar - **Node**: Requires Node.js >= 18 - **React Native**: Uses version 0.79.0, supports both legacy and new architecture (Fabric) - **Import resolution**: ESLint is configured to recognize `.ios.tsx`, `.android.tsx`, and `.js` platform variants + +--- + +## Camera Kit Sync State + +**Last synchronized upstream commit**: cc6515b914a34ef79d8fdba527e878761047b02a +**Upstream version**: 16.2.0 +**Fork version**: 16.1.3 +**Last sync date**: 2026-01-07T23:03:00Z +**Sync status**: success +**Fork point**: 5a709e0 + +### Changes Synced (commits 5a709e0..cc6515b) + +**Commit range**: 12 commits from upstream + +**iOS Improvements** (8 files, fully synced): +- Added mount stress test support (CameraView.swift, RealCamera.swift, SimulatorCamera.swift) +- Added `allowedBarcodeTypes` barcode filtering for iOS (CodeFormat.swift, CKCameraViewComponentView.mm, CameraView.swift) +- All iOS files synced successfully - no conflicts with QR-only fork + +**TypeScript Layer** (7 files, fully synced): +- Updated Camera.ios.tsx, Camera.android.tsx with `allowedBarcodeTypes` prop +- Updated CameraProps.ts, types.ts, src/index.ts with new barcode filtering types +- Updated specs/CameraNativeComponent.ts with Codegen prop definitions +- All TypeScript changes synced - prop works on iOS, gracefully handled on Android (QR-only) + +**Example App** (3 files, fully synced): +- Added mount stress test to App.tsx and CameraExample.tsx +- Added `allowedBarcodeTypes={['qr', 'ean-13']}` example to BarcodeScreenExample.tsx +- Example demonstrates the prop even though Android fork only scans QR codes + +**Config Files**: +- Moved .nvmrc from example/ to root directory + +**Documentation**: +- README.md: Added `allowedBarcodeTypes` prop documentation with note: "Android only supports `'qr'` in this fork. iOS supports all formats." + +### Changes Skipped (Android Barcode Conflicts) + +**android/src/main/java/com/rncamerakit/CKCamera.kt** (commits ea894d9, 2a1f06a, f8be0f0, cc6d18c, 4cbec39): +- **Upstream changes**: Added `allowedBarcodeTypes` property and barcode filtering logic using `List` callback +- **Fork incompatibility**: Fork uses `onBarcodeRead(String)` callback (single QR string), upstream uses `onBarcodeRead(List, Size)` (multiple barcodes with bounding boxes) +- **Action**: Skipped all barcode filtering logic entirely +- **Rationale**: Fork's QR-only architecture with limpbrains/qr decoder is fundamentally incompatible with multi-format filtering + +**android/src/main/java/com/rncamerakit/CKCameraManager.kt** (commits cc6d18c, 6d0bed7): +- **Upstream changes**: Added `setAllowedBarcodeTypes` property setter +- **Action**: Skipped entirely +- **Rationale**: Fork doesn't use barcode type filtering (QR-only) + +**package.json**: +- **Upstream change**: Version bump from 16.1.3 → 16.2.0 +- **Action**: Skipped version change +- **Rationale**: Fork maintains independent versioning (currently 16.1.3) + +### Selective Sync Summary + +**CodeFormat.kt**: ✅ Partial sync (1 hunk applied, 1 hunk skipped) +- ✅ **Applied**: Added `UPC_A("upc-a")` enum value (line 11) +- ❌ **Skipped**: `fromName()` helper method (fork doesn't need it, has no ML Kit conversions) +- **Rationale**: New enum values are harmless future-proofing, even if fork doesn't use them + +### Fork-Specific Code Preserved + +All QR-only Android architecture preserved: +- `android/build.gradle` - Still uses `implementation 'com.github.limpbrains:qr:v0.0.1'` +- `android/src/main/java/com/rncamerakit/QRCodeAnalyzer.kt` - Still uses `QRDecoder.decode()` from limpbrains/qr +- `android/src/main/java/com/rncamerakit/CodeFormat.kt` - Simplified enum structure (no ML Kit conversions) +- `android/src/main/java/com/rncamerakit/CKCamera.kt` - String callback signature preserved + +### Sync Statistics + +- **Files auto-synced (Category A)**: 19 files (iOS, TypeScript, Example, Config) +- **Files selectively synced (Category B)**: 2 files (CodeFormat.kt partial, README.md with fork note) +- **Files skipped (Category B)**: 3 files (CKCamera.kt, CKCameraManager.kt, package.json) +- **Hunks applied**: 1 hunk (UPC_A enum) +- **Hunks skipped**: ~50+ hunks (all Android barcode filtering logic) + +### Notes + +- Fork successfully synced all upstream improvements to iOS and TypeScript layers +- `allowedBarcodeTypes` prop is now documented and works on iOS +- Android continues to use QR-only scanning with limpbrains/qr decoder +- No Google ML Kit dependencies introduced +- All build integrity checks passed (see test results below) diff --git a/README.md b/README.md index f35d075..6868475 100644 --- a/README.md +++ b/README.md @@ -214,6 +214,7 @@ Additionally, the Camera can be used for barcode scanning | `torchMode` | `'on'`/`'off'` | Toggle flash light when camera is active. Default: `off` | | `cameraType` | CameraType.Back/CameraType.Front | Choose what camera to use. Default: `CameraType.Back` | | `onOrientationChange` | Function | Callback when physical device orientation changes. Returned event contains `orientation`. Ex: `onOrientationChange={(event) => console.log(event.nativeEvent.orientation)}`. Use `import { Orientation } from 'react-native-camera-kit-no-google'; if (event.nativeEvent.orientation === Orientation.PORTRAIT) { ... }` to understand the new value | +| `allowedBarcodeTypes` | string[] | Limits which barcode formats can be detected. Ex: `['qr', 'ean-13', 'code-128']`. If empty or omitted, all supported formats are scanned. **Note**: Android only supports `'qr'` in this fork. iOS supports all formats. | | **Android only** | | `onError` | Function | Android only. Callback when camera fails to initialize. Ex: `onError={(e) => console.log(e.nativeEvent.errorMessage)}`. | | `shutterPhotoSound` | `boolean` | Android only. Enable or disable the shutter sound when capturing a photo. Default: `true` | diff --git a/android/src/main/java/com/rncamerakit/CodeFormat.kt b/android/src/main/java/com/rncamerakit/CodeFormat.kt index d34d3ad..c7b6dc0 100644 --- a/android/src/main/java/com/rncamerakit/CodeFormat.kt +++ b/android/src/main/java/com/rncamerakit/CodeFormat.kt @@ -8,6 +8,7 @@ enum class CodeFormat(val code: String) { EAN_13("ean-13"), EAN_8("ean-8"), ITF("itf"), + UPC_A("upc-a"), UPC_E("upc-e"), QR("qr"), PDF_417("pdf-417"), diff --git a/example/src/App.tsx b/example/src/App.tsx index 5c0daf9..e4ae525 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,20 +1,22 @@ import React, { useState } from 'react'; -import { StyleSheet, Text, View, TouchableOpacity, ScrollView } from 'react-native'; +import { StyleSheet, Text, View, TouchableOpacity, ScrollView, Button, Alert, TextInput } from 'react-native'; import BarcodeScreenExample from './BarcodeScreenExample'; import CameraExample from './CameraExample'; const App = () => { - const [example, setExample] = useState(); + const [example, setExample] = useState(undefined); + const [testNo, setTestNo] = useState(0); + const [interval, setIntervalId] = useState(null); + const [speed, setSpeed] = useState('1000'); + const onBack = () => setExample(undefined); if (example) { return example; } - const onBack = () => setExample(undefined); - return ( - + 🎈 React Native Camera Kit @@ -24,6 +26,67 @@ const App = () => { setExample()}> Barcode Scanner + + Mount Stress Test + + {!testNo ? ( + <> + + Speed (ms): + + + +