2023-11-09 03:57:05 -07:00
|
|
|
import { Point } from './Point'
|
|
|
|
|
2023-10-04 04:53:52 -06:00
|
|
|
/**
|
|
|
|
* The type of the code to scan.
|
|
|
|
*/
|
|
|
|
export type CodeType =
|
|
|
|
| 'code-128'
|
|
|
|
| 'code-39'
|
|
|
|
| 'code-93'
|
|
|
|
| 'codabar'
|
|
|
|
| 'ean-13'
|
|
|
|
| 'ean-8'
|
|
|
|
| 'itf'
|
|
|
|
| 'upc-e'
|
|
|
|
| 'qr'
|
|
|
|
| 'pdf-417'
|
|
|
|
| 'aztec'
|
|
|
|
| 'data-matrix'
|
|
|
|
|
2023-11-09 03:57:05 -07:00
|
|
|
/**
|
|
|
|
* The full area that is used for code scanning. In most cases, this is 1280x720 or 1920x1080.
|
|
|
|
*/
|
|
|
|
export interface CodeScannerFrame {
|
|
|
|
/**
|
|
|
|
* The width of the frame
|
|
|
|
*/
|
|
|
|
width: number
|
|
|
|
/**
|
|
|
|
* The height of the frame
|
|
|
|
*/
|
|
|
|
height: number
|
|
|
|
}
|
|
|
|
|
2023-10-04 04:53:52 -06:00
|
|
|
/**
|
|
|
|
* A scanned code.
|
|
|
|
*/
|
|
|
|
export interface Code {
|
|
|
|
/**
|
|
|
|
* The type of the code that was scanned.
|
|
|
|
*/
|
|
|
|
type: CodeType | 'unknown'
|
|
|
|
/**
|
|
|
|
* The string value, or null if it cannot be decoded.
|
|
|
|
*/
|
|
|
|
value?: string
|
|
|
|
/**
|
|
|
|
* The location of the code relative to the Camera Preview (in dp).
|
|
|
|
*/
|
|
|
|
frame?: {
|
|
|
|
x: number
|
|
|
|
y: number
|
|
|
|
width: number
|
|
|
|
height: number
|
|
|
|
}
|
2023-11-09 03:57:05 -07:00
|
|
|
/**
|
|
|
|
* The location of each corner relative to the Camera Preview (in dp).
|
|
|
|
*/
|
|
|
|
corners?: Point[]
|
2023-10-04 04:53:52 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A scanner for detecting codes in a Camera Stream.
|
|
|
|
*/
|
|
|
|
export interface CodeScanner {
|
|
|
|
/**
|
|
|
|
* The types of codes to configure the code scanner for.
|
|
|
|
*/
|
|
|
|
codeTypes: CodeType[]
|
|
|
|
/**
|
|
|
|
* A callback to call whenever the scanned codes change.
|
2023-11-09 03:57:05 -07:00
|
|
|
* @param codes The scanned codes, or an empty array if none.
|
|
|
|
* @param frame The full area that is used for scanning. Code bounds and corners are relative to this frame.
|
2023-10-04 04:53:52 -06:00
|
|
|
*/
|
2023-11-09 03:57:05 -07:00
|
|
|
onCodeScanned: (codes: Code[], frame: CodeScannerFrame) => void
|
2023-10-04 04:53:52 -06:00
|
|
|
/**
|
|
|
|
* Crops the scanner's view area to the specific region of interest.
|
2024-01-13 11:35:30 -07:00
|
|
|
*
|
|
|
|
* @platform iOS
|
2023-10-04 04:53:52 -06:00
|
|
|
*/
|
|
|
|
regionOfInterest?: {
|
|
|
|
x: number
|
|
|
|
y: number
|
|
|
|
width: number
|
|
|
|
height: number
|
|
|
|
}
|
|
|
|
}
|