Last active
August 7, 2021 12:53
-
-
Save srflp/84219f09c009572442c6859016f4d98d to your computer and use it in GitHub Desktop.
Barcode Detector API Types, not yet implemented in libdom.d.ts in TypeScript, because the browser support is two low. Docs: https://developer.mozilla.org/en-US/docs/Web/API/Barcode_Detection_API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Barcode Detector API Types | |
// remove these types after they get implemented in TypeScript | |
type BarcodeFormat = | |
| 'aztec' | |
| 'code_128' | |
| 'code_39' | |
| 'code_93' | |
| 'codabar' | |
| 'data_matrix' | |
| 'ean_13' | |
| 'ean_8' | |
| 'itf' | |
| 'pdf417' | |
| 'qr_code' | |
| 'upc_a' | |
| 'upc_e' | |
| 'unknown'; | |
interface CornerPoint { | |
x: number; | |
y: number; | |
} | |
interface DetectedBarcode { | |
boundingBox: DOMRectReadOnly; | |
cornerPoints: [CornerPoint, CornerPoint, CornerPoint, CornerPoint]; | |
format: BarcodeFormat; | |
rawValue: string; | |
} | |
interface BarcodeDetector { | |
detect(image: ImageBitmapSource): Promise<DetectedBarcode[]>; | |
getSupportedFormats(): Promise<BarcodeFormat[]>; | |
} | |
interface BarcodeDetectorOptions { | |
formats: BarcodeFormat[]; | |
} | |
declare global { | |
var BarcodeDetector: { | |
prototype: BarcodeDetector; | |
new (barcodeDetectorOptions?: BarcodeDetectorOptions): BarcodeDetector; | |
}; | |
} | |
export {}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment