Documentation
    Preparing search index...

    Class ComponentSerializerRegistry

    The per-type component serializers a document is read and written with (§79, §81).

    Keyed by the component class's typeName; iteration — and therefore the order components appear in a document — is registration order.

    const registry = createDefaultComponentSerializers();
    registry.register(RigidBody, {
    serialize: (body) => ({ kind: body.kind }),
    deserialize: (data) => new RigidBody(readKind(data)),
    });
    Index
    • Registers serializer for the component class type, keyed by its typeName (§6a, §79). Returns this so registrations chain.

      Type Parameters

      Parameters

      Returns this

      FourError INVALID_APPLICATION_STATE if the class carries no typeName, or if that name is already registered — a silent overwrite would make the shape of a document depend on module evaluation order. Build a fresh registry to serialize a type differently.

    • The document entries for the components attached to node, in registration order (§6a, §79).

      Every attached component is accounted for: the walk is over node.components (2026-08-06, A-15), so a component whose type this registry does not know is seen rather than silently missed, and unknownComponents decides what happens to it. Emission then runs over the registry, which is what keeps the output order independent of the order the components were attached in.

      Parameters

      • node: Node

        the node whose components to write

      • unknownComponents: UnknownComponentPolicy = "throw"

        "throw" (the default) refuses an unserializable component; "skip" drops it

      Returns ComponentDocument[]

      FourError INVALID_APPLICATION_STATE for a component with no registered serializer, or one whose class carries no typeName (plan D2), under the default policy