isahaq-barcode 1.8.0 → 2.0.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.
- package/CHANGELOG.md +107 -0
- package/LICENSE +21 -0
- package/README.md +319 -519
- package/bin/generate.js +171 -134
- package/browser.js +163 -170
- package/index.d.ts +497 -0
- package/index.js +118 -38
- package/package.json +68 -34
- package/src/builders/QrCodeBuilder.js +328 -165
- package/src/encoders/BarcodeEncoder.js +260 -0
- package/src/renderers/HTMLRenderer.js +36 -169
- package/src/renderers/PDFRenderer.js +108 -130
- package/src/renderers/PNGRenderer.js +7 -83
- package/src/renderers/RenderFormats.js +89 -38
- package/src/renderers/SVGRenderer.js +8 -182
- package/src/services/BarcodeService.js +96 -36
- package/src/types/BarcodeTypes.js +535 -144
- package/src/validators/Validator.js +140 -122
- package/.eslintrc.js +0 -29
- package/.prettierignore +0 -11
- package/.prettierrc +0 -11
- package/eslint.config.js +0 -67
- package/examples/basic-usage.js +0 -58
- package/examples/batch-example.json +0 -56
- package/examples/express-server.js +0 -163
- package/jest.config.js +0 -13
- package/tests/BarcodeGenerator.test.js +0 -187
- package/tests/BarcodeService.test.js +0 -76
- package/tests/QrCodeBuilder.test.js +0 -130
- package/tests/setup.js +0 -59
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [2.0.0] - 2026-07-26
|
|
9
|
+
|
|
10
|
+
This release replaces the rendering core. Before it, only PNG output produced a
|
|
11
|
+
real barcode: SVG, HTML and PDF drew decorative bars derived from character
|
|
12
|
+
codes, and any type that JsBarcode did not support (Data Matrix, PDF417, Aztec,
|
|
13
|
+
the postal symbologies, MaxiCode, Code 16K, Code 49, ...) silently fell back to
|
|
14
|
+
Code 128. Every advertised type and format now produces a real, scannable
|
|
15
|
+
symbology, verified by decoding the output with ZXing (`npm run verify:scan`).
|
|
16
|
+
|
|
17
|
+
### Breaking changes
|
|
18
|
+
|
|
19
|
+
- `png()`, `svg()`, `html()` and `pdf()` now all return promises. Previously
|
|
20
|
+
`png()`, `svg()` and `html()` returned values synchronously.
|
|
21
|
+
Use `svgSync()` and `htmlSync()` where a synchronous call is needed.
|
|
22
|
+
```js
|
|
23
|
+
// 1.x
|
|
24
|
+
const buffer = BarcodeGenerator.png('1234567890', 'code128');
|
|
25
|
+
// 2.x
|
|
26
|
+
const buffer = await BarcodeGenerator.png('1234567890', 'code128');
|
|
27
|
+
```
|
|
28
|
+
- `batch()` now returns a promise resolving to the results array.
|
|
29
|
+
- SVG, HTML and PDF output changed completely, because it is now a real barcode.
|
|
30
|
+
HTML output is a single `<div>` wrapping an inline SVG instead of a grid of
|
|
31
|
+
styled `<div>` elements, and no longer emits a `<style>` block.
|
|
32
|
+
- The `jpg` and `jpeg` render formats were removed from `getRenderFormats()`.
|
|
33
|
+
They were advertised but always failed with "No renderer available".
|
|
34
|
+
`QrCodeBuilder` still supports `format: 'jpeg'`.
|
|
35
|
+
- The default quiet zone is now 10 modules (the value the specifications
|
|
36
|
+
require) rather than 10 pixels, so default output is slightly wider. Pass
|
|
37
|
+
`margin` in pixels or `quietZone` in modules to override it.
|
|
38
|
+
- `canvas` moved to `optionalDependencies` and is only needed for QR codes with
|
|
39
|
+
a logo, label or watermark. Barcode rendering no longer uses it at all.
|
|
40
|
+
- `jsbarcode` is no longer a dependency or a peer dependency; encoding is done
|
|
41
|
+
by `bwip-js`. `qrcode` moved from a peer dependency to a regular dependency.
|
|
42
|
+
- Browser build: `png()` resolves to a `Blob` instead of a `Buffer` (`Buffer`
|
|
43
|
+
does not exist in browsers without a polyfill), and SVG generation no longer
|
|
44
|
+
requires a DOM.
|
|
45
|
+
- `EAN-8` and `UPC-A` check digit validation is now correct. Codes that were
|
|
46
|
+
wrongly accepted before are now rejected, and vice versa.
|
|
47
|
+
- The default QR `logoSize` is 20 (percent) instead of 60. A logo covering 60%
|
|
48
|
+
of a QR code destroys it.
|
|
49
|
+
- A missing or unreadable QR logo now rejects instead of logging a warning and
|
|
50
|
+
silently producing a code without the logo.
|
|
51
|
+
|
|
52
|
+
### Added
|
|
53
|
+
|
|
54
|
+
- `svgSync()` and `htmlSync()` for synchronous SVG and HTML generation.
|
|
55
|
+
- `generate(data, type, format, options)` on the public API.
|
|
56
|
+
- Real support for all 45 registered types, including `datamatrix`, `pdf417`,
|
|
57
|
+
`aztec`, `microqr`, `maxicode`, `code16k`, `code49`, `postnet`, `planet`,
|
|
58
|
+
`rms4cc`, `kix`, `imb`, `pharmacode` and `pharmacodetwotracks`.
|
|
59
|
+
- `size` option to size 2D symbologies in pixels, `quietZone` to set the quiet
|
|
60
|
+
zone in modules, `rotate` for 90/180/270 degree rotation, `textColor`, and
|
|
61
|
+
`bwipOptions` to pass raw encoder options through.
|
|
62
|
+
- PDF options: `pageSize` (for example `'A4'`), `fitToBarcode`, `title`.
|
|
63
|
+
- `getBarcodeCategories()`, `getBarcodeTypesByCategory()`, `getDefaultOptions()`.
|
|
64
|
+
- `BarcodeTypes.getTypeInfo()`, `getSymbology()`, `getEncodeOptions()` and
|
|
65
|
+
`RenderFormats.getFormatInfo()`.
|
|
66
|
+
- TypeScript declarations (`index.d.ts`) covering the whole public API.
|
|
67
|
+
- QR codes as SVG (`format: 'svg'`) and `data:image/svg+xml` data URIs.
|
|
68
|
+
- `npm run verify:scan`, which decodes generated barcodes with ZXing.
|
|
69
|
+
- GitHub Actions CI across Node 18, 20 and 22.
|
|
70
|
+
|
|
71
|
+
### Fixed
|
|
72
|
+
|
|
73
|
+
- `getBarcodeTypes()`, `getRenderFormats()`, `getBarcodeTypeInfo()` and
|
|
74
|
+
`getRenderFormatInfo()` threw `TypeError: ... is not a function`; the methods
|
|
75
|
+
they called did not exist.
|
|
76
|
+
- Code 93 output was missing its two mandatory check characters, so scanners
|
|
77
|
+
could not read it.
|
|
78
|
+
- CLI: `barcode --format pdf` wrote a `[object Promise]` to disk, and `batch`
|
|
79
|
+
crashed with "results is not iterable", both from unawaited promises.
|
|
80
|
+
- CLI: `require('chalk')`/`require('ora')` crashed on Node 18 and 20 because
|
|
81
|
+
those packages are ESM only. The CLI now has no colour dependencies, honours
|
|
82
|
+
`NO_COLOR`, writes diagnostics to stderr and data to stdout, and reports the
|
|
83
|
+
real package version instead of a hardcoded `1.0.0`.
|
|
84
|
+
- `npm install` failed with `ERESOLVE` because `eslint-config-standard@17`
|
|
85
|
+
requires ESLint 8 while the project uses ESLint 9. The unused legacy
|
|
86
|
+
`.eslintrc.js` and its plugins were removed.
|
|
87
|
+
- Express example: unawaited generator calls, an error handler Express ignored
|
|
88
|
+
because it declared three parameters, and non-JSON-serialisable buffers in the
|
|
89
|
+
batch response.
|
|
90
|
+
- `QrCodeBuilder.build()` no longer shares mutable options with the builder.
|
|
91
|
+
- Colour options now accept `#rgb`, `#rrggbb`, `rrggbb` and RGB arrays
|
|
92
|
+
consistently across the barcode and QR code APIs.
|
|
93
|
+
|
|
94
|
+
### Changed
|
|
95
|
+
|
|
96
|
+
- The test suite exercises the real encoders instead of mocking them. The
|
|
97
|
+
previous mocks made PDF tests hang until the 10 second timeout and asserted
|
|
98
|
+
nothing about the output.
|
|
99
|
+
- `BarcodeTypes` and `RenderFormats` are generated from one registry, so type
|
|
100
|
+
metadata, categories, validation limits and the encoder mapping cannot drift.
|
|
101
|
+
- Package contents are now limited to what is needed at runtime: tests, ESLint
|
|
102
|
+
and Prettier configs and the webpack config are no longer published, and
|
|
103
|
+
`LICENSE` is.
|
|
104
|
+
|
|
105
|
+
## [1.9.0] and earlier
|
|
106
|
+
|
|
107
|
+
See the [commit history](https://github.com/isahaq1/npm-barcodegenerator/commits/main).
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 hmisahaq01
|
|
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.
|