Start of Web App (#689)

This commit is contained in:
Aaron DeRuvo
2025-07-11 14:07:40 +02:00
committed by GitHub
parent 19f167297a
commit 252f1ba1ef
56 changed files with 4424 additions and 551 deletions

View File

@@ -0,0 +1,65 @@
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11
import React, { useCallback } from 'react';
import { extractMRZInfo } from '../../utils/utils';
// TODO: Web find a lightweight ocr or mrz scanner.
export interface PassportCameraProps {
isMounted: boolean;
onPassportRead: (
error: Error | null,
mrzData?: ReturnType<typeof extractMRZInfo>,
) => void;
}
export const PassportCamera: React.FC<PassportCameraProps> = ({
onPassportRead,
isMounted,
}) => {
const handleError = useCallback(() => {
if (!isMounted) {
return;
}
const error = new Error('Passport camera not implemented for web yet');
onPassportRead(error);
}, [onPassportRead, isMounted]);
// Web stub - no functionality yet
React.useEffect(() => {
// Simulate that the component is not ready for web
if (isMounted) {
console.warn('PassportCamera: Web implementation not yet available');
// Optionally trigger an error after a short delay to indicate not implemented
const timer = setTimeout(() => {
handleError();
}, 100);
return () => clearTimeout(timer);
}
}, [isMounted, handleError]);
return (
<div
style={{
width: '100%',
height: '100%',
backgroundColor: '#000',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
color: '#fff',
fontSize: '16px',
textAlign: 'center',
padding: '20px',
}}
>
<div>
<div style={{ marginBottom: '16px' }}>📷 Passport Camera</div>
<div style={{ fontSize: '14px', opacity: 0.7 }}>
Web implementation coming soon
</div>
</div>
</div>
);
};

View File

@@ -0,0 +1,40 @@
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11
import React from 'react';
import BarcodeScanner, { BarcodeFormat } from 'react-qr-barcode-scanner';
export interface QRCodeScannerViewProps {
isMounted: boolean;
onQRData: (error: Error | null, uri?: string) => void;
}
export function QRCodeScannerView({
onQRData,
isMounted,
}: QRCodeScannerViewProps) {
if (!isMounted) {
return null;
}
return (
<BarcodeScanner
width={500}
height={500}
formats={[BarcodeFormat.QR_CODE]}
delay={300}
onUpdate={(err, result) => {
if (result) {
const url = result.getText();
console.log('SELF URL', url);
onQRData(null, url);
} else if (err && err instanceof Error) {
// it will give NotFoundException2 every frame until a QR code is found so we ignore it because thats just noisy
if (err.name !== 'NotFoundException2') {
onQRData(err);
}
}
}}
/>
);
}
export default QRCodeScannerView;