@nddeps/barcode-scanner 0.2.0 → 0.3.1
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.
- package/dist/create-barcode-scanner.d.ts +35 -0
- package/dist/create-watchable.d.ts +5 -0
- package/dist/index.d.ts +4 -6
- package/dist/index.js +260 -158
- package/dist/utils/get-camera-access.d.ts +2 -0
- package/dist/utils/get-scan-area.d.ts +9 -0
- package/dist/utils/get-video-render-offset.d.ts +8 -0
- package/dist/utils/get-video-render-size.d.ts +7 -0
- package/dist/utils/has-camera-access.d.ts +2 -0
- package/dist/utils/index.d.ts +8 -4
- package/dist/utils/is-barcode-detector-available.d.ts +4 -2
- package/dist/utils/translate-area-to-video-render.d.ts +3 -0
- package/dist/utils/translate-area-to-video-source.d.ts +3 -0
- package/dist/utils/wait.d.ts +2 -0
- package/dist/worker/index.d.ts +3 -0
- package/dist/worker/worker.decode.d.ts +3 -0
- package/dist/worker/worker.install.d.ts +2 -0
- package/dist/worker/worker.instance.d.ts +4 -0
- package/dist/worker/worker.types.d.ts +16 -0
- package/dist/worker.js +1 -0
- package/package.json +68 -66
- package/dist/barcode-detector.type.d.ts +0 -104
- package/dist/barcode-scanner.d.ts +0 -47
- package/dist/barcode-scanner.types.d.ts +0 -17
- package/dist/barcode-scanner.worker.js +0 -1
- package/dist/utils/convert-to-element-area.d.ts +0 -3
- package/dist/utils/convert-to-video-area.d.ts +0 -3
- package/dist/utils/get-video-rendered-offset.d.ts +0 -8
- package/dist/utils/get-video-rendered-size.d.ts +0 -5
package/package.json
CHANGED
|
@@ -1,66 +1,68 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@nddeps/barcode-scanner",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"private": false,
|
|
5
|
-
"keywords": [
|
|
6
|
-
"barcode",
|
|
7
|
-
"scanner",
|
|
8
|
-
"barcode-scanner"
|
|
9
|
-
],
|
|
10
|
-
"homepage": "https://github.com/No-Deprecated-Dependencies/barcode-scanner",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/No-Deprecated-Dependencies/barcode-scanner.git"
|
|
14
|
-
},
|
|
15
|
-
"license": "MIT",
|
|
16
|
-
"author": "Aleksei Saenko",
|
|
17
|
-
"type": "module",
|
|
18
|
-
"exports": {
|
|
19
|
-
".": {
|
|
20
|
-
"types": "./dist/index.d.ts",
|
|
21
|
-
"import": "./dist/index.js"
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
},
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"@eslint/
|
|
46
|
-
"@eslint/
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"eslint
|
|
52
|
-
"eslint-
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"stylelint
|
|
60
|
-
"stylelint-config-
|
|
61
|
-
"stylelint-
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@nddeps/barcode-scanner",
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"keywords": [
|
|
6
|
+
"barcode",
|
|
7
|
+
"scanner",
|
|
8
|
+
"barcode-scanner"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/No-Deprecated-Dependencies/barcode-scanner",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/No-Deprecated-Dependencies/barcode-scanner.git"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "Aleksei Saenko",
|
|
17
|
+
"type": "module",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./worker": {
|
|
24
|
+
"import": "./dist/worker.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"files": [
|
|
30
|
+
"./dist"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "vite build && tsc -b",
|
|
34
|
+
"dev": "vite",
|
|
35
|
+
"preview": "vite preview"
|
|
36
|
+
},
|
|
37
|
+
"overrides": {
|
|
38
|
+
"vite": "npm:rolldown-vite@7.3.1"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"barcode-detector": "^3.0.8",
|
|
42
|
+
"zxing-wasm": "^2.2.4"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@eslint/css": "^0.14.1",
|
|
46
|
+
"@eslint/js": "^9.39.2",
|
|
47
|
+
"@eslint/json": "^1.0.0",
|
|
48
|
+
"@eslint/markdown": "^7.5.1",
|
|
49
|
+
"@types/emscripten": "^1.41.5",
|
|
50
|
+
"@types/node": "^25.1.0",
|
|
51
|
+
"eslint": "^9.39.2",
|
|
52
|
+
"eslint-config-prettier": "^10.1.8",
|
|
53
|
+
"eslint-plugin-perfectionist": "^5.4.0",
|
|
54
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
55
|
+
"globals": "^17.2.0",
|
|
56
|
+
"jiti": "^2.6.1",
|
|
57
|
+
"prettier": "3.8.1",
|
|
58
|
+
"sort-package-json": "^3.6.1",
|
|
59
|
+
"stylelint": "^16.26.1",
|
|
60
|
+
"stylelint-config-recess-order": "^7.6.0",
|
|
61
|
+
"stylelint-config-standard": "^39.0.1",
|
|
62
|
+
"stylelint-config-standard-scss": "^16.0.0",
|
|
63
|
+
"stylelint-order": "^7.0.1",
|
|
64
|
+
"typescript": "~5.9.3",
|
|
65
|
+
"typescript-eslint": "^8.54.0",
|
|
66
|
+
"vite": "npm:rolldown-vite@7.3.1"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for the Barcode Detection API
|
|
3
|
-
* @see https://wicg.github.io/shape-detection-api/#barcode-detection-api
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* BarcodeDetector type
|
|
7
|
-
* @see https://wicg.github.io/shape-detection-api/#barcodedetector
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const detector = new BarcodeDetector({ formats: ['qr_code'] });
|
|
12
|
-
* const barcodes = await detector.detect(imageElement);
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export type BarcodeDetector = {
|
|
16
|
-
/**
|
|
17
|
-
* Creates a new BarcodeDetector instance
|
|
18
|
-
* @param barcodeDetectorOptions Optional configuration for the detector
|
|
19
|
-
*/
|
|
20
|
-
new (barcodeDetectorOptions?: BarcodeDetectorOptions): BarcodeDetector;
|
|
21
|
-
/**
|
|
22
|
-
* Detects barcodes in the provided image source
|
|
23
|
-
* @param image The image source to detect barcodes in
|
|
24
|
-
* @returns Promise that resolves to an array of DetectedBarcode objects
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
* const detector = new BarcodeDetector();
|
|
29
|
-
* const barcodes = await detector.detect(imageElement);
|
|
30
|
-
* barcodes.forEach(barcode => {
|
|
31
|
-
* console.log('Found:', barcode.rawValue, 'Format:', barcode.format);
|
|
32
|
-
* });
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
detect(image: ImageBitmapSource | Uint8ClampedArray): Promise<DetectedBarcode[]>;
|
|
36
|
-
/**
|
|
37
|
-
* Returns a promise that resolves to an array of barcode formats
|
|
38
|
-
* supported by the user agent
|
|
39
|
-
* @returns Promise that resolves to an array of supported BarcodeFormat values
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```typescript
|
|
43
|
-
* const formats = await BarcodeDetector.getSupportedFormats();
|
|
44
|
-
* console.log('Supported formats:', formats);
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
getSupportedFormats(): Promise<BarcodeFormat[]>;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Options for BarcodeDetector constructor
|
|
51
|
-
* @see https://wicg.github.io/shape-detection-api/#dictdef-barcodedetectoroptions
|
|
52
|
-
*/
|
|
53
|
-
export type BarcodeDetectorOptions = {
|
|
54
|
-
/**
|
|
55
|
-
* Optional array of barcode formats to detect.
|
|
56
|
-
* If not specified, all supported formats will be detected.
|
|
57
|
-
*/
|
|
58
|
-
formats?: BarcodeFormat[];
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Supported barcode formats
|
|
62
|
-
* @see https://wicg.github.io/shape-detection-api/#enumdef-barcodeformat
|
|
63
|
-
*/
|
|
64
|
-
export type BarcodeFormat = 'aztec' | 'codabar' | 'code_128' | 'code_39' | 'code_93' | 'data_matrix' | 'ean_13' | 'ean_8' | 'itf' | 'pdf417' | 'qr_code' | 'unknown' | 'upc_a' | 'upc_e';
|
|
65
|
-
/**
|
|
66
|
-
* Represents a detected barcode in an image
|
|
67
|
-
* @see https://wicg.github.io/shape-detection-api/#dictdef-detectedbarcode
|
|
68
|
-
*/
|
|
69
|
-
export type DetectedBarcode = {
|
|
70
|
-
/**
|
|
71
|
-
* The bounding box of the detected barcode
|
|
72
|
-
*/
|
|
73
|
-
readonly boundingBox: DOMRectReadOnly;
|
|
74
|
-
/**
|
|
75
|
-
* The four corner points of the detected barcode in clockwise order
|
|
76
|
-
* (top-left, top-right, bottom-right, bottom-left)
|
|
77
|
-
*/
|
|
78
|
-
readonly cornerPoints: Point2D[];
|
|
79
|
-
/**
|
|
80
|
-
* The format of the detected barcode
|
|
81
|
-
*/
|
|
82
|
-
readonly format: BarcodeFormat;
|
|
83
|
-
/**
|
|
84
|
-
* The raw value decoded from the barcode
|
|
85
|
-
*/
|
|
86
|
-
readonly rawValue: string;
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Point2D represents a 2D point with x and y coordinates
|
|
90
|
-
* @see https://w3c.github.io/mediacapture-image/#dictdef-point2d
|
|
91
|
-
*/
|
|
92
|
-
export type Point2D = {
|
|
93
|
-
x: number;
|
|
94
|
-
y: number;
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Global declaration for BarcodeDetector (extends Window interface)
|
|
98
|
-
* This allows TypeScript to recognize BarcodeDetector as a global when available
|
|
99
|
-
*/
|
|
100
|
-
declare global {
|
|
101
|
-
interface Window {
|
|
102
|
-
BarcodeDetector?: BarcodeDetector;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { DetectedBarcode } from './barcode-detector.type';
|
|
2
|
-
import type { OnDecode, OnDecodeError, ScanArea } from './barcode-scanner.types';
|
|
3
|
-
declare class BarcodeScanner {
|
|
4
|
-
private calcScanArea;
|
|
5
|
-
private canvas;
|
|
6
|
-
private canvasContext;
|
|
7
|
-
private debug?;
|
|
8
|
-
private decodeFrameRequestTimestamp;
|
|
9
|
-
private decodeTimeout;
|
|
10
|
-
private isDecodeFrameProcessed;
|
|
11
|
-
private isDestroyed;
|
|
12
|
-
private onDecode;
|
|
13
|
-
private onDecodeError?;
|
|
14
|
-
private onVisibilityChange;
|
|
15
|
-
private requestFrame;
|
|
16
|
-
private resumeOnVisibilityChange;
|
|
17
|
-
private scanArea;
|
|
18
|
-
private scanRate;
|
|
19
|
-
private video;
|
|
20
|
-
private videoActive;
|
|
21
|
-
private videoPaused;
|
|
22
|
-
private worker;
|
|
23
|
-
constructor({ onDecode, onDecodeError, options, video, }: {
|
|
24
|
-
onDecode: OnDecode;
|
|
25
|
-
onDecodeError?: OnDecodeError;
|
|
26
|
-
options?: {
|
|
27
|
-
calcScanArea?: (video: HTMLVideoElement) => ScanArea;
|
|
28
|
-
debug?: boolean;
|
|
29
|
-
decodeTimeout?: number;
|
|
30
|
-
preferWorker?: boolean;
|
|
31
|
-
scanRate?: number;
|
|
32
|
-
};
|
|
33
|
-
video: HTMLVideoElement;
|
|
34
|
-
});
|
|
35
|
-
decode(imageData: ImageData): Promise<DetectedBarcode | null>;
|
|
36
|
-
destroy(): Promise<void>;
|
|
37
|
-
getCameraAccess(): Promise<boolean>;
|
|
38
|
-
getScanArea(video: HTMLVideoElement): ScanArea;
|
|
39
|
-
hasCameraAccess(): Promise<boolean>;
|
|
40
|
-
pause(): void;
|
|
41
|
-
start({ facingMode, }?: {
|
|
42
|
-
facingMode?: 'environment' | 'user';
|
|
43
|
-
}): Promise<void>;
|
|
44
|
-
stop(): Promise<void>;
|
|
45
|
-
private decodeFrame;
|
|
46
|
-
}
|
|
47
|
-
export { BarcodeScanner };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { DetectedBarcode } from './barcode-detector.type';
|
|
2
|
-
export type OnDecode = (data: null | string, area: ScanArea) => void;
|
|
3
|
-
export type OnDecodeError = () => void;
|
|
4
|
-
export type ScanArea = {
|
|
5
|
-
height: number;
|
|
6
|
-
width: number;
|
|
7
|
-
x: number;
|
|
8
|
-
y: number;
|
|
9
|
-
};
|
|
10
|
-
export type WorkerRequest = {
|
|
11
|
-
data: ImageData | null;
|
|
12
|
-
uuid: string;
|
|
13
|
-
};
|
|
14
|
-
export type WorkerResponse = {
|
|
15
|
-
data: DetectedBarcode | null;
|
|
16
|
-
uuid: string;
|
|
17
|
-
};
|