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

@absolutejs/sync-pack-presence

v0.3.1

Published

Per-channel live presence pack for @absolutejs/sync — heartbeat-driven, scoped, TTL-cleaned, with cursor + typing state patches

Readme

@absolutejs/sync-pack-presence

Per-channel live presence for @absolutejs/sync. Heartbeat-driven, scoped (per workspace/tenant), TTL-cleaned. Plugs into a SyncEngine with one engine.registerPack(...) call.

bun add @absolutejs/sync-pack-presence

Usage

import { createSyncEngine } from '@absolutejs/sync/engine';
import { createPresencePack } from '@absolutejs/sync-pack-presence';

const engine = createSyncEngine();
engine.registerPack(
	createPresencePack({
		// REQUIRED in practice: how the pack reads the current actor id from
		// your app's ctx. Default is `(ctx) => ctx.userId`.
		getActorId: (ctx) => ctx.session.userId,

		// OPTIONAL: tenant/workspace scope. Two scopes never see each other's
		// presence rows.
		scope: (ctx) => ctx.session.workspaceId,

		// OPTIONAL: TTL on a heartbeat (seconds). Default 30.
		heartbeatTtlSec: 30,

		// OPTIONAL: cron for the cleanup schedule. Default every 15 seconds.
		// You must still wire `@elysiajs/cron` to fire this — sync only owns
		// the handler, not the trigger.
		cleanupCron: '*/15 * * * * *'
	})
);

The pack exposes:

| Surface | Name | What it does | | ---------------------- | --------------------- | --------------------------------------------------------------------- | | Collection | presence | Subscribe with params: { channel } — returns live members | | Mutation | presence:heartbeat | Upsert the caller's row in a channel and refresh its TTL | | Mutation | presence:leave | Delete the caller's row in a channel | | Schedule | presence:cleanup | Delete rows with expiresAt <= now (cron-fired by your host) |

Storage

By default the pack uses an in-memory store — presence is ephemeral and almost always fine to lose on restart. To use a persistent backend (Drizzle, Postgres, Redis, …) pass a custom store:

import { createPresencePack, type PresenceStore } from '@absolutejs/sync-pack-presence';

const store: PresenceStore = {
	reader: { all: () => /* SELECT * FROM presence */ },
	writer: {
		insert: (row) => /* INSERT */,
		update: (row) => /* UPDATE */,
		delete: (row) => /* DELETE */,
	},
	expired: (now) => /* SELECT * FROM presence WHERE expires_at <= $1 */
};

engine.registerPack(createPresencePack({ store, getActorId: (ctx) => ctx.userId }));

Multiple instances

To run two presence packs on the same engine (e.g. one per product surface), pass a prefix to each — it scopes the owned table, the collection name, the mutation names, and the schedule name:

engine.registerPack(createPresencePack({ prefix: 'docs_', getActorId }));
engine.registerPack(createPresencePack({ prefix: 'chat_', getActorId }));

// Mutations are now `docs_presence:heartbeat` and `chat_presence:heartbeat`.
// Collections are `docs_presence` and `chat_presence`.
// Schedules are `docs_presence:cleanup` and `chat_presence:cleanup`.

Composition

This pack composes via subscriptions, not cross-pack mutation calls. If another pack wants to react to presence changes (e.g. a typing-indicator display), it subscribes to the presence collection — it does not call presence:heartbeat from inside its own handler. That keeps packs decoupled.

What's in the SyncPack

createPresencePack(config) returns a plain SyncPack record:

  • ownsTables: ['presence'] (or [${prefix}presence])
  • schemas: field validators for the presence row
  • permissions: read scoped to scope(ctx), write requires row.actorId === getActorId(ctx)
  • readers / writers: the in-memory store (or your custom one)
  • collections: the per-channel live-members collection
  • mutations: presence:heartbeat and presence:leave
  • schedules: presence:cleanup with a retry policy

This is inspectable at runtime via engine.inspect().packs.