github zxing-js/library v0.23.0

8 hours ago

Changelog

Error Robustness

  • MultiFormatReader: Non-ReaderException errors (TypeError, RangeError, etc.) are now logged instead of silently swallowed during decode attempts. Previously, programming errors were invisible and produced misleading "no barcode found" results. (src/core/MultiFormatReader.ts)
  • MultiFormatReader: Skip redundant setHints() calls when the same hints object is passed to decode() repeatedly, avoiding unnecessary reader reconstruction. (src/core/MultiFormatReader.ts)
  • BrowserCodeReader: Unexpected errors in the continuous scan loop are now logged via console.error. Previously the loop would stop silently with no indication of what went wrong. (src/browser/BrowserCodeReader.ts)

Scanning Quality

  • OneDReader: Increased default row sampling from 15 to 25 lines, covering ~78% of image height (up from ~47%). This improves detection of 1D barcodes positioned away from the image center without requiring TRY_HARDER mode. (src/core/oned/OneDReader.ts)
  • BrowserCodeReader: Added GlobalHistogramBinarizer fallback when HybridBinarizer fails with NotFoundException. Local thresholding can fail on very small barcodes or uniform-background images where a single global threshold works better. The fallback only triggers on failure, so the normal fast path is unaffected. (src/browser/BrowserCodeReader.ts)

Performance

  • HTMLCanvasElementLuminanceSource: Merged two duplicate 25-line grayscale conversion loops (normal vs. inverted) into a single loop using an XOR mask. Reduces code and eliminates a branch. (src/browser/HTMLCanvasElementLuminanceSource.ts)
  • HTMLCanvasElementLuminanceSource: Use subarray() instead of slice() in getRow() to avoid an intermediate buffer copy on every row read. (src/browser/HTMLCanvasElementLuminanceSource.ts)
  • HTMLCanvasElementLuminanceSource + BrowserCodeReader: Added optional grayscale buffer reuse across frames during continuous scanning, avoiding a ~900KB Uint8ClampedArray allocation per frame on 1280x720 video. (src/browser/HTMLCanvasElementLuminanceSource.ts, src/browser/BrowserCodeReader.ts)
  • BitMatrix: Replaced Math.floor(x / 32) with bitwise (x >> 5) in all hot-path methods (get, set, unset, flip, setRegion, constructor). These are the innermost operations in binarization and grid sampling. (src/core/common/BitMatrix.ts)
  • BitMatrix: Replaced manual zeroing loop in clear() with native Int32Array.fill(0). (src/core/common/BitMatrix.ts)
  • DefaultGridSampler: Replaced Math.floor() with bitwise | 0 in the inner grid sampling loop, called per-pixel for every 2D barcode module. (src/core/common/DefaultGridSampler.ts)
  • GlobalHistogramBinarizer: Replaced manual bucket zeroing loop with Int32Array.fill(0). (src/core/common/GlobalHistogramBinarizer.ts)
  • FinderPatternFinder: Replaced manual 5-element array zeroing with Int32Array.fill(0) in 3 locations. (src/core/qrcode/detector/FinderPatternFinder.ts)

New Format: MaxiCode

  • MaxiCodeReader: Full MaxiCode 2D barcode decoding support (modes 2–5), ported from the Java ZXing reference implementation. MaxiCode is a fixed-size hexagonal barcode used primarily by UPS for package sorting. (src/core/maxicode/MaxiCodeReader.ts)
  • MaxiCode Decoder: Reed-Solomon error correction with interleaved EVEN/ODD codeword processing, supporting structured carrier messages (modes 2–3 with postal code, country, and service class) and standard/enhanced error correction messages (modes 4–5). (src/core/maxicode/decoder/Decoder.ts, src/core/maxicode/decoder/BitMatrixParser.ts, src/core/maxicode/decoder/DecodedBitStreamParser.ts)
  • MultiFormatReader: MaxiCode is now included in both format-specific and default reader lists. (src/core/MultiFormatReader.ts)
  • ReedSolomonDecoder: Added decodeWithECCount() method that returns the number of corrected errors, used by the MaxiCode decoder to report error correction statistics. (src/core/common/reedsolomon/ReedSolomonDecoder.ts)
  • ResultMetadataType: Added ERRORS_CORRECTED enum value for reporting error correction counts in decode results. (src/core/ResultMetadataType.ts)

Don't miss a new library release

NewReleases is sending notifications on new releases.