@ethlete/query 0.1.0-next.6 → 0.1.0-next.8

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,6 +1,8 @@
1
1
  import { Subject, timer, filter, takeWhile, BehaviorSubject, interval, takeUntil, tap, switchMap, of, fromEvent, startWith, concat, take, debounceTime, combineLatest, map, distinctUntilChanged } from 'rxjs';
2
2
  import * as i0 from '@angular/core';
3
3
  import { Directive, Input, InjectionToken, inject, ChangeDetectorRef, ViewContainerRef, TemplateRef, ErrorHandler, ElementRef } from '@angular/core';
4
+ import * as i1 from '@ethlete/core';
5
+ import { DestroyDirective } from '@ethlete/core';
4
6
  import { FormGroup } from '@angular/forms';
5
7
  import { Router, ActivatedRoute } from '@angular/router';
6
8
 
@@ -200,12 +202,20 @@ const buildRequestError = async (error, route, requestInit) => {
200
202
  }
201
203
  if (isFetchResponse(error)) {
202
204
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
203
- let detail;
205
+ let detail = null;
204
206
  try {
205
- detail = await error.text();
207
+ detail = await error.json();
206
208
  }
207
- catch (err) {
208
- detail = null;
209
+ catch {
210
+ // noop
211
+ }
212
+ if (!detail) {
213
+ try {
214
+ detail = await error.text();
215
+ }
216
+ catch {
217
+ // noop
218
+ }
209
219
  }
210
220
  const err = {
211
221
  code: error.status,
@@ -270,7 +280,9 @@ const request = async (options) => {
270
280
  if (!response.ok) {
271
281
  throw response;
272
282
  }
273
- const data = (await response.json());
283
+ const isJsonResponse = response.headers.get('Content-Type')?.includes('application/json');
284
+ const isTextResponse = response.headers.get('Content-Type')?.includes('text/plain');
285
+ const data = (isJsonResponse ? await response.json() : isTextResponse ? await response.text() : null);
274
286
  const expiresInSeconds = options.cacheAdapter
275
287
  ? options.cacheAdapter(response.headers)
276
288
  : extractExpiresInSeconds(response.headers);
@@ -717,9 +729,9 @@ class QueryDirective {
717
729
  }
718
730
  }
719
731
  }
720
- QueryDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: QueryDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: i0.ErrorHandler }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
721
- QueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.9", type: QueryDirective, isStandalone: true, selector: "[query]", inputs: { query: "query", cache: ["queryCache", "cache"] }, ngImport: i0 });
722
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: QueryDirective, decorators: [{
732
+ QueryDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: QueryDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: i0.ErrorHandler }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
733
+ QueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.0", type: QueryDirective, isStandalone: true, selector: "[query]", inputs: { query: "query", cache: ["queryCache", "cache"] }, ngImport: i0 });
734
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: QueryDirective, decorators: [{
723
735
  type: Directive,
724
736
  args: [{
725
737
  // eslint-disable-next-line @angular-eslint/directive-selector
@@ -913,7 +925,7 @@ class InfinityQueryDirective {
913
925
  itemsPerPage: null,
914
926
  };
915
927
  this._infinityQueryInstance = null;
916
- this._destroy$ = new Subject();
928
+ this._destroy$ = inject(DestroyDirective).destroy$;
917
929
  this._cdr = inject(ChangeDetectorRef);
918
930
  this._viewContainerRef = inject(ViewContainerRef);
919
931
  this._mainTemplateRef = inject((TemplateRef));
@@ -949,8 +961,6 @@ class InfinityQueryDirective {
949
961
  this._renderMainView();
950
962
  }
951
963
  ngOnDestroy() {
952
- this._destroy$.next(true);
953
- this._destroy$.unsubscribe();
954
964
  this.instance?._destroy();
955
965
  }
956
966
  _setupInfinityQuery(config) {
@@ -1030,9 +1040,9 @@ class InfinityQueryDirective {
1030
1040
  this._data$.next([]);
1031
1041
  }
1032
1042
  }
1033
- InfinityQueryDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: InfinityQueryDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1034
- InfinityQueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.9", type: InfinityQueryDirective, isStandalone: true, selector: "[infinityQuery]", inputs: { infinityQuery: "infinityQuery" }, providers: [{ provide: INFINITY_QUERY_TOKEN, useExisting: InfinityQueryDirective }], exportAs: ["infinityQuery"], ngImport: i0 });
1035
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: InfinityQueryDirective, decorators: [{
1043
+ InfinityQueryDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: InfinityQueryDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1044
+ InfinityQueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.0", type: InfinityQueryDirective, isStandalone: true, selector: "[infinityQuery]", inputs: { infinityQuery: "infinityQuery" }, providers: [{ provide: INFINITY_QUERY_TOKEN, useExisting: InfinityQueryDirective }], exportAs: ["infinityQuery"], hostDirectives: [{ directive: i1.DestroyDirective }], ngImport: i0 });
1045
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: InfinityQueryDirective, decorators: [{
1036
1046
  type: Directive,
1037
1047
  args: [{
1038
1048
  // eslint-disable-next-line @angular-eslint/directive-selector
@@ -1040,6 +1050,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImpor
1040
1050
  exportAs: 'infinityQuery',
1041
1051
  standalone: true,
1042
1052
  providers: [{ provide: INFINITY_QUERY_TOKEN, useExisting: InfinityQueryDirective }],
1053
+ hostDirectives: [DestroyDirective],
1043
1054
  }]
1044
1055
  }], propDecorators: { infinityQuery: [{
1045
1056
  type: Input
@@ -1082,9 +1093,9 @@ class InfinityQueryTriggerDirective {
1082
1093
  this._observer.observe(this._elementRef.nativeElement);
1083
1094
  }
1084
1095
  }
1085
- InfinityQueryTriggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: InfinityQueryTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1086
- InfinityQueryTriggerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.9", type: InfinityQueryTriggerDirective, isStandalone: true, selector: "[infinityQueryTrigger], infinity-query-trigger", inputs: { scrollContainerSelector: "scrollContainerSelector" }, ngImport: i0 });
1087
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: InfinityQueryTriggerDirective, decorators: [{
1096
+ InfinityQueryTriggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: InfinityQueryTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1097
+ InfinityQueryTriggerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.0", type: InfinityQueryTriggerDirective, isStandalone: true, selector: "[infinityQueryTrigger], infinity-query-trigger", inputs: { scrollContainerSelector: "scrollContainerSelector" }, ngImport: i0 });
1098
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: InfinityQueryTriggerDirective, decorators: [{
1088
1099
  type: Directive,
1089
1100
  args: [{
1090
1101
  // eslint-disable-next-line @angular-eslint/directive-selector