@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.
Files changed (475) hide show
  1. package/README.md +12 -6
  2. package/android/react_viro/react_viro-release.aar +0 -0
  3. package/components/AR/ViroARPlaneSelector.tsx +76 -37
  4. package/components/Utilities/ViroVersion.ts +1 -1
  5. package/dist/components/AR/ViroARPlaneSelector.d.ts +1 -1
  6. package/dist/components/AR/ViroARPlaneSelector.js +46 -18
  7. package/dist/components/Utilities/ViroVersion.d.ts +1 -1
  8. package/dist/components/Utilities/ViroVersion.js +1 -1
  9. package/dist/dynamic-index.d.ts +11 -0
  10. package/dist/dynamic-index.js +28 -0
  11. package/dist/examples/AutoDetectionExample.d.ts +10 -0
  12. package/dist/examples/AutoDetectionExample.js +91 -0
  13. package/dist/fabric-interop/NativeViro.d.ts +42 -0
  14. package/dist/fabric-interop/NativeViro.js +262 -0
  15. package/dist/fabric-interop/ViroEventsManager.d.ts +83 -0
  16. package/dist/fabric-interop/ViroEventsManager.js +222 -0
  17. package/dist/fabric-interop/ViroFabricContainer.d.ts +34 -0
  18. package/dist/fabric-interop/ViroFabricContainer.js +200 -0
  19. package/dist/fabric-interop/android/src/main/js/specs/ViroFabricContainerViewNativeComponent.d.ts +35 -0
  20. package/dist/fabric-interop/android/src/main/js/specs/ViroFabricContainerViewNativeComponent.js +20 -0
  21. package/dist/fabric-interop/components/AR/ViroARPlane.d.ts +22 -0
  22. package/dist/fabric-interop/components/AR/ViroARPlane.js +95 -0
  23. package/dist/fabric-interop/components/AR/ViroARPlaneSelector.d.ts +43 -0
  24. package/dist/fabric-interop/components/AR/ViroARPlaneSelector.js +152 -0
  25. package/dist/fabric-interop/components/AR/ViroARTrackingTargets.d.ts +55 -0
  26. package/dist/fabric-interop/components/AR/ViroARTrackingTargets.js +85 -0
  27. package/dist/fabric-interop/components/AR/ViroCommonProps.d.ts +91 -0
  28. package/dist/fabric-interop/components/AR/ViroCommonProps.js +7 -0
  29. package/dist/fabric-interop/components/Animation/ViroAnimations.d.ts +48 -0
  30. package/dist/fabric-interop/components/Animation/ViroAnimations.js +64 -0
  31. package/dist/fabric-interop/components/Material/ViroMaterials.d.ts +66 -0
  32. package/dist/fabric-interop/components/Material/ViroMaterials.js +85 -0
  33. package/dist/fabric-interop/components/Types/ViroEvents.d.ts +202 -0
  34. package/dist/fabric-interop/components/Types/ViroEvents.js +53 -0
  35. package/dist/fabric-interop/components/Types/ViroUtils.d.ts +137 -0
  36. package/dist/fabric-interop/components/Types/ViroUtils.js +7 -0
  37. package/dist/fabric-interop/components/Viro360Image.d.ts +23 -0
  38. package/dist/fabric-interop/components/Viro360Image.js +45 -0
  39. package/dist/fabric-interop/components/Viro360Video.d.ts +29 -0
  40. package/dist/fabric-interop/components/Viro360Video.js +47 -0
  41. package/dist/fabric-interop/components/Viro3DObject.d.ts +60 -0
  42. package/dist/fabric-interop/components/Viro3DObject.js +49 -0
  43. package/dist/fabric-interop/components/Viro3DSceneNavigator.d.ts +49 -0
  44. package/dist/fabric-interop/components/Viro3DSceneNavigator.js +388 -0
  45. package/dist/fabric-interop/components/ViroARCamera.d.ts +29 -0
  46. package/dist/fabric-interop/components/ViroARCamera.js +64 -0
  47. package/dist/fabric-interop/components/ViroARImageMarker.d.ts +21 -0
  48. package/dist/fabric-interop/components/ViroARImageMarker.js +71 -0
  49. package/dist/fabric-interop/components/ViroARObjectMarker.d.ts +21 -0
  50. package/dist/fabric-interop/components/ViroARObjectMarker.js +71 -0
  51. package/dist/fabric-interop/components/ViroARPlane.d.ts +24 -0
  52. package/dist/fabric-interop/components/ViroARPlane.js +88 -0
  53. package/dist/fabric-interop/components/ViroARScene.d.ts +29 -0
  54. package/dist/fabric-interop/components/ViroARScene.js +89 -0
  55. package/dist/fabric-interop/components/ViroARSceneNavigator.d.ts +29 -0
  56. package/dist/fabric-interop/components/ViroARSceneNavigator.js +76 -0
  57. package/dist/fabric-interop/components/ViroAmbientLight.d.ts +19 -0
  58. package/dist/fabric-interop/components/ViroAmbientLight.js +46 -0
  59. package/dist/fabric-interop/components/ViroAnimatedComponent.d.ts +24 -0
  60. package/dist/fabric-interop/components/ViroAnimatedComponent.js +63 -0
  61. package/dist/fabric-interop/components/ViroAnimatedImage.d.ts +28 -0
  62. package/dist/fabric-interop/components/ViroAnimatedImage.js +49 -0
  63. package/dist/fabric-interop/components/ViroBox.d.ts +20 -0
  64. package/dist/fabric-interop/components/ViroBox.js +47 -0
  65. package/dist/fabric-interop/components/ViroButton.d.ts +32 -0
  66. package/dist/fabric-interop/components/ViroButton.js +92 -0
  67. package/dist/fabric-interop/components/ViroCamera.d.ts +17 -0
  68. package/dist/fabric-interop/components/ViroCamera.js +30 -0
  69. package/dist/fabric-interop/components/ViroController.d.ts +19 -0
  70. package/dist/fabric-interop/components/ViroController.js +64 -0
  71. package/dist/fabric-interop/components/ViroDirectionalLight.d.ts +28 -0
  72. package/dist/fabric-interop/components/ViroDirectionalLight.js +55 -0
  73. package/dist/fabric-interop/components/ViroFlexView.d.ts +36 -0
  74. package/dist/fabric-interop/components/ViroFlexView.js +97 -0
  75. package/dist/fabric-interop/components/ViroGeometry.d.ts +23 -0
  76. package/dist/fabric-interop/components/ViroGeometry.js +50 -0
  77. package/dist/fabric-interop/components/ViroGlobal.d.ts +45 -0
  78. package/dist/fabric-interop/components/ViroGlobal.js +20 -0
  79. package/dist/fabric-interop/components/ViroImage.d.ts +29 -0
  80. package/dist/fabric-interop/components/ViroImage.js +52 -0
  81. package/dist/fabric-interop/components/ViroLightingEnvironment.d.ts +19 -0
  82. package/dist/fabric-interop/components/ViroLightingEnvironment.js +44 -0
  83. package/dist/fabric-interop/components/ViroMaterialVideo.d.ts +30 -0
  84. package/dist/fabric-interop/components/ViroMaterialVideo.js +48 -0
  85. package/dist/fabric-interop/components/ViroNode.d.ts +36 -0
  86. package/dist/fabric-interop/components/ViroNode.js +28 -0
  87. package/dist/fabric-interop/components/ViroOmniLight.d.ts +21 -0
  88. package/dist/fabric-interop/components/ViroOmniLight.js +48 -0
  89. package/dist/fabric-interop/components/ViroOrbitCamera.d.ts +17 -0
  90. package/dist/fabric-interop/components/ViroOrbitCamera.js +30 -0
  91. package/dist/fabric-interop/components/ViroParticleEmitter.d.ts +51 -0
  92. package/dist/fabric-interop/components/ViroParticleEmitter.js +50 -0
  93. package/dist/fabric-interop/components/ViroPolygon.d.ts +20 -0
  94. package/dist/fabric-interop/components/ViroPolygon.js +47 -0
  95. package/dist/fabric-interop/components/ViroPolyline.d.ts +19 -0
  96. package/dist/fabric-interop/components/ViroPolyline.js +46 -0
  97. package/dist/fabric-interop/components/ViroPortal.d.ts +16 -0
  98. package/dist/fabric-interop/components/ViroPortal.js +73 -0
  99. package/dist/fabric-interop/components/ViroPortalScene.d.ts +16 -0
  100. package/dist/fabric-interop/components/ViroPortalScene.js +29 -0
  101. package/dist/fabric-interop/components/ViroQuad.d.ts +39 -0
  102. package/dist/fabric-interop/components/ViroQuad.js +49 -0
  103. package/dist/fabric-interop/components/ViroScene.d.ts +29 -0
  104. package/dist/fabric-interop/components/ViroScene.js +103 -0
  105. package/dist/fabric-interop/components/ViroSceneNavigator.d.ts +23 -0
  106. package/dist/fabric-interop/components/ViroSceneNavigator.js +73 -0
  107. package/dist/fabric-interop/components/ViroSkyBox.d.ts +39 -0
  108. package/dist/fabric-interop/components/ViroSkyBox.js +44 -0
  109. package/dist/fabric-interop/components/ViroSound.d.ts +23 -0
  110. package/dist/fabric-interop/components/ViroSound.js +46 -0
  111. package/dist/fabric-interop/components/ViroSoundField.d.ts +24 -0
  112. package/dist/fabric-interop/components/ViroSoundField.js +47 -0
  113. package/dist/fabric-interop/components/ViroSpatialSound.d.ts +27 -0
  114. package/dist/fabric-interop/components/ViroSpatialSound.js +50 -0
  115. package/dist/fabric-interop/components/ViroSphere.d.ts +22 -0
  116. package/dist/fabric-interop/components/ViroSphere.js +49 -0
  117. package/dist/fabric-interop/components/ViroSpinner.d.ts +18 -0
  118. package/dist/fabric-interop/components/ViroSpinner.js +45 -0
  119. package/dist/fabric-interop/components/ViroSpotLight.d.ts +30 -0
  120. package/dist/fabric-interop/components/ViroSpotLight.js +57 -0
  121. package/dist/fabric-interop/components/ViroSurface.d.ts +38 -0
  122. package/dist/fabric-interop/components/ViroSurface.js +48 -0
  123. package/dist/fabric-interop/components/ViroText.d.ts +36 -0
  124. package/dist/fabric-interop/components/ViroText.js +59 -0
  125. package/dist/fabric-interop/components/ViroUtils.d.ts +63 -0
  126. package/dist/fabric-interop/components/ViroUtils.js +140 -0
  127. package/dist/fabric-interop/components/ViroVRSceneNavigator.d.ts +25 -0
  128. package/dist/fabric-interop/components/ViroVRSceneNavigator.js +73 -0
  129. package/dist/fabric-interop/components/ViroVideo.d.ts +32 -0
  130. package/dist/fabric-interop/components/ViroVideo.js +52 -0
  131. package/dist/fabric-interop/components/index.d.ts +62 -0
  132. package/dist/fabric-interop/components/index.js +144 -0
  133. package/dist/fabric-interop/examples/BasicSceneExample.d.ts +11 -0
  134. package/dist/fabric-interop/examples/BasicSceneExample.js +244 -0
  135. package/dist/fabric-interop/examples/ComprehensiveExample.d.ts +13 -0
  136. package/dist/fabric-interop/examples/ComprehensiveExample.js +327 -0
  137. package/dist/fabric-interop/examples/SimpleARExample.d.ts +8 -0
  138. package/dist/fabric-interop/examples/SimpleARExample.js +62 -0
  139. package/dist/fabric-interop/index.d.ts +14 -0
  140. package/dist/fabric-interop/index.js +117 -0
  141. package/dist/fabric-interop/specs/ViroEventsTurboModule.d.ts +19 -0
  142. package/dist/fabric-interop/specs/ViroEventsTurboModule.js +11 -0
  143. package/dist/fabric-interop/test/BasicFunctionalityTest.d.ts +9 -0
  144. package/dist/fabric-interop/test/BasicFunctionalityTest.js +222 -0
  145. package/dist/fabric.d.ts +13 -0
  146. package/dist/fabric.js +29 -0
  147. package/dist/plugins/withViro.d.ts +3 -0
  148. package/dist/plugins/withViro.js +19 -0
  149. package/dist/plugins/withViroAndroid.js +24 -20
  150. package/dist/plugins/withViroIos.js +20 -2
  151. package/dynamic-index-source.d.ts +77 -0
  152. package/dynamic-index.ts +41 -0
  153. package/fabric-interop/NativeViro.ts +335 -0
  154. package/fabric-interop/README.md +282 -0
  155. package/fabric-interop/ViroEventsManager.js +257 -0
  156. package/fabric-interop/ViroFabricContainer.tsx +273 -0
  157. package/fabric-interop/components/AR/ViroARPlane.tsx +108 -0
  158. package/fabric-interop/components/AR/ViroARPlaneSelector.tsx +185 -0
  159. package/fabric-interop/components/AR/ViroARTrackingTargets.ts +108 -0
  160. package/fabric-interop/components/AR/ViroCommonProps.ts +140 -0
  161. package/fabric-interop/components/Animation/ViroAnimations.ts +96 -0
  162. package/fabric-interop/components/Material/ViroMaterials.ts +127 -0
  163. package/fabric-interop/components/Resources/viro_spinner_1.png +0 -0
  164. package/fabric-interop/components/Resources/viro_spinner_1_w.png +0 -0
  165. package/fabric-interop/components/Resources/viro_spinner_1a.png +0 -0
  166. package/fabric-interop/components/Resources/viro_spinner_1a_w.png +0 -0
  167. package/fabric-interop/components/Types/ViroEvents.ts +285 -0
  168. package/fabric-interop/components/Types/ViroUtils.ts +160 -0
  169. package/fabric-interop/components/Viro360Image.tsx +70 -0
  170. package/fabric-interop/components/Viro360Video.tsx +78 -0
  171. package/fabric-interop/components/Viro3DObject.tsx +122 -0
  172. package/fabric-interop/components/Viro3DSceneNavigator.tsx +503 -0
  173. package/fabric-interop/components/ViroARCamera.tsx +105 -0
  174. package/fabric-interop/components/ViroARImageMarker.tsx +98 -0
  175. package/fabric-interop/components/ViroARObjectMarker.tsx +100 -0
  176. package/fabric-interop/components/ViroARPlane.tsx +120 -0
  177. package/fabric-interop/components/ViroARScene.tsx +127 -0
  178. package/fabric-interop/components/ViroARSceneNavigator.tsx +82 -0
  179. package/fabric-interop/components/ViroAmbientLight.tsx +62 -0
  180. package/fabric-interop/components/ViroAnimatedComponent.tsx +91 -0
  181. package/fabric-interop/components/ViroAnimatedImage.tsx +81 -0
  182. package/fabric-interop/components/ViroBox.tsx +72 -0
  183. package/fabric-interop/components/ViroButton.tsx +125 -0
  184. package/fabric-interop/components/ViroCamera.tsx +45 -0
  185. package/fabric-interop/components/ViroController.tsx +87 -0
  186. package/fabric-interop/components/ViroDirectionalLight.tsx +84 -0
  187. package/fabric-interop/components/ViroFlexView.tsx +146 -0
  188. package/fabric-interop/components/ViroGeometry.tsx +78 -0
  189. package/fabric-interop/components/ViroGlobal.ts +114 -0
  190. package/fabric-interop/components/ViroImage.tsx +85 -0
  191. package/fabric-interop/components/ViroLightingEnvironment.tsx +63 -0
  192. package/fabric-interop/components/ViroMaterialVideo.tsx +82 -0
  193. package/fabric-interop/components/ViroNode.tsx +62 -0
  194. package/fabric-interop/components/ViroOmniLight.tsx +66 -0
  195. package/fabric-interop/components/ViroOrbitCamera.tsx +45 -0
  196. package/fabric-interop/components/ViroParticleEmitter.tsx +111 -0
  197. package/fabric-interop/components/ViroPolygon.tsx +72 -0
  198. package/fabric-interop/components/ViroPolyline.tsx +71 -0
  199. package/fabric-interop/components/ViroPortal.tsx +91 -0
  200. package/fabric-interop/components/ViroPortalScene.tsx +43 -0
  201. package/fabric-interop/components/ViroQuad.tsx +82 -0
  202. package/fabric-interop/components/ViroScene.tsx +117 -0
  203. package/fabric-interop/components/ViroSceneNavigator.tsx +71 -0
  204. package/fabric-interop/components/ViroSkyBox.tsx +75 -0
  205. package/fabric-interop/components/ViroSound.tsx +71 -0
  206. package/fabric-interop/components/ViroSoundField.tsx +75 -0
  207. package/fabric-interop/components/ViroSpatialSound.tsx +81 -0
  208. package/fabric-interop/components/ViroSphere.tsx +75 -0
  209. package/fabric-interop/components/ViroSpinner.tsx +63 -0
  210. package/fabric-interop/components/ViroSpotLight.tsx +86 -0
  211. package/fabric-interop/components/ViroSurface.tsx +80 -0
  212. package/fabric-interop/components/ViroText.tsx +114 -0
  213. package/fabric-interop/components/ViroUtils.ts +208 -0
  214. package/fabric-interop/components/ViroVRSceneNavigator.tsx +75 -0
  215. package/fabric-interop/components/ViroVideo.tsx +91 -0
  216. package/fabric-interop/components/index.ts +94 -0
  217. package/fabric-interop/dist/NativeViro.d.ts +43 -0
  218. package/fabric-interop/dist/NativeViro.d.ts.map +1 -0
  219. package/fabric-interop/dist/NativeViro.js +263 -0
  220. package/fabric-interop/dist/NativeViro.js.map +1 -0
  221. package/fabric-interop/dist/ViroFabricContainer.d.ts +35 -0
  222. package/fabric-interop/dist/ViroFabricContainer.d.ts.map +1 -0
  223. package/fabric-interop/dist/ViroFabricContainer.js +201 -0
  224. package/fabric-interop/dist/ViroFabricContainer.js.map +1 -0
  225. package/fabric-interop/dist/components/AR/ViroARPlane.d.ts +23 -0
  226. package/fabric-interop/dist/components/AR/ViroARPlane.d.ts.map +1 -0
  227. package/fabric-interop/dist/components/AR/ViroARPlane.js +96 -0
  228. package/fabric-interop/dist/components/AR/ViroARPlane.js.map +1 -0
  229. package/fabric-interop/dist/components/AR/ViroARPlaneSelector.d.ts +44 -0
  230. package/fabric-interop/dist/components/AR/ViroARPlaneSelector.d.ts.map +1 -0
  231. package/fabric-interop/dist/components/AR/ViroARPlaneSelector.js +156 -0
  232. package/fabric-interop/dist/components/AR/ViroARPlaneSelector.js.map +1 -0
  233. package/fabric-interop/dist/components/AR/ViroARTrackingTargets.d.ts +56 -0
  234. package/fabric-interop/dist/components/AR/ViroARTrackingTargets.d.ts.map +1 -0
  235. package/fabric-interop/dist/components/AR/ViroARTrackingTargets.js +86 -0
  236. package/fabric-interop/dist/components/AR/ViroARTrackingTargets.js.map +1 -0
  237. package/fabric-interop/dist/components/AR/ViroCommonProps.d.ts +92 -0
  238. package/fabric-interop/dist/components/AR/ViroCommonProps.d.ts.map +1 -0
  239. package/fabric-interop/dist/components/AR/ViroCommonProps.js +8 -0
  240. package/fabric-interop/dist/components/AR/ViroCommonProps.js.map +1 -0
  241. package/fabric-interop/dist/components/Animation/ViroAnimations.d.ts +49 -0
  242. package/fabric-interop/dist/components/Animation/ViroAnimations.d.ts.map +1 -0
  243. package/fabric-interop/dist/components/Animation/ViroAnimations.js +65 -0
  244. package/fabric-interop/dist/components/Animation/ViroAnimations.js.map +1 -0
  245. package/fabric-interop/dist/components/Material/ViroMaterials.d.ts +67 -0
  246. package/fabric-interop/dist/components/Material/ViroMaterials.d.ts.map +1 -0
  247. package/fabric-interop/dist/components/Material/ViroMaterials.js +86 -0
  248. package/fabric-interop/dist/components/Material/ViroMaterials.js.map +1 -0
  249. package/fabric-interop/dist/components/Types/ViroEvents.d.ts +203 -0
  250. package/fabric-interop/dist/components/Types/ViroEvents.d.ts.map +1 -0
  251. package/fabric-interop/dist/components/Types/ViroEvents.js +54 -0
  252. package/fabric-interop/dist/components/Types/ViroEvents.js.map +1 -0
  253. package/fabric-interop/dist/components/Types/ViroUtils.d.ts +138 -0
  254. package/fabric-interop/dist/components/Types/ViroUtils.d.ts.map +1 -0
  255. package/fabric-interop/dist/components/Types/ViroUtils.js +8 -0
  256. package/fabric-interop/dist/components/Types/ViroUtils.js.map +1 -0
  257. package/fabric-interop/dist/components/Viro360Image.d.ts +24 -0
  258. package/fabric-interop/dist/components/Viro360Image.d.ts.map +1 -0
  259. package/fabric-interop/dist/components/Viro360Image.js +47 -0
  260. package/fabric-interop/dist/components/Viro360Image.js.map +1 -0
  261. package/fabric-interop/dist/components/Viro360Video.d.ts +30 -0
  262. package/fabric-interop/dist/components/Viro360Video.d.ts.map +1 -0
  263. package/fabric-interop/dist/components/Viro360Video.js +49 -0
  264. package/fabric-interop/dist/components/Viro360Video.js.map +1 -0
  265. package/fabric-interop/dist/components/Viro3DObject.d.ts +61 -0
  266. package/fabric-interop/dist/components/Viro3DObject.d.ts.map +1 -0
  267. package/fabric-interop/dist/components/Viro3DObject.js +51 -0
  268. package/fabric-interop/dist/components/Viro3DObject.js.map +1 -0
  269. package/fabric-interop/dist/components/Viro3DSceneNavigator.d.ts +50 -0
  270. package/fabric-interop/dist/components/Viro3DSceneNavigator.d.ts.map +1 -0
  271. package/fabric-interop/dist/components/Viro3DSceneNavigator.js +389 -0
  272. package/fabric-interop/dist/components/Viro3DSceneNavigator.js.map +1 -0
  273. package/fabric-interop/dist/components/ViroARCamera.d.ts +30 -0
  274. package/fabric-interop/dist/components/ViroARCamera.d.ts.map +1 -0
  275. package/fabric-interop/dist/components/ViroARCamera.js +65 -0
  276. package/fabric-interop/dist/components/ViroARCamera.js.map +1 -0
  277. package/fabric-interop/dist/components/ViroARImageMarker.d.ts +22 -0
  278. package/fabric-interop/dist/components/ViroARImageMarker.d.ts.map +1 -0
  279. package/fabric-interop/dist/components/ViroARImageMarker.js +72 -0
  280. package/fabric-interop/dist/components/ViroARImageMarker.js.map +1 -0
  281. package/fabric-interop/dist/components/ViroARObjectMarker.d.ts +22 -0
  282. package/fabric-interop/dist/components/ViroARObjectMarker.d.ts.map +1 -0
  283. package/fabric-interop/dist/components/ViroARObjectMarker.js +72 -0
  284. package/fabric-interop/dist/components/ViroARObjectMarker.js.map +1 -0
  285. package/fabric-interop/dist/components/ViroARPlane.d.ts +25 -0
  286. package/fabric-interop/dist/components/ViroARPlane.d.ts.map +1 -0
  287. package/fabric-interop/dist/components/ViroARPlane.js +89 -0
  288. package/fabric-interop/dist/components/ViroARPlane.js.map +1 -0
  289. package/fabric-interop/dist/components/ViroARScene.d.ts +30 -0
  290. package/fabric-interop/dist/components/ViroARScene.d.ts.map +1 -0
  291. package/fabric-interop/dist/components/ViroARScene.js +90 -0
  292. package/fabric-interop/dist/components/ViroARScene.js.map +1 -0
  293. package/fabric-interop/dist/components/ViroARSceneNavigator.d.ts +30 -0
  294. package/fabric-interop/dist/components/ViroARSceneNavigator.d.ts.map +1 -0
  295. package/fabric-interop/dist/components/ViroARSceneNavigator.js +78 -0
  296. package/fabric-interop/dist/components/ViroARSceneNavigator.js.map +1 -0
  297. package/fabric-interop/dist/components/ViroAmbientLight.d.ts +20 -0
  298. package/fabric-interop/dist/components/ViroAmbientLight.d.ts.map +1 -0
  299. package/fabric-interop/dist/components/ViroAmbientLight.js +48 -0
  300. package/fabric-interop/dist/components/ViroAmbientLight.js.map +1 -0
  301. package/fabric-interop/dist/components/ViroAnimatedComponent.d.ts +25 -0
  302. package/fabric-interop/dist/components/ViroAnimatedComponent.d.ts.map +1 -0
  303. package/fabric-interop/dist/components/ViroAnimatedComponent.js +65 -0
  304. package/fabric-interop/dist/components/ViroAnimatedComponent.js.map +1 -0
  305. package/fabric-interop/dist/components/ViroAnimatedImage.d.ts +29 -0
  306. package/fabric-interop/dist/components/ViroAnimatedImage.d.ts.map +1 -0
  307. package/fabric-interop/dist/components/ViroAnimatedImage.js +51 -0
  308. package/fabric-interop/dist/components/ViroAnimatedImage.js.map +1 -0
  309. package/fabric-interop/dist/components/ViroBox.d.ts +21 -0
  310. package/fabric-interop/dist/components/ViroBox.d.ts.map +1 -0
  311. package/fabric-interop/dist/components/ViroBox.js +49 -0
  312. package/fabric-interop/dist/components/ViroBox.js.map +1 -0
  313. package/fabric-interop/dist/components/ViroButton.d.ts +33 -0
  314. package/fabric-interop/dist/components/ViroButton.d.ts.map +1 -0
  315. package/fabric-interop/dist/components/ViroButton.js +94 -0
  316. package/fabric-interop/dist/components/ViroButton.js.map +1 -0
  317. package/fabric-interop/dist/components/ViroCamera.d.ts +18 -0
  318. package/fabric-interop/dist/components/ViroCamera.d.ts.map +1 -0
  319. package/fabric-interop/dist/components/ViroCamera.js +31 -0
  320. package/fabric-interop/dist/components/ViroCamera.js.map +1 -0
  321. package/fabric-interop/dist/components/ViroController.d.ts +20 -0
  322. package/fabric-interop/dist/components/ViroController.d.ts.map +1 -0
  323. package/fabric-interop/dist/components/ViroController.js +65 -0
  324. package/fabric-interop/dist/components/ViroController.js.map +1 -0
  325. package/fabric-interop/dist/components/ViroDirectionalLight.d.ts +29 -0
  326. package/fabric-interop/dist/components/ViroDirectionalLight.d.ts.map +1 -0
  327. package/fabric-interop/dist/components/ViroDirectionalLight.js +57 -0
  328. package/fabric-interop/dist/components/ViroDirectionalLight.js.map +1 -0
  329. package/fabric-interop/dist/components/ViroFlexView.d.ts +37 -0
  330. package/fabric-interop/dist/components/ViroFlexView.d.ts.map +1 -0
  331. package/fabric-interop/dist/components/ViroFlexView.js +98 -0
  332. package/fabric-interop/dist/components/ViroFlexView.js.map +1 -0
  333. package/fabric-interop/dist/components/ViroGeometry.d.ts +24 -0
  334. package/fabric-interop/dist/components/ViroGeometry.d.ts.map +1 -0
  335. package/fabric-interop/dist/components/ViroGeometry.js +52 -0
  336. package/fabric-interop/dist/components/ViroGeometry.js.map +1 -0
  337. package/fabric-interop/dist/components/ViroGlobal.d.ts +46 -0
  338. package/fabric-interop/dist/components/ViroGlobal.d.ts.map +1 -0
  339. package/fabric-interop/dist/components/ViroGlobal.js +21 -0
  340. package/fabric-interop/dist/components/ViroGlobal.js.map +1 -0
  341. package/fabric-interop/dist/components/ViroImage.d.ts +30 -0
  342. package/fabric-interop/dist/components/ViroImage.d.ts.map +1 -0
  343. package/fabric-interop/dist/components/ViroImage.js +54 -0
  344. package/fabric-interop/dist/components/ViroImage.js.map +1 -0
  345. package/fabric-interop/dist/components/ViroLightingEnvironment.d.ts +20 -0
  346. package/fabric-interop/dist/components/ViroLightingEnvironment.d.ts.map +1 -0
  347. package/fabric-interop/dist/components/ViroLightingEnvironment.js +46 -0
  348. package/fabric-interop/dist/components/ViroLightingEnvironment.js.map +1 -0
  349. package/fabric-interop/dist/components/ViroMaterialVideo.d.ts +31 -0
  350. package/fabric-interop/dist/components/ViroMaterialVideo.d.ts.map +1 -0
  351. package/fabric-interop/dist/components/ViroMaterialVideo.js +50 -0
  352. package/fabric-interop/dist/components/ViroMaterialVideo.js.map +1 -0
  353. package/fabric-interop/dist/components/ViroNode.d.ts +37 -0
  354. package/fabric-interop/dist/components/ViroNode.d.ts.map +1 -0
  355. package/fabric-interop/dist/components/ViroNode.js +29 -0
  356. package/fabric-interop/dist/components/ViroNode.js.map +1 -0
  357. package/fabric-interop/dist/components/ViroOmniLight.d.ts +22 -0
  358. package/fabric-interop/dist/components/ViroOmniLight.d.ts.map +1 -0
  359. package/fabric-interop/dist/components/ViroOmniLight.js +50 -0
  360. package/fabric-interop/dist/components/ViroOmniLight.js.map +1 -0
  361. package/fabric-interop/dist/components/ViroOrbitCamera.d.ts +18 -0
  362. package/fabric-interop/dist/components/ViroOrbitCamera.d.ts.map +1 -0
  363. package/fabric-interop/dist/components/ViroOrbitCamera.js +31 -0
  364. package/fabric-interop/dist/components/ViroOrbitCamera.js.map +1 -0
  365. package/fabric-interop/dist/components/ViroParticleEmitter.d.ts +52 -0
  366. package/fabric-interop/dist/components/ViroParticleEmitter.d.ts.map +1 -0
  367. package/fabric-interop/dist/components/ViroParticleEmitter.js +52 -0
  368. package/fabric-interop/dist/components/ViroParticleEmitter.js.map +1 -0
  369. package/fabric-interop/dist/components/ViroPolygon.d.ts +21 -0
  370. package/fabric-interop/dist/components/ViroPolygon.d.ts.map +1 -0
  371. package/fabric-interop/dist/components/ViroPolygon.js +49 -0
  372. package/fabric-interop/dist/components/ViroPolygon.js.map +1 -0
  373. package/fabric-interop/dist/components/ViroPolyline.d.ts +20 -0
  374. package/fabric-interop/dist/components/ViroPolyline.d.ts.map +1 -0
  375. package/fabric-interop/dist/components/ViroPolyline.js +48 -0
  376. package/fabric-interop/dist/components/ViroPolyline.js.map +1 -0
  377. package/fabric-interop/dist/components/ViroPortal.d.ts +17 -0
  378. package/fabric-interop/dist/components/ViroPortal.d.ts.map +1 -0
  379. package/fabric-interop/dist/components/ViroPortal.js +74 -0
  380. package/fabric-interop/dist/components/ViroPortal.js.map +1 -0
  381. package/fabric-interop/dist/components/ViroPortalScene.d.ts +17 -0
  382. package/fabric-interop/dist/components/ViroPortalScene.d.ts.map +1 -0
  383. package/fabric-interop/dist/components/ViroPortalScene.js +30 -0
  384. package/fabric-interop/dist/components/ViroPortalScene.js.map +1 -0
  385. package/fabric-interop/dist/components/ViroQuad.d.ts +40 -0
  386. package/fabric-interop/dist/components/ViroQuad.d.ts.map +1 -0
  387. package/fabric-interop/dist/components/ViroQuad.js +51 -0
  388. package/fabric-interop/dist/components/ViroQuad.js.map +1 -0
  389. package/fabric-interop/dist/components/ViroScene.d.ts +30 -0
  390. package/fabric-interop/dist/components/ViroScene.d.ts.map +1 -0
  391. package/fabric-interop/dist/components/ViroScene.js +105 -0
  392. package/fabric-interop/dist/components/ViroScene.js.map +1 -0
  393. package/fabric-interop/dist/components/ViroSceneNavigator.d.ts +24 -0
  394. package/fabric-interop/dist/components/ViroSceneNavigator.d.ts.map +1 -0
  395. package/fabric-interop/dist/components/ViroSceneNavigator.js +74 -0
  396. package/fabric-interop/dist/components/ViroSceneNavigator.js.map +1 -0
  397. package/fabric-interop/dist/components/ViroSkyBox.d.ts +40 -0
  398. package/fabric-interop/dist/components/ViroSkyBox.d.ts.map +1 -0
  399. package/fabric-interop/dist/components/ViroSkyBox.js +46 -0
  400. package/fabric-interop/dist/components/ViroSkyBox.js.map +1 -0
  401. package/fabric-interop/dist/components/ViroSound.d.ts +24 -0
  402. package/fabric-interop/dist/components/ViroSound.d.ts.map +1 -0
  403. package/fabric-interop/dist/components/ViroSound.js +48 -0
  404. package/fabric-interop/dist/components/ViroSound.js.map +1 -0
  405. package/fabric-interop/dist/components/ViroSoundField.d.ts +25 -0
  406. package/fabric-interop/dist/components/ViroSoundField.d.ts.map +1 -0
  407. package/fabric-interop/dist/components/ViroSoundField.js +49 -0
  408. package/fabric-interop/dist/components/ViroSoundField.js.map +1 -0
  409. package/fabric-interop/dist/components/ViroSpatialSound.d.ts +28 -0
  410. package/fabric-interop/dist/components/ViroSpatialSound.d.ts.map +1 -0
  411. package/fabric-interop/dist/components/ViroSpatialSound.js +52 -0
  412. package/fabric-interop/dist/components/ViroSpatialSound.js.map +1 -0
  413. package/fabric-interop/dist/components/ViroSphere.d.ts +23 -0
  414. package/fabric-interop/dist/components/ViroSphere.d.ts.map +1 -0
  415. package/fabric-interop/dist/components/ViroSphere.js +51 -0
  416. package/fabric-interop/dist/components/ViroSphere.js.map +1 -0
  417. package/fabric-interop/dist/components/ViroSpinner.d.ts +19 -0
  418. package/fabric-interop/dist/components/ViroSpinner.d.ts.map +1 -0
  419. package/fabric-interop/dist/components/ViroSpinner.js +47 -0
  420. package/fabric-interop/dist/components/ViroSpinner.js.map +1 -0
  421. package/fabric-interop/dist/components/ViroSpotLight.d.ts +31 -0
  422. package/fabric-interop/dist/components/ViroSpotLight.d.ts.map +1 -0
  423. package/fabric-interop/dist/components/ViroSpotLight.js +59 -0
  424. package/fabric-interop/dist/components/ViroSpotLight.js.map +1 -0
  425. package/fabric-interop/dist/components/ViroSurface.d.ts +39 -0
  426. package/fabric-interop/dist/components/ViroSurface.d.ts.map +1 -0
  427. package/fabric-interop/dist/components/ViroSurface.js +50 -0
  428. package/fabric-interop/dist/components/ViroSurface.js.map +1 -0
  429. package/fabric-interop/dist/components/ViroText.d.ts +37 -0
  430. package/fabric-interop/dist/components/ViroText.d.ts.map +1 -0
  431. package/fabric-interop/dist/components/ViroText.js +61 -0
  432. package/fabric-interop/dist/components/ViroText.js.map +1 -0
  433. package/fabric-interop/dist/components/ViroUtils.d.ts +64 -0
  434. package/fabric-interop/dist/components/ViroUtils.d.ts.map +1 -0
  435. package/fabric-interop/dist/components/ViroUtils.js +141 -0
  436. package/fabric-interop/dist/components/ViroUtils.js.map +1 -0
  437. package/fabric-interop/dist/components/ViroVRSceneNavigator.d.ts +26 -0
  438. package/fabric-interop/dist/components/ViroVRSceneNavigator.d.ts.map +1 -0
  439. package/fabric-interop/dist/components/ViroVRSceneNavigator.js +74 -0
  440. package/fabric-interop/dist/components/ViroVRSceneNavigator.js.map +1 -0
  441. package/fabric-interop/dist/components/ViroVideo.d.ts +33 -0
  442. package/fabric-interop/dist/components/ViroVideo.d.ts.map +1 -0
  443. package/fabric-interop/dist/components/ViroVideo.js +54 -0
  444. package/fabric-interop/dist/components/ViroVideo.js.map +1 -0
  445. package/fabric-interop/dist/components/index.d.ts +63 -0
  446. package/fabric-interop/dist/components/index.d.ts.map +1 -0
  447. package/fabric-interop/dist/components/index.js +145 -0
  448. package/fabric-interop/dist/components/index.js.map +1 -0
  449. package/fabric-interop/dist/index.d.ts +15 -0
  450. package/fabric-interop/dist/index.d.ts.map +1 -0
  451. package/fabric-interop/dist/index.js +118 -0
  452. package/fabric-interop/dist/index.js.map +1 -0
  453. package/fabric-interop/dist/specs/ViroEventsTurboModule.d.ts +20 -0
  454. package/fabric-interop/dist/specs/ViroEventsTurboModule.d.ts.map +1 -0
  455. package/fabric-interop/dist/specs/ViroEventsTurboModule.js +12 -0
  456. package/fabric-interop/dist/specs/ViroEventsTurboModule.js.map +1 -0
  457. package/fabric-interop/examples/BasicSceneExample.tsx +287 -0
  458. package/fabric-interop/examples/ComprehensiveExample.tsx +441 -0
  459. package/fabric-interop/examples/SimpleARExample.tsx +95 -0
  460. package/fabric-interop/global.d.ts +14 -0
  461. package/fabric-interop/index.ts +107 -0
  462. package/fabric-interop/metro.config.js +12 -0
  463. package/fabric-interop/package.json +40 -0
  464. package/fabric-interop/react-native.config.js +22 -0
  465. package/fabric-interop/scripts/validate-build.js +393 -0
  466. package/fabric-interop/scripts/validate-implementation.js +272 -0
  467. package/fabric-interop/specs/README.md +22 -0
  468. package/fabric-interop/specs/ViroEventsTurboModule.ts +27 -0
  469. package/fabric-interop/test/BasicFunctionalityTest.tsx +243 -0
  470. package/fabric-interop/tsconfig.json +38 -0
  471. package/fabric.d.ts +5 -0
  472. package/fabric.ts +14 -0
  473. package/ios/ViroReact.podspec +51 -11
  474. package/package.json +33 -20
  475. 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
+ }