@o3r/components 11.6.0-prerelease.21 → 11.6.0-prerelease.23

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.
@@ -1,7 +1,8 @@
1
- import { of, from, observeOn, animationFrameScheduler, BehaviorSubject, Subscription, firstValueFrom, fromEvent, Subject, ReplaySubject, sample } from 'rxjs';
1
+ import { of, from, observeOn, animationFrameScheduler, BehaviorSubject, firstValueFrom, fromEvent, Subject, ReplaySubject, sample } from 'rxjs';
2
2
  import { mergeMap, bufferCount, concatMap, delay, scan, tap, filter, distinctUntilChanged, map, mapTo, switchMap } from 'rxjs/operators';
3
3
  import * as i0 from '@angular/core';
4
- import { InjectionToken, NgModule, Injectable, Optional, Inject, SimpleChange, forwardRef, Directive, Input, Pipe, Component, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';
4
+ import { InjectionToken, NgModule, inject, DestroyRef, Injectable, Optional, Inject, SimpleChange, forwardRef, Directive, Input, Pipe, Component, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';
5
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
5
6
  import * as i1 from '@ngrx/store';
6
7
  import { createAction, props, on, createReducer, StoreModule, createFeatureSelector, createSelector } from '@ngrx/store';
7
8
  import { asyncProps, createEntityAsyncRequestAdapter, asyncStoreItemAdapter, asyncEntitySerializer, otterComponentInfoPropertyName, sendOtterMessage, filterMessageContent } from '@o3r/core';
@@ -651,8 +652,8 @@ class ComponentsDevtoolsMessageService {
651
652
  constructor(logger, store, options) {
652
653
  this.logger = logger;
653
654
  this.store = store;
654
- this.subscriptions = new Subscription();
655
655
  this.sendMessage = (sendOtterMessage);
656
+ this.destroyRef = inject(DestroyRef);
656
657
  this.options = {
657
658
  ...OTTER_COMPONENTS_DEVTOOLS_DEFAULT_OPTIONS,
658
659
  ...options
@@ -728,14 +729,10 @@ class ComponentsDevtoolsMessageService {
728
729
  }
729
730
  /** @inheritDoc */
730
731
  activate() {
731
- this.subscriptions.add(fromEvent(window, 'message').pipe(filterMessageContent(isComponentsMessage)).subscribe((e) => this.handleEvents(e)));
732
+ fromEvent(window, 'message').pipe(takeUntilDestroyed(this.destroyRef), filterMessageContent(isComponentsMessage)).subscribe((e) => this.handleEvents(e));
732
733
  this.inspectorService.prepareInspector();
733
- this.subscriptions.add(this.inspectorService.otterLikeComponentInfoToBeSent$
734
- .pipe(filter((info) => !!info)).subscribe((info) => this.sendMessage('selectedComponentInfo', info)));
735
- }
736
- /** @inheritDoc */
737
- ngOnDestroy() {
738
- this.subscriptions.unsubscribe();
734
+ this.inspectorService.otterLikeComponentInfoToBeSent$
735
+ .pipe(takeUntilDestroyed(this.destroyRef), filter((info) => !!info)).subscribe((info) => this.sendMessage('selectedComponentInfo', info));
739
736
  }
740
737
  /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ComponentsDevtoolsMessageService, deps: [{ token: i1$1.LoggerService }, { token: i1.Store }, { token: OTTER_COMPONENTS_DEVTOOLS_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
741
738
  /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ComponentsDevtoolsMessageService, providedIn: 'root' }); }
@@ -1341,15 +1338,15 @@ class PlaceholderComponent {
1341
1338
  constructor(store, cd) {
1342
1339
  this.store = store;
1343
1340
  this.cd = cd;
1344
- this.subscription = new Subscription();
1345
1341
  this.id$ = new BehaviorSubject(undefined);
1346
1342
  this.afterViewInit$ = new Subject();
1347
1343
  this.messages$ = new ReplaySubject(1);
1344
+ this.destroyRef = inject(DestroyRef);
1348
1345
  this.mode = this.store.selectSignal(selectPlaceholderTemplateMode);
1349
1346
  }
1350
1347
  /** @inheritdoc */
1351
1348
  ngOnInit() {
1352
- this.subscription.add(this.id$.pipe(filter((id) => !!id), distinctUntilChanged(), switchMap((id) => this.store.select(selectSortedTemplates(id)).pipe(map((placeholders) => ({
1349
+ this.id$.pipe(filter((id) => !!id), distinctUntilChanged(), switchMap((id) => this.store.select(selectSortedTemplates(id)).pipe(map((placeholders) => ({
1353
1350
  id,
1354
1351
  orderedTemplates: placeholders?.orderedTemplates,
1355
1352
  isPending: placeholders?.isPending
@@ -1369,8 +1366,8 @@ class PlaceholderComponent {
1369
1366
  });
1370
1367
  }
1371
1368
  this.cd.markForCheck();
1372
- }));
1373
- this.messages$.pipe(sample(this.afterViewInit$), distinctUntilChanged((previous, current) => JSON.stringify(current) === JSON.stringify(previous))).subscribe({
1369
+ });
1370
+ this.messages$.pipe(takeUntilDestroyed(this.destroyRef), sample(this.afterViewInit$), distinctUntilChanged((previous, current) => JSON.stringify(current) === JSON.stringify(previous))).subscribe({
1374
1371
  next: (data) => sendOtterMessage('placeholder-loading-status', data, false),
1375
1372
  complete: () => sendOtterMessage('placeholder-loading-status', {
1376
1373
  placeholderId: this.id$.value,
@@ -1384,9 +1381,9 @@ class PlaceholderComponent {
1384
1381
  }
1385
1382
  /** @inheritdoc */
1386
1383
  ngOnDestroy() {
1384
+ this.id$.complete();
1387
1385
  this.messages$.complete();
1388
1386
  this.afterViewInit$.complete();
1389
- this.subscription.unsubscribe();
1390
1387
  }
1391
1388
  /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: PlaceholderComponent, deps: [{ token: i1.Store }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
1392
1389
  /** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: PlaceholderComponent, selector: "o3r-placeholder", inputs: { id: "id" }, host: { properties: { "class.debug": "mode() === 'debug'" } }, ngImport: i0, template: "<ng-template #projection>\n <ng-content></ng-content>\n</ng-template>\n@switch (mode()) {\n @case ('debug') {\n <span class=\"placehoder-id\">{{ id$ | async }}</span>\n }\n @case ('pending') {\n <ng-container *ngTemplateOutlet=\"projection\" />\n }\n @case ('normal') {\n @if (isPending) {\n <ng-container *ngTemplateOutlet=\"projection\" />\n } @else {\n <div [innerHTML]=\"template\"></div>\n }\n }\n}\n", styles: [".debug{padding:15px;text-align:center;border:2px dashed var(--o3r-placeholder-debug-color, #a65c27);border-radius:10px;width:100%;background:var(--o3r-placeholder-background, #fff2ea);border-style:dashed;color:var(--o3r-placeholder-debug-color, #a65c27);font-size:larger}\n"], dependencies: [{ kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: i2.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }