Appearance
@idlekitjs/plugins
Engine-level policies and reusable extensions such as autosave and offline progress.
What it provides
autosaveandSaveSchedulerfrom@idlekitjs/plugins/autosave.offlineProgressfrom@idlekitjs/plugins/offline-progress.
Both factories return Extension<T> values installable with engine.use(...).
When to use it
Use @idlekitjs/plugins for operational behavior around the engine: saving on a schedule, saving during browser lifecycle events, and crediting capped offline time on load or resume. Use mechanics for gameplay rules.
Basic usage
ts
import { SaveManager } from "@idlekitjs/core";
import { pageLifecycle } from "@idlekitjs/browser/page-lifecycle";
import { autosave } from "@idlekitjs/plugins/autosave";
import { offlineProgress } from "@idlekitjs/plugins/offline-progress";
import { LocalStorageAdapter } from "@idlekitjs/storage/local-storage";
const save = new SaveManager<State>({
key: "my-game",
version: 1,
adapter: new LocalStorageAdapter(),
});
engine.use(pageLifecycle());
engine.use(offlineProgress({ maxMs: 8 * 60 * 60 * 1000 }));
engine.use(autosave({ manager: save, getState: () => engine.state, intervalMs: 15_000 }));Boundaries
Plugins are engine policies. Removing a plugin should not change the rules of the game, only the operational experience around it.
offlineProgress consumes engine events and advances the engine by capped elapsed time. autosave drives a SaveManager and includes browser lifecycle triggers (visibilitychange and pagehide) in its current implementation, so it is intended for browser games. Generic browser bridges live in @idlekitjs/browser, not in plugins.