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

scandit-sdk-react

v4.0.2

Published

Scandit Barcode Scanner SDK for the Web - React Component

Downloads

5,153

Readme

Scandit Barcode Scanner SDK for the Web - React Component

React component for the Scandit WebSDK.

Enterprise barcode scanning performance in your browser via JavaScript and WebAssembly.

Made by Scandit

Access cameras available on the devices for video input, display a barcode picker interface, configure in-depth settings for barcode symbologies and performance, and let users easily scan barcodes in your web application.

To use this library you must possess a valid Scandit account and license key. You can register for a free trial here.

Table of Contents:

React project integration

Install the Scandit WebSDK

Run npm install scandit-sdk --save to install the WebSDK library and save it to your dependencies.

Add the component to your project

In the component where you want to use it, add the ScanditBarcodeScanner component to your app:

  • import the needed parts:

    import ScanditBarcodeScanner from "scandit-sdk-react";
  • import optional parts from the main Scandit WebSDK if needed:

    import {
      Barcode,
      BarcodePicker,
      Camera,
      CameraAccess,
      CameraSettings,
      ScanSettings,
      SingleImageModeSettings,
    } from "scandit-sdk";

Use the component in your project

Add the component to your render function:

<ScanditBarcodeScanner
  // Library licensing & configuration options (see https://docs.scandit.com/stable/web/globals.html#configure)
  licenseKey={this.licenseKey}
  engineLocation="https://cdn.jsdelivr.net/npm/[email protected]/build" // could also be a local folder, e.g. "build"
  // Picker events
  onReady={() => this.setState({ scannerReady: true })}
  onScan={console.log}
  onScanError={console.log}
  // Picker options
  scanSettings={this.getScanSettings()}
/>

For the above example you also need in your component the following (example), to retrieve the scan settings:

getScanSettings = () => {
  return new ScanSettings({ enabledSymbologies: [Barcode.Symbology.CODE128] });
};

For a fully customized picker, see the example below:

<ScanditBarcodeScanner
  licenseKey={this.licenseKey}
  engineLocation="https://cdn.jsdelivr.net/npm/[email protected]/build"
  preloadBlurryRecognition={true}
  preloadEngine={true}
  onReady={console.log}
  onScan={console.log}
  onScanError={console.log}
  onSubmitFrame={console.log}
  onProcessFrame={console.log}
  scanSettings={this.getScanSettings()}
  paused={false}
  /*️
    ⚠️ Make sure to keep accessCamera and paused synchronized in a sensible way, as resuming scanning accesses
    the camera, so your state might become outdated.
    For example, set accessCamera to true whenever scanning is resumed.
  */
  accessCamera={true}
  camera={undefined}
  cameraSettings={undefined}
  enableCameraSwitcher={true}
  enablePinchToZoom={true}
  enableTapToFocus={true}
  enableTorchToggle={true}
  guiStyle={BarcodePicker.GuiStyle.LASER}
  laserArea={{ x: 0, y: 0, width: 1, height: 1 }}
  playSoundOnScan={true}
  targetScanningFPS={30}
  vibrateOnScan={true}
  videoFit={BarcodePicker.ObjectFit.CONTAIN}
  visible={true}
  viewfinderArea={{ x: 0, y: 0, width: 1, height: 1 }}
  zoom={0}
  // only set on component creation, can not be changed afterwards
  cameraType={Camera.Type.BACK}
  singleImageModeSettings={this.getSingleImageModeSettings()}
/>

For the above example you also need in your component the following (example), to retrieve the single image mode settings:

getSingleImageModeSettings = () => {
  return {
    desktop: {
      usageStrategy: SingleImageModeSettings.UsageStrategy.FALLBACK,
    },
    mobile: {
      usageStrategy: SingleImageModeSettings.UsageStrategy.FALLBACK,
    },
  };
};

Documentation

This component has been made to follow the BarcodePicker creation parameters and methods available in the main Scandit WebSDK library. In addition to that it also integrates the parameters for its configuration. Please refer to the demo application code, WebSDK BarcodePicker documentation and WebSDK configuration documentation for available options and details.

Breaking changes

v4.x

  • The component's singleImageMode attribute is now replaced by singleImageModeSettings, accepting a newly structured settings object.
  • The component's onScannerInitialized and scanner attributes are not available anymore, optimal performance regarding reuse of internal parts is now automatically handled by the library as part of the component's lifecycle.

Support

For questions or support please use the form you can find here or send us an email to [email protected].

License

This project is licensed under the Apache License, Version 2.0.

React component development

In case you want to work and modify the component itself.

Installation

  • Running npm install in the component's root directory will install everything you need for development.

Demo Development Server

  • npm start will run a development server with the component's demo app at http://localhost:3000 with hot module reloading.

Building

  • npm run build will build the component and also bundle the demo app.
  • npm run clean will delete built resources.