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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@phermange/datalogic-sdk-bridge

v0.7.5

Published

React Native bridge for Datalogic SDK - Barcode scanner integration for Expo apps

Downloads

16

Readme

@phermange/datalogic-sdk-bridge

React Native bridge pour le SDK Datalogic - Intégration de scanner de codes-barres pour les applications Expo.

Installation

npm install @phermange/datalogic-sdk-bridge

Utilisation

Import du module

import { BarcodeManager } from "@phermange/datalogic-sdk-bridge";

Écoute des événements de scan

import { useEffect, useState } from "react";
import { BarcodeManager } from "@phermange/datalogic-sdk-bridge";

export default function ScannerComponent() {
  const [lastScannedCode, setLastScannedCode] = useState<string>("");

  useEffect(() => {
    try {
      // Ajouter l'écouteur d'événements
      const subscription = BarcodeManager.addListener(
        "onBarcodeRead",
        (event) => {
          console.log("Code-barres scanné:", event.data);
          console.log("Timestamp:", event.timestamp);
          setLastScannedCode(event.data);
        }
      );

      // Démarrer l'écoute du scanner matériel (optionnel pour la simulation)
      BarcodeManager.addReadListener();

      // Cleanup lors du démontage du composant
      return () => {
        subscription.remove();
        BarcodeManager.removeReadListener();
      };
    } catch (error) {
      console.error("Erreur lors de l'initialisation du scanner:", error);
    }
  }, []);

  return (
    <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
      <Text style={{ fontSize: 18, marginBottom: 20 }}>Scanner Datalogic</Text>
      {lastScannedCode ? (
        <Text style={{ fontSize: 16, color: "green" }}>
          Dernier scan: {lastScannedCode}
        </Text>
      ) : (
        <Text style={{ fontSize: 16, color: "gray" }}>
          En attente d'un scan...
        </Text>
      )}
    </View>
  );
}

Simulation sans matériel (tests)

Pour tester la gestion d'événements côté React Native sans PDA/scanner Datalogic, utilisez la méthode native de simulation:

import { BarcodeManager } from "@phermange/datalogic-sdk-bridge";

// Émet un événement onBarcodeRead avec la donnée fournie
BarcodeManager.simulateBarcodeRead("TEST-123456");

Note:

  • La première fois que vous ajoutez/appelez une API native, une reconstruction native est requise (ex: npx expo run:android). Un simple reload JS ne suffit pas.
  • addReadListener() n'est pas nécessaire pour la simulation, mais peut rester si déjà appelé.

API

BarcodeManager

addReadListener()

Démarre l'écoute du scanner Datalogic (matériel).

removeReadListener()

Arrête l'écoute du scanner Datalogic (matériel).

simulateBarcodeRead(data: string)

Émet manuellement un événement onBarcodeRead pour les tests, avec la chaîne data fournie et un timestamp généré côté natif.

addListener(eventName, listener)

Ajoute un écouteur d'événements pour les scans de codes-barres.

Paramètres:

  • eventName: "onBarcodeRead"
  • listener: Fonction appelée lors d'un scan avec l'événement BarcodeReadEvent

Types TypeScript

type BarcodeReadEvent = {
  data: string; // Le code-barres scanné
  timestamp: number; // Timestamp du scan
};

Plateformes supportées

  • ✅ Android
  • ❌ iOS (non supporté)
  • ❌ Web (non supporté)

Prérequis

  • Expo SDK
  • Appareil Android avec scanner Datalogic intégré (pour les tests matériels)
  • Le SDK Datalogic Android est automatiquement inclus via JitPack

Licence

MIT