npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

svelte-qr-scanner

v1.1.0

Published

This is a simple QRScanner using `instascan` and Svelte.

Downloads

25

Readme

QRScanner

This is a simple QRScanner using instascan and Svelte.

Get started

Import at your javascript at htmlx (svelte) file:

import QRScanner from 'svelte-qr-scanner'

In html part:

<QRScanner height="100" width="100" opts=.../>
  <div class="placeholder">No cameras loaded!</div>
</QRScanner>

Props

  • width - Scanner video width.
  • height - Scanner video height.
  • fit - object-fit strategy (none, contain, fill, scale-down...).
  • border - CSS border String. ('3px solid black').
  • borderRadius - CSS border radius String. ('5px').
  • cameras - List of cameras available.
  • opts - instascan opts.
let opts = {
  // Whether to scan continuously for QR codes. If false, use scanner.scan() to manually scan.
  // If true, the scanner emits the "scan" event when a QR code is scanned. Default true.
  continuous: true,
  
  // The HTML element to use for the camera's video preview. Must be a <video> element.
  // When the camera is active, this element will have the "active" CSS class, otherwise,
  // it will have the "inactive" class. By default, an invisible element will be created to
  // host the video.
  video: document.getElementById('preview'),
  
  // Whether to horizontally mirror the video preview. This is helpful when trying to
  // scan a QR code with a user-facing camera. Default true.
  mirror: true,
  
  // Whether to include the scanned image data as part of the scan result. See the "scan" event
  // for image format details. Default false.
  captureImage: false,
  
  // Only applies to continuous mode. Whether to actively scan when the tab is not active.
  // When false, this reduces CPU usage when the tab is not active. Default true.
  backgroundScan: true,
  
  // Only applies to continuous mode. The period, in milliseconds, before the same QR code
  // will be recognized in succession. Default 5000 (5 seconds).
  refractoryPeriod: 5000,
  
  // Only applies to continuous mode. The period, in rendered frames, between scans. A lower scan period
  // increases CPU usage but makes scan response faster. Default 1 (i.e. analyze every frame).
  scanPeriod: 1
};

Methods

  • scan() - Manually activates scan
  • stop() - Stops scanner
  • changeCamera(camera) - Changes the current camera, if no paramaters passed it changes to the next available camera.

Events

  • scan - Fired when the Scanner reads a QR Code, returns the content as event payload.
  • scannerStarted - Fired when scanner has started.
  • scannerStopped - Fired when scanner has stopped.
  • scannerStartFailed - Fired when scanner start failed.
  • loadCameraFailed - Fired when scanner camera has failed.