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

@excom/service-worker

v0.1.4

Published

<service-worker> custom element

Downloads

114

Readme

service-worker

Observes navigator.serviceWorker and optionally relays its events — zero app JS required.

<div>
  <service-worker></service-worker>
</div>

Features

  • Observation only Reports on an existing Service Worker; never registers one
  • Support detection is-supported reflects API availability
  • Ready state is-ready reflects once an active worker controls the page
  • Event relay relay-events forwards message / messageerror / controllerchange as plain DOM events
  • Bindable state .provision is { isSupported, isReady, hasController, scope } — kept current on connect, ready, and every controllerchange; read it from Quark with prop("provision")

Installation

@excom/service-worker v0.1.4

pnpm add @excom/service-worker
npm install @excom/service-worker
yarn add @excom/service-worker

Import

import "@excom/service-worker";

Usage

This element only observes an already-registered Service Worker — it does not call navigator.serviceWorker.register(...) itself. Register your Service Worker separately (in app code, or your build tool), then drop this element anywhere to expose its state as attributes and, optionally, relay its events.

<service-worker relay-events></service-worker>
<event-handler listen-for="message" fire-event="sw-message-received">
  ...
</event-handler>

Relayed events (message, messageerror, controllerchange) are dispatched with their original names — they are not prefixed with service-worker-.

API Reference

Attributes

| Name | Surface | Type | Default | Values | Description | | --- | --- | --- | --- | --- | --- | | relay-events | option | tokenlist | | "message" | "messageerror" | "controllerchange" | Space-separated navigator.serviceWorker events to relay onto this element. Bare attribute (no value) relays all three. Event names are relayed as-is — not prefixed with the tag. | | is-ready | state | boolean | | | navigator.serviceWorker.ready has resolved — an active worker is controlling the page. | | is-supported | state | boolean | | | The Service Worker API is available ('serviceWorker' in navigator). |

Provision

| Name | Type | Description | | --- | --- | --- | | provision | ServiceWorkerProvision ({ isSupported: boolean; isReady: boolean; hasController: boolean; scope: string \| null; }) | { isSupported, isReady, hasController, scope } — set on connect, when ready resolves (scope comes from the registration), and on every controllerchange. Not reflected as an attribute. |

Fires

| Name | Type | Description | | --- | --- | --- | | message | ServiceWorkerMessageEvent (CustomEvent & { type: "message"; detail: unknown; bubbles: true; cancelable: true; composed: true }) | Relayed verbatim from navigator.serviceWorker's message event when message is included in relay-events. Not tag-prefixed. event.detail is event.data from the original message. | | messageerror | ServiceWorkerMessageErrorEvent (CustomEvent & { type: "messageerror"; detail: unknown; bubbles: true; cancelable: true; composed: true }) | Relayed verbatim from navigator.serviceWorker's messageerror event when messageerror is included in relay-events. Not tag-prefixed. | | controllerchange | ServiceWorkerControllerChangeEvent (CustomEvent & { type: "controllerchange"; detail: void; bubbles: true; cancelable: true; composed: true }) | Relayed verbatim from navigator.serviceWorker's controllerchange event when controllerchange is included in relay-events. Not tag-prefixed. |

Examples

Support / mount / ready state

is-supported, is-mounted (reflected by default), and is-ready are all plain attributes — style or branch on them with CSS. is-ready needs an app-registered Service Worker to ever resolve, so it will likely stay unset in this docs site.

<div>
  <service-worker></service-worker>
</div>

Relay messages from your Service Worker

Relaying message / messageerror / controllerchange requires a Service Worker that your app has already registered and that is actively posting messages — this is not runnable in this docs site, but works like so once wired up:

<service-worker relay-events="message"></service-worker>
<script>
  document
    .querySelector("service-worker")
    .addEventListener("message", (e) => console.log(e.detail));
</script>

Release notes

0.1.1 (2026-09-23)

  • Ship only dist (and declared extras) in the npm tarball; drop build logs, tests and sources

Full documentation: https://nucleus.excom.dev/packages/service-worker