@sythos/js_barcode_universal 1.5.8 → 1.5.9
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/LICENSE +5 -4
- package/NOTICE.md +2 -2
- package/README.md +17 -13
- package/bundle/sythos-barcode.esm.js +11658 -11244
- package/bundle/sythos-barcode.js +11658 -11244
- package/package.json +10 -3
- package/src/index.d.ts +1 -1
- package/src/index.js +508 -516
- package/src/js/aztec/decoder.js +208 -199
- package/src/js/aztec/detector.js +153 -126
- package/src/js/aztec/encoder.js +172 -153
- package/src/js/aztec/high-level.js +106 -101
- package/src/js/aztec/index.js +1 -12
- package/src/js/aztec/tables.js +106 -120
- package/src/js/aztecrune/decoder.js +76 -85
- package/src/js/aztecrune/detector.js +107 -93
- package/src/js/aztecrune/encoder.js +50 -68
- package/src/js/aztecrune/index.js +1 -16
- package/src/js/aztecrune/tables.js +59 -54
- package/src/js/compactpdf417/decoder.js +69 -74
- package/src/js/compactpdf417/detector.js +74 -75
- package/src/js/compactpdf417/encoder.js +68 -81
- package/src/js/compactpdf417/index.js +1 -13
- package/src/js/compactpdf417/tables.js +71 -80
- package/src/js/core/bit-buffer.js +106 -122
- package/src/js/core/bit-matrix.js +196 -194
- package/src/js/core/errors.js +13 -15
- package/src/js/core/galois-field.js +119 -133
- package/src/js/core/index.js +2 -19
- package/src/js/core/reed-solomon.js +195 -204
- package/src/js/databar/codec.js +93 -108
- package/src/js/databar/decoder.js +149 -140
- package/src/js/databar/encoder.js +47 -55
- package/src/js/databar/gs1.js +122 -123
- package/src/js/databar/index.js +4 -36
- package/src/js/databar/patterns.js +81 -85
- package/src/js/databar/tables.js +51 -52
- package/src/js/datamatrix/decoder.js +216 -182
- package/src/js/datamatrix/detector.js +161 -132
- package/src/js/datamatrix/encoder.js +192 -133
- package/src/js/datamatrix/index.js +1 -9
- package/src/js/datamatrix/tables.js +68 -69
- package/src/js/frameqr/decoder.js +102 -125
- package/src/js/frameqr/detector.js +101 -94
- package/src/js/frameqr/encoder.js +67 -80
- package/src/js/frameqr/index.js +1 -10
- package/src/js/frameqr/tables.js +145 -163
- package/src/js/image/binarizer.js +146 -162
- package/src/js/image/grid-sampler.js +63 -79
- package/src/js/image/index.js +0 -2
- package/src/js/image/luminance.js +129 -140
- package/src/js/image/perspective.js +112 -149
- package/src/js/micropdf417/compaction.js +64 -65
- package/src/js/micropdf417/decoder.js +106 -109
- package/src/js/micropdf417/detector.js +73 -70
- package/src/js/micropdf417/encoder.js +129 -154
- package/src/js/micropdf417/error-correction.js +6 -11
- package/src/js/micropdf417/index.js +2 -16
- package/src/js/micropdf417/tables.js +112 -99
- package/src/js/microqr/decoder.js +177 -182
- package/src/js/microqr/detector.js +240 -256
- package/src/js/microqr/encoder.js +239 -194
- package/src/js/microqr/index.js +0 -2
- package/src/js/microqr/tables.js +208 -200
- package/src/js/oned/addons.js +167 -191
- package/src/js/oned/index.js +27 -58
- package/src/js/oned/patterns.js +194 -213
- package/src/js/oned/reader.js +1003 -984
- package/src/js/oned/writers.js +411 -466
- package/src/js/pdf417/compaction.js +315 -222
- package/src/js/pdf417/decoder.js +71 -36
- package/src/js/pdf417/detector.js +377 -361
- package/src/js/pdf417/encoder.js +57 -46
- package/src/js/pdf417/error-correction.js +5 -8
- package/src/js/pdf417/tables.js +248 -250
- package/src/js/qr/decoder.js +311 -347
- package/src/js/qr/detector.js +378 -395
- package/src/js/qr/encoder.js +514 -599
- package/src/js/qr/index.js +0 -2
- package/src/js/qr/tables.js +375 -422
- package/src/js/render/image-data.js +57 -62
- package/src/js/render/index.js +21 -23
- package/src/js/render/options.js +82 -90
- package/src/js/render/png.js +144 -169
- package/src/js/render/svg.js +41 -44
- package/src/js/render/webgl.js +103 -109
- package/src/js/render/webgpu.js +205 -217
- package/src/js/rmqr/decoder.js +161 -53
- package/src/js/rmqr/detector.js +73 -41
- package/src/js/rmqr/encoder.js +253 -104
- package/src/js/rmqr/index.js +1 -5
- package/src/js/rmqr/tables.js +108 -85
- package/src/ts/aztec/decoder.ts +317 -0
- package/src/ts/aztec/detector.ts +224 -0
- package/src/ts/aztec/encoder.ts +257 -0
- package/src/ts/aztec/high-level.ts +211 -0
- package/src/ts/aztec/index.ts +45 -0
- package/src/ts/aztec/tables.ts +210 -0
- package/src/ts/aztecrune/decoder.ts +155 -0
- package/src/ts/aztecrune/detector.ts +166 -0
- package/src/ts/aztecrune/encoder.ts +121 -0
- package/src/ts/aztecrune/index.ts +49 -0
- package/src/ts/aztecrune/tables.ts +137 -0
- package/src/ts/compactpdf417/decoder.ts +128 -0
- package/src/ts/compactpdf417/detector.ts +139 -0
- package/src/ts/compactpdf417/encoder.ts +140 -0
- package/src/ts/compactpdf417/index.ts +17 -0
- package/src/ts/compactpdf417/tables.ts +173 -0
- package/src/ts/core/bit-buffer.ts +174 -0
- package/src/ts/core/bit-matrix.ts +241 -0
- package/src/ts/core/errors.ts +61 -0
- package/src/ts/core/galois-field.ts +207 -0
- package/src/ts/core/index.ts +56 -0
- package/src/ts/core/reed-solomon.ts +327 -0
- package/src/ts/databar/codec.ts +181 -0
- package/src/ts/databar/decoder.ts +215 -0
- package/src/ts/databar/encoder.ts +96 -0
- package/src/ts/databar/gs1.ts +177 -0
- package/src/ts/databar/index.ts +68 -0
- package/src/ts/databar/patterns.ts +143 -0
- package/src/ts/databar/tables.ts +124 -0
- package/src/ts/datamatrix/decoder.ts +262 -0
- package/src/ts/datamatrix/detector.ts +225 -0
- package/src/ts/datamatrix/encoder.ts +191 -0
- package/src/ts/datamatrix/index.ts +42 -0
- package/src/ts/datamatrix/tables.ts +123 -0
- package/src/ts/frameqr/decoder.ts +239 -0
- package/src/ts/frameqr/detector.ts +192 -0
- package/src/ts/frameqr/encoder.ts +156 -0
- package/src/ts/frameqr/index.ts +42 -0
- package/src/ts/frameqr/tables.ts +270 -0
- package/src/ts/image/binarizer.ts +270 -0
- package/src/ts/image/grid-sampler.ts +164 -0
- package/src/ts/image/index.ts +40 -0
- package/src/ts/image/luminance.ts +196 -0
- package/src/ts/image/perspective.ts +195 -0
- package/src/ts/index.d.ts +1 -1
- package/src/ts/index.ts +790 -0
- package/src/ts/micropdf417/compaction.ts +116 -0
- package/src/ts/micropdf417/decoder.ts +183 -0
- package/src/ts/micropdf417/detector.ts +149 -0
- package/src/ts/micropdf417/encoder.ts +209 -0
- package/src/ts/micropdf417/error-correction.ts +55 -0
- package/src/ts/micropdf417/index.ts +49 -0
- package/src/ts/micropdf417/tables.ts +184 -0
- package/src/ts/microqr/decoder.ts +245 -0
- package/src/ts/microqr/detector.ts +355 -0
- package/src/ts/microqr/encoder.ts +269 -0
- package/src/ts/microqr/index.ts +36 -0
- package/src/ts/microqr/tables.ts +316 -0
- package/src/ts/oned/addons.ts +420 -0
- package/src/ts/oned/index.ts +106 -0
- package/src/ts/oned/patterns.ts +384 -0
- package/src/ts/oned/reader.ts +1364 -0
- package/src/ts/oned/writers.ts +746 -0
- package/src/ts/pdf417/compaction.ts +298 -0
- package/src/ts/pdf417/decoder.ts +75 -0
- package/src/ts/pdf417/detector.ts +468 -0
- package/src/ts/pdf417/encoder.ts +91 -0
- package/src/ts/pdf417/error-correction.ts +47 -0
- package/src/ts/pdf417/index.ts +6 -0
- package/src/ts/pdf417/tables.ts +317 -0
- package/src/ts/qr/decoder.ts +575 -0
- package/src/ts/qr/detector.ts +630 -0
- package/src/ts/qr/encoder.ts +958 -0
- package/src/ts/qr/index.ts +44 -0
- package/src/ts/qr/tables.ts +737 -0
- package/src/ts/render/image-data.ts +125 -0
- package/src/ts/render/index.ts +130 -0
- package/src/ts/render/options.ts +160 -0
- package/src/ts/render/png.ts +295 -0
- package/src/ts/render/svg.ts +120 -0
- package/src/ts/render/webgl.ts +206 -0
- package/src/ts/render/webgpu.ts +369 -0
- package/src/ts/rmqr/decoder.ts +101 -0
- package/src/ts/rmqr/detector.ts +90 -0
- package/src/ts/rmqr/encoder.ts +172 -0
- package/src/ts/rmqr/index.ts +37 -0
- package/src/ts/rmqr/tables.ts +154 -0
package/src/js/pdf417/tables.js
CHANGED
|
@@ -27,12 +27,9 @@
|
|
|
27
27
|
*
|
|
28
28
|
* Original work. No code from any other barcode implementation.
|
|
29
29
|
*/
|
|
30
|
-
|
|
31
30
|
/** PDF417 symbol-character pattern table. @module pdf417/tables */
|
|
32
|
-
|
|
33
31
|
export const PDF417_CLUSTER_NUMBERS = Object.freeze([0, 3, 6]);
|
|
34
32
|
export const PDF417_CODEWORDS_PER_CLUSTER = 929;
|
|
35
|
-
|
|
36
33
|
// Transcribed from the normative AIM USS PDF417 specification, Appendix H,
|
|
37
34
|
// Table H1 (Bar-Space Sequence Table), from a publicly accessible copy hosted
|
|
38
35
|
// at https://expresscorp.com/wp-content/uploads/2023/02/USS-PDF-417.pdf.
|
|
@@ -40,259 +37,259 @@ export const PDF417_CODEWORDS_PER_CLUSTER = 929;
|
|
|
40
37
|
// Each eight-digit sequence is ordered bar, space, bar, space, bar, space,
|
|
41
38
|
// bar, space and is indexed by its codeword value from 0 through 928.
|
|
42
39
|
const WIDTH_SEQUENCES = Object.freeze([
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
40
|
+
'3111113641111144511111523111123541111243511112512111132631111334211114251111151621111524111116152111213631112144' +
|
|
41
|
+
'4111215221112235311122434111225111112326211123341111242511113136211131443111315211113235211132433111325111113334' +
|
|
42
|
+
'2111334211114144211141521111424321114251111151525111611131121135411211435112115121121226311212344112124221121325' +
|
|
43
|
+
'3112133311121416211214243112143211121515211215231112161421122135311221434112215111122226211222343112224211122325' +
|
|
44
|
+
'2112233331122341111224242112243211123135211231433112315111123234211232421112333321123341111241432112415111124242' +
|
|
45
|
+
'1112434121131126311311344113114221131225311312334113124111131316211313243113133211131415211314231113151411131613' +
|
|
46
|
+
'1113212621132134311321421113222521132233311322411113232421132332111324231113252211133134211331421113323321133241' +
|
|
47
|
+
'1113333211134142211411253114113341141141111412162114122431141232111413152114132331141331111414142114142211141513' +
|
|
48
|
+
'2114152111142125211421333114214111142224211422321114232321142331111424221114252121143141111433311115111621151124' +
|
|
49
|
+
'3115113211151215211512233115123111151314211513221115141321151421111515121115212411152223111523221116111531161131' +
|
|
50
|
+
'2116122221161321111615113211113542111143521111512211122632111234421112422211132532111333421113411211141622111424' +
|
|
51
|
+
'1211151522112135321121434211215112112226221122343211224212112325221123331211242412112523121131352211314332113151' +
|
|
52
|
+
'1211323422113242121133331211343212114143221141511211424212115151312111264121113451211142312112254121123351211241' +
|
|
53
|
+
'2121131631211324412113322121141531211423412114312121151431211522221211263212113442121142212121262212122532121233' +
|
|
54
|
+
'4212124121212225312122334121224111212316121214152212142332121431112124152121242311212514121221262212213432122142' +
|
|
55
|
+
'1121312612122225221222333212224111213225212132333121324111213324121224231121342312123134221231421121413412123233' +
|
|
56
|
+
'2212324111214233212142411121433212124142112151421212424111215241312211254122113351221141212212163122122441221232' +
|
|
57
|
+
'2122131531221323412213312122141431221422212215132122161222131125321311334213114121222125221312243213123211222216' +
|
|
58
|
+
'1213131531222232321313311122231512131414221314221122241421222422221315211213161212132125221321333213214111223125' +
|
|
59
|
+
'1213222422132232112232242122323222132331112233231213242212132521121331332213314111224133121332321122423212133331' +
|
|
60
|
+
'1122433111225141212311163123112441231132212312153123122341231231212313143123132221231413312314212123151221231611' +
|
|
61
|
+
'1214111622141124321411321123211612141215221412233214123111232215212322233123223111232314121414132214142111232413' +
|
|
62
|
+
'2123242111232512121421242214213211233124121422232214223111233223212332311123332212142421112334211123413211234231' +
|
|
63
|
+
'2124111531241123412411312124121431241222212413133124132121241412212415111215111522151123321511311124211512151214' +
|
|
64
|
+
'2215122211242214212422222215132111242313121514121124241212151511121521231124312311243222112433213125112231251221' +
|
|
65
|
+
'2125141122161122121612131125221311252312112524112311112633111134431111422311122533111233131113162311132433111332' +
|
|
66
|
+
'1311141523111423131115141311161313112126231121343311214213112225231122333311224113112324231123321311242313112522' +
|
|
67
|
+
'1311313423113142131132332311324113113332131141421311424132211125422111335221114122211216322112244221123222211315' +
|
|
68
|
+
'3221132342211331222114143221142222211513322115212312112533121133431211412221212523121224331212321221221613121315' +
|
|
69
|
+
'3221223233121331122123152221232323121422122124141312151312212513131221252312213333122141122131251312222432213141' +
|
|
70
|
+
'1221322422213232231223311221332313122422122134221312313323123141122141331312323212214232131233311312414112215141' +
|
|
71
|
+
'3131111641311124513111323131121541311223513112313131131441311322313114134131142131311512222211163222112442221132' +
|
|
72
|
+
'2131211622221215413121324222123121312215313122234131223121312314222214133222142121312413313124212222161113131116' +
|
|
73
|
+
'2313112433131132122221161313121523131223331312311131311612222215222222233222223111313215213132233131323123131421' +
|
|
74
|
+
'1131331412222413222224211131341313131611131321242313213212223124131322232313223111314124122232232222323111314223' +
|
|
75
|
+
'2131423113132421122234211313313212224132131332311131513212224231313211154132112351321131313212144132122231321313' +
|
|
76
|
+
'4132132131321412313215112223111532231123422311312132211522231214413221312132221431322222322313212132231322231412' +
|
|
77
|
+
'2132241222231511213225111314111523141123331411311223211513141214231412221132311512232214222322222314132111323214' +
|
|
78
|
+
'2132322213141412113233131223241213141511122325111314212323142131122331231314222211324123122332221314232111324222' +
|
|
79
|
+
'1223332113143131113251313133111441331122313312134133122131331312313314112224111432241122213321142224121332241221' +
|
|
80
|
+
'2133221331332221213323122224141121332411131511142315112212242114131512132315122111333114122422132224222111333213' +
|
|
81
|
+
'2133322113151411113333121224241111333411122431221133412211334221413411213134131132251121222512122225131113161113' +
|
|
82
|
+
'1225211311343113131613111225231124111125141112162411122414111315241113233411133114111414241114221411151324111521' +
|
|
83
|
+
'1411212524112133341121411411222424112232141123232411233114112422141125211411313324113141141132321411333114114141' +
|
|
84
|
+
'2321111633211124432111322321121533211223232113143321132223211413332114212321151214121116241211243412113213212116' +
|
|
85
|
+
'1412121533212132341212311321221523212223332122311321231414121413241214211321241323212421141216111412212424122132' +
|
|
86
|
+
'1321312414122223241222311321322323213231132133221412242114123132132141321412323113214231323111154231112352311131' +
|
|
87
|
+
'3231121442311222323113134231132132311412323115112322111533221123223121152322121433221222223122143231222233221321' +
|
|
88
|
+
'2231231323221412223124122322151122312511141311152413112313222115141312143322213112313115132222142322222224131321' +
|
|
89
|
+
'1231321422313222141314121231331313222412141315111322251114132123241321311322312314132222123141231322322214132321' +
|
|
90
|
+
'1231422213223321141331311322413112315131414111145141112241411213514112214141131241411411323211144232112231412114' +
|
|
91
|
+
'4141212242321221314122134141222131412312323214113141241123231114332311222232211423231213332312212141311422322213' +
|
|
92
|
+
'3232222121413213314132212323141121413312223224112141341114141114241411221323211414141213241412211232311413232213' +
|
|
93
|
+
'2323222111414114123232132232322114141411114142132141422113232411114143121414212213233122141422211232412213233221' +
|
|
94
|
+
'1141512212324221114152214142111351421121414212124142131132331113423311213142211341422121314222123233131131422311' +
|
|
95
|
+
'2324111333241121223321132324121221423113223322122324131121423212223323112142331114151113241511211324211323242121' +
|
|
96
|
+
'1233311313242212141513111142411312333212132423111142421212333311114243111324312111425121414312113143211231432211' +
|
|
97
|
+
'2234211221433112214332111325211212343112114341121143421115111116151112152511122315111314151114131511151215112124' +
|
|
98
|
+
'1511222315112322151124211511313215113231242111152421121434211222242113133421132124211412242115111512111525121123' +
|
|
99
|
+
'1421211524212123251212221421221424212222142123132421232114212412151215111421251115122123251221311421312324213131' +
|
|
100
|
+
'1421322215122321142133211512313114214131333111143331121333311312333114112422111423312114333121223422122123312213' +
|
|
101
|
+
'3331222123312312242214112331241115131114142221141513121325131221133131141422221315131312133132131422231215131411' +
|
|
102
|
+
'1331331214222411151321221422312215132221133141221422322113314221424111134241121242411311333211133241211342412121' +
|
|
103
|
+
'3241221233321311324123112423111334231121233221133332212122413113233222122423131122413212233223112241331115141113' +
|
|
104
|
+
'2514112114232113242321211332311314232212151413111241411313323212142323111241421213323311151421211423312113324121' +
|
|
105
|
+
'1241512151511112515112114242111241512112424212114151221133331112324221123333121131513112324222113151321124241112' +
|
|
106
|
+
'2333211224241211224231122333221121514112',
|
|
107
|
+
'5111112561111133411112165111122461111232411113155111132361111331411114145111142241111513511115214111161241112125' +
|
|
108
|
+
'5111213361112141311122164111222451112232311123154111232351112331311124144111242231112513411125213111261231113125' +
|
|
109
|
+
'4111313351113141211132163111322441113232211133153111332341113331211134143111342221113513311135212111361221114125' +
|
|
110
|
+
'3111413341114141111142162111422431114232111143152111432331114331111144142111442211114513211145211111512521115133' +
|
|
111
|
+
'3111514111115224211152321111532321115331111154221111613321116141111162321111633141121116511211246112113241121215' +
|
|
112
|
+
'5112122361121231411213145112132241121413511214214112151241121611311221164112212451122132311222154112222351122231' +
|
|
113
|
+
'3112231441122322311224134112242131122512311226112112311631123124411231322112321531123223411232312112331431123322' +
|
|
114
|
+
'2112341331123421211235122112361111124116211241243112413211124215211242233112423111124314211243221112441321124421' +
|
|
115
|
+
'1112451211125124211251321112522321125231111253221112542111126132111262314113111551131123611311314113121451131222' +
|
|
116
|
+
'4113131351131321411314124113151131132115411321235113213131132214411322223113231341132321311324123113251121133115' +
|
|
117
|
+
'3113312341133131211332143113322221133313311333212113341221133511111341152113412331134131111342142113422211134313' +
|
|
118
|
+
'2113432111134412111345111113512321135131111352221113532111136131411411145114112241141213511412214114131241141411' +
|
|
119
|
+
'3114211441142122311422134114222131142312311424112114311431143122211432133114322121143312211434111114411421144122' +
|
|
120
|
+
'1114421321144221111443121114441111145122111452214115111351151121411512124115131131152113411521213115221231152311' +
|
|
121
|
+
'2115311331153121211532122115331111154113211541211115421211154311411611124116121131162112311622112116311221163211' +
|
|
122
|
+
'4211111652111124621111324211121552111223621112314211131452111322421114135211142142111512421116113211211642112124' +
|
|
123
|
+
'5211213232112215421122235211223132112314421123223211241342112421321125123211261122113116321131244211313222113215' +
|
|
124
|
+
'3211322342113231221133143211332222113413321134212211351222113611121141162211412432114132121142152211422332114231' +
|
|
125
|
+
'1211431422114322121144132211442112114512121151242211513212115223221152311211532212115421121161321211623151211115' +
|
|
126
|
+
'6121112311211164512112146121122211211263512113136121132111211362512114125121151142121115521211236212113141212115' +
|
|
127
|
+
'4212121461212131412122145121222252121321412123134212141241212412421215114121251132122115421221235212213131213115' +
|
|
128
|
+
'3212221442122222312132144121322242122321312133133212241231213412321225113121351122123115321231234212313121214115' +
|
|
129
|
+
'2212321432123222212142143121422232123321212143132212341221214412221235112121451112124115221241233212413111215115' +
|
|
130
|
+
'1212421422124222112152142121522222124321112153131212441211215412121245111212512322125131112161231212522211216222' +
|
|
131
|
+
'1212532111216321121261315122111461221122112211635122121361221221112212625122131211221361512214114213111452131122' +
|
|
132
|
+
'4122211442131213521312214122221351222221412223124213141141222411321321144213212231223114321322134213222131223213' +
|
|
133
|
+
'4122322131223312321324113122341122133114321331222122411422133213321332212122421331224221212243122213341121224411' +
|
|
134
|
+
'1213411422134122112251141213421322134221112252132122522111225312121344111122541112135122112261221213522111226221' +
|
|
135
|
+
'5123111361231121112311625123121211231261512313114214111352141121412321135123212141232212421413114123231132142113' +
|
|
136
|
+
'4214212131233113321422123123321232142311312333112214311332143121212341133123412121234212221433112123431112144113' +
|
|
137
|
+
'2214412111235113121442121123521212144311112353111214512111236121512411121124116151241211421511124124211242151211' +
|
|
138
|
+
'4124221132152112312431123215221131243211221531122124411222153211212442111215411211245112121542111124521151251111' +
|
|
139
|
+
'4216111141252111321621113125311122163111212541114311111553111123631111314311121453111222431113135311132143111412' +
|
|
140
|
+
'4311151133112115431121235311213133112214431122223311231343112321331124123311251123113115331131234311313123113214' +
|
|
141
|
+
'3311322223113313331133212311341223113511131141152311412333114131131142142311422213114313231143211311441213114511' +
|
|
142
|
+
'1311512323115131131152221311532113116131522111146221112212211163522112136221122112211262522113121221136152211411' +
|
|
143
|
+
'4312111453121122422121144312121353121221422122135221222142212312431214114221241133122114431221223221311433122213' +
|
|
144
|
+
'4312222132213213422132213221331233122411322134112312311433123122222141142312321333123221222142133221422122214312' +
|
|
145
|
+
'2312341122214411131241142312412212215114131242132312422112215213222152211221531213124411122154111312512212216122' +
|
|
146
|
+
'1312522112216221613111131131115421311162613112121131125321311261613113111131135211311451522211136222112112221162' +
|
|
147
|
+
'5131211361312121113121621222126151312212522213111131226151312311431311135313112142222113431312124131311351313121' +
|
|
148
|
+
'4313131141313212422223114131331133132113431321213222311333132212313141133222321233132311313142123222331131314311' +
|
|
149
|
+
'2313311333133121222241132313321221315113222242122313331121315212222243112131531113134113231341211222511313134212' +
|
|
150
|
+
'1131611312225212131343111131621212225311113163111313512112226121613211121132115321321161613212111132125211321351' +
|
|
151
|
+
'5223111212231161513221125223121111322161513222114314111242232112431412114132311242232211413232113314211232233112' +
|
|
152
|
+
'3314221131324112322332113132421123143112222341122314321121325112222342112132521113144112122351121314421111326112' +
|
|
153
|
+
'1223521111326211613311111133115211331251522411115133211143151111422421114133311133152111322431113133411123153111' +
|
|
154
|
+
'2224411121335111131541111224511111336111113411514411111454111122441112135411122144111312441114113411211444112122' +
|
|
155
|
+
'3411221344112221341123123411241124113114341131222411321334113221241133122411341114114114241141221411421324114221' +
|
|
156
|
+
'1411431214114411141151221411522153211113632111211321116253211212132112615321131144121113541211214321211344121212' +
|
|
157
|
+
'4321221244121311432123113412211344122121332131133412221233213212341223113321331124123113341231212321411324123212' +
|
|
158
|
+
'2321421224123311232143111412411324124121132151131412421213215212141243111321531114125121132161216231111212311153' +
|
|
159
|
+
'2231116162311211123112521231135153221112132211615231211253221211123121615231221144131112432221124413121142313112' +
|
|
160
|
+
'4322221142313211341321123322311234132211323141123322321132314211241331122322411224133211223151122322421122315211' +
|
|
161
|
+
'1413411213225112141342111231611213225211123162111141114421411152114112432141125111411342114114416232111112321152' +
|
|
162
|
+
'6141211111412152123212511141225153231111523221115141311144141111432321114232311141414111341421113323311132324111' +
|
|
163
|
+
'3141511124143111232341112232511121416111141441111323511112326111114211432142115111421242114213411233115111422151' +
|
|
164
|
+
'1143114211431241114411414511111345111212451113113511211345112121351122123511231125113113351131212511321225113311' +
|
|
165
|
+
'1511411325114121151142121511431115115121542111121421116154211211451211124421211245121211442122113512211234213112' +
|
|
166
|
+
'3512221134213211251231122421411225123211242142111512411214215112151242111421521163311111133111521331125154221111' +
|
|
167
|
+
'5331211145131111442221114331311135132111342231113331411125133111242241112331511115134111142251111331611112411143' +
|
|
168
|
+
'2241115112411242124113411332115112412151115111342151114211511233215112411151133211511431124211421151214212421241' +
|
|
169
|
+
'1151224111521133215211411152123211521331124311411152214111531132115312311154113136112112361122112611311226113211' +
|
|
170
|
+
'1611411216114211452121113612211135213111261231112521411116124111152151111431115113411142134112411251113322511141' +
|
|
171
|
+
'1251123212511331134211411251214111611124216111321161122321611231116113221161142112521132116121321252123111612231' +
|
|
172
|
+
'1162112321621131116212221162132112531131116221311163112211631221144111411351113213511231126111232261113112611222' +
|
|
173
|
+
'1261132113521131126121311262112212621221',
|
|
174
|
+
'2111115531111163111112462111125431111262111113452111135331111361111114442111145211111543611121141111215521112163' +
|
|
175
|
+
'6111221311112254211122626111231211112353211123616111241111112452511131146111312211113163511132136111322111113262' +
|
|
176
|
+
'5111331211113361511134114111411451114122411142135111422141114312411144113111511441115122311152134111522131115312' +
|
|
177
|
+
'3111541121116114311161222111621331116221211163121112114621121154311211621112124521121253311212611112134421121352' +
|
|
178
|
+
'1112144321121451111215426112211311122154211221626112221211122253211222616112231111122352111224515112311361123121' +
|
|
179
|
+
'1112316251123212111232615112331141124113511241214112421241124311311251134112512131125212311253112112611331126121' +
|
|
180
|
+
'2112621221126311111311452113115331131161111312442113125211131343211313511113144211131541611321121113215321132161' +
|
|
181
|
+
'6113221111132252111323515113311211133161511332114113411241134211311351123113521121136112211362111114114421141152' +
|
|
182
|
+
'1114124321141251111413421114144161142111111421521114225151143111411441113114511111151143211511511115124211151341' +
|
|
183
|
+
'1115215111161142111612411211114622111154321111621211124522111253321112611211134422111352121114432211145112111542' +
|
|
184
|
+
'6211211312112154221121626211221212112253221122616211231112112352121124515211311362113121121131625211321212113261' +
|
|
185
|
+
'5211331142114113521141214211421242114311321151134211512132115212321153112211611332116121221162122211631121211145' +
|
|
186
|
+
'3121115341211161112112362121124431211252112113352121134331211351112114342121144211211533212115411121163212121145' +
|
|
187
|
+
'2212115332121161112121451212124422121252112122442121225222121351112123431212144211212442121215411121254162122112' +
|
|
188
|
+
'1212215322122161612131126212221111213153121222526121321111213252121223511121335152123112121231615121411252123211' +
|
|
189
|
+
'1121416151214211421241124121511242124211412152113212511231216112321252113121621122126112221262111122113621221144' +
|
|
190
|
+
'3122115211221235212212433122125111221334212213421122143321221441112215321122163112131144221311521122214412131243' +
|
|
191
|
+
'2213125111222243212222511122234212131441112224416213211112132152612231111122315212132251112232515213311151224111' +
|
|
192
|
+
'4213411141225111321351113122611122136111112311352123114331231151112312342123124211231333212313411123143211231531' +
|
|
193
|
+
'1214114322141151112321431214124211232242121413411123234112142151112331511124113421241142112412332124124111241332' +
|
|
194
|
+
'1124143112151142112421421215124111242241112511332125114111251232112513311216114111252141112611321126123113111145' +
|
|
195
|
+
'2311115333111161131112442311125213111343231113511311144213111541631121121311215323112161631122111311225213112351' +
|
|
196
|
+
'5311311213113161531132114311411243114211331151123311521123116112231162111221113622211144322111521221123522211243' +
|
|
197
|
+
'3221125112211334222113421221143322211441122115321221163113121144231211521221214413121243231212511221224322212251' +
|
|
198
|
+
'1221234213121441122124416312211113122152622131111221315213122251122132515312311152214111431241114221511133125111' +
|
|
199
|
+
'3221611123126111213111353131114341311151113112262131123431311242113113252131133331311341113114242131143211311523' +
|
|
200
|
+
'2131153111311622122211352222114332221151113121351222123422221242113122342131224222221341113123331222143211312432' +
|
|
201
|
+
'1222153111312531131311432313115112222143131312421131314312222242131313411131324212222341113133411313215112223151' +
|
|
202
|
+
'1131415111321126213211343132114211321225213212333132124111321324213213321132142321321431113215221132162112231134' +
|
|
203
|
+
'2223114211322134122312332223124111322233213222411132233212231431113224311314114212232142131412411132314212232241' +
|
|
204
|
+
'1132324111331125213311333133114111331224213312321133132321331331113314221133152112241133222411411133213312241232' +
|
|
205
|
+
'1133223212241331113323311315114112242141113331411134112421341132113412232134123111341322113414211225113211342132' +
|
|
206
|
+
'1225123111342231113511232135113111351222113513211226113111352131113611221136122114111144241111521411124324111251' +
|
|
207
|
+
'1411134214111441141121521411225154113111441141113411511124116111132111352321114333211151132112342321124213211333' +
|
|
208
|
+
'2321134113211432132115311412114324121151132121431412124213212242141213411321234114122151132131511231112622311134' +
|
|
209
|
+
'3231114212311225223112333231124112311324223113321231142322311431123115221231162113221134232211421231213413221233' +
|
|
210
|
+
'2322124112312233132213321231233213221431123124311413114213222142141312411231314213222241123132412141112531411133' +
|
|
211
|
+
'4141114111411216214112243141123211411315214113233141133111411414214114221141151321411521114116121232112522321133' +
|
|
212
|
+
'3232114111412125123212242232123211412224214122322232133111412323123214221141242212321521114125211323113323231141' +
|
|
213
|
+
'1232213313231232114131331232223213231331114132321232233111413331141411411323214112323141114141411142111621421124' +
|
|
214
|
+
'3142113211421215214212233142123111421314214213221142141321421421114215121142161112331124223311321142212412331223' +
|
|
215
|
+
'2233123111422223214222311142232212331421114224211324113212332132132412311142313212332231114232311143111521431123' +
|
|
216
|
+
'3143113111431214214312221143131321431321114314121143151112341123223411311143212312341222114322221234132111432321' +
|
|
217
|
+
'1325113112342131114331311144111421441122114412132144122111441312114414111235112211442122123512211144222111451113' +
|
|
218
|
+
'2145112111451212114513111236112111452121151111432511115115111242151113411511215114211134242111421421123324211241' +
|
|
219
|
+
'1421133214211431151211421421214215121241142122411331112523311133333111411331122423311232133113232331133113311422' +
|
|
220
|
+
'1331152114221133242211411331213314221232133122321422133113312331151311411422214113313141124111162241112432411132' +
|
|
221
|
+
'1241121522411223324112311241131422411322124114132241142112411512124116111332112423321132124121241332122323321231' +
|
|
222
|
+
'1241222322412231124123221332142112412421142311321332213214231231124131321332223112413231215111153151112341511131' +
|
|
223
|
+
'2151121431511222215113133151132121511412215115111242111522421123324211311151211512421214224212221151221421512222' +
|
|
224
|
+
'2242132111512313124214121151241212421511115125111333112323331131124221231333122211513123124222221333132111513222' +
|
|
225
|
+
'1242232111513321142411311333213112423131115141312152111431521122215212133152122121521312215214111243111422431122' +
|
|
226
|
+
'1152211412431213224312211152221321522221115223121243141111522411133411221243212213341221115231221243222111523221' +
|
|
227
|
+
'2153111331531121215312122153131112441113224411211153211312441212115322121244131111532311133511211244212111533121' +
|
|
228
|
+
'2154111221541211124511121154211212451211115422111611114216111241152111332521114115211232152113311612114115212141' +
|
|
229
|
+
'1431112424311132143112232431123114311322143114211522113214312132152212311431223113411115234111233341113113411214' +
|
|
230
|
+
'2341122213411313234113211341141213411511143211232432113113412123234121311341222214321321134123211523113114322131' +
|
|
231
|
+
'1341313122511114325111222251121332511221225113122251141113421114234211221251211422512122234212211251221313421312' +
|
|
232
|
+
'1251231213421411125124111433112213422122143312211251312213422221125132213161111341611121316112123161131122521113' +
|
|
233
|
+
'3252112121612113225212122161221222521311216123111343111323431121125221131343121211613113125222121343131111613212' +
|
|
234
|
+
'1252231111613311143411211343212112523121116141213162111231621211225311122162211222531211216222111344111212532112' +
|
|
235
|
+
'1344121111623112125322111162321131631111225411112163211113451111125421111163311116211132162112311531112325311131' +
|
|
236
|
+
'1531122215311321162211311531213114411114244111221441121324411221144113121441141115321122144121221532122114412221' +
|
|
237
|
+
'2351111333511121235112122351131114421113244211211351211323512121135122121442131113512311153311211442212113513121' +
|
|
238
|
+
'3261111232611211235211122261211223521211226122111443111213522112144312111261311213522211126132113262111123531111' +
|
|
239
|
+
'2262211114441111135321111262311116311122163112211541111325411121154112121541131116321121154121212451111224511211' +
|
|
240
|
+
'1542111214512112154212111451221133611111',
|
|
244
241
|
]);
|
|
245
|
-
|
|
246
242
|
function patternFromWidths(sequence) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
243
|
+
let pattern = 0;
|
|
244
|
+
for (let element = 0; element < 8; element++) {
|
|
245
|
+
const width = sequence.charCodeAt(element) - 48;
|
|
246
|
+
const dark = (element & 1) === 0;
|
|
247
|
+
for (let i = 0; i < width; i++)
|
|
248
|
+
pattern = (pattern << 1) | (dark ? 1 : 0);
|
|
249
|
+
}
|
|
250
|
+
return pattern;
|
|
254
251
|
}
|
|
255
|
-
|
|
256
252
|
/** Return the cluster discriminator for an eight-element bar/space sequence. */
|
|
257
253
|
export function pdf417ClusterForWidths(widths) {
|
|
258
|
-
|
|
259
|
-
|
|
254
|
+
if (!widths || widths.length !== 8)
|
|
255
|
+
throw new Error('PDF417: a character requires eight element widths');
|
|
256
|
+
return ((widths[0] - widths[2] + widths[4] - widths[6]) % 9 + 9) % 9;
|
|
260
257
|
}
|
|
261
|
-
|
|
262
258
|
function buildPatternTable() {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
259
|
+
const tables = WIDTH_SEQUENCES.map((source, tableIndex) => {
|
|
260
|
+
if (source.length !== PDF417_CODEWORDS_PER_CLUSTER * 8)
|
|
261
|
+
throw new Error('PDF417: corrupt pattern-table length');
|
|
262
|
+
const expectedCluster = PDF417_CLUSTER_NUMBERS[tableIndex];
|
|
263
|
+
const table = new Int32Array(PDF417_CODEWORDS_PER_CLUSTER);
|
|
264
|
+
const seen = new Set();
|
|
265
|
+
for (let codeword = 0; codeword < PDF417_CODEWORDS_PER_CLUSTER; codeword++) {
|
|
266
|
+
const sequence = source.slice(codeword * 8, codeword * 8 + 8);
|
|
267
|
+
const widths = Array.from(sequence, (digit) => digit.charCodeAt(0) - 48);
|
|
268
|
+
if (widths.some((width) => width < 1 || width > 6) || widths.reduce((sum, width) => sum + width, 0) !== 17) {
|
|
269
|
+
throw new Error('PDF417: corrupt pattern-table width');
|
|
270
|
+
}
|
|
271
|
+
if (pdf417ClusterForWidths(widths) !== expectedCluster)
|
|
272
|
+
throw new Error('PDF417: corrupt pattern-table cluster');
|
|
273
|
+
const pattern = patternFromWidths(sequence);
|
|
274
|
+
if (seen.has(pattern))
|
|
275
|
+
throw new Error('PDF417: duplicate pattern in cluster');
|
|
276
|
+
seen.add(pattern);
|
|
277
|
+
table[codeword] = pattern;
|
|
278
|
+
}
|
|
279
|
+
return Object.freeze(Array.from(table));
|
|
280
|
+
});
|
|
281
|
+
return Object.freeze(tables);
|
|
283
282
|
}
|
|
284
|
-
|
|
285
283
|
/** Pattern table indexed by cluster index (0, 1, 2) and codeword value. */
|
|
286
284
|
export const PDF417_PATTERN_TABLE = buildPatternTable();
|
|
287
285
|
const PATTERN_TO_CODEWORD = new Map();
|
|
288
286
|
for (let index = 0; index < PDF417_PATTERN_TABLE.length; index++) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
287
|
+
for (let codeword = 0; codeword < PDF417_CODEWORDS_PER_CLUSTER; codeword++) {
|
|
288
|
+
PATTERN_TO_CODEWORD.set(PDF417_PATTERN_TABLE[index][codeword], Object.freeze({
|
|
289
|
+
codeword, cluster: PDF417_CLUSTER_NUMBERS[index],
|
|
290
|
+
}));
|
|
291
|
+
}
|
|
294
292
|
}
|
|
295
|
-
|
|
296
293
|
/**
|
|
297
294
|
* Return the 17-bit bar/space pattern for a codeword in a row cluster.
|
|
298
295
|
* @param {number} codeword
|
|
@@ -300,18 +297,19 @@ for (let index = 0; index < PDF417_PATTERN_TABLE.length; index++) {
|
|
|
300
297
|
* @returns {number}
|
|
301
298
|
*/
|
|
302
299
|
export function pdf417PatternForCodeword(codeword, cluster) {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
300
|
+
if (!Number.isInteger(codeword) || codeword < 0 || codeword >= PDF417_CODEWORDS_PER_CLUSTER)
|
|
301
|
+
throw new Error('PDF417: codeword must be in 0..928');
|
|
302
|
+
const index = PDF417_CLUSTER_NUMBERS.indexOf(cluster);
|
|
303
|
+
if (index < 0)
|
|
304
|
+
throw new Error('PDF417: cluster must be 0, 3 or 6');
|
|
305
|
+
return PDF417_PATTERN_TABLE[index][codeword];
|
|
307
306
|
}
|
|
308
|
-
|
|
309
307
|
/**
|
|
310
308
|
* Decode an exact 17-bit symbol-character pattern to its codeword and cluster.
|
|
311
309
|
* @param {number} pattern
|
|
312
310
|
* @returns {{codeword: number, cluster: number} | null}
|
|
313
311
|
*/
|
|
314
312
|
export function pdf417CodewordForPattern(pattern) {
|
|
315
|
-
|
|
316
|
-
|
|
313
|
+
const result = PATTERN_TO_CODEWORD.get(pattern);
|
|
314
|
+
return result ? { ...result } : null;
|
|
317
315
|
}
|