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

@rozek/sds-core-jj

v0.0.13

Published

json-joy CRDT backend for shareable-data-store

Readme

@rozek/sds-core-jj

The json-joy CRDT backend for shareable-data-store. Provides SDS_DataStore, SDS_Item, SDS_Link, SDS_Entry, and SDS_Error backed by json-joy JSON CRDT.


Prerequisites

| requirement | details | | --- | --- | | Node.js 22+ | required when using this package in a Node.js project or build toolchain. Download from nodejs.org. | | Modern browser | required when using this package in a web application. Any evergreen browser is supported: Chrome 90+, Firefox 90+, Safari 15+, Edge 90+. | | json-joy ≥ 17 | peer dependency — install separately: pnpm add json-joy. |

This package is isomorphic. All other runtime dependencies (fflate, fractional-indexing, zod) are bundled.


When to use this package

Choose @rozek/sds-core-jj when:

  • you want the mature, well-tested json-joy CRDT backend.
  • you need the canonical-snapshot guarantee — every fromScratch() call starts from the same internal CRDT node-Id space, so cross-peer patches are always compatible even without prior snapshot exchange.
  • you need json-joy-specific serialisation interoperability (the binary format is stable and gzip-compressed).

Choose one of the alternative backend packages when you need a different CRDT library or want to migrate an existing store.


Installation

pnpm add @rozek/sds-core-jj
# peer dependencies:
pnpm add @rozek/sds-core
pnpm add json-joy

API

The public API — SDS_DataStore, SDS_Item, SDS_Link, SDS_Entry, SDS_Error, and all provider interfaces — is identical across all backends and is fully documented in the @rozek/sds-core README.


Examples

Building a tree and subscribing to changes

import { SDS_DataStore } from '@rozek/sds-core-jj'

const Store = SDS_DataStore.fromScratch()

const unsubscribe = Store.onChangeInvoke((Origin, ChangeSet) => {
  for (const [EntryId, changedKeys] of Object.entries(ChangeSet)) {
    console.log(`[${Origin}] ${EntryId}: ${[...changedKeys].join(', ')}`)
  }
})

Store.transact(() => {
  const Journal = Store.newItemAt(undefined, Store.RootItem)
  Journal.Label = 'Journal'

  const Entry = Store.newItemAt(undefined, Journal)
  Entry.Label = '2025-01-01'
  Entry.Info['mood'] = 'hopeful'
})

unsubscribe()

Syncing two stores via CRDT patches

import { SDS_DataStore } from '@rozek/sds-core-jj'

// two peers start from the same snapshot
const StoreA = SDS_DataStore.fromScratch()
const StoreB = SDS_DataStore.fromBinary(StoreA.asBinary())

// peer A makes a change
const ItemA = StoreA.newItemAt(undefined, StoreA.RootItem)
ItemA.Label = 'shared item'

// peer A exports a patch and peer B applies it
const Patch = StoreA.exportPatch()
StoreB.applyRemotePatch(Patch)

// both peers now agree
const ItemB = StoreB.EntryWithId(ItemA.Id)
console.log(ItemB?.Label)  // 'shared item'

Collaborative character editing

import { SDS_DataStore } from '@rozek/sds-core-jj'

const Store = SDS_DataStore.fromScratch({ LiteralSizeLimit: 65536 })
const Item = Store.newItemAt(undefined, Store.RootItem)

Item.writeValue('Hello, World!')

// replace characters 7–12 with 'SDS'
Item.changeValue(7, 12, 'SDS')

console.log(await Item.readValue())  // 'Hello, SDS!'

json-joy-specific details

Canonical empty snapshot

SDS_DataStore.fromScratch() loads a pre-generated canonical empty snapshot instead of building the CRDT document from scratch. This ensures all peers start from the same internal json-joy node-Id space so that patches are always compatible — even if the peers never exchanged a snapshot first.

The canonical snapshot is stored in packages/core-jj/src/store/canonical-empty-snapshot.ts and must be regenerated whenever the store schema or the json-joy version changes. The generation script is in packages/core/scripts/generate-canonical-snapshot.test.ts.

Cursor format

The SDS_SyncCursor for the json-joy backend is a 4-byte big-endian uint32 encoding the patch-log index. The persistence and network layers treat it as an opaque Uint8Array.

Patch encoding

Local patches are captured via json-joy's Model.api.flush() and assembled into a length-prefixed multi-patch envelope by encodePatches() / decodePatches() helpers inside SDS_DataStore.


Building

pnpm --filter @rozek/sds-core-jj build

Output is written to packages/core-jj/dist/.


License

MIT License © Andreas Rozek