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 🙏

© 2026 – Pkg Stats / Ryan Hefner

j-queue-sdk-web

v4.0.1

Published

A TypeScript package to check WebSocket connection status and control web access with a popup

Readme

J-Queue SDK Web

The J-Queue SDK Web is a JavaScript library for managing online queue systems in web applications. It provides a seamless integration with a WebSocket-based queue service, displaying a customizable popup UI to inform users about their queue status.

Features

  • Real-time Queue Management: Connects to a WebSocket server to receive real-time updates on queue position and status.
  • Customizable Popup UI: Displays a loading or queue position popup with customizable styles, colors, and languages (English and Korean).
  • Navigation Control: Prevents navigation during queue wait to ensure users don't lose their place.
  • Session Storage: Persists queue tokens and connect keys in sessionStorage for continuity.
  • Script Tag Configuration: Supports initialization via data-* attributes on the script tag for easy setup.
  • Event Listeners: Allows adding listeners for queue status updates.
  • Custom Events: Supports handling custom WebSocket events with utility functions.

Installation

Install the SDK via npm:

npm install j-queue-sdk-web

Or include it directly in your HTML using a CDN (replace x.x.x with the desired version):

<script src="https://unpkg.com/j-queue-sdk-web@<version>/dist/j-queue-sdk-web.js"></script>

Usage

Programmatic Initialization

Import and initialize the SDK in your JavaScript/TypeScript code:

import ConnectionJQueueSdkWeb from 'j-queue-sdk-web';

const config = {
  wsUrl: 'https://api-extra-queue.pressai.kr',
  apiUrl: 'https://api-extra-queue.pressai.kr',
  socketConfig: {
    query: { connect_key: 'your_connect_key' },
  },
  popupConfig: {
    isShowLoadingOnConnect: true,
    language: 'en',
    textColor: '#276bff',
    loaderGradientStart: '#276bff',
    loaderGradientEnd: 'rgba(39,107,255,0.05)',
  },
};

ConnectionJQueueSdkWeb.init(config)
  .then(({ disconnect }) => {
    console.log('J-Queue SDK initialized');
    // Store disconnect function for later use
  })
  .catch((error) => {
    console.error('Initialization failed:', error);
  });

// Add a status listener
ConnectionJQueueSdkWeb.addStatusListener((status) => {
  console.log('Queue status:', status);
});

Script Tag Initialization

Include the SDK script with data-* attributes to auto-initialize:

<script
  src="https://unpkg.com/j-queue-sdk-web@<version>/dist/j-queue-sdk-web.js"
  data-ws-url="https://api-extra-queue.pressai.kr"
  data-api-url="https://api-extra-queue.pressai.kr"
  data-connect-key="your_connect_key"
  data-show-loading="true"
  data-language="ko"
  data-mode="prod" 
  data-text-color="#276bff"
  data-loader-gradient-start="#276bff"
  data-loader-gradient-end="rgba(39,107,255,0.05)"
></script>

The SDK will automatically initialize using these attributes when the script loads.

Configuration Options

The InitConfig interface defines the configuration options:

  • wsUrl: WebSocket URL (default: https://api-extra-queue.pressai.kr for prod, https://dev-api-extra-queue.pressai.kr for dev).
  • apiUrl: API URL for operations like leaving the queue.
  • socketConfig: Socket.IO configuration.
    • query: Query parameters (e.g., { connect_key: 'your_key' }).
    • transports: Transport methods (default: ['websocket']).
    • reconnectionAttempts: Number of reconnection attempts (default: 3).
    • reconnectionDelay: Delay between reconnections (default: 1000ms).
  • popupConfig: Popup UI configuration.
    • content: Custom HTML or a function returning HTML based on queue position.
    • language: 'en' or 'ko' (default: 'ko').
    • textColor: Text color for popup content.
    • loaderGradientStart: Starting color for loader gradient.
    • loaderGradientEnd: Ending color for loader gradient.
    • style: Custom CSS for the popup.
    • isShowLoadingOnConnect: Show loading popup during connection (default: false).
  • customEvents: Handlers for custom WebSocket events.
  • option: Storage key settings.
    • storageTokenKey: sessionStorage key for queue token (default: 'queue_token').
    • storageConnectKey: sessionStorage key for connect key (default: 'connect_key').

Methods

  • init(config: InitConfig): Initializes the SDK. Returns a promise resolving to an object with a disconnect method.
  • addStatusListener(listener): Adds a callback to receive queue status updates.
  • removeStatusListener(listener): Removes a status listener.
  • getQueueStatus(): Returns the current queue status ({ uuid, position, status } or null).
  • initFromScriptAttributes(): Initializes the SDK using script tag attributes (called automatically on load).

Queue Statuses

Defined in the OnlineQueueStatus enum:

  • WAITING (1): User is waiting in the queue.
  • ACTIVE (2): User is active and can proceed.
  • EMPTY (3): Queue is empty or connect key is invalid.

Development

Prerequisites

  • Node.js >= 14
  • npm >= 6

Setup

git clone <repository-url>
cd j-queue-sdk-web
npm install

Running Tests

The SDK includes unit tests using Jest. Run them with:

npm test

Building

To build the SDK:

npm run build

Contributing

Contributions are welcome! Please submit a pull request or open an issue to discuss changes.

License

MIT

Repository