angular-three 1.6.6 → 1.6.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,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { ElementRef, Injectable, inject, InjectionToken, ViewContainerRef, TemplateRef, Directive, Input, EventEmitter, getDebugNode, RendererFactory2, ChangeDetectorRef, makeEnvironmentProviders, EnvironmentInjector, createEnvironmentInjector, Component, HostBinding, Output, ViewChild, Injector, Pipe, SkipSelf, ContentChild } from '@angular/core';
2
+ import { ElementRef, inject, ChangeDetectorRef, Injectable, InjectionToken, ViewContainerRef, TemplateRef, Directive, Input, EventEmitter, getDebugNode, RendererFactory2, makeEnvironmentProviders, EnvironmentInjector, createEnvironmentInjector, Component, HostBinding, Output, ViewChild, Injector, Pipe, SkipSelf, ContentChild } from '@angular/core';
3
3
  import { provideNgxResizeOptions, NgxResize } from 'ngx-resize';
4
4
  import { isObservable, of, map, from, tap, retry, catchError, share, ReplaySubject, switchMap, forkJoin, take, BehaviorSubject, startWith, combineLatest, filter, distinctUntilChanged, takeUntil, merge } from 'rxjs';
5
5
  import * as THREE from 'three';
@@ -459,6 +459,19 @@ function applyProps(instance, props) {
459
459
  return instance;
460
460
  }
461
461
 
462
+ function safeDetectChanges(cdr) {
463
+ if (!cdr)
464
+ return;
465
+ try {
466
+ if (cdr['context']) {
467
+ cdr.detectChanges();
468
+ }
469
+ }
470
+ catch (e) {
471
+ cdr.markForCheck();
472
+ }
473
+ }
474
+
462
475
  const startWithUndefined = () => startWith(undefined);
463
476
  /**
464
477
  * An extended `tap` operator that accepts an `effectFn` which:
@@ -516,6 +529,7 @@ function tapEffect(effectFn) {
516
529
  class NgtRxStore extends RxState {
517
530
  constructor() {
518
531
  super();
532
+ const cdr = inject(ChangeDetectorRef, { optional: true });
519
533
  // set a dummy property so that initial this.get() won't return undefined
520
534
  this.set({ __ngt_dummy__: '__ngt_dummy__' });
521
535
  // call initialize that might be setup by derived Stores
@@ -532,10 +546,14 @@ class NgtRxStore extends RxState {
532
546
  modded[key] = value === undefined ? this.get(key) : value;
533
547
  return modded;
534
548
  }, {});
535
- return originalSet(modArgs);
549
+ const value = originalSet(modArgs);
550
+ safeDetectChanges(cdr);
551
+ return value;
536
552
  }
537
553
  // @ts-expect-error not sure why ...args here doesn't pass tuple check
538
- return originalSet(...args);
554
+ const value = originalSet(...args);
555
+ safeDetectChanges(cdr);
556
+ return value;
539
557
  };
540
558
  },
541
559
  });
@@ -2582,17 +2600,6 @@ function injectBeforeRender(cb, priority = 0) {
2582
2600
  }
2583
2601
  }
2584
2602
 
2585
- function safeDetectChanges(cdr) {
2586
- try {
2587
- if (cdr['context']) {
2588
- cdr.detectChanges();
2589
- }
2590
- }
2591
- catch (e) {
2592
- cdr.markForCheck();
2593
- }
2594
- }
2595
-
2596
2603
  function injectNgtRef(initialValue = null) {
2597
2604
  const ref = is.ref(initialValue) ? initialValue : new ElementRef(initialValue);
2598
2605
  let lastValue = ref.nativeElement;