Skip to content

Conversation

gjulivan
Copy link
Collaborator

@gjulivan gjulivan commented Sep 2, 2025

  • add logic to use BarcodeDetector API
  • increase ideal width and height camera resolution for higher end devices

note: add Class "debug" on Properties -> Styling : Class in studio pro to check if BarcodeDetector API is being used.
if BarcodeDetector API is used, green border will be shown, otherwise, it is normal zxing/library.

@Copilot Copilot AI review requested due to automatic review settings September 2, 2025 22:28
@gjulivan gjulivan requested a review from a team as a code owner September 2, 2025 22:28
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for using the native browser BarcodeDetector API when available, falling back to the ZXing library for better performance. It introduces a new architecture with separate reader classes for native and ZXing implementations, along with improved video resolution settings.

  • Refactors the barcode scanning logic into separate reader classes (native vs ZXing)
  • Implements feature detection to automatically choose the best available API
  • Increases video resolution limits to improve scanning performance on high-end devices

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/ui/BarcodeScanner.scss Adds debug styling to visually distinguish between native and ZXing detectors
src/package.xml Bumps version from 2.4.2 to 2.5.0 for the new feature
src/hooks/zxReader.ts New ZXing-based reader implementation extracted from useReader hook
src/hooks/useReader.ts Refactored to use factory pattern for reader selection and return API type
src/hooks/nativeReader.ts New native BarcodeDetector API reader implementation
src/helpers/utils.tsx Extracts shared utilities and types, increases video resolution constraints
src/helpers/barcode-detector.ts TypeScript definitions for native BarcodeDetector API
src/helpers/barcode-detector-utils.tsx Utility functions for native BarcodeDetector feature detection and usage
src/components/BarcodeScanner.tsx Updates to use new reader architecture and apply conditional CSS classes
package.json Version bump to 2.5.0
CHANGELOG.md Documents the new native API support and resolution improvements

@gjulivan gjulivan changed the title feat(barcode): add logic to use barcodedetector API [WC-3032] Add logic to use barcodedetector API for barcode scanner Sep 2, 2025
@gjulivan gjulivan force-pushed the barcode-detector branch 2 times, most recently from bf89b73 to deebbf9 Compare September 2, 2025 22:37
samuelreichert
samuelreichert previously approved these changes Sep 3, 2025
Copy link
Contributor

@samuelreichert samuelreichert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

samuelreichert
samuelreichert previously approved these changes Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants