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

@tensnap/protocol

v0.3.3

Published

Canonical TenSnap renderer/simulator protocol payload types, schemas, and codecs.

Downloads

790

Readme

@tensnap/protocol

TenSnap's renderer/simulator contract: Zod schemas, inferred TypeScript types, JSON/MessagePack codecs, and conformance traces.

  • SPECIFICATION.md contains the cross-message lifecycle, transaction, ordering, and failure rules that cannot be expressed locally in code.
  • src/*.ts contains the payload schemas and their field-level documentation.
  • dist/protocol-types.md is the generated schema/type reference.
  • Root conformance suite contains canonical wire traces, executable binding probes, and the cross-binding evidence matrix.
  • src/codec.ts owns strict encoding, runtime validation, and the only legacy compatibility boundary.

Renderer persistence, project sources, snapshots, view layout, and painting are not wire protocol. Those contracts live in @tensnap/core and host packages.

Session codecs

Retain a ProtocolCodec (or createProtocolCodec() result) per session. The one-shot encodeProtocolMessage() / decodeProtocolMessage() helpers are deprecated; existing external callers can migrate to codec.encode(message, encoding) / codec.decode(frame) without changing their options. Pass the helpers' options argument to the codec constructor instead. A session codec retains legacy transaction correlation and lazily reuses MessagePack encoder/decoder state. Separate directional validation policies can use separate codecs. JSON-only sessions do not allocate MessagePack scratch buffers. For an isolated operation, new ProtocolCodec(options).encode(message, encoding) or .decode(frame) provides the same behavior.

MessagePack output owns its bytes: subsequent encodes cannot overwrite an earlier frame, so it can be queued for asynchronous sending. Decoded binary fields may view the input frame; do not mutate or recycle that input while its decoded values are in use. Oversized frames (over 1 MiB of encoded output or input backing storage) and failed MessagePack operations discard the relevant cached instance instead of retaining its buffers for the session's lifetime. This is a scratch-retention policy, not a message-size limit.

Wire records contain portable ProtocolValue data plus dedicated binary fields. Class instances, custom serialization hooks, and other non-portable objects must be projected before reaching the codec; disabling validation does not make them supported wire values. JSON's serializer already omits undefined object properties and writes undefined array entries as null. The wire MessagePack encoder uses ignoreUndefined: true and nil array entries for the same result, avoiding a redundant recursive clone before encoding. Optional undefined schema fields therefore behave identically in both formats. The legacy decoder still removes optional undefined fields introduced by alias conversion.

The generic encodeMessagePack() / decodeMessagePack() persistence helpers retain the upstream default semantics, including encoding undefined map values as nil; they do not apply wire-specific optional-field normalization.

Run focused, validation-off codec benchmarks with:

pnpm --dir packages/protocol bench:codec
# Select just one fixture size/encoding:
pnpm --dir packages/protocol bench:codec -t 'msgpack, 10000 nested items'

These measurements time encoding and decoding separately, without model projection, sockets, semantic oracles, or rendering. They are not substitutes for end-to-end evaluation.

Generate schema-derived type documentation with:

pnpm --dir packages/protocol export:protocol

The generated schema descriptions use unwrapped Markdown paragraphs; the TypeScript code blocks retain their source formatting. The output lives in the ignored dist/ build directory.