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

blox-visualize

v0.1.0

Published

Drop-in trading panels: market chart, order book, depth, tape, order entry, orders, PnL.

Downloads

30

Readme

blox-visualize

Trading panels you can drop on a page, plus the demo server that feeds them.

Two things live here:

  • src/ — the blox-visualize npm package. Framework-agnostic panels that build their own DOM, and one feed adapter that speaks the wire protocol.
  • *.go + static/ — a demo: a TCP→WebSocket bridge onto blox-server, serving a page that mounts the package.

The package

import { FeedAdapter, MarketChart, createPriceFormat } from "blox-visualize";

const fmt  = createPriceFormat(2);
const feed = new FeedAdapter("wss://example/ws");
const chart = new MarketChart(document.querySelector("#chart"), { fmt, title: "BLOX/USD" });

feed.subscribe({
  onHistory: (trades) => chart.seed(trades),   // backfill, oldest first
  onTrade:   (t)      => chart.addTrade(t),
  onOrders:  undefined,
});
feed.connect();

Or mount everything at once:

import { TradingPanel, FeedAdapter } from "blox-visualize";
new TradingPanel(host, { feed: new FeedAdapter(url) });

Every panel is new Panel(host, opts)update(data)destroy(). The host is one element; the panel fills it. Pass title to get a header, or statusEl to send the status line into chrome you already draw.

Panels: MarketChart OrderBook Depth Trades OrderEntry Orders PnlPanel.

Depth hides levels further than maxRangePct from mid (default 1%) and says so on the canvas when it does — one order resting far out would otherwise stretch the axis across dead space and flatten the levels that matter. The window is intersected with the real book, so a tighter book still auto-fits. Pass maxRangePct: 0 to draw the whole book.

Subpath imports (blox-visualize/panels/chart) pull in one panel and nothing else — there are no side effects in any module body, so bundlers drop the rest. lightweight-charts is an optional peer dep, used only by MarketChart: it is taken from window.LightweightCharts if a script tag already loaded it, otherwise imported on demand.

Import blox-visualize/style.css once.

The wire

{ type, payload } frames over one WebSocket. hellohistory → then update / account / status / notice forever.

history is the backfill, and the adapter is what makes it safe: from the moment the socket opens it holds live frames, replays history when it lands, drains what it held, and only then streams. Without that, trades landing during the backfill are either lost or applied out of order. A reconnect re-arms the whole sequence and fires onReset first.

A server that sends no history frame is fine — a timeout releases the hold.

Running the demo

npm install && npm run build:demo   # compile the package into static/lib
cargo build --release -p blox-server
(cd ../blox-sim && go build -o blox-sim .)
go build -o blox-visualize . && ./blox-visualize

./blox-visualize with no flags spawns blox-server and blox-sim and serves the dashboard on http://127.0.0.1:8080. -addr attaches to a server you already run, -no-sim leaves the market to you, -history sets how many trades are retained and replayed to each new client (default 50000).

Developing

npm run check       # typecheck + the feed's backfill/ordering self-check
npm run build:demo  # compile src/ into static/lib
./blox-visualize -static-dir static   # serve the front end off disk

static/ is baked into the binary by //go:embed, so a front-end change is invisible until you go build again — which is easy to forget and looks like your edit did nothing. -static-dir static serves from disk instead; use it while iterating, and rebuild the binary when you ship.

static/app.js is page glue — topbar, status bar, splitters — and deliberately not part of the package.