@wolkabout/commons 0.0.39 → 0.0.40
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.
|
@@ -66,7 +66,7 @@ import * as i32 from '@angular/cdk/drag-drop';
|
|
|
66
66
|
import { DragDropModule } from '@angular/cdk/drag-drop';
|
|
67
67
|
import * as i0 from '@angular/core';
|
|
68
68
|
import { NgModule, InjectionToken, inject, Injectable, Injector, runInInjectionContext, DOCUMENT, Inject, Input, Directive, forwardRef, HostListener, TemplateRef, PLATFORM_ID, Pipe, ViewChild, ContentChild, Optional, Self, Component, input, computed, untracked, signal, viewChild, afterNextRender, effect, output, afterRenderEffect, contentChild } from '@angular/core';
|
|
69
|
-
import { BehaviorSubject, catchError, of, switchMap, EMPTY, tap, filter, map, combineLatestWith, from, distinctUntilChanged, shareReplay, merge, Subject, takeUntil, combineLatest, take, first } from 'rxjs';
|
|
69
|
+
import { BehaviorSubject, catchError, of, switchMap, EMPTY, tap, filter, map, combineLatestWith, forkJoin, from, distinctUntilChanged, shareReplay, merge, Subject, takeUntil, combineLatest, take, first } from 'rxjs';
|
|
70
70
|
import { jwtDecode } from 'jwt-decode';
|
|
71
71
|
import { loadRemoteModule } from '@angular-architects/native-federation';
|
|
72
72
|
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
|
|
@@ -513,46 +513,36 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
|
|
|
513
513
|
|
|
514
514
|
class FeatureRegistry {
|
|
515
515
|
injector = inject(Injector);
|
|
516
|
-
|
|
516
|
+
loadedFeatures = [];
|
|
517
517
|
_features$ = new BehaviorSubject([]);
|
|
518
|
-
expectedFeatures = null;
|
|
519
518
|
/**
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
* If this isn't set, the registration of the feature will output values every time.
|
|
519
|
+
* Call when deploying a standalone app or when there are no external modules to load.
|
|
520
|
+
* Immediately emits the currently registered features.
|
|
523
521
|
*/
|
|
524
|
-
|
|
525
|
-
this.
|
|
522
|
+
noExternalModules() {
|
|
523
|
+
this._features$.next([...this.loadedFeatures]);
|
|
526
524
|
}
|
|
525
|
+
/**
|
|
526
|
+
* Call when deploying a host application.
|
|
527
|
+
* Emits the registered features once all external modules loaded (successfully or unsuccessfully).
|
|
528
|
+
*/
|
|
527
529
|
loadExternalFeatures(features) {
|
|
528
|
-
features.
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
530
|
+
forkJoin(features.map((feature) => from(loadRemoteModule(feature.remote, feature.feature)).pipe(map(module => module.default), catchError((error) => {
|
|
531
|
+
console.warn("Unable to load: ", feature.remote + '/' + feature.feature, error);
|
|
532
|
+
return of(null);
|
|
533
|
+
})))).subscribe((results) => {
|
|
534
|
+
results.forEach((feature) => {
|
|
533
535
|
if (feature) {
|
|
534
536
|
this.registerFeature(feature);
|
|
535
537
|
}
|
|
536
|
-
else {
|
|
537
|
-
this.features.push(null);
|
|
538
|
-
}
|
|
539
538
|
});
|
|
539
|
+
this._features$.next([...this.loadedFeatures]);
|
|
540
540
|
});
|
|
541
541
|
}
|
|
542
542
|
registerFeature(feature) {
|
|
543
|
-
this.
|
|
543
|
+
this.loadedFeatures.push(feature);
|
|
544
544
|
runInInjectionContext(this.injector, () => feature.init?.());
|
|
545
545
|
console.info('Loaded feature: ', feature.name);
|
|
546
|
-
this.finalizeLoading();
|
|
547
|
-
}
|
|
548
|
-
finalizeLoading() {
|
|
549
|
-
const loadedFeatures = this.features.filter((feature) => !!feature);
|
|
550
|
-
if (!this.expectedFeatures) {
|
|
551
|
-
this._features$.next(loadedFeatures);
|
|
552
|
-
}
|
|
553
|
-
else if (this.features.length === this.expectedFeatures) {
|
|
554
|
-
this._features$.next(loadedFeatures);
|
|
555
|
-
}
|
|
556
546
|
}
|
|
557
547
|
get features$() {
|
|
558
548
|
return this._features$.asObservable();
|