MentraOS / examples /bluetooth /react-native /modules /mentra-barcode-scanner /src /MentraBarcodeScannerModule.web.ts
Download examples/bluetooth/react-native/modules/mentra-barcode-scanner/src/MentraBarcodeScannerModule.web.ts from Anirudh1950/MentraOS: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/Anirudh1950/MentraOS/resolve/main/examples/bluetooth/react-native/modules/mentra-barcode-scanner/src/MentraBarcodeScannerModule.web.ts
- Command line
-
hf download hf://Anirudh1950/MentraOS/examples/bluetooth/react-native/modules/mentra-barcode-scanner/src/MentraBarcodeScannerModule.web.ts
-
curl -L -o MentraBarcodeScannerModule.web.ts https://huggingface.co/Anirudh1950/MentraOS/resolve/main/examples/bluetooth/react-native/modules/mentra-barcode-scanner/src/MentraBarcodeScannerModule.web.ts
1.22 kB
| import {NativeModule, registerWebModule} from 'expo'; | |
| import type {BarcodeScanResult, ImageMetadata, TestBarcodeImage} from './MentraBarcodeScanner.types'; | |
| class MentraBarcodeScannerModule extends NativeModule<{}> { | |
| async createTestBarcodeImage(_value: string): Promise<TestBarcodeImage> { | |
| throw new Error('The barcode scanner is only available in the native example app.'); | |
| } | |
| async getImageMetadata(imageUri: string): Promise<ImageMetadata> { | |
| return new Promise((resolve, reject) => { | |
| const image = new Image(); | |
| image.onload = () => resolve({width: image.naturalWidth, height: image.naturalHeight}); | |
| image.onerror = () => reject(new Error('Could not read image metadata.')); | |
| image.src = imageUri; | |
| }); | |
| } | |
| async isSupported(): Promise<boolean> { | |
| return false; | |
| } | |
| async openImage(imageUri: string): Promise<void> { | |
| window.open(imageUri, '_blank', 'noopener,noreferrer'); | |
| } | |
| async scanImage(_imageUri: string): Promise<BarcodeScanResult[]> { | |
| throw new Error('The barcode scanner is only available in the native example app.'); | |
| } | |
| } | |
| export default registerWebModule(MentraBarcodeScannerModule, 'MentraBarcodeScanner'); | |