Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/LiveSplit/livesplit-core/llms.txt

Use this file to discover all available pages before exploring further.

livesplit-core supports two JavaScript delivery modes:
ModeFileEntry pointTarget
Node.jscapi/bindings/node/livesplit_core.js (+ .ts)FFI to native .so/.dll/.dylibServer-side Node.js
WebAssemblycapi/bindings/wasm_bindgen/WASM moduleBrowsers, Deno, Node.js
Both modes expose the same high-level class API. The generated files include a .js version (with JSDoc comments) and a .ts version with full TypeScript type declarations.

Overview

The Node.js binding uses FFI to load the native livesplit_core shared library at runtime. The generated livesplit_core.js / livesplit_core.ts files declare every function using FFI type descriptors such as 'pointer', 'uint32', and 'CString'.

npm package

The binding is published as the livesplit-core npm package.

Class structure

Each livesplit-core type has three classes:
  • TimerRef — shared borrow; exposes read-only methods
  • TimerRefMut extends TimerRef — mutable borrow; exposes mutating methods
  • Timer extends TimerRefMut — owned; adds dispose() which calls the native drop function
Calling dispose() on an owned object sets the internal ptr to null and calls the native drop function. Any subsequent call on the disposed object throws "{name} is disposed".

Naming conventions

Rust method names are converted to lowerCamelCase. Nullable factory methods return T | null. The method new (when nullable in Rust) stays as new in JavaScript since it is a valid static method name.

TypeScript example

import * as LiveSplitCore from 'livesplit-core';

// Run_new is non-nullable → static new() returns Run (never null)
const run = LiveSplitCore.Run.new();
run.setGameName('Sonic Mania');
run.setCategoryName('Mania Mode');
run.pushSegment(LiveSplitCore.Segment.new('Green Hill Zone'));

// Timer_new is nullable → static new() returns Timer | null
const timer = LiveSplitCore.Timer.new(run)!;
timer.start();
timer.split();
timer.reset(true); // true = update splits

// Free native memory
timer.dispose();

JavaScript example

const LiveSplitCore = require('livesplit-core');

const run = LiveSplitCore.Run.new();
run.setGameName('Sonic Mania');
run.setCategoryName('Mania Mode');
run.pushSegment(LiveSplitCore.Segment.new('Green Hill Zone'));

const timer = LiveSplitCore.Timer.new(run);
if (!timer) throw new Error('Run must have at least one segment');

timer.start();
timer.split();
timer.reset(true);
timer.dispose();

Build docs developers (and LLMs) love