Skip to content

v2.0.0

Latest
Compare
Choose a tag to compare
@Sec-ant Sec-ant released this 05 Jan 16:05
· 2 commits to main since this release
52c215c

This release introduces a major refactoring of the underlying Embind APIs and read / write functions. Key changes include a new set of default reader options, enhanced writer capabilities backed by zint, and updated APIs for reading and writing barcodes. These changes break backward compatibility, so we are upgrading to the next major version.

Breaking Changes

Consolidated Reader Function

readBarcodes(...) replaces both readBarcodesFromImageFile(...) and readBarcodesFromImageData(...). The new function can accept either a Blob or an ImageData as its input.

Note

The v1 reader functions readBarcodesFromImageFile and readBarcodesFromImageData are still kept for a smooth migration experience, but marked as deprecated.

Updated Reader Options

A few reader options have changed their default values. This change is to align with the latest ZXing C++ library and provide a more consistent experience across different platforms:

  1. tryCode39ExtendedMode is now true by default. It was previously false.
  2. eanAddOnSymbol is now "Ignore" by default. It was previously "Read".
  3. textMode is now "HRI" by default. It was previously "Plain".

Some deprecated options have been removed, see zxing-cpp#704 for more details:

  1. validateCode39CheckSum is now removed. The Code39 symbol has a valid checksum if the third character of the symbologyIdentifier is an odd digit.
  2. validateITFCheckSum is now removed. The ITF symbol has a valid checksum if the third character of the symbologyIdentifier is a '1'.
  3. returnCodabarStartEnd is now removed. The detected results of Codabar symbols now always include the start and end characters.

eccLevel in Read Result Renamed to ecLevel

In ReadResult, the eccLevel field has been renamed to ecLevel. It now holds strings like "L", "M", "Q", or "H" or stringified numeric percentage values for error correction levels. An empty string indicates that the error correction level is not applicable.

Note

The eccLevel field is still kept for a smooth migration experience, but marked as deprecated.

Renamed & Enhanced Writer Function

writeBarcode(...) replaces writeBarcodeToImageFile(...). This function is now powered by the new zint backend which supports all available formats that are currently supported by the reader. It accepts either a string text or an Uint8Array binary data as its input for barcode generation, and provides new output formats (e.g. SVG, UTF-8) in addition to an image file blob.

The WriterOptions object has also been updated completely.

Note

The final shape of the writeBarcode function is still in review. The current implementation is subject to change.

.wasm Module Initialization / Caching Overhaul

prepareZXingModule(...) replaces both setZXingModuleOverrides(...) and getZXingModuleOverrides(...). The new function provides a more flexible way to initialize the ZXing module with custom options.

Note

The v1 module initialization functions setZXingModuleOverrides and getZXingModuleOverrides are still kept for a smooth migration experience, but marked as deprecated.

purgeZXingModule now only clears the relevant module cache from where it is imported. It no longer resets the global module cache.

Redefined BarcodeFormat-Family Types

None is removed from the BarcodeFormat union type. New types like LinearBarcodeFormat, MatrixBarcodeFormat and LooseBarcodeFormat are introduced. See barcodeFormat.ts for more details.

New Features & Enhancements

More Barcode Formats Supported in Writer

The new writeBarcode function supports more barcode formats than the previous writeBarcodeToImageFile. All barcode formats supported by the reader are now supported by the writer.

New tryDenoise Option for Reading Barcodes

The new tryDenoise option in ReaderOptions allows you to enable or disable the denoising algorithm when reading barcodes. This is an experimental feature. By default, it is set to false.

Bug Fixes

Fix TS moduleResolution: node Subpath Exports Resolution

The subpath export types are now compatible with TypeScript's moduleResolution: node strategy by using the types-versions-wildcards strategy. This package now passes all the arethetypeswrong checks.