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. This class 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
class_names
type Array<string>
all
type Map<Uuid, Cell>
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
ClassConstructor<Cell<ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>>>voidunregister
Unregister a cell class from the registry.
type (class_name: string): boolean
class_name
stringbooleanmaybe_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
Kjson?
(CellRegistryMap[K] extends Cell<infer TSchema extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>> ? input<TSchema> : never) | undefinedoptions?
object | undefinedCellRegistryMap[K] | nullinstantiate
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
Kjson?
(CellRegistryMap[K] extends Cell<infer TSchema extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>> ? input<TSchema> : never) | undefinedoptions?
object | undefinedCellRegistryMap[K]add_cell
type (cell: Cell<any>): void
cell
Cell<any>voidremove_cell
type (id: string & $brand<"Uuid">): void
id
string & $brand<"Uuid">void