angular-three 1.10.2 → 2.0.0-beta.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.
Files changed (62) hide show
  1. package/README.md +89 -5
  2. package/esm2022/index.mjs +5 -7
  3. package/esm2022/lib/canvas.mjs +138 -99
  4. package/esm2022/lib/di/before-render.mjs +7 -10
  5. package/esm2022/lib/di/ref.mjs +38 -59
  6. package/esm2022/lib/directives/args.mjs +5 -8
  7. package/esm2022/lib/directives/common.mjs +20 -13
  8. package/esm2022/lib/directives/parent.mjs +5 -8
  9. package/esm2022/lib/{web → dom}/events.mjs +1 -1
  10. package/esm2022/lib/events.mjs +2 -2
  11. package/esm2022/lib/loader.mjs +58 -44
  12. package/esm2022/lib/loop.mjs +6 -8
  13. package/esm2022/lib/portal.mjs +76 -63
  14. package/esm2022/lib/renderer/provider.mjs +3 -2
  15. package/esm2022/lib/renderer/renderer.mjs +53 -52
  16. package/esm2022/lib/renderer/store.mjs +14 -19
  17. package/esm2022/lib/renderer/utils.mjs +27 -18
  18. package/esm2022/lib/routed-scene.mjs +12 -10
  19. package/esm2022/lib/stores/signal.store.mjs +60 -0
  20. package/esm2022/lib/stores/store.mjs +69 -48
  21. package/esm2022/lib/three-types.mjs +2 -0
  22. package/esm2022/lib/types.mjs +1 -1
  23. package/esm2022/lib/utils/apply-props.mjs +11 -7
  24. package/esm2022/lib/utils/attach.mjs +1 -1
  25. package/esm2022/lib/utils/instance.mjs +14 -14
  26. package/esm2022/lib/utils/safe-detect-changes.mjs +1 -1
  27. package/fesm2022/angular-three.mjs +1673 -1744
  28. package/fesm2022/angular-three.mjs.map +1 -1
  29. package/index.d.ts +4 -6
  30. package/lib/canvas.d.ts +11 -20
  31. package/lib/di/before-render.d.ts +5 -1
  32. package/lib/di/ref.d.ts +5 -11
  33. package/lib/directives/args.d.ts +6 -6
  34. package/lib/directives/common.d.ts +1 -4
  35. package/lib/directives/parent.d.ts +1 -1
  36. package/lib/{web → dom}/events.d.ts +2 -2
  37. package/lib/events.d.ts +3 -3
  38. package/lib/loader.d.ts +6 -2
  39. package/lib/loop.d.ts +4 -4
  40. package/lib/portal.d.ts +11 -18
  41. package/lib/renderer/renderer.d.ts +7 -9
  42. package/lib/renderer/store.d.ts +3 -5
  43. package/lib/renderer/utils.d.ts +6 -4
  44. package/lib/routed-scene.d.ts +4 -2
  45. package/lib/stores/signal.store.d.ts +19 -0
  46. package/lib/stores/store.d.ts +4 -7
  47. package/lib/three-types.d.ts +306 -0
  48. package/lib/types.d.ts +22 -25
  49. package/lib/utils/attach.d.ts +2 -2
  50. package/lib/utils/instance.d.ts +1 -1
  51. package/package.json +6 -7
  52. package/plugin/package.json +1 -1
  53. package/plugin/src/generators/init/init.d.ts +1 -1
  54. package/plugin/src/generators/init/init.js +1 -1
  55. package/esm2022/lib/di/destroy.mjs +0 -23
  56. package/esm2022/lib/di/run-in-context.mjs +0 -40
  57. package/esm2022/lib/pipes/push.mjs +0 -50
  58. package/esm2022/lib/stores/rx-store.mjs +0 -108
  59. package/lib/di/destroy.d.ts +0 -9
  60. package/lib/di/run-in-context.d.ts +0 -6
  61. package/lib/pipes/push.d.ts +0 -16
  62. package/lib/stores/rx-store.d.ts +0 -42
@@ -0,0 +1,306 @@
1
+ import * as THREE from 'three';
2
+ import type { NgtInjectedRef } from './di/ref';
3
+ import type { NgtAfterAttach, NgtAnyRecord, NgtAttachFunction, NgtBeforeRenderEvent, NgtEventHandlers, NgtInstanceNode } from './types';
4
+ export type NgtNonFunctionKeys<T> = {
5
+ [K in keyof T]-?: T[K] extends Function ? never : K;
6
+ }[keyof T];
7
+ export type NgtOverwrite<T, O> = Omit<T, NgtNonFunctionKeys<O>> & O;
8
+ export type NgtExtendedColors<T> = {
9
+ [K in keyof T]: T[K] extends THREE.Color | undefined ? THREE.ColorRepresentation : T[K];
10
+ };
11
+ /**
12
+ * If **T** contains a constructor, @see ConstructorParameters must be used, otherwise **T**.
13
+ */
14
+ type NgtArgs<T> = T extends new (...args: any) => any ? ConstructorParameters<T> : T;
15
+ export type NgtEuler = THREE.Euler | Parameters<THREE.Euler['set']>;
16
+ export type NgtMatrix4 = THREE.Matrix4 | Parameters<THREE.Matrix4['set']> | Readonly<THREE.Matrix4['set']>;
17
+ /**
18
+ * Turn an implementation of THREE.Vector in to the type that an r3f component would accept as a prop.
19
+ */
20
+ type NgtVectorLike<VectorClass extends THREE.Vector> = VectorClass | Parameters<VectorClass['set']> | Readonly<Parameters<VectorClass['set']>> | Parameters<VectorClass['setScalar']>[0];
21
+ export type NgtVector2 = NgtVectorLike<THREE.Vector2>;
22
+ export type NgtVector3 = NgtVectorLike<THREE.Vector3>;
23
+ export type NgtVector4 = NgtVectorLike<THREE.Vector4>;
24
+ export type NgtLayers = THREE.Layers | Parameters<THREE.Layers['set']>[0];
25
+ export type NgtQuaternion = THREE.Quaternion | Parameters<THREE.Quaternion['set']>;
26
+ export interface NgtNodeEventMap<TOriginal> {
27
+ afterAttach: NgtAfterAttach<NgtInstanceNode, TOriginal>;
28
+ afterUpdate: TOriginal;
29
+ beforeRender: NgtBeforeRenderEvent<TOriginal>;
30
+ }
31
+ export type NgtNodeElement<TOriginal, TConstructor> = {
32
+ attach: string | string[] | NgtAttachFunction;
33
+ ref: NgtInjectedRef<TOriginal>;
34
+ addEventListener<TEventKey extends keyof NgtNodeEventMap<TOriginal>>(type: TEventKey, listener: (this: NgtNodeElement<TOriginal, TConstructor>, ev: NgtNodeEventMap<TOriginal>[TEventKey]) => any): void;
35
+ removeEventListener<TEventKey extends keyof NgtNodeEventMap<TOriginal>>(type: TEventKey, listener: (this: NgtNodeElement<TOriginal, TConstructor>, ev: NgtNodeEventMap<TOriginal>[TEventKey]) => any): void;
36
+ __ngt_args__: NgtArgs<TConstructor>;
37
+ };
38
+ export type NgtNode<TOriginal, TConstructor, TNoEvent = NoEvent<TOriginal>> = NgtExtendedColors<NgtOverwrite<Partial<TNoEvent>, NgtNodeElement<TOriginal, TConstructor>>>;
39
+ export type NgtObject3DEventsMap = {
40
+ [TEvent in keyof NgtEventHandlers]-?: Parameters<NonNullable<NgtEventHandlers[TEvent]>>[0];
41
+ };
42
+ export type NgtObject3DNode<TOriginal, TConstructor, TNoEvent = NoEvent<TOriginal>> = NgtOverwrite<NgtNode<TOriginal, TConstructor, TNoEvent>, {
43
+ position: NgtVector3;
44
+ up: NgtVector3;
45
+ scale: NgtVector3;
46
+ rotation: NgtEuler;
47
+ matrix: NgtMatrix4;
48
+ quaternion: NgtQuaternion;
49
+ layers: NgtLayers;
50
+ dispose: (() => void) | null;
51
+ addEventListener<TEventKey extends keyof NgtObject3DEventsMap>(type: TEventKey, listener: (this: NgtObject3DNode<TOriginal, TConstructor>, ev: NgtObject3DEventsMap[TEventKey]) => any): void;
52
+ removeEventListener<TEventKey extends keyof NgtObject3DEventsMap>(type: TEventKey, listener: (this: NgtObject3DNode<TOriginal, TConstructor>, ev: NgtObject3DEventsMap[TEventKey]) => any): void;
53
+ }>;
54
+ type NoEvent<T> = Omit<T, 'addEventListener' | 'removeEventListener'>;
55
+ export type NgtGeometry<TGeometry extends THREE.BufferGeometry, TConstructor> = NgtNode<TGeometry, TConstructor>;
56
+ export type NgtMaterial<TMaterial extends THREE.Material, TConstructor> = NgtNode<TMaterial, TConstructor>;
57
+ export type NgtLight<T extends THREE.Light, P> = NgtObject3DNode<T, P>;
58
+ export type NgtObject3D = NgtObject3DNode<THREE.Object3D, typeof THREE.Object3D>;
59
+ export type NgtAudio = NgtObject3DNode<THREE.Audio, typeof THREE.Audio>;
60
+ export type NgtAudioListener = NgtObject3DNode<THREE.AudioListener, typeof THREE.AudioListener>;
61
+ export type NgtPositionalAudio = NgtObject3DNode<THREE.PositionalAudio, typeof THREE.PositionalAudio>;
62
+ export type NgtMesh = NgtObject3DNode<THREE.Mesh, typeof THREE.Mesh>;
63
+ export type NgtInstancedMesh = NgtObject3DNode<THREE.InstancedMesh, typeof THREE.InstancedMesh>;
64
+ export type NgtScene = NgtObject3DNode<THREE.Scene, typeof THREE.Scene>;
65
+ export type NgtSprite = NgtObject3DNode<THREE.Sprite, typeof THREE.Sprite>;
66
+ export type NgtLOD = NgtObject3DNode<THREE.LOD, typeof THREE.LOD>;
67
+ export type NgtSkinnedMesh = NgtObject3DNode<THREE.SkinnedMesh, typeof THREE.SkinnedMesh>;
68
+ export type NgtSkeleton = NgtObject3DNode<THREE.Skeleton, typeof THREE.Skeleton>;
69
+ export type NgtBone = NgtObject3DNode<THREE.Bone, typeof THREE.Bone>;
70
+ export type NgtLine = NgtObject3DNode<THREE.Line, typeof THREE.Line>;
71
+ export type NgtLineSegments = NgtObject3DNode<THREE.LineSegments, typeof THREE.LineSegments>;
72
+ export type NgtLineLoop = NgtObject3DNode<THREE.LineLoop, typeof THREE.LineLoop>;
73
+ export type NgtPoints = NgtObject3DNode<THREE.Points, typeof THREE.Points>;
74
+ export type NgtGroup = NgtObject3DNode<THREE.Group, typeof THREE.Group>;
75
+ export type NgtCameraNode = NgtObject3DNode<THREE.Camera, typeof THREE.Camera>;
76
+ export type NgtPerspectiveCamera = NgtObject3DNode<THREE.PerspectiveCamera, typeof THREE.PerspectiveCamera>;
77
+ export type NgtOrthographicCamera = NgtObject3DNode<THREE.OrthographicCamera, typeof THREE.OrthographicCamera>;
78
+ export type NgtCubeCamera = NgtObject3DNode<THREE.CubeCamera, typeof THREE.CubeCamera>;
79
+ export type NgtArrayCamera = NgtObject3DNode<THREE.ArrayCamera, typeof THREE.ArrayCamera>;
80
+ export type NgtInstancedBufferGeometry = NgtGeometry<THREE.InstancedBufferGeometry, typeof THREE.InstancedBufferGeometry>;
81
+ export type NgtBufferGeometry = NgtGeometry<THREE.BufferGeometry, typeof THREE.BufferGeometry>;
82
+ export type NgtWireframeGeometry = NgtGeometry<THREE.WireframeGeometry, typeof THREE.WireframeGeometry>;
83
+ export type NgtTetrahedronGeometry = NgtGeometry<THREE.TetrahedronGeometry, typeof THREE.TetrahedronGeometry>;
84
+ export type NgtOctahedronGeometry = NgtGeometry<THREE.OctahedronGeometry, typeof THREE.OctahedronGeometry>;
85
+ export type NgtIcosahedronGeometry = NgtGeometry<THREE.IcosahedronGeometry, typeof THREE.IcosahedronGeometry>;
86
+ export type NgtDodecahedronGeometry = NgtGeometry<THREE.DodecahedronGeometry, typeof THREE.DodecahedronGeometry>;
87
+ export type NgtPolyhedronGeometry = NgtGeometry<THREE.PolyhedronGeometry, typeof THREE.PolyhedronGeometry>;
88
+ export type NgtTubeGeometry = NgtGeometry<THREE.TubeGeometry, typeof THREE.TubeGeometry>;
89
+ export type NgtTorusKnotGeometry = NgtGeometry<THREE.TorusKnotGeometry, typeof THREE.TorusKnotGeometry>;
90
+ export type NgtTorusGeometry = NgtGeometry<THREE.TorusGeometry, typeof THREE.TorusGeometry>;
91
+ export type NgtSphereGeometry = NgtGeometry<THREE.SphereGeometry, typeof THREE.SphereGeometry>;
92
+ export type NgtRingGeometry = NgtGeometry<THREE.RingGeometry, typeof THREE.RingGeometry>;
93
+ export type NgtPlaneGeometry = NgtGeometry<THREE.PlaneGeometry, typeof THREE.PlaneGeometry>;
94
+ export type NgtLatheGeometry = NgtGeometry<THREE.LatheGeometry, typeof THREE.LatheGeometry>;
95
+ export type NgtShapeGeometry = NgtGeometry<THREE.ShapeGeometry, typeof THREE.ShapeGeometry>;
96
+ export type NgtExtrudeGeometry = NgtGeometry<THREE.ExtrudeGeometry, typeof THREE.ExtrudeGeometry>;
97
+ export type NgtEdgesGeometry = NgtGeometry<THREE.EdgesGeometry, typeof THREE.EdgesGeometry>;
98
+ export type NgtConeGeometry = NgtGeometry<THREE.ConeGeometry, typeof THREE.ConeGeometry>;
99
+ export type NgtCylinderGeometry = NgtGeometry<THREE.CylinderGeometry, typeof THREE.CylinderGeometry>;
100
+ export type NgtCircleGeometry = NgtGeometry<THREE.CircleGeometry, typeof THREE.CircleGeometry>;
101
+ export type NgtBoxGeometry = NgtGeometry<THREE.BoxGeometry, typeof THREE.BoxGeometry>;
102
+ export type NgtCapsuleGeometry = NgtGeometry<THREE.CapsuleGeometry, typeof THREE.CapsuleGeometry>;
103
+ export type NgtShadowMaterial = NgtMaterial<THREE.ShadowMaterial, [THREE.ShaderMaterialParameters]>;
104
+ export type NgtSpriteMaterial = NgtMaterial<THREE.SpriteMaterial, [THREE.SpriteMaterialParameters]>;
105
+ export type NgtRawShaderMaterial = NgtMaterial<THREE.RawShaderMaterial, [THREE.ShaderMaterialParameters]>;
106
+ export type NgtShaderMaterial = NgtMaterial<THREE.ShaderMaterial, [THREE.ShaderMaterialParameters]>;
107
+ export type NgtPointsMaterial = NgtMaterial<THREE.PointsMaterial, [THREE.PointsMaterialParameters]>;
108
+ export type NgtMeshPhysicalMaterial = NgtMaterial<THREE.MeshPhysicalMaterial, [THREE.MeshPhysicalMaterialParameters]>;
109
+ export type NgtMeshStandardMaterial = NgtMaterial<THREE.MeshStandardMaterial, [THREE.MeshStandardMaterialParameters]>;
110
+ export type NgtMeshPhongMaterial = NgtMaterial<THREE.MeshPhongMaterial, [THREE.MeshPhongMaterialParameters]>;
111
+ export type NgtMeshToonMaterial = NgtMaterial<THREE.MeshToonMaterial, [THREE.MeshToonMaterialParameters]>;
112
+ export type NgtMeshNormalMaterial = NgtMaterial<THREE.MeshNormalMaterial, [THREE.MeshNormalMaterialParameters]>;
113
+ export type NgtMeshLambertMaterial = NgtMaterial<THREE.MeshLambertMaterial, [THREE.MeshLambertMaterialParameters]>;
114
+ export type NgtMeshDepthMaterial = NgtMaterial<THREE.MeshDepthMaterial, [THREE.MeshDepthMaterialParameters]>;
115
+ export type NgtMeshDistanceMaterial = NgtMaterial<THREE.MeshDistanceMaterial, [THREE.MeshDistanceMaterialParameters]>;
116
+ export type NgtMeshBasicMaterial = NgtMaterial<THREE.MeshBasicMaterial, [THREE.MeshBasicMaterialParameters]>;
117
+ export type NgtMeshMatcapMaterial = NgtMaterial<THREE.MeshMatcapMaterial, [THREE.MeshMatcapMaterialParameters]>;
118
+ export type NgtLineDashedMaterial = NgtMaterial<THREE.LineDashedMaterial, [THREE.LineDashedMaterialParameters]>;
119
+ export type NgtLineBasicMaterial = NgtMaterial<THREE.LineBasicMaterial, [THREE.LineBasicMaterialParameters]>;
120
+ export type NgtPrimitive = NgtAnyRecord;
121
+ export type NgtValue = NgtNode<{
122
+ rawValue: any;
123
+ }, {}>;
124
+ export type NgtLightShadow = NgtNode<THREE.LightShadow, typeof THREE.LightShadow>;
125
+ export type NgtSpotLightShadow = NgtNode<THREE.SpotLightShadow, typeof THREE.SpotLightShadow>;
126
+ export type NgtDirectionalLightShadow = NgtNode<THREE.DirectionalLightShadow, typeof THREE.DirectionalLightShadow>;
127
+ export type NgtSpotLight = NgtLight<THREE.SpotLight, typeof THREE.SpotLight>;
128
+ export type NgtPointLight = NgtLight<THREE.PointLight, typeof THREE.PointLight>;
129
+ export type NgtRectAreaLight = NgtLight<THREE.RectAreaLight, typeof THREE.RectAreaLight>;
130
+ export type NgtHemisphereLight = NgtLight<THREE.HemisphereLight, typeof THREE.HemisphereLight>;
131
+ export type NgtDirectionalLight = NgtLight<THREE.DirectionalLight, typeof THREE.DirectionalLight>;
132
+ export type NgtAmbientLight = NgtLight<THREE.AmbientLight, typeof THREE.AmbientLight>;
133
+ export type NgtAmbientLightProbe = NgtLight<THREE.AmbientLightProbe, typeof THREE.AmbientLightProbe>;
134
+ export type NgtHemisphereLightProbe = NgtLight<THREE.HemisphereLightProbe, typeof THREE.HemisphereLightProbe>;
135
+ export type NgtLightProbe = NgtLight<THREE.LightProbe, typeof THREE.LightProbe>;
136
+ export type NgtSpotLightHelper = NgtObject3DNode<THREE.SpotLightHelper, typeof THREE.SpotLightHelper>;
137
+ export type NgtSkeletonHelper = NgtObject3DNode<THREE.SkeletonHelper, typeof THREE.SkeletonHelper>;
138
+ export type NgtPointLightHelper = NgtObject3DNode<THREE.PointLightHelper, typeof THREE.PointLightHelper>;
139
+ export type NgtHemisphereLightHelper = NgtObject3DNode<THREE.HemisphereLightHelper, typeof THREE.HemisphereLightHelper>;
140
+ export type NgtGridHelper = NgtObject3DNode<THREE.GridHelper, typeof THREE.GridHelper>;
141
+ export type NgtPolarGridHelper = NgtObject3DNode<THREE.PolarGridHelper, typeof THREE.PolarGridHelper>;
142
+ export type NgtDirectionalLightHelper = NgtObject3DNode<THREE.DirectionalLightHelper, typeof THREE.DirectionalLightHelper>;
143
+ export type NgtCameraHelper = NgtObject3DNode<THREE.CameraHelper, typeof THREE.CameraHelper>;
144
+ export type NgtBoxHelper = NgtObject3DNode<THREE.BoxHelper, typeof THREE.BoxHelper>;
145
+ export type NgtBox3Helper = NgtObject3DNode<THREE.Box3Helper, typeof THREE.Box3Helper>;
146
+ export type NgtPlaneHelper = NgtObject3DNode<THREE.PlaneHelper, typeof THREE.PlaneHelper>;
147
+ export type NgtArrowHelper = NgtObject3DNode<THREE.ArrowHelper, typeof THREE.ArrowHelper>;
148
+ export type NgtAxesHelper = NgtObject3DNode<THREE.AxesHelper, typeof THREE.AxesHelper>;
149
+ export type NgtTexture = NgtNode<THREE.Texture, typeof THREE.Texture>;
150
+ export type NgtVideoTexture = NgtNode<THREE.VideoTexture, typeof THREE.VideoTexture>;
151
+ export type NgtDataTexture = NgtNode<THREE.DataTexture, typeof THREE.DataTexture>;
152
+ export type NgtData3DTexture = NgtNode<THREE.Data3DTexture, typeof THREE.Data3DTexture>;
153
+ export type NgtCompressedTexture = NgtNode<THREE.CompressedTexture, typeof THREE.CompressedTexture>;
154
+ export type NgtCubeTexture = NgtNode<THREE.CubeTexture, typeof THREE.CubeTexture>;
155
+ export type NgtCanvasTexture = NgtNode<THREE.CanvasTexture, typeof THREE.CanvasTexture>;
156
+ export type NgtDepthTexture = NgtNode<THREE.DepthTexture, typeof THREE.DepthTexture>;
157
+ export type NgtRaycaster = NgtNode<THREE.Raycaster, typeof THREE.Raycaster>;
158
+ export type NgtVector2Node = NgtNode<THREE.Vector2, typeof THREE.Vector2>;
159
+ export type NgtVector3Node = NgtNode<THREE.Vector3, typeof THREE.Vector3>;
160
+ export type NgtVector4Node = NgtNode<THREE.Vector4, typeof THREE.Vector4>;
161
+ export type NgtEulerNode = NgtNode<THREE.Euler, typeof THREE.Euler>;
162
+ export type NgtMatrix3Node = NgtNode<THREE.Matrix3, typeof THREE.Matrix3>;
163
+ export type NgtMatrix4Node = NgtNode<THREE.Matrix4, typeof THREE.Matrix4>;
164
+ export type NgtQuaternionNode = NgtNode<THREE.Quaternion, typeof THREE.Quaternion>;
165
+ export type NgtBufferAttribute = NgtNode<THREE.BufferAttribute, typeof THREE.BufferAttribute>;
166
+ export type NgtFloat16BufferAttribute = NgtNode<THREE.Float16BufferAttribute, typeof THREE.Float16BufferAttribute>;
167
+ export type NgtFloat32BufferAttribute = NgtNode<THREE.Float32BufferAttribute, typeof THREE.Float32BufferAttribute>;
168
+ export type NgtFloat64BufferAttribute = NgtNode<THREE.Float64BufferAttribute, typeof THREE.Float64BufferAttribute>;
169
+ export type NgtInt8BufferAttribute = NgtNode<THREE.Int8BufferAttribute, typeof THREE.Int8BufferAttribute>;
170
+ export type NgtInt16BufferAttribute = NgtNode<THREE.Int16BufferAttribute, typeof THREE.Int16BufferAttribute>;
171
+ export type NgtInt32BufferAttribute = NgtNode<THREE.Int32BufferAttribute, typeof THREE.Int32BufferAttribute>;
172
+ export type NgtUint8BufferAttribute = NgtNode<THREE.Uint8BufferAttribute, typeof THREE.Uint8BufferAttribute>;
173
+ export type NgtUint16BufferAttribute = NgtNode<THREE.Uint16BufferAttribute, typeof THREE.Uint16BufferAttribute>;
174
+ export type NgtUint32BufferAttribute = NgtNode<THREE.Uint32BufferAttribute, typeof THREE.Uint32BufferAttribute>;
175
+ export type NgtInstancedBufferAttribute = NgtNode<THREE.InstancedBufferAttribute, typeof THREE.InstancedBufferAttribute>;
176
+ export type NgtColor = NgtNode<THREE.Color, THREE.ColorRepresentation>;
177
+ export type NgtFog = NgtNode<THREE.Fog, typeof THREE.Fog>;
178
+ export type NgtFogExp2 = NgtNode<THREE.FogExp2, typeof THREE.FogExp2>;
179
+ export type NgtShape = NgtNode<THREE.Shape, typeof THREE.Shape>;
180
+ export interface ThreeElements {
181
+ 'ngt-object3D': NgtObject3D;
182
+ 'ngt-audio': NgtAudio;
183
+ 'ngt-audio-listener': NgtAudioListener;
184
+ 'ngt-positional-audio': NgtPositionalAudio;
185
+ 'ngt-mesh': NgtMesh;
186
+ 'ngt-instanced-mesh': NgtInstancedMesh;
187
+ 'ngt-scene': NgtScene;
188
+ 'ngt-sprite': NgtSprite;
189
+ 'ngt-lOD': NgtLOD;
190
+ 'ngt-skinned-mesh': NgtSkinnedMesh;
191
+ 'ngt-skeleton': NgtSkeleton;
192
+ 'ngt-bone': NgtBone;
193
+ 'ngt-line': NgtLine;
194
+ 'ngt-line-segments': NgtLineSegments;
195
+ 'ngt-line-loop': NgtLineLoop;
196
+ 'ngt-points': NgtPoints;
197
+ 'ngt-group': NgtGroup;
198
+ 'ngt-camera': NgtCameraNode;
199
+ 'ngt-perspective-camera': NgtPerspectiveCamera;
200
+ 'ngt-orthographic-camera': NgtOrthographicCamera;
201
+ 'ngt-cube-camera': NgtCubeCamera;
202
+ 'ngt-array-camera': NgtArrayCamera;
203
+ 'ngt-instanced-buffer-geometry': NgtInstancedBufferGeometry;
204
+ 'ngt-buffer-geometry': NgtBufferGeometry;
205
+ 'ngt-wireframe-geometry': NgtWireframeGeometry;
206
+ 'ngt-tetrahedron-geometry': NgtTetrahedronGeometry;
207
+ 'ngt-octahedron-geometry': NgtOctahedronGeometry;
208
+ 'ngt-icosahedron-geometry': NgtIcosahedronGeometry;
209
+ 'ngt-polyhedron-geometry': NgtPolyhedronGeometry;
210
+ 'ngt-dodecahedron-geometry': NgtDodecahedronGeometry;
211
+ 'ngt-tube-geometry': NgtTubeGeometry;
212
+ 'ngt-torus-knot-geometry': NgtTorusKnotGeometry;
213
+ 'ngt-torus-geometry': NgtTorusGeometry;
214
+ 'ngt-sphere-geometry': NgtSphereGeometry;
215
+ 'ngt-ring-geometry': NgtRingGeometry;
216
+ 'ngt-plane-geometry': NgtPlaneGeometry;
217
+ 'ngt-lathe-geometry': NgtLatheGeometry;
218
+ 'ngt-shape-geometry': NgtShapeGeometry;
219
+ 'ngt-extrude-geometry': NgtExtrudeGeometry;
220
+ 'ngt-edges-geometry': NgtEdgesGeometry;
221
+ 'ngt-cone-geometry': NgtConeGeometry;
222
+ 'ngt-cylinder-geometry': NgtCylinderGeometry;
223
+ 'ngt-circle-geometry': NgtCircleGeometry;
224
+ 'ngt-box-geometry': NgtBoxGeometry;
225
+ 'ngt-capsule-geometry': NgtCapsuleGeometry;
226
+ 'ngt-shadow-material': NgtShadowMaterial;
227
+ 'ngt-sprite-material': NgtSpriteMaterial;
228
+ 'ngt-raw-shader-material': NgtRawShaderMaterial;
229
+ 'ngt-shader-material': NgtShaderMaterial;
230
+ 'ngt-points-material': NgtPointsMaterial;
231
+ 'ngt-mesh-physical-material': NgtMeshPhysicalMaterial;
232
+ 'ngt-mesh-standard-material': NgtMeshStandardMaterial;
233
+ 'ngt-mesh-phong-material': NgtMeshPhongMaterial;
234
+ 'ngt-mesh-toon-material': NgtMeshToonMaterial;
235
+ 'ngt-mesh-normal-material': NgtMeshNormalMaterial;
236
+ 'ngt-mesh-lambert-material': NgtMeshLambertMaterial;
237
+ 'ngt-mesh-depth-material': NgtMeshDepthMaterial;
238
+ 'ngt-mesh-distance-material': NgtMeshDistanceMaterial;
239
+ 'ngt-mesh-basic-material': NgtMeshBasicMaterial;
240
+ 'ngt-mesh-matcap-material': NgtMeshMatcapMaterial;
241
+ 'ngt-line-dashed-material': NgtLineDashedMaterial;
242
+ 'ngt-line-basic-material': NgtLineBasicMaterial;
243
+ 'ngt-primitive': NgtPrimitive;
244
+ 'ngt-value': NgtValue;
245
+ 'ngt-spot-light-shadow': NgtSpotLightShadow;
246
+ 'ngt-spot-light': NgtSpotLight;
247
+ 'ngt-point-light': NgtPointLight;
248
+ 'ngt-rect-area-light': NgtRectAreaLight;
249
+ 'ngt-hemisphere-light': NgtHemisphereLight;
250
+ 'ngt-directional-light-shadow': NgtDirectionalLightShadow;
251
+ 'ngt-directional-light': NgtDirectionalLight;
252
+ 'ngt-ambient-light': NgtAmbientLight;
253
+ 'ngt-light-shadow': NgtLightShadow;
254
+ 'ngt-ambient-light-probe': NgtAmbientLightProbe;
255
+ 'ngt-hemisphere-light-probe': NgtHemisphereLightProbe;
256
+ 'ngt-light-probe': NgtLightProbe;
257
+ 'ngt-spot-light-helper': NgtSpotLightHelper;
258
+ 'ngt-skeleton-helper': NgtSkeletonHelper;
259
+ 'ngt-point-light-helper': NgtPointLightHelper;
260
+ 'ngt-hemisphere-light-helper': NgtHemisphereLightHelper;
261
+ 'ngt-grid-helper': NgtGridHelper;
262
+ 'ngt-polar-grid-helper': NgtPolarGridHelper;
263
+ 'ngt-directional-light-helper': NgtDirectionalLightHelper;
264
+ 'ngt-camera-helper': NgtCameraHelper;
265
+ 'ngt-box-helper': NgtBoxHelper;
266
+ 'ngt-box3-helper': NgtBox3Helper;
267
+ 'ngt-plane-helper': NgtPlaneHelper;
268
+ 'ngt-arrow-helper': NgtArrowHelper;
269
+ 'ngt-axes-helper': NgtAxesHelper;
270
+ 'ngt-texture': NgtTexture;
271
+ 'ngt-video-texture': NgtVideoTexture;
272
+ 'ngt-data-texture': NgtDataTexture;
273
+ 'ngt-data3D-texture': NgtData3DTexture;
274
+ 'ngt-compressed-texture': NgtCompressedTexture;
275
+ 'ngt-cube-texture': NgtCubeTexture;
276
+ 'ngt-canvas-texture': NgtCanvasTexture;
277
+ 'ngt-depth-texture': NgtDepthTexture;
278
+ 'ngt-raycaster': NgtRaycaster;
279
+ 'ngt-vector2': NgtVector2Node;
280
+ 'ngt-vector3': NgtVector3Node;
281
+ 'ngt-vector4': NgtVector4Node;
282
+ 'ngt-euler': NgtEulerNode;
283
+ 'ngt-matrix3': NgtMatrix3Node;
284
+ 'ngt-matrix4': NgtMatrix4Node;
285
+ 'ngt-quaternion': NgtQuaternionNode;
286
+ 'ngt-buffer-attribute': NgtBufferAttribute;
287
+ 'ngt-float16-buffer-attribute': NgtFloat16BufferAttribute;
288
+ 'ngt-float32-buffer-attribute': NgtFloat32BufferAttribute;
289
+ 'ngt-float64-buffer-attribute': NgtFloat64BufferAttribute;
290
+ 'ngt-int8-buffer-attribute': NgtInt8BufferAttribute;
291
+ 'ngt-int16-buffer-attribute': NgtInt16BufferAttribute;
292
+ 'ngt-int32-buffer-attribute': NgtInt32BufferAttribute;
293
+ 'ngt-unit8-buffer-attribute': NgtUint8BufferAttribute;
294
+ 'ngt-unit16-buffer-attribute': NgtUint16BufferAttribute;
295
+ 'ngt-unit32-buffer-attribute': NgtUint32BufferAttribute;
296
+ 'ngt-instanced-buffer-attribute': NgtInstancedBufferAttribute;
297
+ 'ngt-color': NgtColor;
298
+ 'ngt-fog': NgtFog;
299
+ 'ngt-fog-exp2': NgtFogExp2;
300
+ 'ngt-shape': NgtShape;
301
+ }
302
+ declare global {
303
+ interface HTMLElementTagNameMap extends ThreeElements {
304
+ }
305
+ }
306
+ export {};
package/lib/types.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  /// <reference types="webxr" />
2
- import type { ElementRef, EventEmitter } from '@angular/core';
3
- import type { BehaviorSubject } from 'rxjs';
2
+ import type { ElementRef, EventEmitter, WritableSignal } from '@angular/core';
4
3
  import * as THREE from 'three';
5
- import type { NgtRxStore } from './stores/rx-store';
4
+ import type { NgtSignalStore } from './stores/signal.store';
6
5
  export type NgtAnyRecord = Record<string, any>;
7
6
  export type NgtProperties<T> = Pick<T, {
8
7
  [K in keyof T]: T[K] extends (_: any) => any ? never : K;
@@ -53,11 +52,11 @@ export type NgtCamera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
53
52
  export type NgtCameraManual = NgtCamera & {
54
53
  manual?: boolean;
55
54
  };
56
- export interface NgtIntersection extends THREE.Intersection {
55
+ export type NgtIntersection = THREE.Intersection & {
57
56
  /** The event source (the object which registered the handler) */
58
57
  eventObject: THREE.Object3D;
59
- }
60
- export interface NgtIntersectionEvent<TSourceEvent> extends NgtIntersection {
58
+ };
59
+ export type NgtIntersectionEvent<TSourceEvent> = NgtIntersection & {
61
60
  /** The event source (the object which registered the handler) */
62
61
  eventObject: THREE.Object3D;
63
62
  /** An array of intersections */
@@ -78,7 +77,7 @@ export interface NgtIntersectionEvent<TSourceEvent> extends NgtIntersection {
78
77
  nativeEvent: TSourceEvent;
79
78
  /** If the event was stopped by calling stopPropagation */
80
79
  stopped: boolean;
81
- }
80
+ };
82
81
  export type NgtThreeEvent<TEvent> = NgtIntersectionEvent<TEvent> & NgtProperties<TEvent>;
83
82
  export type NgtDomEvent = PointerEvent | MouseEvent | WheelEvent;
84
83
  export type NgtEventHandlers = {
@@ -99,8 +98,8 @@ export type NgtEventHandlers = {
99
98
  export type NgtEvents = {
100
99
  [TEvent in keyof NgtEventHandlers]-?: EventListener;
101
100
  };
102
- export type NgtFilterFunction = (items: THREE.Intersection[], store: NgtRxStore<NgtState>) => THREE.Intersection[];
103
- export type NgtComputeFunction = (event: NgtDomEvent, root: NgtRxStore<NgtState>, previous?: NgtRxStore<NgtState>) => void;
101
+ export type NgtFilterFunction = (items: THREE.Intersection[], store: NgtSignalStore<NgtState>) => THREE.Intersection[];
102
+ export type NgtComputeFunction = (event: NgtDomEvent, root: NgtSignalStore<NgtState>, previous?: NgtSignalStore<NgtState>) => void;
104
103
  export type NgtEventManager<TTarget> = {
105
104
  /** Determines if the event layer is active */
106
105
  enabled: boolean;
@@ -137,25 +136,25 @@ export type NgtBeforeRenderEvent<TObject extends NgtInstanceNode = NgtInstanceNo
137
136
  };
138
137
  export type NgtBeforeRenderRecord = {
139
138
  callback: (state: NgtRenderState) => void;
140
- store: NgtRxStore<NgtState>;
139
+ store: NgtSignalStore<NgtState>;
141
140
  priority?: number;
142
141
  };
143
142
  export type NgtInternalState = {
144
143
  active: boolean;
145
144
  priority: number;
146
145
  frames: number;
147
- lastEvent: NgtDomEvent | null;
146
+ lastEvent: ElementRef<NgtDomEvent | null>;
148
147
  interaction: THREE.Object3D[];
149
148
  hovered: Map<string, NgtThreeEvent<NgtDomEvent>>;
150
149
  subscribers: NgtBeforeRenderRecord[];
151
150
  capturedMap: Map<number, Map<THREE.Object3D, NgtPointerCaptureTarget>>;
152
151
  initialClick: [x: number, y: number];
153
152
  initialHits: THREE.Object3D[];
154
- subscribe: (callback: NgtBeforeRenderRecord['callback'], priority?: number, store?: NgtRxStore<NgtState>) => () => void;
153
+ subscribe: (callback: NgtBeforeRenderRecord['callback'], priority?: number, store?: NgtSignalStore<NgtState>) => () => void;
155
154
  };
156
155
  export type NgtState = {
157
- get: NgtRxStore<NgtState>['get'];
158
- set: NgtRxStore<NgtState>['set'];
156
+ get: NgtSignalStore<NgtState>['get'];
157
+ set: NgtSignalStore<NgtState>['set'];
159
158
  /** when all building blocks are initialized */
160
159
  ready: boolean;
161
160
  /** The instance of the renderer */
@@ -211,25 +210,23 @@ export type NgtState = {
211
210
  /** When the canvas was clicked but nothing was hit */
212
211
  onPointerMissed?: (event: MouseEvent) => void;
213
212
  /** If this state model is layerd (via createPortal) then this contains the previous layer */
214
- previousStore?: NgtRxStore<NgtState>;
213
+ previousStore?: NgtSignalStore<NgtState>;
215
214
  /** Internals */
216
215
  internal: NgtInternalState;
217
- addInteraction: (instance: THREE.Object3D) => void;
218
- removeInteraction: (uuid: string) => void;
219
216
  };
220
- export type NgtAttachFunction<TChild = any, TParent = any> = (parent: TParent, child: TChild, store: NgtRxStore<NgtState>) => void | (() => void);
217
+ export type NgtAttachFunction<TChild = any, TParent = any> = (parent: TParent, child: TChild, store: NgtSignalStore<NgtState>) => void | (() => void);
221
218
  export type NgtAfterAttach<TParent extends NgtInstanceNode = NgtInstanceNode, TChild extends NgtInstanceNode = NgtInstanceNode> = {
222
219
  parent: TParent;
223
220
  node: TChild;
224
221
  };
225
222
  export type NgtInstanceLocalState = {
226
223
  /** the state getter of the canvas that the instance is being rendered to */
227
- store: NgtRxStore<NgtState>;
228
- nonObjects: BehaviorSubject<NgtInstanceNode[]>;
229
- objects: BehaviorSubject<NgtInstanceNode[]>;
224
+ store: NgtSignalStore<NgtState>;
225
+ nonObjects: WritableSignal<NgtInstanceNode[]>;
226
+ objects: WritableSignal<NgtInstanceNode[]>;
230
227
  add: (instance: NgtInstanceNode, type: 'objects' | 'nonObjects') => void;
231
228
  remove: (instance: NgtInstanceNode, type: 'objects' | 'nonObjects') => void;
232
- parent: NgtInstanceNode | null;
229
+ parent: WritableSignal<NgtInstanceNode | null>;
233
230
  primitive?: boolean;
234
231
  eventCount: number;
235
232
  handlers: Partial<NgtEventHandlers>;
@@ -248,7 +245,7 @@ export type NgtGLRenderer = {
248
245
  render: (scene: THREE.Scene, camera: THREE.Camera) => void;
249
246
  };
250
247
  export type NgtGLOptions = NgtGLRenderer | ((canvas: HTMLCanvasElement) => NgtGLRenderer) | Partial<NgtProperties<THREE.WebGLRenderer> | THREE.WebGLRendererParameters> | undefined;
251
- export interface NgtObjectMap {
248
+ export type NgtObjectMap = {
252
249
  nodes: {
253
250
  [name: string]: THREE.Object3D;
254
251
  };
@@ -256,7 +253,7 @@ export interface NgtObjectMap {
256
253
  [name: string]: THREE.Material;
257
254
  };
258
255
  [key: string]: any;
259
- }
256
+ };
260
257
  export type NgtCanvasInputs = {
261
258
  /** A threejs renderer instance or props that go into the default renderer */
262
259
  gl?: NgtGLOptions;
@@ -300,7 +297,7 @@ export type NgtCanvasInputs = {
300
297
  manual?: boolean;
301
298
  };
302
299
  /** An R3F event manager to manage elements' pointer events */
303
- events?: (store: NgtRxStore<NgtState>) => NgtEventManager<HTMLElement>;
300
+ events?: (store: NgtSignalStore<NgtState>) => NgtEventManager<HTMLElement>;
304
301
  /** The target where events are being subscribed to, default: the div that wraps canvas */
305
302
  eventSource?: HTMLElement | ElementRef<HTMLElement>;
306
303
  /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
@@ -1,9 +1,9 @@
1
- import { NgtRxStore } from '../stores/rx-store';
1
+ import { NgtSignalStore } from '../stores/signal.store';
2
2
  import type { NgtAnyRecord, NgtAttachFunction, NgtState } from '../types';
3
3
  export declare function attach(object: NgtAnyRecord, value: unknown, paths?: string[]): void;
4
4
  export declare function detach(parent: NgtAnyRecord, child: NgtAnyRecord, attachProp: string[] | NgtAttachFunction): void;
5
5
  export declare function createAttachFunction<TParent = any, TChild = any>(cb: (params: {
6
6
  parent: TParent;
7
7
  child: TChild;
8
- store: NgtRxStore<NgtState>;
8
+ store: NgtSignalStore<NgtState>;
9
9
  }) => (() => void) | void): NgtAttachFunction<TChild, TParent>;
@@ -1,4 +1,4 @@
1
1
  import type { NgtAnyRecord, NgtInstanceLocalState, NgtInstanceNode } from '../types';
2
2
  export declare function getLocalState<TInstance extends object = NgtAnyRecord>(obj: TInstance | undefined): NgtInstanceLocalState;
3
3
  export declare function invalidateInstance<TInstance extends object>(instance: TInstance): void;
4
- export declare function prepare<TInstance extends object = NgtAnyRecord>(object: TInstance | (() => TInstance), localState?: Partial<NgtInstanceLocalState>): NgtInstanceNode<TInstance>;
4
+ export declare function prepare<TInstance extends object = NgtAnyRecord>(object: TInstance, localState?: Partial<NgtInstanceLocalState>): NgtInstanceNode<TInstance>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "angular-three",
3
- "version": "1.10.2",
3
+ "version": "2.0.0-beta.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -21,15 +21,14 @@
21
21
  ],
22
22
  "license": "MIT",
23
23
  "peerDependencies": {
24
- "@angular/common": "^15.1.0 || ^16.0.0",
25
- "@angular/core": "^15.1.0 || 16.0.0",
24
+ "@angular/common": "^16.0.0",
25
+ "@angular/core": "^16.0.0",
26
26
  "three": "^0.148.0 || ^0.149.0 || ^0.150.0 || ^0.151.0 || ^0.152.0",
27
- "rxjs": "7.8.0",
28
- "@angular/router": "16.0.0"
27
+ "@angular/router": "16.0.0",
28
+ "rxjs": "7.8.0"
29
29
  },
30
30
  "dependencies": {
31
- "ngx-resize": "^1.0.0",
32
- "@rx-angular/state": "^14.0.0",
31
+ "ngx-resize": "^2.0.0",
33
32
  "tslib": "^2.3.0",
34
33
  "@nx/devkit": "^16.0.0",
35
34
  "nx": "^16.0.0"
@@ -5,5 +5,5 @@
5
5
  },
6
6
  "main": "./src/index.js",
7
7
  "types": "./src/index.d.ts",
8
- "version": "1.10.2"
8
+ "version": "2.0.0-beta.0"
9
9
  }
@@ -1,5 +1,5 @@
1
1
  import { Tree } from '@nx/devkit';
2
- export declare const ANGULAR_THREE_VERSION = "^1.0.0";
2
+ export declare const ANGULAR_THREE_VERSION = "^2.0.0";
3
3
  export declare const THREE_VERSION = "^0.152.0";
4
4
  export declare const THREE_TYPE_VERSION = "^0.152.0";
5
5
  export default function (tree: Tree): Promise<() => void>;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.THREE_TYPE_VERSION = exports.THREE_VERSION = exports.ANGULAR_THREE_VERSION = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- exports.ANGULAR_THREE_VERSION = '^1.0.0';
5
+ exports.ANGULAR_THREE_VERSION = '^2.0.0';
6
6
  exports.THREE_VERSION = '^0.152.0';
7
7
  exports.THREE_TYPE_VERSION = '^0.152.0';
8
8
  async function default_1(tree) {
@@ -1,23 +0,0 @@
1
- import { ChangeDetectorRef, inject } from '@angular/core';
2
- import { ReplaySubject } from 'rxjs';
3
- /**
4
- * A utility injection fn that can be used in other injection fn to provide the destroy capability.
5
- */
6
- export function injectNgtDestroy(cb) {
7
- try {
8
- const cdr = inject(ChangeDetectorRef);
9
- const destroy$ = new ReplaySubject();
10
- queueMicrotask(() => {
11
- cdr.onDestroy(() => {
12
- destroy$.next();
13
- destroy$.complete();
14
- cb?.();
15
- });
16
- });
17
- return { destroy$, cdr };
18
- }
19
- catch (e) {
20
- throw new Error(`[NGT] injectNgtDestroy is being called outside of Constructor Context`);
21
- }
22
- }
23
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJza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aW1wb3J0IHsgT2JzZXJ2YWJsZSwgUmVwbGF5U3ViamVjdCB9IGZyb20gJ3J4anMnO1xuXG4vKipcbiAqIEEgdXRpbGl0eSBpbmplY3Rpb24gZm4gdGhhdCBjYW4gYmUgdXNlZCBpbiBvdGhlciBpbmplY3Rpb24gZm4gdG8gcHJvdmlkZSB0aGUgZGVzdHJveSBjYXBhYmlsaXR5LlxuICovXG5leHBvcnQgZnVuY3Rpb24gaW5qZWN0Tmd0RGVzdHJveShjYj86ICgpID0+IHZvaWQpOiB7IGRlc3Ryb3kkOiBPYnNlcnZhYmxlPHZvaWQ+OyBjZHI6IENoYW5nZURldGVjdG9yUmVmIH0ge1xuICAgIHRyeSB7XG4gICAgICAgIGNvbnN0IGNkciA9IGluamVjdChDaGFuZ2VEZXRlY3RvclJlZik7XG4gICAgICAgIGNvbnN0IGRlc3Ryb3kkID0gbmV3IFJlcGxheVN1YmplY3Q8dm9pZD4oKTtcblxuICAgICAgICBxdWV1ZU1pY3JvdGFzaygoKSA9PiB7XG4gICAgICAgICAgICAoY2RyIGFzIFZpZXdSZWYpLm9uRGVzdHJveSgoKSA9PiB7XG4gICAgICAgICAgICAgICAgZGVzdHJveSQubmV4dCgpO1xuICAgICAgICAgICAgICAgIGRlc3Ryb3kkLmNvbXBsZXRlKCk7XG4gICAgICAgICAgICAgICAgY2I/LigpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHJldHVybiB7IGRlc3Ryb3kkLCBjZHIgfTtcbiAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgIHRocm93IG5ldyBFcnJvcihgW05HVF0gaW5qZWN0Tmd0RGVzdHJveSBpcyBiZWluZyBjYWxsZWQgb3V0c2lkZSBvZiBDb25zdHJ1Y3RvciBDb250ZXh0YCk7XG4gICAgfVxufVxuIl19
@@ -1,40 +0,0 @@
1
- import { EnvironmentInjector, inject, Injector } from '@angular/core';
2
- /**
3
- * Please use this sparringly and know what you're doing.
4
- *
5
- * Create a runInContext function that has access to the NodeInjector as well
6
- */
7
- export function createRunInContext() {
8
- const nodeInjector = inject(Injector);
9
- const envInjector = inject(EnvironmentInjector);
10
- const originalGet = envInjector.get.bind(envInjector);
11
- return (cb) => {
12
- let tryFromNodeInjector = false;
13
- envInjector.get = (...args) => {
14
- try {
15
- const originalFlags = args[2];
16
- if (!(originalFlags & 8)) {
17
- args[2] |= 8;
18
- }
19
- const fromEnvInjector = originalGet(...args);
20
- if (fromEnvInjector)
21
- return fromEnvInjector;
22
- if (fromEnvInjector === null && ((args[1] !== undefined && args[1] === null) || originalFlags & 8))
23
- return fromEnvInjector;
24
- args[2] = originalFlags;
25
- if (!tryFromNodeInjector) {
26
- tryFromNodeInjector = true;
27
- const fromNodeInjector = nodeInjector.get(...args);
28
- tryFromNodeInjector = false;
29
- return fromNodeInjector;
30
- }
31
- return null;
32
- }
33
- catch (e) {
34
- return originalGet(...args);
35
- }
36
- };
37
- return envInjector.runInContext(cb);
38
- };
39
- }
40
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnVuLWluLWNvbnRleHQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9saWJzL2FuZ3VsYXItdGhyZWUvc3JjL2xpYi9kaS9ydW4taW4tY29udGV4dC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxFQUFFLFFBQVEsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUV0RTs7OztHQUlHO0FBQ0gsTUFBTSxVQUFVLGtCQUFrQjtJQUM5QixNQUFNLFlBQVksR0FBRyxNQUFNLENBQUMsUUFBUSxDQUFDLENBQUM7SUFDdEMsTUFBTSxXQUFXLEdBQUcsTUFBTSxDQUFDLG1CQUFtQixDQUFDLENBQUM7SUFFaEQsTUFBTSxXQUFXLEdBQUcsV0FBVyxDQUFD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B7XG4gICAgICAgICAgICAgICAgY29uc3Qgb3JpZ2luYWxGbGFncyA9IChhcmdzIGFzIGFueSlbMl07XG4gICAgICAgICAgICAgICAgaWYgKCEob3JpZ2luYWxGbGFncyAmIDgpKSB7XG4gICAgICAgICAgICAgICAgICAgIChhcmdzIGFzIGFueSlbMl0gfD0gODtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29uc3QgZnJvbUVudkluamVjdG9yID0gb3JpZ2luYWxHZXQoLi4uYXJncyk7XG4gICAgICAgICAgICAgICAgaWYgKGZyb21FbnZJbmplY3RvcikgcmV0dXJuIGZyb21FbnZJbmplY3RvcjtcbiAgICAgICAgICAgICAgICBpZiAoZnJvbUVudkluamVjdG9yID09PSBudWxsICYmICgoYXJnc1sxXSAhPT0gdW5kZWZpbmVkICYmIGFyZ3NbMV0gPT09IG51bGwpIHx8IG9yaWdpbmFsRmxhZ3MgJiA4KSlcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZyb21FbnZJbmplY3RvcjtcbiAgICAgICAgICAgICAgICAoYXJncyBhcyBhbnkpWzJdID0gb3JpZ2luYWxGbGFncztcbiAgICAgICAgICAgICAgICBpZiAoIXRyeUZyb21Ob2RlSW5qZWN0b3IpIHtcbiAgICAgICAgICAgICAgICAgICAgdHJ5RnJvbU5vZGVJbmplY3RvciA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGZyb21Ob2RlSW5qZWN0b3IgPSBub2RlSW5qZWN0b3IuZ2V0KC4uLihhcmdzIGFzIFBhcmFtZXRlcnM8SW5qZWN0b3JbJ2dldCddPikpO1xuICAgICAgICAgICAgICAgICAgICB0cnlGcm9tTm9kZUluamVjdG9yID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBmcm9tTm9kZUluamVjdG9yO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gb3JpZ2luYWxHZXQoLi4uYXJncyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG5cbiAgICAgICAgcmV0dXJuIGVudkluamVjdG9yLnJ1bkluQ29udGV4dChjYik7XG4gICAgfTtcbn1cbiJdfQ==