@opensourcekd/ng-common-libs 1.2.7 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -82,8 +82,24 @@ declare const APP_CONFIG: {
82
82
  * This service is designed for MicroFrontend architectures where different apps need to communicate
83
83
  * The ReplaySubject keeps last 100 events in memory for late subscribers
84
84
  *
85
+ * **IMPORTANT for Module Federation / MicroFrontends:**
86
+ * This service uses a module-level singleton to ensure ONE instance across all MFEs and shell.
87
+ * Before using `inject(EventBusService)` in components, you must provide it at application level:
88
+ *
85
89
  * @example
86
90
  * ```typescript
91
+ * // In app.config.ts (standalone) or app.module.ts (NgModule)
92
+ * import { EventBusService, getEventBusService } from '@opensourcekd/ng-common-libs';
93
+ *
94
+ * export const appConfig: ApplicationConfig = {
95
+ * providers: [
96
+ * { provide: EventBusService, useFactory: getEventBusService }
97
+ * ]
98
+ * };
99
+ * ```
100
+ *
101
+ * Then use in components:
102
+ * ```typescript
87
103
  * import { Component, inject, OnInit } from '@angular/core';
88
104
  * import { EventBusService } from '@opensourcekd/ng-common-libs';
89
105
  *
@@ -148,6 +164,25 @@ declare class EventBusService {
148
164
  */
149
165
  sendEvent(s: string): void;
150
166
  }
167
+ /**
168
+ * Factory function to get the singleton EventBusService instance
169
+ * Use this in your application providers to ensure singleton behavior across MFEs
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * // In app.config.ts or app.module.ts
174
+ * import { EventBusService, getEventBusService } from '@opensourcekd/ng-common-libs';
175
+ *
176
+ * export const appConfig: ApplicationConfig = {
177
+ * providers: [
178
+ * { provide: EventBusService, useFactory: getEventBusService }
179
+ * ]
180
+ * };
181
+ * ```
182
+ *
183
+ * @returns The singleton EventBusService instance
184
+ */
185
+ declare function getEventBusService(): EventBusService;
151
186
 
152
187
  /**
153
188
  * User information from ID token
@@ -189,6 +224,23 @@ interface UserData {
189
224
  *
190
225
  * Configuration is centralized in config/auth.config.ts for easy management
191
226
  *
227
+ * **IMPORTANT for Module Federation / MicroFrontends:**
228
+ * This service uses a module-level singleton to ensure ONE instance across all MFEs and shell.
229
+ * Before using `inject(AuthService)` in components, you must provide it at application level:
230
+ *
231
+ * @example
232
+ * ```typescript
233
+ * // In app.config.ts (standalone) or app.module.ts (NgModule)
234
+ * import { AuthService, getAuthService, EventBusService, getEventBusService } from '@opensourcekd/ng-common-libs';
235
+ *
236
+ * export const appConfig: ApplicationConfig = {
237
+ * providers: [
238
+ * { provide: EventBusService, useFactory: getEventBusService },
239
+ * { provide: AuthService, useFactory: getAuthService }
240
+ * ]
241
+ * };
242
+ * ```
243
+ *
192
244
  * NOTE: All navigation logic using setTimeout is commented out as per requirements.
193
245
  * To enable navigation after auth operations, uncomment the marked sections in consuming components.
194
246
  */
@@ -346,6 +398,28 @@ declare class AuthService {
346
398
  */
347
399
  private emitAuthEvent;
348
400
  }
401
+ /**
402
+ * Factory function to get the singleton AuthService instance
403
+ * Use this in your application providers to ensure singleton behavior across MFEs
404
+ *
405
+ * Lazy initialization ensures Auth0 can be configured before service creation
406
+ *
407
+ * @example
408
+ * ```typescript
409
+ * // In app.config.ts or app.module.ts
410
+ * import { AuthService, getAuthService, EventBusService, getEventBusService } from '@opensourcekd/ng-common-libs';
411
+ *
412
+ * export const appConfig: ApplicationConfig = {
413
+ * providers: [
414
+ * { provide: EventBusService, useFactory: getEventBusService },
415
+ * { provide: AuthService, useFactory: getAuthService }
416
+ * ]
417
+ * };
418
+ * ```
419
+ *
420
+ * @returns The singleton AuthService instance
421
+ */
422
+ declare function getAuthService(): AuthService;
349
423
 
350
424
  /**
351
425
  * Auth0 Configuration
@@ -439,5 +513,5 @@ declare function removeStorageItem(key: string, storageType?: 'localStorage' | '
439
513
  */
440
514
  declare function configureAuth0(config: Partial<typeof AUTH0_CONFIG>): void;
441
515
 
442
- export { APP_CONFIG, AUTH0_CONFIG, AuthService, EventBus, EventBusService, STORAGE_CONFIG, STORAGE_KEYS, configureAuth0, getStorageItem, removeStorageItem, setStorageItem };
516
+ export { APP_CONFIG, AUTH0_CONFIG, AuthService, EventBus, EventBusService, STORAGE_CONFIG, STORAGE_KEYS, configureAuth0, getAuthService, getEventBusService, getStorageItem, removeStorageItem, setStorageItem };
443
517
  export type { EventPayload, UserData, UserInfo };