@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.
Files changed (94) hide show
  1. package/README.md +15 -3
  2. package/bundle/sythos-barcode.esm.js +2 -2
  3. package/bundle/sythos-barcode.js +2 -2
  4. package/examples/read.html +5 -3
  5. package/package.json +91 -25
  6. package/src/index.js +1 -1
  7. package/typings/aztec/decoder.d.ts +57 -0
  8. package/typings/aztec/detector.d.ts +62 -0
  9. package/typings/aztec/encoder.d.ts +94 -0
  10. package/typings/aztec/high-level.d.ts +89 -0
  11. package/typings/aztec/index.d.ts +35 -0
  12. package/typings/aztec/tables.d.ts +144 -0
  13. package/typings/aztecrune/decoder.d.ts +56 -0
  14. package/typings/aztecrune/detector.d.ts +53 -0
  15. package/typings/aztecrune/encoder.d.ts +51 -0
  16. package/typings/aztecrune/index.d.ts +35 -0
  17. package/typings/aztecrune/tables.d.ts +75 -0
  18. package/typings/bundle/sythos-barcode.d.ts +31 -0
  19. package/typings/bundle/sythos-barcode.esm.d.ts +31 -0
  20. package/typings/compactpdf417/decoder.d.ts +64 -0
  21. package/typings/compactpdf417/detector.d.ts +48 -0
  22. package/typings/compactpdf417/encoder.d.ts +49 -0
  23. package/typings/compactpdf417/index.d.ts +8 -0
  24. package/typings/compactpdf417/tables.d.ts +84 -0
  25. package/typings/core/bit-buffer.d.ts +78 -0
  26. package/typings/core/bit-matrix.d.ts +129 -0
  27. package/typings/core/errors.d.ts +57 -0
  28. package/typings/core/galois-field.d.ts +141 -0
  29. package/typings/core/index.d.ts +40 -0
  30. package/typings/core/reed-solomon.d.ts +65 -0
  31. package/typings/databar/codec.d.ts +78 -0
  32. package/typings/databar/decoder.d.ts +55 -0
  33. package/typings/databar/encoder.d.ts +34 -0
  34. package/typings/databar/gs1.d.ts +48 -0
  35. package/typings/databar/index.d.ts +37 -0
  36. package/typings/databar/patterns.d.ts +46 -0
  37. package/typings/databar/tables.d.ts +119 -0
  38. package/typings/datamatrix/decoder.d.ts +57 -0
  39. package/typings/datamatrix/detector.d.ts +59 -0
  40. package/typings/datamatrix/encoder.d.ts +36 -0
  41. package/typings/datamatrix/index.d.ts +35 -0
  42. package/typings/datamatrix/tables.d.ts +88 -0
  43. package/typings/frameqr/decoder.d.ts +64 -0
  44. package/typings/frameqr/detector.d.ts +96 -0
  45. package/typings/frameqr/encoder.d.ts +73 -0
  46. package/typings/frameqr/index.d.ts +34 -0
  47. package/typings/frameqr/tables.d.ts +123 -0
  48. package/typings/image/binarizer.d.ts +85 -0
  49. package/typings/image/grid-sampler.d.ts +82 -0
  50. package/typings/image/index.d.ts +39 -0
  51. package/typings/image/luminance.d.ts +112 -0
  52. package/typings/image/perspective.d.ts +111 -0
  53. package/typings/index.d.ts +363 -0
  54. package/typings/micropdf417/compaction.d.ts +38 -0
  55. package/typings/micropdf417/decoder.d.ts +57 -0
  56. package/typings/micropdf417/detector.d.ts +95 -0
  57. package/typings/micropdf417/encoder.d.ts +34 -0
  58. package/typings/micropdf417/error-correction.d.ts +38 -0
  59. package/typings/micropdf417/index.d.ts +36 -0
  60. package/typings/micropdf417/tables.d.ts +73 -0
  61. package/typings/microqr/decoder.d.ts +49 -0
  62. package/typings/microqr/detector.d.ts +96 -0
  63. package/typings/microqr/encoder.d.ts +33 -0
  64. package/typings/microqr/index.d.ts +35 -0
  65. package/typings/microqr/tables.d.ts +107 -0
  66. package/typings/oned/addons.d.ts +181 -0
  67. package/typings/oned/index.d.ts +55 -0
  68. package/typings/oned/patterns.d.ts +259 -0
  69. package/typings/oned/reader.d.ts +129 -0
  70. package/typings/oned/writers.d.ts +218 -0
  71. package/typings/pdf417/compaction.d.ts +59 -0
  72. package/typings/pdf417/decoder.d.ts +48 -0
  73. package/typings/pdf417/detector.d.ts +73 -0
  74. package/typings/pdf417/encoder.d.ts +32 -0
  75. package/typings/pdf417/error-correction.d.ts +34 -0
  76. package/typings/pdf417/index.d.ts +10 -0
  77. package/typings/pdf417/tables.d.ts +53 -0
  78. package/typings/qr/decoder.d.ts +79 -0
  79. package/typings/qr/detector.d.ts +93 -0
  80. package/typings/qr/encoder.d.ts +166 -0
  81. package/typings/qr/index.d.ts +43 -0
  82. package/typings/qr/tables.d.ts +291 -0
  83. package/typings/render/image-data.d.ts +58 -0
  84. package/typings/render/index.d.ts +110 -0
  85. package/typings/render/options.d.ts +98 -0
  86. package/typings/render/png.d.ts +58 -0
  87. package/typings/render/svg.d.ts +46 -0
  88. package/typings/render/webgl.d.ts +45 -0
  89. package/typings/render/webgpu.d.ts +51 -0
  90. package/typings/rmqr/decoder.d.ts +42 -0
  91. package/typings/rmqr/detector.d.ts +81 -0
  92. package/typings/rmqr/encoder.d.ts +45 -0
  93. package/typings/rmqr/index.d.ts +34 -0
  94. package/typings/rmqr/tables.d.ts +89 -0
@@ -0,0 +1,84 @@
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
+ /** PDF417 start pattern, in module widths. */
32
+ export declare const COMPACT_PDF417_START = "81111113";
33
+ /** Binary module representation of the start pattern. */
34
+ export declare const COMPACT_PDF417_START_BITS = "11111111010101000";
35
+ /** Compact PDF417's reduced stop is one dark module. */
36
+ export declare const COMPACT_PDF417_STOP_MODULES = 1;
37
+ /** Minimum/maximum number of rows and data columns. */
38
+ export declare const COMPACT_PDF417_LIMITS: Readonly<{
39
+ minRows: 3;
40
+ maxRows: 90;
41
+ minColumns: 1;
42
+ maxColumns: 30;
43
+ maxCodewords: 928;
44
+ }>;
45
+ /**
46
+ * Return the printed width in modules for a compact symbol.
47
+ *
48
+ * 17 start + 17 left indicator + 17 per codeword column + 1 reduced stop.
49
+ * @param {number} columns
50
+ */
51
+ export declare function compactPdf417Width(columns: number): number;
52
+ /**
53
+ * Validate a compact matrix geometry and return its dimensions.
54
+ *
55
+ * @param {number} width
56
+ * @param {number} height
57
+ * @param {number} rowHeight
58
+ */
59
+ export declare function compactPdf417Geometry(width: number, height: number, rowHeight?: number): {
60
+ rows: number;
61
+ columns: number;
62
+ rowHeight: number;
63
+ width: number;
64
+ height: number;
65
+ };
66
+ /**
67
+ * Validate encoder dimensions before codeword packing.
68
+ * @param {object} options
69
+ */
70
+ export declare function validateCompactPdf417Options(options?: object): any;
71
+ /**
72
+ * The row indicator values used by ordinary PDF417 are retained unchanged.
73
+ * Compact symbols omit only the right indicator, so the left indicator still
74
+ * carries the row group, row count, error-correction level and column count.
75
+ */
76
+ export declare function compactPdf417Indicators(row: any, rows: any, columns: any, level: any): number;
77
+ /**
78
+ * Return all standard ECC levels which agree with the observed left
79
+ * indicators. This is kept as a table helper so decoder and tests share the
80
+ * same compact-layout rule.
81
+ */
82
+ export declare function compactPdf417MatchingLevels(leftIndicators: any, rows: any, columns: any): number[];
83
+ /** Validate representative layout invariants. */
84
+ export declare function validateCompactPdf417Tables(): string[];
@@ -0,0 +1,78 @@
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
+ /** Growable MSB-first bit writer. */
32
+ export declare class BitWriter {
33
+ /** @type {number[]} Packed bytes; the last one may be partially filled. */
34
+ bytes: number[];
35
+ bitLength: number;
36
+ constructor();
37
+ /** @returns {number} Bits written so far. */
38
+ get length(): number;
39
+ /**
40
+ * Append the low `count` bits of `value`, most significant first.
41
+ *
42
+ * @param {number} value
43
+ * @param {number} count
44
+ */
45
+ put(value: number, count: number): void;
46
+ /** @param {boolean} bit */
47
+ putBit(bit: boolean): void;
48
+ /** @param {ArrayLike<number>} data */
49
+ putBytes(data: ArrayLike<number>): void;
50
+ /** Pad with zero bits until the length is a multiple of 8. */
51
+ padToByte(): void;
52
+ /**
53
+ * @returns {Uint8Array} Byte view; trailing bits of the final byte are zero.
54
+ */
55
+ toBytes(): Uint8Array;
56
+ /** @returns {string} Debug view, e.g. "0100 0011 0101". */
57
+ toString(): string;
58
+ }
59
+ /** MSB-first bit reader over a byte array. */
60
+ export declare class BitReader {
61
+ bytes: ArrayLike<number>;
62
+ byteOffset: number;
63
+ bitOffset: number;
64
+ /** @param {ArrayLike<number>} bytes */
65
+ constructor(bytes: ArrayLike<number>);
66
+ /** @returns {number} Bits not yet consumed. */
67
+ available(): number;
68
+ /**
69
+ * Read `count` bits (1..32) as an unsigned integer, most significant first.
70
+ *
71
+ * @param {number} count
72
+ * @returns {number}
73
+ * @throws {FormatError} If the stream is exhausted.
74
+ */
75
+ read(count: number): number;
76
+ /** @returns {boolean} */
77
+ readBit(): boolean;
78
+ }
@@ -0,0 +1,129 @@
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
+ * A 2D bit grid — the common currency of this library.
33
+ *
34
+ * Every writer produces one; every reader consumes one; every renderer draws
35
+ * one. Keeping it as the single interchange type is what lets formats and
36
+ * output targets stay independent of each other.
37
+ *
38
+ * Storage is row-packed into a Uint32Array: one allocation, cache-friendly row
39
+ * scans, and cheap whole-row operations for the 1D readers.
40
+ *
41
+ * Convention: a set bit is a DARK module (ink). This matches how symbols are
42
+ * described in every specification, and renderers invert as needed.
43
+ *
44
+ * @module core/bit-matrix
45
+ */
46
+ export declare class BitMatrix {
47
+ width: number;
48
+ height: number;
49
+ rowWords: number;
50
+ bits: Uint32Array<ArrayBuffer>;
51
+ /**
52
+ * @param {number} width
53
+ * @param {number} height
54
+ */
55
+ constructor(width: number, height?: number);
56
+ /**
57
+ * @param {number} x @param {number} y
58
+ * @returns {boolean} True if the module is dark.
59
+ */
60
+ get(x: number, y: number): boolean;
61
+ /** @param {number} x @param {number} y */
62
+ set(x: number, y: number): void;
63
+ /** @param {number} x @param {number} y */
64
+ unset(x: number, y: number): void;
65
+ /** @param {number} x @param {number} y */
66
+ flip(x: number, y: number): void;
67
+ /**
68
+ * @param {number} x @param {number} y @param {boolean} value
69
+ */
70
+ setValue(x: number, y: number, value: boolean): void;
71
+ /** Fill a rectangle. @param {number} x @param {number} y @param {number} w @param {number} h */
72
+ setRegion(x: number, y: number, w: number, h: number): void;
73
+ clear(): void;
74
+ /** @returns {BitMatrix} */
75
+ clone(): BitMatrix;
76
+ /**
77
+ * Copy row `y` into a reusable array, avoiding an allocation per row in the
78
+ * 1D scanning loops which run this thousands of times per image.
79
+ *
80
+ * @param {number} y
81
+ * @param {Uint8Array} [out]
82
+ * @returns {Uint8Array}
83
+ */
84
+ getRow(y: number, out?: Uint8Array): Uint8Array;
85
+ /**
86
+ * Add a uniform light border. Symbols need a quiet zone to be scannable at
87
+ * all, so this is applied by default when rendering.
88
+ *
89
+ * @param {number} size Modules of margin on every side.
90
+ * @returns {BitMatrix}
91
+ */
92
+ withMargin(size: number): BitMatrix;
93
+ /**
94
+ * Nearest-neighbour upscale. Integer factors only — a barcode resampled with
95
+ * interpolation stops being readable.
96
+ *
97
+ * @param {number} factor
98
+ * @returns {BitMatrix}
99
+ */
100
+ scale(factor: number): BitMatrix;
101
+ /**
102
+ * Bounding box of the dark modules, or null if the matrix is empty.
103
+ * @returns {{x: number, y: number, width: number, height: number} | null}
104
+ */
105
+ getBounds(): {
106
+ x: number;
107
+ y: number;
108
+ width: number;
109
+ height: number;
110
+ } | null;
111
+ /**
112
+ * Rotate 180 degrees, in place. Cheaper than re-detecting when a reader
113
+ * discovers a symbol is upside down.
114
+ */
115
+ rotate180(): void;
116
+ /**
117
+ * Build from a string of '1'/'X'/'#' (dark) and anything else (light),
118
+ * newline-separated. Test fixtures are far more legible this way.
119
+ *
120
+ * @param {string} text
121
+ * @returns {BitMatrix}
122
+ */
123
+ static parse(text: string): BitMatrix;
124
+ /**
125
+ * @param {string} [dark] @param {string} [light]
126
+ * @returns {string}
127
+ */
128
+ toString(dark?: string, light?: string): string;
129
+ }
@@ -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
+ * Error types.
33
+ *
34
+ * Decoding uses exceptions for control flow internally: a detector that fails
35
+ * on one candidate should be cheap to abandon, and a `try` around a candidate
36
+ * loop reads better than threading `null` through six call frames. The public
37
+ * API converts them to results.
38
+ *
39
+ * @module core/errors
40
+ */
41
+ /** Base class so consumers can `catch (e) { if (e instanceof BarcodeError) ... }`. */
42
+ export declare class BarcodeError extends Error {
43
+ /** @param {string} message */
44
+ constructor(message: string);
45
+ }
46
+ /** Input could not be encoded — bad payload, or it does not fit the symbology. */
47
+ export declare class EncodeError extends BarcodeError {
48
+ }
49
+ /** No symbol was found in the image. Not an error condition for `decode()`. */
50
+ export declare class NotFoundError extends BarcodeError {
51
+ }
52
+ /** A symbol was found, but its geometry or content is malformed. */
53
+ export declare class FormatError extends BarcodeError {
54
+ }
55
+ /** A symbol was found and read, but error correction could not repair it. */
56
+ export declare class ChecksumError extends BarcodeError {
57
+ }
@@ -0,0 +1,141 @@
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
+ * Finite field arithmetic.
33
+ *
34
+ * One class serves every field this suite needs:
35
+ *
36
+ * GF(2^4) Aztec, small layer counts
37
+ * GF(2^6) Aztec
38
+ * GF(2^8) QR Code, Data Matrix, Aztec
39
+ * GF(2^10) Aztec
40
+ * GF(2^12) Aztec
41
+ * GF(929) PDF417 <- a PRIME field, not a binary one
42
+ *
43
+ * ## The prime-field trap
44
+ *
45
+ * Multiplication unifies cleanly: exp/log tables work for the multiplicative
46
+ * group of any finite field. Addition does NOT.
47
+ *
48
+ * binary GF(2^m): a + b == a - b == a XOR b (self-inverse)
49
+ * prime GF(p): a + b == (a+b) % p
50
+ * a - b == (a-b+p) % p (NOT self-inverse)
51
+ *
52
+ * So `add`, `sub` and `neg` are methods on the field, never inlined. Any code
53
+ * that writes a bare `^` for field arithmetic works perfectly for every binary
54
+ * field and silently corrupts PDF417 — the failure is invisible until a real
55
+ * scanner rejects the symbol. Route every operation through the field object.
56
+ *
57
+ * @module core/galois-field
58
+ */
59
+ export declare class GaloisField {
60
+ size: number;
61
+ prime: boolean;
62
+ primitive: number;
63
+ generator: number;
64
+ name: string;
65
+ /** Multiplicative order: every non-zero element is generator^i for some i < order. */
66
+ order: number;
67
+ expTable: Int32Array<ArrayBuffer>;
68
+ logTable: Int32Array<ArrayBuffer>;
69
+ /**
70
+ * @param {object} opts
71
+ * @param {number} opts.size Field order: 2^m for binary, p for prime.
72
+ * @param {boolean} [opts.prime] True for a prime field (mod arithmetic).
73
+ * @param {number} [opts.primitive] Primitive polynomial, binary fields only.
74
+ * @param {number} [opts.generator] Multiplicative generator. Defaults to 2
75
+ * for binary fields (x), and must be given explicitly for prime fields.
76
+ * @param {string} [opts.name]
77
+ */
78
+ constructor({ size, prime, primitive, generator, name }: {
79
+ size: number;
80
+ prime?: boolean;
81
+ primitive?: number;
82
+ generator?: number;
83
+ name?: string;
84
+ });
85
+ /** Additive identity is 0 and multiplicative identity is 1 in every field here. */
86
+ get zero(): number;
87
+ get one(): number;
88
+ /**
89
+ * a + b.
90
+ * @param {number} a @param {number} b @returns {number}
91
+ */
92
+ add(a: number, b: number): number;
93
+ /**
94
+ * a - b. Distinct from add() in prime fields — see the module note.
95
+ * @param {number} a @param {number} b @returns {number}
96
+ */
97
+ sub(a: number, b: number): number;
98
+ /**
99
+ * -a.
100
+ * @param {number} a @returns {number}
101
+ */
102
+ neg(a: number): number;
103
+ /**
104
+ * a * b.
105
+ * @param {number} a @param {number} b @returns {number}
106
+ */
107
+ mul(a: number, b: number): number;
108
+ /**
109
+ * a / b.
110
+ * @param {number} a @param {number} b @returns {number}
111
+ */
112
+ div(a: number, b: number): number;
113
+ /**
114
+ * 1 / a.
115
+ * @param {number} a @returns {number}
116
+ */
117
+ inv(a: number): number;
118
+ /**
119
+ * generator^i, for any integer i (negative included).
120
+ * @param {number} i @returns {number}
121
+ */
122
+ exp(i: number): number;
123
+ /**
124
+ * Discrete log base generator.
125
+ * @param {number} a @returns {number}
126
+ */
127
+ log(a: number): number;
128
+ }
129
+ /** QR Code, Data Matrix uses its own — see below. x^8 + x^4 + x^3 + x^2 + 1 */
130
+ export declare const GF256_QR: GaloisField;
131
+ /** Data Matrix ECC200. x^8 + x^5 + x^3 + x^2 + 1 */
132
+ export declare const GF256_DM: GaloisField;
133
+ /** Aztec's eight-bit data field is algebraically identical to Data Matrix's. */
134
+ export declare const GF256_AZTEC: GaloisField;
135
+ /** PDF417. Prime field; 3 is a primitive root modulo 929. */
136
+ export declare const GF929: GaloisField;
137
+ /** Aztec, by layer count. */
138
+ export declare const GF16: GaloisField;
139
+ export declare const GF64: GaloisField;
140
+ export declare const GF1024: GaloisField;
141
+ export declare const GF4096: GaloisField;
@@ -0,0 +1,40 @@
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
+ * Core primitives, re-exported.
33
+ *
34
+ * @module core
35
+ */
36
+ export { BitMatrix } from './bit-matrix.js';
37
+ export { BitWriter, BitReader } from './bit-buffer.js';
38
+ export { GaloisField, GF256_QR, GF256_DM, GF929, GF16, GF64, GF1024, GF4096, } from './galois-field.js';
39
+ export { rsEncode, rsDecode, generatorPoly } from './reed-solomon.js';
40
+ export { BarcodeError, EncodeError, NotFoundError, FormatError, ChecksumError, } from './errors.js';
@@ -0,0 +1,65 @@
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
+ * Build the generator polynomial for `eccLen` parity symbols.
33
+ *
34
+ * g(x) = product over i of (x - a^(base + i)), i = 0 .. eccLen-1
35
+ *
36
+ * `base` is 0 for QR; 1 for Aztec, Data Matrix and PDF417.
37
+ *
38
+ * @param {number} eccLen
39
+ * @param {import('./galois-field.js').GaloisField} field
40
+ * @param {number} [base]
41
+ * @returns {number[]} Monic, degree-descending, length eccLen + 1.
42
+ */
43
+ export declare function generatorPoly(eccLen: number, field: import('./galois-field.js').GaloisField, base?: number): number[];
44
+ /**
45
+ * Compute `eccLen` parity symbols for `data`.
46
+ *
47
+ * @param {ArrayLike<number>} data
48
+ * @param {number} eccLen
49
+ * @param {import('./galois-field.js').GaloisField} field
50
+ * @param {number} [base]
51
+ * @returns {number[]} The parity symbols alone, length eccLen.
52
+ */
53
+ export declare function rsEncode(data: ArrayLike<number>, eccLen: number, field: import('./galois-field.js').GaloisField, base?: number): number[];
54
+ /**
55
+ * Correct errors in a received codeword, in place.
56
+ *
57
+ * @param {number[]} received Data followed by parity, degree-descending.
58
+ * @param {number} eccLen
59
+ * @param {import('./galois-field.js').GaloisField} field
60
+ * @param {number} [base]
61
+ * @param {number[]} [erasures] Known damaged indexes, counted from wire order.
62
+ * @returns {number} Number of symbols corrected.
63
+ * @throws {ChecksumError} If the damage exceeds the correction capacity.
64
+ */
65
+ export declare function rsDecode(received: number[], eccLen: number, field: import('./galois-field.js').GaloisField, base?: number, erasures?: number[]): number;
@@ -0,0 +1,78 @@
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
+ /** Calculate the GS1 modulo-10 check digit for a GTIN body. */
32
+ export declare function gtinCheckDigit(body: any): string;
33
+ /** Return a checked 14-digit GTIN, preserving only its standardized digits. */
34
+ export declare function normalizeGTIN(value: any): string;
35
+ /** Build a checked GTIN-14 from its thirteen-digit data body. */
36
+ export declare function makeGTIN14(body: any): string;
37
+ /**
38
+ * Compact a GTIN into the four values shared by Omnidirectional, Truncated,
39
+ * Stacked and Stacked Omnidirectional. The `physicalCharacters` sequence is
40
+ * left-to-right on a linear DataBar-14 row: 1, 2, 4, 3.
41
+ */
42
+ export declare function encodeDataBar14GTIN(value: any, options?: {}): Readonly<{
43
+ gtin: string;
44
+ linkage: boolean;
45
+ symbolValue: bigint;
46
+ leftPair: bigint;
47
+ rightPair: bigint;
48
+ logicalCharacters: Readonly<{
49
+ outerLeft: number;
50
+ innerLeft: number;
51
+ outerRight: number;
52
+ innerRight: number;
53
+ }>;
54
+ physicalCharacters: readonly number[];
55
+ }>;
56
+ /** Reconstruct and validate a GTIN from the four DataBar-14 character values. */
57
+ export declare function decodeDataBar14GTIN(values: any): Readonly<{
58
+ linkage: boolean;
59
+ gtin: string;
60
+ leftPair: bigint;
61
+ rightPair: bigint;
62
+ }>;
63
+ /** Compact a DataBar Limited-eligible GTIN into its two data character values. */
64
+ export declare function encodeDataBarLimitedGTIN(value: any, options?: {}): Readonly<{
65
+ gtin: string;
66
+ linkage: boolean;
67
+ symbolValue: bigint;
68
+ left: number;
69
+ right: number;
70
+ }>;
71
+ /** Reconstruct and validate a GTIN from DataBar Limited data character values. */
72
+ export declare function decodeDataBarLimitedGTIN(values: any): Readonly<{
73
+ linkage: boolean;
74
+ gtin: string;
75
+ symbolValue: bigint;
76
+ }>;
77
+ /** GS1 transmitted form for the GTIN-only DataBar variants. */
78
+ export declare function dataBarGtinTransmission(value: any): string;