17 lines
		
	
	
		
			449 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
		
		
			
		
	
	
			17 lines
		
	
	
		
			449 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
|  | import type { IBlockHandler } from './block.base.js'; | ||
|  | 
 | ||
|  | export class BlockRegistry { | ||
|  |   private static handlers = new Map<string, IBlockHandler>(); | ||
|  |    | ||
|  |   static register(type: string, handler: IBlockHandler): void { | ||
|  |     this.handlers.set(type, handler); | ||
|  |   } | ||
|  |    | ||
|  |   static getHandler(type: string): IBlockHandler | undefined { | ||
|  |     return this.handlers.get(type); | ||
|  |   } | ||
|  |    | ||
|  |   static getAllTypes(): string[] { | ||
|  |     return Array.from(this.handlers.keys()); | ||
|  |   } | ||
|  | } |