@zylem/behaviors
v0.5.8
Published
Tree-shakable Zylem behavior descriptors, systems, coordinators, and runtime-agnostic behavior helpers.
Readme
Zylem Behaviors
The simulation layer of the Zylem framework: tree-shakable behavior descriptors, FSMs, coordinators, and the Simulation API that owns the @zylem/runtime WASM module (ECS + Rapier physics).
@zylem/behaviors sits between the game framework and the runtime:
@zylem/game-lib → @zylem/behaviors → @zylem/runtime (WASM)createSimulation()/Simulation— loads and owns the WASM stage, exposesspawn/despawnwith opaqueEntityHandles, a fixed-timestepupdate(delta)loop, snapshot/pose accessors, raycasts, debug rendering, and translatedSimulationEvents (collision start/stop with handles instead of raw slots).- Behavior descriptors (
Platformer3DBehavior,TopDownMovementBehavior, …) — attach WASM-side controllers to entities and forward per-frame input through slot-indexed buffers; FSM state is read back from snapshots. MockBehaviorRuntime— in-memoryBehaviorRuntimeimplementation for unit-testing behaviors without loading WASM.
Physics simulation is WASM-only; there is no TypeScript physics fallback. Disposal chains downward: Simulation.dispose() destroys the WASM stage.
Use per-behavior entrypoints when you want bundlers to pull only the behavior family you import:
import { ScreenWrapBehavior } from '@zylem/behaviors/screen-wrap';
import { CooldownBehavior } from '@zylem/behaviors/cooldown';The package is ESM-only and declares sideEffects: false.
Requirements
- Node >= 22.12.0
- pnpm >= 10.32.1
Commands
pnpm install
pnpm build
pnpm typecheck
pnpm test