angular-three 1.5.1 → 1.6.0

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, Pipe, SkipSelf, ContentChild } 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';
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';
@@ -993,34 +993,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImpor
993
993
  type: Input
994
994
  }] } });
995
995
 
996
- class NgtRef extends NgtCommonDirective {
997
- set ref(ref) {
998
- if (!ref || ref == null)
999
- return;
1000
- this.injected = false;
1001
- this.injectedRef = ref;
1002
- this.createView();
1003
- }
1004
- get ref() {
1005
- if (this.validate()) {
1006
- this.injected = true;
1007
- return this.injectedRef;
1008
- }
1009
- return null;
1010
- }
1011
- validate() {
1012
- return !this.injected && !!this.injectedRef && !this.injectedRef.nativeElement;
1013
- }
1014
- }
1015
- NgtRef.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtRef, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1016
- NgtRef.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.3", type: NgtRef, isStandalone: true, selector: "[ref]", inputs: { ref: "ref" }, usesInheritance: true, ngImport: i0 });
1017
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtRef, decorators: [{
1018
- type: Directive,
1019
- args: [{ selector: '[ref]', standalone: true }]
1020
- }], propDecorators: { ref: [{
1021
- type: Input
1022
- }] } });
1023
-
1024
996
  function releaseInternalPointerCapture(capturedMap, obj, captures, pointerId) {
1025
997
  const captureData = captures.get(obj);
1026
998
  if (captureData) {
@@ -1718,15 +1690,21 @@ class NgtRendererStore {
1718
1690
  applyProperty(node, name, value) {
1719
1691
  if (node.__ngt_renderer__[3 /* NgtRendererClassId.destroyed */])
1720
1692
  return;
1693
+ // [ref]
1694
+ if (name === SPECIAL_PROPERTIES.REF && is.ref(value)) {
1695
+ node.__ngt_renderer__[11 /* NgtRendererClassId.ref */] = value;
1696
+ value.nativeElement = node;
1697
+ return;
1698
+ }
1721
1699
  const parent = getLocalState(node).parent || node.__ngt_renderer__[1 /* NgtRendererClassId.parent */];
1722
- // rawValue
1700
+ // [rawValue]
1723
1701
  if (getLocalState(node).isRaw && name === SPECIAL_PROPERTIES.VALUE) {
1724
1702
  node.__ngt_renderer__[10 /* NgtRendererClassId.rawValue */] = value;
1725
1703
  if (parent)
1726
1704
  attachThreeChild(parent, node);
1727
1705
  return;
1728
1706
  }
1729
- // attach
1707
+ // [attach]
1730
1708
  if (name === SPECIAL_PROPERTIES.ATTACH) {
1731
1709
  getLocalState(node).attach = Array.isArray(value) ? value.map((v) => v.toString()) : value;
1732
1710
  if (parent)
@@ -1795,9 +1773,8 @@ class NgtRendererStore {
1795
1773
  }
1796
1774
  getCreationState() {
1797
1775
  const injectedArgs = this.firstNonInjectedDirective(NgtArgs)?.args || [];
1798
- const injectedRef = this.firstNonInjectedDirective(NgtRef)?.ref || null;
1799
1776
  const store = this.tryGetPortalStore();
1800
- return { injectedArgs, injectedRef, store };
1777
+ return { injectedArgs, store };
1801
1778
  }
1802
1779
  destroy(node, parent) {
1803
1780
  const state = node.__ngt_renderer__;
@@ -2014,7 +1991,7 @@ class NgtRenderer {
2014
1991
  if (name === SPECIAL_DOM_TAG.NGT_VALUE) {
2015
1992
  return this.store.createNode('three', Object.assign({ __ngt_renderer__: { rawValue: undefined } }, { __ngt__: { isRaw: true } }));
2016
1993
  }
2017
- const { injectedArgs, injectedRef, store } = this.store.getCreationState();
1994
+ const { injectedArgs, store } = this.store.getCreationState();
2018
1995
  // handle primitive
2019
1996
  if (name === SPECIAL_DOM_TAG.NGT_PRIMITIVE) {
2020
1997
  if (!injectedArgs[0])
@@ -2027,10 +2004,7 @@ class NgtRenderer {
2027
2004
  }
2028
2005
  if (!localState.store)
2029
2006
  localState.store = store;
2030
- const primitiveNode = this.store.createNode('three', object);
2031
- if (injectedRef)
2032
- injectedRef.nativeElement = primitiveNode;
2033
- return primitiveNode;
2007
+ return this.store.createNode('three', object);
2034
2008
  }
2035
2009
  const threeTag = name.startsWith('ngt') ? name.slice(4) : name;
2036
2010
  const threeName = kebabToPascal(threeTag);
@@ -2046,10 +2020,6 @@ class NgtRenderer {
2046
2020
  else if (is.material(instance)) {
2047
2021
  localState.attach = ['material'];
2048
2022
  }
2049
- if (injectedRef) {
2050
- injectedRef.nativeElement = node;
2051
- node.__ngt_renderer__[11 /* NgtRendererClassId.ref */] = injectedRef;
2052
- }
2053
2023
  return node;
2054
2024
  }
2055
2025
  const domNode = this.store.createNode('dom', element);
@@ -2662,6 +2632,26 @@ function injectNgtRef(initialValue = null) {
2662
2632
  return Object.assign(ref, { subscribe, $, children$, useCDR: (cdr) => void cdRefs.push(cdr) });
2663
2633
  }
2664
2634
 
2635
+ function createRunInContext() {
2636
+ const nodeInjector = inject(Injector);
2637
+ const envInjector = inject(EnvironmentInjector);
2638
+ const originalGet = envInjector.get;
2639
+ return (cb) => {
2640
+ envInjector.get = (...args) => {
2641
+ try {
2642
+ const fromNodeInjector = nodeInjector.get(...args);
2643
+ if (fromNodeInjector)
2644
+ return fromNodeInjector;
2645
+ return originalGet(...args);
2646
+ }
2647
+ catch (e) {
2648
+ return originalGet(...args);
2649
+ }
2650
+ };
2651
+ return envInjector.runInContext(cb);
2652
+ };
2653
+ }
2654
+
2665
2655
  class NgtRepeat extends NgForOf {
2666
2656
  set ngForRepeat(count) {
2667
2657
  this.ngForOf = Number.isInteger(count) ? Array.from({ length: count }, (_, i) => i) : [];
@@ -2961,5 +2951,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImpor
2961
2951
  * Generated bundle index. Do not edit.
2962
2952
  */
2963
2953
 
2964
- export { NGT_CATALOGUE, NgtArgs, NgtCanvas, NgtPortal, NgtPortalBeforeRender, NgtPortalContent, NgtPush, NgtRef, NgtRepeat, NgtRxStore, NgtStore, addAfterEffect, addEffect, addTail, applyProps, checkNeedsUpdate, checkUpdate, createAttachFunction, createLoop, extend, flushGlobalEffects, getLocalState, injectBeforeRender, injectNgtDestroy, injectNgtLoader, injectNgtRef, invalidateInstance, is, makeDefaultCamera, makeDefaultRenderer, makeDpr, makeId, makeObjectGraph, prepare, rootStateMap, safeDetectChanges, startWithUndefined, tapEffect, updateCamera };
2954
+ export { NGT_CATALOGUE, NgtArgs, NgtCanvas, NgtPortal, NgtPortalBeforeRender, NgtPortalContent, NgtPush, NgtRepeat, NgtRxStore, NgtStore, addAfterEffect, addEffect, addTail, applyProps, checkNeedsUpdate, checkUpdate, createAttachFunction, createLoop, createRunInContext, extend, flushGlobalEffects, getLocalState, injectBeforeRender, injectNgtDestroy, injectNgtLoader, injectNgtRef, invalidateInstance, is, makeDefaultCamera, makeDefaultRenderer, makeDpr, makeId, makeObjectGraph, prepare, rootStateMap, safeDetectChanges, startWithUndefined, tapEffect, updateCamera };
2965
2955
  //# sourceMappingURL=angular-three.mjs.map