Remove code scanning (#112)
* Remove Audio Device if it failed to configure * Add `audio-in-use-by-other-app` error * Try removing on interruption * Format code * Remove code scanning * Fix export
This commit is contained in:
@@ -5,7 +5,6 @@ import type { CameraDevice } from './CameraDevice';
|
||||
import type { ErrorWithCause } from './CameraError';
|
||||
import { CameraCaptureError, CameraRuntimeError, tryParseNativeCameraError, isErrorWithCause } from './CameraError';
|
||||
import type { CameraProps } from './CameraProps';
|
||||
import type { Code } from './Code';
|
||||
import type { PhotoFile, TakePhotoOptions } from './PhotoFile';
|
||||
import type { Point } from './Point';
|
||||
import type { TakeSnapshotOptions } from './Snapshot';
|
||||
@@ -20,14 +19,10 @@ interface OnErrorEvent {
|
||||
message: string;
|
||||
cause?: ErrorWithCause;
|
||||
}
|
||||
interface OnCodeScannedEvent {
|
||||
codes: Code[];
|
||||
}
|
||||
type NativeCameraViewProps = Omit<CameraProps, 'device' | 'onInitialized' | 'onError' | 'onCodeScanned'> & {
|
||||
cameraId: string;
|
||||
onInitialized?: (event: NativeSyntheticEvent<void>) => void;
|
||||
onError?: (event: NativeSyntheticEvent<OnErrorEvent>) => void;
|
||||
onCodeScanned?: (event: NativeSyntheticEvent<OnCodeScannedEvent>) => void;
|
||||
};
|
||||
type RefType = React.Component<NativeCameraViewProps> & Readonly<NativeMethods>;
|
||||
//#endregion
|
||||
@@ -94,7 +89,6 @@ export class Camera extends React.PureComponent<CameraProps, CameraState> {
|
||||
this.state = { cameraId: undefined };
|
||||
this.onInitialized = this.onInitialized.bind(this);
|
||||
this.onError = this.onError.bind(this);
|
||||
this.onCodeScanned = this.onCodeScanned.bind(this);
|
||||
this.ref = React.createRef<RefType>();
|
||||
}
|
||||
|
||||
@@ -375,14 +369,6 @@ export class Camera extends React.PureComponent<CameraProps, CameraState> {
|
||||
private onInitialized(): void {
|
||||
this.props.onInitialized?.();
|
||||
}
|
||||
|
||||
private onCodeScanned(event: NativeSyntheticEvent<OnCodeScannedEvent>): void {
|
||||
if (event == null) throw new Error('onCodeScanned() was invoked but event was null!');
|
||||
|
||||
if (this.props.onCodeScanned == null)
|
||||
console.warn('Camera: onCodeScanned event was invoked but no listeners attached! Did you forget to remove the `scannableCodes` property?');
|
||||
else this.props.onCodeScanned(event.nativeEvent.codes);
|
||||
}
|
||||
//#endregion
|
||||
|
||||
/**
|
||||
@@ -403,16 +389,7 @@ export class Camera extends React.PureComponent<CameraProps, CameraState> {
|
||||
|
||||
// We remove the big `device` object from the props because we only need to pass `cameraId` to native.
|
||||
const { device: _, ...props } = this.props;
|
||||
return (
|
||||
<NativeCameraView
|
||||
{...props}
|
||||
cameraId={this.state.cameraId}
|
||||
ref={this.ref}
|
||||
onInitialized={this.onInitialized}
|
||||
onError={this.onError}
|
||||
onCodeScanned={this.onCodeScanned}
|
||||
/>
|
||||
);
|
||||
return <NativeCameraView {...props} cameraId={this.state.cameraId} ref={this.ref} onInitialized={this.onInitialized} onError={this.onError} />;
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
|
@@ -2,7 +2,6 @@ import type { ViewProps } from 'react-native';
|
||||
import type { CameraDevice, CameraDeviceFormat, ColorSpace } from './CameraDevice';
|
||||
import type { CameraRuntimeError } from './CameraError';
|
||||
import type { CameraPreset } from './CameraPreset';
|
||||
import type { Code, CodeType } from './Code';
|
||||
|
||||
export interface CameraProps extends ViewProps {
|
||||
/**
|
||||
@@ -127,16 +126,5 @@ export interface CameraProps extends ViewProps {
|
||||
* Called when the camera was successfully initialized.
|
||||
*/
|
||||
onInitialized?: () => void;
|
||||
|
||||
// TODO: Remove once frameProcessors land
|
||||
/**
|
||||
* Specify the code types this camera can scan. Will be removed with the addition of Frame Processors.
|
||||
*/
|
||||
scannableCodes?: CodeType[];
|
||||
// TODO: Remove once frameProcessors land
|
||||
/**
|
||||
* Called when one or multiple codes have been scanned. Will be removed with the addition of Frame Processors.
|
||||
*/
|
||||
onCodeScanned?: (codes: Code[]) => void;
|
||||
//#endregion
|
||||
}
|
||||
|
65
src/Code.ts
65
src/Code.ts
@@ -1,65 +0,0 @@
|
||||
/**
|
||||
* Available code types
|
||||
*/
|
||||
export type CodeType =
|
||||
| 'cat-body'
|
||||
| 'dog-body'
|
||||
| 'human-body'
|
||||
| 'salient-object'
|
||||
| 'aztec'
|
||||
| 'code-128'
|
||||
| 'code-39'
|
||||
| 'code-39-mod-43'
|
||||
| 'code-93'
|
||||
| 'data-matrix'
|
||||
| 'ean-13'
|
||||
| 'ean-8'
|
||||
| 'face'
|
||||
| 'interleaved-2-of-5'
|
||||
| 'itf-14'
|
||||
| 'pdf-417'
|
||||
| 'qr'
|
||||
| 'upce';
|
||||
|
||||
/**
|
||||
* Represents a Metadata Code read by the Camera. Example: QR Code
|
||||
*/
|
||||
export interface Code {
|
||||
/**
|
||||
* The decoded string representation of the code.
|
||||
*/
|
||||
code?: string;
|
||||
/**
|
||||
* The type of the code.
|
||||
*/
|
||||
type: CodeType;
|
||||
/**
|
||||
* The position of the code relative to the camera's bounds
|
||||
*/
|
||||
bounds: {
|
||||
/**
|
||||
* Returns the smallest value for the x-coordinate of the rectangle.
|
||||
*/
|
||||
minX: number;
|
||||
/**
|
||||
* Returns the smallest value for the y-coordinate of the rectangle.
|
||||
*/
|
||||
minY: number;
|
||||
/**
|
||||
* Returns the largest value of the x-coordinate for the rectangle.
|
||||
*/
|
||||
maxX: number;
|
||||
/**
|
||||
* Returns the largest value of the y-coordinate for the rectangle.
|
||||
*/
|
||||
maxY: number;
|
||||
/**
|
||||
* Returns the width of a rectangle.
|
||||
*/
|
||||
width: number;
|
||||
/**
|
||||
* Returns the height of a rectangle.
|
||||
*/
|
||||
height: number;
|
||||
};
|
||||
}
|
@@ -5,7 +5,6 @@ export * from './CameraError';
|
||||
export * from './CameraPosition';
|
||||
export * from './CameraPreset';
|
||||
export * from './CameraProps';
|
||||
export * from './Code';
|
||||
export * from './PhotoFile';
|
||||
export * from './Point';
|
||||
export * from './Snapshot';
|
||||
|
Reference in New Issue
Block a user