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

@shinka-rpc/browser-extension

v0.0.2

Published

Symmetric RPC bus. [Documentation is here](https://shinka-rpc-js.readthedocs.io/latest/transports/browser-extension/)

Readme

@shinka-rpc/browser-extension

Symmetric RPC bus. Documentation is here

This package contains a transports of @shinka-rpc/core for browser extension

Usage

The most common use-case is to passthrough requests and events from the page to the extension environment, and back. There are some contexts here:

Sometimes you need to communicate between them

Also you don't need to use any serializer here

Some pre-requirements

Inasmuch as page may send and receive messages, it would be good idea to mark our messages. So, let's define the file constants.ts:

export const MAIN2ISOLATED_TYPE = "MY_EXTENSION_MAIN2ISOLATED";
export const ISOLATED2MAIN_TYPE = "MY_EXTENSION_ISOLATED2MAIN";

Page MAIN ExecutionWorld

Here we are able to connect to the page ISOLATED ExecutionWorld only:

import { ClientBus } from "@shinka-rpc/core";
import { createClientFactory } from "@shinka-rpc/browser-extension";

import { MAIN2ISOLATED_TYPE, ISOLATED2MAIN_TYPE } from "./constants";

const factory = createClientFactory(ISOLATED2MAIN_TYPE, MAIN2ISOLATED_TYPE);
const bus = new ClientBus({ factory });

API Reference: createClientFactory

  • Required TAG_ONMESSAGE: unknown
  • Required TAG_SEND: unknown

Page ISOLATED ExecutionWorld

Here we are able to connect both to the page MAIN ExecutionWorld and to the background script. Some requests and events we have to passthrough to the background server script. That's why I think it's good idea to create the pair of buses:

import {
  createClientFactory,
  createIsolatedPair,
} from "@shinka-rpc/browser-extension";
import { passThroughEvent, passThroughRequest } from "@shinka-rpc/core";

import { MAIN2ISOLATED_TYPE, ISOLATED2MAIN_TYPE } from "./constants";

// Here be careful! We are using the same function `createClientFactory` to
// connect the content `MAIN` script. Here tags have to be passed in REVERSED
// order
const contentBusFactory = createClientFactory(
  MAIN2ISOLATED_TYPE,
  ISOLATED2MAIN_TYPE,
);

const { contentBus, extensionBus } = createIsolatedPair({ contentBusFactory });

passThroughEvent(contentBus, extensionBus, "example-event");
passThroughRequest(contentBus, extensionBus, "example-request");

API Reference: createIsolatedPair

  • Required contentBusFactory: FactoryClient<ClientBus>
  • Optional responseTimeout: number
  • Optional contentRegistry: Registry<ClientBus> hooks for content bus
  • Optional extensionRegistry: Registry<ClientBus> hooks for extension environment

Backgroung server script

Here we receive connections from all tabs with active extension ISOLATED ExecutionWorld. It's clear server scenario

import { ServerBus } from "@shinka-rpc/core";
import { messagePortFactory } from "@shinka-rpc/browser-extension";

export const server = new ServerBus()

chrome.runtime.onConnect.addListener(messagePortFactory(server));

API Reference: messagePortFactory

  • Required bus: ServerBus
  • Optional complete: (port: chrome.runtime.Port) => CompleteFN