@smartsoft001/angular 2.98.0 → 2.99.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.
@@ -455,21 +455,33 @@ class DynamicComponentStorageService {
455
455
  const getComponents = (k, m) => {
456
456
  if (!m)
457
457
  return [];
458
- const fromStore = m.injector.get(DYNAMIC_COMPONENTS_STORE, null);
459
- return (fromStore ? fromStore : m.instance.constructor['ɵmod'].declarations).filter((c) => c['smartType'] === k);
458
+ try {
459
+ const fromStore = m.injector.get(DYNAMIC_COMPONENTS_STORE, null);
460
+ if (fromStore) {
461
+ return fromStore.filter((c) => c['smartType'] === k);
462
+ }
463
+ }
464
+ catch (error) {
465
+ console.warn('Error getting components from store:', error);
466
+ }
467
+ return [];
460
468
  };
461
469
  let components = getComponents(key, moduleRef);
462
470
  if (!components.length && moduleRef) {
463
- const applicationRef = moduleRef.injector.get(ApplicationRef);
464
- let appComponentInjector = applicationRef.components.find((t) => t.componentType.name === 'AppComponent')?.injector;
465
- if (!appComponentInjector) {
466
- appComponentInjector = applicationRef.components[0]?.injector;
471
+ try {
472
+ const applicationRef = moduleRef.injector.get(ApplicationRef);
473
+ let appComponentInjector = applicationRef.components.find((t) => t.componentType.name === 'AppComponent')?.injector;
474
+ if (!appComponentInjector) {
475
+ appComponentInjector = applicationRef.components[0]?.injector;
476
+ }
477
+ if (appComponentInjector) {
478
+ const appModuleRef = appComponentInjector.get(NgModuleRef);
479
+ components = getComponents(key, appModuleRef);
480
+ }
467
481
  }
468
- if (!appComponentInjector) {
469
- return [];
482
+ catch (error) {
483
+ console.warn('Error getting components from ApplicationRef:', error);
470
484
  }
471
- const appModuleRef = appComponentInjector.get(NgModuleRef);
472
- components = getComponents(key, appModuleRef);
473
485
  }
474
486
  return components;
475
487
  }