@ethlete/query 0.1.0-next.10 → 0.1.0-next.12

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.
Files changed (29) hide show
  1. package/esm2020/lib/auth/auth-provider.types.mjs +1 -1
  2. package/esm2020/lib/auth/basic-auth-provider.mjs +5 -5
  3. package/esm2020/lib/auth/bearer-auth-provider.mjs +18 -8
  4. package/esm2020/lib/auth/custom-header-auth-provider.mjs +4 -4
  5. package/esm2020/lib/directives/infinity-query-trigger.directive.mjs +3 -3
  6. package/esm2020/lib/directives/infinity-query.directive.mjs +7 -9
  7. package/esm2020/lib/directives/query.directive.mjs +17 -17
  8. package/esm2020/lib/infinite-query/infinity-query.mjs +11 -11
  9. package/esm2020/lib/query/query.mjs +44 -22
  10. package/esm2020/lib/query/query.types.mjs +1 -1
  11. package/esm2020/lib/query-client/query-client.mjs +7 -7
  12. package/esm2020/lib/query-client/query-client.types.mjs +1 -1
  13. package/esm2020/lib/query-form/query-form.mjs +4 -4
  14. package/fesm2015/ethlete-query.mjs +140 -106
  15. package/fesm2015/ethlete-query.mjs.map +1 -1
  16. package/fesm2020/ethlete-query.mjs +134 -103
  17. package/fesm2020/ethlete-query.mjs.map +1 -1
  18. package/lib/auth/auth-provider.types.d.ts +16 -1
  19. package/lib/auth/bearer-auth-provider.d.ts +1 -0
  20. package/lib/directives/infinity-query.directive.d.ts +1 -2
  21. package/lib/infinite-query/infinity-query.types.d.ts +4 -4
  22. package/lib/query/query.d.ts +5 -3
  23. package/lib/query/query.types.d.ts +17 -14
  24. package/lib/query/query.utils.d.ts +1 -1
  25. package/lib/query-client/query-client.d.ts +9 -9
  26. package/lib/query-client/query-client.types.d.ts +9 -9
  27. package/lib/query-form/query-form.types.d.ts +2 -2
  28. package/lib/request/request.types.d.ts +10 -10
  29. package/package.json +5 -5
@@ -1,35 +1,34 @@
1
1
  import { Subject, timer, filter, takeWhile, switchMap, of, BehaviorSubject, interval, takeUntil, tap, 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
+ import { DestroyService } from '@ethlete/core';
6
5
  import { FormGroup } from '@angular/forms';
7
6
  import { Router, ActivatedRoute } from '@angular/router';
8
7
 
9
8
  class CustomHeaderAuthProvider {
9
+ get header() {
10
+ return { [this._config.name]: this._config.value };
11
+ }
10
12
  constructor(_config) {
11
13
  this._config = _config;
12
14
  this.queryClient = null;
13
15
  }
14
- get header() {
15
- return { [this._config.name]: this._config.value };
16
- }
17
16
  cleanUp() {
18
17
  // noop
19
18
  }
20
19
  }
21
20
 
22
21
  class BasicAuthProvider {
23
- constructor(_config) {
24
- this._config = _config;
25
- this.queryClient = null;
26
- }
27
22
  get header() {
28
23
  return { Authorization: `Basic ${this._basicAuthString}` };
29
24
  }
30
25
  get _basicAuthString() {
31
26
  return btoa(`${this._config.username}:${this._config.password}`);
32
27
  }
28
+ constructor(_config) {
29
+ this._config = _config;
30
+ this.queryClient = null;
31
+ }
33
32
  cleanUp() {
34
33
  // noop
35
34
  }
@@ -314,10 +313,14 @@ const decryptBearer = (token) => {
314
313
  };
315
314
 
316
315
  class BearerAuthProvider {
316
+ get header() {
317
+ return { Authorization: `Bearer ${this._token}` };
318
+ }
317
319
  constructor(_config) {
318
320
  this._config = _config;
319
321
  this._refreshToken = null;
320
322
  this._refreshTimerSubscription = null;
323
+ this._failureCount = 0;
321
324
  this.queryClient = null;
322
325
  this.onRefreshInitiation$ = new Subject();
323
326
  this.onRefreshSuccess$ = new Subject();
@@ -328,14 +331,12 @@ class BearerAuthProvider {
328
331
  this._setupRefresh(this._config.refreshConfig);
329
332
  }
330
333
  }
331
- get header() {
332
- return { Authorization: `Bearer ${this._token}` };
333
- }
334
334
  cleanUp() {
335
335
  this._refreshTimerSubscription?.unsubscribe();
336
336
  this._refreshTimerSubscription = null;
337
337
  }
338
338
  _setupRefresh(config) {
339
+ this.cleanUp();
339
340
  const bearer = decryptBearer(this._token);
340
341
  if (!bearer) {
341
342
  return;
@@ -343,10 +344,11 @@ class BearerAuthProvider {
343
344
  const expiresInPropertyName = config.expiresInPropertyName || 'exp';
344
345
  const expiresIn = bearer[expiresInPropertyName];
345
346
  const fiveMinutes = 5 * 60 * 1000;
347
+ const refreshBuffer = config.refreshBuffer ?? fiveMinutes;
346
348
  if (expiresIn === undefined) {
347
349
  throw new Error(`Bearer token does not contain an '${expiresInPropertyName}' property`);
348
350
  }
349
- const remainingTime = new Date(expiresIn * 1000).getTime() - fiveMinutes - new Date().getTime();
351
+ const remainingTime = new Date(expiresIn * 1000).getTime() - refreshBuffer - new Date().getTime();
350
352
  const strategy = config.strategy ?? "beforeExpiration" /* AuthBearerRefreshStrategy.BeforeExpiration */;
351
353
  switch (strategy) {
352
354
  case "beforeExpiration" /* AuthBearerRefreshStrategy.BeforeExpiration */:
@@ -361,13 +363,14 @@ class BearerAuthProvider {
361
363
  if (!this.queryClient) {
362
364
  throw new Error('Query client instance is null');
363
365
  }
364
- const { method, route, bodyAdapter, responseAdapter } = config;
366
+ const { method, route, requestAdapter, responseAdapter, paramLocation } = config;
367
+ const data = requestAdapter?.(this._refreshToken) ?? { refreshToken: this._refreshToken };
365
368
  const fullRoute = buildRoute({
366
369
  base: this.queryClient.config.baseRoute,
367
370
  route,
371
+ queryParams: paramLocation === 'query' ? data : undefined,
368
372
  });
369
- const body = bodyAdapter ? bodyAdapter(this._refreshToken) : { refreshToken: this._refreshToken };
370
- const requestInit = { body: buildBody(body), method };
373
+ const requestInit = { body: paramLocation === 'body' ? buildBody(data) : undefined, method };
371
374
  this.onRefreshInitiation$.next();
372
375
  try {
373
376
  const result = await request({
@@ -384,6 +387,8 @@ class BearerAuthProvider {
384
387
  this._token = tokens.token;
385
388
  this._refreshToken = tokens.refreshToken;
386
389
  this.onRefreshSuccess$.next(tokens);
390
+ this._setupRefresh(config);
391
+ this._failureCount = 0;
387
392
  }
388
393
  catch (error) {
389
394
  if (error instanceof Error) {
@@ -392,6 +397,10 @@ class BearerAuthProvider {
392
397
  else {
393
398
  this.onRefreshFailure$.next(error);
394
399
  }
400
+ this._failureCount++;
401
+ if (this._failureCount <= (config.maxRefreshAttempts ?? 3)) {
402
+ this._setupRefresh(config);
403
+ }
395
404
  }
396
405
  }
397
406
  }
@@ -419,31 +428,6 @@ const gql = (strings, ...values) => {
419
428
  return str;
420
429
  };
421
430
 
422
- const deepFreeze = (object) => {
423
- // check if object is actually an object or frozen
424
- if (!object || typeof object !== 'object' || Object.isFrozen(object)) {
425
- return object;
426
- }
427
- // Retrieve the property names defined on object
428
- const propNames = Object.getOwnPropertyNames(object);
429
- // Freeze properties before freezing self
430
- for (const name of propNames) {
431
- const value = object[name];
432
- if (value && typeof value === 'object') {
433
- deepFreeze(value);
434
- }
435
- }
436
- return Object.freeze(object);
437
- };
438
-
439
- /**
440
- * Dummy function for providing types while not breaking inference.
441
- * **This function always returns null.**
442
- * @see https://github.com/microsoft/TypeScript/issues/26242
443
- * @returns null
444
- */
445
- const def = () => null;
446
-
447
431
  function filterSuccess() {
448
432
  return function (source) {
449
433
  return source.pipe(filter((value) => isQueryStateSuccess(value)));
@@ -501,21 +485,8 @@ const isGqlQueryConfig = (config) => {
501
485
  };
502
486
 
503
487
  class Query {
504
- constructor(_client, _queryConfig, _route, _args) {
505
- this._client = _client;
506
- this._queryConfig = _queryConfig;
507
- this._route = _route;
508
- this._args = _args;
509
- this._currentId = 0;
510
- this._abortController = new AbortController();
511
- this._pollingSubscription = null;
512
- this._state$ = new BehaviorSubject({
513
- type: "PREPARED" /* QueryStateType.Prepared */,
514
- meta: { id: this._currentId },
515
- });
516
- }
517
488
  get _nextId() {
518
- return this._currentId++;
489
+ return ++this._currentId;
519
490
  }
520
491
  get state$() {
521
492
  return this._state$.asObservable();
@@ -533,6 +504,20 @@ class Query {
533
504
  }
534
505
  return ts < Date.now();
535
506
  }
507
+ constructor(_client, _queryConfig, _route, _args) {
508
+ this._client = _client;
509
+ this._queryConfig = _queryConfig;
510
+ this._route = _route;
511
+ this._args = _args;
512
+ this._currentId = 0;
513
+ this._abortController = new AbortController();
514
+ this._pollingSubscription = null;
515
+ this._onAbort$ = new Subject();
516
+ this._state$ = new BehaviorSubject({
517
+ type: "PREPARED" /* QueryStateType.Prepared */,
518
+ meta: { id: this._currentId },
519
+ });
520
+ }
536
521
  clone() {
537
522
  return this._client.fetch(this._queryConfig);
538
523
  }
@@ -547,11 +532,12 @@ class Query {
547
532
  if (isQueryStateLoading(this._state$.value)) {
548
533
  this.abort();
549
534
  }
550
- const meta = deepFreeze({ id });
535
+ const meta = { id };
551
536
  this._state$.next({
552
537
  type: "LOADING" /* QueryStateType.Loading */,
553
538
  meta,
554
539
  });
540
+ this._updateUseResultInDependencies();
555
541
  let body = null;
556
542
  let contentType = null;
557
543
  if (isGqlQueryConfig(this._queryConfig)) {
@@ -616,9 +602,9 @@ class Query {
616
602
  : responseData;
617
603
  this._state$.next({
618
604
  type: "SUCCESS" /* QueryStateType.Success */,
619
- response: deepFreeze(transformedResponse),
620
- rawResponse: deepFreeze(responseData),
621
- meta: deepFreeze({ ...meta, expiresAt: response.expiresInTimestamp }),
605
+ response: transformedResponse,
606
+ rawResponse: responseData,
607
+ meta: { ...meta, expiresAt: response.expiresInTimestamp },
622
608
  });
623
609
  })
624
610
  .catch((error) => this._handleExecuteError(error, meta));
@@ -627,6 +613,7 @@ class Query {
627
613
  abort() {
628
614
  this._abortController.abort();
629
615
  this._abortController = new AbortController();
616
+ this._onAbort$.next();
630
617
  return this;
631
618
  }
632
619
  poll(config) {
@@ -643,6 +630,26 @@ class Query {
643
630
  this._pollingSubscription = null;
644
631
  return this;
645
632
  }
633
+ _updateUseResultInDependencies() {
634
+ if (!this._args?.useResultIn?.length) {
635
+ return;
636
+ }
637
+ this.state$
638
+ .pipe(filterSuccess(), takeUntil(this._onAbort$), takeUntilResponse(), tap((state) => {
639
+ if (!this._args?.useResultIn) {
640
+ return;
641
+ }
642
+ for (const query of this._args.useResultIn) {
643
+ query._state$.next({
644
+ type: "SUCCESS" /* QueryStateType.Success */,
645
+ meta: { ...state.meta, id: query._nextId },
646
+ rawResponse: state.rawResponse,
647
+ response: state.response,
648
+ });
649
+ }
650
+ }))
651
+ .subscribe();
652
+ }
646
653
  _handleExecuteError(error, meta) {
647
654
  if (isAbortRequestError(error)) {
648
655
  this._state$.next({
@@ -664,6 +671,19 @@ class Query {
664
671
  }
665
672
 
666
673
  class QueryDirective {
674
+ get query() {
675
+ return this._query;
676
+ }
677
+ set query(v) {
678
+ this._query = v;
679
+ this._subscribeToQuery();
680
+ }
681
+ get cache() {
682
+ return this._cache;
683
+ }
684
+ set cache(v) {
685
+ this._cache = v;
686
+ }
667
687
  constructor(_mainTemplateRef, _viewContainerRef, _errorHandler, _cdr) {
668
688
  this._mainTemplateRef = _mainTemplateRef;
669
689
  this._viewContainerRef = _viewContainerRef;
@@ -680,19 +700,6 @@ class QueryDirective {
680
700
  };
681
701
  this._cache = false;
682
702
  }
683
- get query() {
684
- return this._query;
685
- }
686
- set query(v) {
687
- this._query = v;
688
- this._subscribeToQuery();
689
- }
690
- get cache() {
691
- return this._cache;
692
- }
693
- set cache(v) {
694
- this._cache = v;
695
- }
696
703
  static ngTemplateContextGuard(dir, ctx) {
697
704
  return true;
698
705
  }
@@ -744,9 +751,9 @@ class QueryDirective {
744
751
  }
745
752
  }
746
753
  }
747
- QueryDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: QueryDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: i0.ErrorHandler }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
748
- QueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.2", type: QueryDirective, isStandalone: true, selector: "[query]", inputs: { query: "query", cache: ["queryCache", "cache"] }, ngImport: i0 });
749
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: QueryDirective, decorators: [{
754
+ QueryDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: QueryDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: i0.ErrorHandler }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
755
+ QueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.0", type: QueryDirective, isStandalone: true, selector: "[query]", inputs: { query: "query", cache: ["queryCache", "cache"] }, ngImport: i0 });
756
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: QueryDirective, decorators: [{
750
757
  type: Directive,
751
758
  args: [{
752
759
  // eslint-disable-next-line @angular-eslint/directive-selector
@@ -762,16 +769,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImpor
762
769
 
763
770
  /* eslint-disable @typescript-eslint/no-explicit-any */
764
771
  class InfinityQuery {
765
- constructor(_config) {
766
- this._config = _config;
767
- this._currentPage$ = new BehaviorSubject(null);
768
- this._currentCalculatedPage$ = new BehaviorSubject(null);
769
- this._totalPages$ = new BehaviorSubject(null);
770
- this._itemsPerPage$ = new BehaviorSubject(this._config.limitParam?.value ?? 10);
771
- this._currentQuery$ = new BehaviorSubject(null);
772
- this._data$ = new BehaviorSubject([]);
773
- this._subscriptions = [];
774
- }
775
772
  get currentPage$() {
776
773
  return this._currentPage$.asObservable();
777
774
  }
@@ -808,6 +805,16 @@ class InfinityQuery {
808
805
  get data() {
809
806
  return this._data$.getValue();
810
807
  }
808
+ constructor(_config) {
809
+ this._config = _config;
810
+ this._currentPage$ = new BehaviorSubject(null);
811
+ this._currentCalculatedPage$ = new BehaviorSubject(null);
812
+ this._totalPages$ = new BehaviorSubject(null);
813
+ this._itemsPerPage$ = new BehaviorSubject(this._config.limitParam?.value ?? 10);
814
+ this._currentQuery$ = new BehaviorSubject(null);
815
+ this._data$ = new BehaviorSubject([]);
816
+ this._subscriptions = [];
817
+ }
811
818
  nextPage() {
812
819
  const newPage = (this._currentPage$.value ?? 0) + 1;
813
820
  const calculatedPage = this._config?.pageParam?.valueCalculator?.({
@@ -940,7 +947,7 @@ class InfinityQueryDirective {
940
947
  itemsPerPage: null,
941
948
  };
942
949
  this._infinityQueryInstance = null;
943
- this._destroy$ = inject(DestroyDirective).destroy$;
950
+ this._destroy$ = inject(DestroyService).destroy$;
944
951
  this._cdr = inject(ChangeDetectorRef);
945
952
  this._viewContainerRef = inject(ViewContainerRef);
946
953
  this._mainTemplateRef = inject((TemplateRef));
@@ -1055,17 +1062,16 @@ class InfinityQueryDirective {
1055
1062
  this._data$.next([]);
1056
1063
  }
1057
1064
  }
1058
- InfinityQueryDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: InfinityQueryDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1059
- InfinityQueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.2", type: InfinityQueryDirective, isStandalone: true, selector: "[infinityQuery]", inputs: { infinityQuery: "infinityQuery" }, providers: [{ provide: INFINITY_QUERY_TOKEN, useExisting: InfinityQueryDirective }], exportAs: ["infinityQuery"], hostDirectives: [{ directive: i1.DestroyDirective }], ngImport: i0 });
1060
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: InfinityQueryDirective, decorators: [{
1065
+ InfinityQueryDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: InfinityQueryDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1066
+ InfinityQueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.0", type: InfinityQueryDirective, isStandalone: true, selector: "[infinityQuery]", inputs: { infinityQuery: "infinityQuery" }, providers: [{ provide: INFINITY_QUERY_TOKEN, useExisting: InfinityQueryDirective }, DestroyService], exportAs: ["infinityQuery"], ngImport: i0 });
1067
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: InfinityQueryDirective, decorators: [{
1061
1068
  type: Directive,
1062
1069
  args: [{
1063
1070
  // eslint-disable-next-line @angular-eslint/directive-selector
1064
1071
  selector: '[infinityQuery]',
1065
1072
  exportAs: 'infinityQuery',
1066
1073
  standalone: true,
1067
- providers: [{ provide: INFINITY_QUERY_TOKEN, useExisting: InfinityQueryDirective }],
1068
- hostDirectives: [DestroyDirective],
1074
+ providers: [{ provide: INFINITY_QUERY_TOKEN, useExisting: InfinityQueryDirective }, DestroyService],
1069
1075
  }]
1070
1076
  }], propDecorators: { infinityQuery: [{
1071
1077
  type: Input
@@ -1108,9 +1114,9 @@ class InfinityQueryTriggerDirective {
1108
1114
  this._observer.observe(this._elementRef.nativeElement);
1109
1115
  }
1110
1116
  }
1111
- InfinityQueryTriggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: InfinityQueryTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1112
- InfinityQueryTriggerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.2", type: InfinityQueryTriggerDirective, isStandalone: true, selector: "[infinityQueryTrigger], infinity-query-trigger", inputs: { scrollContainerSelector: "scrollContainerSelector" }, ngImport: i0 });
1113
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: InfinityQueryTriggerDirective, decorators: [{
1117
+ InfinityQueryTriggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: InfinityQueryTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1118
+ InfinityQueryTriggerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.0", type: InfinityQueryTriggerDirective, isStandalone: true, selector: "[infinityQueryTrigger], infinity-query-trigger", inputs: { scrollContainerSelector: "scrollContainerSelector" }, ngImport: i0 });
1119
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: InfinityQueryTriggerDirective, decorators: [{
1114
1120
  type: Directive,
1115
1121
  args: [{
1116
1122
  // eslint-disable-next-line @angular-eslint/directive-selector
@@ -1202,6 +1208,12 @@ config, args) => {
1202
1208
  };
1203
1209
 
1204
1210
  class QueryClient {
1211
+ get config() {
1212
+ return this._clientConfig;
1213
+ }
1214
+ get authProvider() {
1215
+ return this._authProvider;
1216
+ }
1205
1217
  constructor(_clientConfig) {
1206
1218
  this._clientConfig = _clientConfig;
1207
1219
  this._authProvider = null;
@@ -1276,23 +1288,17 @@ class QueryClient {
1276
1288
  enableGarbageCollectorLogging: _clientConfig.logging?.queryStateGarbageCollector,
1277
1289
  });
1278
1290
  }
1279
- get config() {
1280
- return this._clientConfig;
1281
- }
1282
- get authProvider() {
1283
- return this._authProvider;
1284
- }
1285
1291
  }
1286
1292
 
1287
1293
  class QueryField {
1294
+ get control() {
1295
+ return this.data.control;
1296
+ }
1288
1297
  constructor(data) {
1289
1298
  this.data = data;
1290
1299
  this.changes$ = this._setupChangesObservable();
1291
1300
  this._currentDebounceTimeout = null;
1292
1301
  }
1293
- get control() {
1294
- return this.data.control;
1295
- }
1296
1302
  setValue(value) {
1297
1303
  if (this._currentDebounceTimeout !== null) {
1298
1304
  clearTimeout(this._currentDebounceTimeout);
@@ -1498,6 +1504,31 @@ const transformToSortQueryParam = (value) => {
1498
1504
  return null;
1499
1505
  };
1500
1506
 
1507
+ const deepFreeze = (object) => {
1508
+ // check if object is actually an object or frozen
1509
+ if (!object || typeof object !== 'object' || Object.isFrozen(object)) {
1510
+ return object;
1511
+ }
1512
+ // Retrieve the property names defined on object
1513
+ const propNames = Object.getOwnPropertyNames(object);
1514
+ // Freeze properties before freezing self
1515
+ for (const name of propNames) {
1516
+ const value = object[name];
1517
+ if (value && typeof value === 'object') {
1518
+ deepFreeze(value);
1519
+ }
1520
+ }
1521
+ return Object.freeze(object);
1522
+ };
1523
+
1524
+ /**
1525
+ * Dummy function for providing types while not breaking inference.
1526
+ * **This function always returns null.**
1527
+ * @see https://github.com/microsoft/TypeScript/issues/26242
1528
+ * @returns null
1529
+ */
1530
+ const def = () => null;
1531
+
1501
1532
  /**
1502
1533
  * Generated bundle index. Do not edit.
1503
1534
  */