Skip to main content

Serializer

Central serialization system for ExcaliburJS Handles all serialization/deserialization with extensible registry

Index

Constructors

constructor

Methods

staticactorFromJSON

  • actorFromJSON(json: string): Actor | null
  • Parameters

    • json: string

    Returns Actor | null

staticactorToJSON

  • actorToJSON(actor: Actor, pretty?: boolean): string
  • Parameters

    • actor: Actor
    • pretty: boolean = false

    Returns string

staticclearComponents

  • clearComponents(): void
  • Clear all registered components


    Returns void

staticclearCustomActors

  • clearCustomActors(): void
  • Returns void

staticclearGraphics

  • clearGraphics(): void
  • Clear all registered graphics


    Returns void

staticdeserializeActor

staticdeserializeComponent

staticdeserializeEntity

staticentityFromJSON

  • entityFromJSON(json: string): Entity<any> | null
  • Deserialize entity from JSON string


    Parameters

    • json: string

    Returns Entity<any> | null

staticentityToJSON

  • entityToJSON(entity: Entity, pretty?: boolean): string
  • Serialize entity to JSON string


    Parameters

    • entity: Entity
    • pretty: boolean = false

    Returns string

staticgetCustomActor

  • getCustomActor(typeName: string): typeof Actor | null
  • Parameters

    • typeName: string

    Returns typeof Actor | null

staticgetCustomSerializer

  • getCustomSerializer(typeName: string): { deserialize: (data: any) => any; serialize: (obj: any) => any } | undefined
  • Parameters

    • typeName: string

    Returns { deserialize: (data: any) => any; serialize: (obj: any) => any } | undefined

staticgetGraphic

  • getGraphic(id: string): any
  • Parameters

    • id: string

    Returns any

staticgetRegisteredComponents

  • getRegisteredComponents(): string[]
  • Get all registered component types


    Returns string[]

staticgetRegisteredCustomActors

  • getRegisteredCustomActors(): string[]
  • Returns string[]

staticgetRegisteredGraphics

  • getRegisteredGraphics(): string[]
  • Get all registered graphic IDs


    Returns string[]

staticgetRegistry

  • getRegistry(registry: components | graphics | actors): Map<string, any>
  • Parameters

    • registry: components | graphics | actors

    Returns Map<string, any>

staticinit

  • init(autoRegisterComponents?: boolean): void
  • Parameters

    • autoRegisterComponents: boolean = true

    Returns void

staticisComponentRegistered

  • isComponentRegistered(typeName: string): boolean
  • Check if a component type is registered


    Parameters

    • typeName: string

    Returns boolean

staticisCustomActorRegistered

  • isCustomActorRegistered(typeName: string): boolean
  • Parameters

    • typeName: string

    Returns boolean

staticisGraphicRegistered

  • isGraphicRegistered(id: string): boolean
  • Check if a graphic is registered


    Parameters

    • id: string

    Returns boolean

staticisInitialized

  • isInitialized(): boolean
  • Returns boolean

staticregisterComponent

staticregisterComponents

staticregisterCustomActor

  • registerCustomActor(ctor: typeof Actor): void
  • Parameters

    Returns void

staticregisterCustomActors

  • registerCustomActors(ctors: typeof Actor[]): void
  • Parameters

    Returns void

staticregisterCustomSerializer

  • registerCustomSerializer(typeName: string, serialize: (obj: any) => any, deserialize: (data: any) => any): void
  • Register a custom serializer for a specific type Useful for types like Vector, Color, BoundingBox, etc.


    Parameters

    • typeName: string
    • serialize: (obj: any) => any
      • deserialize: (data: any) => any

        Returns void

      staticregisterGraphic

      • registerGraphic(id: string, graphic: any): void
      • Parameters

        • id: string
        • graphic: any

        Returns void

      staticregisterGraphics

      • registerGraphics(graphics: Record<string, any>): void
      • Parameters

        • graphics: Record<string, any>

        Returns void

      staticreset

      • reset(): void
      • Reset all registrations (useful for testing)


        Returns void

      staticserializeActor

      staticserializeComponent

      staticserializeEntity

      staticunregisterComponent

      • unregisterComponent(typeName: string): boolean
      • Unregister a component type


        Parameters

        • typeName: string

        Returns boolean

      staticunregisterCustomActor

      • unregisterCustomActor(typeName: string): boolean
      • Parameters

        • typeName: string

        Returns boolean

      staticunregisterGraphic

      • unregisterGraphic(id: string): boolean
      • Unregister a graphic


        Parameters

        • id: string

        Returns boolean

      staticvalidateEntityData

      • Validate entity data structure


        Parameters

        • data: any

        Returns data is EntityData