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

@novasamatech/host-api

v0.13.0

Published

Host API: transport implementation for host - product integration.

Readme

@novasamatech/host-api

A protocol designed to connect Products and Host applications by providing a set of methods for communication.

Installation

npm install @novasamatech/host-api --save -E

Usage

The Host API package is composed of four main parts:

  • Protocol — SCALE codecs;
  • Provider — IPC interface, depends on environment;
  • Transport — wrapper around protocol for making actual calls;
  • Host API — wrapper around transport for direct usage of business methods.

Provider

Provider is an interface for IPC communication. You can find the definition here. The main goal is to abstract actual message send/receive logic from API. Products should not implement their own providers, it should be done inside SDKs.

Wire format

The wire format follows the truapi specification (codec version 3, RFC 0027). Every frame is

[requestId: SCALE str][trait: u8][method: u8][message_type: u8][payload bytes...]

(trait, method) addresses a method — the ids live in hostApiProtocol, grouped by trait — and message_type names the leg of the exchange: request / response / cancel for a request, start / receive / interrupt / stop for a subscription. The payload is that leg's own versioned wrapper (v1 → index 0, v2 → 1, …); a response is Result<Versioned<Ok>, CallError<Versioned<Err>>> and an interrupt Result<(), CallError<Versioned<Err>>>. Frames for an address the peer does not know are answered with a protocol error on the reserved (255, 255) address.

Transport

Transport is a low-level wrapper around protocol and provider. It encapsulates serialization/deserialization and request/subscription logic. Methods are addressed by (trait, method), exactly as the wire addresses them.

import { createTransport, enumValue, resultErr, resultOk } from '@novasamatech/host-api';
import { provider } from './custom-provider.js';

const transport = createTransport(provider);

// requesting by consumer

const response = await transport.request('localStorage', 'read', enumValue('v1', 'key'));

// handling request on provider side

const stop = transport.handleRequest('localStorage', 'read', async (payload, { signal }) => {
  try {
    const result = await readFromStorage(payload.value, signal);
    return enumValue(payload.tag, resultOk(result));
  } catch (e) {
    return enumValue(payload.tag, resultErr(e));
  }
});

// subscribing by consumer

const subscription = transport.subscribe('chat', 'actionSubscribe', enumValue('v1', undefined), (payload) => {
  console.log('action received:', payload);
});

subscription.onInterrupt(({ value }) => {
  // `undefined` is a clean completion; otherwise the method's own error or a transport failure
  console.log('subscription interrupted', value);
});

subscription.unsubscribe();

// handling subscription on provider side

transport.handleSubscription('chat', 'actionSubscribe', (params, send, interrupt) => {
  const unsubscribe = subscribeToChatActions((err, action) => {
    if (err) {
      interrupt(enumValue('v1', err));
    } else {
      send(enumValue('v1', action));
    }
  });

  return unsubscribe;
});

Aborting the signal passed to transport.request withdraws the call with a cancel frame: the handler's own signal fires, and the caller is answered CallError::Cancelled.

Host API

Host API is a wrapper around transport that provides convenient methods for calling methods and subscribing to events, nested by trait: hostApi.<trait>.<method>. It can be used by products directly or indirectly via SDK. All requests return a ResultAsync struct from the neverthrow library.

import { createHostApi, createTransport, enumValue } from '@novasamatech/host-api';
import { provider } from './custom-provider.js';

const transport = createTransport(provider);
const hostApi = createHostApi(transport);

// requesting data

const storageValue = hostApi.localStorage.read(enumValue('v1', 'key'));

storageValue.match(
  (data) => console.log('success:', data),
  (err) => console.log('error:', err)
);

// subscribing to events

const subscription = hostApi.chat.actionSubscribe(enumValue('v1', undefined), (action) => {
  console.log('action received:', action);
});

subscription.onInterrupt(() => {
  console.log('subscription interrupted');
});

subscription.unsubscribe();

Host-initiated subscriptions — the host opens them, the product serves them — are registered instead of called:

const stop = hostApi.renderer.render((params, send, interrupt) => {
  // params.value: { context: RenderContext, payload: Uint8Array }
  send(enumValue('v1', enumValue('String', 'Hello')));
  return () => {};
});

Renderer

The renderer trait draws product-defined bodies inside the host: chat messages, input widgets and Pocket cards. The host starts renderer.render with a RenderContext and an opaque payload; the product streams RendererNode trees back, and interactions inside those bodies arrive on renderer.actionSubscribe.

Available nodes: Box, Column, Row, Spacer, Text, Button, TextField, Image, Effect. Components support optional Modifiers (margin, padding, background, border, dimensions, opacity, blending mode) and containers carry children.

import { RenderContext, RendererNode } from '@novasamatech/host-api';

Account Connection Status

Products can subscribe to account connection status changes:

const subscription = hostApi.account.connectionStatusSubscribe(enumValue('v1', undefined), (status) => {
  // status.value: 'connected' | 'disconnected'
  console.log('connection status:', status.value);
});