Skip to content

@idlekitjs/core

Headless engine primitives for IdleKit games: engine creation, state, simulation, events, saves, numbers, randomness and formatting.

What it provides

  • createEngine and Engine for the runtime orchestrator.
  • SimulationLoop, manualScheduler and frame scheduler contracts.
  • ReactiveStore and dirty-key tracking for state changes.
  • EventBus and engine events such as loaded and resume.
  • SaveManager and save/load orchestration.
  • Decimal, D, seeded Random, createRandom and formatting helpers.
  • Re-exported engine contracts from @idlekitjs/types.

When to use it

Use @idlekitjs/core in every IdleKit game or headless simulation. It is the lowest runtime layer: systems, extensions, save managers and tests all build around the engine. Browser frames, DOM rendering, gameplay mechanics and storage backends are injected from other packages.

Basic usage

ts
import { createEngine, manualScheduler } from "@idlekitjs/core";

interface State {
  coins: number;
}

const scheduler = manualScheduler();
const engine = createEngine<State>({
  initialState: { coins: 0 },
  scheduler,
});

engine.addSystem((state, dt) => {
  state.coins += dt;
});

engine.start();
scheduler.frame(1000);
console.log(engine.state.coins);

Boundaries

@idlekitjs/core has no DOM, browser, gameplay or concrete storage dependency. It defines and consumes contracts; other packages implement those contracts:

Types owned by other packages are imported from those packages. Core re-exports only engine-level contracts such as Extension, EngineContext, System, SaveAdapter and EngineEvents.