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

@tyrosking/web-push

v0.2.0

Published

Tencent Cloud Web Push SDK - Service Worker-based web push notification service

Readme

Tencent Cloud Web Push SDK

A web-based push notification SDK built on modern Web APIs including Service Worker, Push API, and Notification API.

Features

  • 🚀 Built on modern Web standard APIs
  • 📱 Cross-platform push notification support
  • 🔧 TypeScript support
  • 📊 Built-in analytics functionality
  • 🎯 Event-driven architecture
  • 💾 Local state persistence
  • 🔒 Secure VAPID authentication

Browser Support

  • Chrome 50+
  • Firefox 44+
  • Safari 16+
  • Edge 17+

Installation

npm install @tencentcloud/web-push

Quick Start

Basic Usage

import webPush from '@tencentcloud/web-push';

const SDKAppID = 0; // Your SDKAppID
const appKey = 'your-app-key'; // Client key
const userID = 'xxx'; // User ID

// Register push service
await webPush.registerPush({ SDKAppID, appKey, userID });

// Listen for push messages
webPush.addPushListener(webPush.EVENT.MESSAGE_RECEIVED, (message) => {
  console.log('Received push message:', message);
});

// Listen for notification clicks
webPush.addPushListener(webPush.EVENT.NOTIFICATION_CLICKED, (data) => {
  console.log('Notification clicked:', data);
});

// Listen for message revocation
webPush.addPushListener(webPush.EVENT.MESSAGE_REVOKED, (messageID) => {
  console.log('Message revoked:', messageID);
});

Integration with Chat SDK

import webPush from '@tencentcloud/web-push';
import ChatSDK from '@tencentcloud/lite-chat';

const SDKAppID = 0; // Your SDKAppID
const appKey = 'your-app-key'; // Client key
const userID = 'xxx'; // User ID
const userSig = 'xxxx'; // User signature for IM login

const chat = ChatSDK.create({ SDKAppID });
await chat.login({ userID, userSig });

// Register push service with chat instance
await webPush.registerPush({ SDKAppID, appKey, userID, chat });

API Reference

Methods

| API | Parameters | Description | | -------------------- | --------------------------------------------------- | -------------------------- | | registerPush | options: RegisterPushOptions | Register push service | | unRegisterPush | - | Unregister push service | | addPushListener | eventName: EVENT, listener: Function<EventResult> | Add push event listener | | removePushListener | eventName: EVENT, listener: Function<EventResult> | Remove push event listener |

Type Definitions

interface RegisterPushOptions {
  SDKAppID: number;
  appKey: string;
  userID: string;
  serviceWorkerPath?: string;
  chat?: any;
}

enum EVENT {
  MESSAGE_RECEIVED = 'message_received',
  MESSAGE_REVOKED = 'message_revoked',
  NOTIFICATION_CLICKED = 'notification_clicked',
}

interface Message {
  ID: string;
  type:
    | 'TIMTextElem'
    | 'TIMImageElem'
    | 'TIMSoundElem'
    | 'TIMVideoFileElem'
    | 'TIMFileElem'
    | 'TIMCustomElem'
    | 'TIMRelayElem'
    | 'TIMLocationElem'
    | 'TIMFaceElem';
  payload: any;
  conversationID: string;
  conversationType: 'C2C' | 'GROUP';
  to: string;
  from: string;
  flow: string;
  time: number;
  status: string;
  isRevoked: boolean;
  nick: string;
  avatar: string;
  isPeerRead: boolean;
  nameCard: string;
  atUserList: string[];
  cloudCustomData: string;
  isDeleted: boolean;
  isModified: boolean;
  needReadReceipt: boolean;
  readReceiptInfo: any;
  isBroadcastMessage: boolean;
  isSupportExtension: boolean;
  receiverList?: string[];
  revoker: string;
  sequence: number;
  progress: number;
  revokerInfo: {
    userID: string;
    nick: string;
    avatar: string;
  };
  revokeReason: string;
  hasRiskContent: boolean;
}

interface MessageReceivedResult {
  message: Message;
}

interface MessageRevokedResult {
  messageID: string;
}

interface MessageNotificationClickedResult {
  ext: string;
}

interface EventResult {
  data:
    | MessageReceivedResult
    | MessageRevokedResult
    | MessageNotificationClickedResult;
}

Event Types

  • MESSAGE_RECEIVED: Received a push message
  • MESSAGE_REVOKED: Message was revoked
  • NOTIFICATION_CLICKED: Notification was clicked

Service Worker Configuration

The SDK requires a Service Worker to handle push messages. Make sure to place the sw.js file in your website's root directory:

// public/sw.js
importScripts('node_modules/@tencentcloud/web-push/sw.js');

License

MIT License