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

@emtpzh/reader-component

v0.1.5

Published

Standalone reader extracted from Folo — publishable as a Web Component

Readme

@emtpzh/reader-component

A standalone article reader extracted from Folo, packaged as a Web Component (<folo-reader>).

Designed for use in browser extensions: the extension parses content and injects it via a ContentProvider, while the reader handles all rendering, dark mode, table of contents, and reading progress.

Build

# Standalone web app (dev/preview)
pnpm dev
pnpm build          # → dist/

# Web Component npm package
pnpm build:wc       # → dist-wc/folo-reader.js

Usage in a browser extension

1. Import the package

// Registers the <folo-reader> custom element as a side effect
import "@emtpzh/reader-component"

Or load the built file directly:

<script type="module" src="folo-reader.js"></script>

2. Implement a ContentProvider

import type { ContentProvider, ReaderEntry } from "@emtpzh/reader-component"

const provider: ContentProvider = {
  // Return the list of entries shown in the sidebar
  getEntries: async (): Promise<ReaderEntry[]> => {
    return [
      {
        id: "1",
        title: "My Article",
        content: "<p>Hello world</p>",
        publishedAt: new Date().toISOString(),
        author: "Alice",
        url: "https://example.com/article",
      },
    ]
  },

  // Return full content for a single entry (called when user selects one)
  getEntryDetail: async (id: string): Promise<ReaderEntry | null> => {
    return myContentMap[id] ?? null
  },
}

3. Mount and inject the provider

import { setContentProvider } from "@emtpzh/reader-component"

// Inject provider before or after mounting — both work
setContentProvider(provider)

const reader = document.createElement("folo-reader")
reader.style.cssText = "width: 100%; height: 100vh;"
document.body.appendChild(reader)

You can also call setProvider on the element instance directly:

const reader = document.querySelector("folo-reader") as any
reader.setProvider(provider)

4. Update content dynamically

Call setContentProvider again at any time to swap the data source (e.g. when the user navigates to a new page).

setContentProvider(newProvider)

ReaderEntry type

interface ReaderEntry {
  id: string
  title: string
  content: string // HTML string
  publishedAt: string // ISO 8601
  url?: string
  description?: string
  author?: string
  authorUrl?: string
  authorAvatar?: string
  categories?: string[]
  media?: { url: string; type: "photo" | "video"; width?: number; height?: number }[]
  attachments?: { url: string; title?: string; mime_type?: string; size_in_bytes?: number }[]
}

CSS isolation

The component uses Shadow DOM. All Tailwind CSS is injected into the shadow root — no styles leak in or out. The host page's styles have no effect on the reader.

Dark mode follows prefers-color-scheme automatically and can be toggled by the user via the button in the bottom-right corner.

Externalizing React

By default, React is bundled into folo-reader.js (self-contained, no peer dependencies).

If the extension already bundles React 19, you can avoid shipping it twice by setting rollupOptions.external in vite.config.ts:

rollupOptions: {
  external: ['react', 'react-dom'],
}

Then make sure React is available in the extension's build graph before importing this package.