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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wranggle/rpc-relay

v0.4.0-alpha.0

Published

WranggleRpc relay for bridging transports, when a message needs to hop across an intermediate window/process

Downloads

2

Readme

WranggleRpc Relay

The Relay is used to resend a message from one transort to another transport from some window/process in the middle, one that is not the final endpoint.

It is needed frequently in Wranggle's process automation product, which sometimes even needs to use two relays. For example, when authoring a Wranggle automation script, an RPC message sent from a browser extension content script to the desktop authoring Studio's user interface needs to travel through the main browser extension window and again through the Studio's main Electron process to reach its final endpoint.

Setup

If you are using the full @wranggle/rpc package, the Relay is already bundled within. You can import/require it with:

import Relay from '@wranggle/rpc';
// or
const { Relay } = require('@wranggle/rpc');

Unbundled Alternative

If you prefer using just the packages you need, the unbundled es6 is also available on NPM:

yarn add @wranggle/rpc-relay
# or
npm install @wranggle/rpc-relay

Unbundled import:

import Relay from '@wranggle/rpc-relay';

Construction

The relay has two required fields: left and right. Each is a WranggleRpc transport. It doesn't matter which is which. Messages received on the left are sent on to the right and vice versa.

You can use any type of WranggleRpc transport--in fact they're usually different types.

For example, here's a relay bridging a WebSocket server connection for a browser extension (the "left" side) with an Electron app's main-to-ui transport (the "right" side):

const Relay = require('@wranggle/rpc-relay');

const browserTransport = new WebSocketTransport({
  serverSocket: socket,
});

const uiTransport = new ElectronTransport({
  ipcSender: rendererWindow.webContents,
  ipcReceiver: ipcMain,
});

const relay new Relay({
  left: browserTransport,
  right: uiTransport,  
});

Options and methods

  • shouldRelay: Optional function that can block messages from being relayed. If applied, it must return true or the message will be dropped. It is passed the payload (for both requests and responses.) Type signature: (payload: RequestPayload | ResponsePayload) => boolean

  • relay.stopTransports()