import { visTypeAliasRegistry , VisTypeAlias } from './vis_type_alias_registry' ; import { BaseVisType } from './base_vis_type' ; import { VisTypeDefinition } from './types' ; import { VisGroups } from './vis_groups_enum' ; internal export class TypesService { private types : Record < string , BaseVisType < any > > = { } ; private unregisteredHiddenTypes : string [ ] = [ ] ; private registerVisualization < TVisParam > ( visDefinition ) { if ( this . unregisteredHiddenTypes . includes ( visDefinition . name ) ) { visDefinition . hidden = true ; } if ( this . types [ visDefinition . name ] ) { throw new Error ( 'type already exists!' ) ; } this . types [ visDefinition . name ] = visDefinition ; } public setup ( ) { return { param config createBaseVisualization : < TVisParams > ( config ) : void => { const vis = new BaseVisType ( config ) ; this . registerVisualization ( vis ) ; } , param { VisTypeAlias } config registerAlias : visTypeAliasRegistry . add , param { string [ ] } typeNames hideTypes : ( typeNames ) : void => { typeNames . forEach ( ( name ) => { if ( this . types [ name ] ) { this . types [ name ] . hidden = true ; } else { this . unregisteredHiddenTypes . push ( name ) ; } } ) ; } , } ; } public start ( ) { return { param { string } visualization get : < TVisParams > ( visualization ) : BaseVisType < TVisParams > | undefined => { return this . types [ visualization ] ; } , /**
             * returns all registered visualization types
             */ all : ( ) : BaseVisType [ ] => { return [ ... Object . values ( this . types ) ] ; } , /**
             * returns all registered aliases
             */ getAliases : visTypeAliasRegistry . get , param { string } visTypeAliasName unRegisterAlias : visTypeAliasRegistry . remove , param { VisGroups } group getByGroup : ( group ) => { return Object . values ( this . types ) . filter ( ( type ) => { return type . group === group ; } ) ; } , } ; } public stop ( ) { } } internal export type TypesSetup = ReturnType < TypesService [ 'setup' ] > ; export type TypesStart = ReturnType < TypesService [ 'start' ] > ; public export type { VisTypeAlias } ;