@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.
Files changed (179) hide show
  1. package/LICENSE +5 -4
  2. package/NOTICE.md +2 -2
  3. package/README.md +17 -13
  4. package/bundle/sythos-barcode.esm.js +11658 -11244
  5. package/bundle/sythos-barcode.js +11658 -11244
  6. package/package.json +10 -3
  7. package/src/index.d.ts +1 -1
  8. package/src/index.js +508 -516
  9. package/src/js/aztec/decoder.js +208 -199
  10. package/src/js/aztec/detector.js +153 -126
  11. package/src/js/aztec/encoder.js +172 -153
  12. package/src/js/aztec/high-level.js +106 -101
  13. package/src/js/aztec/index.js +1 -12
  14. package/src/js/aztec/tables.js +106 -120
  15. package/src/js/aztecrune/decoder.js +76 -85
  16. package/src/js/aztecrune/detector.js +107 -93
  17. package/src/js/aztecrune/encoder.js +50 -68
  18. package/src/js/aztecrune/index.js +1 -16
  19. package/src/js/aztecrune/tables.js +59 -54
  20. package/src/js/compactpdf417/decoder.js +69 -74
  21. package/src/js/compactpdf417/detector.js +74 -75
  22. package/src/js/compactpdf417/encoder.js +68 -81
  23. package/src/js/compactpdf417/index.js +1 -13
  24. package/src/js/compactpdf417/tables.js +71 -80
  25. package/src/js/core/bit-buffer.js +106 -122
  26. package/src/js/core/bit-matrix.js +196 -194
  27. package/src/js/core/errors.js +13 -15
  28. package/src/js/core/galois-field.js +119 -133
  29. package/src/js/core/index.js +2 -19
  30. package/src/js/core/reed-solomon.js +195 -204
  31. package/src/js/databar/codec.js +93 -108
  32. package/src/js/databar/decoder.js +149 -140
  33. package/src/js/databar/encoder.js +47 -55
  34. package/src/js/databar/gs1.js +122 -123
  35. package/src/js/databar/index.js +4 -36
  36. package/src/js/databar/patterns.js +81 -85
  37. package/src/js/databar/tables.js +51 -52
  38. package/src/js/datamatrix/decoder.js +216 -182
  39. package/src/js/datamatrix/detector.js +161 -132
  40. package/src/js/datamatrix/encoder.js +192 -133
  41. package/src/js/datamatrix/index.js +1 -9
  42. package/src/js/datamatrix/tables.js +68 -69
  43. package/src/js/frameqr/decoder.js +102 -125
  44. package/src/js/frameqr/detector.js +101 -94
  45. package/src/js/frameqr/encoder.js +67 -80
  46. package/src/js/frameqr/index.js +1 -10
  47. package/src/js/frameqr/tables.js +145 -163
  48. package/src/js/image/binarizer.js +146 -162
  49. package/src/js/image/grid-sampler.js +63 -79
  50. package/src/js/image/index.js +0 -2
  51. package/src/js/image/luminance.js +129 -140
  52. package/src/js/image/perspective.js +112 -149
  53. package/src/js/micropdf417/compaction.js +64 -65
  54. package/src/js/micropdf417/decoder.js +106 -109
  55. package/src/js/micropdf417/detector.js +73 -70
  56. package/src/js/micropdf417/encoder.js +129 -154
  57. package/src/js/micropdf417/error-correction.js +6 -11
  58. package/src/js/micropdf417/index.js +2 -16
  59. package/src/js/micropdf417/tables.js +112 -99
  60. package/src/js/microqr/decoder.js +177 -182
  61. package/src/js/microqr/detector.js +240 -256
  62. package/src/js/microqr/encoder.js +239 -194
  63. package/src/js/microqr/index.js +0 -2
  64. package/src/js/microqr/tables.js +208 -200
  65. package/src/js/oned/addons.js +167 -191
  66. package/src/js/oned/index.js +27 -58
  67. package/src/js/oned/patterns.js +194 -213
  68. package/src/js/oned/reader.js +1003 -984
  69. package/src/js/oned/writers.js +411 -466
  70. package/src/js/pdf417/compaction.js +315 -222
  71. package/src/js/pdf417/decoder.js +71 -36
  72. package/src/js/pdf417/detector.js +377 -361
  73. package/src/js/pdf417/encoder.js +57 -46
  74. package/src/js/pdf417/error-correction.js +5 -8
  75. package/src/js/pdf417/tables.js +248 -250
  76. package/src/js/qr/decoder.js +311 -347
  77. package/src/js/qr/detector.js +378 -395
  78. package/src/js/qr/encoder.js +514 -599
  79. package/src/js/qr/index.js +0 -2
  80. package/src/js/qr/tables.js +375 -422
  81. package/src/js/render/image-data.js +57 -62
  82. package/src/js/render/index.js +21 -23
  83. package/src/js/render/options.js +82 -90
  84. package/src/js/render/png.js +144 -169
  85. package/src/js/render/svg.js +41 -44
  86. package/src/js/render/webgl.js +103 -109
  87. package/src/js/render/webgpu.js +205 -217
  88. package/src/js/rmqr/decoder.js +161 -53
  89. package/src/js/rmqr/detector.js +73 -41
  90. package/src/js/rmqr/encoder.js +253 -104
  91. package/src/js/rmqr/index.js +1 -5
  92. package/src/js/rmqr/tables.js +108 -85
  93. package/src/ts/aztec/decoder.ts +317 -0
  94. package/src/ts/aztec/detector.ts +224 -0
  95. package/src/ts/aztec/encoder.ts +257 -0
  96. package/src/ts/aztec/high-level.ts +211 -0
  97. package/src/ts/aztec/index.ts +45 -0
  98. package/src/ts/aztec/tables.ts +210 -0
  99. package/src/ts/aztecrune/decoder.ts +155 -0
  100. package/src/ts/aztecrune/detector.ts +166 -0
  101. package/src/ts/aztecrune/encoder.ts +121 -0
  102. package/src/ts/aztecrune/index.ts +49 -0
  103. package/src/ts/aztecrune/tables.ts +137 -0
  104. package/src/ts/compactpdf417/decoder.ts +128 -0
  105. package/src/ts/compactpdf417/detector.ts +139 -0
  106. package/src/ts/compactpdf417/encoder.ts +140 -0
  107. package/src/ts/compactpdf417/index.ts +17 -0
  108. package/src/ts/compactpdf417/tables.ts +173 -0
  109. package/src/ts/core/bit-buffer.ts +174 -0
  110. package/src/ts/core/bit-matrix.ts +241 -0
  111. package/src/ts/core/errors.ts +61 -0
  112. package/src/ts/core/galois-field.ts +207 -0
  113. package/src/ts/core/index.ts +56 -0
  114. package/src/ts/core/reed-solomon.ts +327 -0
  115. package/src/ts/databar/codec.ts +181 -0
  116. package/src/ts/databar/decoder.ts +215 -0
  117. package/src/ts/databar/encoder.ts +96 -0
  118. package/src/ts/databar/gs1.ts +177 -0
  119. package/src/ts/databar/index.ts +68 -0
  120. package/src/ts/databar/patterns.ts +143 -0
  121. package/src/ts/databar/tables.ts +124 -0
  122. package/src/ts/datamatrix/decoder.ts +262 -0
  123. package/src/ts/datamatrix/detector.ts +225 -0
  124. package/src/ts/datamatrix/encoder.ts +191 -0
  125. package/src/ts/datamatrix/index.ts +42 -0
  126. package/src/ts/datamatrix/tables.ts +123 -0
  127. package/src/ts/frameqr/decoder.ts +239 -0
  128. package/src/ts/frameqr/detector.ts +192 -0
  129. package/src/ts/frameqr/encoder.ts +156 -0
  130. package/src/ts/frameqr/index.ts +42 -0
  131. package/src/ts/frameqr/tables.ts +270 -0
  132. package/src/ts/image/binarizer.ts +270 -0
  133. package/src/ts/image/grid-sampler.ts +164 -0
  134. package/src/ts/image/index.ts +40 -0
  135. package/src/ts/image/luminance.ts +196 -0
  136. package/src/ts/image/perspective.ts +195 -0
  137. package/src/ts/index.d.ts +1 -1
  138. package/src/ts/index.ts +790 -0
  139. package/src/ts/micropdf417/compaction.ts +116 -0
  140. package/src/ts/micropdf417/decoder.ts +183 -0
  141. package/src/ts/micropdf417/detector.ts +149 -0
  142. package/src/ts/micropdf417/encoder.ts +209 -0
  143. package/src/ts/micropdf417/error-correction.ts +55 -0
  144. package/src/ts/micropdf417/index.ts +49 -0
  145. package/src/ts/micropdf417/tables.ts +184 -0
  146. package/src/ts/microqr/decoder.ts +245 -0
  147. package/src/ts/microqr/detector.ts +355 -0
  148. package/src/ts/microqr/encoder.ts +269 -0
  149. package/src/ts/microqr/index.ts +36 -0
  150. package/src/ts/microqr/tables.ts +316 -0
  151. package/src/ts/oned/addons.ts +420 -0
  152. package/src/ts/oned/index.ts +106 -0
  153. package/src/ts/oned/patterns.ts +384 -0
  154. package/src/ts/oned/reader.ts +1364 -0
  155. package/src/ts/oned/writers.ts +746 -0
  156. package/src/ts/pdf417/compaction.ts +298 -0
  157. package/src/ts/pdf417/decoder.ts +75 -0
  158. package/src/ts/pdf417/detector.ts +468 -0
  159. package/src/ts/pdf417/encoder.ts +91 -0
  160. package/src/ts/pdf417/error-correction.ts +47 -0
  161. package/src/ts/pdf417/index.ts +6 -0
  162. package/src/ts/pdf417/tables.ts +317 -0
  163. package/src/ts/qr/decoder.ts +575 -0
  164. package/src/ts/qr/detector.ts +630 -0
  165. package/src/ts/qr/encoder.ts +958 -0
  166. package/src/ts/qr/index.ts +44 -0
  167. package/src/ts/qr/tables.ts +737 -0
  168. package/src/ts/render/image-data.ts +125 -0
  169. package/src/ts/render/index.ts +130 -0
  170. package/src/ts/render/options.ts +160 -0
  171. package/src/ts/render/png.ts +295 -0
  172. package/src/ts/render/svg.ts +120 -0
  173. package/src/ts/render/webgl.ts +206 -0
  174. package/src/ts/render/webgpu.ts +369 -0
  175. package/src/ts/rmqr/decoder.ts +101 -0
  176. package/src/ts/rmqr/detector.ts +90 -0
  177. package/src/ts/rmqr/encoder.ts +172 -0
  178. package/src/ts/rmqr/index.ts +37 -0
  179. package/src/ts/rmqr/tables.ts +154 -0
@@ -27,7 +27,6 @@
27
27
  *
28
28
  * Original work. No code from any other barcode implementation.
29
29
  */
30
-
31
30
  /**
32
31
  * MicroPDF417 format facts and Row Address Pattern (RAP) helpers.
33
32
  *
@@ -42,143 +41,157 @@
42
41
  *
43
42
  * @module micropdf417/tables
44
43
  */
45
-
46
44
  const variant = (id, columns, rows, eccCodewords, rapStart, rapRotation) => Object.freeze({
47
- id,
48
- columns,
49
- rows,
50
- totalCodewords: columns * rows,
51
- dataCodewords: columns * rows - eccCodewords,
52
- eccCodewords,
53
- rapStart,
54
- rapRotation,
45
+ id,
46
+ columns,
47
+ rows,
48
+ totalCodewords: columns * rows,
49
+ dataCodewords: columns * rows - eccCodewords,
50
+ eccCodewords,
51
+ rapStart,
52
+ rapRotation,
55
53
  });
56
-
57
54
  /** All 34 predefined MicroPDF417 symbol variants, in format-table order. */
58
55
  export const MICROPDF417_VARIANTS = Object.freeze([
59
- variant(1, 1, 11, 7, 1, 8), variant(2, 1, 14, 7, 8, 0),
60
- variant(3, 1, 17, 7, 36, 0), variant(4, 1, 20, 8, 19, 0),
61
- variant(5, 1, 24, 8, 9, 8), variant(6, 1, 28, 8, 25, 8),
62
- variant(7, 2, 8, 8, 1, 0), variant(8, 2, 11, 9, 1, 8),
63
- variant(9, 2, 14, 9, 8, 0), variant(10, 2, 17, 10, 36, 0),
64
- variant(11, 2, 20, 11, 19, 0), variant(12, 2, 23, 13, 9, 8),
65
- variant(13, 2, 26, 15, 27, 8),
66
- variant(14, 3, 6, 12, 1, 0), variant(15, 3, 8, 14, 7, 0),
67
- variant(16, 3, 10, 16, 15, 0), variant(17, 3, 12, 18, 25, 0),
68
- variant(18, 3, 15, 21, 37, 0), variant(19, 3, 20, 26, 1, 16),
69
- variant(20, 3, 26, 32, 1, 8), variant(21, 3, 32, 38, 21, 8),
70
- variant(22, 3, 38, 44, 15, 16), variant(23, 3, 44, 50, 1, 24),
71
- variant(24, 4, 4, 8, 47, 24), variant(25, 4, 6, 12, 1, 0),
72
- variant(26, 4, 8, 14, 7, 0), variant(27, 4, 10, 16, 15, 0),
73
- variant(28, 4, 12, 18, 25, 0), variant(29, 4, 15, 21, 37, 0),
74
- variant(30, 4, 20, 26, 1, 16), variant(31, 4, 26, 32, 1, 8),
75
- variant(32, 4, 32, 38, 21, 8), variant(33, 4, 38, 44, 15, 16),
76
- variant(34, 4, 44, 50, 1, 24),
56
+ variant(1, 1, 11, 7, 1, 8), variant(2, 1, 14, 7, 8, 0),
57
+ variant(3, 1, 17, 7, 36, 0), variant(4, 1, 20, 8, 19, 0),
58
+ variant(5, 1, 24, 8, 9, 8), variant(6, 1, 28, 8, 25, 8),
59
+ variant(7, 2, 8, 8, 1, 0), variant(8, 2, 11, 9, 1, 8),
60
+ variant(9, 2, 14, 9, 8, 0), variant(10, 2, 17, 10, 36, 0),
61
+ variant(11, 2, 20, 11, 19, 0), variant(12, 2, 23, 13, 9, 8),
62
+ variant(13, 2, 26, 15, 27, 8),
63
+ variant(14, 3, 6, 12, 1, 0), variant(15, 3, 8, 14, 7, 0),
64
+ variant(16, 3, 10, 16, 15, 0), variant(17, 3, 12, 18, 25, 0),
65
+ variant(18, 3, 15, 21, 37, 0), variant(19, 3, 20, 26, 1, 16),
66
+ variant(20, 3, 26, 32, 1, 8), variant(21, 3, 32, 38, 21, 8),
67
+ variant(22, 3, 38, 44, 15, 16), variant(23, 3, 44, 50, 1, 24),
68
+ variant(24, 4, 4, 8, 47, 24), variant(25, 4, 6, 12, 1, 0),
69
+ variant(26, 4, 8, 14, 7, 0), variant(27, 4, 10, 16, 15, 0),
70
+ variant(28, 4, 12, 18, 25, 0), variant(29, 4, 15, 21, 37, 0),
71
+ variant(30, 4, 20, 26, 1, 16), variant(31, 4, 26, 32, 1, 8),
72
+ variant(32, 4, 32, 38, 21, 8), variant(33, 4, 38, 44, 15, 16),
73
+ variant(34, 4, 44, 50, 1, 24),
77
74
  ]);
78
-
79
75
  const byId = new Map(MICROPDF417_VARIANTS.map((entry) => [entry.id, entry]));
80
-
81
76
  // Six run widths, ordered bar-space-bar-space-bar-space. A RAP is ten
82
77
  // modules wide; the right RAP has one additional one-module stop bar when
83
78
  // rendered. Keeping runs rather than bitmap literals makes each invariant
84
79
  // inspectable and avoids a rendering-specific representation here.
85
80
  const SIDE_RAP_RUNS = Object.freeze([
86
- '221311', '311311', '312211', '222211', '213211', '214111', '223111', '313111',
87
- '322111', '412111', '421111', '331111', '241111', '232111', '231211', '321211',
88
- '411211', '411121', '411112', '321112', '312112', '311212', '311221', '311131',
89
- '311122', '311113', '221113', '221122', '221131', '221221', '222121', '312121',
90
- '321121', '231121', '231112', '222112', '213112', '212212', '212221', '212131',
91
- '212122', '212113', '211213', '211123', '211132', '211141', '211231', '211222',
92
- '211312', '211321', '211411', '212311',
81
+ '221311', '311311', '312211', '222211', '213211', '214111', '223111', '313111',
82
+ '322111', '412111', '421111', '331111', '241111', '232111', '231211', '321211',
83
+ '411211', '411121', '411112', '321112', '312112', '311212', '311221', '311131',
84
+ '311122', '311113', '221113', '221122', '221131', '221221', '222121', '312121',
85
+ '321121', '231121', '231112', '222112', '213112', '212212', '212221', '212131',
86
+ '212122', '212113', '211213', '211123', '211132', '211141', '211231', '211222',
87
+ '211312', '211321', '211411', '212311',
93
88
  ]);
94
-
95
89
  const CENTER_RAP_RUNS = Object.freeze([
96
- '112231', '121231', '122131', '131131', '131221', '132121', '141121', '141211',
97
- '142111', '133111', '132211', '131311', '122311', '123211', '124111', '115111',
98
- '114211', '114121', '123121', '123112', '122212', '122221', '121321', '121411',
99
- '112411', '113311', '113221', '113212', '113122', '122122', '131122', '131113',
100
- '122113', '113113', '112213', '112222', '112312', '112321', '111421', '111331',
101
- '111322', '111232', '111223', '111133', '111124', '111214', '112114', '121114',
102
- '121123', '121132', '112132', '112141',
90
+ '112231', '121231', '122131', '131131', '131221', '132121', '141121', '141211',
91
+ '142111', '133111', '132211', '131311', '122311', '123211', '124111', '115111',
92
+ '114211', '114121', '123121', '123112', '122212', '122221', '121321', '121411',
93
+ '112411', '113311', '113221', '113212', '113122', '122122', '131122', '131113',
94
+ '122113', '113113', '112213', '112222', '112312', '112321', '111421', '111331',
95
+ '111322', '111232', '111223', '111133', '111124', '111214', '112114', '121114',
96
+ '121123', '121132', '112132', '112141',
103
97
  ]);
104
-
105
98
  /** @param {number} value @param {number} offset @returns {number} */
106
99
  export function microPdf417NextRap(value, offset = 1) {
107
- if (!Number.isInteger(value) || value < 1 || value > 52) throw new RangeError('MicroPDF417: RAP number must be in 1..52');
108
- if (!Number.isInteger(offset)) throw new RangeError('MicroPDF417: RAP offset must be an integer');
109
- return ((value - 1 + offset) % 52 + 52) % 52 + 1;
100
+ if (!Number.isInteger(value) || value < 1 || value > 52)
101
+ throw new RangeError('MicroPDF417: RAP number must be in 1..52');
102
+ if (!Number.isInteger(offset))
103
+ throw new RangeError('MicroPDF417: RAP offset must be an integer');
104
+ return ((value - 1 + offset) % 52 + 52) % 52 + 1;
110
105
  }
111
-
112
106
  /** @param {number} id @returns {Readonly<typeof MICROPDF417_VARIANTS[number]>} */
113
107
  export function microPdf417VariantByNumber(id) {
114
- const entry = byId.get(id);
115
- if (!entry) throw new RangeError('MicroPDF417: variant must be an integer in 1..34');
116
- return entry;
108
+ const entry = byId.get(id);
109
+ if (!entry)
110
+ throw new RangeError('MicroPDF417: variant must be an integer in 1..34');
111
+ return entry;
117
112
  }
118
-
119
113
  /**
120
114
  * Return the smallest data-region candidate that fits `codewords`.
121
115
  * Ties are resolved by width, then height, so selection is deterministic.
122
116
  */
123
117
  export function microPdf417VariantForCapacity(codewords) {
124
- if (!Number.isInteger(codewords) || codewords < 1) throw new RangeError('MicroPDF417: codeword capacity must be a positive integer');
125
- const candidates = MICROPDF417_VARIANTS.filter((entry) => entry.dataCodewords >= codewords);
126
- if (!candidates.length) throw new RangeError('MicroPDF417: payload exceeds the largest symbol data region');
127
- return candidates.slice().sort((a, b) => a.totalCodewords - b.totalCodewords || a.columns - b.columns || a.rows - b.rows)[0];
118
+ if (!Number.isInteger(codewords) || codewords < 1)
119
+ throw new RangeError('MicroPDF417: codeword capacity must be a positive integer');
120
+ const candidates = MICROPDF417_VARIANTS.filter((entry) => entry.dataCodewords >= codewords);
121
+ if (!candidates.length)
122
+ throw new RangeError('MicroPDF417: payload exceeds the largest symbol data region');
123
+ return candidates.slice().sort((a, b) => a.totalCodewords - b.totalCodewords || a.columns - b.columns || a.rows - b.rows)[0];
128
124
  }
129
-
130
125
  /** Return the six bar/space run widths for a numbered side or center RAP. */
131
126
  export function microPdf417RapSequence(number, kind = 'side') {
132
- if (!Number.isInteger(number) || number < 1 || number > 52) throw new RangeError('MicroPDF417: RAP number must be in 1..52');
133
- if (kind === 'side') return SIDE_RAP_RUNS[number - 1];
134
- if (kind === 'center') return CENTER_RAP_RUNS[number - 1];
135
- throw new RangeError('MicroPDF417: RAP kind must be side or center');
127
+ if (!Number.isInteger(number) || number < 1 || number > 52)
128
+ throw new RangeError('MicroPDF417: RAP number must be in 1..52');
129
+ if (kind === 'side')
130
+ return SIDE_RAP_RUNS[number - 1];
131
+ if (kind === 'center')
132
+ return CENTER_RAP_RUNS[number - 1];
133
+ throw new RangeError('MicroPDF417: RAP kind must be side or center');
136
134
  }
137
-
138
135
  /**
139
136
  * Resolve all row-address data for a zero-based row within a variant.
140
137
  * @returns {{left: number, center: number|null, right: number, cluster: 0|3|6}}
141
138
  */
142
139
  export function microPdf417RowAddress(entry, row) {
143
- if (!entry || !Number.isInteger(entry.columns) || !Number.isInteger(entry.rows)) throw new TypeError('MicroPDF417: a variant entry is required');
144
- if (!Number.isInteger(row) || row < 0 || row >= entry.rows) throw new RangeError(`MicroPDF417: row must be in 0..${entry.rows - 1}`);
145
- const left = microPdf417NextRap(entry.rapStart, row);
146
- const cluster = /** @type {0|3|6} */ (((left - 1) % 3) * 3);
147
- if (entry.columns < 3) return { left, center: null, right: microPdf417NextRap(left, entry.rapRotation), cluster };
148
- const center = microPdf417NextRap(left, entry.rapRotation);
149
- return { left, center, right: microPdf417NextRap(center, entry.rapRotation), cluster };
140
+ if (!entry || !Number.isInteger(entry.columns) || !Number.isInteger(entry.rows))
141
+ throw new TypeError('MicroPDF417: a variant entry is required');
142
+ if (!Number.isInteger(row) || row < 0 || row >= entry.rows)
143
+ throw new RangeError(`MicroPDF417: row must be in 0..${entry.rows - 1}`);
144
+ const left = microPdf417NextRap(entry.rapStart, row);
145
+ const cluster = /** @type {0|3|6} */ (((left - 1) % 3) * 3);
146
+ if (entry.columns < 3)
147
+ return { left, center: null, right: microPdf417NextRap(left, entry.rapRotation), cluster };
148
+ const center = microPdf417NextRap(left, entry.rapRotation);
149
+ return { left, center, right: microPdf417NextRap(center, entry.rapRotation), cluster };
150
150
  }
151
-
152
151
  const validRuns = (runs) => runs.length === 6 && /^[1-9]{6}$/.test(runs) && [...runs].reduce((sum, digit) => sum + Number(digit), 0) === 10;
153
152
  const oneEdgeShift = (from, to) => [...from].reduce((sum, digit, index) => sum + Math.abs(Number(digit) - Number(to[index])), 0) === 2;
154
-
155
153
  /** Return any table-invariant failures; an empty result means the table is coherent. */
156
154
  export function validateMicroPdf417Tables() {
157
- const issues = [];
158
- if (MICROPDF417_VARIANTS.length !== 34) issues.push('expected 34 variants');
159
- const ids = new Set();
160
- const formats = new Set();
161
- for (const entry of MICROPDF417_VARIANTS) {
162
- if (ids.has(entry.id)) issues.push(`duplicate variant ${entry.id}`); ids.add(entry.id);
163
- const format = `${entry.columns}x${entry.rows}`;
164
- if (formats.has(format)) issues.push(`duplicate format ${format}`); formats.add(format);
165
- if (entry.totalCodewords !== entry.columns * entry.rows) issues.push(`${format}: total codeword geometry mismatch`);
166
- if (entry.dataCodewords + entry.eccCodewords !== entry.totalCodewords) issues.push(`${format}: data/ECC capacity mismatch`);
167
- if (entry.eccCodewords < 7 || entry.eccCodewords > 50) issues.push(`${format}: invalid ECC length`);
168
- if (entry.rapStart < 1 || entry.rapStart > 52 || entry.rapRotation < 0 || entry.rapRotation > 51) issues.push(`${format}: invalid RAP assignment`);
169
- for (let row = 0; row < entry.rows; row++) {
170
- const address = microPdf417RowAddress(entry, row);
171
- if (address.cluster !== ((address.left - 1) % 3) * 3) issues.push(`${format}: cluster mismatch at row ${row}`);
172
- if ((entry.columns < 3) !== (address.center === null)) issues.push(`${format}: center RAP layout mismatch`);
155
+ const issues = [];
156
+ if (MICROPDF417_VARIANTS.length !== 34)
157
+ issues.push('expected 34 variants');
158
+ const ids = new Set();
159
+ const formats = new Set();
160
+ for (const entry of MICROPDF417_VARIANTS) {
161
+ if (ids.has(entry.id))
162
+ issues.push(`duplicate variant ${entry.id}`);
163
+ ids.add(entry.id);
164
+ const format = `${entry.columns}x${entry.rows}`;
165
+ if (formats.has(format))
166
+ issues.push(`duplicate format ${format}`);
167
+ formats.add(format);
168
+ if (entry.totalCodewords !== entry.columns * entry.rows)
169
+ issues.push(`${format}: total codeword geometry mismatch`);
170
+ if (entry.dataCodewords + entry.eccCodewords !== entry.totalCodewords)
171
+ issues.push(`${format}: data/ECC capacity mismatch`);
172
+ if (entry.eccCodewords < 7 || entry.eccCodewords > 50)
173
+ issues.push(`${format}: invalid ECC length`);
174
+ if (entry.rapStart < 1 || entry.rapStart > 52 || entry.rapRotation < 0 || entry.rapRotation > 51)
175
+ issues.push(`${format}: invalid RAP assignment`);
176
+ for (let row = 0; row < entry.rows; row++) {
177
+ const address = microPdf417RowAddress(entry, row);
178
+ if (address.cluster !== ((address.left - 1) % 3) * 3)
179
+ issues.push(`${format}: cluster mismatch at row ${row}`);
180
+ if ((entry.columns < 3) !== (address.center === null))
181
+ issues.push(`${format}: center RAP layout mismatch`);
182
+ }
173
183
  }
174
- }
175
- for (const [kind, runs] of [['side', SIDE_RAP_RUNS], ['center', CENTER_RAP_RUNS]]) {
176
- if (runs.length !== 52) issues.push(`${kind}: expected 52 RAPs`);
177
- if (new Set(runs).size !== runs.length) issues.push(`${kind}: duplicate RAP`);
178
- for (let i = 0; i < runs.length; i++) {
179
- if (!validRuns(runs[i])) issues.push(`${kind}: invalid RAP ${i + 1}`);
180
- if (runs.length && !oneEdgeShift(runs[i], runs[(i + 1) % runs.length])) issues.push(`${kind}: RAP ${i + 1} is not adjacent to its successor`);
184
+ for (const [kind, runs] of [['side', SIDE_RAP_RUNS], ['center', CENTER_RAP_RUNS]]) {
185
+ if (runs.length !== 52)
186
+ issues.push(`${kind}: expected 52 RAPs`);
187
+ if (new Set(runs).size !== runs.length)
188
+ issues.push(`${kind}: duplicate RAP`);
189
+ for (let i = 0; i < runs.length; i++) {
190
+ if (!validRuns(runs[i]))
191
+ issues.push(`${kind}: invalid RAP ${i + 1}`);
192
+ if (runs.length && !oneEdgeShift(runs[i], runs[(i + 1) % runs.length]))
193
+ issues.push(`${kind}: RAP ${i + 1} is not adjacent to its successor`);
194
+ }
181
195
  }
182
- }
183
- return issues;
196
+ return issues;
184
197
  }