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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@rbxts/topo-runtime

v0.8.0

Published

Topologically-aware runtime for Roblox

Downloads

263

Readme

topo-runtime

This package provides an API for writing systems in function hook-ish style. The approach allows for seamless hot-reloading and thus better DX.

Check out the make-jsx package to use JSX in conjunction with hooks like useInstance.

Setup

Add the following entry inside compilerOptions.plugins of the tsconfig:

{
    "transform": "@rbxts/topo-runtime/transform/out/index.js"
}

Basic Usage


import { customHook } from "customHook";
import { loop } from "core";
// or
const loop = new Loop();

function mySystem() {
    // do something with hooks
}

const [step, evict] = loop.scheduleSystem(mySystem);
const connection = RunService.Heartbeat.Connect(step);
// or
const name = "my_system"
RunService.BindToRenderStep(name, Enum.RenderPriority.Camera.Value - 10, step)

defineCleanupCallback(() => {
    connection.Disconnect();
    // or
    RunService.UnbindFromRenderStep(name);

    // If you want a cold reload (meaning all of the state will be reset)
    // you have to evict the system before scheduling the hot reloaded one;
    if (coldReload) {
        evict();
    }
});

Loop

The Loop instance is required to run topologically aware functions. It also collects debug information that could be used by debugger implementations.

Hooks

Use useHookState function for implementing custom hooks. There is topo-hooks package that provides a set of common hooks.

Custom hooks example


function cleanupCallback() {}

export function customHook(discriminator?: unknown) {
    const storage = useHookState(discriminator, cleanupCallback);

    return // some stuff
}

Advanced

When implementing the hot-reload behavior for systems, the following behaviors should be considered.

The unique key for determining the system state is consists of 2 parts:

  • source of the script (the same as GetFullName());
  • system name; It means that moving the system declaration around or adding a new ones won't affect it's state when hot-reloaded. An attempt to schedule the anonymous function will result in an error being thrown.

The system state is a map where the key is a base key and the value is table consisting a hooks storage alongside cleanup callback. The hooks storage is a map where the key is a discriminator (if not provided, it defaults to 0) and the value is a discriminated hook storage.

The base keys are generated at compile time. These keys are unique per file and consist of the following parts:

  • the line and the character;
  • the text of the hook expression; It means that any line/character/text adjustments of the hook calls will result in their state being lost.