ComponentDef
Defined in: src/component-store.ts:10
Schema definition for a component type — handles serialization, optional dependency declarations, and optional schema evolution.
Type Parameters
Section titled “Type Parameters”T
Properties
Section titled “Properties”columns?
Section titled “columns?”
readonlyoptionalcolumns?: readonlyColumnField[]
Defined in: src/component-store.ts:26
When present, the component is all-numeric and stored columnar
(Structure-of-Arrays): one typed-array column per field, each with its own
element kind. Set automatically by simpleComponent when every
schema field is numeric. world.registerComponent uses it to pick a
columnar ColumnStore over the object-backed ComponentStore. Never
set for components with a boolean / string field or a hand-written
serialize / deserialize.
Per-field precision is explicit via NumericColumnKind: 'number'
is f64 (lossless, the safe default — entity-id refs and large counters
stay exact), and a hot spatial field opts into 'f32' for half-size,
cache-friendlier storage.
deserialize
Section titled “deserialize”deserialize: (
raw,label) =>T
Defined in: src/component-store.ts:45
Parameters
Section titled “Parameters”unknown
string
Returns
Section titled “Returns”T
migrations?
Section titled “migrations?”
readonlyoptionalmigrations?:Readonly<Record<number,ComponentMigration>>
Defined in: src/component-store.ts:36
Per-version upgrade functions. migrations[n] transforms a raw value
serialized at version n into the shape expected at version n + 1.
The chain runs from the saved version up to def.version before the
final deserialize.
A save written with no version info (legacy array shape) is treated as
version 0, so migrations[0], migrations[1], … are applied in order.
readonlyname:string
Defined in: src/component-store.ts:11
requires?
Section titled “requires?”
readonlyoptionalrequires?: readonlystring[]
Defined in: src/component-store.ts:38
Other component names that must be present on the same entity.
serialize
Section titled “serialize”serialize: (
value) =>unknown
Defined in: src/component-store.ts:46
Parameters
Section titled “Parameters”T
Returns
Section titled “Returns”unknown
version?
Section titled “version?”
readonlyoptionalversion?:number
Defined in: src/component-store.ts:44
Current schema version of this component. Defaults to 0 (unversioned).
When > 0, ComponentStore.toSerialized wraps the payload with
{ version, entries } so loaders know which migrations to apply.