Skip to content

Use Barcode Detection API #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 3, 2025
Merged

Use Barcode Detection API #9

merged 9 commits into from
Apr 3, 2025

Conversation

jameseaster
Copy link
Contributor

Resolves - use Barcode Detection API


What kind of change does this PR introduce?

  • Feature update

What is the current behavior?

  • Depend on html5qrcode barcode detection

What is the new behavior?

  • Use Barcode Detection API for barcode detection

Does this PR introduce a breaking change?

  • No

How has this been tested?

  • Locally

Screenshots:

  • n/a

@codecov-commenter
Copy link

codecov-commenter commented Apr 2, 2025

Codecov Report

Attention: Patch coverage is 0% with 34 lines in your changes missing coverage. Please review.

Project coverage is 0.87%. Comparing base (7ec0542) to head (3165e1a).

Files with missing lines Patch % Lines
components/BarcodeScanner.vue 0.00% 25 Missing ⚠️
lib/barcodes.js 0.00% 9 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main      #9      +/-   ##
========================================
- Coverage   1.13%   0.87%   -0.26%     
========================================
  Files          2       3       +1     
  Lines         88     114      +26     
  Branches      15      18       +3     
========================================
  Hits           1       1              
- Misses        87     113      +26     
Files with missing lines Coverage Δ
components/ScannerUI.vue 0.00% <ø> (ø)
lib/barcodes.js 0.00% <0.00%> (ø)
components/BarcodeScanner.vue 1.06% <0.00%> (-0.22%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7ec0542...3165e1a. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@@ -46,6 +48,7 @@ export default {

// Constants
let scanner = null;
const abortController = new AbortController();
Copy link
Member

Choose a reason for hiding this comment

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

Note that if this component can do more than one scan (before it has to go out of scope or get cleaned up or whatever by Vue), then we'll need a new AbortController for each scan. Otherwise it will always abort after the first abort and never scan again.

const {signal} = abortController;
const barcodes = await detectBarcodes({barcodeDetector, video, signal});
const [result] = barcodes;
if(result?.format && result?.rawValue) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's possible for result to be undefined/falsey now with our new design, i.e., detectBarcodes always returns 1 or more barcodes. So we can simplify this and just use the result, I'd think.

@jameseaster jameseaster requested a review from dlongley April 3, 2025 15:13
Copy link
Member

@dlongley dlongley left a comment

Choose a reason for hiding this comment

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

Approving with some suggestions to be applied that I'll double check before merging and releasing. Thanks!

@jameseaster jameseaster requested a review from dlongley April 3, 2025 19:11
@dlongley dlongley merged commit 1e682a6 into main Apr 3, 2025
3 checks passed
@dlongley dlongley deleted the barcode-detection-api branch April 3, 2025 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants