@@ -111,6 +111,7 @@ export interface VersionCompatibility {
111111 */
112112export class PluginLoader {
113113 private logger : Logger ;
114+ private context ?: PluginContext ;
114115 private loadedPlugins : Map < string , PluginMetadata > = new Map ( ) ;
115116 private serviceFactories : Map < string , ServiceRegistration > = new Map ( ) ;
116117 private serviceInstances : Map < string , any > = new Map ( ) ;
@@ -120,6 +121,20 @@ export class PluginLoader {
120121 this . logger = logger ;
121122 }
122123
124+ /**
125+ * Set the plugin context for service factories
126+ */
127+ setContext ( context : PluginContext ) : void {
128+ this . context = context ;
129+ }
130+
131+ /**
132+ * Get a synchronous service instance if it exists (Sync Helper)
133+ */
134+ getServiceInstance < T > ( name : string ) : T | undefined {
135+ return this . serviceInstances . get ( name ) as T ;
136+ }
137+
123138 /**
124139 * Load a plugin asynchronously with validation
125140 */
@@ -431,9 +446,9 @@ export class PluginLoader {
431446 }
432447
433448 private async createServiceInstance ( registration : ServiceRegistration ) : Promise < any > {
434- // This is a simplified version - in real implementation,
435- // we would need to pass proper context with resolved dependencies
436- const mockContext = { } as PluginContext ;
437- return await registration . factory ( mockContext ) ;
449+ if ( ! this . context ) {
450+ throw new Error ( `[PluginLoader] Context not set - cannot create service ' ${ registration . name } '` ) ;
451+ }
452+ return await registration . factory ( this . context ) ;
438453 }
439454}
0 commit comments