Files
ecs-observable/src/serialization.ts
T
hypercross cd6350e0b1 feat: add support for data-carrying relationships
Introduce the ability to attach optional data payloads to
relationships. This includes:

- Updating `defineRelationship` to accept default values.
- Adding `getRelData` and `setRelData` to the `World` class.
- Allowing `relate` to accept an optional data override.
- Updating serialization to include relationship data in snapshots.
- Implementing lazy storage for relationship data using `SparseSet`.
2026-06-02 17:56:12 +08:00

14 lines
462 B
TypeScript

/**
* Plain JSON-compatible representation of a World.
* Returned by `world.toJSON()`, consumed by `World.fromJSON()`.
*/
export interface WorldSnapshot {
/** Entity stable ID → component map (component name → data). */
entities: Record<string, Record<string, unknown>>;
/** Relationship name → (source ID → target ID or edge object). */
relationships: Record<
string,
Record<string, string | { target: string; data: unknown }>
>;
}