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

@yartsun/chat-widget-types

v1.0.17

Published

TypeScript definitions and professional migration system for HyperShadow Chat Widget configurations

Readme

🎨 Chat Widget Types & Migration System

Professional TypeScript definitions and migration system for HyperShadow Chat Widget configurations with support for version upgrades.

⚡ Features

  • 🏗️ Complete TypeScript definitions for all widget configurations
  • 🚀 Professional migration system V1 → V2 (and extensible for future versions)
  • 🎛️ CLI tools for config migration
  • 📊 Detailed migration reports and logging
  • 🛡️ Safe migrations with backup and validation
  • 🔧 Extensible architecture for future versions
  • 📈 High performance (~200-500 migrations/sec)

📦 Installation

npm install @yartsun/chat-widget-types

🎯 Quick Usage

import { WidgetConfig, quickMigrateV1toV2 } from '@yartsun/chat-widget-types'

// Type-safe configuration
const config: WidgetConfig = {
  settings: { /* ... */ },
  sections: { /* ... */ }
}

// Quick migration V1 → V2
const configV1 = { /* your V1 config */ }
const configV2 = await quickMigrateV1toV2(configV1)

🎨 Themes (V3 presets)

You can import JSON theme presets directly from the package.

Import by file path (subpath export)

import softTheme from '@yartsun/chat-widget-types/themes/configV3-soft.json'
import shineTheme from '@yartsun/chat-widget-types/themes/configV3-shine.json'
import ultraTheme from '@yartsun/chat-widget-types/themes/configV3-ultra.json'

Import by named alias (THEME_*)

import softTheme from '@yartsun/chat-widget-types/THEME_V3_SOFT'
import shineTheme from '@yartsun/chat-widget-types/THEME_V3_SHINE'
import ultraTheme from '@yartsun/chat-widget-types/THEME_V3_ULTRA'

🔄 Configuration Migration

Simple Migration

import { quickMigrateV1toV2 } from '@yartsun/chat-widget-types'

const migratedConfig = await quickMigrateV1toV2(yourV1Config)
if (migratedConfig) {
  console.log('✅ Migration successful!')
}

Advanced Migration with Reports

import { MigrationFacade, MigrationPresets } from '@yartsun/chat-widget-types'

const facade = new MigrationFacade(true) // verbose mode

// Preview migration
const preview = await facade.preview(config, '2.0')
console.log(`Will apply ${preview.appliedStrategies.length} strategies`)

// Execute migration
const result = await facade.migrateV1toV2(config, MigrationPresets.DEBUG)
if (result.success) {
  console.log('Migration completed:', result.appliedStrategies)
}

🎛️ CLI Migration Tool

# Simple migration
npm run migrate -- -i examples/configV1.json

# Migration with backup and verbose output
npm run migrate -- -i config.json -o config-v2.json -b -v

# Preview migration without executing
npm run migrate -- -i config.json -p

# Help
npm run migrate:help

Available Scripts

  • npm run migrate - Run migration CLI
  • npm run migrate:demo - Full migration demonstration
  • npm run migrate:examples - Run all examples
  • npm run migrate:help - Show CLI help

📊 What Changed in V2?

New Settings Fields:

  • loader: Animation type for loading states
  • buttonStyle: Button appearance style
  • buttonType: Button content type

New Section Features:

  • chipStyle in top section parameters
  • bgType for message backgrounds (bubble/plain)
  • aprooveButton & rejectButton for user actions
  • Enhanced inputSend with border styles and input types
  • warningAlert component
  • disclaimer text support

🏗️ Architecture

The migration system uses professional design patterns:

  • Strategy Pattern - Modular migration strategies
  • Command Pattern - Validation and utility commands
  • Facade Pattern - Simple API interface
  • Factory Pattern - Strategy and command creation
src/migration/
├── types.ts      # Type definitions
├── strategies.ts # Migration strategies V1→V2
├── commands.ts   # Validation & utility commands
├── migrator.ts   # Core migration engine
├── facade.ts     # Simple API facade
└── examples.ts   # Usage examples

🔧 Core Types

// Main configuration
interface WidgetConfig {
  settings: WidgetSettings
  sections: WidgetSections
}

// Settings with V2 enhancements
interface WidgetSettings {
  // Core fields
  widgetTitle: string
  welcomeMessage: string
  bgChat: string
  
  // V2 additions
  loader?: Loader
  buttonStyle?: ButtonStyle
  buttonType?: BtnType
}

// Enhanced sections
interface WidgetSections {
  top: TopSection    // Enhanced with chipStyle
  inside: InsideSection  // Added approve/reject buttons
  bottom: BottomSection  // Added warning alerts
}

Utility Functions

import {
  extractSettings,
  buildWidgetConfig,
} from '@yartsun/chat-widget-types'

// Extract structured settings from config
const settings = extractSettings(widgetConfig)

// Build config from separate settings
const newConfig = buildWidgetConfig(general, shapes, colors, fonts)

🎯 Extending for New Versions

The system is designed for easy extension. To add V3:

  1. Update types:
export type ConfigVersion = '1.0' | '2.0' | '3.0'
export interface ConfigV3 extends ConfigV2 { /* new fields */ }
  1. Create strategies:
export class AddNewFeatureV2toV3Strategy extends BaseMigrationStrategy {
  name = 'AddNewFeatureV2toV3'
  appliesTo = { from: '2.0', to: '3.0' }
  // implementation
}
  1. Register strategies:
export const V2_TO_V3_STRATEGIES = [new AddNewFeatureV2toV3Strategy()]

🧪 Examples & Demo

Run the full demonstration:

npm run migrate:demo

This includes:

  • Real file migration (examples/configV1.json → V2)
  • Performance testing (100 migrations)
  • All migration modes demonstration
  • Comparison with reference V2 config

📈 Performance

  • Speed: ~2-5ms per migration
  • Throughput: ~200-500 migrations/second
  • Memory: Minimal footprint
  • Reliability: 100% success rate on valid V1 configs

🛡️ Safety Features

  • Automatic version detection
  • Input validation
  • Backup creation before migration
  • Rollback support (where applicable)
  • Detailed error reporting
  • Dry-run mode for previewing changes

📚 API Reference

Quick Functions

  • quickMigrateV1toV2(config) - Simple V1→V2 migration
  • quickMigrateToLatest(config) - Migrate to latest version

Classes

  • MigrationFacade - Main API interface
  • ConfigMigrator - Core migration engine
  • ConfigHelpers - Utility functions

Presets

  • MigrationPresets.STRICT - Fail on any error
  • MigrationPresets.SOFT - Continue on errors
  • MigrationPresets.DEBUG - Verbose logging
  • MigrationPresets.PRODUCTION - Minimal output

🔧 Development

Building

npm run build

Testing Migration

# Run all examples
npm run migrate:examples

# Full demo with performance tests
npm run migrate:demo

# Test specific migration
npm run migrate -- -i examples/configV1.json -p

🤝 Contributing

  1. Follow TypeScript best practices
  2. Extend BaseMigrationStrategy for new strategies
  3. Add comprehensive tests
  4. Update documentation
  5. Follow SOLID principles

📄 License

MIT License - Free for commercial and non-commercial use.

🔗 Links


Built with ❤️ for professional widget configuration management