UNPKG

@hadss/hmrouter-plugin

Version:

HMRouter Compiler Plugin

46 lines (45 loc) 1.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AnnotationAnalyzerRegistry = void 0; const RouterAnalyzer_1 = require("./RouterAnalyzer"); const ComponentAnalyzer_1 = require("./ComponentAnalyzer"); const ConstantResolver_1 = require("./utils/ConstantResolver"); class AnnotationAnalyzerRegistry { constructor() { this.analyzers = new Set(); this.constantResolver = null; } static getInstance() { if (!this.instance) { this.instance = new AnnotationAnalyzerRegistry(); } return this.instance; } initialize(modulePath) { if (this.constantResolver) { return; } this.constantResolver = new ConstantResolver_1.ConstantResolver(modulePath); this.registerDefaultAnalyzers(); } registerAnalyzer(analyzer) { this.analyzers.add(analyzer); } getAnalyzers() { return Array.from(this.analyzers); } getConstantResolver() { if (!this.constantResolver) { throw new Error('AnnotationAnalyzerRegistry not initialized. Call initialize() first.'); } return this.constantResolver; } registerDefaultAnalyzers() { if (!this.constantResolver) { throw new Error('AnnotationAnalyzerRegistry not initialized properly.'); } this.registerAnalyzer(new RouterAnalyzer_1.RouterAnalyzer(this.constantResolver)); this.registerAnalyzer(new ComponentAnalyzer_1.ComponentAnalyzer(this.constantResolver)); } } exports.AnnotationAnalyzerRegistry = AnnotationAnalyzerRegistry;