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

@l8b/runtime

v1.0.11

Published

**Runtime Orchestrator** - Core runtime system for the l8b game engine.

Readme

@l8b/runtime

Runtime Orchestrator - Core runtime system for the l8b game engine.

Note: This package is for engine developers integrating l8b into applications.

Overview

The runtime package provides RuntimeOrchestrator, which coordinates all engine subsystems:

  • Screen rendering
  • Audio playback
  • Input handling
  • Asset loading
  • Scene management
  • Storage/IO
  • Standard library
  • VM execution

Installation

pnpm install @l8b/runtime

Basic Usage

import { RuntimeOrchestrator } from "@l8b/runtime";

// Create runtime instance
const runtime = new RuntimeOrchestrator({
  canvas: document.getElementById("game-canvas"),
  listener: {
    // Optional callbacks
    codeStarted: () => console.log("Game started"),
    codePaused: () => console.log("Game paused"),
    codeEnded: () => console.log("Game ended"),
    reportError: (error) => console.error("Runtime error:", error),
  },
});

// Load and run LootiScript code
const code = `
  function update() {
    // Game logic
  }
  
  function draw() {
    screen.clear("#000")
    screen.drawText("Hello World", 10, 10, 16)
  }
`;

await runtime.loadCode(code);
runtime.start();

Configuration

RuntimeOptions

interface RuntimeOptions {
  canvas?: HTMLCanvasElement;
  width?: number;
  height?: number;
  listener?: RuntimeListener;
  preserveStorage?: boolean;
}
  • canvas - Canvas element for rendering (optional, creates one if not provided)
  • width - Canvas width in pixels (default: 1080)
  • height - Canvas height in pixels (default: 1920)
  • listener - Event callbacks for runtime lifecycle
  • preserveStorage - Keep existing storage data (default: false)

RuntimeListener

interface RuntimeListener {
  codeStarted?: () => void;
  codePaused?: () => void;
  codeEnded?: () => void;
  reportError?: (error: string) => void;
}

API Methods

loadCode()

Load and compile LootiScript code.

await runtime.loadCode(sourceCode: string): Promise<void>

start()

Start the game loop.

runtime.start(): void

pause()

Pause the game loop.

runtime.pause(): void

resume()

Resume the game loop.

runtime.resume(): void

stop()

Stop the game loop and reset.

runtime.stop(): void

getCanvas()

Get the canvas element.

const canvas = runtime.getCanvas(): HTMLCanvasElement

Architecture

The RuntimeOrchestrator initializes and coordinates:

  1. Screen (@l8b/screen) - 2D/3D rendering
  2. Audio (@l8b/audio) - Sound and music playback
  3. Input (@l8b/input) - Keyboard, mouse, touch, gamepad
  4. Assets - Asset loading and management
  5. Storage (@l8b/io) - Persistent data storage
  6. System - System information and utilities
  7. Scene (@l8b/scene) - Scene and routing management
  8. VM (@l8b/vm) - LootiScript execution
  9. Stdlib (@l8b/stdlib) - Standard library functions

All subsystems are exposed to LootiScript via global objects.

Integration Example

import { RuntimeOrchestrator } from "@l8b/runtime";

class GameEngine {
  private runtime: RuntimeOrchestrator;

  constructor(canvas: HTMLCanvasElement) {
    this.runtime = new RuntimeOrchestrator({
      canvas,
      listener: {
        codeStarted: () => this.onGameStart(),
        codePaused: () => this.onGamePause(),
        codeEnded: () => this.onGameEnd(),
        reportError: (error) => this.onError(error),
      },
    });
  }

  async loadGame(code: string) {
    await this.runtime.loadCode(code);
  }

  start() {
    this.runtime.start();
  }

  pause() {
    this.runtime.pause();
  }

  private onGameStart() {
    console.log("Game started");
  }

  private onGamePause() {
    console.log("Game paused");
  }

  private onGameEnd() {
    console.log("Game ended");
  }

  private onError(error: string) {
    console.error("Game error:", error);
  }
}

// Usage
const canvas = document.getElementById("game-canvas");
const engine = new GameEngine(canvas);

await engine.loadGame(gameCode);
engine.start();

Package Structure

runtime/
├── src/
│   ├── core/
│   │   └── orchestrator.ts    # Main RuntimeOrchestrator
│   ├── assets/
│   │   └── loader.ts           # Asset loading
│   ├── input/
│   │   └── manager.ts          # Input management
│   ├── system/
│   │   └── api.ts              # System API
│   └── types/
│       └── index.ts            # TypeScript types
└── index.ts

See Also

  • @l8b/vm - LootiScript virtual machine
  • @l8b/screen - Rendering system
  • @l8b/audio - Audio system
  • @l8b/input - Input system
  • @l8b/scene - Scene management
  • @l8b/io - Storage and IO
  • @l8b/stdlib - Standard library