@trustchex/react-native-sdk 1.163.6 → 1.163.8
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.
- package/TrustchexSDK.podspec +0 -1
- package/android/src/main/AndroidManifest.xml +1 -2
- package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin-Bridging-Header.h +9 -0
- package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin.swift +173 -157
- package/lib/module/Shared/Components/QrCodeScannerCamera.js +15 -3
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/index.js +0 -2
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.js +2 -0
- package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts.map +1 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts +0 -2
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts.map +1 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Shared/Components/QrCodeScannerCamera.tsx +15 -2
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/index.ts +0 -4
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.ts +2 -0
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/components/BarcodeCamera.js +0 -66
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/components/BarcodeCamera.d.ts +0 -13
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/components/BarcodeCamera.d.ts.map +0 -1
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/components/BarcodeCamera.tsx +0 -85
package/TrustchexSDK.podspec
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<manifest xmlns:tools="http://schemas.android.com/tools"
|
|
2
|
-
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
-
package="com.trustchex.reactnativesdk">
|
|
2
|
+
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
4
3
|
<uses-permission android:name="android.permission.INTERNET" />
|
|
5
4
|
<uses-permission android:name="android.permission.CAMERA" />
|
|
6
5
|
<uses-permission android:name="android.permission.NFC" />
|
package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin-Bridging-Header.h
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#ifndef BarcodeScannerFrameProcessorPlugin_Bridging_Header_h
|
|
2
|
+
#define BarcodeScannerFrameProcessorPlugin_Bridging_Header_h
|
|
3
|
+
|
|
4
|
+
#if VISION_CAMERA_ENABLE_FRAME_PROCESSORS
|
|
5
|
+
#import <VisionCamera/FrameProcessorPlugin.h>
|
|
6
|
+
#import <VisionCamera/Frame.h>
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
#endif /* BarcodeScannerFrameProcessorPlugin_Bridging_Header_h */
|
|
@@ -1,172 +1,188 @@
|
|
|
1
1
|
import Foundation
|
|
2
|
-
import VisionCamera
|
|
3
2
|
import Vision
|
|
3
|
+
import VisionCamera
|
|
4
4
|
|
|
5
5
|
@objc(BarcodeScannerFrameProcessorPlugin)
|
|
6
6
|
public class BarcodeScannerFrameProcessorPlugin: FrameProcessorPlugin {
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
public override init(proxy: VisionCameraProxyHolder, options: [AnyHashable: Any]! = [:]) {
|
|
9
|
+
super.init(proxy: proxy, options: options)
|
|
10
|
+
print(
|
|
11
|
+
"BarcodeScannerFrameProcessorPlugin: Initialized with options: \(String(describing: options))"
|
|
12
|
+
)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public override func callback(_ frame: Frame, withArguments arguments: [AnyHashable: Any]?)
|
|
16
|
+
-> Any?
|
|
17
|
+
{
|
|
18
|
+
print("BarcodeScannerFrameProcessorPlugin: callback called")
|
|
19
|
+
|
|
20
|
+
// Get the pixel buffer from the frame
|
|
21
|
+
guard let imageBuffer = CMSampleBufferGetImageBuffer(frame.buffer) else {
|
|
22
|
+
print("BarcodeScannerFrameProcessorPlugin: Could not get pixel buffer from frame")
|
|
23
|
+
return []
|
|
24
|
+
}
|
|
12
25
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return .code93
|
|
36
|
-
case "data-matrix":
|
|
37
|
-
return .dataMatrix
|
|
38
|
-
case "ean-13":
|
|
39
|
-
return .ean13
|
|
40
|
-
case "ean-8":
|
|
41
|
-
return .ean8
|
|
42
|
-
case "itf":
|
|
43
|
-
return .i2of5
|
|
44
|
-
case "pdf-417":
|
|
45
|
-
return .pdf417
|
|
46
|
-
case "qr":
|
|
47
|
-
return .qr
|
|
48
|
-
case "upc-e":
|
|
49
|
-
return .upce
|
|
50
|
-
default:
|
|
51
|
-
return nil
|
|
52
|
-
}
|
|
53
|
-
}
|
|
26
|
+
// Parse barcode types from arguments (default to QR codes)
|
|
27
|
+
var symbologies: [VNBarcodeSymbology] = [.qr]
|
|
28
|
+
|
|
29
|
+
if let arguments = arguments,
|
|
30
|
+
let barcodeTypes = arguments["barcodeTypes"] as? [String]
|
|
31
|
+
{
|
|
32
|
+
symbologies = barcodeTypes.compactMap { type in
|
|
33
|
+
switch type {
|
|
34
|
+
case "aztec": return .aztec
|
|
35
|
+
case "codabar": return .codabar
|
|
36
|
+
case "code-128": return .code128
|
|
37
|
+
case "code-39": return .code39
|
|
38
|
+
case "code-93": return .code93
|
|
39
|
+
case "data-matrix": return .dataMatrix
|
|
40
|
+
case "ean-13": return .ean13
|
|
41
|
+
case "ean-8": return .ean8
|
|
42
|
+
case "itf": return .i2of5
|
|
43
|
+
case "pdf-417": return .pdf417
|
|
44
|
+
case "qr": return .qr
|
|
45
|
+
case "upc-a": return .ean13 // UPC-A is subset of EAN-13
|
|
46
|
+
case "upc-e": return .upce
|
|
47
|
+
default: return nil
|
|
54
48
|
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
55
51
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
// Use semaphore to make async Vision calls synchronous for frame processor
|
|
53
|
+
let semaphore = DispatchSemaphore(value: 0)
|
|
54
|
+
var detectedBarcodes: [VNBarcodeObservation] = []
|
|
55
|
+
var visionError: Error? = nil
|
|
60
56
|
|
|
61
|
-
|
|
57
|
+
// Create Vision request handler
|
|
58
|
+
let handler = VNImageRequestHandler(cvPixelBuffer: imageBuffer, options: [:])
|
|
62
59
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
} catch {
|
|
67
|
-
return []
|
|
68
|
-
}
|
|
60
|
+
// Create barcode detection request
|
|
61
|
+
let request = VNDetectBarcodesRequest { (request, error) in
|
|
62
|
+
defer { semaphore.signal() }
|
|
69
63
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// Add barcode type
|
|
77
|
-
let type: String
|
|
78
|
-
switch barcode.symbology {
|
|
79
|
-
case .aztec:
|
|
80
|
-
type = "aztec"
|
|
81
|
-
case .codabar:
|
|
82
|
-
type = "codabar"
|
|
83
|
-
case .code128:
|
|
84
|
-
type = "code-128"
|
|
85
|
-
case .code39:
|
|
86
|
-
type = "code-39"
|
|
87
|
-
case .code93:
|
|
88
|
-
type = "code-93"
|
|
89
|
-
case .dataMatrix:
|
|
90
|
-
type = "data-matrix"
|
|
91
|
-
case .ean13:
|
|
92
|
-
type = "ean-13"
|
|
93
|
-
case .ean8:
|
|
94
|
-
type = "ean-8"
|
|
95
|
-
case .i2of5, .i2of5Checksum, .itf14:
|
|
96
|
-
type = "itf"
|
|
97
|
-
case .pdf417:
|
|
98
|
-
type = "pdf-417"
|
|
99
|
-
case .qr:
|
|
100
|
-
type = "qr"
|
|
101
|
-
case .upce:
|
|
102
|
-
type = "upc-e"
|
|
103
|
-
default:
|
|
104
|
-
type = "unknown"
|
|
105
|
-
}
|
|
106
|
-
barcodeDict["type"] = type
|
|
107
|
-
|
|
108
|
-
// Convert bounding box to our format
|
|
109
|
-
let boundingBox = barcode.boundingBox
|
|
110
|
-
let imageSize = CGSize(width: CVPixelBufferGetWidth(imageBuffer), height: CVPixelBufferGetHeight(imageBuffer))
|
|
111
|
-
|
|
112
|
-
// Vision framework uses normalized coordinates (0-1), convert to pixel coordinates
|
|
113
|
-
let origin = CGPoint(
|
|
114
|
-
x: boundingBox.origin.x * imageSize.width,
|
|
115
|
-
y: (1 - boundingBox.origin.y - boundingBox.size.height) * imageSize.height // Flip Y coordinate
|
|
116
|
-
)
|
|
117
|
-
let size = CGSize(
|
|
118
|
-
width: boundingBox.size.width * imageSize.width,
|
|
119
|
-
height: boundingBox.size.height * imageSize.height
|
|
120
|
-
)
|
|
121
|
-
|
|
122
|
-
barcodeDict["boundingBox"] = [
|
|
123
|
-
"origin": [
|
|
124
|
-
"x": origin.x,
|
|
125
|
-
"y": origin.y
|
|
126
|
-
],
|
|
127
|
-
"size": [
|
|
128
|
-
"width": size.width,
|
|
129
|
-
"height": size.height
|
|
130
|
-
]
|
|
131
|
-
]
|
|
132
|
-
|
|
133
|
-
// Convert corner points to our format
|
|
134
|
-
let topLeft = CGPoint(
|
|
135
|
-
x: barcode.topLeft.x * imageSize.width,
|
|
136
|
-
y: (1 - barcode.topLeft.y) * imageSize.height
|
|
137
|
-
)
|
|
138
|
-
let topRight = CGPoint(
|
|
139
|
-
x: barcode.topRight.x * imageSize.width,
|
|
140
|
-
y: (1 - barcode.topRight.y) * imageSize.height
|
|
141
|
-
)
|
|
142
|
-
let bottomLeft = CGPoint(
|
|
143
|
-
x: barcode.bottomLeft.x * imageSize.width,
|
|
144
|
-
y: (1 - barcode.bottomLeft.y) * imageSize.height
|
|
145
|
-
)
|
|
146
|
-
let bottomRight = CGPoint(
|
|
147
|
-
x: barcode.bottomRight.x * imageSize.width,
|
|
148
|
-
y: (1 - barcode.bottomRight.y) * imageSize.height
|
|
149
|
-
)
|
|
150
|
-
|
|
151
|
-
barcodeDict["cornerPoints"] = [
|
|
152
|
-
["x": topLeft.x, "y": topLeft.y],
|
|
153
|
-
["x": topRight.x, "y": topRight.y],
|
|
154
|
-
["x": bottomRight.x, "y": bottomRight.y],
|
|
155
|
-
["x": bottomLeft.x, "y": bottomLeft.y]
|
|
156
|
-
]
|
|
157
|
-
|
|
158
|
-
// Add native data
|
|
159
|
-
var nativeDict: [String: Any] = [:]
|
|
160
|
-
|
|
161
|
-
if let descriptor = barcode.barcodeDescriptor {
|
|
162
|
-
nativeDict["descriptor"] = descriptor
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
barcodeDict["native"] = nativeDict
|
|
166
|
-
|
|
167
|
-
return barcodeDict
|
|
168
|
-
}
|
|
64
|
+
if let error = error {
|
|
65
|
+
print("BarcodeScannerFrameProcessorPlugin: Vision error: \(error.localizedDescription)")
|
|
66
|
+
visionError = error
|
|
67
|
+
return
|
|
68
|
+
}
|
|
169
69
|
|
|
170
|
-
|
|
70
|
+
detectedBarcodes = request.results as? [VNBarcodeObservation] ?? []
|
|
71
|
+
print("BarcodeScannerFrameProcessorPlugin: Detected \(detectedBarcodes.count) barcodes")
|
|
171
72
|
}
|
|
73
|
+
|
|
74
|
+
// Set symbologies
|
|
75
|
+
request.symbologies = symbologies
|
|
76
|
+
|
|
77
|
+
// Perform the request
|
|
78
|
+
do {
|
|
79
|
+
try handler.perform([request])
|
|
80
|
+
} catch {
|
|
81
|
+
print(
|
|
82
|
+
"BarcodeScannerFrameProcessorPlugin: Error performing Vision request: \(error.localizedDescription)"
|
|
83
|
+
)
|
|
84
|
+
return []
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Wait for completion with timeout
|
|
88
|
+
let waitResult = semaphore.wait(timeout: .now() + 0.1) // 100ms timeout
|
|
89
|
+
if waitResult == .timedOut {
|
|
90
|
+
print("BarcodeScannerFrameProcessorPlugin: Vision request timed out")
|
|
91
|
+
return []
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Check for errors
|
|
95
|
+
if let error = visionError {
|
|
96
|
+
print(
|
|
97
|
+
"BarcodeScannerFrameProcessorPlugin: Vision processing failed: \(error.localizedDescription)"
|
|
98
|
+
)
|
|
99
|
+
return []
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Convert results to pixel coordinates at iOS level
|
|
103
|
+
let result = detectedBarcodes.compactMap { barcode -> [String: Any]? in
|
|
104
|
+
guard let barcodeValue = barcode.payloadStringValue, !barcodeValue.isEmpty else {
|
|
105
|
+
return nil
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
print("BarcodeScannerFrameProcessorPlugin: Processing barcode: \(barcodeValue)")
|
|
109
|
+
|
|
110
|
+
var map: [String: Any] = [:]
|
|
111
|
+
|
|
112
|
+
// Main value that TypeScript interface expects
|
|
113
|
+
map["value"] = barcodeValue
|
|
114
|
+
|
|
115
|
+
// Convert from normalized (0-1) coordinates to pixel coordinates
|
|
116
|
+
let frameWidth = frame.width
|
|
117
|
+
let frameHeight = frame.height
|
|
118
|
+
let boundingBox = barcode.boundingBox
|
|
119
|
+
|
|
120
|
+
// Convert from normalized (0-1) with bottom-left origin to pixel coordinates with top-left origin
|
|
121
|
+
let left = boundingBox.origin.x * CGFloat(frameWidth)
|
|
122
|
+
let bottom = boundingBox.origin.y * CGFloat(frameHeight)
|
|
123
|
+
let width = boundingBox.size.width * CGFloat(frameWidth)
|
|
124
|
+
let height = boundingBox.size.height * CGFloat(frameHeight)
|
|
125
|
+
let top = CGFloat(frameHeight) - bottom - height // Flip Y coordinate from bottom-left to top-left
|
|
126
|
+
|
|
127
|
+
// Create bounding box in pixel coordinates with top-left origin
|
|
128
|
+
map["boundingBox"] = [
|
|
129
|
+
"origin": [
|
|
130
|
+
"x": Int(left),
|
|
131
|
+
"y": Int(top),
|
|
132
|
+
],
|
|
133
|
+
"size": [
|
|
134
|
+
"width": Int(width),
|
|
135
|
+
"height": Int(height),
|
|
136
|
+
],
|
|
137
|
+
]
|
|
138
|
+
|
|
139
|
+
// Convert corner points to pixel coordinates with top-left origin
|
|
140
|
+
let cornerPoints = [
|
|
141
|
+
[
|
|
142
|
+
"x": Int(barcode.topLeft.x * CGFloat(frameWidth)),
|
|
143
|
+
"y": Int((1.0 - barcode.topLeft.y) * CGFloat(frameHeight)),
|
|
144
|
+
],
|
|
145
|
+
[
|
|
146
|
+
"x": Int(barcode.topRight.x * CGFloat(frameWidth)),
|
|
147
|
+
"y": Int((1.0 - barcode.topRight.y) * CGFloat(frameHeight)),
|
|
148
|
+
],
|
|
149
|
+
[
|
|
150
|
+
"x": Int(barcode.bottomRight.x * CGFloat(frameWidth)),
|
|
151
|
+
"y": Int((1.0 - barcode.bottomRight.y) * CGFloat(frameHeight)),
|
|
152
|
+
],
|
|
153
|
+
[
|
|
154
|
+
"x": Int(barcode.bottomLeft.x * CGFloat(frameWidth)),
|
|
155
|
+
"y": Int((1.0 - barcode.bottomLeft.y) * CGFloat(frameHeight)),
|
|
156
|
+
],
|
|
157
|
+
]
|
|
158
|
+
map["cornerPoints"] = cornerPoints
|
|
159
|
+
|
|
160
|
+
// Map barcode symbology to TypeScript BarcodeType strings
|
|
161
|
+
let typeString: String
|
|
162
|
+
switch barcode.symbology {
|
|
163
|
+
case .aztec: typeString = "aztec"
|
|
164
|
+
case .codabar: typeString = "codabar"
|
|
165
|
+
case .code128: typeString = "code-128"
|
|
166
|
+
case .code39: typeString = "code-39"
|
|
167
|
+
case .code93: typeString = "code-93"
|
|
168
|
+
case .dataMatrix: typeString = "data-matrix"
|
|
169
|
+
case .ean13: typeString = "ean-13"
|
|
170
|
+
case .ean8: typeString = "ean-8"
|
|
171
|
+
case .i2of5, .i2of5Checksum, .itf14: typeString = "itf"
|
|
172
|
+
case .pdf417: typeString = "pdf-417"
|
|
173
|
+
case .qr: typeString = "qr"
|
|
174
|
+
case .upce: typeString = "upc-e"
|
|
175
|
+
default: typeString = "unknown"
|
|
176
|
+
}
|
|
177
|
+
map["type"] = typeString
|
|
178
|
+
|
|
179
|
+
print(
|
|
180
|
+
"BarcodeScannerFrameProcessorPlugin: Converted barcode - value: \(barcodeValue), type: \(typeString), boundingBox: \(map["boundingBox"] ?? "nil")"
|
|
181
|
+
)
|
|
182
|
+
return map
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
print("BarcodeScannerFrameProcessorPlugin: Returning \(result.count) processed barcodes")
|
|
186
|
+
return result
|
|
187
|
+
}
|
|
172
188
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import React, { useEffect } from 'react';
|
|
4
|
-
import { View, StyleSheet, ActivityIndicator, Text as TextView, Text, Linking } from 'react-native';
|
|
4
|
+
import { View, StyleSheet, ActivityIndicator, Text as TextView, Text, Linking, Platform } from 'react-native';
|
|
5
5
|
import { Camera, useCameraDevice, useCameraFormat, useCameraPermission, useFrameProcessor } from 'react-native-vision-camera';
|
|
6
6
|
import { useRunOnJS, useSharedValue } from 'react-native-worklets-core';
|
|
7
7
|
import { useKeepAwake } from "../Libs/native-keep-awake.utils.js";
|
|
@@ -71,8 +71,20 @@ const QrCodeScannerCamera = ({
|
|
|
71
71
|
return false;
|
|
72
72
|
};
|
|
73
73
|
const handleQrCode = useRunOnJS((code, width, height, orientation) => {
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
// TODO: Fix iOS coordinates - iOS coordinate system conversion may be incorrect
|
|
75
|
+
// causing frame checking to fail. Need to verify coordinate normalization
|
|
76
|
+
// between iOS Vision framework and React Native coordinate systems.
|
|
77
|
+
|
|
78
|
+
// On iOS, skip frame checking and scan any QR code found
|
|
79
|
+
if (Platform.OS === 'ios') {
|
|
80
|
+
if (code.value) {
|
|
81
|
+
onQrCodeScanned(code.value);
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
// On Android, continue with frame checking
|
|
85
|
+
if (isInScanningFrame(code, width, height, orientation) && code.value) {
|
|
86
|
+
onQrCodeScanned(code.value);
|
|
87
|
+
}
|
|
76
88
|
}
|
|
77
89
|
}, [onQrCodeScanned]);
|
|
78
90
|
const frameProcessor = useFrameProcessor(frame => {
|
|
@@ -13,8 +13,6 @@ export const scanCodes = defaultPlugin.scanCodes;
|
|
|
13
13
|
// Hooks
|
|
14
14
|
export { useBarcodeScanner } from "./hooks/useBarcodeScanner.js";
|
|
15
15
|
export { useCameraPermissions } from "./hooks/useCameraPermissions.js";
|
|
16
|
-
// Components
|
|
17
|
-
export { BarcodeCamera } from "./components/BarcodeCamera.js";
|
|
18
16
|
// Utilities
|
|
19
17
|
export { convertFrameToScreen, convertScreenToFrame, convertBarcodeToScreen, getRectCenter, getCornerPointsCenter, getBoundsFromCornerPoints } from "./utils/geometry.js";
|
|
20
18
|
export { boundingBoxToHighlight, barcodesToHighlights, getHighlightStyle, cornerPointsToPath, cornerPointsToPolygonPoints } from "./utils/highlights.js";
|
|
@@ -14,6 +14,8 @@ export function createBarcodeScannerPlugin() {
|
|
|
14
14
|
try {
|
|
15
15
|
// @ts-ignore
|
|
16
16
|
const result = plugin.call(frame, options);
|
|
17
|
+
|
|
18
|
+
// iOS now handles coordinate conversion, so return results directly
|
|
17
19
|
return result || [];
|
|
18
20
|
} catch (error) {
|
|
19
21
|
console.warn('scanCodes: Plugin call failed:', error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QrCodeScannerCamera.d.ts","sourceRoot":"","sources":["../../../../../src/Shared/Components/QrCodeScannerCamera.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"QrCodeScannerCamera.d.ts","sourceRoot":"","sources":["../../../../../src/Shared/Components/QrCodeScannerCamera.tsx"],"names":[],"mappings":"AA0BA,MAAM,WAAW,wBAAwB;IACvC,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED,QAAA,MAAM,mBAAmB,GAAI,qBAAqB,wBAAwB,4CA2MzE,CAAC;AAqFF,eAAe,mBAAmB,CAAC"}
|
|
@@ -5,8 +5,6 @@ export { useBarcodeScanner } from './hooks/useBarcodeScanner';
|
|
|
5
5
|
export { useCameraPermissions } from './hooks/useCameraPermissions';
|
|
6
6
|
export type { UseBarcodeScannerOptions, UseBarcodeScannerResult, } from './hooks/useBarcodeScanner';
|
|
7
7
|
export type { UseCameraPermissionResult } from './hooks/useCameraPermissions';
|
|
8
|
-
export { BarcodeCamera } from './components/BarcodeCamera';
|
|
9
|
-
export type { BarcodeCameraProps } from './components/BarcodeCamera';
|
|
10
8
|
export { convertFrameToScreen, convertScreenToFrame, convertBarcodeToScreen, getRectCenter, getCornerPointsCenter, getBoundsFromCornerPoints, } from './utils/geometry';
|
|
11
9
|
export type { FrameDimensions, ScreenDimensions } from './utils/geometry';
|
|
12
10
|
export { boundingBoxToHighlight, barcodesToHighlights, getHighlightStyle, cornerPointsToPath, cornerPointsToPolygonPoints, } from './utils/highlights';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/VisionCameraPlugins/BarcodeScanner/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAKzD,eAAO,MAAM,SAAS,qIAA0B,CAAC;AAGjD,YAAY,EACV,WAAW,EACX,OAAO,EACP,mBAAmB,EACnB,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,SAAS,EACT,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,YAAY,EACV,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAG9E,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/VisionCameraPlugins/BarcodeScanner/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAKzD,eAAO,MAAM,SAAS,qIAA0B,CAAC;AAGjD,YAAY,EACV,WAAW,EACX,OAAO,EACP,mBAAmB,EACnB,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,SAAS,EACT,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,YAAY,EACV,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAG9E,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,aAAa,EACb,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE1E,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,0BAA0B,EAC1B,yBAAyB,EACzB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanCodes.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAIjB,wBAAgB,0BAA0B,IAAI,oBAAoB,
|
|
1
|
+
{"version":3,"file":"scanCodes.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAIjB,wBAAgB,0BAA0B,IAAI,oBAAoB,CAsBjE"}
|
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
Text as TextView,
|
|
7
7
|
Text,
|
|
8
8
|
Linking,
|
|
9
|
+
Platform,
|
|
9
10
|
} from 'react-native';
|
|
10
11
|
import {
|
|
11
12
|
Camera,
|
|
@@ -105,8 +106,20 @@ const QrCodeScannerCamera = ({ onQrCodeScanned }: QrCodeScannerCameraProps) => {
|
|
|
105
106
|
height: number,
|
|
106
107
|
orientation: Orientation
|
|
107
108
|
) => {
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
// TODO: Fix iOS coordinates - iOS coordinate system conversion may be incorrect
|
|
110
|
+
// causing frame checking to fail. Need to verify coordinate normalization
|
|
111
|
+
// between iOS Vision framework and React Native coordinate systems.
|
|
112
|
+
|
|
113
|
+
// On iOS, skip frame checking and scan any QR code found
|
|
114
|
+
if (Platform.OS === 'ios') {
|
|
115
|
+
if (code.value) {
|
|
116
|
+
onQrCodeScanned(code.value);
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
// On Android, continue with frame checking
|
|
120
|
+
if (isInScanningFrame(code, width, height, orientation) && code.value) {
|
|
121
|
+
onQrCodeScanned(code.value);
|
|
122
|
+
}
|
|
110
123
|
}
|
|
111
124
|
},
|
|
112
125
|
[onQrCodeScanned]
|
|
@@ -31,10 +31,6 @@ export type {
|
|
|
31
31
|
} from './hooks/useBarcodeScanner';
|
|
32
32
|
export type { UseCameraPermissionResult } from './hooks/useCameraPermissions';
|
|
33
33
|
|
|
34
|
-
// Components
|
|
35
|
-
export { BarcodeCamera } from './components/BarcodeCamera';
|
|
36
|
-
export type { BarcodeCameraProps } from './components/BarcodeCamera';
|
|
37
|
-
|
|
38
34
|
// Utilities
|
|
39
35
|
export {
|
|
40
36
|
convertFrameToScreen,
|
|
@@ -20,6 +20,8 @@ export function createBarcodeScannerPlugin(): BarcodeScannerPlugin {
|
|
|
20
20
|
try {
|
|
21
21
|
// @ts-ignore
|
|
22
22
|
const result = plugin.call(frame, options) as Barcode[];
|
|
23
|
+
|
|
24
|
+
// iOS now handles coordinate conversion, so return results directly
|
|
23
25
|
return result || [];
|
|
24
26
|
} catch (error) {
|
|
25
27
|
console.warn('scanCodes: Plugin call failed:', error);
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React, { useCallback, useState } from 'react';
|
|
4
|
-
import { StyleSheet, View } from 'react-native';
|
|
5
|
-
import { Camera, useCameraDevices } from 'react-native-vision-camera';
|
|
6
|
-
import { useBarcodeScanner, useCameraPermissions } from "../index.js";
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
export const BarcodeCamera = ({
|
|
9
|
-
style,
|
|
10
|
-
isActive = true,
|
|
11
|
-
device = 'back',
|
|
12
|
-
enableZoomGesture = true,
|
|
13
|
-
onBarcodeScanned,
|
|
14
|
-
onError,
|
|
15
|
-
onInitialized,
|
|
16
|
-
...barcodeScannerOptions
|
|
17
|
-
}) => {
|
|
18
|
-
const devices = useCameraDevices();
|
|
19
|
-
const cameraDevice = devices.find(d => device === 'back' ? d.position === 'back' : d.position === 'front');
|
|
20
|
-
const {
|
|
21
|
-
hasPermission,
|
|
22
|
-
requestPermission
|
|
23
|
-
} = useCameraPermissions();
|
|
24
|
-
const [isCameraInitialized, setIsCameraInitialized] = useState(false);
|
|
25
|
-
const {
|
|
26
|
-
scanBarcodes
|
|
27
|
-
} = useBarcodeScanner({
|
|
28
|
-
...barcodeScannerOptions,
|
|
29
|
-
onBarcodeScanned,
|
|
30
|
-
onError
|
|
31
|
-
});
|
|
32
|
-
const handleCameraInitialized = useCallback(() => {
|
|
33
|
-
setIsCameraInitialized(true);
|
|
34
|
-
onInitialized?.();
|
|
35
|
-
}, [onInitialized]);
|
|
36
|
-
|
|
37
|
-
// Request permission if not granted
|
|
38
|
-
React.useEffect(() => {
|
|
39
|
-
if (!hasPermission) {
|
|
40
|
-
requestPermission();
|
|
41
|
-
}
|
|
42
|
-
}, [hasPermission, requestPermission]);
|
|
43
|
-
if (!hasPermission || !cameraDevice) {
|
|
44
|
-
return /*#__PURE__*/_jsx(View, {
|
|
45
|
-
style: [styles.container, style]
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
return /*#__PURE__*/_jsx(Camera, {
|
|
49
|
-
style: [styles.camera, style],
|
|
50
|
-
device: cameraDevice,
|
|
51
|
-
isActive: isActive && isCameraInitialized,
|
|
52
|
-
enableZoomGesture: enableZoomGesture,
|
|
53
|
-
onInitialized: handleCameraInitialized,
|
|
54
|
-
onError: onError
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
const styles = StyleSheet.create({
|
|
58
|
-
container: {
|
|
59
|
-
flex: 1,
|
|
60
|
-
backgroundColor: 'black'
|
|
61
|
-
},
|
|
62
|
-
camera: {
|
|
63
|
-
flex: 1
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
export default BarcodeCamera;
|
package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/components/BarcodeCamera.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type UseBarcodeScannerOptions } from '../index';
|
|
3
|
-
export interface BarcodeCameraProps extends UseBarcodeScannerOptions {
|
|
4
|
-
style?: any;
|
|
5
|
-
isActive?: boolean;
|
|
6
|
-
device?: 'back' | 'front';
|
|
7
|
-
enableZoomGesture?: boolean;
|
|
8
|
-
onInitialized?: () => void;
|
|
9
|
-
onError?: (error: Error) => void;
|
|
10
|
-
}
|
|
11
|
-
export declare const BarcodeCamera: React.FC<BarcodeCameraProps>;
|
|
12
|
-
export default BarcodeCamera;
|
|
13
|
-
//# sourceMappingURL=BarcodeCamera.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BarcodeCamera.d.ts","sourceRoot":"","sources":["../../../../../../../src/Shared/VisionCameraPlugins/BarcodeScanner/components/BarcodeCamera.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgC,MAAM,OAAO,CAAC;AAOrD,OAAO,EAIL,KAAK,wBAAwB,EAC9B,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,kBAAmB,SAAQ,wBAAwB;IAClE,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAiDtD,CAAC;AAYF,eAAe,aAAa,CAAC"}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useState } from 'react';
|
|
2
|
-
import { StyleSheet, View } from 'react-native';
|
|
3
|
-
import {
|
|
4
|
-
Camera,
|
|
5
|
-
useCameraDevices,
|
|
6
|
-
type Frame,
|
|
7
|
-
} from 'react-native-vision-camera';
|
|
8
|
-
import {
|
|
9
|
-
useBarcodeScanner,
|
|
10
|
-
useCameraPermissions,
|
|
11
|
-
type Barcode,
|
|
12
|
-
type UseBarcodeScannerOptions,
|
|
13
|
-
} from '../index';
|
|
14
|
-
|
|
15
|
-
export interface BarcodeCameraProps extends UseBarcodeScannerOptions {
|
|
16
|
-
style?: any;
|
|
17
|
-
isActive?: boolean;
|
|
18
|
-
device?: 'back' | 'front';
|
|
19
|
-
enableZoomGesture?: boolean;
|
|
20
|
-
onInitialized?: () => void;
|
|
21
|
-
onError?: (error: Error) => void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const BarcodeCamera: React.FC<BarcodeCameraProps> = ({
|
|
25
|
-
style,
|
|
26
|
-
isActive = true,
|
|
27
|
-
device = 'back',
|
|
28
|
-
enableZoomGesture = true,
|
|
29
|
-
onBarcodeScanned,
|
|
30
|
-
onError,
|
|
31
|
-
onInitialized,
|
|
32
|
-
...barcodeScannerOptions
|
|
33
|
-
}) => {
|
|
34
|
-
const devices = useCameraDevices();
|
|
35
|
-
const cameraDevice = devices.find((d) =>
|
|
36
|
-
device === 'back' ? d.position === 'back' : d.position === 'front'
|
|
37
|
-
);
|
|
38
|
-
const { hasPermission, requestPermission } = useCameraPermissions();
|
|
39
|
-
const [isCameraInitialized, setIsCameraInitialized] = useState(false);
|
|
40
|
-
|
|
41
|
-
const { scanBarcodes } = useBarcodeScanner({
|
|
42
|
-
...barcodeScannerOptions,
|
|
43
|
-
onBarcodeScanned,
|
|
44
|
-
onError,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const handleCameraInitialized = useCallback(() => {
|
|
48
|
-
setIsCameraInitialized(true);
|
|
49
|
-
onInitialized?.();
|
|
50
|
-
}, [onInitialized]);
|
|
51
|
-
|
|
52
|
-
// Request permission if not granted
|
|
53
|
-
React.useEffect(() => {
|
|
54
|
-
if (!hasPermission) {
|
|
55
|
-
requestPermission();
|
|
56
|
-
}
|
|
57
|
-
}, [hasPermission, requestPermission]);
|
|
58
|
-
|
|
59
|
-
if (!hasPermission || !cameraDevice) {
|
|
60
|
-
return <View style={[styles.container, style]} />;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<Camera
|
|
65
|
-
style={[styles.camera, style]}
|
|
66
|
-
device={cameraDevice}
|
|
67
|
-
isActive={isActive && isCameraInitialized}
|
|
68
|
-
enableZoomGesture={enableZoomGesture}
|
|
69
|
-
onInitialized={handleCameraInitialized}
|
|
70
|
-
onError={onError}
|
|
71
|
-
/>
|
|
72
|
-
);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const styles = StyleSheet.create({
|
|
76
|
-
container: {
|
|
77
|
-
flex: 1,
|
|
78
|
-
backgroundColor: 'black',
|
|
79
|
-
},
|
|
80
|
-
camera: {
|
|
81
|
-
flex: 1,
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
export default BarcodeCamera;
|