@reactvision/react-viro 2.42.0 → 2.43.1
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.
- package/README.md +12 -6
- package/android/react_viro/react_viro-release.aar +0 -0
- package/components/AR/ViroARPlaneSelector.tsx +76 -37
- package/components/Utilities/ViroVersion.ts +1 -1
- package/dist/components/AR/ViroARPlaneSelector.d.ts +1 -1
- package/dist/components/AR/ViroARPlaneSelector.js +46 -18
- package/dist/components/Utilities/ViroVersion.d.ts +1 -1
- package/dist/components/Utilities/ViroVersion.js +1 -1
- package/dist/dynamic-index.d.ts +11 -0
- package/dist/dynamic-index.js +28 -0
- package/dist/examples/AutoDetectionExample.d.ts +10 -0
- package/dist/examples/AutoDetectionExample.js +91 -0
- package/dist/fabric-interop/NativeViro.d.ts +42 -0
- package/dist/fabric-interop/NativeViro.js +262 -0
- package/dist/fabric-interop/ViroEventsManager.d.ts +83 -0
- package/dist/fabric-interop/ViroEventsManager.js +222 -0
- package/dist/fabric-interop/ViroFabricContainer.d.ts +34 -0
- package/dist/fabric-interop/ViroFabricContainer.js +200 -0
- package/dist/fabric-interop/android/src/main/js/specs/ViroFabricContainerViewNativeComponent.d.ts +35 -0
- package/dist/fabric-interop/android/src/main/js/specs/ViroFabricContainerViewNativeComponent.js +20 -0
- package/dist/fabric-interop/components/AR/ViroARPlane.d.ts +22 -0
- package/dist/fabric-interop/components/AR/ViroARPlane.js +95 -0
- package/dist/fabric-interop/components/AR/ViroARPlaneSelector.d.ts +43 -0
- package/dist/fabric-interop/components/AR/ViroARPlaneSelector.js +152 -0
- package/dist/fabric-interop/components/AR/ViroARTrackingTargets.d.ts +55 -0
- package/dist/fabric-interop/components/AR/ViroARTrackingTargets.js +85 -0
- package/dist/fabric-interop/components/AR/ViroCommonProps.d.ts +91 -0
- package/dist/fabric-interop/components/AR/ViroCommonProps.js +7 -0
- package/dist/fabric-interop/components/Animation/ViroAnimations.d.ts +48 -0
- package/dist/fabric-interop/components/Animation/ViroAnimations.js +64 -0
- package/dist/fabric-interop/components/Material/ViroMaterials.d.ts +66 -0
- package/dist/fabric-interop/components/Material/ViroMaterials.js +85 -0
- package/dist/fabric-interop/components/Types/ViroEvents.d.ts +202 -0
- package/dist/fabric-interop/components/Types/ViroEvents.js +53 -0
- package/dist/fabric-interop/components/Types/ViroUtils.d.ts +137 -0
- package/dist/fabric-interop/components/Types/ViroUtils.js +7 -0
- package/dist/fabric-interop/components/Viro360Image.d.ts +23 -0
- package/dist/fabric-interop/components/Viro360Image.js +45 -0
- package/dist/fabric-interop/components/Viro360Video.d.ts +29 -0
- package/dist/fabric-interop/components/Viro360Video.js +47 -0
- package/dist/fabric-interop/components/Viro3DObject.d.ts +60 -0
- package/dist/fabric-interop/components/Viro3DObject.js +49 -0
- package/dist/fabric-interop/components/Viro3DSceneNavigator.d.ts +49 -0
- package/dist/fabric-interop/components/Viro3DSceneNavigator.js +388 -0
- package/dist/fabric-interop/components/ViroARCamera.d.ts +29 -0
- package/dist/fabric-interop/components/ViroARCamera.js +64 -0
- package/dist/fabric-interop/components/ViroARImageMarker.d.ts +21 -0
- package/dist/fabric-interop/components/ViroARImageMarker.js +71 -0
- package/dist/fabric-interop/components/ViroARObjectMarker.d.ts +21 -0
- package/dist/fabric-interop/components/ViroARObjectMarker.js +71 -0
- package/dist/fabric-interop/components/ViroARPlane.d.ts +24 -0
- package/dist/fabric-interop/components/ViroARPlane.js +88 -0
- package/dist/fabric-interop/components/ViroARScene.d.ts +29 -0
- package/dist/fabric-interop/components/ViroARScene.js +89 -0
- package/dist/fabric-interop/components/ViroARSceneNavigator.d.ts +29 -0
- package/dist/fabric-interop/components/ViroARSceneNavigator.js +76 -0
- package/dist/fabric-interop/components/ViroAmbientLight.d.ts +19 -0
- package/dist/fabric-interop/components/ViroAmbientLight.js +46 -0
- package/dist/fabric-interop/components/ViroAnimatedComponent.d.ts +24 -0
- package/dist/fabric-interop/components/ViroAnimatedComponent.js +63 -0
- package/dist/fabric-interop/components/ViroAnimatedImage.d.ts +28 -0
- package/dist/fabric-interop/components/ViroAnimatedImage.js +49 -0
- package/dist/fabric-interop/components/ViroBox.d.ts +20 -0
- package/dist/fabric-interop/components/ViroBox.js +47 -0
- package/dist/fabric-interop/components/ViroButton.d.ts +32 -0
- package/dist/fabric-interop/components/ViroButton.js +92 -0
- package/dist/fabric-interop/components/ViroCamera.d.ts +17 -0
- package/dist/fabric-interop/components/ViroCamera.js +30 -0
- package/dist/fabric-interop/components/ViroController.d.ts +19 -0
- package/dist/fabric-interop/components/ViroController.js +64 -0
- package/dist/fabric-interop/components/ViroDirectionalLight.d.ts +28 -0
- package/dist/fabric-interop/components/ViroDirectionalLight.js +55 -0
- package/dist/fabric-interop/components/ViroFlexView.d.ts +36 -0
- package/dist/fabric-interop/components/ViroFlexView.js +97 -0
- package/dist/fabric-interop/components/ViroGeometry.d.ts +23 -0
- package/dist/fabric-interop/components/ViroGeometry.js +50 -0
- package/dist/fabric-interop/components/ViroGlobal.d.ts +45 -0
- package/dist/fabric-interop/components/ViroGlobal.js +20 -0
- package/dist/fabric-interop/components/ViroImage.d.ts +29 -0
- package/dist/fabric-interop/components/ViroImage.js +52 -0
- package/dist/fabric-interop/components/ViroLightingEnvironment.d.ts +19 -0
- package/dist/fabric-interop/components/ViroLightingEnvironment.js +44 -0
- package/dist/fabric-interop/components/ViroMaterialVideo.d.ts +30 -0
- package/dist/fabric-interop/components/ViroMaterialVideo.js +48 -0
- package/dist/fabric-interop/components/ViroNode.d.ts +36 -0
- package/dist/fabric-interop/components/ViroNode.js +28 -0
- package/dist/fabric-interop/components/ViroOmniLight.d.ts +21 -0
- package/dist/fabric-interop/components/ViroOmniLight.js +48 -0
- package/dist/fabric-interop/components/ViroOrbitCamera.d.ts +17 -0
- package/dist/fabric-interop/components/ViroOrbitCamera.js +30 -0
- package/dist/fabric-interop/components/ViroParticleEmitter.d.ts +51 -0
- package/dist/fabric-interop/components/ViroParticleEmitter.js +50 -0
- package/dist/fabric-interop/components/ViroPolygon.d.ts +20 -0
- package/dist/fabric-interop/components/ViroPolygon.js +47 -0
- package/dist/fabric-interop/components/ViroPolyline.d.ts +19 -0
- package/dist/fabric-interop/components/ViroPolyline.js +46 -0
- package/dist/fabric-interop/components/ViroPortal.d.ts +16 -0
- package/dist/fabric-interop/components/ViroPortal.js +73 -0
- package/dist/fabric-interop/components/ViroPortalScene.d.ts +16 -0
- package/dist/fabric-interop/components/ViroPortalScene.js +29 -0
- package/dist/fabric-interop/components/ViroQuad.d.ts +39 -0
- package/dist/fabric-interop/components/ViroQuad.js +49 -0
- package/dist/fabric-interop/components/ViroScene.d.ts +29 -0
- package/dist/fabric-interop/components/ViroScene.js +103 -0
- package/dist/fabric-interop/components/ViroSceneNavigator.d.ts +23 -0
- package/dist/fabric-interop/components/ViroSceneNavigator.js +73 -0
- package/dist/fabric-interop/components/ViroSkyBox.d.ts +39 -0
- package/dist/fabric-interop/components/ViroSkyBox.js +44 -0
- package/dist/fabric-interop/components/ViroSound.d.ts +23 -0
- package/dist/fabric-interop/components/ViroSound.js +46 -0
- package/dist/fabric-interop/components/ViroSoundField.d.ts +24 -0
- package/dist/fabric-interop/components/ViroSoundField.js +47 -0
- package/dist/fabric-interop/components/ViroSpatialSound.d.ts +27 -0
- package/dist/fabric-interop/components/ViroSpatialSound.js +50 -0
- package/dist/fabric-interop/components/ViroSphere.d.ts +22 -0
- package/dist/fabric-interop/components/ViroSphere.js +49 -0
- package/dist/fabric-interop/components/ViroSpinner.d.ts +18 -0
- package/dist/fabric-interop/components/ViroSpinner.js +45 -0
- package/dist/fabric-interop/components/ViroSpotLight.d.ts +30 -0
- package/dist/fabric-interop/components/ViroSpotLight.js +57 -0
- package/dist/fabric-interop/components/ViroSurface.d.ts +38 -0
- package/dist/fabric-interop/components/ViroSurface.js +48 -0
- package/dist/fabric-interop/components/ViroText.d.ts +36 -0
- package/dist/fabric-interop/components/ViroText.js +59 -0
- package/dist/fabric-interop/components/ViroUtils.d.ts +63 -0
- package/dist/fabric-interop/components/ViroUtils.js +140 -0
- package/dist/fabric-interop/components/ViroVRSceneNavigator.d.ts +25 -0
- package/dist/fabric-interop/components/ViroVRSceneNavigator.js +73 -0
- package/dist/fabric-interop/components/ViroVideo.d.ts +32 -0
- package/dist/fabric-interop/components/ViroVideo.js +52 -0
- package/dist/fabric-interop/components/index.d.ts +62 -0
- package/dist/fabric-interop/components/index.js +144 -0
- package/dist/fabric-interop/examples/BasicSceneExample.d.ts +11 -0
- package/dist/fabric-interop/examples/BasicSceneExample.js +244 -0
- package/dist/fabric-interop/examples/ComprehensiveExample.d.ts +13 -0
- package/dist/fabric-interop/examples/ComprehensiveExample.js +327 -0
- package/dist/fabric-interop/examples/SimpleARExample.d.ts +8 -0
- package/dist/fabric-interop/examples/SimpleARExample.js +62 -0
- package/dist/fabric-interop/index.d.ts +14 -0
- package/dist/fabric-interop/index.js +117 -0
- package/dist/fabric-interop/specs/ViroEventsTurboModule.d.ts +19 -0
- package/dist/fabric-interop/specs/ViroEventsTurboModule.js +11 -0
- package/dist/fabric-interop/test/BasicFunctionalityTest.d.ts +9 -0
- package/dist/fabric-interop/test/BasicFunctionalityTest.js +222 -0
- package/dist/fabric.d.ts +13 -0
- package/dist/fabric.js +29 -0
- package/dist/plugins/withViro.d.ts +3 -0
- package/dist/plugins/withViro.js +19 -0
- package/dist/plugins/withViroAndroid.js +24 -20
- package/dist/plugins/withViroIos.js +20 -2
- package/dynamic-index-source.d.ts +77 -0
- package/dynamic-index.ts +41 -0
- package/fabric-interop/NativeViro.ts +335 -0
- package/fabric-interop/README.md +282 -0
- package/fabric-interop/ViroEventsManager.js +257 -0
- package/fabric-interop/ViroFabricContainer.tsx +273 -0
- package/fabric-interop/components/AR/ViroARPlane.tsx +108 -0
- package/fabric-interop/components/AR/ViroARPlaneSelector.tsx +185 -0
- package/fabric-interop/components/AR/ViroARTrackingTargets.ts +108 -0
- package/fabric-interop/components/AR/ViroCommonProps.ts +140 -0
- package/fabric-interop/components/Animation/ViroAnimations.ts +96 -0
- package/fabric-interop/components/Material/ViroMaterials.ts +127 -0
- package/fabric-interop/components/Resources/viro_spinner_1.png +0 -0
- package/fabric-interop/components/Resources/viro_spinner_1_w.png +0 -0
- package/fabric-interop/components/Resources/viro_spinner_1a.png +0 -0
- package/fabric-interop/components/Resources/viro_spinner_1a_w.png +0 -0
- package/fabric-interop/components/Types/ViroEvents.ts +285 -0
- package/fabric-interop/components/Types/ViroUtils.ts +160 -0
- package/fabric-interop/components/Viro360Image.tsx +70 -0
- package/fabric-interop/components/Viro360Video.tsx +78 -0
- package/fabric-interop/components/Viro3DObject.tsx +122 -0
- package/fabric-interop/components/Viro3DSceneNavigator.tsx +503 -0
- package/fabric-interop/components/ViroARCamera.tsx +105 -0
- package/fabric-interop/components/ViroARImageMarker.tsx +98 -0
- package/fabric-interop/components/ViroARObjectMarker.tsx +100 -0
- package/fabric-interop/components/ViroARPlane.tsx +120 -0
- package/fabric-interop/components/ViroARScene.tsx +127 -0
- package/fabric-interop/components/ViroARSceneNavigator.tsx +82 -0
- package/fabric-interop/components/ViroAmbientLight.tsx +62 -0
- package/fabric-interop/components/ViroAnimatedComponent.tsx +91 -0
- package/fabric-interop/components/ViroAnimatedImage.tsx +81 -0
- package/fabric-interop/components/ViroBox.tsx +72 -0
- package/fabric-interop/components/ViroButton.tsx +125 -0
- package/fabric-interop/components/ViroCamera.tsx +45 -0
- package/fabric-interop/components/ViroController.tsx +87 -0
- package/fabric-interop/components/ViroDirectionalLight.tsx +84 -0
- package/fabric-interop/components/ViroFlexView.tsx +146 -0
- package/fabric-interop/components/ViroGeometry.tsx +78 -0
- package/fabric-interop/components/ViroGlobal.ts +114 -0
- package/fabric-interop/components/ViroImage.tsx +85 -0
- package/fabric-interop/components/ViroLightingEnvironment.tsx +63 -0
- package/fabric-interop/components/ViroMaterialVideo.tsx +82 -0
- package/fabric-interop/components/ViroNode.tsx +62 -0
- package/fabric-interop/components/ViroOmniLight.tsx +66 -0
- package/fabric-interop/components/ViroOrbitCamera.tsx +45 -0
- package/fabric-interop/components/ViroParticleEmitter.tsx +111 -0
- package/fabric-interop/components/ViroPolygon.tsx +72 -0
- package/fabric-interop/components/ViroPolyline.tsx +71 -0
- package/fabric-interop/components/ViroPortal.tsx +91 -0
- package/fabric-interop/components/ViroPortalScene.tsx +43 -0
- package/fabric-interop/components/ViroQuad.tsx +82 -0
- package/fabric-interop/components/ViroScene.tsx +117 -0
- package/fabric-interop/components/ViroSceneNavigator.tsx +71 -0
- package/fabric-interop/components/ViroSkyBox.tsx +75 -0
- package/fabric-interop/components/ViroSound.tsx +71 -0
- package/fabric-interop/components/ViroSoundField.tsx +75 -0
- package/fabric-interop/components/ViroSpatialSound.tsx +81 -0
- package/fabric-interop/components/ViroSphere.tsx +75 -0
- package/fabric-interop/components/ViroSpinner.tsx +63 -0
- package/fabric-interop/components/ViroSpotLight.tsx +86 -0
- package/fabric-interop/components/ViroSurface.tsx +80 -0
- package/fabric-interop/components/ViroText.tsx +114 -0
- package/fabric-interop/components/ViroUtils.ts +208 -0
- package/fabric-interop/components/ViroVRSceneNavigator.tsx +75 -0
- package/fabric-interop/components/ViroVideo.tsx +91 -0
- package/fabric-interop/components/index.ts +94 -0
- package/fabric-interop/dist/NativeViro.d.ts +43 -0
- package/fabric-interop/dist/NativeViro.d.ts.map +1 -0
- package/fabric-interop/dist/NativeViro.js +263 -0
- package/fabric-interop/dist/NativeViro.js.map +1 -0
- package/fabric-interop/dist/ViroFabricContainer.d.ts +35 -0
- package/fabric-interop/dist/ViroFabricContainer.d.ts.map +1 -0
- package/fabric-interop/dist/ViroFabricContainer.js +201 -0
- package/fabric-interop/dist/ViroFabricContainer.js.map +1 -0
- package/fabric-interop/dist/components/AR/ViroARPlane.d.ts +23 -0
- package/fabric-interop/dist/components/AR/ViroARPlane.d.ts.map +1 -0
- package/fabric-interop/dist/components/AR/ViroARPlane.js +96 -0
- package/fabric-interop/dist/components/AR/ViroARPlane.js.map +1 -0
- package/fabric-interop/dist/components/AR/ViroARPlaneSelector.d.ts +44 -0
- package/fabric-interop/dist/components/AR/ViroARPlaneSelector.d.ts.map +1 -0
- package/fabric-interop/dist/components/AR/ViroARPlaneSelector.js +156 -0
- package/fabric-interop/dist/components/AR/ViroARPlaneSelector.js.map +1 -0
- package/fabric-interop/dist/components/AR/ViroARTrackingTargets.d.ts +56 -0
- package/fabric-interop/dist/components/AR/ViroARTrackingTargets.d.ts.map +1 -0
- package/fabric-interop/dist/components/AR/ViroARTrackingTargets.js +86 -0
- package/fabric-interop/dist/components/AR/ViroARTrackingTargets.js.map +1 -0
- package/fabric-interop/dist/components/AR/ViroCommonProps.d.ts +92 -0
- package/fabric-interop/dist/components/AR/ViroCommonProps.d.ts.map +1 -0
- package/fabric-interop/dist/components/AR/ViroCommonProps.js +8 -0
- package/fabric-interop/dist/components/AR/ViroCommonProps.js.map +1 -0
- package/fabric-interop/dist/components/Animation/ViroAnimations.d.ts +49 -0
- package/fabric-interop/dist/components/Animation/ViroAnimations.d.ts.map +1 -0
- package/fabric-interop/dist/components/Animation/ViroAnimations.js +65 -0
- package/fabric-interop/dist/components/Animation/ViroAnimations.js.map +1 -0
- package/fabric-interop/dist/components/Material/ViroMaterials.d.ts +67 -0
- package/fabric-interop/dist/components/Material/ViroMaterials.d.ts.map +1 -0
- package/fabric-interop/dist/components/Material/ViroMaterials.js +86 -0
- package/fabric-interop/dist/components/Material/ViroMaterials.js.map +1 -0
- package/fabric-interop/dist/components/Types/ViroEvents.d.ts +203 -0
- package/fabric-interop/dist/components/Types/ViroEvents.d.ts.map +1 -0
- package/fabric-interop/dist/components/Types/ViroEvents.js +54 -0
- package/fabric-interop/dist/components/Types/ViroEvents.js.map +1 -0
- package/fabric-interop/dist/components/Types/ViroUtils.d.ts +138 -0
- package/fabric-interop/dist/components/Types/ViroUtils.d.ts.map +1 -0
- package/fabric-interop/dist/components/Types/ViroUtils.js +8 -0
- package/fabric-interop/dist/components/Types/ViroUtils.js.map +1 -0
- package/fabric-interop/dist/components/Viro360Image.d.ts +24 -0
- package/fabric-interop/dist/components/Viro360Image.d.ts.map +1 -0
- package/fabric-interop/dist/components/Viro360Image.js +47 -0
- package/fabric-interop/dist/components/Viro360Image.js.map +1 -0
- package/fabric-interop/dist/components/Viro360Video.d.ts +30 -0
- package/fabric-interop/dist/components/Viro360Video.d.ts.map +1 -0
- package/fabric-interop/dist/components/Viro360Video.js +49 -0
- package/fabric-interop/dist/components/Viro360Video.js.map +1 -0
- package/fabric-interop/dist/components/Viro3DObject.d.ts +61 -0
- package/fabric-interop/dist/components/Viro3DObject.d.ts.map +1 -0
- package/fabric-interop/dist/components/Viro3DObject.js +51 -0
- package/fabric-interop/dist/components/Viro3DObject.js.map +1 -0
- package/fabric-interop/dist/components/Viro3DSceneNavigator.d.ts +50 -0
- package/fabric-interop/dist/components/Viro3DSceneNavigator.d.ts.map +1 -0
- package/fabric-interop/dist/components/Viro3DSceneNavigator.js +389 -0
- package/fabric-interop/dist/components/Viro3DSceneNavigator.js.map +1 -0
- package/fabric-interop/dist/components/ViroARCamera.d.ts +30 -0
- package/fabric-interop/dist/components/ViroARCamera.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroARCamera.js +65 -0
- package/fabric-interop/dist/components/ViroARCamera.js.map +1 -0
- package/fabric-interop/dist/components/ViroARImageMarker.d.ts +22 -0
- package/fabric-interop/dist/components/ViroARImageMarker.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroARImageMarker.js +72 -0
- package/fabric-interop/dist/components/ViroARImageMarker.js.map +1 -0
- package/fabric-interop/dist/components/ViroARObjectMarker.d.ts +22 -0
- package/fabric-interop/dist/components/ViroARObjectMarker.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroARObjectMarker.js +72 -0
- package/fabric-interop/dist/components/ViroARObjectMarker.js.map +1 -0
- package/fabric-interop/dist/components/ViroARPlane.d.ts +25 -0
- package/fabric-interop/dist/components/ViroARPlane.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroARPlane.js +89 -0
- package/fabric-interop/dist/components/ViroARPlane.js.map +1 -0
- package/fabric-interop/dist/components/ViroARScene.d.ts +30 -0
- package/fabric-interop/dist/components/ViroARScene.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroARScene.js +90 -0
- package/fabric-interop/dist/components/ViroARScene.js.map +1 -0
- package/fabric-interop/dist/components/ViroARSceneNavigator.d.ts +30 -0
- package/fabric-interop/dist/components/ViroARSceneNavigator.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroARSceneNavigator.js +78 -0
- package/fabric-interop/dist/components/ViroARSceneNavigator.js.map +1 -0
- package/fabric-interop/dist/components/ViroAmbientLight.d.ts +20 -0
- package/fabric-interop/dist/components/ViroAmbientLight.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroAmbientLight.js +48 -0
- package/fabric-interop/dist/components/ViroAmbientLight.js.map +1 -0
- package/fabric-interop/dist/components/ViroAnimatedComponent.d.ts +25 -0
- package/fabric-interop/dist/components/ViroAnimatedComponent.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroAnimatedComponent.js +65 -0
- package/fabric-interop/dist/components/ViroAnimatedComponent.js.map +1 -0
- package/fabric-interop/dist/components/ViroAnimatedImage.d.ts +29 -0
- package/fabric-interop/dist/components/ViroAnimatedImage.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroAnimatedImage.js +51 -0
- package/fabric-interop/dist/components/ViroAnimatedImage.js.map +1 -0
- package/fabric-interop/dist/components/ViroBox.d.ts +21 -0
- package/fabric-interop/dist/components/ViroBox.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroBox.js +49 -0
- package/fabric-interop/dist/components/ViroBox.js.map +1 -0
- package/fabric-interop/dist/components/ViroButton.d.ts +33 -0
- package/fabric-interop/dist/components/ViroButton.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroButton.js +94 -0
- package/fabric-interop/dist/components/ViroButton.js.map +1 -0
- package/fabric-interop/dist/components/ViroCamera.d.ts +18 -0
- package/fabric-interop/dist/components/ViroCamera.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroCamera.js +31 -0
- package/fabric-interop/dist/components/ViroCamera.js.map +1 -0
- package/fabric-interop/dist/components/ViroController.d.ts +20 -0
- package/fabric-interop/dist/components/ViroController.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroController.js +65 -0
- package/fabric-interop/dist/components/ViroController.js.map +1 -0
- package/fabric-interop/dist/components/ViroDirectionalLight.d.ts +29 -0
- package/fabric-interop/dist/components/ViroDirectionalLight.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroDirectionalLight.js +57 -0
- package/fabric-interop/dist/components/ViroDirectionalLight.js.map +1 -0
- package/fabric-interop/dist/components/ViroFlexView.d.ts +37 -0
- package/fabric-interop/dist/components/ViroFlexView.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroFlexView.js +98 -0
- package/fabric-interop/dist/components/ViroFlexView.js.map +1 -0
- package/fabric-interop/dist/components/ViroGeometry.d.ts +24 -0
- package/fabric-interop/dist/components/ViroGeometry.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroGeometry.js +52 -0
- package/fabric-interop/dist/components/ViroGeometry.js.map +1 -0
- package/fabric-interop/dist/components/ViroGlobal.d.ts +46 -0
- package/fabric-interop/dist/components/ViroGlobal.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroGlobal.js +21 -0
- package/fabric-interop/dist/components/ViroGlobal.js.map +1 -0
- package/fabric-interop/dist/components/ViroImage.d.ts +30 -0
- package/fabric-interop/dist/components/ViroImage.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroImage.js +54 -0
- package/fabric-interop/dist/components/ViroImage.js.map +1 -0
- package/fabric-interop/dist/components/ViroLightingEnvironment.d.ts +20 -0
- package/fabric-interop/dist/components/ViroLightingEnvironment.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroLightingEnvironment.js +46 -0
- package/fabric-interop/dist/components/ViroLightingEnvironment.js.map +1 -0
- package/fabric-interop/dist/components/ViroMaterialVideo.d.ts +31 -0
- package/fabric-interop/dist/components/ViroMaterialVideo.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroMaterialVideo.js +50 -0
- package/fabric-interop/dist/components/ViroMaterialVideo.js.map +1 -0
- package/fabric-interop/dist/components/ViroNode.d.ts +37 -0
- package/fabric-interop/dist/components/ViroNode.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroNode.js +29 -0
- package/fabric-interop/dist/components/ViroNode.js.map +1 -0
- package/fabric-interop/dist/components/ViroOmniLight.d.ts +22 -0
- package/fabric-interop/dist/components/ViroOmniLight.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroOmniLight.js +50 -0
- package/fabric-interop/dist/components/ViroOmniLight.js.map +1 -0
- package/fabric-interop/dist/components/ViroOrbitCamera.d.ts +18 -0
- package/fabric-interop/dist/components/ViroOrbitCamera.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroOrbitCamera.js +31 -0
- package/fabric-interop/dist/components/ViroOrbitCamera.js.map +1 -0
- package/fabric-interop/dist/components/ViroParticleEmitter.d.ts +52 -0
- package/fabric-interop/dist/components/ViroParticleEmitter.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroParticleEmitter.js +52 -0
- package/fabric-interop/dist/components/ViroParticleEmitter.js.map +1 -0
- package/fabric-interop/dist/components/ViroPolygon.d.ts +21 -0
- package/fabric-interop/dist/components/ViroPolygon.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroPolygon.js +49 -0
- package/fabric-interop/dist/components/ViroPolygon.js.map +1 -0
- package/fabric-interop/dist/components/ViroPolyline.d.ts +20 -0
- package/fabric-interop/dist/components/ViroPolyline.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroPolyline.js +48 -0
- package/fabric-interop/dist/components/ViroPolyline.js.map +1 -0
- package/fabric-interop/dist/components/ViroPortal.d.ts +17 -0
- package/fabric-interop/dist/components/ViroPortal.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroPortal.js +74 -0
- package/fabric-interop/dist/components/ViroPortal.js.map +1 -0
- package/fabric-interop/dist/components/ViroPortalScene.d.ts +17 -0
- package/fabric-interop/dist/components/ViroPortalScene.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroPortalScene.js +30 -0
- package/fabric-interop/dist/components/ViroPortalScene.js.map +1 -0
- package/fabric-interop/dist/components/ViroQuad.d.ts +40 -0
- package/fabric-interop/dist/components/ViroQuad.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroQuad.js +51 -0
- package/fabric-interop/dist/components/ViroQuad.js.map +1 -0
- package/fabric-interop/dist/components/ViroScene.d.ts +30 -0
- package/fabric-interop/dist/components/ViroScene.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroScene.js +105 -0
- package/fabric-interop/dist/components/ViroScene.js.map +1 -0
- package/fabric-interop/dist/components/ViroSceneNavigator.d.ts +24 -0
- package/fabric-interop/dist/components/ViroSceneNavigator.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroSceneNavigator.js +74 -0
- package/fabric-interop/dist/components/ViroSceneNavigator.js.map +1 -0
- package/fabric-interop/dist/components/ViroSkyBox.d.ts +40 -0
- package/fabric-interop/dist/components/ViroSkyBox.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroSkyBox.js +46 -0
- package/fabric-interop/dist/components/ViroSkyBox.js.map +1 -0
- package/fabric-interop/dist/components/ViroSound.d.ts +24 -0
- package/fabric-interop/dist/components/ViroSound.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroSound.js +48 -0
- package/fabric-interop/dist/components/ViroSound.js.map +1 -0
- package/fabric-interop/dist/components/ViroSoundField.d.ts +25 -0
- package/fabric-interop/dist/components/ViroSoundField.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroSoundField.js +49 -0
- package/fabric-interop/dist/components/ViroSoundField.js.map +1 -0
- package/fabric-interop/dist/components/ViroSpatialSound.d.ts +28 -0
- package/fabric-interop/dist/components/ViroSpatialSound.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroSpatialSound.js +52 -0
- package/fabric-interop/dist/components/ViroSpatialSound.js.map +1 -0
- package/fabric-interop/dist/components/ViroSphere.d.ts +23 -0
- package/fabric-interop/dist/components/ViroSphere.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroSphere.js +51 -0
- package/fabric-interop/dist/components/ViroSphere.js.map +1 -0
- package/fabric-interop/dist/components/ViroSpinner.d.ts +19 -0
- package/fabric-interop/dist/components/ViroSpinner.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroSpinner.js +47 -0
- package/fabric-interop/dist/components/ViroSpinner.js.map +1 -0
- package/fabric-interop/dist/components/ViroSpotLight.d.ts +31 -0
- package/fabric-interop/dist/components/ViroSpotLight.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroSpotLight.js +59 -0
- package/fabric-interop/dist/components/ViroSpotLight.js.map +1 -0
- package/fabric-interop/dist/components/ViroSurface.d.ts +39 -0
- package/fabric-interop/dist/components/ViroSurface.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroSurface.js +50 -0
- package/fabric-interop/dist/components/ViroSurface.js.map +1 -0
- package/fabric-interop/dist/components/ViroText.d.ts +37 -0
- package/fabric-interop/dist/components/ViroText.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroText.js +61 -0
- package/fabric-interop/dist/components/ViroText.js.map +1 -0
- package/fabric-interop/dist/components/ViroUtils.d.ts +64 -0
- package/fabric-interop/dist/components/ViroUtils.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroUtils.js +141 -0
- package/fabric-interop/dist/components/ViroUtils.js.map +1 -0
- package/fabric-interop/dist/components/ViroVRSceneNavigator.d.ts +26 -0
- package/fabric-interop/dist/components/ViroVRSceneNavigator.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroVRSceneNavigator.js +74 -0
- package/fabric-interop/dist/components/ViroVRSceneNavigator.js.map +1 -0
- package/fabric-interop/dist/components/ViroVideo.d.ts +33 -0
- package/fabric-interop/dist/components/ViroVideo.d.ts.map +1 -0
- package/fabric-interop/dist/components/ViroVideo.js +54 -0
- package/fabric-interop/dist/components/ViroVideo.js.map +1 -0
- package/fabric-interop/dist/components/index.d.ts +63 -0
- package/fabric-interop/dist/components/index.d.ts.map +1 -0
- package/fabric-interop/dist/components/index.js +145 -0
- package/fabric-interop/dist/components/index.js.map +1 -0
- package/fabric-interop/dist/index.d.ts +15 -0
- package/fabric-interop/dist/index.d.ts.map +1 -0
- package/fabric-interop/dist/index.js +118 -0
- package/fabric-interop/dist/index.js.map +1 -0
- package/fabric-interop/dist/specs/ViroEventsTurboModule.d.ts +20 -0
- package/fabric-interop/dist/specs/ViroEventsTurboModule.d.ts.map +1 -0
- package/fabric-interop/dist/specs/ViroEventsTurboModule.js +12 -0
- package/fabric-interop/dist/specs/ViroEventsTurboModule.js.map +1 -0
- package/fabric-interop/examples/BasicSceneExample.tsx +287 -0
- package/fabric-interop/examples/ComprehensiveExample.tsx +441 -0
- package/fabric-interop/examples/SimpleARExample.tsx +95 -0
- package/fabric-interop/global.d.ts +14 -0
- package/fabric-interop/index.ts +107 -0
- package/fabric-interop/metro.config.js +12 -0
- package/fabric-interop/package.json +40 -0
- package/fabric-interop/react-native.config.js +22 -0
- package/fabric-interop/scripts/validate-build.js +393 -0
- package/fabric-interop/scripts/validate-implementation.js +272 -0
- package/fabric-interop/specs/README.md +22 -0
- package/fabric-interop/specs/ViroEventsTurboModule.ts +27 -0
- package/fabric-interop/test/BasicFunctionalityTest.tsx +243 -0
- package/fabric-interop/tsconfig.json +38 -0
- package/fabric.d.ts +5 -0
- package/fabric.ts +14 -0
- package/ios/ViroReact.podspec +51 -11
- package/package.json +33 -20
- package/scripts/copy-types.js +46 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ViroEventsManager.js
|
|
3
|
+
* JavaScript integration for ViroEventsTurboModule
|
|
4
|
+
*
|
|
5
|
+
* This module provides the JavaScript interface for handling
|
|
6
|
+
* Viro JSI events through the TurboModule system
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { NativeEventEmitter, NativeModules } from "react-native";
|
|
10
|
+
import ViroEventsTurboModule from "./specs/ViroEventsTurboModule";
|
|
11
|
+
|
|
12
|
+
class ViroEventsManager {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.eventEmitter = new NativeEventEmitter(ViroEventsTurboModule);
|
|
15
|
+
this.listeners = new Map();
|
|
16
|
+
this.callbackRegistry = new Map();
|
|
17
|
+
|
|
18
|
+
// Set up event listeners
|
|
19
|
+
this.setupEventListeners();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
setupEventListeners() {
|
|
23
|
+
// Listen for JSI callbacks
|
|
24
|
+
this.eventEmitter.addListener("ViroJSICallback", (event) => {
|
|
25
|
+
this.handleJSICallback(event);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Listen for node events
|
|
29
|
+
this.eventEmitter.addListener("ViroNodeEvent", (event) => {
|
|
30
|
+
this.handleNodeEvent(event);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Listen for scene events
|
|
34
|
+
this.eventEmitter.addListener("ViroSceneEvent", (event) => {
|
|
35
|
+
this.handleSceneEvent(event);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Register a callback for JSI events
|
|
41
|
+
* @param {string} callbackId - The callback ID from JSI
|
|
42
|
+
* @param {function} callback - The JavaScript callback function
|
|
43
|
+
*/
|
|
44
|
+
registerJSICallback(callbackId, callback) {
|
|
45
|
+
if (typeof callback === "function") {
|
|
46
|
+
this.callbackRegistry.set(callbackId, callback);
|
|
47
|
+
console.log(`[ViroEventsManager] Registered JSI callback: ${callbackId}`);
|
|
48
|
+
} else {
|
|
49
|
+
console.warn(
|
|
50
|
+
`[ViroEventsManager] Invalid callback for ID: ${callbackId}`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Unregister a JSI callback
|
|
57
|
+
* @param {string} callbackId - The callback ID to remove
|
|
58
|
+
*/
|
|
59
|
+
unregisterJSICallback(callbackId) {
|
|
60
|
+
if (this.callbackRegistry.has(callbackId)) {
|
|
61
|
+
this.callbackRegistry.delete(callbackId);
|
|
62
|
+
console.log(
|
|
63
|
+
`[ViroEventsManager] Unregistered JSI callback: ${callbackId}`
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Register a listener for node events
|
|
70
|
+
* @param {string} nodeId - The node ID
|
|
71
|
+
* @param {string} eventName - The event name
|
|
72
|
+
* @param {function} callback - The callback function
|
|
73
|
+
*/
|
|
74
|
+
registerNodeEventListener(nodeId, eventName, callback) {
|
|
75
|
+
const key = `${nodeId}.${eventName}`;
|
|
76
|
+
this.listeners.set(key, callback);
|
|
77
|
+
console.log(`[ViroEventsManager] Registered node event listener: ${key}`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Register a listener for scene events
|
|
82
|
+
* @param {string} sceneId - The scene ID
|
|
83
|
+
* @param {string} eventName - The event name
|
|
84
|
+
* @param {function} callback - The callback function
|
|
85
|
+
*/
|
|
86
|
+
registerSceneEventListener(sceneId, eventName, callback) {
|
|
87
|
+
const key = `scene.${sceneId}.${eventName}`;
|
|
88
|
+
this.listeners.set(key, callback);
|
|
89
|
+
console.log(`[ViroEventsManager] Registered scene event listener: ${key}`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Handle JSI callback events
|
|
94
|
+
* @private
|
|
95
|
+
*/
|
|
96
|
+
handleJSICallback(event) {
|
|
97
|
+
const { callbackId, eventData, timestamp } = event;
|
|
98
|
+
|
|
99
|
+
console.log(
|
|
100
|
+
`[ViroEventsManager] Received JSI callback: ${callbackId}`,
|
|
101
|
+
eventData
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const callback = this.callbackRegistry.get(callbackId);
|
|
105
|
+
if (callback) {
|
|
106
|
+
try {
|
|
107
|
+
callback(eventData);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
console.error(
|
|
110
|
+
`[ViroEventsManager] Error executing JSI callback ${callbackId}:`,
|
|
111
|
+
error
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
console.warn(
|
|
116
|
+
`[ViroEventsManager] No callback registered for ID: ${callbackId}`
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Handle node events
|
|
123
|
+
* @private
|
|
124
|
+
*/
|
|
125
|
+
handleNodeEvent(event) {
|
|
126
|
+
const { nodeId, eventName, eventData, timestamp } = event;
|
|
127
|
+
const key = `${nodeId}.${eventName}`;
|
|
128
|
+
|
|
129
|
+
console.log(`[ViroEventsManager] Received node event: ${key}`, eventData);
|
|
130
|
+
|
|
131
|
+
const callback = this.listeners.get(key);
|
|
132
|
+
if (callback) {
|
|
133
|
+
try {
|
|
134
|
+
callback(eventData);
|
|
135
|
+
} catch (error) {
|
|
136
|
+
console.error(
|
|
137
|
+
`[ViroEventsManager] Error executing node event callback ${key}:`,
|
|
138
|
+
error
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Handle scene events
|
|
146
|
+
* @private
|
|
147
|
+
*/
|
|
148
|
+
handleSceneEvent(event) {
|
|
149
|
+
const { sceneId, eventName, eventData, timestamp } = event;
|
|
150
|
+
const key = `scene.${sceneId}.${eventName}`;
|
|
151
|
+
|
|
152
|
+
console.log(`[ViroEventsManager] Received scene event: ${key}`, eventData);
|
|
153
|
+
|
|
154
|
+
const callback = this.listeners.get(key);
|
|
155
|
+
if (callback) {
|
|
156
|
+
try {
|
|
157
|
+
callback(eventData);
|
|
158
|
+
} catch (error) {
|
|
159
|
+
console.error(
|
|
160
|
+
`[ViroEventsManager] Error executing scene event callback ${key}:`,
|
|
161
|
+
error
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Check if the event system is ready
|
|
169
|
+
* @returns {boolean}
|
|
170
|
+
*/
|
|
171
|
+
isEventSystemReady() {
|
|
172
|
+
try {
|
|
173
|
+
return ViroEventsTurboModule.isEventSystemReady();
|
|
174
|
+
} catch (error) {
|
|
175
|
+
console.error(
|
|
176
|
+
"[ViroEventsManager] Error checking event system status:",
|
|
177
|
+
error
|
|
178
|
+
);
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Get the number of active listeners
|
|
185
|
+
* @returns {number}
|
|
186
|
+
*/
|
|
187
|
+
getActiveListenerCount() {
|
|
188
|
+
try {
|
|
189
|
+
return ViroEventsTurboModule.getActiveListenerCount();
|
|
190
|
+
} catch (error) {
|
|
191
|
+
console.error("[ViroEventsManager] Error getting listener count:", error);
|
|
192
|
+
return 0;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Manually emit a JSI callback (for testing)
|
|
198
|
+
* @param {string} callbackId - The callback ID
|
|
199
|
+
* @param {object} eventData - The event data
|
|
200
|
+
*/
|
|
201
|
+
emitJSICallback(callbackId, eventData = {}) {
|
|
202
|
+
try {
|
|
203
|
+
ViroEventsTurboModule.emitJSICallback(callbackId, eventData);
|
|
204
|
+
} catch (error) {
|
|
205
|
+
console.error("[ViroEventsManager] Error emitting JSI callback:", error);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Manually emit a node event (for testing)
|
|
211
|
+
* @param {string} nodeId - The node ID
|
|
212
|
+
* @param {string} eventName - The event name
|
|
213
|
+
* @param {object} eventData - The event data
|
|
214
|
+
*/
|
|
215
|
+
emitNodeEvent(nodeId, eventName, eventData = {}) {
|
|
216
|
+
try {
|
|
217
|
+
ViroEventsTurboModule.emitNodeEvent(nodeId, eventName, eventData);
|
|
218
|
+
} catch (error) {
|
|
219
|
+
console.error("[ViroEventsManager] Error emitting node event:", error);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Manually emit a scene event (for testing)
|
|
225
|
+
* @param {string} sceneId - The scene ID
|
|
226
|
+
* @param {string} eventName - The event name
|
|
227
|
+
* @param {object} eventData - The event data
|
|
228
|
+
*/
|
|
229
|
+
emitSceneEvent(sceneId, eventName, eventData = {}) {
|
|
230
|
+
try {
|
|
231
|
+
ViroEventsTurboModule.emitSceneEvent(sceneId, eventName, eventData);
|
|
232
|
+
} catch (error) {
|
|
233
|
+
console.error("[ViroEventsManager] Error emitting scene event:", error);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Clean up all listeners and callbacks
|
|
239
|
+
*/
|
|
240
|
+
cleanup() {
|
|
241
|
+
console.log("[ViroEventsManager] Cleaning up event manager");
|
|
242
|
+
|
|
243
|
+
// Remove all event listeners
|
|
244
|
+
this.eventEmitter.removeAllListeners("ViroJSICallback");
|
|
245
|
+
this.eventEmitter.removeAllListeners("ViroNodeEvent");
|
|
246
|
+
this.eventEmitter.removeAllListeners("ViroSceneEvent");
|
|
247
|
+
|
|
248
|
+
// Clear registries
|
|
249
|
+
this.listeners.clear();
|
|
250
|
+
this.callbackRegistry.clear();
|
|
251
|
+
|
|
252
|
+
console.log("[ViroEventsManager] Event manager cleanup completed");
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Export singleton instance
|
|
257
|
+
export default new ViroEventsManager();
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ViroFabricContainer
|
|
3
|
+
*
|
|
4
|
+
* This is the main container component that Fabric manages directly.
|
|
5
|
+
* It serves as a viewport for the Viro rendering engine and delegates
|
|
6
|
+
* rendering to the existing native implementation.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
10
|
+
import {
|
|
11
|
+
requireNativeComponent,
|
|
12
|
+
UIManager,
|
|
13
|
+
findNodeHandle,
|
|
14
|
+
Platform,
|
|
15
|
+
View,
|
|
16
|
+
Text,
|
|
17
|
+
NativeEventEmitter,
|
|
18
|
+
NativeModules,
|
|
19
|
+
} from "react-native";
|
|
20
|
+
|
|
21
|
+
// Check if New Architecture is enabled
|
|
22
|
+
const isNewArchitectureEnabled = () => {
|
|
23
|
+
if (global.__turboModuleProxy == null) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
"Viro: New Architecture is not enabled. This library requires React Native New Architecture. " +
|
|
26
|
+
"Please enable it in your app by following the instructions at: " +
|
|
27
|
+
"https://reactnative.dev/docs/new-architecture-intro"
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// We're assuming the minimum supported version (0.76.9+) since this is a Fabric-only component
|
|
32
|
+
return true;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// Check if the component exists in UIManager
|
|
36
|
+
const isFabricComponentAvailable = () => {
|
|
37
|
+
isNewArchitectureEnabled(); // This will throw if New Architecture is not enabled
|
|
38
|
+
|
|
39
|
+
if (
|
|
40
|
+
!UIManager.getViewManagerConfig ||
|
|
41
|
+
UIManager.getViewManagerConfig("ViroFabricContainerView") == null
|
|
42
|
+
) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
"ViroFabricContainerView is not available. Make sure you have installed the native module properly."
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return true;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// Define the native component
|
|
52
|
+
// @ts-ignore - TypeScript doesn't know about the props of the native component
|
|
53
|
+
const NativeViroFabricContainer = requireNativeComponent<any>(
|
|
54
|
+
"ViroFabricContainerView"
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
// Props for the container
|
|
58
|
+
export interface ViroFabricContainerProps {
|
|
59
|
+
// General props
|
|
60
|
+
debug?: boolean;
|
|
61
|
+
style?: React.CSSProperties;
|
|
62
|
+
|
|
63
|
+
// AR specific props
|
|
64
|
+
arEnabled?: boolean;
|
|
65
|
+
autofocus?: boolean;
|
|
66
|
+
worldAlignment?: "Gravity" | "GravityAndHeading" | "Camera";
|
|
67
|
+
videoQuality?: "High" | "Low";
|
|
68
|
+
|
|
69
|
+
// Event callbacks
|
|
70
|
+
onInitialized?: (success: boolean) => void;
|
|
71
|
+
onTrackingUpdated?: (state: any) => void;
|
|
72
|
+
onCameraTransformUpdate?: (transform: any) => void;
|
|
73
|
+
onARSessionFailed?: (error: string) => void;
|
|
74
|
+
|
|
75
|
+
// Scene management callbacks
|
|
76
|
+
onSceneStateChanged?: (event: { sceneId: string; state: string }) => void;
|
|
77
|
+
onMemoryWarning?: (event: { memoryStats: Record<string, any> }) => void;
|
|
78
|
+
|
|
79
|
+
// Children components
|
|
80
|
+
children?: React.ReactNode;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* ViroFabricContainer is the main component that hosts the Viro rendering engine.
|
|
85
|
+
* It creates a native view that the Viro renderer can draw on and manages the
|
|
86
|
+
* lifecycle of the Viro system.
|
|
87
|
+
*/
|
|
88
|
+
export const ViroFabricContainer: React.FC<ViroFabricContainerProps> = ({
|
|
89
|
+
debug = false,
|
|
90
|
+
arEnabled = false,
|
|
91
|
+
worldAlignment = "Gravity",
|
|
92
|
+
onInitialized,
|
|
93
|
+
onTrackingUpdated,
|
|
94
|
+
onCameraTransformUpdate,
|
|
95
|
+
onSceneStateChanged,
|
|
96
|
+
onMemoryWarning,
|
|
97
|
+
children,
|
|
98
|
+
}) => {
|
|
99
|
+
// Reference to the native component
|
|
100
|
+
const containerRef = useRef<any>(null);
|
|
101
|
+
|
|
102
|
+
// Root node ID for the scene
|
|
103
|
+
const rootNodeId = useRef<string>("viro_root_scene");
|
|
104
|
+
|
|
105
|
+
// Event callback registry
|
|
106
|
+
const eventCallbacks = useRef<Record<string, (event: any) => void>>({});
|
|
107
|
+
|
|
108
|
+
// Set up event handling for JSI and fallback event emitter approach
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
// Set up global event handler for JSI events
|
|
111
|
+
if (typeof global !== "undefined") {
|
|
112
|
+
// @ts-ignore - This property will be added by the native code
|
|
113
|
+
global.handleViroEvent = (callbackId: string, eventData: any) => {
|
|
114
|
+
// Find the callback in the registry and call it
|
|
115
|
+
const callback = eventCallbacks.current[callbackId];
|
|
116
|
+
if (callback) {
|
|
117
|
+
callback(eventData);
|
|
118
|
+
} else {
|
|
119
|
+
console.warn(`No callback found for ID: ${callbackId}`);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Set up event emitter for fallback approach
|
|
125
|
+
const eventEmitter = new NativeEventEmitter(
|
|
126
|
+
NativeModules.ViroFabricManager
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
// Add the ViroEvent listener
|
|
130
|
+
const subscription = eventEmitter.addListener("ViroEvent", (event) => {
|
|
131
|
+
const { callbackId, data } = event;
|
|
132
|
+
const callback = eventCallbacks.current[callbackId];
|
|
133
|
+
if (callback) {
|
|
134
|
+
callback(data);
|
|
135
|
+
} else {
|
|
136
|
+
console.warn(
|
|
137
|
+
`No callback found for ID: ${callbackId} (via event emitter)`
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
return () => {
|
|
143
|
+
// Clean up event subscription
|
|
144
|
+
subscription.remove();
|
|
145
|
+
|
|
146
|
+
// Clean up global event handler
|
|
147
|
+
if (typeof global !== "undefined") {
|
|
148
|
+
// @ts-ignore - This property was added by us
|
|
149
|
+
delete global.handleViroEvent;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}, []);
|
|
153
|
+
|
|
154
|
+
// Initialize the Viro system when the component mounts
|
|
155
|
+
useEffect(() => {
|
|
156
|
+
if (containerRef.current && isFabricComponentAvailable()) {
|
|
157
|
+
const nodeHandle = findNodeHandle(containerRef.current);
|
|
158
|
+
if (!nodeHandle) {
|
|
159
|
+
console.error("Failed to get node handle for ViroFabricContainer");
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
// Use the codegenNativeCommands approach for New Architecture
|
|
165
|
+
const ViroFabricContainerCommands = UIManager.getViewManagerConfig(
|
|
166
|
+
"ViroFabricContainerView"
|
|
167
|
+
).Commands;
|
|
168
|
+
|
|
169
|
+
if (!ViroFabricContainerCommands) {
|
|
170
|
+
console.error(
|
|
171
|
+
"ViroFabricContainerView commands not found in UIManager"
|
|
172
|
+
);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Call the native method to initialize
|
|
177
|
+
UIManager.dispatchViewManagerCommand(
|
|
178
|
+
nodeHandle,
|
|
179
|
+
ViroFabricContainerCommands.initialize,
|
|
180
|
+
[debug || false, arEnabled || false, worldAlignment || "Gravity"]
|
|
181
|
+
);
|
|
182
|
+
} catch (error) {
|
|
183
|
+
console.error("Failed to initialize ViroFabricContainer:", error);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Cleanup when unmounting
|
|
188
|
+
return () => {
|
|
189
|
+
if (containerRef.current) {
|
|
190
|
+
const nodeHandle = findNodeHandle(containerRef.current);
|
|
191
|
+
if (!nodeHandle) return;
|
|
192
|
+
|
|
193
|
+
try {
|
|
194
|
+
// Use the same approach as initialize for cleanup
|
|
195
|
+
const ViroFabricContainerCommands = UIManager.getViewManagerConfig(
|
|
196
|
+
"ViroFabricContainerView"
|
|
197
|
+
).Commands;
|
|
198
|
+
|
|
199
|
+
if (
|
|
200
|
+
!ViroFabricContainerCommands ||
|
|
201
|
+
!ViroFabricContainerCommands.cleanup
|
|
202
|
+
) {
|
|
203
|
+
console.error(
|
|
204
|
+
"ViroFabricContainerView cleanup command not found in UIManager"
|
|
205
|
+
);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Call the native method to cleanup
|
|
210
|
+
UIManager.dispatchViewManagerCommand(
|
|
211
|
+
nodeHandle,
|
|
212
|
+
ViroFabricContainerCommands.cleanup,
|
|
213
|
+
[]
|
|
214
|
+
);
|
|
215
|
+
} catch (error) {
|
|
216
|
+
console.error("Failed to cleanup ViroFabricContainer:", error);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
}, [debug, arEnabled, worldAlignment]);
|
|
221
|
+
|
|
222
|
+
// Handle initialization event
|
|
223
|
+
const handleInitialized = (event: any) => {
|
|
224
|
+
if (onInitialized) {
|
|
225
|
+
onInitialized(event.nativeEvent.success);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
// Handle tracking updated event
|
|
230
|
+
const handleTrackingUpdated = (event: any) => {
|
|
231
|
+
if (onTrackingUpdated) {
|
|
232
|
+
onTrackingUpdated(event.nativeEvent);
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
// Handle camera transform update event
|
|
237
|
+
const handleCameraTransformUpdate = (event: any) => {
|
|
238
|
+
if (onCameraTransformUpdate) {
|
|
239
|
+
onCameraTransformUpdate(event.nativeEvent);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
// Handle scene state changed event
|
|
244
|
+
const handleSceneStateChanged = (event: any) => {
|
|
245
|
+
if (onSceneStateChanged) {
|
|
246
|
+
onSceneStateChanged(event.nativeEvent);
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
// Handle memory warning event
|
|
251
|
+
const handleMemoryWarning = (event: any) => {
|
|
252
|
+
if (onMemoryWarning) {
|
|
253
|
+
onMemoryWarning(event.nativeEvent);
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
// This will throw an error if the native component is not available or New Architecture is not enabled
|
|
258
|
+
isFabricComponentAvailable();
|
|
259
|
+
|
|
260
|
+
return (
|
|
261
|
+
<NativeViroFabricContainer
|
|
262
|
+
ref={containerRef}
|
|
263
|
+
style={{ flex: 1 }}
|
|
264
|
+
onInitialized={handleInitialized}
|
|
265
|
+
onTrackingUpdated={handleTrackingUpdated}
|
|
266
|
+
onCameraTransformUpdate={handleCameraTransformUpdate}
|
|
267
|
+
onSceneStateChanged={handleSceneStateChanged}
|
|
268
|
+
onMemoryWarning={handleMemoryWarning}
|
|
269
|
+
>
|
|
270
|
+
{children}
|
|
271
|
+
</NativeViroFabricContainer>
|
|
272
|
+
);
|
|
273
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ViroARPlane
|
|
3
|
+
*
|
|
4
|
+
* Container for Viro Components anchored to a detected plane.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { useEffect, useState } from "react";
|
|
9
|
+
import { ViroNode } from "../ViroNode";
|
|
10
|
+
import { useViroNode } from "../ViroUtils";
|
|
11
|
+
import {
|
|
12
|
+
registerEventListener,
|
|
13
|
+
unregisterEventListener,
|
|
14
|
+
} from "../../NativeViro";
|
|
15
|
+
import { ViroCommonProps, ViroObjectProps } from "./ViroCommonProps";
|
|
16
|
+
import { ViroAnchorFoundMap, ViroAnchorUpdatedMap } from "../Types/ViroEvents";
|
|
17
|
+
|
|
18
|
+
type Props = ViroCommonProps &
|
|
19
|
+
ViroObjectProps & {
|
|
20
|
+
anchorId?: string;
|
|
21
|
+
minHeight?: number;
|
|
22
|
+
minWidth?: number;
|
|
23
|
+
alignment?:
|
|
24
|
+
| "Horizontal"
|
|
25
|
+
| "HorizontalUpward"
|
|
26
|
+
| "HorizontalDownward"
|
|
27
|
+
| "Vertical";
|
|
28
|
+
onAnchorFound?: (anchorMap: ViroAnchorFoundMap) => void;
|
|
29
|
+
onAnchorUpdated?: (anchorMap: ViroAnchorUpdatedMap) => void;
|
|
30
|
+
onAnchorRemoved?: () => void;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Container for Viro Components anchored to a detected plane.
|
|
35
|
+
*/
|
|
36
|
+
export function ViroARPlane(props: Props): React.ReactElement {
|
|
37
|
+
const {
|
|
38
|
+
anchorId,
|
|
39
|
+
minHeight,
|
|
40
|
+
minWidth,
|
|
41
|
+
alignment,
|
|
42
|
+
onAnchorFound,
|
|
43
|
+
onAnchorUpdated,
|
|
44
|
+
onAnchorRemoved,
|
|
45
|
+
children,
|
|
46
|
+
...rest
|
|
47
|
+
} = props;
|
|
48
|
+
|
|
49
|
+
// Create the node
|
|
50
|
+
const nodeProps = {
|
|
51
|
+
...rest,
|
|
52
|
+
anchorId,
|
|
53
|
+
minHeight,
|
|
54
|
+
minWidth,
|
|
55
|
+
alignment,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const nodeId = useViroNode("arPlane", nodeProps);
|
|
59
|
+
|
|
60
|
+
// Set up event listeners
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
const anchorFoundCallbackId = onAnchorFound
|
|
63
|
+
? registerEventListener(nodeId, "onAnchorFound", (event) => {
|
|
64
|
+
onAnchorFound(event.anchorFoundMap);
|
|
65
|
+
})
|
|
66
|
+
: null;
|
|
67
|
+
|
|
68
|
+
const anchorUpdatedCallbackId = onAnchorUpdated
|
|
69
|
+
? registerEventListener(nodeId, "onAnchorUpdated", (event) => {
|
|
70
|
+
onAnchorUpdated(event.anchorUpdatedMap);
|
|
71
|
+
})
|
|
72
|
+
: null;
|
|
73
|
+
|
|
74
|
+
const anchorRemovedCallbackId = onAnchorRemoved
|
|
75
|
+
? registerEventListener(nodeId, "onAnchorRemoved", () => {
|
|
76
|
+
onAnchorRemoved();
|
|
77
|
+
})
|
|
78
|
+
: null;
|
|
79
|
+
|
|
80
|
+
// Clean up event listeners
|
|
81
|
+
return () => {
|
|
82
|
+
if (anchorFoundCallbackId) {
|
|
83
|
+
unregisterEventListener(nodeId, "onAnchorFound", anchorFoundCallbackId);
|
|
84
|
+
}
|
|
85
|
+
if (anchorUpdatedCallbackId) {
|
|
86
|
+
unregisterEventListener(
|
|
87
|
+
nodeId,
|
|
88
|
+
"onAnchorUpdated",
|
|
89
|
+
anchorUpdatedCallbackId
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
if (anchorRemovedCallbackId) {
|
|
93
|
+
unregisterEventListener(
|
|
94
|
+
nodeId,
|
|
95
|
+
"onAnchorRemoved",
|
|
96
|
+
anchorRemovedCallbackId
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}, [nodeId, onAnchorFound, onAnchorUpdated, onAnchorRemoved]);
|
|
101
|
+
|
|
102
|
+
// Render children within this node
|
|
103
|
+
return (
|
|
104
|
+
<ViroNode viroTag={nodeId} position={[0, 0, 0]}>
|
|
105
|
+
{children}
|
|
106
|
+
</ViroNode>
|
|
107
|
+
);
|
|
108
|
+
}
|