UNPKG

@pulzar/core

Version:

Next-generation Node.js framework for ultra-fast web applications with zero-reflection DI, GraphQL, WebSockets, events, and edge runtime support

157 lines 3.96 kB
import { CompiledContainer } from "./zero-reflection"; import { Token } from "./tokens"; export interface ASTProviderInfo { token: Token; className: string; filePath: string; dependencies: Token[]; singleton: boolean; scope: "singleton" | "transient" | "request"; } export interface ASTModuleInfo { name: string; filePath: string; providers: ASTProviderInfo[]; imports: ASTModuleImport[]; exports: ASTModuleExport[]; namespace?: string; } export interface ASTModuleImport { module: string; providers?: Token[]; namespace?: string; filePath?: string; } export interface ASTModuleExport { token: Token; name?: string; reExport?: boolean; fromModule?: string; } export interface CompilationResult { providers: ASTProviderInfo[]; modules: ASTModuleInfo[]; container: CompiledContainer; generatedCode: string; } export declare class ASTDependencyCompiler { private project; private providers; private modules; private sourceRoot; constructor(tsConfigPath?: string, sourceRoot?: string); /** * Scan project files for DI metadata */ scanProject(): Promise<void>; /** * Incremental scan of specific files for watch mode */ incrementalScan(filePaths: string[]): Promise<void>; /** * Clear cached data for a specific file */ private clearFileData; /** * Scan specific source file */ private scanSourceFile; /** * Extract provider information from class declaration */ private extractProviderInfo; /** * Extract module information from source file */ private extractModuleInfo; /** * Resolve providers from module options */ private resolveProvidersFromOptions; /** * Parse module imports */ private parseModuleImports; /** * Parse module exports */ private parseModuleExports; /** * Find decorator by name */ private findDecorator; /** * Parse decorator arguments using ts-morph AST - no eval() or regex */ private parseDecoratorArguments; /** * Parse object literal using ts-morph AST (safe, no eval!) */ private parseObjectLiteralAST; /** * Parse token value (string, symbol, or identifier) */ private parseTokenValue; /** * Parse boolean value */ private parseBooleanValue; /** * Parse string value */ private parseStringValue; /** * Parse array value */ private parseArrayValue; /** * Parse literal value (string, number, boolean, identifier) */ private parseLiteralValue; /** * Extract constructor dependencies */ private extractDependencies; /** * Extract token from @Inject decorator */ private extractInjectToken; /** * Compile to DI container with validation */ compile(): CompilationResult; /** * Validate module imports and exports */ private validateModules; /** * Validate dependencies and scope rules */ private validateDependencies; /** * Check for circular dependencies */ private hasCircularDependency; /** * Check if token is built-in (framework provided) */ private isBuiltInToken; /** * Generate ESM-safe runtime code for the compiled container */ private generateRuntimeCode; /** * Convert file path to ESM-compatible path with .js extension */ private convertToESMPath; /** * Get relative import path with proper ESM handling */ private getRelativeImportPath; /** * Save generated code to file */ saveGeneratedCode(outputPath: string, result: CompilationResult): Promise<void>; } export declare function createASTCompiler(tsConfigPath?: string, sourceRoot?: string): ASTDependencyCompiler; //# sourceMappingURL=ast-compiler.d.ts.map