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

@ingjuego/kon-tools

v0.2.88

Published

Maneja las herramientas

Downloads

16

Readme

kon-tools-package

@ingjuego/kon-tools

Librería de componentes y hooks reusables de React Native compatible con Expo y JS puro/Node.js. Permite compartir datos y lógica entre clientes, incluyendo un carrito compartido en tiempo real vía WebSocket y utilidades para juegos en tiempo real con Socket.IO.

Estructura del proyecto

  • components/: Componentes reusables (ej: SharedCart)
  • hooks/: Hooks personalizados (ej: useSharedCartWS)
  • models/: Tipos y modelos de datos
  • src/: Módulo principal y exports
  • example/: Proyecto de ejemplo para pruebas rápidas

Instalación

npm install @ingjuego/kon-tools

Uso básico

En React Native/Expo

Importa y utiliza los componentes o hooks en tu app Expo:

import { SharedCart } from '@ingjuego/kon-tools/components/SharedCart';

// ...
<SharedCart url="ws://localhost:8080" />

O usa el hook directamente:

import { useSharedCartWS } from '@ingjuego/kon-tools/hooks/useSharedCartWS';

const { cart, updateCart } = useSharedCartWS("ws://localhost:8080");

En Node.js/JS puro (Socket.IO)

Puedes usar las clases GameServer y GameClient para juegos o apps en tiempo real:

const { GameServer, GameClient } = require('@ingjuego/kon-tools');
const { Server } = require('socket.io');
const httpServer = require('http').createServer();
const io = GameServer.createServer(httpServer);

const gameServer = new GameServer(io);
gameServer.createRoom('sala1');

// Cliente
const { io: ioClient } = require('socket.io-client');
const socket = ioClient('http://localhost:3000');
const client = new GameClient(socket);
client.joinRoom('sala1');

Compartir carrito en tiempo real

El hook useSharedCartWS permite sincronizar el carrito entre todos los clientes conectados a un WebSocket propio. Puedes usar el componente SharedCart para una integración rápida.

Ejemplo de servidor WebSocket (Node.js)

const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 8080 });
let sharedCart = [];
wss.on('connection', ws => {
  ws.send(JSON.stringify({ type: 'cart', items: sharedCart }));
  ws.on('message', msg => {
    const data = JSON.parse(msg);
    if (data.type === 'updateCart') {
      sharedCart = data.items;
      wss.clients.forEach(client => {
        if (client.readyState === WebSocket.OPEN) {
          client.send(JSON.stringify({ type: 'cart', items: sharedCart }));
        }
      });
    }
  });
});

Ejemplo de servidor Socket.IO (Node.js)

const { GameServer } = require('@ingjuego/kon-tools');
const { Server } = require('socket.io');
const httpServer = require('http').createServer();
const io = GameServer.createServer(httpServer);

const gameServer = new GameServer(io);
gameServer.createRoom('sala1');

Scripts útiles

  • npm run build: Compila la librería
  • npm run test: Ejecuta los tests
  • npm run lint: Linting del código

Publicación

  1. Asegúrate de tener una cuenta en npm.
  2. Actualiza la versión en package.json.
  3. Ejecuta npm publish para publicar la librería.

Compatibilidad multiplataforma

Esta librería detecta automáticamente el entorno y expone la API adecuada para React Native/Expo, Node.js y JS puro/web. Consulta la documentación y los ejemplos para cada caso de uso.

Contribuir

Pull requests y sugerencias son bienvenidas. Por favor, abre un issue para discutir cambios importantes.

Licencia

MIT

npm publish --access public