Skip to content

Commit e5850d3

Browse files
committed
fix: add more checking for supported barcode detector detect function
1 parent 7fba42b commit e5850d3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/pluggableWidgets/barcode-scanner-web/src/helpers/barcode-detector-utils.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ const mapToNativeFormat = (format: string): string => {
2121

2222
// Check if BarcodeDetector API is available
2323
export const isBarcodeDetectorSupported = (): boolean => {
24-
return typeof globalThis !== "undefined" && "BarcodeDetector" in globalThis;
24+
return (
25+
typeof globalThis !== "undefined" &&
26+
"BarcodeDetector" in globalThis &&
27+
"detect" in (globalThis as any).BarcodeDetector &&
28+
typeof (globalThis as any).BarcodeDetector.detect === "function"
29+
);
2530
};
2631

2732
// Get supported formats for BarcodeDetector

0 commit comments

Comments
 (0)