feat: add barcode reader

This commit is contained in:
2026-01-02 23:32:01 -03:00
parent 7c6045f1b3
commit 49b9389532
4 changed files with 327 additions and 0 deletions

22
src/app/types/globalThis.d.ts vendored Normal file
View File

@@ -0,0 +1,22 @@
type ImageBitmapSource = HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas | VideoFrame | Blob | ImageData
export type BarcodeDetectorOptions = {
formats: string[]
}
export type DetectedBarcode = {
boundingBox: DOMRectReadOnly;
cornerPoints: coords[];
format: string[];
rawValue: string;
}
declare global {
var BarcodeDetector: BarcodeDetector;
}
declare type BarcodeDetector = {
new (formats?: {formats: string[]}): BarcodeDetector;
static getSupportedFormats(): Promise<string[]>;
detect(imageBitmapSource: ImageBitmapSource): Promise<DetectedBarcode[]>;
}