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

@palantir/pack.state.demo

v0.8.0

Published

Offline demo implementation of `DocumentService` for local development and testing.

Readme

@palantir/pack.state.demo

Offline demo implementation of DocumentService for local development and testing.

Purpose

This package provides a browser-based, offline-capable document service implementation that:

  • Persists documents locally using IndexedDB (via y-indexeddb)
  • Synchronizes document changes across browser tabs using BroadcastChannel API
  • Implements presence and activity tracking across tabs
  • Requires no backend server or network connectivity

This is intended for:

  • Local development without Foundry backend
  • Testing React components and pack layers in isolation
  • Demos and prototypes
  • Unit and integration testing

Architecture

Two-tier Persistence

  1. Metadata Store: Single Y.Doc containing metadata for all documents
  2. Document Store: Individual Y.Docs per document, each with its own IndexedDB persistence

Cross-Tab Synchronization

  • Data Channels: Y.js updates broadcast via BroadcastChannel for real-time sync
  • Presence Channels: Heartbeat mechanism tracks active clients across tabs
  • Activity Broadcasting: Custom presence data shared across all document subscribers

Status Management

Documents transition through standard load and live states:

  • Load: UNLOADEDLOADINGLOADED
  • Live: DISCONNECTEDCONNECTINGCONNECTED

Usage

import { createPackApp } from "@palantir/pack.core";
import { createDemoDocumentServiceConfig } from "@palantir/pack.state.demo";

const app = createPackApp({
  modules: [
    createDemoDocumentServiceConfig({
      dbPrefix: "my-app", // Optional, defaults to "pack-demo"
    }),
  ],
});

Implementation Details

BaseYjsDocumentService Extension

Extends BaseYjsDocumentService which handles:

  • Y.Doc lifecycle and initialization
  • Record CRUD operations
  • Subscription management
  • Change notifications

Demo implementation adds:

  • IndexedDB persistence layer
  • BroadcastChannel synchronization
  • Presence heartbeat management

Presence Heartbeat Protocol

Clients broadcast heartbeats every 5 seconds. The PresenceManager:

  • Tracks all active clients by clientId
  • Emits "arrive" events when new heartbeats appear
  • Emits "depart" events when heartbeats go stale (>15s)

This provides automatic presence detection without explicit arrive/depart messages.

Testing

Run tests with:

pnpm test

Tests cover:

  • Document creation and persistence across service instances
  • Cross-tab synchronization (simulated with multiple service instances)
  • Presence arrive/depart events
  • Activity event broadcasting
  • Status transition lifecycle
  • Search functionality

Limitations

  • Browser-only: Requires IndexedDB and BroadcastChannel APIs
  • No conflict resolution: Relies on Y.js CRDT for concurrent edits
  • No server sync: Changes persist only in browser storage
  • No auth/security: All documents accessible locally
  • Storage limits: Subject to browser IndexedDB quotas

Private Package

This package is marked as private and not published to npm. It's intended for internal development and testing workflows only.