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

@jidou-ai/chat-widget

v1.6.0

Published

Jidou AI Web Chat Widget - Embeddable AI chat widget

Downloads

1,412

Readme

Jidou Chat Widget

A lightweight, customizable chat widget for AI-powered customer support.

Features

  • Multiple Display Modes: Floating, fullscreen, and embedded
  • Internationalization: Supports English, Traditional Chinese (zh-TW), Simplified Chinese (zh-CN), and Japanese
  • Theming: Light/dark themes with customizable colors
  • Real-time Communication: WebSocket-based messaging with auto-reconnect
  • Message Persistence: Local storage for chat history
  • Responsive Design: Works on desktop and mobile
  • Configurable Typing Indicator: Choose between animated dots or typewriter-style text with custom verbs
  • Shadow DOM: Isolated styles that won't conflict with host page

Installation

Via Script Tag

<script>
  window.JidouChatSettings = {
    clientId: 'YOUR_CLIENT_ID',
    // ... other options
  };
</script>
<script src="https://cdn.jidou.ai/widget.js"></script>

Via NPM

npm install @jidou-ai/chat-widget
import { Widget } from '@jidou-ai/chat-widget';

const widget = new Widget({
  clientId: 'YOUR_CLIENT_ID',
  // ... other options
});
widget.init();

Configuration

window.JidouChatSettings = {
  // Required
  clientId: 'YOUR_CLIENT_ID',

  // Display mode: 'floating' | 'fullscreen' | 'embedded'
  displayMode: 'floating',

  // Language: 'en' | 'zh-TW' | 'zh-CN' | 'ja' | 'auto'
  language: 'auto',

  // Theme: 'light' | 'dark'
  theme: 'light',

  // WebSocket URL (optional, uses default if not specified)
  wsUrl: 'wss://chat.jidou.ai/ws',

  // Custom colors
  colors: {
    primary: '#4F46E5',
    background: '#FFFFFF',
    text: '#1F2937',
    botBubble: '#F3F4F6',
    userBubble: '#4F46E5',
  },

  // Launcher configuration (floating mode only)
  launcher: {
    show: true,
    position: 'bottom-right', // 'bottom-right' | 'bottom-left'
    size: 'medium',           // 'small' | 'medium' | 'large'
    shape: 'circle',          // 'circle' | 'rounded'
    offsetX: 20,
    offsetY: 20,
    tooltip: {
      show: true,
      text: 'Need help?',
    },
  },

  // Chat window configuration
  chatWindow: {
    width: 380,
    height: 600,
    borderRadius: 16,
    typingIndicator: {
      style: 'dots',       // 'dots' | 'text'
      texts: ['Thinking...', 'Analyzing...', 'Composing...'],  // text style only
      interval: 2000,      // ms to pause at each completed word (text style only)
    },
    header: {
      title: 'AI Assistant',
      subtitle: 'Online',
      logo: {
        show: true,
        url: 'https://example.com/logo.png',
        size: 40,
      },
    },
    footer: {
      input: {
        placeholder: 'Type a message...',
        maxLength: 1000,
      },
      branding: {
        show: true,
        text: 'Powered by Jidou',
      },
    },
    welcomeScreen: {
      quickReplies: {
        items: [
          { text: 'Getting Started', icon: '🚀' },
          { text: 'Pricing', icon: '💰' },
          { text: 'Support', icon: '🆘' },
        ],
      },
    },
  },

  // Behavior configuration
  behavior: {
    autoOpen: {
      enabled: false,
      delay: 3000,
    },
    persistence: {
      enabled: true,
      duration: 7, // days
    },
  },

  // Container for embedded mode
  container: '#chat-container',

  // Z-index
  zIndex: 9999,

  // Event hooks
  hooks: {
    onLoad: () => {},
    onReady: () => {},
    onOpen: () => {},
    onClose: () => {},
    onMessageSent: (message) => {},
    onMessageReceived: (message) => {},
    onConnectionStateChange: (state) => {},
    onReconnect: (attempt) => {},
    onError: (error) => {},
  },
};

API

The widget exposes a global JidouChat object with the following methods:

// Open the chat window
JidouChat.open();

// Close the chat window
JidouChat.close();

// Toggle the chat window
JidouChat.toggle();

// Check if chat is open
JidouChat.isOpen();

// Send a message programmatically
JidouChat.sendMessage('Hello!');

// Change display mode
JidouChat.setDisplayMode('fullscreen');
JidouChat.setDisplayMode('floating');
JidouChat.setDisplayMode('embedded', { container: '#my-container' });

// Get current display mode
JidouChat.getDisplayMode();

// Get current state
JidouChat.getState();

// Subscribe to events
JidouChat.on('onMessageReceived', (message) => {
  console.log('New message:', message);
});

// Unsubscribe from events
JidouChat.off('onMessageReceived', handler);

// Destroy the widget
JidouChat.destroy();

Typing Indicator

The widget supports two typing indicator styles when the assistant is composing a response:

Dots (default)

The classic animated dots (...) indicator. No configuration needed.

Text (typewriter)

A typewriter-style animation that cycles through configurable verb phrases character by character, similar to the Claude Code CLI.

chatWindow: {
  typingIndicator: {
    style: 'text',
    // Optional: custom texts (defaults to i18n "Thinking...", "Analyzing...", "Composing...")
    texts: ['Searching knowledge base...', 'Crafting response...', 'Almost done...'],
    // Optional: pause duration in ms at each completed word (default: 2000)
    interval: 2500,
  },
}

When using style: 'text' without providing texts, the widget uses built-in translations based on the current language setting:

| Language | Default texts | |----------|--------------| | English | Thinking..., Analyzing..., Composing... | | 繁體中文 | 思考中..., 分析中..., 撰寫中... | | 简体中文 | 思考中..., 分析中..., 撰写中... | | 日本語 | 考え中..., 分析中..., 作成中... |

Internationalization

The widget automatically detects browser language when language: 'auto' is set. Supported languages:

| Code | Language | |------|----------| | en | English | | zh-TW | Traditional Chinese | | zh-CN | Simplified Chinese | | ja | Japanese |

Translated strings include:

  • Connection status (Connecting, Connected, Disconnected, etc.)
  • Chat window title
  • Input placeholder
  • Button labels (Close, Expand, Collapse)
  • Branding text
  • Typing indicator texts (Thinking, Analyzing, Composing)

Development

Prerequisites

  • Node.js 18+
  • npm or yarn

Setup

# Install dependencies
npm install

# Start development server with mock WebSocket
npm run dev

# Build for production
npm run build

# Run tests
npm test

Project Structure

src/
├── components/       # UI components
│   ├── BaseComponent.ts
│   ├── ChatWindow.ts
│   ├── ConnectionStatus.ts
│   ├── InputArea.ts
│   ├── Launcher.ts
│   ├── MessageList.ts
│   ├── QuickReplies.ts
│   └── icons.ts
├── core/
│   └── Widget.ts     # Main widget class
├── i18n/             # Internationalization
│   ├── index.ts
│   └── translations.ts
├── services/         # Business logic
│   ├── ChatHistoryManager.ts
│   ├── StateManager.ts
│   └── WebSocketClient.ts
├── styles/           # CSS styles
├── types/            # TypeScript types
├── utils/            # Utility functions
└── index.ts          # Entry point

Browser Support

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)

License

Copyright © Jidou AI. All rights reserved.