Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

html5-qrcode

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html5-qrcode - npm Package Versions

1
7

2.1.4

Diff

Changelog

Source

Version 2.1.4

mebjas
published 2.1.3 •

Changelog

Source

Version 2.1.3

  • Reduce the assets size using SVG instead of GIF files.
mebjas
published 2.1.2 •

Changelog

Source

Version 2.1.2

  • If there is only one camera detected, automatically use that.
  • Cosmetic fixes: show Launching Camera... in button when launching the camera.
mebjas
published 2.1.1 •

Changelog

Source

Version 2.1.1

  • Fixed dashboard section exceeding the parent HTML element width.

  • Added support for following beta APIs which allows modifying running video stream state, which camera stream is running.

    /**
     * Returns the capabilities of the running video track.
     * 
     * Note: Should only be called if {@code Html5QrcodeScanner#getState()}
     *   returns {@code Html5QrcodeScannerState#SCANNING} or 
     *   {@code Html5QrcodeScannerState#PAUSED}.
     *
     * @beta This is an experimental API
     * @returns the capabilities of a running video track.
     * @throws error if the scanning is not in running state.
     */
    public getRunningTrackCapabilities(): MediaTrackCapabilities;
    
    /**
     * Apply a video constraints on running video track from camera.
     *
     * Note: Should only be called if {@code Html5QrcodeScanner#getState()}
     *   returns {@code Html5QrcodeScannerState#SCANNING} or 
     *   {@code Html5QrcodeScannerState#PAUSED}.
     *
     * @beta This is an experimental API
     * @param {MediaTrackConstraints} specifies a variety of video or camera
     *  controls as defined in
     *  https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints
     * @returns a Promise which succeeds if the passed constraints are applied,
     *  fails otherwise.
     * @throws error if the scanning is not in running state.
     */
    public applyVideoConstraints(videoConstaints: MediaTrackConstraints)   
    

    Important note: Both these APIs are beta and not publicly documented.

  • Support for pausing and resuming code scanning in camera scan mode. New APIs are added to both Html5QrcodeScanner and Html5Qrcode. They should only be called when the scanner state is Html5QrcodeScannerState#SCANNING (== 2) or Html5QrcodeScannerState#PAUSED (== 3).

    APIs added:

    /**
     * Pauses the ongoing scan.
     * 
     * Note: this will not stop the viewfinder, but stop decoding camera stream.
     * 
     * @throws error if method is called when scanner is not in scanning state.
     */
    public pause();
    
    /**
     * Resumes the paused scan.
     * 
     * Note: with this caller will start getting results in success and error
     * callbacks.
     * 
     * @throws error if method is called when scanner is not in paused state.
     */
    public resume();
    
        /**
     * Gets state of the camera scan.
     *
     * @returns state of type {@enum ScannerState}.
     */
    public getState(): Html5QrcodeScannerState;
    

    Example usage:

    let html5QrcodeScanner = new Html5QrcodeScanner(
        "reader", 
        { 
            fps: 10,
            qrbox: {width: 250, height: 250},
            rememberLastUsedCamera: true,
            aspectRatio: 1.7777778
        });
    
    function onScanSuccess(decodedText, decodedResult) {
        if (html5QrcodeScanner.getState() 
            !== Html5QrcodeScannerState.NOT_STARTED) {
            // Add this check to ensure success callback is not being called
            // from file based scanner.
    
            // Pause on scan result
            html5QrcodeScanner.pause();
        }
    
    
        // Handle your business logic
        // ...
    
        // .. ok to resume now or elsewhere.
        // just call html5QrcodeScanner.resume();
        // Make sure to check if the state is !== NOT_STARTED
    }
    html5QrcodeScanner.render(onScanSuccess);
    

    Note: when camera scan is paused it adds a UI element indicating that state.

mebjas
published 2.1.0 •

Changelog

Source

Version 2.1.0

  • [Fixed] issues related to using with lodash - https://github.com/mebjas/html5-qrcode/issues/284
  • [Fixed] Unable to use with typescript definition - https://github.com/mebjas/html5-qrcode/issues/283
  • [Fixed] Not working with react - https://github.com/mebjas/html5-qrcode/issues/322
  • [Fixed] TypeError: Html5QrcodeScanner is not a constructor - https://github.com/mebjas/html5-qrcode/issues/270
  • [Fixed] TypeError: window._ is undefined - https://github.com/mebjas/html5-qrcode/issues/248
mebjas
published 2.0.13 •

Changelog

Source

Version 2.0.13

Added ability to set custom width and height to the scanner with config.qrbox argument.

Now we can pass config.qrbox argument as instance of interface QrDimensions.

function onScanSuccess(decodedText, decodedResult) { /* handle success. */ }
function onScanFailure(error) { /* handle failure. */ }

let config = { fps: 10, qrbox: { width: 250, height: 250 } };

let html5QrcodeScanner = new Html5QrcodeScanner(
    "reader", config , /* verbose= */ false);
html5QrcodeScanner.render(onScanSuccess, onScanFailure);

For a rectangular QR Scanning box we can set it to something like:

// .. rest of the code
let config = { fps: 10, qrbox: { width: 400, height: 150 } };

let html5QrcodeScanner = new Html5QrcodeScanner(
    "reader", config , /* verbose= */ false);
html5QrcodeScanner.render(onScanSuccess, onScanFailure);
mebjas
published 2.0.12 •

Changelog

Source

Version 2.0.12

  • Redundant information in the top status bar removed.
  • Added support for remembering permission and last camera used. This feature is on by default. Can be turned on or off using rememberLastUsedCamera flag in Html5QrcodeScannerConfig. How to explicitly enable it:
      function onScanSuccess(decodedText, decodedResult) {
          // handle success.
      }
      let html5QrcodeScanner = new Html5QrcodeScanner(
        "reader", 
        { 
            fps: 10,
            qrbox: 250,
            rememberLastUsedCamera: true
            // ^ set this to false to disable this.
        });
      html5QrcodeScanner.render(onScanSuccess);
    
mebjas
published 2.0.11 •

Changelog

Source

Version 2.0.11

  • Add support for native BarcodeDetector based scanning.
    • On Chrome ZXing based decoder takes 20-25 ms on my Mac book pro 16.
    • On Chrome BarcodeDetector based decoder takes 8.6-11 ms on my Mac book pro 16.
    // How to enable
    // Note: will only work if browser / OS supports this HTML api.
    // Read more: https://developer.mozilla.org/en-US/docs/Web/API/BarcodeDetector#browser_compatibility
    function onScanSuccess(decodedText, decodedResult) {
        // handle success.
    }
    let html5QrcodeScanner = new Html5QrcodeScanner(
      "reader", 
      { 
          fps: 10,
          qrbox: 250,
          experimentalFeatures: {
              useBarCodeDetectorIfSupported: true
          }
      });
    html5QrcodeScanner.render(onScanSuccess);
    
mebjas
published 2.0.10 •

Changelog

Source

Version 2.0.10

  • Migrate from assets hosted on Github to embedded base64 assets.
mebjas
published 2.0.9 •

Changelog

Source

Version 2.0.9

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc