* ExportManager - Plugin registry center for the export feature * * Manages registration and retrieval of: * - Source plugins (data sources like messages, text snippets, etc.) * - Format plugins (output formats like markdown, html, png, etc.) * - Previewer plugins (preview components for differ
| 21 | * - Editor plugins (edit components for different formats) |
| 22 | */ |
| 23 | class ExportManager { |
| 24 | private sources = new Map<SourceType, SourcePlugin>() |
| 25 | private formats = new Map<FormatType, FormatPlugin>() |
| 26 | private previewers: PreviewerPlugin[] = [] |
| 27 | private editors: EditorPlugin[] = [] |
| 28 | |
| 29 | // ==================== Registration Methods ==================== |
| 30 | |
| 31 | /** |
| 32 | * Register a source plugin |
| 33 | */ |
| 34 | registerSource<T extends SourceData>(plugin: SourcePlugin<T>): void { |
| 35 | this.sources.set(plugin.id, plugin as unknown as SourcePlugin) |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Register a format plugin |
| 40 | */ |
| 41 | registerFormat(plugin: FormatPlugin): void { |
| 42 | this.formats.set(plugin.id, plugin) |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Register a previewer plugin |
| 47 | */ |
| 48 | registerPreviewer(plugin: PreviewerPlugin): void { |
| 49 | // Remove existing previewer with same id if exists |
| 50 | this.previewers = this.previewers.filter((p) => p.id !== plugin.id) |
| 51 | this.previewers.push(plugin) |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Register an editor plugin |
| 56 | */ |
| 57 | registerEditor(plugin: EditorPlugin): void { |
| 58 | // Remove existing editor with same id if exists |
| 59 | this.editors = this.editors.filter((e) => e.id !== plugin.id) |
| 60 | this.editors.push(plugin) |
| 61 | } |
| 62 | |
| 63 | // ==================== Query Methods ==================== |
| 64 | |
| 65 | /** |
| 66 | * Get a source plugin by type |
| 67 | */ |
| 68 | getSource<T extends SourceData>(type: SourceType): SourcePlugin<T> | undefined { |
| 69 | return this.sources.get(type) as SourcePlugin<T> | undefined |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Get all registered source plugins |
| 74 | */ |
| 75 | getAllSources(): SourcePlugin[] { |
| 76 | return Array.from(this.sources.values()) |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Get a format plugin by type |
nothing calls this directly
no outgoing calls
no test coverage detected