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

@actuallab/fusion-rpc

v14.3.34

Published

Bridge between Fusion and RPC - FusionHub, compute service registration

Downloads

1,423

Readme

@actuallab/fusion-rpc

npm Documentation License

The bridge between @actuallab/fusion and @actuallab/rpc: FusionHub — a compute-aware RPC hub whose client proxies cache results locally and drop them the moment the .NET server says the value changed. This is the TypeScript equivalent of Fusion's client-side RPC infrastructure (Remote Compute Service interceptor, RpcComputeCallType).

This is the package you want if your goal is "call Fusion Compute Services running on a .NET server from a JS/TS client, and get real-time updates".

Installation

npm install @actuallab/fusion-rpc

ESM-first with a CJS fallback; ships its own .d.ts. Pulls in @actuallab/core, @actuallab/fusion, and @actuallab/rpc.

Quick start

import { FusionHub, defineComputeService } from '@actuallab/fusion-rpc';
import { RpcClientPeer, RpcPeerStateMonitor } from '@actuallab/rpc';

// 1. Define the service — the name must match the .NET interface name exactly.
const TodoApiDef = defineComputeService('ITodoApi', {
    // Compute methods: cached locally, invalidated by the server
    Get: { args: ['', ''] },                     // (session, id) → TodoItem
    ListIds: { args: ['', 0] },                  // (session, count) → string[]
    GetSummary: { args: [''] },                  // (session) → TodoSummary

    // Commands: opt out of compute caching
    AddOrUpdate: { args: [{}], callTypeId: 0 },
    Remove: { args: [{}], callTypeId: 0 },
});

// 2. Hub + peer. The RpcClientPeer ctor starts the connect/reconnect loop.
const hub = new FusionHub();
const peer = new RpcClientPeer(hub, 'ws://localhost:5005/rpc/ws');
hub.addPeer(peer);

// 3. Typed client proxy — addClient is idempotent per (peer, service),
//    so every consumer shares one Computed and one invalidation stream.
const api = hub.addClient<ITodoApi>(peer, TodoApiDef);

// 4. Optional: connection status for the UI
const monitor = new RpcPeerStateMonitor(peer);

// Cached until the server invalidates it
const ids = await api.ListIds('~', 10);

Render it with useComputedState and the component refreshes itself whenever the server-side data changes.

How invalidation flows

  1. The client calls a compute method — FusionHub sends it with CallType = 1.
  2. The server computes, responds with $sys.Ok; the client caches the result locally.
  3. Server-side data changes and the server-side Computed<T> is invalidated.
  4. The server sends $sys-c.Invalidate for that call id.
  5. The client invalidates its local replica; the invalidation cascades into every dependent @computeMethod and ComputedState<T> — and React re-renders.

An Invalidate that arrives before the result retries the call transparently (up to 3 attempts while connected). On disconnect, compute replicas self-invalidate instead of being re-sent, since the server's tracking for them is gone; regular in-flight calls are re-sent as usual.

API surface

| API | Description | |-----|-------------| | FusionHub | RpcHub + compute-aware proxies, invalidation wiring, acceptConnection(ws) for hosting | | defineComputeService(name, methods) | Service definition where methods default to callTypeId: 1 (compute); use callTypeId: 0 for commands | | FUSION_CALL_TYPE_ID | The compute call type id (1) | | RpcOutboundComputeCall | The outbound call type that carries invalidation handling |

Notes

  • Cancellation. A caller's AbortSignal travels through AsyncContext (abortSignalKey); aborting sends $sys.Cancel, and the resulting cancellation error is never cached.
  • Hosting compute services in Node. hub.addService(def, impl) wraps compute methods and wires invalidation to $sys-c.Invalidate. Use a class with @computeMethod members whenever service methods call each other — a plain-object impl calls them as raw functions and loses the dependency edges.

Documentation

License

MIT — see LICENSE.