@sythos/js_barcode_universal 1.5.13 → 1.5.15

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 (137) hide show
  1. package/LICENSE +22 -4
  2. package/NOTICE.md +10 -1
  3. package/README.md +416 -22
  4. package/bundle/sythos-barcode.esm.js +22176 -11991
  5. package/bundle/sythos-barcode.js +22059 -11991
  6. package/licenses/README.md +12 -1
  7. package/licenses/codablockf.license +51 -0
  8. package/licenses/code16k.license +52 -0
  9. package/licenses/code25.license +58 -0
  10. package/licenses/code32.license +51 -0
  11. package/licenses/dotcode.license +66 -0
  12. package/licenses/gs1-composite.license +106 -0
  13. package/licenses/gs1-databar.license +21 -14
  14. package/licenses/hanxin.license +95 -0
  15. package/licenses/maxicode.license +62 -0
  16. package/licenses/postal.license +61 -0
  17. package/licenses/pzn.license +53 -0
  18. package/licenses/telepen.license +73 -0
  19. package/llms.txt +62 -6
  20. package/package.json +47 -3
  21. package/src/index.d.ts +111 -6
  22. package/src/index.js +362 -13
  23. package/src/js/codablockf/decoder.js +198 -0
  24. package/src/js/codablockf/encoder.js +97 -0
  25. package/src/js/codablockf/index.js +3 -0
  26. package/src/js/code16k/decoder.js +303 -0
  27. package/src/js/code16k/detector.js +187 -0
  28. package/src/js/code16k/encoder.js +153 -0
  29. package/src/js/code16k/index.js +14 -0
  30. package/src/js/code16k/tables.js +152 -0
  31. package/src/js/composite/index.js +570 -0
  32. package/src/js/core/detection-contract.js +185 -0
  33. package/src/js/core/symbol-layout.js +155 -0
  34. package/src/js/databar/expanded.js +968 -0
  35. package/src/js/databar/index.js +4 -0
  36. package/src/js/databar/layout.js +192 -0
  37. package/src/js/databar/limited.js +533 -0
  38. package/src/js/databar/stacked-omnidirectional.js +548 -0
  39. package/src/js/databar/stacked.js +528 -0
  40. package/src/js/dotcode/decoder.js +548 -0
  41. package/src/js/dotcode/detector.js +251 -0
  42. package/src/js/dotcode/encoder.js +453 -0
  43. package/src/js/dotcode/index.js +34 -0
  44. package/src/js/dotcode/tables.js +168 -0
  45. package/src/js/hanxin/decoder.js +299 -0
  46. package/src/js/hanxin/detector.js +122 -0
  47. package/src/js/hanxin/encoder.js +259 -0
  48. package/src/js/hanxin/index.js +16 -0
  49. package/src/js/hanxin/tables.js +316 -0
  50. package/src/js/image/height-coded.js +164 -0
  51. package/src/js/maxicode/decoder.js +275 -0
  52. package/src/js/maxicode/detector.js +118 -0
  53. package/src/js/maxicode/encoder.js +438 -0
  54. package/src/js/maxicode/index.js +34 -0
  55. package/src/js/maxicode/tables.js +132 -0
  56. package/src/js/oned/code25.js +148 -0
  57. package/src/js/oned/index.js +21 -3
  58. package/src/js/oned/postal.js +889 -0
  59. package/src/js/oned/reader.js +272 -7
  60. package/src/js/oned/telepen.js +361 -0
  61. package/src/js/oned/writers.js +186 -12
  62. package/src/js/stacked128/common.js +208 -0
  63. package/src/ts/codablockf/decoder.ts +212 -0
  64. package/src/ts/codablockf/encoder.ts +128 -0
  65. package/src/ts/codablockf/index.d.ts +31 -0
  66. package/src/ts/codablockf/index.ts +6 -0
  67. package/src/ts/code16k/decoder.d.ts +25 -0
  68. package/src/ts/code16k/decoder.ts +313 -0
  69. package/src/ts/code16k/detector.d.ts +21 -0
  70. package/src/ts/code16k/detector.ts +203 -0
  71. package/src/ts/code16k/encoder.d.ts +26 -0
  72. package/src/ts/code16k/encoder.ts +198 -0
  73. package/src/ts/code16k/index.d.ts +10 -0
  74. package/src/ts/code16k/index.ts +47 -0
  75. package/src/ts/code16k/tables.d.ts +54 -0
  76. package/src/ts/code16k/tables.ts +195 -0
  77. package/src/ts/composite/index.d.ts +74 -0
  78. package/src/ts/composite/index.ts +547 -0
  79. package/src/ts/core/detection-contract.d.ts +119 -0
  80. package/src/ts/core/detection-contract.ts +267 -0
  81. package/src/ts/core/symbol-layout.d.ts +108 -0
  82. package/src/ts/core/symbol-layout.ts +236 -0
  83. package/src/ts/databar/expanded.d.ts +40 -0
  84. package/src/ts/databar/expanded.ts +948 -0
  85. package/src/ts/databar/index.d.ts +48 -0
  86. package/src/ts/databar/index.ts +48 -0
  87. package/src/ts/databar/layout.d.ts +122 -0
  88. package/src/ts/databar/layout.ts +275 -0
  89. package/src/ts/databar/limited.d.ts +85 -0
  90. package/src/ts/databar/limited.ts +553 -0
  91. package/src/ts/databar/stacked-omnidirectional.d.ts +128 -0
  92. package/src/ts/databar/stacked-omnidirectional.ts +559 -0
  93. package/src/ts/databar/stacked.d.ts +96 -0
  94. package/src/ts/databar/stacked.ts +549 -0
  95. package/src/ts/dotcode/decoder.d.ts +58 -0
  96. package/src/ts/dotcode/decoder.ts +467 -0
  97. package/src/ts/dotcode/detector.d.ts +63 -0
  98. package/src/ts/dotcode/detector.ts +263 -0
  99. package/src/ts/dotcode/encoder.d.ts +69 -0
  100. package/src/ts/dotcode/encoder.ts +427 -0
  101. package/src/ts/dotcode/index.d.ts +37 -0
  102. package/src/ts/dotcode/index.ts +72 -0
  103. package/src/ts/dotcode/tables.d.ts +74 -0
  104. package/src/ts/dotcode/tables.ts +174 -0
  105. package/src/ts/hanxin/decoder.d.ts +48 -0
  106. package/src/ts/hanxin/decoder.ts +314 -0
  107. package/src/ts/hanxin/detector.d.ts +45 -0
  108. package/src/ts/hanxin/detector.ts +124 -0
  109. package/src/ts/hanxin/encoder.d.ts +41 -0
  110. package/src/ts/hanxin/encoder.ts +290 -0
  111. package/src/ts/hanxin/index.d.ts +16 -0
  112. package/src/ts/hanxin/index.ts +18 -0
  113. package/src/ts/hanxin/tables.d.ts +80 -0
  114. package/src/ts/hanxin/tables.ts +348 -0
  115. package/src/ts/image/height-coded.d.ts +101 -0
  116. package/src/ts/image/height-coded.ts +227 -0
  117. package/src/ts/index.d.ts +46 -2
  118. package/src/ts/index.ts +380 -13
  119. package/src/ts/maxicode/decoder.ts +265 -0
  120. package/src/ts/maxicode/detector.ts +109 -0
  121. package/src/ts/maxicode/encoder.ts +414 -0
  122. package/src/ts/maxicode/index.d.ts +96 -0
  123. package/src/ts/maxicode/index.ts +44 -0
  124. package/src/ts/maxicode/tables.ts +136 -0
  125. package/src/ts/oned/code25.d.ts +42 -0
  126. package/src/ts/oned/code25.ts +170 -0
  127. package/src/ts/oned/index.d.ts +7 -2
  128. package/src/ts/oned/index.ts +45 -3
  129. package/src/ts/oned/postal.d.ts +44 -0
  130. package/src/ts/oned/postal.ts +819 -0
  131. package/src/ts/oned/reader.d.ts +35 -0
  132. package/src/ts/oned/reader.ts +261 -7
  133. package/src/ts/oned/telepen.d.ts +65 -0
  134. package/src/ts/oned/telepen.ts +368 -0
  135. package/src/ts/oned/writers.d.ts +32 -0
  136. package/src/ts/oned/writers.ts +184 -13
  137. package/src/ts/stacked128/common.ts +225 -0
@@ -33,4 +33,8 @@ export { GS1_SEPARATOR, decodeGS1ElementString, encodeGS1ElementString, formatGS
33
33
  export { DATABAR14_VARIANTS, DATABAR_LIMITED_VARIANT, dataBar14GroupFor, validateDataBarTables, } from './tables.js';
34
34
  export { encodeDataBar14 } from './encoder.js';
35
35
  export { decodeDataBar14, decodeDataBar14Scanline } from './decoder.js';
36
+ export { encodeDataBarLimited, decodeDataBarLimited, detectDataBarLimited, detectAndDecodeDataBarLimited, decodeDataBarLimitedScanline, } from './limited.js';
37
+ export { encodeDataBarExpanded, decodeDataBarExpanded, detectDataBarExpanded, detectAndDecodeDataBarExpanded, decodeDataBarExpandedScanline, encodeGS1DataBarExpanded, decodeGS1DataBarExpanded, detectGS1DataBarExpanded, detectAndDecodeGS1DataBarExpanded, } from './expanded.js';
38
+ export { encodeDataBar14Stacked, decodeDataBar14Stacked, detectDataBar14Stacked, detectAndDecodeDataBar14Stacked, encodeDataBarStacked, decodeDataBarStacked, detectDataBarStacked, detectAndDecodeDataBarStacked, encodeGS1DataBarStacked, decodeGS1DataBarStacked, detectGS1DataBarStacked, detectAndDecodeGS1DataBarStacked, } from './stacked.js';
39
+ export { encodeDataBarStackedOmnidirectional, decodeDataBarStackedOmnidirectional, detectDataBarStackedOmnidirectional, detectAndDecodeDataBarStackedOmnidirectional, encodeDataBarStackedOmni, decodeDataBarStackedOmni, detectDataBarStackedOmni, detectAndDecodeDataBarStackedOmni, encodeDataBar14StackedOmnidirectional, decodeDataBar14StackedOmnidirectional, detectDataBar14StackedOmnidirectional, encodeDataBar14StackedOmni, decodeDataBar14StackedOmni, detectDataBar14StackedOmni, } from './stacked-omnidirectional.js';
36
40
  export { DATABAR14_CHECKSUM_WEIGHTS, DATABAR14_FINDERS, dataBar14CharacterWidths, dataBar14ValueForWidths, dataBarWidths, } from './patterns.js';
@@ -0,0 +1,192 @@
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-License-Identifier: MIT
27
+ *
28
+ * Original work. No code from any other barcode implementation.
29
+ */
30
+ /*
31
+ * These limits are intentionally conservative. They keep a future renderer
32
+ * from receiving dimensions that are technically safe JavaScript integers but
33
+ * impractical to materialise. No matrix is allocated by this module.
34
+ */
35
+ const MAX_LAYOUT_DIMENSION = 32768;
36
+ const MAX_LAYOUT_MODULES = 16777216;
37
+ const DATA_BAR_LAYOUT_IDS = Object.freeze([
38
+ 'omni',
39
+ 'truncated',
40
+ 'limited',
41
+ 'stacked',
42
+ 'stacked-omni',
43
+ 'expanded',
44
+ 'expanded-stacked',
45
+ 'omnidirectional',
46
+ 'stacked-omnidirectional',
47
+ ]);
48
+ const STACKED_LAYOUT_IDS = Object.freeze([
49
+ 'stacked',
50
+ 'stacked-omni',
51
+ 'expanded-stacked',
52
+ 'stacked-omnidirectional',
53
+ ]);
54
+ const hasOwn = (value, property) => Object.prototype.hasOwnProperty.call(value, property);
55
+ function isRecord(value) {
56
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
57
+ }
58
+ function isBoundedPositiveInteger(value) {
59
+ return typeof value === 'number'
60
+ && Number.isSafeInteger(value)
61
+ && value > 0
62
+ && value <= MAX_LAYOUT_DIMENSION;
63
+ }
64
+ function isBoundedNonNegativeInteger(value) {
65
+ return typeof value === 'number'
66
+ && Number.isSafeInteger(value)
67
+ && value >= 0
68
+ && value <= MAX_LAYOUT_DIMENSION;
69
+ }
70
+ function isLayoutId(value) {
71
+ return typeof value === 'string'
72
+ && DATA_BAR_LAYOUT_IDS.includes(value);
73
+ }
74
+ function isStackedId(id) {
75
+ return STACKED_LAYOUT_IDS.includes(id);
76
+ }
77
+ /**
78
+ * Calculate the active (quiet-zone-free) matrix dimensions for a descriptor.
79
+ * The result is safe because callers first pass the descriptor through the
80
+ * bounded validation checks.
81
+ */
82
+ function activeHeight(layout) {
83
+ return layout.rows * layout.rowHeight
84
+ + (layout.rows - 1) * layout.separatorModules;
85
+ }
86
+ /**
87
+ * Check that the descriptor can be materialised by a future renderer without
88
+ * exceeding the shared geometry budget.
89
+ */
90
+ function isWithinModuleBudget(layout) {
91
+ const height = activeHeight(layout);
92
+ const footprintWidth = layout.modulesPerRow + layout.quietZone * 2;
93
+ const footprintHeight = height + layout.quietZone * 2;
94
+ if (footprintWidth > MAX_LAYOUT_DIMENSION || footprintHeight > MAX_LAYOUT_DIMENSION) {
95
+ return false;
96
+ }
97
+ if (footprintWidth > MAX_LAYOUT_MODULES / footprintHeight)
98
+ return false;
99
+ return footprintWidth * footprintHeight <= MAX_LAYOUT_MODULES;
100
+ }
101
+ /**
102
+ * Return whether an unknown value is a valid DataBar physical layout.
103
+ *
104
+ * Validation is side-effect free and performs no matrix allocation. A value
105
+ * supplied by a caller may remain mutable; use {@link createDataBarLayout}
106
+ * when an immutable descriptor is required.
107
+ */
108
+ export function validateDataBarLayout(value) {
109
+ if (!isRecord(value))
110
+ return false;
111
+ if (!hasOwn(value, 'id') || !isLayoutId(value.id))
112
+ return false;
113
+ if (!hasOwn(value, 'rows') || !isBoundedPositiveInteger(value.rows))
114
+ return false;
115
+ if (!hasOwn(value, 'modulesPerRow') || !isBoundedPositiveInteger(value.modulesPerRow))
116
+ return false;
117
+ if (!hasOwn(value, 'rowHeight') || !isBoundedPositiveInteger(value.rowHeight))
118
+ return false;
119
+ if (!hasOwn(value, 'separatorModules') || !isBoundedNonNegativeInteger(value.separatorModules))
120
+ return false;
121
+ if (!hasOwn(value, 'quietZone') || !isBoundedPositiveInteger(value.quietZone))
122
+ return false;
123
+ if (!hasOwn(value, 'linkage') || typeof value.linkage !== 'boolean')
124
+ return false;
125
+ if (!hasOwn(value, 'checksumModulus')
126
+ || !isBoundedPositiveInteger(value.checksumModulus)
127
+ || value.checksumModulus < 2)
128
+ return false;
129
+ if (!hasOwn(value, 'stacked') || typeof value.stacked !== 'boolean')
130
+ return false;
131
+ const rowsAreStacked = value.rows > 1;
132
+ if (value.stacked !== rowsAreStacked)
133
+ return false;
134
+ if (isStackedId(value.id) !== value.stacked)
135
+ return false;
136
+ if (!value.stacked && value.separatorModules !== 0)
137
+ return false;
138
+ if (value.stacked && value.separatorModules < 1)
139
+ return false;
140
+ return isWithinModuleBudget({
141
+ rows: value.rows,
142
+ modulesPerRow: value.modulesPerRow,
143
+ rowHeight: value.rowHeight,
144
+ separatorModules: value.separatorModules,
145
+ quietZone: value.quietZone,
146
+ });
147
+ }
148
+ /**
149
+ * Create a validated, shallowly immutable DataBar layout descriptor.
150
+ *
151
+ * Only documented fields are copied. Unknown input properties are ignored so
152
+ * format-specific metadata cannot leak mutable state into the shared layout.
153
+ * This factory describes future physical variants but intentionally does not
154
+ * encode any payload.
155
+ *
156
+ * @throws {TypeError} If `options` is not an object.
157
+ * @throws {RangeError} If a field is invalid or the physical footprint exceeds
158
+ * the safe geometry budget.
159
+ */
160
+ export function createDataBarLayout(options) {
161
+ if (!isRecord(options)) {
162
+ throw new TypeError('GS1 DataBar layout options must be an object');
163
+ }
164
+ const descriptor = {
165
+ id: options.id,
166
+ rows: options.rows,
167
+ modulesPerRow: options.modulesPerRow,
168
+ rowHeight: options.rowHeight,
169
+ separatorModules: options.separatorModules,
170
+ quietZone: options.quietZone,
171
+ linkage: options.linkage,
172
+ checksumModulus: options.checksumModulus,
173
+ stacked: options.stacked,
174
+ };
175
+ if (!validateDataBarLayout(descriptor)) {
176
+ throw new RangeError('Invalid GS1 DataBar layout descriptor');
177
+ }
178
+ return Object.freeze(descriptor);
179
+ }
180
+ /**
181
+ * Count active module cells in all rows, including row separators and excluding
182
+ * the outer quiet zone. `rowHeight` is the number of module rows occupied by
183
+ * each active DataBar row.
184
+ *
185
+ * @throws {TypeError} If `layout` is not a valid descriptor.
186
+ */
187
+ export function dataBarTotalModules(layout) {
188
+ if (!validateDataBarLayout(layout)) {
189
+ throw new TypeError('Cannot count modules for an invalid GS1 DataBar layout');
190
+ }
191
+ return layout.modulesPerRow * activeHeight(layout);
192
+ }