@sythos/js_barcode_universal 0.1.0

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 (53) hide show
  1. package/LICENSE +215 -0
  2. package/NOTICE.md +106 -0
  3. package/README.md +433 -0
  4. package/bundle/sythos-barcode.esm.js +7998 -0
  5. package/bundle/sythos-barcode.js +7948 -0
  6. package/examples/create.html +731 -0
  7. package/examples/read.html +341 -0
  8. package/licenses/README.md +42 -0
  9. package/licenses/codabar.license +74 -0
  10. package/licenses/code-11.license +69 -0
  11. package/licenses/code-128.license +69 -0
  12. package/licenses/code-39.license +70 -0
  13. package/licenses/code-93.license +71 -0
  14. package/licenses/ean-13.license +70 -0
  15. package/licenses/ean-8.license +70 -0
  16. package/licenses/gs1-128.license +71 -0
  17. package/licenses/isbn.license +76 -0
  18. package/licenses/itf-14.license +69 -0
  19. package/licenses/itf.license +70 -0
  20. package/licenses/msi-plessey.license +72 -0
  21. package/licenses/pharmacode.license +71 -0
  22. package/licenses/qr-code.license +75 -0
  23. package/licenses/upc-a.license +72 -0
  24. package/licenses/upc-e.license +69 -0
  25. package/package.json +89 -0
  26. package/src/core/bit-buffer.js +174 -0
  27. package/src/core/bit-matrix.js +241 -0
  28. package/src/core/errors.js +61 -0
  29. package/src/core/galois-field.js +204 -0
  30. package/src/core/index.js +56 -0
  31. package/src/core/reed-solomon.js +313 -0
  32. package/src/image/binarizer.js +270 -0
  33. package/src/image/grid-sampler.js +164 -0
  34. package/src/image/index.js +40 -0
  35. package/src/image/luminance.js +196 -0
  36. package/src/image/perspective.js +195 -0
  37. package/src/index.js +240 -0
  38. package/src/oned/index.js +89 -0
  39. package/src/oned/patterns.js +384 -0
  40. package/src/oned/reader.js +918 -0
  41. package/src/oned/writers.js +741 -0
  42. package/src/qr/decoder.js +575 -0
  43. package/src/qr/detector.js +630 -0
  44. package/src/qr/encoder.js +958 -0
  45. package/src/qr/index.js +44 -0
  46. package/src/qr/tables.js +737 -0
  47. package/src/render/image-data.js +125 -0
  48. package/src/render/index.js +130 -0
  49. package/src/render/options.js +160 -0
  50. package/src/render/png.js +295 -0
  51. package/src/render/svg.js +120 -0
  52. package/src/render/webgl.js +206 -0
  53. package/src/render/webgpu.js +369 -0
package/LICENSE ADDED
@@ -0,0 +1,215 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sythos
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+
24
+ ================================================================================
25
+ APPENDIX — INFORMATIONAL INVENTORY OF NON-MIT LICENSES, PATENTS AND TRADEMARKS
26
+ ================================================================================
27
+
28
+ READ THIS FIRST
29
+ ---------------
30
+
31
+ **Nothing in this appendix applies to, encumbers, or imposes any obligation on
32
+ the software distributed under the MIT License above.**
33
+
34
+ This package contains 100% original code, written from scratch. It has ZERO
35
+ runtime dependencies. No source code, and no table of values, has been copied
36
+ from any other software project, under any license. The distributed artifact is
37
+ therefore covered by the MIT License above and by nothing else.
38
+
39
+ This appendix exists only because barcode symbologies carry a history of
40
+ specification copyrights, expired patents and live trademarks, and it is useful
41
+ to have that history inventoried in one place. It is an ENGINEERING INVENTORY,
42
+ NOT LEGAL ADVICE. Every row marked "TO VERIFY" is an item the author has not
43
+ independently confirmed; do not rely on any of it for a legal decision. If your
44
+ use case is commercially sensitive, consult a qualified attorney.
45
+
46
+
47
+ 1. THE DISTRIBUTED PACKAGE
48
+ --------------------------
49
+
50
+ Runtime dependencies ............ none
51
+ Third-party code included ....... none
52
+ Third-party licenses that apply . none
53
+ Effective license ............... MIT, in full, as stated above
54
+
55
+
56
+ 2. DEVELOPMENT-TIME TOOLS (NOT DISTRIBUTED, NOT LINKED, NEVER READ)
57
+ -------------------------------------------------------------------
58
+
59
+ Tool License Role
60
+ -------------------------------- ----------- ---------------------------
61
+ independent barcode various differential encode and
62
+ implementations decode oracles
63
+ typescript (tsc) Apache-2.0 .d.ts generation from JSDoc
64
+
65
+ THE PROJECT RULE, STATED PRECISELY:
66
+
67
+ These tools may be INVOKED during testing.
68
+ Their SOURCE is never opened, and no line of their code, and no constant
69
+ from their tables, ever enters this project's output.
70
+
71
+ They are used strictly as black boxes: an input goes in, the OUTPUT that comes
72
+ back is compared against ours. Outputs are facts about a published symbology,
73
+ not creative expression, so comparing against them creates no derivative work
74
+ and no license obligation. This is the standard clean-room technique, and it is
75
+ the opposite of source copying — it is how originality is PROVEN rather than
76
+ merely asserted.
77
+
78
+ typescript (tsc) is not a barcode library and carries no symbology logic at
79
+ all. It is an optional generator: it reads the JSDoc annotations already
80
+ present in this project's own source and emits .d.ts declarations from them.
81
+ There is no TypeScript source in this project.
82
+
83
+ No barcode library is a dependency of this package. None of the tools above is
84
+ a runtime dependency, none ships in the published package, and running or not
85
+ running any of them changes nothing about the distributed JavaScript.
86
+
87
+ Should any of them ever be proposed as a runtime dependency, this section must
88
+ be revisited — the zero-dependency rule exists to prevent exactly that.
89
+
90
+
91
+ 3. SPECIFICATION DOCUMENTS
92
+ --------------------------
93
+
94
+ Specification TEXT is copyrighted by its publisher. The SYMBOLOGIES the text
95
+ describes are not — an encoding scheme is a system, not a work of authorship.
96
+ This project implements the symbologies; it does not reproduce, redistribute or
97
+ excerpt the specification documents.
98
+
99
+ Document Publisher / rights holder
100
+ -------------------------------- ---------------------------------------
101
+ ISO/IEC 18004 (QR Code) ISO/IEC — copyrighted, paywalled
102
+ ISO/IEC 16022 (Data Matrix) ISO/IEC — copyrighted, paywalled
103
+ ISO/IEC 15438 (PDF417) ISO/IEC — copyrighted, paywalled
104
+ ISO/IEC 24778 (Aztec) ISO/IEC — copyrighted, paywalled
105
+ ISO/IEC 16023 (MaxiCode) ISO/IEC — copyrighted, paywalled
106
+ ISO/IEC 15417 (Code 128) ISO/IEC — copyrighted, paywalled
107
+ ISO/IEC 16388 (Code 39) ISO/IEC — copyrighted, paywalled
108
+ ISO/IEC 16390 (ITF) ISO/IEC — copyrighted, paywalled
109
+ ISO/IEC 15420 (EAN/UPC) ISO/IEC — copyrighted, paywalled
110
+ ISO 2108 (ISBN numbering) ISO — copyrighted; the numbering
111
+ scheme, not a symbology
112
+ ISO/IEC 24723-5 (GS1 Composite,
113
+ DataBar, DotCode
114
+ and related) ISO/IEC — copyrighted, paywalled
115
+ GS1 General Specifications GS1 — freely downloadable; redistribution
116
+ terms are GS1's own [TO VERIFY]
117
+ AIM symbology specifications AIM Inc. — terms vary [TO VERIFY]
118
+ GB/T 21049 (Han Xin Code) SAC (China) [TO VERIFY]
119
+ USPS publications (POSTNET,
120
+ PLANET, Intelligent Mail) USPS — published openly [TO VERIFY]
121
+
122
+
123
+ 4. PATENT POSITIONS
124
+ -------------------
125
+
126
+ Barcode patents from the 1990s have broadly expired, and several rights holders
127
+ issued public statements permitting free use. NONE OF THE FOLLOWING HAS BEEN
128
+ INDEPENDENTLY VERIFIED BY THE AUTHOR. Treat every entry as a research pointer.
129
+
130
+ Symbology Rights holder Reported position
131
+ ------------- ----------------- --------------------------------------
132
+ QR Code DENSO WAVE patent rights reportedly not
133
+ exercised for standardised QR
134
+ [TO VERIFY]
135
+ Micro QR DENSO WAVE assumed to follow QR [TO VERIFY]
136
+ rMQR DENSO WAVE standardised 2022 — MUCH NEWER; do NOT
137
+ assume the older QR position covers it
138
+ [TO VERIFY — PRIORITY]
139
+ Data Matrix orig. RVSI/CiMatrix ECC200 reported released for
140
+ public use [TO VERIFY]
141
+ PDF417 orig. Symbol Tech. reported released for
142
+ public use [TO VERIFY]
143
+ Aztec Code orig. Welch Allyn reported placed in the
144
+ public domain [TO VERIFY]
145
+ MaxiCode UPS reported released for
146
+ public use [TO VERIFY]
147
+ DotCode AIM open AIM standard [TO VERIFY]
148
+ Han Xin Code Chinese nat'l std status under GB/T 21049 [TO VERIFY]
149
+ DataBar/GS1 GS1 published for open use [TO VERIFY]
150
+ Code 128 / 39 /
151
+ 93 / Codabar / ITF / MSI /
152
+ Code 11 / Telepen / Pharmacode originating patents long expired
153
+ [TO VERIFY]
154
+
155
+ Formats whose status could not be established as clearly redistributable are
156
+ NOT IMPLEMENTED by this project. See section 6.
157
+
158
+
159
+ 5. TRADEMARKS
160
+ -------------
161
+
162
+ **A trademark is not a license.** These marks do not restrict anyone's right to
163
+ implement the corresponding symbology. They restrict BRANDING — how a product
164
+ names and presents itself.
165
+
166
+ Mark Holder
167
+ ----------------------- -----------------------------------
168
+ QR Code(R) DENSO WAVE INCORPORATED
169
+ Micro QR, rMQR DENSO WAVE INCORPORATED
170
+ Aztec Code originally Welch Allyn [TO VERIFY]
171
+ MaxiCode United Parcel Service of America
172
+ GS1, GS1 DataBar,
173
+ GS1 DataMatrix, GS1-128 GS1 AISBL
174
+ Data Matrix [status TO VERIFY]
175
+ Telepen SB Electronic Systems Ltd [TO VERIFY]
176
+
177
+ All marks are the property of their respective owners and are used here in a
178
+ purely descriptive, nominative sense — to identify which symbologies this
179
+ software reads and writes.
180
+
181
+ PRACTICAL CONSEQUENCE: this package may accurately describe itself as
182
+ implementing QR Code, Aztec Code, MaxiCode and so on. It must NOT be NAMED
183
+ after any of those marks. A descriptive package name is required.
184
+
185
+
186
+ 6. EXPLICITLY NOT IMPLEMENTED — PROPRIETARY OR UNCLEAR STATUS
187
+ -------------------------------------------------------------
188
+
189
+ Deliberately excluded because they are proprietary, license-encumbered, or of
190
+ status too unclear to redistribute an implementation with confidence:
191
+
192
+ Digimarc Barcode ........ proprietary, Digimarc Corporation
193
+ VeriCode / VSCode ....... proprietary, Veritec Inc.
194
+ DataGlyphs .............. proprietary, Xerox
195
+ Snowflake Code .......... proprietary, Marconi Data Systems
196
+ ShotCode ................ proprietary
197
+ Microsoft Tag ........... proprietary, discontinued
198
+ Bokode .................. research project, unclear status
199
+ Softstrip ............... obsolete, unclear status
200
+ Ultracode ............... status unresolved [TO VERIFY]
201
+
202
+ If any of these is later confirmed to be freely implementable and
203
+ redistributable, it may move into scope — and this section must be updated in
204
+ the same commit.
205
+
206
+
207
+ 7. MAINTENANCE RULE
208
+ -------------------
209
+
210
+ This appendix is normative for the project's process, not for its users. Any
211
+ change to the dependency set, the oracle tools, or the implemented format list
212
+ MUST update this file in the same commit. A "[TO VERIFY]" marker may only be
213
+ removed together with a citation recorded in NOTICE.md.
214
+
215
+ Last reviewed: 2026-08-04
package/NOTICE.md ADDED
@@ -0,0 +1,106 @@
1
+ # NOTICE
2
+
3
+ ## Origin of this code
4
+
5
+ Every line of JavaScript in this repository is **original work by Sythos**.
6
+
7
+ No source code, and no table of constants, has been copied from any other
8
+ software project — under any license, permissive or otherwise. That covers
9
+ every other barcode implementation, without exception.
10
+
11
+ The symbologies are implemented from **published descriptions of the formats**
12
+ (which are systems and facts, not works of authorship) and from **constant
13
+ tables generated by this project's own scripts** in `tools/`, wherever a table
14
+ is derivable rather than arbitrary.
15
+
16
+ ## What "third-party" means here
17
+
18
+ | | |
19
+ |---|---|
20
+ | Runtime dependencies | **none** |
21
+ | Bundled third-party code | **none** |
22
+ | Third-party licenses applying to the distributed package | **none** |
23
+
24
+ The `LICENSE` file carries the full MIT text plus an informational appendix
25
+ inventorying the specification copyrights, patent history and trademarks that
26
+ surround these symbologies. **None of them encumbers this code** — the appendix
27
+ exists for reference, not because obligations flow from it.
28
+
29
+ ## Where other barcode libraries may and may not appear
30
+
31
+ The line is drawn at **invoke vs. read**:
32
+
33
+ | | |
34
+ |---|---|
35
+ | Running an independent implementation during **testing**, comparing its output to ours | **allowed** |
36
+ | Reading its source, or lifting a constant table from it, into this project | **never** |
37
+
38
+ Such outputs are facts about a published symbology, not creative expression —
39
+ comparing against them creates no derivative work. This is how the originality
40
+ of the shipped code is *demonstrated*, not compromised: an implementation that
41
+ independently agrees with several unrelated ones, byte for byte, is evidently
42
+ correct and evidently not a copy of any of them.
43
+
44
+ No third-party barcode code is a runtime dependency, and none of it ships in the
45
+ published package. See `LICENSE` §2.
46
+
47
+ ## How correctness is verified
48
+
49
+ Five independent mechanisms. The first four require no other barcode
50
+ implementation to exist at all; the fifth is the cross-check.
51
+
52
+ **1. Self-validating tables.** Where a constant table is redundant with
53
+ geometry, the redundancy is checked. QR's error-correction block table is the
54
+ clearest case: for every one of the 160 version/ECC-level combinations, the sum
55
+ of data and ECC codewords across all blocks *must* equal the symbol's total
56
+ codeword capacity — and that capacity is computed independently from the module
57
+ geometry (symbol size, minus finder, timing, alignment, format and version
58
+ areas, divided by 8). A single mistyped digit anywhere in that table breaks the
59
+ identity and fails the test. The table cannot be quietly wrong.
60
+
61
+ **2. Structural invariants.** Reed–Solomon must correct up to the theoretical
62
+ limit of `floor((n-k)/2)` symbol errors and no further; a wrong generator
63
+ polynomial or a mishandled field operation fails this well before any symbol is
64
+ produced. Checksums, guard patterns and mode-length constraints are asserted
65
+ per format.
66
+
67
+ **3. Reference values computed from first principles.** Where a published
68
+ worked example exists in the format's public documentation, its intermediate
69
+ values are checked — not copied code, just the arithmetic any correct
70
+ implementation must reproduce.
71
+
72
+ **4. The real world — the decisive test.** `examples/create.html` renders any
73
+ symbol to the screen; a phone camera or a supermarket scanner reads it or does
74
+ not. This is the strongest oracle available and the one that actually matters,
75
+ because it tests against the installed base of real scanners rather than
76
+ against one other library's opinion. **A format is not considered finished
77
+ until a symbol it produced has been read by a device this project did not
78
+ write.**
79
+
80
+ **5. Differential testing against independent implementations.** Random
81
+ payloads across every version and ECC level are encoded here and decoded by
82
+ several unrelated third-party barcode implementations — and vice versa. These
83
+ are invoked as black boxes and their source is never read (see above).
84
+ Agreement across implementations that share no lineage is strong evidence of
85
+ correctness; disagreement localises a bug immediately.
86
+
87
+ Note that round-trip testing (encode → decode with our own code) is used for
88
+ regression coverage but is explicitly **not** treated as proof of correctness:
89
+ it is symmetric, so a fault applied consistently in both directions passes it
90
+ while producing symbols no scanner can read. Mechanisms 1, 4 and 5 exist
91
+ precisely to catch that class of fault.
92
+
93
+ ## Attribution log
94
+
95
+ Records any constant table whose values were transcribed from a documented
96
+ source rather than generated by `tools/`. Each entry names the source and the
97
+ date of transcription.
98
+
99
+ *(empty — all tables to date are generated by `tools/` or derived from
100
+ first principles in the module that uses them)*
101
+
102
+ ## Verification log
103
+
104
+ Records each `[TO VERIFY]` marker cleared from `LICENSE`, with its citation.
105
+
106
+ *(empty)*