angular-three 1.5.0 → 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,24 +1690,25 @@ class NgtRendererStore {
1718
1690
  applyProperty(node, name, value) {
1719
1691
  if (node.__ngt_renderer__[3 /* NgtRendererClassId.destroyed */])
1720
1692
  return;
1721
- // setup [ref] here
1722
- // ref should never change
1723
- // if (name === SPECIAL_PROPERTIES.REF && is.ref(value)) {
1724
- // node.__ngt_renderer__[NgtRendererClassId.ref] = value;
1725
- // value.nativeElement = node;
1726
- // return;
1727
- // }
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
+ }
1728
1699
  const parent = getLocalState(node).parent || node.__ngt_renderer__[1 /* NgtRendererClassId.parent */];
1729
- // rawValue
1700
+ // [rawValue]
1730
1701
  if (getLocalState(node).isRaw && name === SPECIAL_PROPERTIES.VALUE) {
1731
1702
  node.__ngt_renderer__[10 /* NgtRendererClassId.rawValue */] = value;
1732
- attachThreeChild(parent, node);
1703
+ if (parent)
1704
+ attachThreeChild(parent, node);
1733
1705
  return;
1734
1706
  }
1735
- // attach
1707
+ // [attach]
1736
1708
  if (name === SPECIAL_PROPERTIES.ATTACH) {
1737
1709
  getLocalState(node).attach = Array.isArray(value) ? value.map((v) => v.toString()) : value;
1738
- attachThreeChild(parent, node);
1710
+ if (parent)
1711
+ attachThreeChild(parent, node);
1739
1712
  return;
1740
1713
  }
1741
1714
  const compound = node.__ngt_renderer__[4 /* NgtRendererClassId.compound */];
@@ -1800,9 +1773,8 @@ class NgtRendererStore {
1800
1773
  }
1801
1774
  getCreationState() {
1802
1775
  const injectedArgs = this.firstNonInjectedDirective(NgtArgs)?.args || [];
1803
- const injectedRef = this.firstNonInjectedDirective(NgtRef)?.ref || null;
1804
1776
  const store = this.tryGetPortalStore();
1805
- return { injectedArgs, injectedRef, store };
1777
+ return { injectedArgs, store };
1806
1778
  }
1807
1779
  destroy(node, parent) {
1808
1780
  const state = node.__ngt_renderer__;
@@ -2019,7 +1991,7 @@ class NgtRenderer {
2019
1991
  if (name === SPECIAL_DOM_TAG.NGT_VALUE) {
2020
1992
  return this.store.createNode('three', Object.assign({ __ngt_renderer__: { rawValue: undefined } }, { __ngt__: { isRaw: true } }));
2021
1993
  }
2022
- const { injectedArgs, injectedRef, store } = this.store.getCreationState();
1994
+ const { injectedArgs, store } = this.store.getCreationState();
2023
1995
  // handle primitive
2024
1996
  if (name === SPECIAL_DOM_TAG.NGT_PRIMITIVE) {
2025
1997
  if (!injectedArgs[0])
@@ -2032,10 +2004,7 @@ class NgtRenderer {
2032
2004
  }
2033
2005
  if (!localState.store)
2034
2006
  localState.store = store;
2035
- const primitiveNode = this.store.createNode('three', object);
2036
- if (injectedRef)
2037
- injectedRef.nativeElement = primitiveNode;
2038
- return primitiveNode;
2007
+ return this.store.createNode('three', object);
2039
2008
  }
2040
2009
  const threeTag = name.startsWith('ngt') ? name.slice(4) : name;
2041
2010
  const threeName = kebabToPascal(threeTag);
@@ -2051,10 +2020,6 @@ class NgtRenderer {
2051
2020
  else if (is.material(instance)) {
2052
2021
  localState.attach = ['material'];
2053
2022
  }
2054
- if (injectedRef) {
2055
- injectedRef.nativeElement = node;
2056
- node.__ngt_renderer__[11 /* NgtRendererClassId.ref */] = injectedRef;
2057
- }
2058
2023
  return node;
2059
2024
  }
2060
2025
  const domNode = this.store.createNode('dom', element);
@@ -2667,6 +2632,26 @@ function injectNgtRef(initialValue = null) {
2667
2632
  return Object.assign(ref, { subscribe, $, children$, useCDR: (cdr) => void cdRefs.push(cdr) });
2668
2633
  }
2669
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
+
2670
2655
  class NgtRepeat extends NgForOf {
2671
2656
  set ngForRepeat(count) {
2672
2657
  this.ngForOf = Number.isInteger(count) ? Array.from({ length: count }, (_, i) => i) : [];
@@ -2966,5 +2951,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImpor
2966
2951
  * Generated bundle index. Do not edit.
2967
2952
  */
2968
2953
 
2969
- 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 };
2970
2955
  //# sourceMappingURL=angular-three.mjs.map