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

@dickcocker/wxt-messaging

v1.0.0

Published

Messaging in web-extension.

Readme

@dickcocker/wxt-messaging

About

TypeScript module for messaging in web-extension.

Little enhance of browser-messaging.

Supports:

  • all browsers;
  • manifest versions 2 and 3.

API

Install @types/chrome to get Port type in RuntimePortChatServer.

Classes

  • RuntimePortChatServer - for background.service-worker (background.script);

  • RuntimePortChatClient - for content-scripts;

  • WindowChatP2p - point-to-point chat for content-scripts (main and isolated worlds);

  • WindowChat - chat for content-scripts (main and isolated worlds).

Methods

All chats provides methods:

  • Base:

    1. message - to send message;

    2. response - to send response to message;

    3. on - to add listener of messages or responses;

    4. off - to remove listener of messages or responses.

  • Advanced:

    1. request - to send message and get its response;

    2. commands - to set message handlers that can send response.

Examples

Base

// content-script

const chat = new WindowChatP2p(true)

chat.on('message', (packet) => {
  if (packet.message === 'say hi')
    chat.response(packet.id, 'hi')
})

// will:
// 1. get message 'say hi';
// 2. response 'hi'.
// content-script in main world

const chat = new WindowChatP2p(false)

const off = chat.on('response', (packet) => {
  console.log('Response: ', packet.data)

  off()
})

chat.message('say hi')

// will:
// 1. message 'say hi';
// 2. get response 'hi';
// 3. log it;
// 4. stop listening responses.

Advanced

// service-worker

const chat = new RuntimePortChatServer()

chat.commands({
  hi: 'hi',

  sum(packet: PacketMessage<number[]>) {
    let result = 0

    for (const num of packet.data) {
      result += num
    }

    return result
  },

  promise,

  withoutResponse: () => {
    // undefined return = no response
  }
}, (packet) => console.log('Unhandled message: ', packet.message))

function promise(): Promise<'promise'> {
  return new Promise(
    resolve => setTimeout(
      () => resolve('promise'),
      1000
    )
  )
}
// content-script

const chat = new RuntimePortChatClient('client')

// will log 'hi'
chat.request('hi').then(console.log)

const sum = await chat.request<number>('sum', [1, 2, 3])
// sum is 6

// will log 'promise' in a second
chat.request('promise').then(console.log)

// will never log
chat.request('withoutResponse').then(console.log)

// will log 'something random' in service-worker
chat.message('something random')