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

cycle-web-extensions

v0.5.1

Published

Cycle drivers to build WebExtensions

Readme

cycle-web-extensions

Cycle.js drivers to use in Chrome extensions and WebExtensions.

Forked from cycle-extensions to rewrite it with xstream. Additionally support for the tabs and windows APIs was added, and the MessagesDriver now supports more than one simultaneous connection.

Drivers

MessagesDriver

In the Web Extension architecture, logic and state both live in a long-running background page. The user interface lives in a separate page called a popup. The two pages communicate by passing messages between each other. The background page awaits connections; the popup initiates them.

messagesDriver accepts a stream of messages to send to the other page and returns a stream of messages received from the other page.

makeMessagesDriver takes a single named argument, shouldInitiate. Set it to false in the background page and true in any other pages.

Here's an example of a simple counter. Notice that when the popup opens, it sends a request for the current state to the background page. The response it receives creates the first frame of DOM.

import { run } from '@cycle/run'
import xs from 'xstream'
import sampleCombine from 'xstream/extra/sampleCombine'

import {
	makeMessagesDriver,
	newMessage,
	pickType,
} from 'cycle-web-extensions'

function Background({ messages: messages$ }) {
	const initialState = { count: 0 }

	const state$ = messages$.reduce(
		(state, message) => {
			if (message.type === 'increment') { return { ...state, count: state.count + 1 } }
			if (message.type === 'decrement') { return { ...state, count: state.count - 1 } }
			return state
		},
		initialState,
	)

	return {
		messages: xs.merge(
			state$.map(state => newMessage(['state_changed', state])),
			pickType(messages$, 'current_state_requested')
				.compose(sampleCombine(state$))
				.map(([, state]) => newMessage(['state_changed'], state))
			),
	}
}

run(
	Background,
	{ messages: makeMessagesDriver({ shouldInitiate: false }) },
)

// and in your popup script
import {
	makeMessagesDriver,
	newMessage,
} from 'cycle-web-extensions'
import { button, div } from 'hyperscript-helpers'

function Popup({ DOM, messages: messages$ }) {
	const count$ = pickType(messages$, 'state_changed')
		.map(payload => payload.count) // Why no pluck in xstream?

	return {
		messages: xs.merge(
			DOM.select('.increment').events('click').mapTo(newMessage(['increment'])),
			DOM.select('.decrement').events('click').mapTo(newMessage(['decrement'])),
		).startWith(newMessage('current_state_requested')),
		DOM: count$.map(
			count => (
				div([
					`The count is now ${count}.`,
					div([button('.decrement', ['-1']), button('.increment', ['+1'])]),
				])
			),
		),
	}
}

function intent(DOM) {
	const increment$ = DOM.select('.increment').events('click')
		.mapTo(newMessage(['increment']))
	const decrement$ = DOM.select('.decrement').events('click')
		.mapTo(newMessage(['decrement']))

	return {
		messages: xs.merge(increment$, decrement$)
			.startWith(newMessage(['current_state_requested'])),
	}
}

run(
	Popup,
	{
		DOM: makeDOMDriver('#root'),
		messages: makeMessagesDriver({ shouldInitiate: true }),
	},
)

WindowsDriver

  • TODO: Document this

TabsDriver

  • TODO: Document this

To see a real extension written with these drivers, check out nspaeth/tab-manager.

Installation

yarn add cycle-web-extensions

License

Apache 2.0