@sythos/js_barcode_universal 1.5.5 → 1.5.7
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/README.md +15 -3
- package/bundle/sythos-barcode.esm.js +2 -2
- package/bundle/sythos-barcode.js +2 -2
- package/examples/read.html +5 -3
- package/package.json +91 -25
- package/src/index.js +1 -1
- package/typings/aztec/decoder.d.ts +57 -0
- package/typings/aztec/detector.d.ts +62 -0
- package/typings/aztec/encoder.d.ts +94 -0
- package/typings/aztec/high-level.d.ts +89 -0
- package/typings/aztec/index.d.ts +35 -0
- package/typings/aztec/tables.d.ts +144 -0
- package/typings/aztecrune/decoder.d.ts +56 -0
- package/typings/aztecrune/detector.d.ts +53 -0
- package/typings/aztecrune/encoder.d.ts +51 -0
- package/typings/aztecrune/index.d.ts +35 -0
- package/typings/aztecrune/tables.d.ts +75 -0
- package/typings/bundle/sythos-barcode.d.ts +31 -0
- package/typings/bundle/sythos-barcode.esm.d.ts +31 -0
- package/typings/compactpdf417/decoder.d.ts +64 -0
- package/typings/compactpdf417/detector.d.ts +48 -0
- package/typings/compactpdf417/encoder.d.ts +49 -0
- package/typings/compactpdf417/index.d.ts +8 -0
- package/typings/compactpdf417/tables.d.ts +84 -0
- package/typings/core/bit-buffer.d.ts +78 -0
- package/typings/core/bit-matrix.d.ts +129 -0
- package/typings/core/errors.d.ts +57 -0
- package/typings/core/galois-field.d.ts +141 -0
- package/typings/core/index.d.ts +40 -0
- package/typings/core/reed-solomon.d.ts +65 -0
- package/typings/databar/codec.d.ts +78 -0
- package/typings/databar/decoder.d.ts +55 -0
- package/typings/databar/encoder.d.ts +34 -0
- package/typings/databar/gs1.d.ts +48 -0
- package/typings/databar/index.d.ts +37 -0
- package/typings/databar/patterns.d.ts +46 -0
- package/typings/databar/tables.d.ts +119 -0
- package/typings/datamatrix/decoder.d.ts +57 -0
- package/typings/datamatrix/detector.d.ts +59 -0
- package/typings/datamatrix/encoder.d.ts +36 -0
- package/typings/datamatrix/index.d.ts +35 -0
- package/typings/datamatrix/tables.d.ts +88 -0
- package/typings/frameqr/decoder.d.ts +64 -0
- package/typings/frameqr/detector.d.ts +96 -0
- package/typings/frameqr/encoder.d.ts +73 -0
- package/typings/frameqr/index.d.ts +34 -0
- package/typings/frameqr/tables.d.ts +123 -0
- package/typings/image/binarizer.d.ts +85 -0
- package/typings/image/grid-sampler.d.ts +82 -0
- package/typings/image/index.d.ts +39 -0
- package/typings/image/luminance.d.ts +112 -0
- package/typings/image/perspective.d.ts +111 -0
- package/typings/index.d.ts +363 -0
- package/typings/micropdf417/compaction.d.ts +38 -0
- package/typings/micropdf417/decoder.d.ts +57 -0
- package/typings/micropdf417/detector.d.ts +95 -0
- package/typings/micropdf417/encoder.d.ts +34 -0
- package/typings/micropdf417/error-correction.d.ts +38 -0
- package/typings/micropdf417/index.d.ts +36 -0
- package/typings/micropdf417/tables.d.ts +73 -0
- package/typings/microqr/decoder.d.ts +49 -0
- package/typings/microqr/detector.d.ts +96 -0
- package/typings/microqr/encoder.d.ts +33 -0
- package/typings/microqr/index.d.ts +35 -0
- package/typings/microqr/tables.d.ts +107 -0
- package/typings/oned/addons.d.ts +181 -0
- package/typings/oned/index.d.ts +55 -0
- package/typings/oned/patterns.d.ts +259 -0
- package/typings/oned/reader.d.ts +129 -0
- package/typings/oned/writers.d.ts +218 -0
- package/typings/pdf417/compaction.d.ts +59 -0
- package/typings/pdf417/decoder.d.ts +48 -0
- package/typings/pdf417/detector.d.ts +73 -0
- package/typings/pdf417/encoder.d.ts +32 -0
- package/typings/pdf417/error-correction.d.ts +34 -0
- package/typings/pdf417/index.d.ts +10 -0
- package/typings/pdf417/tables.d.ts +53 -0
- package/typings/qr/decoder.d.ts +79 -0
- package/typings/qr/detector.d.ts +93 -0
- package/typings/qr/encoder.d.ts +166 -0
- package/typings/qr/index.d.ts +43 -0
- package/typings/qr/tables.d.ts +291 -0
- package/typings/render/image-data.d.ts +58 -0
- package/typings/render/index.d.ts +110 -0
- package/typings/render/options.d.ts +98 -0
- package/typings/render/png.d.ts +58 -0
- package/typings/render/svg.d.ts +46 -0
- package/typings/render/webgl.d.ts +45 -0
- package/typings/render/webgpu.d.ts +51 -0
- package/typings/rmqr/decoder.d.ts +42 -0
- package/typings/rmqr/detector.d.ts +81 -0
- package/typings/rmqr/encoder.d.ts +45 -0
- package/typings/rmqr/index.d.ts +34 -0
- package/typings/rmqr/tables.d.ts +89 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Sythos Barcode Suite
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2026 Sythos
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* SPDX-FileCopyrightText: 2026 Sythos (https://www.sythos.net)
|
|
27
|
+
* SPDX-License-Identifier: MIT
|
|
28
|
+
*
|
|
29
|
+
* Original work. No code from any other barcode implementation.
|
|
30
|
+
*/
|
|
31
|
+
export type ImageLike = {
|
|
32
|
+
/**
|
|
33
|
+
* RGBA, 4 bytes per pixel.
|
|
34
|
+
*/
|
|
35
|
+
data: Uint8ClampedArray | Uint8Array | number[];
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* @typedef {object} ImageLike
|
|
41
|
+
* @property {Uint8ClampedArray | Uint8Array | number[]} data RGBA, 4 bytes per pixel.
|
|
42
|
+
* @property {number} width
|
|
43
|
+
* @property {number} height
|
|
44
|
+
*/
|
|
45
|
+
export declare class LuminanceSource {
|
|
46
|
+
grey: Uint8Array<ArrayBufferLike>;
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
/**
|
|
50
|
+
* @param {Uint8Array} grey One byte per pixel.
|
|
51
|
+
* @param {number} width
|
|
52
|
+
* @param {number} height
|
|
53
|
+
*/
|
|
54
|
+
constructor(grey: Uint8Array, width: number, height: number);
|
|
55
|
+
/**
|
|
56
|
+
* Build from any ImageData-shaped object.
|
|
57
|
+
*
|
|
58
|
+
* Transparent pixels are composited over white rather than read as black:
|
|
59
|
+
* a PNG barcode with a transparent background is common, and treating alpha
|
|
60
|
+
* as ink turns the entire quiet zone into a solid dark field.
|
|
61
|
+
*
|
|
62
|
+
* @param {ImageLike} image
|
|
63
|
+
* @returns {LuminanceSource}
|
|
64
|
+
*/
|
|
65
|
+
static fromImageData(image: ImageLike): LuminanceSource;
|
|
66
|
+
/**
|
|
67
|
+
* Build directly from single-channel data, skipping conversion.
|
|
68
|
+
*
|
|
69
|
+
* @param {Uint8Array} grey
|
|
70
|
+
* @param {number} width
|
|
71
|
+
* @param {number} height
|
|
72
|
+
* @returns {LuminanceSource}
|
|
73
|
+
*/
|
|
74
|
+
static fromGrey(grey: Uint8Array, width: number, height: number): LuminanceSource;
|
|
75
|
+
/**
|
|
76
|
+
* @param {number} x @param {number} y
|
|
77
|
+
* @returns {number} 0-255.
|
|
78
|
+
*/
|
|
79
|
+
get(x: number, y: number): number;
|
|
80
|
+
/**
|
|
81
|
+
* @param {number} y
|
|
82
|
+
* @param {Uint8Array} [out]
|
|
83
|
+
* @returns {Uint8Array}
|
|
84
|
+
*/
|
|
85
|
+
getRow(y: number, out?: Uint8Array): Uint8Array;
|
|
86
|
+
/**
|
|
87
|
+
* Rotate 90 degrees clockwise.
|
|
88
|
+
*
|
|
89
|
+
* The 1D readers scan horizontally, so this is how they find vertically
|
|
90
|
+
* oriented barcodes: scan, rotate, scan again.
|
|
91
|
+
*
|
|
92
|
+
* @returns {LuminanceSource}
|
|
93
|
+
*/
|
|
94
|
+
rotate90(): LuminanceSource;
|
|
95
|
+
/**
|
|
96
|
+
* Downscale by an integer factor with box averaging.
|
|
97
|
+
*
|
|
98
|
+
* Large camera frames are slow to scan and no more informative than a
|
|
99
|
+
* half-size copy; detectors use this to find candidates cheaply.
|
|
100
|
+
*
|
|
101
|
+
* @param {number} factor
|
|
102
|
+
* @returns {LuminanceSource}
|
|
103
|
+
*/
|
|
104
|
+
downscale(factor: number): LuminanceSource;
|
|
105
|
+
/**
|
|
106
|
+
* Invert. Some symbols are printed light-on-dark, and readers retry inverted
|
|
107
|
+
* when a first pass finds nothing.
|
|
108
|
+
*
|
|
109
|
+
* @returns {LuminanceSource}
|
|
110
|
+
*/
|
|
111
|
+
invert(): LuminanceSource;
|
|
112
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Sythos Barcode Suite
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2026 Sythos
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* SPDX-FileCopyrightText: 2026 Sythos (https://www.sythos.net)
|
|
27
|
+
* SPDX-License-Identifier: MIT
|
|
28
|
+
*
|
|
29
|
+
* Original work. No code from any other barcode implementation.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Projective (perspective) transforms.
|
|
33
|
+
*
|
|
34
|
+
* A 2D symbol photographed off-axis is not a rotated square — it is a
|
|
35
|
+
* quadrilateral with converging edges. Correcting that needs a full projective
|
|
36
|
+
* map, not an affine one; an affine approximation reads the near edge of a
|
|
37
|
+
* tilted symbol correctly and drifts a module or more by the far edge.
|
|
38
|
+
*
|
|
39
|
+
* The map is a 3x3 homogeneous matrix. Points are transformed as
|
|
40
|
+
* (x, y, 1) * M, then divided through by the resulting w.
|
|
41
|
+
*
|
|
42
|
+
* @module image/perspective
|
|
43
|
+
*/
|
|
44
|
+
export declare class PerspectiveTransform {
|
|
45
|
+
a11: any;
|
|
46
|
+
a21: any;
|
|
47
|
+
a31: any;
|
|
48
|
+
a12: any;
|
|
49
|
+
a22: any;
|
|
50
|
+
a32: any;
|
|
51
|
+
a13: any;
|
|
52
|
+
a23: any;
|
|
53
|
+
a33: any;
|
|
54
|
+
constructor(a11: any, a21: any, a31: any, a12: any, a22: any, a32: any, a13: any, a23: any, a33: any);
|
|
55
|
+
/**
|
|
56
|
+
* Transform points in place.
|
|
57
|
+
*
|
|
58
|
+
* @param {Float32Array | number[]} points Interleaved [x0, y0, x1, y1, ...].
|
|
59
|
+
* @returns {Float32Array | number[]} The same array.
|
|
60
|
+
*/
|
|
61
|
+
transform(points: Float32Array | number[]): Float32Array | number[];
|
|
62
|
+
/**
|
|
63
|
+
* Transform a single point.
|
|
64
|
+
*
|
|
65
|
+
* @param {number} x @param {number} y
|
|
66
|
+
* @returns {{x: number, y: number}}
|
|
67
|
+
*/
|
|
68
|
+
transformPoint(x: number, y: number): {
|
|
69
|
+
x: number;
|
|
70
|
+
y: number;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Map the unit square — (0,0), (1,0), (1,1), (0,1) — onto an arbitrary quad.
|
|
74
|
+
*
|
|
75
|
+
* Corners are given in that same order, i.e. going around the quad, not
|
|
76
|
+
* as opposite pairs.
|
|
77
|
+
*
|
|
78
|
+
* @returns {PerspectiveTransform}
|
|
79
|
+
*/
|
|
80
|
+
static squareToQuad(x0: any, y0: any, x1: any, y1: any, x2: any, y2: any, x3: any, y3: any): PerspectiveTransform;
|
|
81
|
+
/**
|
|
82
|
+
* Map an arbitrary quad onto the unit square — the inverse of
|
|
83
|
+
* {@link squareToQuad}, via the adjugate.
|
|
84
|
+
*
|
|
85
|
+
* @returns {PerspectiveTransform}
|
|
86
|
+
*/
|
|
87
|
+
static quadToSquare(x0: any, y0: any, x1: any, y1: any, x2: any, y2: any, x3: any, y3: any): PerspectiveTransform;
|
|
88
|
+
/**
|
|
89
|
+
* Map one quad onto another, corner for corner.
|
|
90
|
+
*
|
|
91
|
+
* This is what turns four detected finder corners into a sampling grid:
|
|
92
|
+
* compose "detected quad -> unit square" with "unit square -> ideal grid".
|
|
93
|
+
*
|
|
94
|
+
* @returns {PerspectiveTransform}
|
|
95
|
+
*/
|
|
96
|
+
static quadToQuad(sx0: any, sy0: any, sx1: any, sy1: any, sx2: any, sy2: any, sx3: any, sy3: any, dx0: any, dy0: any, dx1: any, dy1: any, dx2: any, dy2: any, dx3: any, dy3: any): PerspectiveTransform;
|
|
97
|
+
/**
|
|
98
|
+
* Adjugate — the inverse up to a scale factor, which is irrelevant in
|
|
99
|
+
* homogeneous coordinates because the division by w cancels it.
|
|
100
|
+
*
|
|
101
|
+
* @returns {PerspectiveTransform}
|
|
102
|
+
*/
|
|
103
|
+
inverse(): PerspectiveTransform;
|
|
104
|
+
/**
|
|
105
|
+
* Matrix product: apply `this` first, then `other`.
|
|
106
|
+
*
|
|
107
|
+
* @param {PerspectiveTransform} other
|
|
108
|
+
* @returns {PerspectiveTransform}
|
|
109
|
+
*/
|
|
110
|
+
times(other: PerspectiveTransform): PerspectiveTransform;
|
|
111
|
+
}
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Sythos Barcode Suite
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2026 Sythos
|
|
7
|
+
* SPDX-FileCopyrightText: 2026 Sythos (https://www.sythos.net)
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
* in the Software without restriction, including without limitation the rights
|
|
12
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
* furnished to do so, subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
* copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
* SOFTWARE.
|
|
26
|
+
*
|
|
27
|
+
* SPDX-License-Identifier: MIT
|
|
28
|
+
*
|
|
29
|
+
* Original work. No code from any other barcode implementation.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Sythos Barcode Suite — public API.
|
|
33
|
+
*
|
|
34
|
+
* Two functions carry the whole surface:
|
|
35
|
+
*
|
|
36
|
+
* encode(text, { format }) -> BitMatrix
|
|
37
|
+
* decode(image, { formats }) -> Result[]
|
|
38
|
+
*
|
|
39
|
+
* Everything else is a renderer or a format-specific escape hatch. The core is
|
|
40
|
+
* free of I/O and of any platform assumption: images go in as
|
|
41
|
+
* `{ data, width, height }` with RGBA bytes, which is exactly what `ImageData`
|
|
42
|
+
* is, so a canvas, an `OffscreenCanvas`, sharp, jimp and node-canvas all work
|
|
43
|
+
* without an adapter.
|
|
44
|
+
*
|
|
45
|
+
* @module @sythos/js_barcode_universal
|
|
46
|
+
*/
|
|
47
|
+
import { BitMatrix } from './core/bit-matrix.js';
|
|
48
|
+
export { BitMatrix };
|
|
49
|
+
export { BarcodeError, EncodeError, NotFoundError, FormatError, ChecksumError, } from './core/errors.js';
|
|
50
|
+
export { LuminanceSource } from './image/luminance.js';
|
|
51
|
+
export { binarize, binarizeGlobal, binarizeHybrid } from './image/binarizer.js';
|
|
52
|
+
export * from './oned/index.js';
|
|
53
|
+
export { toSVG, toSVGDataURI } from './render/svg.js';
|
|
54
|
+
export { toImageData, toCanvas } from './render/image-data.js';
|
|
55
|
+
export { toPNG, toPNGDataURI } from './render/png.js';
|
|
56
|
+
export { renderToCanvasAuto, isWebGL2Available } from './render/index.js';
|
|
57
|
+
export { renderToCanvasAutoAsync, isWebGPUAvailable } from './render/index.js';
|
|
58
|
+
export { encodeQR, decodeQR, detectQR, detectAndDecodeQR } from './qr/index.js';
|
|
59
|
+
export { encodeDataMatrix, decodeDataMatrix, detectDataMatrix, detectAndDecodeDataMatrix, } from './datamatrix/index.js';
|
|
60
|
+
export { encodeAztec, decodeAztec, detectAztec, detectAndDecodeAztec } from './aztec/index.js';
|
|
61
|
+
export * from './aztecrune/index.js';
|
|
62
|
+
export { encodePDF417, decodePDF417, detectPDF417, detectAndDecodePDF417 } from './pdf417/index.js';
|
|
63
|
+
export * from './compactpdf417/index.js';
|
|
64
|
+
export * from './databar/index.js';
|
|
65
|
+
export { encodeMicroPDF417, decodeMicroPDF417, detectMicroPDF417, detectAndDecodeMicroPDF417, } from './micropdf417/index.js';
|
|
66
|
+
export { encodeMicroQR, decodeMicroQR, detectMicroQR, detectAndDecodeMicroQR } from './microqr/index.js';
|
|
67
|
+
export { encodeRMQR, decodeRMQR, detectRMQR, detectAndDecodeRMQR } from './rmqr/index.js';
|
|
68
|
+
export { encodeFrameQR, decodeFrameQR, detectFrameQR, detectAndDecodeFrameQR, } from './frameqr/index.js';
|
|
69
|
+
export type FormatInfo = {
|
|
70
|
+
id: string;
|
|
71
|
+
label: string;
|
|
72
|
+
canWrite: boolean;
|
|
73
|
+
canRead: boolean;
|
|
74
|
+
kind: '1D' | '2D';
|
|
75
|
+
role?: 'supplement';
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Every format this build supports.
|
|
79
|
+
*
|
|
80
|
+
* Writing and reading are listed separately on purpose. Writing a symbology is
|
|
81
|
+
* a table lookup; reading one needs a detector that finds it in a photograph,
|
|
82
|
+
* which is far more work. The two lists legitimately differ, and saying so
|
|
83
|
+
* here is better than failing at call time.
|
|
84
|
+
*
|
|
85
|
+
* @returns {FormatInfo[]}
|
|
86
|
+
*/
|
|
87
|
+
export declare function listFormats(): FormatInfo[];
|
|
88
|
+
/**
|
|
89
|
+
* Encode a payload into a barcode matrix.
|
|
90
|
+
*
|
|
91
|
+
* The result is a `BitMatrix` where a set bit is a dark module, with no quiet
|
|
92
|
+
* zone — the renderers add that, because the right margin depends on the
|
|
93
|
+
* output medium. Linear symbols come back one module tall; height is a
|
|
94
|
+
* rendering decision, not an encoding one.
|
|
95
|
+
*
|
|
96
|
+
* @param {string | number} text
|
|
97
|
+
* @param {object} [options]
|
|
98
|
+
* @param {string} [options.format] Format id. Default 'qr'.
|
|
99
|
+
* @param {'L'|'M'|'Q'|'H'} [options.ecc] QR error-correction level.
|
|
100
|
+
* @param {number} [options.version] QR version, 1-40. Auto if omitted.
|
|
101
|
+
* @param {boolean} [options.checkDigit] Append a check digit, where optional.
|
|
102
|
+
* @param {boolean} [options.fullAscii] Code 39 extended encoding.
|
|
103
|
+
* @param {boolean} [options.gs1] Emit a leading FNC1.
|
|
104
|
+
* @param {number} [options.layers] Aztec layer count; automatic if omitted.
|
|
105
|
+
* @param {boolean} [options.compact] Force an Aztec Compact or Full symbol.
|
|
106
|
+
* @param {number} [options.eccPercent] Requested Aztec error-correction percentage.
|
|
107
|
+
* @param {number} [options.eccLevel] PDF417 error-correction level, 0-8.
|
|
108
|
+
* @param {number} [options.columns] PDF417 columns, 1-30.
|
|
109
|
+
* @param {number} [options.rows] PDF417 rows, 3-90.
|
|
110
|
+
* @param {number} [options.rowHeight] PDF417 row height in modules.
|
|
111
|
+
* @param {'auto'|'text'|'byte'|'numeric'} [options.compaction] PDF417 compaction mode.
|
|
112
|
+
* @param {number} [options.eci] MicroPDF417 byte-compaction ECI assignment (3 or 26).
|
|
113
|
+
* @param {number} [options.aspectRatio] Preferred MicroPDF417 symbol aspect ratio.
|
|
114
|
+
* @param {object} [options.canvas] FrameQR Code artwork reservation.
|
|
115
|
+
* @param {'square'|'circle'|'diamond'} [options.canvas.shape] Canvas shape.
|
|
116
|
+
* @param {number} [options.canvas.size] Odd canvas size in QR modules.
|
|
117
|
+
* @param {number} [options.canvas.width] Canvas width in QR modules.
|
|
118
|
+
* @param {number} [options.canvas.height] Canvas height in QR modules.
|
|
119
|
+
* @param {number} [options.canvas.centerX] Canvas centre X in QR modules.
|
|
120
|
+
* @param {number} [options.canvas.centerY] Canvas centre Y in QR modules.
|
|
121
|
+
* @param {0|90|180|270} [options.canvas.angle] Canvas quarter-turn.
|
|
122
|
+
* @returns {BitMatrix}
|
|
123
|
+
*/
|
|
124
|
+
export declare function encode(text: string | number, options?: {
|
|
125
|
+
format?: string;
|
|
126
|
+
ecc?: 'L' | 'M' | 'Q' | 'H';
|
|
127
|
+
version?: number;
|
|
128
|
+
checkDigit?: boolean;
|
|
129
|
+
fullAscii?: boolean;
|
|
130
|
+
gs1?: boolean;
|
|
131
|
+
layers?: number;
|
|
132
|
+
compact?: boolean;
|
|
133
|
+
eccPercent?: number;
|
|
134
|
+
eccLevel?: number;
|
|
135
|
+
columns?: number;
|
|
136
|
+
rows?: number;
|
|
137
|
+
rowHeight?: number;
|
|
138
|
+
compaction?: 'auto' | 'text' | 'byte' | 'numeric';
|
|
139
|
+
eci?: number;
|
|
140
|
+
aspectRatio?: number;
|
|
141
|
+
canvas?: {
|
|
142
|
+
shape?: 'square' | 'circle' | 'diamond';
|
|
143
|
+
size?: number;
|
|
144
|
+
width?: number;
|
|
145
|
+
height?: number;
|
|
146
|
+
centerX?: number;
|
|
147
|
+
centerY?: number;
|
|
148
|
+
angle?: 0 | 90 | 180 | 270;
|
|
149
|
+
};
|
|
150
|
+
}): BitMatrix;
|
|
151
|
+
export type DecodeResult = {
|
|
152
|
+
text: string;
|
|
153
|
+
format: string;
|
|
154
|
+
/**
|
|
155
|
+
* Raw octets exposed by byte-oriented payload modes, before text decoding.
|
|
156
|
+
*/
|
|
157
|
+
bytes?: Uint8Array;
|
|
158
|
+
/**
|
|
159
|
+
* PDF417 compaction segments in source order.
|
|
160
|
+
*/
|
|
161
|
+
segments?: {
|
|
162
|
+
mode: 'text' | 'byte' | 'numeric';
|
|
163
|
+
text: string;
|
|
164
|
+
bytes: Uint8Array;
|
|
165
|
+
eci: number;
|
|
166
|
+
latch: number | null;
|
|
167
|
+
codewordStart: number;
|
|
168
|
+
codewordEnd: number;
|
|
169
|
+
}[];
|
|
170
|
+
/**
|
|
171
|
+
* QR version.
|
|
172
|
+
*/
|
|
173
|
+
version?: number;
|
|
174
|
+
/**
|
|
175
|
+
* QR error-correction level.
|
|
176
|
+
*/
|
|
177
|
+
ecc?: string;
|
|
178
|
+
/**
|
|
179
|
+
* Aztec layer count.
|
|
180
|
+
*/
|
|
181
|
+
layers?: number;
|
|
182
|
+
/**
|
|
183
|
+
* Whether an Aztec symbol is Compact.
|
|
184
|
+
*/
|
|
185
|
+
compact?: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Reed–Solomon corrections applied by an Aztec decode.
|
|
188
|
+
*/
|
|
189
|
+
corrections?: number;
|
|
190
|
+
/**
|
|
191
|
+
* PDF417 row count.
|
|
192
|
+
*/
|
|
193
|
+
rows?: number;
|
|
194
|
+
/**
|
|
195
|
+
* PDF417 column count.
|
|
196
|
+
*/
|
|
197
|
+
columns?: number;
|
|
198
|
+
/**
|
|
199
|
+
* PDF417 error-correction level.
|
|
200
|
+
*/
|
|
201
|
+
eccLevel?: number;
|
|
202
|
+
/**
|
|
203
|
+
* PDF417 row height in modules.
|
|
204
|
+
*/
|
|
205
|
+
rowHeight?: number;
|
|
206
|
+
/**
|
|
207
|
+
* MicroPDF417 predefined variant number.
|
|
208
|
+
*/
|
|
209
|
+
variant?: number;
|
|
210
|
+
/**
|
|
211
|
+
* MicroPDF417 fixed error-correction codewords.
|
|
212
|
+
*/
|
|
213
|
+
eccCodewords?: number;
|
|
214
|
+
/**
|
|
215
|
+
* FrameQR Code profile identifier.
|
|
216
|
+
*/
|
|
217
|
+
profile?: string;
|
|
218
|
+
/**
|
|
219
|
+
* Whether the profile is certified by its originator.
|
|
220
|
+
*/
|
|
221
|
+
certified?: boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Canvas reservation metadata for the FrameQR Code profile.
|
|
224
|
+
*/
|
|
225
|
+
canvas?: object;
|
|
226
|
+
/**
|
|
227
|
+
* Attached EAN/UPC supplement.
|
|
228
|
+
*/
|
|
229
|
+
addon?: {
|
|
230
|
+
format: 'ean2' | 'ean5';
|
|
231
|
+
text: string;
|
|
232
|
+
parity: string;
|
|
233
|
+
checksum?: number;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* Camera-profile confidence from 0 to 1.
|
|
237
|
+
*/
|
|
238
|
+
confidence?: number;
|
|
239
|
+
/**
|
|
240
|
+
* Camera-profile bounds in the scanned orientation.
|
|
241
|
+
*/
|
|
242
|
+
bounds?: {
|
|
243
|
+
x: number;
|
|
244
|
+
y: number;
|
|
245
|
+
width: number;
|
|
246
|
+
height: number;
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* Camera-profile orientation in degrees.
|
|
250
|
+
*/
|
|
251
|
+
rotation?: 0 | 90 | 180 | 270;
|
|
252
|
+
/**
|
|
253
|
+
* Camera-profile validation evidence.
|
|
254
|
+
*/
|
|
255
|
+
quality?: {
|
|
256
|
+
quietZone: boolean;
|
|
257
|
+
checksum: boolean | null;
|
|
258
|
+
rows: number | null;
|
|
259
|
+
consistency: number | null;
|
|
260
|
+
};
|
|
261
|
+
/**
|
|
262
|
+
* Whether the physical symbol is classified as GS1.
|
|
263
|
+
*/
|
|
264
|
+
gs1?: boolean;
|
|
265
|
+
/**
|
|
266
|
+
* GS1 symbology identifier.
|
|
267
|
+
*/
|
|
268
|
+
symbologyIdentifier?: string;
|
|
269
|
+
/**
|
|
270
|
+
* Parsed GS1 Application Identifier fields.
|
|
271
|
+
*/
|
|
272
|
+
elements?: Array<{
|
|
273
|
+
ai: string;
|
|
274
|
+
value: string;
|
|
275
|
+
fixed?: boolean;
|
|
276
|
+
}>;
|
|
277
|
+
/**
|
|
278
|
+
* Semantic GS1 parsing error after a valid physical read.
|
|
279
|
+
*/
|
|
280
|
+
gs1ParseError?: string;
|
|
281
|
+
/**
|
|
282
|
+
* GS1 DataBar GTIN-14 payload.
|
|
283
|
+
*/
|
|
284
|
+
gtin?: string;
|
|
285
|
+
/**
|
|
286
|
+
* GS1 DataBar linkage flag.
|
|
287
|
+
*/
|
|
288
|
+
linkage?: boolean;
|
|
289
|
+
};
|
|
290
|
+
/**
|
|
291
|
+
* @typedef {object} DecodeResult
|
|
292
|
+
* @property {string} text
|
|
293
|
+
* @property {string} format
|
|
294
|
+
* @property {Uint8Array} [bytes] Raw octets exposed by byte-oriented payload modes, before text decoding.
|
|
295
|
+
* @property {{mode: 'text'|'byte'|'numeric', text: string, bytes: Uint8Array, eci: number, latch: number|null, codewordStart: number, codewordEnd: number}[]} [segments] PDF417 compaction segments in source order.
|
|
296
|
+
* @property {number} [version] QR version.
|
|
297
|
+
* @property {string} [ecc] QR error-correction level.
|
|
298
|
+
* @property {number} [layers] Aztec layer count.
|
|
299
|
+
* @property {boolean} [compact] Whether an Aztec symbol is Compact.
|
|
300
|
+
* @property {number} [corrections] Reed–Solomon corrections applied by an Aztec decode.
|
|
301
|
+
* @property {number} [rows] PDF417 row count.
|
|
302
|
+
* @property {number} [columns] PDF417 column count.
|
|
303
|
+
* @property {number} [eccLevel] PDF417 error-correction level.
|
|
304
|
+
* @property {number} [rowHeight] PDF417 row height in modules.
|
|
305
|
+
* @property {number} [variant] MicroPDF417 predefined variant number.
|
|
306
|
+
* @property {number} [eccCodewords] MicroPDF417 fixed error-correction codewords.
|
|
307
|
+
* @property {string} [profile] FrameQR Code profile identifier.
|
|
308
|
+
* @property {boolean} [certified] Whether the profile is certified by its originator.
|
|
309
|
+
* @property {object} [canvas] Canvas reservation metadata for the FrameQR Code profile.
|
|
310
|
+
* @property {{format:'ean2'|'ean5', text:string, parity:string, checksum?:number}} [addon] Attached EAN/UPC supplement.
|
|
311
|
+
* @property {number} [confidence] Camera-profile confidence from 0 to 1.
|
|
312
|
+
* @property {{x:number,y:number,width:number,height:number}} [bounds] Camera-profile bounds in the scanned orientation.
|
|
313
|
+
* @property {0|90|180|270} [rotation] Camera-profile orientation in degrees.
|
|
314
|
+
* @property {{quietZone:boolean,checksum:boolean|null,rows:number|null,consistency:number|null}} [quality] Camera-profile validation evidence.
|
|
315
|
+
* @property {boolean} [gs1] Whether the physical symbol is classified as GS1.
|
|
316
|
+
* @property {string} [symbologyIdentifier] GS1 symbology identifier.
|
|
317
|
+
* @property {Array<{ai:string,value:string,fixed?:boolean}>} [elements] Parsed GS1 Application Identifier fields.
|
|
318
|
+
* @property {string} [gs1ParseError] Semantic GS1 parsing error after a valid physical read.
|
|
319
|
+
* @property {string} [gtin] GS1 DataBar GTIN-14 payload.
|
|
320
|
+
* @property {boolean} [linkage] GS1 DataBar linkage flag.
|
|
321
|
+
*/
|
|
322
|
+
/**
|
|
323
|
+
* Find and decode every barcode in an image.
|
|
324
|
+
*
|
|
325
|
+
* Returns an array, empty when nothing is found — an image with no barcode is
|
|
326
|
+
* an ordinary outcome for a camera frame, not an error, and throwing would
|
|
327
|
+
* make the common scanning loop a try/catch.
|
|
328
|
+
*
|
|
329
|
+
* @param {{data: Uint8ClampedArray|Uint8Array|number[], width: number, height: number}} image
|
|
330
|
+
* @param {object} [options]
|
|
331
|
+
* @param {string[]} [options.formats] Restrict to these format ids.
|
|
332
|
+
* @param {boolean} [options.tryHarder] Retry inverted and rotated. Default true.
|
|
333
|
+
* @param {'global'|'hybrid'|'auto'} [options.binarizer]
|
|
334
|
+
* @param {'camera'} [options.profile] Opt-in strict camera profile for validated 1D reads.
|
|
335
|
+
* @param {object} [options.frameqr] FrameQR Code detector options when
|
|
336
|
+
* the profile marker is not preserved through image rendering.
|
|
337
|
+
* @returns {DecodeResult[]}
|
|
338
|
+
*/
|
|
339
|
+
export declare function decode(image: {
|
|
340
|
+
data: Uint8ClampedArray | Uint8Array | number[];
|
|
341
|
+
width: number;
|
|
342
|
+
height: number;
|
|
343
|
+
}, options?: {
|
|
344
|
+
formats?: string[];
|
|
345
|
+
tryHarder?: boolean;
|
|
346
|
+
binarizer?: 'global' | 'hybrid' | 'auto';
|
|
347
|
+
profile?: 'camera';
|
|
348
|
+
frameqr?: object;
|
|
349
|
+
}): DecodeResult[];
|
|
350
|
+
/**
|
|
351
|
+
* Decode, or throw if nothing is found.
|
|
352
|
+
*
|
|
353
|
+
* @param {{data: Uint8ClampedArray|Uint8Array|number[], width: number, height: number}} image
|
|
354
|
+
* @param {object} [options]
|
|
355
|
+
* @returns {DecodeResult}
|
|
356
|
+
*/
|
|
357
|
+
export declare function decodeStrict(image: {
|
|
358
|
+
data: Uint8ClampedArray | Uint8Array | number[];
|
|
359
|
+
width: number;
|
|
360
|
+
height: number;
|
|
361
|
+
}, options?: object): DecodeResult;
|
|
362
|
+
/** Library version, matching package.json. */
|
|
363
|
+
export declare const VERSION = "1.5.6";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Sythos Barcode Suite
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2026 Sythos
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* SPDX-FileCopyrightText: 2026 Sythos (https://www.sythos.net)
|
|
27
|
+
* SPDX-License-Identifier: MIT
|
|
28
|
+
*
|
|
29
|
+
* Original work. No code from any other barcode implementation.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Compact one MicroPDF417 value.
|
|
33
|
+
*
|
|
34
|
+
* Unlike PDF417, MicroPDF417 starts in Byte Compaction. Text therefore needs
|
|
35
|
+
* an explicit 900 latch. Byte compaction always emits 901 or 924 so its start
|
|
36
|
+
* state is unambiguous, including when an ECI designator precedes it.
|
|
37
|
+
*/
|
|
38
|
+
export declare function compactMicroPDF417(value: any, options?: {}): any[];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Sythos Barcode Suite
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2026 Sythos
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* SPDX-FileCopyrightText: 2026 Sythos (https://www.sythos.net)
|
|
27
|
+
* SPDX-License-Identifier: MIT
|
|
28
|
+
*
|
|
29
|
+
* Original work. No code from any other barcode implementation.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Decode a sampled MicroPDF417 matrix.
|
|
33
|
+
*
|
|
34
|
+
* The complete fixed data region is compacted after correction. Encoder padding
|
|
35
|
+
* is PDF417 Text latch 900, which contributes no characters at the end of the
|
|
36
|
+
* payload. This avoids relying on non-symbol metadata for payload length.
|
|
37
|
+
*/
|
|
38
|
+
export declare function decodeMicroPDF417(matrix: any, options?: {}): {
|
|
39
|
+
text: string;
|
|
40
|
+
bytes: Uint8Array<ArrayBuffer>;
|
|
41
|
+
segments: {
|
|
42
|
+
mode: string;
|
|
43
|
+
text: string;
|
|
44
|
+
bytes: Uint8Array<ArrayBuffer>;
|
|
45
|
+
eci: number;
|
|
46
|
+
latch: any;
|
|
47
|
+
codewordStart: number;
|
|
48
|
+
codewordEnd: number;
|
|
49
|
+
}[];
|
|
50
|
+
codewords: number[];
|
|
51
|
+
rows: any;
|
|
52
|
+
columns: any;
|
|
53
|
+
variant: any;
|
|
54
|
+
eccCodewords: any;
|
|
55
|
+
rowHeight: number;
|
|
56
|
+
corrections: number;
|
|
57
|
+
};
|