@sythos/js_barcode_universal 1.5.6 → 1.5.8

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 (180) hide show
  1. package/NOTICE.md +1 -1
  2. package/README.md +55 -35
  3. package/bundle/sythos-barcode.esm.js +618 -465
  4. package/bundle/sythos-barcode.js +618 -465
  5. package/package.json +90 -24
  6. package/src/index.d.ts +363 -0
  7. package/src/index.js +286 -133
  8. package/src/{aztec → js/aztec}/decoder.js +0 -1
  9. package/src/{aztec → js/aztec}/detector.js +0 -1
  10. package/src/{aztec → js/aztec}/encoder.js +0 -1
  11. package/src/{aztec → js/aztec}/high-level.js +0 -1
  12. package/src/{aztec → js/aztec}/index.js +0 -1
  13. package/src/{aztec → js/aztec}/tables.js +0 -1
  14. package/src/{aztecrune → js/aztecrune}/decoder.js +0 -1
  15. package/src/{aztecrune → js/aztecrune}/detector.js +0 -1
  16. package/src/{aztecrune → js/aztecrune}/encoder.js +0 -1
  17. package/src/{aztecrune → js/aztecrune}/index.js +0 -1
  18. package/src/{aztecrune → js/aztecrune}/tables.js +0 -1
  19. package/src/{compactpdf417 → js/compactpdf417}/decoder.js +0 -1
  20. package/src/{compactpdf417 → js/compactpdf417}/detector.js +0 -1
  21. package/src/{compactpdf417 → js/compactpdf417}/encoder.js +0 -1
  22. package/src/{compactpdf417 → js/compactpdf417}/index.js +0 -5
  23. package/src/{compactpdf417 → js/compactpdf417}/tables.js +0 -1
  24. package/src/{core → js/core}/bit-buffer.js +0 -1
  25. package/src/{core → js/core}/bit-matrix.js +0 -1
  26. package/src/{core → js/core}/errors.js +0 -1
  27. package/src/{core → js/core}/galois-field.js +0 -1
  28. package/src/{core → js/core}/index.js +0 -1
  29. package/src/{core → js/core}/reed-solomon.js +0 -1
  30. package/src/{databar → js/databar}/codec.js +0 -1
  31. package/src/{databar → js/databar}/decoder.js +0 -1
  32. package/src/{databar → js/databar}/encoder.js +0 -1
  33. package/src/{databar → js/databar}/gs1.js +0 -1
  34. package/src/{databar → js/databar}/index.js +0 -1
  35. package/src/{databar → js/databar}/patterns.js +0 -1
  36. package/src/{databar → js/databar}/tables.js +0 -1
  37. package/src/{datamatrix → js/datamatrix}/decoder.js +0 -1
  38. package/src/{datamatrix → js/datamatrix}/detector.js +0 -1
  39. package/src/{datamatrix → js/datamatrix}/encoder.js +0 -1
  40. package/src/{datamatrix → js/datamatrix}/index.js +0 -1
  41. package/src/{datamatrix → js/datamatrix}/tables.js +0 -1
  42. package/src/{frameqr → js/frameqr}/decoder.js +15 -16
  43. package/src/{frameqr → js/frameqr}/detector.js +2 -3
  44. package/src/{frameqr → js/frameqr}/encoder.js +7 -8
  45. package/src/{frameqr → js/frameqr}/index.js +0 -1
  46. package/src/{frameqr → js/frameqr}/tables.js +10 -11
  47. package/src/{image → js/image}/binarizer.js +0 -1
  48. package/src/{image → js/image}/grid-sampler.js +0 -1
  49. package/src/js/image/index.js +40 -0
  50. package/src/{image → js/image}/luminance.js +0 -1
  51. package/src/{image → js/image}/perspective.js +0 -1
  52. package/src/{micropdf417 → js/micropdf417}/compaction.js +0 -1
  53. package/src/{micropdf417 → js/micropdf417}/decoder.js +0 -1
  54. package/src/{micropdf417 → js/micropdf417}/detector.js +0 -1
  55. package/src/{micropdf417 → js/micropdf417}/encoder.js +0 -1
  56. package/src/{micropdf417 → js/micropdf417}/error-correction.js +0 -1
  57. package/src/{micropdf417 → js/micropdf417}/index.js +0 -1
  58. package/src/{micropdf417 → js/micropdf417}/tables.js +0 -1
  59. package/src/{microqr → js/microqr}/decoder.js +0 -1
  60. package/src/{microqr → js/microqr}/detector.js +0 -1
  61. package/src/{microqr → js/microqr}/encoder.js +0 -1
  62. package/src/js/microqr/index.js +36 -0
  63. package/src/{microqr → js/microqr}/tables.js +0 -1
  64. package/src/{oned → js/oned}/addons.js +0 -1
  65. package/src/{oned → js/oned}/index.js +0 -1
  66. package/src/{oned → js/oned}/patterns.js +0 -1
  67. package/src/{oned → js/oned}/reader.js +0 -1
  68. package/src/{oned → js/oned}/writers.js +0 -1
  69. package/src/{pdf417 → js/pdf417}/compaction.js +0 -1
  70. package/src/{pdf417 → js/pdf417}/decoder.js +0 -1
  71. package/src/{pdf417 → js/pdf417}/detector.js +0 -1
  72. package/src/{pdf417 → js/pdf417}/encoder.js +0 -1
  73. package/src/{pdf417 → js/pdf417}/error-correction.js +0 -1
  74. package/src/js/pdf417/index.js +6 -0
  75. package/src/{pdf417 → js/pdf417}/tables.js +0 -1
  76. package/src/{qr → js/qr}/decoder.js +0 -1
  77. package/src/{qr → js/qr}/detector.js +0 -1
  78. package/src/{qr → js/qr}/encoder.js +0 -1
  79. package/src/js/qr/index.js +44 -0
  80. package/src/{qr → js/qr}/tables.js +0 -1
  81. package/src/{render → js/render}/image-data.js +0 -1
  82. package/src/{render → js/render}/index.js +0 -1
  83. package/src/{render → js/render}/options.js +0 -1
  84. package/src/{render → js/render}/png.js +0 -1
  85. package/src/{render → js/render}/svg.js +0 -1
  86. package/src/{render → js/render}/webgl.js +0 -1
  87. package/src/{render → js/render}/webgpu.js +0 -1
  88. package/src/{rmqr → js/rmqr}/decoder.js +0 -1
  89. package/src/{rmqr → js/rmqr}/detector.js +0 -1
  90. package/src/{rmqr → js/rmqr}/encoder.js +0 -1
  91. package/src/{rmqr → js/rmqr}/index.js +0 -1
  92. package/src/{rmqr → js/rmqr}/tables.js +0 -1
  93. package/src/ts/aztec/decoder.d.ts +57 -0
  94. package/src/ts/aztec/detector.d.ts +62 -0
  95. package/src/ts/aztec/encoder.d.ts +94 -0
  96. package/src/ts/aztec/high-level.d.ts +89 -0
  97. package/src/ts/aztec/index.d.ts +35 -0
  98. package/src/ts/aztec/tables.d.ts +144 -0
  99. package/src/ts/aztecrune/decoder.d.ts +56 -0
  100. package/src/ts/aztecrune/detector.d.ts +53 -0
  101. package/src/ts/aztecrune/encoder.d.ts +51 -0
  102. package/src/ts/aztecrune/index.d.ts +35 -0
  103. package/src/ts/aztecrune/tables.d.ts +75 -0
  104. package/src/ts/bundle/sythos-barcode.d.ts +31 -0
  105. package/src/ts/bundle/sythos-barcode.esm.d.ts +31 -0
  106. package/src/ts/compactpdf417/decoder.d.ts +64 -0
  107. package/src/ts/compactpdf417/detector.d.ts +48 -0
  108. package/src/ts/compactpdf417/encoder.d.ts +49 -0
  109. package/src/ts/compactpdf417/index.d.ts +8 -0
  110. package/src/ts/compactpdf417/tables.d.ts +84 -0
  111. package/src/ts/core/bit-buffer.d.ts +78 -0
  112. package/src/ts/core/bit-matrix.d.ts +129 -0
  113. package/src/ts/core/errors.d.ts +57 -0
  114. package/src/ts/core/galois-field.d.ts +141 -0
  115. package/src/ts/core/index.d.ts +40 -0
  116. package/src/ts/core/reed-solomon.d.ts +65 -0
  117. package/src/ts/databar/codec.d.ts +78 -0
  118. package/src/ts/databar/decoder.d.ts +55 -0
  119. package/src/ts/databar/encoder.d.ts +34 -0
  120. package/src/ts/databar/gs1.d.ts +48 -0
  121. package/src/ts/databar/index.d.ts +37 -0
  122. package/src/ts/databar/patterns.d.ts +46 -0
  123. package/src/ts/databar/tables.d.ts +119 -0
  124. package/src/ts/datamatrix/decoder.d.ts +57 -0
  125. package/src/ts/datamatrix/detector.d.ts +59 -0
  126. package/src/ts/datamatrix/encoder.d.ts +36 -0
  127. package/src/ts/datamatrix/index.d.ts +35 -0
  128. package/src/ts/datamatrix/tables.d.ts +88 -0
  129. package/src/ts/frameqr/decoder.d.ts +64 -0
  130. package/src/ts/frameqr/detector.d.ts +96 -0
  131. package/src/ts/frameqr/encoder.d.ts +73 -0
  132. package/src/ts/frameqr/index.d.ts +34 -0
  133. package/src/ts/frameqr/tables.d.ts +123 -0
  134. package/src/ts/image/binarizer.d.ts +85 -0
  135. package/src/ts/image/grid-sampler.d.ts +82 -0
  136. package/src/{image/index.js → ts/image/index.d.ts} +0 -2
  137. package/src/ts/image/luminance.d.ts +112 -0
  138. package/src/ts/image/perspective.d.ts +111 -0
  139. package/src/ts/index.d.ts +363 -0
  140. package/src/ts/micropdf417/compaction.d.ts +38 -0
  141. package/src/ts/micropdf417/decoder.d.ts +57 -0
  142. package/src/ts/micropdf417/detector.d.ts +95 -0
  143. package/src/ts/micropdf417/encoder.d.ts +34 -0
  144. package/src/ts/micropdf417/error-correction.d.ts +38 -0
  145. package/src/ts/micropdf417/index.d.ts +36 -0
  146. package/src/ts/micropdf417/tables.d.ts +73 -0
  147. package/src/ts/microqr/decoder.d.ts +49 -0
  148. package/src/ts/microqr/detector.d.ts +96 -0
  149. package/src/ts/microqr/encoder.d.ts +33 -0
  150. package/src/{microqr/index.js → ts/microqr/index.d.ts} +0 -2
  151. package/src/ts/microqr/tables.d.ts +107 -0
  152. package/src/ts/oned/addons.d.ts +181 -0
  153. package/src/ts/oned/index.d.ts +55 -0
  154. package/src/ts/oned/patterns.d.ts +259 -0
  155. package/src/ts/oned/reader.d.ts +129 -0
  156. package/src/ts/oned/writers.d.ts +218 -0
  157. package/src/ts/pdf417/compaction.d.ts +59 -0
  158. package/src/ts/pdf417/decoder.d.ts +48 -0
  159. package/src/ts/pdf417/detector.d.ts +73 -0
  160. package/src/ts/pdf417/encoder.d.ts +32 -0
  161. package/src/ts/pdf417/error-correction.d.ts +34 -0
  162. package/src/{pdf417/index.js → ts/pdf417/index.d.ts} +0 -1
  163. package/src/ts/pdf417/tables.d.ts +53 -0
  164. package/src/ts/qr/decoder.d.ts +79 -0
  165. package/src/ts/qr/detector.d.ts +93 -0
  166. package/src/ts/qr/encoder.d.ts +166 -0
  167. package/src/{qr/index.js → ts/qr/index.d.ts} +0 -2
  168. package/src/ts/qr/tables.d.ts +291 -0
  169. package/src/ts/render/image-data.d.ts +58 -0
  170. package/src/ts/render/index.d.ts +110 -0
  171. package/src/ts/render/options.d.ts +98 -0
  172. package/src/ts/render/png.d.ts +58 -0
  173. package/src/ts/render/svg.d.ts +46 -0
  174. package/src/ts/render/webgl.d.ts +45 -0
  175. package/src/ts/render/webgpu.d.ts +51 -0
  176. package/src/ts/rmqr/decoder.d.ts +42 -0
  177. package/src/ts/rmqr/detector.d.ts +81 -0
  178. package/src/ts/rmqr/encoder.d.ts +45 -0
  179. package/src/ts/rmqr/index.d.ts +34 -0
  180. package/src/ts/rmqr/tables.d.ts +89 -0
@@ -0,0 +1,181 @@
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
+ * UPC/EAN two- and five-digit supplements.
33
+ *
34
+ * Supplements are small symbols printed to the right of an EAN/UPC symbol.
35
+ * They use the ordinary EAN odd/even digit patterns, a 1011 start guard and
36
+ * 01 separators between digits. EAN-2 selects its parity from the numeric
37
+ * value modulo four. EAN-5 derives a checksum from the five digits and uses
38
+ * that value to select one of ten parity rows.
39
+ *
40
+ * This module intentionally keeps supplements separate from the base EAN/UPC
41
+ * writers. `composeEANAddon` and the `*WithAddon` helpers are opt-in; existing
42
+ * EAN/UPC APIs continue to return their original one-row matrices unchanged.
43
+ *
44
+ * @module oned/addons
45
+ */
46
+ import { BitMatrix } from '../core/bit-matrix.js';
47
+ /** EAN-2 parity rows, indexed by the two-digit value modulo four. */
48
+ export declare const EAN2_PARITY: readonly string[];
49
+ /** EAN-5 parity rows, indexed by the supplemental checksum. */
50
+ export declare const EAN5_PARITY: readonly string[];
51
+ /** Start guard used by both UPC/EAN supplemental symbols. */
52
+ export declare const EAN_ADDON_START = "1011";
53
+ /** Separator inserted between adjacent supplemental digits. */
54
+ export declare const EAN_ADDON_SEPARATOR = "01";
55
+ export declare const EAN2_WIDTH: number;
56
+ export declare const EAN5_WIDTH: number;
57
+ /**
58
+ * EAN-5 supplemental checksum.
59
+ *
60
+ * The first, third and fifth digits carry weight three; the second and fourth
61
+ * carry weight nine. The checksum is not printed as a sixth digit: it selects
62
+ * the odd/even parity row for the five encoded digits.
63
+ *
64
+ * @param {string|number} value Five digits.
65
+ * @returns {number} Checksum value, 0-9.
66
+ */
67
+ export declare function ean5Checksum(value: string | number): number;
68
+ /** Alias for callers that use the EAN family check-digit terminology. */
69
+ export declare const ean5CheckDigit: typeof ean5Checksum;
70
+ /**
71
+ * Resolve the EAN-2 parity row for a payload.
72
+ *
73
+ * @param {string|number} value Two digits.
74
+ * @returns {string} Two-character A/B parity row.
75
+ */
76
+ export declare function ean2Parity(value: string | number): string;
77
+ /**
78
+ * Resolve the EAN-5 parity row for a payload.
79
+ *
80
+ * @param {string|number} value Five digits.
81
+ * @returns {string} Five-character A/B parity row.
82
+ */
83
+ export declare function ean5Parity(value: string | number): string;
84
+ /**
85
+ * Encode an EAN-2 supplement.
86
+ *
87
+ * @param {string|number} value Exactly two decimal digits.
88
+ * @returns {BitMatrix} A 20-module, one-row supplement.
89
+ */
90
+ export declare function encodeEAN2(value: string | number): BitMatrix;
91
+ /**
92
+ * Encode an EAN-5 supplement.
93
+ *
94
+ * @param {string|number} value Exactly five decimal digits.
95
+ * @returns {BitMatrix} A 47-module, one-row supplement.
96
+ */
97
+ export declare function encodeEAN5(value: string | number): BitMatrix;
98
+ /**
99
+ * Encode either supported supplement length.
100
+ *
101
+ * @param {string|number} value Two or five decimal digits.
102
+ * @returns {BitMatrix}
103
+ */
104
+ export declare function encodeEANAddon(value: string | number): BitMatrix;
105
+ /** Alias using the spelling used by some EAN documentation. */
106
+ export declare const encodeEANAddOn: typeof encodeEANAddon;
107
+ /**
108
+ * Validate and decode an EAN-2 supplement. A leading quiet zone is accepted;
109
+ * the decoder searches the row for a valid start guard so a composed base
110
+ * EAN/UPC matrix can be passed directly as well.
111
+ *
112
+ * @param {BitMatrix} matrix One-row, module-aligned supplement or composition.
113
+ * @returns {{format:'ean2',text:string,parity:string}}
114
+ * @throws {FormatError} When no valid supplement is found.
115
+ */
116
+ export declare function decodeEAN2(matrix: BitMatrix): {
117
+ format: 'ean2';
118
+ text: string;
119
+ parity: string;
120
+ };
121
+ /**
122
+ * Validate and decode an EAN-5 supplement.
123
+ *
124
+ * @param {BitMatrix} matrix One-row, module-aligned supplement or composition.
125
+ * @returns {{format:'ean5',text:string,parity:string,checksum:number}}
126
+ * @throws {FormatError} When no valid supplement is found.
127
+ */
128
+ export declare function decodeEAN5(matrix: BitMatrix): {
129
+ format: 'ean5';
130
+ text: string;
131
+ parity: string;
132
+ checksum: number;
133
+ };
134
+ /**
135
+ * Decode either supported supplement length.
136
+ *
137
+ * @param {BitMatrix} matrix One-row, module-aligned supplement or composition.
138
+ * @returns {{format:'ean2'|'ean5',text:string,parity:string,checksum?:number}}
139
+ * @throws {FormatError} When neither supplement grammar matches.
140
+ */
141
+ export declare function decodeEANAddon(matrix: BitMatrix): {
142
+ format: 'ean2' | 'ean5';
143
+ text: string;
144
+ parity: string;
145
+ checksum?: number;
146
+ };
147
+ /** Alias using the spelling used by some EAN documentation. */
148
+ export declare const decodeEANAddOn: typeof decodeEANAddon;
149
+ /**
150
+ * Join a base EAN/UPC matrix and a supplement with the standard quiet gap.
151
+ *
152
+ * The helper does not alter either input. By default it inserts nine light
153
+ * modules, the conventional separation between the base symbol and an add-on.
154
+ * The result carries the supplement metadata under `eanAddon` for renderers or
155
+ * callers that need to label the composed symbol.
156
+ *
157
+ * @param {BitMatrix} base Base EAN/UPC matrix.
158
+ * @param {BitMatrix|string|number} addon Add-on matrix or two/five digits.
159
+ * @param {{gap?:number}} [options]
160
+ * @returns {BitMatrix}
161
+ */
162
+ export declare function composeEANAddon(base: BitMatrix, addon: BitMatrix | string | number, options?: {
163
+ gap?: number;
164
+ }): BitMatrix;
165
+ /**
166
+ * Compose an EAN-13 symbol with an EAN-2 or EAN-5 supplement.
167
+ *
168
+ * @param {string} value Base EAN-13 payload.
169
+ * @param {string|number} addon Two or five supplemental digits.
170
+ * @param {{gap?:number}} [options]
171
+ * @returns {BitMatrix}
172
+ */
173
+ export declare function encodeEAN13WithAddon(value: string, addon: string | number, options?: {
174
+ gap?: number;
175
+ }): BitMatrix;
176
+ /** @see encodeEAN13WithAddon */
177
+ export declare function encodeEAN8WithAddon(value: any, addon: any, options?: {}): BitMatrix;
178
+ /** @see encodeEAN13WithAddon */
179
+ export declare function encodeUPCAWithAddon(value: any, addon: any, options?: {}): BitMatrix;
180
+ /** @see encodeEAN13WithAddon */
181
+ export declare function encodeUPCEWithAddon(value: any, addon: any, options?: {}): BitMatrix;
@@ -0,0 +1,55 @@
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
+ * Linear symbologies.
33
+ *
34
+ * @module oned
35
+ */
36
+ export { encodeEAN13, encodeEAN8, encodeUPCA, encodeUPCE, encodeISBN, encodeCode39, encodeCode93, encodeCode128, encodeITF, encodeITF14, encodeCodabar, encodeCode11, encodeMSI, encodePharmacode, ean13CheckDigit, } from './writers.js';
37
+ export { EAN2_PARITY, EAN5_PARITY, EAN2_WIDTH, EAN5_WIDTH, EAN_ADDON_START, EAN_ADDON_SEPARATOR, ean2Parity, ean5Checksum, ean5CheckDigit, ean5Parity, encodeEAN2, encodeEAN5, encodeEANAddon, encodeEANAddOn, decodeEAN2, decodeEAN5, decodeEANAddon, decodeEANAddOn, composeEANAddon, encodeEAN13WithAddon, encodeEAN8WithAddon, encodeUPCAWithAddon, encodeUPCEWithAddon, } from './addons.js';
38
+ export { decodeOneD, decodeOneDStrict, decodeCode11, decodeMSI, patternVariance, recordPattern, toNarrowWidePattern, } from './reader.js';
39
+ export { validateTables } from './patterns.js';
40
+ /**
41
+ * Writers by format id, for the top-level `encode()` dispatcher.
42
+ *
43
+ * `readable` marks the formats this suite can also decode. Writing is a table
44
+ * lookup and easy to support broadly; reading needs a detector per symbology,
45
+ * so the two lists legitimately differ and the API says so rather than
46
+ * failing at runtime.
47
+ *
48
+ * @type {Record<string, {encode: Function, readable: boolean, label: string, role?: string}>}
49
+ */
50
+ export declare const ONED_FORMATS: Record<string, {
51
+ encode: Function;
52
+ readable: boolean;
53
+ label: string;
54
+ role?: string;
55
+ }>;
@@ -0,0 +1,259 @@
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
+ * Pattern tables for the linear symbologies.
33
+ *
34
+ * Every table here is a published fact about a symbology, expressed in this
35
+ * project's own notation and validated by structural invariants rather than
36
+ * trusted. `validateTables()` at the bottom asserts the properties each
37
+ * symbology guarantees — module counts, wide-element counts, uniqueness — and
38
+ * the test suite runs it. A transcription slip that breaks an invariant fails
39
+ * the build; the invariants are chosen so that most single-character slips do.
40
+ *
41
+ * Two notations appear:
42
+ *
43
+ * width strings "212222" — element widths in modules, bar first, then
44
+ * alternating space/bar. Used by Code 128, 93,
45
+ * Codabar, ITF, Code 39, Code 11.
46
+ * module strings "0001101" — one character per module, 1 = dark. Used by
47
+ * EAN/UPC, where every element is a whole number
48
+ * of modules out of a fixed 7.
49
+ *
50
+ * @module oned/patterns
51
+ */
52
+ /** Odd-parity ("L") digit patterns, 7 modules each. */
53
+ export declare const EAN_L: string[];
54
+ /** Even-parity ("G") patterns: the R pattern reversed. */
55
+ export declare const EAN_G: string[];
56
+ /** Right-hand ("R") patterns: the L pattern complemented. */
57
+ export declare const EAN_R: string[];
58
+ /**
59
+ * Which parity set each of the six left-hand EAN-13 digits uses, indexed by
60
+ * the first digit. This is how the thirteenth digit is carried without a
61
+ * thirteenth symbol position.
62
+ */
63
+ export declare const EAN13_PARITY: string[];
64
+ /** UPC-E parity patterns, indexed by check digit. Used when the number system is 0. */
65
+ export declare const UPCE_PARITY: string[];
66
+ export declare const EAN_START_END = "101";
67
+ export declare const EAN_MIDDLE = "01010";
68
+ export declare const UPCE_END = "010101";
69
+ /**
70
+ * Code 39 is "three of nine": nine elements per character, of which exactly
71
+ * three are wide. `n` and `w` below are narrow and wide; elements alternate
72
+ * bar, space, bar, ... starting and ending with a bar.
73
+ */
74
+ export declare const CODE39: {
75
+ '0': string;
76
+ '1': string;
77
+ '2': string;
78
+ '3': string;
79
+ '4': string;
80
+ '5': string;
81
+ '6': string;
82
+ '7': string;
83
+ '8': string;
84
+ '9': string;
85
+ A: string;
86
+ B: string;
87
+ C: string;
88
+ D: string;
89
+ E: string;
90
+ F: string;
91
+ G: string;
92
+ H: string;
93
+ I: string;
94
+ J: string;
95
+ K: string;
96
+ L: string;
97
+ M: string;
98
+ N: string;
99
+ O: string;
100
+ P: string;
101
+ Q: string;
102
+ R: string;
103
+ S: string;
104
+ T: string;
105
+ U: string;
106
+ V: string;
107
+ W: string;
108
+ X: string;
109
+ Y: string;
110
+ Z: string;
111
+ '-': string;
112
+ '.': string;
113
+ ' ': string;
114
+ $: string;
115
+ '/': string;
116
+ '+': string;
117
+ '%': string;
118
+ '*': string;
119
+ };
120
+ /** Character set for the optional modulo-43 check digit; '*' is excluded. */
121
+ export declare const CODE39_CHECK_SET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%";
122
+ /** Two-character escapes giving Code 39 the full ASCII range. */
123
+ export declare const CODE39_EXTENDED: any[];
124
+ /** Nine modules per character across six elements. */
125
+ export declare const CODE93: {
126
+ '0': string;
127
+ '1': string;
128
+ '2': string;
129
+ '3': string;
130
+ '4': string;
131
+ '5': string;
132
+ '6': string;
133
+ '7': string;
134
+ '8': string;
135
+ '9': string;
136
+ A: string;
137
+ B: string;
138
+ C: string;
139
+ D: string;
140
+ E: string;
141
+ F: string;
142
+ G: string;
143
+ H: string;
144
+ I: string;
145
+ J: string;
146
+ K: string;
147
+ L: string;
148
+ M: string;
149
+ N: string;
150
+ O: string;
151
+ P: string;
152
+ Q: string;
153
+ R: string;
154
+ S: string;
155
+ T: string;
156
+ U: string;
157
+ V: string;
158
+ W: string;
159
+ X: string;
160
+ Y: string;
161
+ Z: string;
162
+ '-': string;
163
+ '.': string;
164
+ ' ': string;
165
+ $: string;
166
+ '/': string;
167
+ '+': string;
168
+ '%': string;
169
+ S$: string;
170
+ 'S%': string;
171
+ 'S/': string;
172
+ 'S+': string;
173
+ };
174
+ /**
175
+ * Symbol values 0..46 in order, as keys into {@link CODE93}. An array rather
176
+ * than a string, because the four shift characters have multi-character keys.
177
+ */
178
+ export declare const CODE93_VALUES: string[];
179
+ export declare const CODE93_START_STOP = "111141";
180
+ /**
181
+ * All 107 symbol patterns. Eleven modules each across six elements; the stop
182
+ * pattern is the sole exception at thirteen modules across seven.
183
+ *
184
+ * The eleven-module invariant is checked below and catches the overwhelming
185
+ * majority of transcription slips, since almost any single-digit change to a
186
+ * pattern breaks the sum.
187
+ */
188
+ export declare const CODE128: string[];
189
+ export declare const CODE128_START_A = 103;
190
+ export declare const CODE128_START_B = 104;
191
+ export declare const CODE128_START_C = 105;
192
+ export declare const CODE128_STOP = 106;
193
+ export declare const CODE128_FNC1 = 102;
194
+ export declare const CODE128_FNC2 = 97;
195
+ export declare const CODE128_FNC3 = 96;
196
+ export declare const CODE128_FNC4_A = 101;
197
+ export declare const CODE128_FNC4_B = 100;
198
+ export declare const CODE128_SHIFT = 98;
199
+ export declare const CODE128_CODE_A = 101;
200
+ export declare const CODE128_CODE_B = 100;
201
+ export declare const CODE128_CODE_C = 99;
202
+ /** Five elements per digit, exactly two of them wide. */
203
+ export declare const ITF: string[];
204
+ /** Seven elements per character. */
205
+ export declare const CODABAR: {
206
+ '0': string;
207
+ '1': string;
208
+ '2': string;
209
+ '3': string;
210
+ '4': string;
211
+ '5': string;
212
+ '6': string;
213
+ '7': string;
214
+ '8': string;
215
+ '9': string;
216
+ '-': string;
217
+ $: string;
218
+ ':': string;
219
+ '/': string;
220
+ '.': string;
221
+ '+': string;
222
+ A: string;
223
+ B: string;
224
+ C: string;
225
+ D: string;
226
+ };
227
+ export declare const CODABAR_START_STOP = "ABCD";
228
+ /** Five elements per character, one or two of them wide. */
229
+ export declare const CODE11: {
230
+ '0': string;
231
+ '1': string;
232
+ '2': string;
233
+ '3': string;
234
+ '4': string;
235
+ '5': string;
236
+ '6': string;
237
+ '7': string;
238
+ '8': string;
239
+ '9': string;
240
+ '-': string;
241
+ };
242
+ export declare const CODE11_START_STOP = "nnwwn";
243
+ /** Each bit of a digit becomes a bar pair: 1 is wide-then-narrow, 0 the reverse. */
244
+ export declare const MSI_BIT: {
245
+ 0: string;
246
+ 1: string;
247
+ };
248
+ export declare const MSI_START = "110";
249
+ export declare const MSI_STOP = "1001";
250
+ /**
251
+ * Assert every invariant these tables are supposed to satisfy.
252
+ *
253
+ * This is the first of the correctness mechanisms described in NOTICE.md:
254
+ * the tables are redundant with the symbology rules, so the rules can check
255
+ * the tables. Called from the test suite; cheap enough to call anywhere.
256
+ *
257
+ * @returns {string[]} Problems found; empty means all invariants hold.
258
+ */
259
+ export declare function validateTables(): string[];
@@ -0,0 +1,129 @@
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
+ * Compare measured run lengths against an ideal pattern, scale-independently.
33
+ *
34
+ * Returns a normalised mismatch score, or Infinity when any single element is
35
+ * further out of proportion than `maxIndividual` allows. Rejecting on the
36
+ * worst element as well as the total is what stops a run of noise whose widths
37
+ * happen to average out from being accepted as a character.
38
+ *
39
+ * @param {number[]} counters Measured widths, in pixels.
40
+ * @param {number[]} pattern Ideal widths, in modules.
41
+ * @param {number} maxIndividual Tolerance per element, as a fraction of a module.
42
+ * @returns {number}
43
+ */
44
+ export declare function patternVariance(counters: number[], pattern: number[], maxIndividual: number): number;
45
+ /**
46
+ * Measure alternating run lengths starting at `start`.
47
+ *
48
+ * @param {Uint8Array} row One byte per pixel, 1 = dark.
49
+ * @param {number} start
50
+ * @param {number[]} counters Filled in place; its length sets how many runs to read.
51
+ * @returns {boolean} False if the row ended before the runs were filled.
52
+ */
53
+ export declare function recordPattern(row: Uint8Array, start: number, counters: number[]): boolean;
54
+ /**
55
+ * Classify run lengths into narrow and wide, for the n/w symbologies.
56
+ *
57
+ * The wide:narrow ratio is not fixed by these formats — it is anywhere from
58
+ * 2:1 to 3:1 and varies with the printer — so the split has to be discovered
59
+ * from the data. Candidate thresholds are tried from the smallest counter
60
+ * upward until exactly the expected number of wide elements falls out.
61
+ *
62
+ * @param {number[]} counters
63
+ * @param {number} expectedWide How many elements must be wide.
64
+ * @returns {number} Bit pattern, MSB = first element wide; -1 if undecidable.
65
+ */
66
+ export declare function toNarrowWidePattern(counters: number[], expectedWide: number): number;
67
+ /**
68
+ * Decode Code 11 from one binarized scanline.
69
+ *
70
+ * @param {Uint8Array} row
71
+ * @param {object} [options]
72
+ * @param {boolean} [options.checkDigit]
73
+ * @returns {{format:'code11', text:string}|null}
74
+ */
75
+ export declare function decodeCode11(row: Uint8Array, options?: {
76
+ checkDigit?: boolean;
77
+ }): {
78
+ format: 'code11';
79
+ text: string;
80
+ } | null;
81
+ /**
82
+ * Decode MSI/Plessey from one binarized scanline.
83
+ *
84
+ * @param {Uint8Array} row
85
+ * @param {object} [options]
86
+ * @param {boolean} [options.checkDigit]
87
+ * @returns {{format:'msi', text:string}|null}
88
+ */
89
+ export declare function decodeMSI(row: Uint8Array, options?: {
90
+ checkDigit?: boolean;
91
+ }): {
92
+ format: 'msi';
93
+ text: string;
94
+ } | null;
95
+ /**
96
+ * Read every linear symbol found in a binarized image.
97
+ *
98
+ * @param {import('../core/bit-matrix.js').BitMatrix} image Binarized; set bit = dark.
99
+ * @param {object} [options]
100
+ * @param {string[]} [options.formats] Restrict to these format ids.
101
+ * @param {number} [options.rows] How many horizontal slices to try.
102
+ * @param {boolean} [options.tryHarder] Also scan reversed rows, for mirrored symbols.
103
+ * @param {'camera'} [options.profile] Require stable, quiet-zone-qualified reads.
104
+ * @param {0|90|180|270} [options.cameraRotation] Orientation already normalized by the caller.
105
+ * @returns {Array<{format: string, text: string, row: number}>}
106
+ */
107
+ export declare function decodeOneD(image: import('../core/bit-matrix.js').BitMatrix, options?: {
108
+ formats?: string[];
109
+ rows?: number;
110
+ tryHarder?: boolean;
111
+ profile?: 'camera';
112
+ cameraRotation?: 0 | 90 | 180 | 270;
113
+ }): Array<{
114
+ format: string;
115
+ text: string;
116
+ row: number;
117
+ }>;
118
+ /**
119
+ * Convenience wrapper that throws when nothing is found.
120
+ *
121
+ * @param {import('../core/bit-matrix.js').BitMatrix} image
122
+ * @param {object} [options]
123
+ * @returns {{format: string, text: string, row: number}}
124
+ */
125
+ export declare function decodeOneDStrict(image: import('../core/bit-matrix.js').BitMatrix, options?: object): {
126
+ format: string;
127
+ text: string;
128
+ row: number;
129
+ };