cell_registry.svelte.ts

Declarations
#

2 declarations

view source

CellRegistry
#

cell_registry.svelte.ts view source

Registry for managing cell classes and their instances. The goal is to allow dynamic instantiation of all cells from serializable JSON. CellRegistry does not currently justify its weight/complexity and may be removed in the future, but I want to continue exploring the ideas behind it until we get fully snapshottable UI.

app

type Frontend

readonly

class_names

type Array<string>

readonly

all

type Map<Uuid, Cell>

readonly

constructor

type new (app: Frontend): CellRegistry

app

register

Register a cell class with the registry.

type (constructor: ClassConstructor<Cell<ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>>>): void

constructor
type ClassConstructor<Cell<ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>>>
returns void

unregister

Unregister a cell class from the registry.

type (class_name: string): boolean

class_name
type string
returns boolean

maybe_instantiate

Attempt to instantiate a class, returning null if not found. Logs an error in development if the class isn't registered.

type <K extends keyof CellRegistryMap>(class_name: K, json?: (CellRegistryMap[K] extends Cell<infer TSchema extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>> ? input<...> : never) | undefined, options?: object | undefined): CellRegistryMap[K] | null

class_name
type K
json?
type (CellRegistryMap[K] extends Cell<infer TSchema extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>> ? input<TSchema> : never) | undefined
optional
options?
type object | undefined
optional
returns CellRegistryMap[K] | null

instantiate

Create an instance of a registered cell class by name. Throws if the class isn't found.

Type is automatically inferred from class name literals.

type <K extends keyof CellRegistryMap>(class_name: K, json?: (CellRegistryMap[K] extends Cell<infer TSchema extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>> ? input<...> : never) | undefined, options?: object | undefined): CellRegistryMap[K]

class_name
type K
json?
type (CellRegistryMap[K] extends Cell<infer TSchema extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>> ? input<TSchema> : never) | undefined
optional
options?
type object | undefined
optional
returns CellRegistryMap[K]

add_cell

type (cell: Cell<any>): void

cell
type Cell<any>
returns void

remove_cell

type (id: string & $brand<"Uuid">): void

id
type string & $brand<"Uuid">
returns void

ClassNotRegisteredError
#

cell_registry.svelte.ts view source

Error thrown when attempting to instantiate an unregistered class.

inheritance

extends:
  • Error

class_name

type string

readonly

available_classes

type Array<string>

readonly

constructor

type new (class_name: string, available_classes: string[], options?: ErrorOptions | undefined): ClassNotRegisteredError

class_name
type string
available_classes
type string[]
options?
type ErrorOptions | undefined
optional

Imported by
#