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

@devicechain/dashboards

v1.9.0

Published

DeviceChain dashboard runtime — the DashboardHub (telemetry subscription multiplexing over the client wire, plus the alarm, command and location channels) and the dashboard-definition, selector, slot, and binding-manifest types.

Readme

@devicechain/dashboards

The DeviceChain dashboard runtime: the DashboardHub, which multiplexes live telemetry, alarms, commands and locations over the client wire, and the typed dashboard-definition contract that describes a board.

No React, no rendering. This is the layer under a widget set — the DeviceChain console and the standalone /dash viewer both sit on it, and so can yours. @devicechain/widgets is the React widget set built on this package.

npm install @devicechain/dashboards @devicechain/client graphql

@devicechain/client and graphql are peer dependencies. Peers rather than ordinary dependencies on purpose: the hub classifies stream errors with instanceof against the SDK's error type, and instanceof is false across two copies of the same package — a duplicate would turn "you may not view this device" into what reads like an outage.

The hub

One hub serves a whole board. Widgets subscribe to it; it does the deduplication.

import { DashboardHub, resolveWidgetDatasource } from '@devicechain/dashboards';

const hub = new DashboardHub({
  resolver,                 // how a selector becomes device tokens
  authorities: user.authorities, // what this viewer may do; drives hub.can(...)
});

// The hub holds no slot bindings: resolve a widget's `slot` selector through them
// first. A slot with no binding resolves to an explicit `unbound` selector, which the
// hub answers with no data; a raw `slot` selector is an error.
// It is undefined only for a widget that declares no datasource at all.
const datasource = resolveWidgetDatasource(widget.datasource, bindings);
const stop = datasource && hub.subscribeWidget(datasource, {
  next: (sample) => setLatest(sample),
});

// later
stop?.();
hub.disposeAll();

Ten widgets pointed at the same device open one upstream subscription, not ten. Each widget declares the measurement names it cares about (none means all), and the hub fans a single stream out to the subscribers that asked for each name.

Each subscription returns a disposer. Bucket reads return a promise:

| method | what it carries | | --- | --- | | subscribeWidget | measurement samples for a datasource selector | | subscribeMembers | a fleet widget's members, then each member's samples tagged with its device | | bucketMeasurements(datasource, window) | a Promise<MeasurementBucket[]> of count, minimum, maximum and sum; not a subscription | | subscribeAlarms | live alarm rows, plus acknowledgeAlarm / clearAlarm | | subscribeCommands | command rows and their delivery status, plus sendCommand | | subscribeLocations | position series for map widgets |

The widget layer depends on the WidgetDataSource interface, not on the hub class, so a host can feed it from the hub, from SyntheticDataSource or from a recorded run (RecordedDataSource). subscribeMembers, bucketMeasurements and readMemberSeeds are optional on that interface: a source without them leaves the widgets that need them saying so instead of showing a number.

disposeAll() tears down every open channel — a host calls it when the board closes, which is what keeps a poll and a socket from outliving the page.

authorities is an optional string[] (use decodeToken(token)?.authorities from @devicechain/client). Missing authorities grant no actions; '*' grants all. can(authority) checks that list. subscribeWidget(datasource, sink) receives individual MeasurementSample values. Alarm and command subscriptions take { datasource?, pageSize, ...filters } and emit whole snapshots through sink.next; location subscriptions take { datasource? } and emit either kind: 'positions' or kind: 'forbidden'. An absent alarm datasource means tenant-wide scope; an unbound selector means no devices.

sendCommand(deviceToken, commandKey, payload?) returns a Promise<CommandDispatch>: { status: 'sent', token } or { status: 'rejected', code, reason }. The payload is JSON text. A server refusal resolves to rejected; a transport failure rejects the promise. acknowledgeAlarm(token) and clearAlarm(token) return Promise<void>.

subscribePresence(datasource, sink) supplies device connectivity. Custom WidgetDataSource implementations may omit presence, member feeds, bucket reads, seed reads and declared-metric lookups; widgets feature-detect these capabilities. declaredMetrics(deviceType) and declaredMetricsForDevice(deviceToken) return measurement names or null when unknown; null must not mean that a metric is absent. Use historyWindowFor(spanSeconds, endMs) to construct the HistoryWindow used by bucketMeasurements and fetchWidgetHistory(widget, window, options?).

The definition contract

A dashboard is JSON. The server stores it opaquely; this package is what gives it a shape.

import { parseDashboardDefinition, serializeDefinition } from '@devicechain/dashboards';

const board = parseDashboardDefinition(json); // throws DashboardDefinitionError

A board saved by a newer release than this package is refused rather than read as the current format: the DashboardDefinitionError carries code: 'schemaTooNew' and the version it found in found. Test code, not instanceof, so the check still holds when an application ends up with two copies of the package.

Parsing is validating: a malformed board fails here, in your code, rather than half-rendering later. A board stored in an older format is converted as it is parsed, and the result carries a convertedFrom mark until it is saved again (withoutConversionMark drops it). isDirty compares a working copy against its saved original.

Layout

A board lays out on a grid of square cells. Each widget has a WidgetLayout: a Placement per breakpoint, with base required. A placement is either a grid footprint (GridPlacement, measured in cells) or a position relative to another widget (RelativePlacement). The column count follows the container, so the same board reads on a phone and on a wall display.

| need | exports | | --- | --- | | the placement a widget shows at a width | activeBreakpoint, resolvePlacement | | what a renderer draws for a container width | effectiveLayout, layoutShape, liveColumns | | pixel boxes for every widget | layoutRects, gridRect, relativeRect, cellSizeAt | | grid lengths and the widget frame | gridLengthPx, gutterPx, paddingPx, resolveFrame | | placement against what each widget can show | lintLayout, blockingLayoutFindings |

The editor-model transforms are pure functions an authoring UI can wire to drag and resize: addWidget, moveWidget, resizeWidget, setWidgetPlacement, placeOnGrid, placeRelative, deleteWidget, setTitle, setCanvasGrid, setCanvasDensity and updateWidget, with gridPlacementToPx and pxToGridPlacement to convert between cells and pixels. Moving or resizing a grid widget pushes whatever it now covers out of its way. Grid widgets never overlap, so there is no stacking order to manage.

Time range and density

A board has a time range: TIME_RANGE_PRESETS (15 minutes to 7 days), initialTimeRange, pauseRange / resumeRange and rangeWindow manage it, and timeRangeLinkFromSearch reads the range, paused and from / to URL parameters (timeRangeFromSearch reads only range and paused, for a host that knows no fixed window). A fixed from-to window is an additive variant of the same state: absoluteRange builds it and TimeRangeState.absolute marks it, while paused, pausedAt and spanSeconds still describe the window as a frozen rolling range, so code that only knows rolling ranges keeps working. Its density (CANVAS_DENSITIES: compact, comfortable, wall) scales every text and spacing size by DENSITY_SCALE; a host may override the board's own value at view time.

Slots

A board can be written once and pointed at many entities. A widget's datasource may name a slot instead of a device, and the host supplies a binding for that slot at view time — effectiveBindings, resolveContextBindings, applySelection and resolveSlotCandidates are the machinery.

The hub holds no bindings. A slot is resolved to a concrete selector before it is subscribed — resolveWidgetDatasource(datasource, bindings), which the DashboardRenderer in @devicechain/widgets calls for every widget — so one hub serves a board for its whole life, and re-pointing a slot re-subscribes only the widgets bound to it. A slot with no binding resolves to { kind: 'unbound' }, which every channel treats as zero devices; it is never turned into an absent datasource, which the alarm channel reads as tenant-wide. A raw slot selector handed straight to the hub is an error.

Synthetic data

SyntheticDataSource implements the same interface as the hub and generates plausible measurements, so a board can be previewed, screenshotted or demonstrated with no instance behind it.

Recorded playback and editor state

parseBoardRecording(input) validates a recording or throws RecordingFormatError. Use createRecordedClock(recording) and new RecordedDataSource(recording, clock) to replay it through WidgetDataSource; createRecordedResolver(recording) and createRecordedLister(recording) supply recorded entity lookup. Drive the clock with play(), pause(), seek(timeMs) and setRate(rate) (PLAYBACK_RATES lists supported rates). On teardown, call source.disposeAll() and clock.pause(). A renderer using this source should set seedHistory={false} so it does not query live history. Unsupported recorded channels report NotInRecordingError.

For an editor, createEditHistory, commitEdit, undoEdit and redoEdit manage immutable definition history. copyWidget / serializeWidgetClipboard and parseWidgetClipboard / pasteWidgets provide the portable clipboard format; duplicateWidget copies within a board. Keep the installed widget catalog with parsing and validation so extension widgets retain their identity.

Command status

isTerminalCommandStatus and isCancellableCommandStatus are the two questions worth asking about a command, and they are different questions — a SENT command is still in flight but is no longer cancellable. The underlying sets are deliberately not exported: every surface asks the predicate, so a new status cannot be learned by some call sites and not others.

Upgrading from 0.21

0.22 replaces the layout model, so code written against 0.21 needs changes:

| 0.21 | 0.22 | | --- | --- | | WidgetBox | Placement (GridPlacement or RelativePlacement) | | resolveWidgetBox | resolvePlacement | | baseBox | basePlacement | | setWidgetBox | setWidgetPlacement, or moveWidget / resizeWidget | | gridBoxToPx / pxToGridBox | gridPlacementToPx / pxToGridPlacement | | bringToFront | removed: grid widgets cannot overlap, so there is no stacking order |

These keep their names but change type:

  • WidgetLayout maps a breakpoint to a Placement, and Breakpoints maps a name to a BreakpointSpec.
  • CanvasGrid replaces gap and rowHeight with minCellSize, gutter and padding; GridGeometry replaces its column and row sizes with cell and gutter.
  • SYNTHETIC_GENERATORS is a list of generator ids ('sine', 'ramp', 'random-walk') instead of { value, label } pairs. Supply your own labels; the stored ids are unchanged.
  • parseDashboardDefinition refuses a definition whose grid widgets overlap. A definition in an older format is converted before that check.

Some unions gained members, which breaks an exhaustive switch over them: WidgetChannel has 'aggregate' (the stat card), OptionSpec has ListOptionSpec, and WidgetType, WidgetId and BuiltinWidgetId have the new built-in widgets.

The release's upgrade guide covers what changes for stored boards and for the other packages: If you build against the npm packages.

Compatibility

ESM only, built for bundler resolution (Vite, webpack, Rollup, esbuild). The emitted declarations use extensionless specifiers, which resolve under TypeScript's bundler module resolution and not under node16/nodenext.

License

Apache-2.0. See LICENSE.