@codeuctivity/qr-scanner 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,140 @@
1
+ declare class QrScanner {
2
+ static readonly DEFAULT_CANVAS_SIZE = 400;
3
+ static readonly NO_QR_CODE_FOUND = "No QR code found";
4
+ private static _disableBarcodeDetector;
5
+ private static _workerMessageId;
6
+ /** @deprecated */
7
+ static set WORKER_PATH(workerPath: string);
8
+ static hasCamera(): Promise<boolean>;
9
+ static listCameras(requestLabels?: boolean): Promise<Array<QrScanner.Camera>>;
10
+ readonly $video: HTMLVideoElement;
11
+ readonly $canvas: HTMLCanvasElement;
12
+ readonly $overlay?: HTMLDivElement;
13
+ private readonly $codeOutlineHighlight?;
14
+ private readonly _onDecode?;
15
+ private readonly _legacyOnDecode?;
16
+ private readonly _legacyCanvasSize;
17
+ private _preferredCamera;
18
+ private readonly _maxScansPerSecond;
19
+ private _lastScanTimestamp;
20
+ private _scanRegion;
21
+ private _codeOutlineHighlightRemovalTimeout?;
22
+ private _qrEnginePromise;
23
+ private _active;
24
+ private _paused;
25
+ private _flashOn;
26
+ private _destroyed;
27
+ constructor(video: HTMLVideoElement, onDecode: (result: QrScanner.ScanResult) => void, options: {
28
+ onDecodeError?: (error: Error | string) => void;
29
+ calculateScanRegion?: (video: HTMLVideoElement) => QrScanner.ScanRegion;
30
+ preferredCamera?: QrScanner.FacingMode | QrScanner.DeviceId;
31
+ maxScansPerSecond?: number;
32
+ highlightScanRegion?: boolean;
33
+ highlightCodeOutline?: boolean;
34
+ overlay?: HTMLDivElement;
35
+ /** just a temporary flag until we switch entirely to the new api */
36
+ returnDetailedScanResult?: true;
37
+ });
38
+ /** @deprecated */
39
+ constructor(video: HTMLVideoElement, onDecode: (result: string) => void, onDecodeError?: (error: Error | string) => void, calculateScanRegion?: (video: HTMLVideoElement) => QrScanner.ScanRegion, preferredCamera?: QrScanner.FacingMode | QrScanner.DeviceId);
40
+ /** @deprecated */
41
+ constructor(video: HTMLVideoElement, onDecode: (result: string) => void, onDecodeError?: (error: Error | string) => void, canvasSize?: number, preferredCamera?: QrScanner.FacingMode | QrScanner.DeviceId);
42
+ /** @deprecated */
43
+ constructor(video: HTMLVideoElement, onDecode: (result: string) => void, canvasSize?: number);
44
+ hasFlash(): Promise<boolean>;
45
+ isFlashOn(): boolean;
46
+ toggleFlash(): Promise<void>;
47
+ turnFlashOn(): Promise<void>;
48
+ turnFlashOff(): Promise<void>;
49
+ destroy(): void;
50
+ start(): Promise<void>;
51
+ stop(): void;
52
+ pause(stopStreamImmediately?: boolean): Promise<boolean>;
53
+ setCamera(facingModeOrDeviceId: QrScanner.FacingMode | QrScanner.DeviceId): Promise<void>;
54
+ static scanImage(imageOrFileOrBlobOrUrl: HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap | SVGImageElement | File | Blob | URL | String, options: {
55
+ scanRegion?: QrScanner.ScanRegion | null;
56
+ qrEngine?: Worker | BarcodeDetector | Promise<Worker | BarcodeDetector> | null;
57
+ canvas?: HTMLCanvasElement | null;
58
+ disallowCanvasResizing?: boolean;
59
+ alsoTryWithoutScanRegion?: boolean;
60
+ /** just a temporary flag until we switch entirely to the new api */
61
+ returnDetailedScanResult?: true;
62
+ }): Promise<QrScanner.ScanResult>;
63
+ /** @deprecated */
64
+ static scanImage(imageOrFileOrBlobOrUrl: HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap | SVGImageElement | File | Blob | URL | String, scanRegion?: QrScanner.ScanRegion | null, qrEngine?: Worker | BarcodeDetector | Promise<Worker | BarcodeDetector> | null, canvas?: HTMLCanvasElement | null, disallowCanvasResizing?: boolean, alsoTryWithoutScanRegion?: boolean): Promise<string>;
65
+ setGrayscaleWeights(red: number, green: number, blue: number, useIntegerApproximation?: boolean): void;
66
+ setInversionMode(inversionMode: QrScanner.InversionMode): void;
67
+ static createQrEngine(): Promise<Worker | BarcodeDetector>;
68
+ /** @deprecated */
69
+ static createQrEngine(workerPath: string): Promise<Worker | BarcodeDetector>;
70
+ private _onPlay;
71
+ private _onLoadedMetaData;
72
+ private _onVisibilityChange;
73
+ private _calculateScanRegion;
74
+ private _updateOverlay;
75
+ private static _convertPoints;
76
+ private _scanFrame;
77
+ private _onDecodeError;
78
+ private _getCameraStream;
79
+ private _restartVideoStream;
80
+ private static _stopVideoStream;
81
+ private _setVideoMirror;
82
+ private _getFacingMode;
83
+ private static _drawToCanvas;
84
+ private static _loadImage;
85
+ private static _awaitImageLoad;
86
+ private static _postWorkerMessage;
87
+ private static _postWorkerMessageSync;
88
+ }
89
+ declare namespace QrScanner {
90
+ interface ScanRegion {
91
+ x?: number;
92
+ y?: number;
93
+ width?: number;
94
+ height?: number;
95
+ downScaledWidth?: number;
96
+ downScaledHeight?: number;
97
+ }
98
+ type FacingMode = 'environment' | 'user';
99
+ type DeviceId = string;
100
+ interface Camera {
101
+ id: DeviceId;
102
+ label: string;
103
+ }
104
+ type InversionMode = 'original' | 'invert' | 'both';
105
+ interface Point {
106
+ x: number;
107
+ y: number;
108
+ }
109
+ interface ScanResult {
110
+ data: string;
111
+ cornerPoints: QrScanner.Point[];
112
+ bytes: Number[];
113
+ }
114
+ }
115
+ declare class BarcodeDetector {
116
+ constructor(options?: {
117
+ formats: string[];
118
+ });
119
+ static getSupportedFormats(): Promise<string[]>;
120
+ detect(image: ImageBitmapSource): Promise<Array<{
121
+ rawValue: string;
122
+ cornerPoints: QrScanner.Point[];
123
+ }>>;
124
+ }
125
+ declare global {
126
+ interface Navigator {
127
+ readonly userAgentData?: {
128
+ readonly platform: string;
129
+ readonly brands: Array<{
130
+ readonly brand: string;
131
+ readonly version: string;
132
+ }>;
133
+ getHighEntropyValues(hints: string[]): Promise<{
134
+ readonly architecture?: string;
135
+ readonly platformVersion?: string;
136
+ }>;
137
+ };
138
+ }
139
+ }
140
+ export default QrScanner;