@cleanuidev/react-native-scanner 1.0.0-beta.1
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/LICENSE +20 -0
- package/README.md +609 -0
- package/Scanner.podspec +20 -0
- package/android/build.gradle +90 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +8 -0
- package/android/src/main/java/com/scanner/CameraInfoModule.kt +253 -0
- package/android/src/main/java/com/scanner/ScannerPackage.kt +21 -0
- package/android/src/main/java/com/scanner/ScannerView.kt +783 -0
- package/android/src/main/java/com/scanner/ScannerViewManager.kt +181 -0
- package/android/src/main/java/com/scanner/utils/BarcodeFrameManager.kt +170 -0
- package/android/src/main/java/com/scanner/views/BarcodeFrameOverlayView.kt +43 -0
- package/android/src/main/java/com/scanner/views/FocusAreaView.kt +124 -0
- package/ios/BarcodeDetectionManager.swift +229 -0
- package/ios/BarcodeFrameManager.swift +175 -0
- package/ios/BarcodeFrameOverlayView.swift +102 -0
- package/ios/CameraManager.swift +396 -0
- package/ios/CoordinateTransformer.swift +140 -0
- package/ios/FocusAreaOverlayView.swift +161 -0
- package/ios/Models.swift +341 -0
- package/ios/Protocols.swift +194 -0
- package/ios/ScannerView.h +14 -0
- package/ios/ScannerView.mm +358 -0
- package/ios/ScannerViewImpl.swift +580 -0
- package/ios/react-native-scanner-Bridging-Header.h +26 -0
- package/lib/module/CameraInfoModule.js +8 -0
- package/lib/module/CameraInfoModule.js.map +1 -0
- package/lib/module/ScannerViewNativeComponent.ts +121 -0
- package/lib/module/hooks/useCameraInfo.js +106 -0
- package/lib/module/hooks/useCameraInfo.js.map +1 -0
- package/lib/module/index.js +13 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +47 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/CameraInfoModule.d.ts +8 -0
- package/lib/typescript/src/CameraInfoModule.d.ts.map +1 -0
- package/lib/typescript/src/ScannerViewNativeComponent.d.ts +91 -0
- package/lib/typescript/src/ScannerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useCameraInfo.d.ts +25 -0
- package/lib/typescript/src/hooks/useCameraInfo.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +8 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +145 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +178 -0
- package/src/CameraInfoModule.ts +11 -0
- package/src/ScannerViewNativeComponent.ts +121 -0
- package/src/hooks/useCameraInfo.ts +190 -0
- package/src/index.tsx +30 -0
- package/src/types.ts +177 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import {
|
|
2
|
+
codegenNativeComponent,
|
|
3
|
+
type ViewProps,
|
|
4
|
+
type NativeSyntheticEvent,
|
|
5
|
+
} from 'react-native';
|
|
6
|
+
import type {
|
|
7
|
+
DirectEventHandler,
|
|
8
|
+
Double,
|
|
9
|
+
} from 'react-native/Libraries/Types/CodegenTypesNamespace';
|
|
10
|
+
|
|
11
|
+
// Define codegen types locally (no longer exported from react-native in 0.83)
|
|
12
|
+
|
|
13
|
+
// Event payload types for better TypeScript inference
|
|
14
|
+
export interface BarcodeScannedEventPayload {
|
|
15
|
+
barcodes: {
|
|
16
|
+
data: string;
|
|
17
|
+
format: string;
|
|
18
|
+
timestamp: Double;
|
|
19
|
+
boundingBox?: {
|
|
20
|
+
left: Double;
|
|
21
|
+
top: Double;
|
|
22
|
+
right: Double;
|
|
23
|
+
bottom: Double;
|
|
24
|
+
};
|
|
25
|
+
area?: Double;
|
|
26
|
+
}[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ScannerErrorEventPayload {
|
|
30
|
+
error: string;
|
|
31
|
+
code: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface OnLoadEventPayload {
|
|
35
|
+
success: boolean;
|
|
36
|
+
error?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Event types for use in handlers
|
|
40
|
+
export type BarcodeScannedEvent =
|
|
41
|
+
NativeSyntheticEvent<BarcodeScannedEventPayload>;
|
|
42
|
+
export type ScannerErrorEvent = NativeSyntheticEvent<ScannerErrorEventPayload>;
|
|
43
|
+
export type OnLoadEvent = NativeSyntheticEvent<OnLoadEventPayload>;
|
|
44
|
+
|
|
45
|
+
// Nested object types for better codegen compatibility
|
|
46
|
+
export interface FocusAreaSize {
|
|
47
|
+
width: Double;
|
|
48
|
+
height: Double;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface FocusAreaPosition {
|
|
52
|
+
x: Double; // 0-100
|
|
53
|
+
y: Double; // 0-100
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface FocusAreaConfig {
|
|
57
|
+
enabled?: boolean;
|
|
58
|
+
showOverlay?: boolean;
|
|
59
|
+
borderColor?: string;
|
|
60
|
+
tintColor?: string;
|
|
61
|
+
// NOTE: Codegen does not support mixed types (number OR object), so we always pass {width,height}.
|
|
62
|
+
size?: FocusAreaSize;
|
|
63
|
+
position?: FocusAreaPosition;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface BarcodeFramesConfig {
|
|
67
|
+
enabled?: boolean;
|
|
68
|
+
color?: string;
|
|
69
|
+
onlyInFocusArea?: boolean;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface BoundingBox {
|
|
73
|
+
left: Double;
|
|
74
|
+
top: Double;
|
|
75
|
+
right: Double;
|
|
76
|
+
bottom: Double;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface BarcodeData {
|
|
80
|
+
data: string;
|
|
81
|
+
format: string;
|
|
82
|
+
timestamp: Double;
|
|
83
|
+
boundingBox?: BoundingBox;
|
|
84
|
+
area?: Double;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface NativeProps extends ViewProps {
|
|
88
|
+
barcodeTypes?: string[];
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Focus area configuration (Android: drives overlay + optional filtering).
|
|
92
|
+
* - `showOverlay` controls whether the scanning region is drawn.
|
|
93
|
+
* - `enabled` controls whether scanning is restricted to that region.
|
|
94
|
+
*/
|
|
95
|
+
focusArea?: FocusAreaConfig;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Barcode frames configuration (draw rectangles around detected barcodes).
|
|
99
|
+
*/
|
|
100
|
+
barcodeFrames?: BarcodeFramesConfig;
|
|
101
|
+
|
|
102
|
+
torch?: boolean;
|
|
103
|
+
zoom?: Double;
|
|
104
|
+
pauseScanning?: boolean;
|
|
105
|
+
|
|
106
|
+
barcodeScanStrategy?: string;
|
|
107
|
+
keepScreenOn?: boolean;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Minimum interval (in seconds) between barcode emission events.
|
|
111
|
+
* Prevents rapid duplicate detections. Set to 0 to disable debouncing.
|
|
112
|
+
* @default 0.5
|
|
113
|
+
*/
|
|
114
|
+
barcodeEmissionInterval?: Double;
|
|
115
|
+
|
|
116
|
+
onBarcodeScanned?: DirectEventHandler<BarcodeScannedEventPayload>;
|
|
117
|
+
onScannerError?: DirectEventHandler<ScannerErrorEventPayload>;
|
|
118
|
+
onLoad?: DirectEventHandler<OnLoadEventPayload>;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export default codegenNativeComponent<NativeProps>('ScannerView');
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect, useCallback, useMemo } from 'react';
|
|
4
|
+
import CameraInfoModule from "../CameraInfoModule.js";
|
|
5
|
+
export function useCameraInfo() {
|
|
6
|
+
const [deviceInfo, setDeviceInfo] = useState(null);
|
|
7
|
+
const [currentCameraInfo, setCurrentCameraInfo] = useState(null);
|
|
8
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
9
|
+
const [error, setError] = useState(null);
|
|
10
|
+
const loadCameraInfo = useCallback(async () => {
|
|
11
|
+
try {
|
|
12
|
+
setIsLoading(true);
|
|
13
|
+
setError(null);
|
|
14
|
+
const info = await CameraInfoModule.getCameraInfo();
|
|
15
|
+
setDeviceInfo(info);
|
|
16
|
+
|
|
17
|
+
// Try to get current camera info if available
|
|
18
|
+
try {
|
|
19
|
+
const currentInfo = await CameraInfoModule.getCurrentCameraInfo();
|
|
20
|
+
setCurrentCameraInfo(currentInfo);
|
|
21
|
+
} catch (e) {
|
|
22
|
+
// Current camera info might not be available if no camera is bound
|
|
23
|
+
console.log('Current camera info not available:', e);
|
|
24
|
+
}
|
|
25
|
+
} catch (e) {
|
|
26
|
+
let errorMessage = 'Failed to load camera information';
|
|
27
|
+
|
|
28
|
+
// Handle specific error types
|
|
29
|
+
if (e?.code === 'PERMISSION_ERROR') {
|
|
30
|
+
errorMessage = 'Camera permission not granted. Please grant camera permission in app settings.';
|
|
31
|
+
} else if (e?.code === 'NO_CAMERAS_ERROR') {
|
|
32
|
+
errorMessage = 'No cameras found on this device.';
|
|
33
|
+
} else if (e?.code === 'CAMERA_ACCESS_ERROR') {
|
|
34
|
+
errorMessage = 'Unable to access camera information. Please try again.';
|
|
35
|
+
} else if (e?.message) {
|
|
36
|
+
errorMessage = e.message;
|
|
37
|
+
}
|
|
38
|
+
setError(errorMessage);
|
|
39
|
+
console.error('Error loading camera info:', e);
|
|
40
|
+
} finally {
|
|
41
|
+
setIsLoading(false);
|
|
42
|
+
}
|
|
43
|
+
}, []);
|
|
44
|
+
const refreshInfo = useCallback(async () => {
|
|
45
|
+
await loadCameraInfo();
|
|
46
|
+
}, [loadCameraInfo]);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
loadCameraInfo();
|
|
49
|
+
}, [loadCameraInfo]);
|
|
50
|
+
// Computed properties
|
|
51
|
+
const allCameras = useMemo(() => deviceInfo?.cameras || [], [deviceInfo?.cameras]);
|
|
52
|
+
const backCameras = useMemo(() => allCameras.filter(camera => camera.facing === 'back'), [allCameras]);
|
|
53
|
+
const frontCameras = useMemo(() => allCameras.filter(camera => camera.facing === 'front'), [allCameras]);
|
|
54
|
+
const macroCameras = useMemo(() => allCameras.filter(camera => camera.isMacroCamera), [allCameras]);
|
|
55
|
+
const hasMultipleCameras = allCameras.length > 1;
|
|
56
|
+
const hasBackCamera = backCameras.length > 0;
|
|
57
|
+
const hasFrontCamera = frontCameras.length > 0;
|
|
58
|
+
const hasMacroCamera = macroCameras.length > 0;
|
|
59
|
+
const hasTorch = allCameras.some(camera => camera.hasFlash);
|
|
60
|
+
const defaultBackCamera = deviceInfo?.defaultBackCamera ? allCameras.find(camera => camera.id === deviceInfo.defaultBackCamera) || null : backCameras[0] || null;
|
|
61
|
+
const defaultFrontCamera = deviceInfo?.defaultFrontCamera ? allCameras.find(camera => camera.id === deviceInfo.defaultFrontCamera) || null : frontCameras[0] || null;
|
|
62
|
+
|
|
63
|
+
// Zoom range from all cameras
|
|
64
|
+
const allZoomRanges = allCameras.map(camera => ({
|
|
65
|
+
min: camera.zoomMin,
|
|
66
|
+
max: camera.zoomMax
|
|
67
|
+
}));
|
|
68
|
+
const maxZoom = Math.max(...allZoomRanges.map(range => range.max), 1);
|
|
69
|
+
const minZoom = Math.min(...allZoomRanges.map(range => range.min), 1);
|
|
70
|
+
const getCameraById = useCallback(id => {
|
|
71
|
+
return allCameras.find(camera => camera.id === id) || null;
|
|
72
|
+
}, [allCameras]);
|
|
73
|
+
const getCamerasByFacing = useCallback(facing => {
|
|
74
|
+
return allCameras.filter(camera => camera.facing === facing);
|
|
75
|
+
}, [allCameras]);
|
|
76
|
+
return {
|
|
77
|
+
// Device information
|
|
78
|
+
deviceInfo,
|
|
79
|
+
currentCameraInfo,
|
|
80
|
+
// Camera lists
|
|
81
|
+
allCameras,
|
|
82
|
+
backCameras,
|
|
83
|
+
frontCameras,
|
|
84
|
+
macroCameras,
|
|
85
|
+
// Quick access properties
|
|
86
|
+
hasMultipleCameras,
|
|
87
|
+
hasBackCamera,
|
|
88
|
+
hasFrontCamera,
|
|
89
|
+
hasMacroCamera,
|
|
90
|
+
hasTorch,
|
|
91
|
+
// Default cameras
|
|
92
|
+
defaultBackCamera,
|
|
93
|
+
defaultFrontCamera,
|
|
94
|
+
// Zoom information
|
|
95
|
+
maxZoom,
|
|
96
|
+
minZoom,
|
|
97
|
+
// Loading and error states
|
|
98
|
+
isLoading,
|
|
99
|
+
error,
|
|
100
|
+
// Actions
|
|
101
|
+
refreshInfo,
|
|
102
|
+
getCameraById,
|
|
103
|
+
getCamerasByFacing
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=useCameraInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useState","useEffect","useCallback","useMemo","CameraInfoModule","useCameraInfo","deviceInfo","setDeviceInfo","currentCameraInfo","setCurrentCameraInfo","isLoading","setIsLoading","error","setError","loadCameraInfo","info","getCameraInfo","currentInfo","getCurrentCameraInfo","e","console","log","errorMessage","code","message","refreshInfo","allCameras","cameras","backCameras","filter","camera","facing","frontCameras","macroCameras","isMacroCamera","hasMultipleCameras","length","hasBackCamera","hasFrontCamera","hasMacroCamera","hasTorch","some","hasFlash","defaultBackCamera","find","id","defaultFrontCamera","allZoomRanges","map","min","zoomMin","max","zoomMax","maxZoom","Math","range","minZoom","getCameraById","getCamerasByFacing"],"sourceRoot":"../../../src","sources":["hooks/useCameraInfo.ts"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,SAAS,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AACjE,OAAOC,gBAAgB,MAAM,wBAAqB;AA4ClD,OAAO,SAASC,aAAaA,CAAA,EAAwB;EACnD,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGP,QAAQ,CAA0B,IAAI,CAAC;EAC3E,MAAM,CAACQ,iBAAiB,EAAEC,oBAAoB,CAAC,GAC7CT,QAAQ,CAA2B,IAAI,CAAC;EAC1C,MAAM,CAACU,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IACbC,cAAc;IACdC,cAAc;IACdC,QAAQ;IAER;IACAG,iBAAiB;IACjBG,kBAAkB;IAElB;IACAO,OAAO;IACPG,OAAO;IAEP;IACA9C,SAAS;IACTE,KAAK;IAEL;IACAa,WAAW;IACXgC,aAAa;IACbC;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export { BarcodeFormat, BarcodeScanStrategy } from "./types.js";
|
|
4
|
+
// Export the camera info hook
|
|
5
|
+
export { useCameraInfo } from "./hooks/useCameraInfo.js";
|
|
6
|
+
// Re-export the native component and event types
|
|
7
|
+
|
|
8
|
+
export { default as ScannerView } from './ScannerViewNativeComponent';
|
|
9
|
+
export * from './ScannerViewNativeComponent';
|
|
10
|
+
|
|
11
|
+
// Export event types for better TypeScript inference
|
|
12
|
+
// These are the wrapped NativeSyntheticEvent types that users should use in their handlers
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["BarcodeFormat","BarcodeScanStrategy","useCameraInfo","default","ScannerView"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,mBAAmB,QAAQ,YAAS;AAc5D;AACA,SAASC,aAAa,QAAQ,0BAAuB;AAGrD;;AAEA,SAASC,OAAO,IAAIC,WAAW,QAAQ,8BAA8B;AACrE,cAAc,8BAA8B;;AAE5C;AACA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Barcode format enum
|
|
4
|
+
export let BarcodeFormat = /*#__PURE__*/function (BarcodeFormat) {
|
|
5
|
+
BarcodeFormat["QR_CODE"] = "QR_CODE";
|
|
6
|
+
BarcodeFormat["CODE_128"] = "CODE_128";
|
|
7
|
+
BarcodeFormat["CODE_39"] = "CODE_39";
|
|
8
|
+
BarcodeFormat["EAN_13"] = "EAN_13";
|
|
9
|
+
BarcodeFormat["EAN_8"] = "EAN_8";
|
|
10
|
+
BarcodeFormat["UPC_A"] = "UPC_A";
|
|
11
|
+
BarcodeFormat["UPC_E"] = "UPC_E";
|
|
12
|
+
BarcodeFormat["DATA_MATRIX"] = "DATA_MATRIX";
|
|
13
|
+
BarcodeFormat["PDF_417"] = "PDF_417";
|
|
14
|
+
BarcodeFormat["AZTEC"] = "AZTEC";
|
|
15
|
+
BarcodeFormat["ITF"] = "ITF";
|
|
16
|
+
return BarcodeFormat;
|
|
17
|
+
}({});
|
|
18
|
+
|
|
19
|
+
// Barcode scan strategy enum
|
|
20
|
+
export let BarcodeScanStrategy = /*#__PURE__*/function (BarcodeScanStrategy) {
|
|
21
|
+
BarcodeScanStrategy["ONE"] = "ONE";
|
|
22
|
+
BarcodeScanStrategy["ALL"] = "ALL";
|
|
23
|
+
BarcodeScanStrategy["BIGGEST"] = "BIGGEST";
|
|
24
|
+
BarcodeScanStrategy["SORT_BY_BIGGEST"] = "SORT_BY_BIGGEST";
|
|
25
|
+
return BarcodeScanStrategy;
|
|
26
|
+
}({});
|
|
27
|
+
|
|
28
|
+
// Frame size configuration - can be a number (square) or object (rectangle)
|
|
29
|
+
|
|
30
|
+
// Focus area configuration
|
|
31
|
+
|
|
32
|
+
// Barcode frame configuration
|
|
33
|
+
|
|
34
|
+
// Camera information types
|
|
35
|
+
|
|
36
|
+
// Barcode scanned event payload
|
|
37
|
+
|
|
38
|
+
// Scanner error event payload
|
|
39
|
+
|
|
40
|
+
// On load event payload (for camera initialization)
|
|
41
|
+
|
|
42
|
+
// Event types
|
|
43
|
+
|
|
44
|
+
// Props interface for the scanner view
|
|
45
|
+
|
|
46
|
+
// Method invokers for controlling the scanner
|
|
47
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["BarcodeFormat","BarcodeScanStrategy"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;AAEA;AACA,WAAYA,aAAa,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;;AAczB;AACA,WAAYC,mBAAmB,0BAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAA,OAAnBA,mBAAmB;AAAA;;AAO/B;;AAGA;;AAqCA;;AAOA;;AAqCA;;AAcA;;AAMA;;AAMA;;AAOA;;AA4BA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DeviceCameraInfo, CurrentCameraInfo } from './types';
|
|
2
|
+
export interface CameraInfoModuleInterface {
|
|
3
|
+
getCameraInfo(): Promise<DeviceCameraInfo>;
|
|
4
|
+
getCurrentCameraInfo(): Promise<CurrentCameraInfo>;
|
|
5
|
+
}
|
|
6
|
+
declare const _default: CameraInfoModuleInterface;
|
|
7
|
+
export default _default;
|
|
8
|
+
//# sourceMappingURL=CameraInfoModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CameraInfoModule.d.ts","sourceRoot":"","sources":["../../../src/CameraInfoModule.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAInE,MAAM,WAAW,yBAAyB;IACxC,aAAa,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC3C,oBAAoB,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACpD;wBAEkC,yBAAyB;AAA5D,wBAA6D"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type ViewProps, type NativeSyntheticEvent } from 'react-native';
|
|
2
|
+
import type { DirectEventHandler, Double } from 'react-native/Libraries/Types/CodegenTypesNamespace';
|
|
3
|
+
export interface BarcodeScannedEventPayload {
|
|
4
|
+
barcodes: {
|
|
5
|
+
data: string;
|
|
6
|
+
format: string;
|
|
7
|
+
timestamp: Double;
|
|
8
|
+
boundingBox?: {
|
|
9
|
+
left: Double;
|
|
10
|
+
top: Double;
|
|
11
|
+
right: Double;
|
|
12
|
+
bottom: Double;
|
|
13
|
+
};
|
|
14
|
+
area?: Double;
|
|
15
|
+
}[];
|
|
16
|
+
}
|
|
17
|
+
export interface ScannerErrorEventPayload {
|
|
18
|
+
error: string;
|
|
19
|
+
code: string;
|
|
20
|
+
}
|
|
21
|
+
export interface OnLoadEventPayload {
|
|
22
|
+
success: boolean;
|
|
23
|
+
error?: string;
|
|
24
|
+
}
|
|
25
|
+
export type BarcodeScannedEvent = NativeSyntheticEvent<BarcodeScannedEventPayload>;
|
|
26
|
+
export type ScannerErrorEvent = NativeSyntheticEvent<ScannerErrorEventPayload>;
|
|
27
|
+
export type OnLoadEvent = NativeSyntheticEvent<OnLoadEventPayload>;
|
|
28
|
+
export interface FocusAreaSize {
|
|
29
|
+
width: Double;
|
|
30
|
+
height: Double;
|
|
31
|
+
}
|
|
32
|
+
export interface FocusAreaPosition {
|
|
33
|
+
x: Double;
|
|
34
|
+
y: Double;
|
|
35
|
+
}
|
|
36
|
+
export interface FocusAreaConfig {
|
|
37
|
+
enabled?: boolean;
|
|
38
|
+
showOverlay?: boolean;
|
|
39
|
+
borderColor?: string;
|
|
40
|
+
tintColor?: string;
|
|
41
|
+
size?: FocusAreaSize;
|
|
42
|
+
position?: FocusAreaPosition;
|
|
43
|
+
}
|
|
44
|
+
export interface BarcodeFramesConfig {
|
|
45
|
+
enabled?: boolean;
|
|
46
|
+
color?: string;
|
|
47
|
+
onlyInFocusArea?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface BoundingBox {
|
|
50
|
+
left: Double;
|
|
51
|
+
top: Double;
|
|
52
|
+
right: Double;
|
|
53
|
+
bottom: Double;
|
|
54
|
+
}
|
|
55
|
+
export interface BarcodeData {
|
|
56
|
+
data: string;
|
|
57
|
+
format: string;
|
|
58
|
+
timestamp: Double;
|
|
59
|
+
boundingBox?: BoundingBox;
|
|
60
|
+
area?: Double;
|
|
61
|
+
}
|
|
62
|
+
export interface NativeProps extends ViewProps {
|
|
63
|
+
barcodeTypes?: string[];
|
|
64
|
+
/**
|
|
65
|
+
* Focus area configuration (Android: drives overlay + optional filtering).
|
|
66
|
+
* - `showOverlay` controls whether the scanning region is drawn.
|
|
67
|
+
* - `enabled` controls whether scanning is restricted to that region.
|
|
68
|
+
*/
|
|
69
|
+
focusArea?: FocusAreaConfig;
|
|
70
|
+
/**
|
|
71
|
+
* Barcode frames configuration (draw rectangles around detected barcodes).
|
|
72
|
+
*/
|
|
73
|
+
barcodeFrames?: BarcodeFramesConfig;
|
|
74
|
+
torch?: boolean;
|
|
75
|
+
zoom?: Double;
|
|
76
|
+
pauseScanning?: boolean;
|
|
77
|
+
barcodeScanStrategy?: string;
|
|
78
|
+
keepScreenOn?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Minimum interval (in seconds) between barcode emission events.
|
|
81
|
+
* Prevents rapid duplicate detections. Set to 0 to disable debouncing.
|
|
82
|
+
* @default 0.5
|
|
83
|
+
*/
|
|
84
|
+
barcodeEmissionInterval?: Double;
|
|
85
|
+
onBarcodeScanned?: DirectEventHandler<BarcodeScannedEventPayload>;
|
|
86
|
+
onScannerError?: DirectEventHandler<ScannerErrorEventPayload>;
|
|
87
|
+
onLoad?: DirectEventHandler<OnLoadEventPayload>;
|
|
88
|
+
}
|
|
89
|
+
declare const _default: import("react-native/types_generated/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeProps>;
|
|
90
|
+
export default _default;
|
|
91
|
+
//# sourceMappingURL=ScannerViewNativeComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScannerViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/ScannerViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,oBAAoB,EAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACV,kBAAkB,EAClB,MAAM,EACP,MAAM,oDAAoD,CAAC;AAK5D,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE;YACZ,IAAI,EAAE,MAAM,CAAC;YACb,GAAG,EAAE,MAAM,CAAC;YACZ,KAAK,EAAE,MAAM,CAAC;YACd,MAAM,EAAE,MAAM,CAAC;SAChB,CAAC;QACF,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;CACL;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAGD,MAAM,MAAM,mBAAmB,GAC7B,oBAAoB,CAAC,0BAA0B,CAAC,CAAC;AACnD,MAAM,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,wBAAwB,CAAC,CAAC;AAC/E,MAAM,MAAM,WAAW,GAAG,oBAAoB,CAAC,kBAAkB,CAAC,CAAC;AAGnE,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,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,CAAC,kBAAkB,CAAC,CAAC;CACjD;;AAED,wBAAkE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DeviceCameraInfo, CurrentCameraInfo, CameraInfo, CameraFacing } from '../types';
|
|
2
|
+
export interface UseCameraInfoReturn {
|
|
3
|
+
deviceInfo: DeviceCameraInfo | null;
|
|
4
|
+
currentCameraInfo: CurrentCameraInfo | null;
|
|
5
|
+
allCameras: CameraInfo[];
|
|
6
|
+
backCameras: CameraInfo[];
|
|
7
|
+
frontCameras: CameraInfo[];
|
|
8
|
+
macroCameras: CameraInfo[];
|
|
9
|
+
hasMultipleCameras: boolean;
|
|
10
|
+
hasBackCamera: boolean;
|
|
11
|
+
hasFrontCamera: boolean;
|
|
12
|
+
hasMacroCamera: boolean;
|
|
13
|
+
hasTorch: boolean;
|
|
14
|
+
defaultBackCamera: CameraInfo | null;
|
|
15
|
+
defaultFrontCamera: CameraInfo | null;
|
|
16
|
+
maxZoom: number;
|
|
17
|
+
minZoom: number;
|
|
18
|
+
isLoading: boolean;
|
|
19
|
+
error: string | null;
|
|
20
|
+
refreshInfo: () => Promise<void>;
|
|
21
|
+
getCameraById: (id: string) => CameraInfo | null;
|
|
22
|
+
getCamerasByFacing: (facing: CameraFacing) => CameraInfo[];
|
|
23
|
+
}
|
|
24
|
+
export declare function useCameraInfo(): UseCameraInfoReturn;
|
|
25
|
+
//# sourceMappingURL=useCameraInfo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCameraInfo.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useCameraInfo.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,YAAY,EACb,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,mBAAmB;IAElC,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACpC,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAG5C,UAAU,EAAE,UAAU,EAAE,CAAC;IACzB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,YAAY,EAAE,UAAU,EAAE,CAAC;IAC3B,YAAY,EAAE,UAAU,EAAE,CAAC;IAG3B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,aAAa,EAAE,OAAO,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;IAGlB,iBAAiB,EAAE,UAAU,GAAG,IAAI,CAAC;IACrC,kBAAkB,EAAE,UAAU,GAAG,IAAI,CAAC;IAGtC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAGhB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAGrB,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,UAAU,GAAG,IAAI,CAAC;IACjD,kBAAkB,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,UAAU,EAAE,CAAC;CAC5D;AAED,wBAAgB,aAAa,IAAI,mBAAmB,CAgJnD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { BarcodeFormat, BarcodeScanStrategy } from './types';
|
|
2
|
+
export type { FrameSize, FocusAreaConfig, BarcodeFramesConfig, BarcodeScannedEventPayload, ScannerErrorEventPayload, OnLoadEventPayload, DeviceCameraInfo, CurrentCameraInfo, CameraInfo, CameraFacing, } from './types';
|
|
3
|
+
export { useCameraInfo } from './hooks/useCameraInfo';
|
|
4
|
+
export type { UseCameraInfoReturn } from './hooks/useCameraInfo';
|
|
5
|
+
export { default as ScannerView } from './ScannerViewNativeComponent';
|
|
6
|
+
export * from './ScannerViewNativeComponent';
|
|
7
|
+
export type { BarcodeScannedEvent, ScannerErrorEvent, OnLoadEvent, } from './ScannerViewNativeComponent';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC7D,YAAY,EACV,SAAS,EACT,eAAe,EACf,mBAAmB,EACnB,0BAA0B,EAC1B,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,YAAY,GACb,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAIjE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACtE,cAAc,8BAA8B,CAAC;AAI7C,YAAY,EACV,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,GACZ,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
export declare enum BarcodeFormat {
|
|
3
|
+
QR_CODE = "QR_CODE",
|
|
4
|
+
CODE_128 = "CODE_128",
|
|
5
|
+
CODE_39 = "CODE_39",
|
|
6
|
+
EAN_13 = "EAN_13",
|
|
7
|
+
EAN_8 = "EAN_8",
|
|
8
|
+
UPC_A = "UPC_A",
|
|
9
|
+
UPC_E = "UPC_E",
|
|
10
|
+
DATA_MATRIX = "DATA_MATRIX",
|
|
11
|
+
PDF_417 = "PDF_417",
|
|
12
|
+
AZTEC = "AZTEC",
|
|
13
|
+
ITF = "ITF"
|
|
14
|
+
}
|
|
15
|
+
export declare enum BarcodeScanStrategy {
|
|
16
|
+
ONE = "ONE",
|
|
17
|
+
ALL = "ALL",
|
|
18
|
+
BIGGEST = "BIGGEST",
|
|
19
|
+
SORT_BY_BIGGEST = "SORT_BY_BIGGEST"
|
|
20
|
+
}
|
|
21
|
+
export type FrameSize = number | {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
};
|
|
25
|
+
export type FocusAreaConfig = {
|
|
26
|
+
/**
|
|
27
|
+
* Whether to restrict scanning to focus area only
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
enabled?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Size of the focus area
|
|
33
|
+
* @default 300
|
|
34
|
+
*/
|
|
35
|
+
size?: FrameSize;
|
|
36
|
+
/**
|
|
37
|
+
* Color of the focus area border
|
|
38
|
+
* @default transparent (no border) when not provided
|
|
39
|
+
*/
|
|
40
|
+
borderColor?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Color of the semi-transparent overlay (tint) around the focus area
|
|
43
|
+
* @default '#000000' with 50% opacity when not provided
|
|
44
|
+
*/
|
|
45
|
+
tintColor?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Whether to draw the focus area overlay
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
showOverlay?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Position of the focus area (percentage from 0-100)
|
|
53
|
+
* @default center (50, 50) when not provided
|
|
54
|
+
*/
|
|
55
|
+
position?: {
|
|
56
|
+
x: number;
|
|
57
|
+
y: number;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export type BarcodeFramesConfig = {
|
|
61
|
+
enabled?: boolean;
|
|
62
|
+
color?: string;
|
|
63
|
+
onlyInFocusArea?: boolean;
|
|
64
|
+
};
|
|
65
|
+
export type CameraFacing = 'front' | 'back' | 'unknown';
|
|
66
|
+
export type ZoomRange = {
|
|
67
|
+
min: number;
|
|
68
|
+
max: number;
|
|
69
|
+
};
|
|
70
|
+
export type CameraInfo = {
|
|
71
|
+
id: string;
|
|
72
|
+
facing: CameraFacing;
|
|
73
|
+
sensorOrientation: number;
|
|
74
|
+
minFocusDistance: number;
|
|
75
|
+
hasFlash: boolean;
|
|
76
|
+
isMacroCamera: boolean;
|
|
77
|
+
zoomMin: number;
|
|
78
|
+
zoomMax: number;
|
|
79
|
+
focalLengths: string[];
|
|
80
|
+
aeModes: string[];
|
|
81
|
+
afModes: string[];
|
|
82
|
+
};
|
|
83
|
+
export type DeviceCameraInfo = {
|
|
84
|
+
cameras: CameraInfo[];
|
|
85
|
+
defaultBackCamera: string;
|
|
86
|
+
defaultFrontCamera: string;
|
|
87
|
+
};
|
|
88
|
+
export type CurrentCameraInfo = {
|
|
89
|
+
status: string;
|
|
90
|
+
message: string;
|
|
91
|
+
currentZoom?: number;
|
|
92
|
+
isTorchEnabled?: boolean;
|
|
93
|
+
focusMode?: string;
|
|
94
|
+
};
|
|
95
|
+
export type BarcodeScannedEventPayload = {
|
|
96
|
+
data: string;
|
|
97
|
+
format: BarcodeFormat;
|
|
98
|
+
timestamp: number;
|
|
99
|
+
boundingBox?: {
|
|
100
|
+
left: number;
|
|
101
|
+
top: number;
|
|
102
|
+
right: number;
|
|
103
|
+
bottom: number;
|
|
104
|
+
};
|
|
105
|
+
area?: number;
|
|
106
|
+
};
|
|
107
|
+
export type ScannerErrorEventPayload = {
|
|
108
|
+
error: string;
|
|
109
|
+
code: string;
|
|
110
|
+
};
|
|
111
|
+
export type OnLoadEventPayload = {
|
|
112
|
+
success: boolean;
|
|
113
|
+
error?: string;
|
|
114
|
+
};
|
|
115
|
+
export type CameraNativeModuleEvents = {
|
|
116
|
+
onBarcodeScanned: (params: BarcodeScannedEventPayload) => void;
|
|
117
|
+
onScannerError: (params: ScannerErrorEventPayload) => void;
|
|
118
|
+
onLoad: (params: OnLoadEventPayload) => void;
|
|
119
|
+
};
|
|
120
|
+
export type CameraNativeModuleViewProps = {
|
|
121
|
+
barcodeTypes?: BarcodeFormat[];
|
|
122
|
+
focusArea?: FocusAreaConfig;
|
|
123
|
+
barcodeFrames?: BarcodeFramesConfig;
|
|
124
|
+
torch?: boolean;
|
|
125
|
+
zoom?: number;
|
|
126
|
+
pauseScanning?: boolean;
|
|
127
|
+
keepScreenOn?: boolean;
|
|
128
|
+
onBarcodeScanned?: (event: {
|
|
129
|
+
nativeEvent: BarcodeScannedEventPayload;
|
|
130
|
+
}) => void;
|
|
131
|
+
onScannerError?: (event: {
|
|
132
|
+
nativeEvent: ScannerErrorEventPayload;
|
|
133
|
+
}) => void;
|
|
134
|
+
onLoad?: (event: {
|
|
135
|
+
nativeEvent: OnLoadEventPayload;
|
|
136
|
+
}) => void;
|
|
137
|
+
style?: StyleProp<ViewStyle>;
|
|
138
|
+
};
|
|
139
|
+
export type CameraNativeModuleMethods = {
|
|
140
|
+
toggleTorch: () => Promise<boolean>;
|
|
141
|
+
startScanning: () => Promise<void>;
|
|
142
|
+
stopScanning: () => Promise<void>;
|
|
143
|
+
isTorchAvailable: () => Promise<boolean>;
|
|
144
|
+
};
|
|
145
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzD,oBAAY,aAAa;IACvB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,KAAK,UAAU;IACf,WAAW,gBAAgB;IAC3B,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,GAAG,QAAQ;CACZ;AAGD,oBAAY,mBAAmB;IAC7B,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,OAAO,YAAY;IACnB,eAAe,oBAAoB;CACpC;AAGD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAGnE,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,OAAO,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