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';
@@ -973,34 +973,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImpor
973
973
  type: Input
974
974
  }] } });
975
975
 
976
- class NgtRef extends NgtCommonDirective {
977
- set ref(ref) {
978
- if (!ref || ref == null)
979
- return;
980
- this.injected = false;
981
- this.injectedRef = ref;
982
- this.createView();
983
- }
984
- get ref() {
985
- if (this.validate()) {
986
- this.injected = true;
987
- return this.injectedRef;
988
- }
989
- return null;
990
- }
991
- validate() {
992
- return !this.injected && !!this.injectedRef && !this.injectedRef.nativeElement;
993
- }
994
- }
995
- NgtRef.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtRef, deps: null, target: i0.ɵɵFactoryTarget.Directive });
996
- 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 });
997
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtRef, decorators: [{
998
- type: Directive,
999
- args: [{ selector: '[ref]', standalone: true }]
1000
- }], propDecorators: { ref: [{
1001
- type: Input
1002
- }] } });
1003
-
1004
976
  function releaseInternalPointerCapture(capturedMap, obj, captures, pointerId) {
1005
977
  const captureData = captures.get(obj);
1006
978
  if (captureData) {
@@ -1695,15 +1667,21 @@ class NgtRendererStore {
1695
1667
  applyProperty(node, name, value) {
1696
1668
  if (node.__ngt_renderer__[3 /* NgtRendererClassId.destroyed */])
1697
1669
  return;
1670
+ // [ref]
1671
+ if (name === SPECIAL_PROPERTIES.REF && is.ref(value)) {
1672
+ node.__ngt_renderer__[11 /* NgtRendererClassId.ref */] = value;
1673
+ value.nativeElement = node;
1674
+ return;
1675
+ }
1698
1676
  const parent = getLocalState(node).parent || node.__ngt_renderer__[1 /* NgtRendererClassId.parent */];
1699
- // rawValue
1677
+ // [rawValue]
1700
1678
  if (getLocalState(node).isRaw && name === SPECIAL_PROPERTIES.VALUE) {
1701
1679
  node.__ngt_renderer__[10 /* NgtRendererClassId.rawValue */] = value;
1702
1680
  if (parent)
1703
1681
  attachThreeChild(parent, node);
1704
1682
  return;
1705
1683
  }
1706
- // attach
1684
+ // [attach]
1707
1685
  if (name === SPECIAL_PROPERTIES.ATTACH) {
1708
1686
  getLocalState(node).attach = Array.isArray(value) ? value.map((v) => v.toString()) : value;
1709
1687
  if (parent)
@@ -1772,11 +1750,10 @@ class NgtRendererStore {
1772
1750
  return null;
1773
1751
  }
1774
1752
  getCreationState() {
1775
- var _a, _b;
1753
+ var _a;
1776
1754
  const injectedArgs = ((_a = this.firstNonInjectedDirective(NgtArgs)) === null || _a === void 0 ? void 0 : _a.args) || [];
1777
- const injectedRef = ((_b = this.firstNonInjectedDirective(NgtRef)) === null || _b === void 0 ? void 0 : _b.ref) || null;
1778
1755
  const store = this.tryGetPortalStore();
1779
- return { injectedArgs, injectedRef, store };
1756
+ return { injectedArgs, store };
1780
1757
  }
1781
1758
  destroy(node, parent) {
1782
1759
  const state = node.__ngt_renderer__;
@@ -1993,7 +1970,7 @@ class NgtRenderer {
1993
1970
  if (name === SPECIAL_DOM_TAG.NGT_VALUE) {
1994
1971
  return this.store.createNode('three', Object.assign({ __ngt_renderer__: { rawValue: undefined } }, { __ngt__: { isRaw: true } }));
1995
1972
  }
1996
- const { injectedArgs, injectedRef, store } = this.store.getCreationState();
1973
+ const { injectedArgs, store } = this.store.getCreationState();
1997
1974
  // handle primitive
1998
1975
  if (name === SPECIAL_DOM_TAG.NGT_PRIMITIVE) {
1999
1976
  if (!injectedArgs[0])
@@ -2006,10 +1983,7 @@ class NgtRenderer {
2006
1983
  }
2007
1984
  if (!localState.store)
2008
1985
  localState.store = store;
2009
- const primitiveNode = this.store.createNode('three', object);
2010
- if (injectedRef)
2011
- injectedRef.nativeElement = primitiveNode;
2012
- return primitiveNode;
1986
+ return this.store.createNode('three', object);
2013
1987
  }
2014
1988
  const threeTag = name.startsWith('ngt') ? name.slice(4) : name;
2015
1989
  const threeName = kebabToPascal(threeTag);
@@ -2025,10 +1999,6 @@ class NgtRenderer {
2025
1999
  else if (is.material(instance)) {
2026
2000
  localState.attach = ['material'];
2027
2001
  }
2028
- if (injectedRef) {
2029
- injectedRef.nativeElement = node;
2030
- node.__ngt_renderer__[11 /* NgtRendererClassId.ref */] = injectedRef;
2031
- }
2032
2002
  return node;
2033
2003
  }
2034
2004
  const domNode = this.store.createNode('dom', element);
@@ -2644,6 +2614,26 @@ function injectNgtRef(initialValue = null) {
2644
2614
  return Object.assign(ref, { subscribe, $, children$, useCDR: (cdr) => void cdRefs.push(cdr) });
2645
2615
  }
2646
2616
 
2617
+ function createRunInContext() {
2618
+ const nodeInjector = inject(Injector);
2619
+ const envInjector = inject(EnvironmentInjector);
2620
+ const originalGet = envInjector.get;
2621
+ return (cb) => {
2622
+ envInjector.get = (...args) => {
2623
+ try {
2624
+ const fromNodeInjector = nodeInjector.get(...args);
2625
+ if (fromNodeInjector)
2626
+ return fromNodeInjector;
2627
+ return originalGet(...args);
2628
+ }
2629
+ catch (e) {
2630
+ return originalGet(...args);
2631
+ }
2632
+ };
2633
+ return envInjector.runInContext(cb);
2634
+ };
2635
+ }
2636
+
2647
2637
  class NgtRepeat extends NgForOf {
2648
2638
  set ngForRepeat(count) {
2649
2639
  this.ngForOf = Number.isInteger(count) ? Array.from({ length: count }, (_, i) => i) : [];
@@ -2923,5 +2913,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImpor
2923
2913
  * Generated bundle index. Do not edit.
2924
2914
  */
2925
2915
 
2926
- 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 };
2916
+ 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 };
2927
2917
  //# sourceMappingURL=angular-three.mjs.map