Appearance
@idlekitjs/core
Headless engine primitives for IdleKit games: engine creation, state, simulation, events, saves, numbers, randomness and formatting.
What it provides
createEngineandEnginefor the runtime orchestrator.SimulationLoop,manualSchedulerand frame scheduler contracts.ReactiveStoreand dirty-key tracking for state changes.EventBusand engine events such asloadedandresume.SaveManagerand save/load orchestration.Decimal,D, seededRandom,createRandomand 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:
- rendering lives in
@idlekitjs/dom; - browser frame/lifecycle bridges live in
@idlekitjs/browser; - resources and transactions live in
@idlekitjs/economy; - gameplay primitives live in
@idlekitjs/mechanics; - concrete save adapters live in
@idlekitjs/storage; - operational extensions live in
@idlekitjs/plugins.
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.