@webspatial/react-sdk 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/default/XRApp.d.ts +21 -0
  3. package/dist/cjs/default/XRApp.d.ts.map +1 -0
  4. package/dist/cjs/default/index.d.ts +5 -0
  5. package/dist/cjs/default/index.d.ts.map +1 -0
  6. package/dist/cjs/default/index.js +3430 -0
  7. package/dist/cjs/default/index.js.map +7 -0
  8. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/CSSSpatialComponent.d.ts +3 -0
  9. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/CSSSpatialComponent.d.ts.map +1 -0
  10. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/CSSSpatialDebugNameContext.d.ts +2 -0
  11. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/CSSSpatialDebugNameContext.d.ts.map +1 -0
  12. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/CSSSpatialDiv.d.ts +6 -0
  13. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/CSSSpatialDiv.d.ts.map +1 -0
  14. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/CSSSpatialLayerContext.d.ts +2 -0
  15. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/CSSSpatialLayerContext.d.ts.map +1 -0
  16. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/CSSSpatialRootContext.d.ts +14 -0
  17. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/CSSSpatialRootContext.d.ts.map +1 -0
  18. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/const.d.ts +6 -0
  19. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/const.d.ts.map +1 -0
  20. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/index.d.ts +2 -0
  21. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/index.d.ts.map +1 -0
  22. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/injectClassStyle.d.ts +2 -0
  23. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/injectClassStyle.d.ts.map +1 -0
  24. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/math/index.d.ts +4 -0
  25. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/math/index.d.ts.map +1 -0
  26. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/useHijackSpatialDivRef.d.ts +4 -0
  27. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/useHijackSpatialDivRef.d.ts.map +1 -0
  28. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/useSpatialStyle.d.ts +29 -0
  29. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/useSpatialStyle.d.ts.map +1 -0
  30. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/utils.d.ts +7 -0
  31. package/dist/cjs/default/spatial-react-components/CSSSpatialDiv/utils.d.ts.map +1 -0
  32. package/dist/cjs/default/spatial-react-components/Model/index.d.ts +42 -0
  33. package/dist/cjs/default/spatial-react-components/Model/index.d.ts.map +1 -0
  34. package/dist/cjs/default/spatial-react-components/Model3D/CSSModel3D.d.ts +4 -0
  35. package/dist/cjs/default/spatial-react-components/Model3D/CSSModel3D.d.ts.map +1 -0
  36. package/dist/cjs/default/spatial-react-components/Model3D/CSSModel3DNotInSpatialDiv.d.ts +3 -0
  37. package/dist/cjs/default/spatial-react-components/Model3D/CSSModel3DNotInSpatialDiv.d.ts.map +1 -0
  38. package/dist/cjs/default/spatial-react-components/Model3D/CSSModel3DPortalInstance.d.ts +3 -0
  39. package/dist/cjs/default/spatial-react-components/Model3D/CSSModel3DPortalInstance.d.ts.map +1 -0
  40. package/dist/cjs/default/spatial-react-components/Model3D/CSSModel3DStandardInstance.d.ts +3 -0
  41. package/dist/cjs/default/spatial-react-components/Model3D/CSSModel3DStandardInstance.d.ts.map +1 -0
  42. package/dist/cjs/default/spatial-react-components/Model3D/Model3D.d.ts +3 -0
  43. package/dist/cjs/default/spatial-react-components/Model3D/Model3D.d.ts.map +1 -0
  44. package/dist/cjs/default/spatial-react-components/Model3D/Model3DNative.d.ts +48 -0
  45. package/dist/cjs/default/spatial-react-components/Model3D/Model3DNative.d.ts.map +1 -0
  46. package/dist/cjs/default/spatial-react-components/Model3D/Model3DNotInSpatialDiv.d.ts +3 -0
  47. package/dist/cjs/default/spatial-react-components/Model3D/Model3DNotInSpatialDiv.d.ts.map +1 -0
  48. package/dist/cjs/default/spatial-react-components/Model3D/Model3DPortalInstance.d.ts +3 -0
  49. package/dist/cjs/default/spatial-react-components/Model3D/Model3DPortalInstance.d.ts.map +1 -0
  50. package/dist/cjs/default/spatial-react-components/Model3D/Model3DStandardInstance.d.ts +3 -0
  51. package/dist/cjs/default/spatial-react-components/Model3D/Model3DStandardInstance.d.ts.map +1 -0
  52. package/dist/cjs/default/spatial-react-components/Model3D/index.d.ts +4 -0
  53. package/dist/cjs/default/spatial-react-components/Model3D/index.d.ts.map +1 -0
  54. package/dist/cjs/default/spatial-react-components/Model3D/types.d.ts +46 -0
  55. package/dist/cjs/default/spatial-react-components/Model3D/types.d.ts.map +1 -0
  56. package/dist/cjs/default/spatial-react-components/Model3D/useDetectLayoutDomUpdated.d.ts +2 -0
  57. package/dist/cjs/default/spatial-react-components/Model3D/useDetectLayoutDomUpdated.d.ts.map +1 -0
  58. package/dist/cjs/default/spatial-react-components/Model3D/useModel3DNative.d.ts +15 -0
  59. package/dist/cjs/default/spatial-react-components/Model3D/useModel3DNative.d.ts.map +1 -0
  60. package/dist/cjs/default/spatial-react-components/Model3D/useSyncDomInfoFromStandardInstance.d.ts +19 -0
  61. package/dist/cjs/default/spatial-react-components/Model3D/useSyncDomInfoFromStandardInstance.d.ts.map +1 -0
  62. package/dist/cjs/default/spatial-react-components/Model3D/utils.d.ts +4 -0
  63. package/dist/cjs/default/spatial-react-components/Model3D/utils.d.ts.map +1 -0
  64. package/dist/cjs/default/spatial-react-components/SpatialMonitor.d.ts +6 -0
  65. package/dist/cjs/default/spatial-react-components/SpatialMonitor.d.ts.map +1 -0
  66. package/dist/cjs/default/spatial-react-components/SpatialPrimitive.d.ts +6 -0
  67. package/dist/cjs/default/spatial-react-components/SpatialPrimitive.d.ts.map +1 -0
  68. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/PortalInstance.d.ts +20 -0
  69. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/PortalInstance.d.ts.map +1 -0
  70. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/SpatialDebugNameContext.d.ts +2 -0
  71. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/SpatialDebugNameContext.d.ts.map +1 -0
  72. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/SpatialIsStandardInstanceContext.d.ts +2 -0
  73. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/SpatialIsStandardInstanceContext.d.ts.map +1 -0
  74. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/SpatialLayerContext.d.ts +2 -0
  75. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/SpatialLayerContext.d.ts.map +1 -0
  76. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/SpatialReactComponent.d.ts +3 -0
  77. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/SpatialReactComponent.d.ts.map +1 -0
  78. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/SpatialReactContext.d.ts +24 -0
  79. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/SpatialReactContext.d.ts.map +1 -0
  80. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/SpatialWindowManager.d.ts +17 -0
  81. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/SpatialWindowManager.d.ts.map +1 -0
  82. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/SpatialWindowManagerContext.d.ts +3 -0
  83. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/SpatialWindowManagerContext.d.ts.map +1 -0
  84. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/StandardInstance.d.ts +10 -0
  85. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/StandardInstance.d.ts.map +1 -0
  86. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/const.d.ts +2 -0
  87. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/const.d.ts.map +1 -0
  88. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/index.d.ts +3 -0
  89. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/index.d.ts.map +1 -0
  90. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/types.d.ts +31 -0
  91. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/types.d.ts.map +1 -0
  92. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/usePortalContainer.d.ts +8 -0
  93. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/usePortalContainer.d.ts.map +1 -0
  94. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/utils.d.ts +15 -0
  95. package/dist/cjs/default/spatial-react-components/SpatialReactComponent/utils.d.ts.map +1 -0
  96. package/dist/cjs/default/spatial-react-components/SpatialView.d.ts +15 -0
  97. package/dist/cjs/default/spatial-react-components/SpatialView.d.ts.map +1 -0
  98. package/dist/cjs/default/spatial-react-components/hooks/useForceUpdate.d.ts +2 -0
  99. package/dist/cjs/default/spatial-react-components/hooks/useForceUpdate.d.ts.map +1 -0
  100. package/dist/cjs/default/spatial-react-components/hooks/useMonitorDocumentHeaderChange.d.ts +2 -0
  101. package/dist/cjs/default/spatial-react-components/hooks/useMonitorDocumentHeaderChange.d.ts.map +1 -0
  102. package/dist/cjs/default/spatial-react-components/hooks/useMonitorDomChange.d.ts +2 -0
  103. package/dist/cjs/default/spatial-react-components/hooks/useMonitorDomChange.d.ts.map +1 -0
  104. package/dist/cjs/default/spatial-react-components/index.d.ts +12 -0
  105. package/dist/cjs/default/spatial-react-components/index.d.ts.map +1 -0
  106. package/dist/cjs/default/spatial-react-components/notifyUpdateStandInstanceLayout.d.ts +13 -0
  107. package/dist/cjs/default/spatial-react-components/notifyUpdateStandInstanceLayout.d.ts.map +1 -0
  108. package/dist/cjs/default/spatial-react-components/primitives.d.ts +3 -0
  109. package/dist/cjs/default/spatial-react-components/primitives.d.ts.map +1 -0
  110. package/dist/cjs/default/spatial-react-components/types.d.ts +18 -0
  111. package/dist/cjs/default/spatial-react-components/types.d.ts.map +1 -0
  112. package/dist/cjs/default/types.d.ts +2 -0
  113. package/dist/cjs/default/types.d.ts.map +1 -0
  114. package/dist/cjs/default/utils/debugTool.d.ts +2 -0
  115. package/dist/cjs/default/utils/debugTool.d.ts.map +1 -0
  116. package/dist/cjs/default/utils/getSession.d.ts +6 -0
  117. package/dist/cjs/default/utils/getSession.d.ts.map +1 -0
  118. package/dist/cjs/default/utils/index.d.ts +3 -0
  119. package/dist/cjs/default/utils/index.d.ts.map +1 -0
  120. package/dist/cjs/web/XRApp.d.ts +21 -0
  121. package/dist/cjs/web/XRApp.d.ts.map +1 -0
  122. package/dist/cjs/web/index.d.ts +5 -0
  123. package/dist/cjs/web/index.d.ts.map +1 -0
  124. package/dist/cjs/web/index.js +3432 -0
  125. package/dist/cjs/web/index.js.map +7 -0
  126. package/dist/cjs/web/noRuntime.d.ts +5 -0
  127. package/dist/cjs/web/noRuntime.d.ts.map +1 -0
  128. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/CSSSpatialComponent.d.ts +3 -0
  129. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/CSSSpatialComponent.d.ts.map +1 -0
  130. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/CSSSpatialDebugNameContext.d.ts +2 -0
  131. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/CSSSpatialDebugNameContext.d.ts.map +1 -0
  132. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/CSSSpatialDiv.d.ts +6 -0
  133. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/CSSSpatialDiv.d.ts.map +1 -0
  134. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/CSSSpatialLayerContext.d.ts +2 -0
  135. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/CSSSpatialLayerContext.d.ts.map +1 -0
  136. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/CSSSpatialRootContext.d.ts +14 -0
  137. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/CSSSpatialRootContext.d.ts.map +1 -0
  138. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/const.d.ts +6 -0
  139. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/const.d.ts.map +1 -0
  140. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/index.d.ts +2 -0
  141. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/index.d.ts.map +1 -0
  142. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/injectClassStyle.d.ts +2 -0
  143. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/injectClassStyle.d.ts.map +1 -0
  144. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/math/index.d.ts +4 -0
  145. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/math/index.d.ts.map +1 -0
  146. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/useHijackSpatialDivRef.d.ts +4 -0
  147. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/useHijackSpatialDivRef.d.ts.map +1 -0
  148. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/useSpatialStyle.d.ts +29 -0
  149. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/useSpatialStyle.d.ts.map +1 -0
  150. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/utils.d.ts +7 -0
  151. package/dist/cjs/web/spatial-react-components/CSSSpatialDiv/utils.d.ts.map +1 -0
  152. package/dist/cjs/web/spatial-react-components/Model/index.d.ts +42 -0
  153. package/dist/cjs/web/spatial-react-components/Model/index.d.ts.map +1 -0
  154. package/dist/cjs/web/spatial-react-components/Model3D/CSSModel3D.d.ts +4 -0
  155. package/dist/cjs/web/spatial-react-components/Model3D/CSSModel3D.d.ts.map +1 -0
  156. package/dist/cjs/web/spatial-react-components/Model3D/CSSModel3DNotInSpatialDiv.d.ts +3 -0
  157. package/dist/cjs/web/spatial-react-components/Model3D/CSSModel3DNotInSpatialDiv.d.ts.map +1 -0
  158. package/dist/cjs/web/spatial-react-components/Model3D/CSSModel3DPortalInstance.d.ts +3 -0
  159. package/dist/cjs/web/spatial-react-components/Model3D/CSSModel3DPortalInstance.d.ts.map +1 -0
  160. package/dist/cjs/web/spatial-react-components/Model3D/CSSModel3DStandardInstance.d.ts +3 -0
  161. package/dist/cjs/web/spatial-react-components/Model3D/CSSModel3DStandardInstance.d.ts.map +1 -0
  162. package/dist/cjs/web/spatial-react-components/Model3D/Model3D.d.ts +3 -0
  163. package/dist/cjs/web/spatial-react-components/Model3D/Model3D.d.ts.map +1 -0
  164. package/dist/cjs/web/spatial-react-components/Model3D/Model3DNative.d.ts +48 -0
  165. package/dist/cjs/web/spatial-react-components/Model3D/Model3DNative.d.ts.map +1 -0
  166. package/dist/cjs/web/spatial-react-components/Model3D/Model3DNotInSpatialDiv.d.ts +3 -0
  167. package/dist/cjs/web/spatial-react-components/Model3D/Model3DNotInSpatialDiv.d.ts.map +1 -0
  168. package/dist/cjs/web/spatial-react-components/Model3D/Model3DPortalInstance.d.ts +3 -0
  169. package/dist/cjs/web/spatial-react-components/Model3D/Model3DPortalInstance.d.ts.map +1 -0
  170. package/dist/cjs/web/spatial-react-components/Model3D/Model3DStandardInstance.d.ts +3 -0
  171. package/dist/cjs/web/spatial-react-components/Model3D/Model3DStandardInstance.d.ts.map +1 -0
  172. package/dist/cjs/web/spatial-react-components/Model3D/index.d.ts +4 -0
  173. package/dist/cjs/web/spatial-react-components/Model3D/index.d.ts.map +1 -0
  174. package/dist/cjs/web/spatial-react-components/Model3D/types.d.ts +46 -0
  175. package/dist/cjs/web/spatial-react-components/Model3D/types.d.ts.map +1 -0
  176. package/dist/cjs/web/spatial-react-components/Model3D/useDetectLayoutDomUpdated.d.ts +2 -0
  177. package/dist/cjs/web/spatial-react-components/Model3D/useDetectLayoutDomUpdated.d.ts.map +1 -0
  178. package/dist/cjs/web/spatial-react-components/Model3D/useModel3DNative.d.ts +15 -0
  179. package/dist/cjs/web/spatial-react-components/Model3D/useModel3DNative.d.ts.map +1 -0
  180. package/dist/cjs/web/spatial-react-components/Model3D/useSyncDomInfoFromStandardInstance.d.ts +19 -0
  181. package/dist/cjs/web/spatial-react-components/Model3D/useSyncDomInfoFromStandardInstance.d.ts.map +1 -0
  182. package/dist/cjs/web/spatial-react-components/Model3D/utils.d.ts +4 -0
  183. package/dist/cjs/web/spatial-react-components/Model3D/utils.d.ts.map +1 -0
  184. package/dist/cjs/web/spatial-react-components/SpatialMonitor.d.ts +6 -0
  185. package/dist/cjs/web/spatial-react-components/SpatialMonitor.d.ts.map +1 -0
  186. package/dist/cjs/web/spatial-react-components/SpatialPrimitive.d.ts +6 -0
  187. package/dist/cjs/web/spatial-react-components/SpatialPrimitive.d.ts.map +1 -0
  188. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/PortalInstance.d.ts +20 -0
  189. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/PortalInstance.d.ts.map +1 -0
  190. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/SpatialDebugNameContext.d.ts +2 -0
  191. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/SpatialDebugNameContext.d.ts.map +1 -0
  192. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/SpatialIsStandardInstanceContext.d.ts +2 -0
  193. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/SpatialIsStandardInstanceContext.d.ts.map +1 -0
  194. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/SpatialLayerContext.d.ts +2 -0
  195. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/SpatialLayerContext.d.ts.map +1 -0
  196. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/SpatialReactComponent.d.ts +3 -0
  197. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/SpatialReactComponent.d.ts.map +1 -0
  198. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/SpatialReactContext.d.ts +24 -0
  199. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/SpatialReactContext.d.ts.map +1 -0
  200. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/SpatialWindowManager.d.ts +17 -0
  201. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/SpatialWindowManager.d.ts.map +1 -0
  202. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/SpatialWindowManagerContext.d.ts +3 -0
  203. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/SpatialWindowManagerContext.d.ts.map +1 -0
  204. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/StandardInstance.d.ts +10 -0
  205. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/StandardInstance.d.ts.map +1 -0
  206. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/const.d.ts +2 -0
  207. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/const.d.ts.map +1 -0
  208. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/index.d.ts +3 -0
  209. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/index.d.ts.map +1 -0
  210. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/types.d.ts +31 -0
  211. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/types.d.ts.map +1 -0
  212. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/usePortalContainer.d.ts +8 -0
  213. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/usePortalContainer.d.ts.map +1 -0
  214. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/utils.d.ts +15 -0
  215. package/dist/cjs/web/spatial-react-components/SpatialReactComponent/utils.d.ts.map +1 -0
  216. package/dist/cjs/web/spatial-react-components/SpatialView.d.ts +15 -0
  217. package/dist/cjs/web/spatial-react-components/SpatialView.d.ts.map +1 -0
  218. package/dist/cjs/web/spatial-react-components/hooks/useForceUpdate.d.ts +2 -0
  219. package/dist/cjs/web/spatial-react-components/hooks/useForceUpdate.d.ts.map +1 -0
  220. package/dist/cjs/web/spatial-react-components/hooks/useMonitorDocumentHeaderChange.d.ts +2 -0
  221. package/dist/cjs/web/spatial-react-components/hooks/useMonitorDocumentHeaderChange.d.ts.map +1 -0
  222. package/dist/cjs/web/spatial-react-components/hooks/useMonitorDomChange.d.ts +2 -0
  223. package/dist/cjs/web/spatial-react-components/hooks/useMonitorDomChange.d.ts.map +1 -0
  224. package/dist/cjs/web/spatial-react-components/index.d.ts +12 -0
  225. package/dist/cjs/web/spatial-react-components/index.d.ts.map +1 -0
  226. package/dist/cjs/web/spatial-react-components/notifyUpdateStandInstanceLayout.d.ts +13 -0
  227. package/dist/cjs/web/spatial-react-components/notifyUpdateStandInstanceLayout.d.ts.map +1 -0
  228. package/dist/cjs/web/spatial-react-components/primitives.d.ts +3 -0
  229. package/dist/cjs/web/spatial-react-components/primitives.d.ts.map +1 -0
  230. package/dist/cjs/web/spatial-react-components/types.d.ts +18 -0
  231. package/dist/cjs/web/spatial-react-components/types.d.ts.map +1 -0
  232. package/dist/cjs/web/types.d.ts +2 -0
  233. package/dist/cjs/web/types.d.ts.map +1 -0
  234. package/dist/cjs/web/utils/debugTool.d.ts +2 -0
  235. package/dist/cjs/web/utils/debugTool.d.ts.map +1 -0
  236. package/dist/cjs/web/utils/getSession.d.ts +6 -0
  237. package/dist/cjs/web/utils/getSession.d.ts.map +1 -0
  238. package/dist/cjs/web/utils/index.d.ts +3 -0
  239. package/dist/cjs/web/utils/index.d.ts.map +1 -0
  240. package/dist/jsx/injectSceneHook.d.ts +2 -0
  241. package/dist/jsx/injectSceneHook.d.ts.map +1 -0
  242. package/dist/jsx/jsx-dev-runtime.d.ts +3 -0
  243. package/dist/jsx/jsx-dev-runtime.d.ts.map +1 -0
  244. package/dist/jsx/jsx-dev-runtime.js +7107 -0
  245. package/dist/jsx/jsx-dev-runtime.js.map +7 -0
  246. package/dist/jsx/jsx-runtime.d.ts +3 -0
  247. package/dist/jsx/jsx-runtime.d.ts.map +1 -0
  248. package/dist/jsx/jsx-runtime.js +7107 -0
  249. package/dist/jsx/jsx-runtime.js.map +7 -0
  250. package/dist/jsx/jsx-shared.d.ts +6 -0
  251. package/dist/jsx/jsx-shared.d.ts.map +1 -0
  252. package/dist/jsx/spatialPolyfill.d.ts +2 -0
  253. package/dist/jsx/spatialPolyfill.d.ts.map +1 -0
  254. package/npm/index.d.ts +1 -0
  255. package/npm/index.js +7 -0
  256. package/npm/plugin/esbuild.js +12 -0
  257. package/npm/plugin/rollup.js +8 -0
  258. package/npm/plugin/shared.js +9 -0
  259. package/npm/plugin/vite.js +85 -0
  260. package/npm/plugin/webpack.js +9 -0
  261. package/package.json +77 -0
@@ -0,0 +1,3432 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/index.ts
32
+ var src_exports = {};
33
+ __export(src_exports, {
34
+ CSSModel3D: () => CSSModel3D,
35
+ CSSSpatialDiv: () => CSSSpatialDiv,
36
+ CSSSpatialPrimitive: () => CSSSpatialPrimitive,
37
+ Model: () => Model,
38
+ Model3D: () => Model3D,
39
+ SpatialDiv: () => SpatialDiv,
40
+ SpatialMonitor: () => SpatialMonitor,
41
+ SpatialPrimitive: () => SpatialPrimitive,
42
+ SpatialView: () => SpatialView,
43
+ XRApp: () => XRApp,
44
+ defaultSceneConfig: () => defaultSceneConfig,
45
+ enableDebugTool: () => enableDebugTool,
46
+ getSession: () => getSession,
47
+ initScene: () => initScene,
48
+ notifyUpdateStandInstanceLayout: () => notifyUpdateStandInstanceLayout,
49
+ parseCornerRadius: () => parseCornerRadius,
50
+ withCSSSpatial: () => withCSSSpatial,
51
+ withSpatial: () => withSpatial
52
+ });
53
+ module.exports = __toCommonJS(src_exports);
54
+
55
+ // src/spatial-react-components/SpatialPrimitive.tsx
56
+ var import_react11 = require("react");
57
+
58
+ // src/spatial-react-components/primitives.ts
59
+ var primitives = [
60
+ "a",
61
+ "abbr",
62
+ "address",
63
+ "area",
64
+ "article",
65
+ "aside",
66
+ "audio",
67
+ "b",
68
+ "base",
69
+ "bdi",
70
+ "bdo",
71
+ "big",
72
+ "blockquote",
73
+ "body",
74
+ "br",
75
+ "button",
76
+ "canvas",
77
+ "caption",
78
+ "cite",
79
+ "code",
80
+ "col",
81
+ "colgroup",
82
+ "data",
83
+ "datalist",
84
+ "dd",
85
+ "del",
86
+ "details",
87
+ "dfn",
88
+ "dialog",
89
+ "div",
90
+ "dl",
91
+ "dt",
92
+ "em",
93
+ "embed",
94
+ "fieldset",
95
+ "figcaption",
96
+ "figure",
97
+ "footer",
98
+ "form",
99
+ "h1",
100
+ "h2",
101
+ "h3",
102
+ "h4",
103
+ "h5",
104
+ "h6",
105
+ "head",
106
+ "header",
107
+ "hgroup",
108
+ "hr",
109
+ "html",
110
+ "i",
111
+ "iframe",
112
+ "img",
113
+ "input",
114
+ "ins",
115
+ "kbd",
116
+ "keygen",
117
+ "label",
118
+ "legend",
119
+ "li",
120
+ "link",
121
+ "main",
122
+ "map",
123
+ "mark",
124
+ "menu",
125
+ "menuitem",
126
+ "meta",
127
+ "meter",
128
+ "nav",
129
+ "noscript",
130
+ "object",
131
+ "ol",
132
+ "optgroup",
133
+ "option",
134
+ "output",
135
+ "p",
136
+ "param",
137
+ "picture",
138
+ "pre",
139
+ "progress",
140
+ "q",
141
+ "rp",
142
+ "rt",
143
+ "ruby",
144
+ "s",
145
+ "samp",
146
+ "script",
147
+ "section",
148
+ "select",
149
+ "small",
150
+ "source",
151
+ "span",
152
+ "strong",
153
+ "style",
154
+ "sub",
155
+ "summary",
156
+ "sup",
157
+ "table",
158
+ "tbody",
159
+ "td",
160
+ "textarea",
161
+ "tfoot",
162
+ "th",
163
+ "thead",
164
+ "time",
165
+ "title",
166
+ "tr",
167
+ "track",
168
+ "u",
169
+ "ul",
170
+ "var",
171
+ "video",
172
+ "wbr",
173
+ // SVG
174
+ "circle",
175
+ "clipPath",
176
+ "defs",
177
+ "ellipse",
178
+ "foreignObject",
179
+ "g",
180
+ "image",
181
+ "line",
182
+ "linearGradient",
183
+ "mask",
184
+ "path",
185
+ "pattern",
186
+ "polygon",
187
+ "polyline",
188
+ "radialGradient",
189
+ "rect",
190
+ "stop",
191
+ "svg",
192
+ "text",
193
+ "tspan"
194
+ ];
195
+
196
+ // src/spatial-react-components/SpatialReactComponent/SpatialReactComponent.tsx
197
+ var import_react10 = require("react");
198
+
199
+ // src/noRuntime.ts
200
+ var SpatialHelper = {};
201
+ var Spatial = {};
202
+
203
+ // src/utils/getSession.ts
204
+ var spatial = null;
205
+ var _currentSession = null;
206
+ function getSession() {
207
+ if (true) return null;
208
+ if (!spatial) {
209
+ spatial = new Spatial();
210
+ }
211
+ if (!spatial.isSupported()) {
212
+ return null;
213
+ }
214
+ if (_currentSession) {
215
+ return _currentSession;
216
+ }
217
+ _currentSession = spatial.requestSession();
218
+ return _currentSession;
219
+ }
220
+ __name(getSession, "getSession");
221
+
222
+ // src/utils/debugTool.ts
223
+ async function getStat() {
224
+ if (true) return;
225
+ const statsInfo = await getSession()._getStats();
226
+ return statsInfo;
227
+ }
228
+ __name(getStat, "getStat");
229
+ function simplifyEntityTree(rootTree) {
230
+ const rootEntity = Object.values(rootTree.childEntities)[0];
231
+ function traverseTree(node, parent, callback) {
232
+ callback(node, parent);
233
+ const childrenNodes = Object.values(node.childEntities);
234
+ if (childrenNodes) {
235
+ childrenNodes.forEach((child) => {
236
+ traverseTree(child, node, callback);
237
+ });
238
+ }
239
+ }
240
+ __name(traverseTree, "traverseTree");
241
+ let rootNode;
242
+ const nodeMap = {};
243
+ function visitNode(node, parent) {
244
+ let newNode = {
245
+ id: node.id,
246
+ name: node.name,
247
+ children: [],
248
+ position: node.position,
249
+ scale: node.scale,
250
+ width: node.components[0].resolutionX,
251
+ height: node.components[0].resolutionY,
252
+ zIndex: node.zIndex,
253
+ visible: node.visible,
254
+ cornerRadius: node.components[0].cornerRadius,
255
+ backgroundMaterial: node.components[0].backgroundMaterial,
256
+ isOpaque: node.components[0].isOpaque
257
+ };
258
+ nodeMap[node.id] = newNode;
259
+ if (!parent) {
260
+ rootNode = newNode;
261
+ } else {
262
+ const parentNode = nodeMap[parent.id];
263
+ parentNode.children.push(newNode);
264
+ }
265
+ }
266
+ __name(visitNode, "visitNode");
267
+ traverseTree(rootEntity, null, visitNode);
268
+ console.log("rootNode", rootNode);
269
+ return rootNode;
270
+ }
271
+ __name(simplifyEntityTree, "simplifyEntityTree");
272
+ async function inspectRootWindowContainer(simple) {
273
+ const rootWindowContainerInfo = await getSession()._inspectRootWindowContainer();
274
+ console.log(rootWindowContainerInfo);
275
+ if (simple) {
276
+ return simplifyEntityTree(rootWindowContainerInfo);
277
+ }
278
+ return rootWindowContainerInfo;
279
+ }
280
+ __name(inspectRootWindowContainer, "inspectRootWindowContainer");
281
+ function enableDebugTool() {
282
+ if (true) return;
283
+ const session = getSession();
284
+ Object.assign(window, {
285
+ session,
286
+ getStat,
287
+ inspectRootWindowContainer
288
+ });
289
+ }
290
+ __name(enableDebugTool, "enableDebugTool");
291
+
292
+ // src/spatial-react-components/SpatialReactComponent/StandardInstance.tsx
293
+ var import_react4 = require("react");
294
+
295
+ // src/spatial-react-components/hooks/useForceUpdate.ts
296
+ var import_react = require("react");
297
+ function useForceUpdate() {
298
+ const [, setToggle] = (0, import_react.useState)(false);
299
+ return () => setToggle((toggle) => !toggle);
300
+ }
301
+ __name(useForceUpdate, "useForceUpdate");
302
+
303
+ // src/spatial-react-components/SpatialReactComponent/SpatialIsStandardInstanceContext.ts
304
+ var import_react2 = require("react");
305
+ var SpatialIsStandardInstanceContext = (0, import_react2.createContext)(
306
+ null
307
+ );
308
+
309
+ // src/spatial-react-components/SpatialReactComponent/SpatialReactContext.ts
310
+ var import_react3 = require("react");
311
+
312
+ // src/spatial-react-components/SpatialReactComponent/const.ts
313
+ var SpatialID = "data-spatial-id";
314
+
315
+ // src/spatial-react-components/SpatialReactComponent/SpatialReactContext.ts
316
+ var SpatialReactContextObject = class {
317
+ static {
318
+ __name(this, "SpatialReactContextObject");
319
+ }
320
+ debugName;
321
+ constructor(debugName) {
322
+ this.debugName = debugName;
323
+ }
324
+ dom = null;
325
+ domSpatialId = null;
326
+ fns = {};
327
+ // cache dom for each spatialId
328
+ spatialId2dom = {};
329
+ spatialId2parentSpatialDom = {};
330
+ // layer : [standardInstance sequence, portalInstance sequence]
331
+ layerSequences = {};
332
+ getSpatialID(layer, isInStandardInstance, debugName = "") {
333
+ if (this.layerSequences[layer] === void 0) {
334
+ this.layerSequences[layer] = [0, 0];
335
+ }
336
+ const idx = isInStandardInstance ? 0 : 1;
337
+ const sequenceId = this.layerSequences[layer][idx];
338
+ this.layerSequences[layer][idx] = sequenceId + 1;
339
+ const spatialId = `${debugName}_${layer}_${sequenceId}`;
340
+ return spatialId;
341
+ }
342
+ onDomChange(spatialId, fn) {
343
+ this.fns[spatialId] = fn;
344
+ if (this.dom) {
345
+ fn();
346
+ }
347
+ }
348
+ offDomChange(spatialId) {
349
+ delete this.fns[spatialId];
350
+ delete this.spatialId2dom[spatialId];
351
+ delete this.spatialId2parentSpatialDom[spatialId];
352
+ }
353
+ notifyDomChange(dom) {
354
+ this.dom = dom;
355
+ this.domSpatialId = dom.getAttribute(SpatialID);
356
+ Object.values(this.fns).forEach((fn) => fn());
357
+ }
358
+ querySpatialDom(spatialId) {
359
+ if (this.domSpatialId === spatialId) {
360
+ return this.dom;
361
+ }
362
+ if (!this.dom) {
363
+ return null;
364
+ }
365
+ if (!this.spatialId2dom[spatialId]) {
366
+ const spatialDom = this.dom.querySelector(`[${SpatialID}="${spatialId}"]`);
367
+ if (spatialDom) {
368
+ this.spatialId2dom[spatialId] = spatialDom;
369
+ }
370
+ }
371
+ return this.spatialId2dom[spatialId];
372
+ }
373
+ queryParentSpatialDom(spatialId) {
374
+ if (this.domSpatialId === spatialId) {
375
+ return null;
376
+ }
377
+ if (this.spatialId2parentSpatialDom[spatialId]) {
378
+ return this.spatialId2parentSpatialDom[spatialId];
379
+ }
380
+ let spatialDom = this.querySpatialDom(spatialId);
381
+ if (spatialDom) {
382
+ if (spatialDom === this.dom) return null;
383
+ let parentSpatialDom = spatialDom.parentElement;
384
+ while (parentSpatialDom && spatialDom !== this.dom) {
385
+ if (parentSpatialDom.hasAttribute(SpatialID)) {
386
+ break;
387
+ } else {
388
+ parentSpatialDom = parentSpatialDom.parentElement;
389
+ }
390
+ }
391
+ this.spatialId2parentSpatialDom[spatialId] = parentSpatialDom;
392
+ return parentSpatialDom;
393
+ }
394
+ return null;
395
+ }
396
+ // Used for CSSModel3D
397
+ // layer : [standardInstance sequence, portalInstance sequence]
398
+ subDivLayerSequences = {};
399
+ subDivEventHandlers = {};
400
+ getSubDivSpatialID(layer, isInStandardInstance, prefix = "") {
401
+ if (this.subDivLayerSequences[layer] === void 0) {
402
+ this.subDivLayerSequences[layer] = [0, 0];
403
+ }
404
+ const idx = isInStandardInstance ? 0 : 1;
405
+ const sequenceId = this.subDivLayerSequences[layer][idx];
406
+ this.subDivLayerSequences[layer][idx] = sequenceId + 1;
407
+ const spatialId = `${prefix}_${layer}_${sequenceId}`;
408
+ return spatialId;
409
+ }
410
+ onSubDivEvent(subSpatialId, eventHandler) {
411
+ this.subDivEventHandlers[subSpatialId] = eventHandler;
412
+ }
413
+ offSubDivEvent(subSpatialId) {
414
+ delete this.subDivEventHandlers[subSpatialId];
415
+ }
416
+ notifySubDivEvent(subSpatialId, args) {
417
+ const eventHandler = this.subDivEventHandlers[subSpatialId];
418
+ if (eventHandler) {
419
+ eventHandler(args);
420
+ }
421
+ }
422
+ };
423
+ var SpatialReactContext = (0, import_react3.createContext)(null);
424
+
425
+ // src/spatial-react-components/SpatialReactComponent/StandardInstance.tsx
426
+ var import_jsx_runtime = require("react/jsx-runtime");
427
+ function useDetectDomRectChange() {
428
+ const ref = (0, import_react4.useRef)(null);
429
+ const forceUpdate = useForceUpdate();
430
+ const spatialReactContextObject = (0, import_react4.useContext)(SpatialReactContext);
431
+ (0, import_react4.useLayoutEffect)(() => {
432
+ ref.current && spatialReactContextObject?.notifyDomChange(ref.current);
433
+ });
434
+ (0, import_react4.useEffect)(() => {
435
+ if (!ref.current || !spatialReactContextObject) {
436
+ console.warn(
437
+ "Ref is not attached to the DOM or spatialReactContextObject is not available"
438
+ );
439
+ return;
440
+ }
441
+ const handleResize = /* @__PURE__ */ __name(() => {
442
+ forceUpdate();
443
+ }, "handleResize");
444
+ window.addEventListener("resize", handleResize);
445
+ return () => {
446
+ window.removeEventListener("resize", handleResize);
447
+ };
448
+ }, [spatialReactContextObject]);
449
+ (0, import_react4.useEffect)(() => {
450
+ if (!ref.current) {
451
+ console.warn("Ref is not attached to the DOM");
452
+ return;
453
+ }
454
+ let ro = new ResizeObserver((elements) => {
455
+ forceUpdate();
456
+ });
457
+ ro.observe(ref.current);
458
+ return () => {
459
+ ro.disconnect();
460
+ };
461
+ }, []);
462
+ (0, import_react4.useEffect)(() => {
463
+ if (!ref.current) {
464
+ console.warn("Ref is not attached to the DOM");
465
+ return;
466
+ }
467
+ let ro = new MutationObserver((elements) => {
468
+ forceUpdate();
469
+ });
470
+ ro.observe(ref.current, {
471
+ attributeFilter: ["class", "style"],
472
+ subtree: true
473
+ });
474
+ return () => {
475
+ ro.disconnect();
476
+ };
477
+ }, []);
478
+ return ref;
479
+ }
480
+ __name(useDetectDomRectChange, "useDetectDomRectChange");
481
+ var StandardInstance = (0, import_react4.forwardRef)(function(inProps, refIn) {
482
+ const { El, style: inStyle, debugShowStandardInstance, ...props } = inProps;
483
+ const extraStyle = {
484
+ visibility: debugShowStandardInstance ? void 0 : "hidden",
485
+ transition: "none"
486
+ };
487
+ const style = { ...inStyle, ...extraStyle };
488
+ var ref = useDetectDomRectChange();
489
+ const proxyRef = new Proxy(ref, {
490
+ get(target, prop, receiver) {
491
+ return Reflect.get(target, prop, receiver);
492
+ },
493
+ set(target, prop, value, receiver) {
494
+ if (prop === "current") {
495
+ const domElement = value;
496
+ if (refIn) {
497
+ if (typeof refIn === "function") {
498
+ refIn(domElement);
499
+ } else {
500
+ refIn.current = domElement;
501
+ }
502
+ }
503
+ }
504
+ return Reflect.set(target, prop, value, receiver);
505
+ }
506
+ });
507
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SpatialIsStandardInstanceContext.Provider, { value: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(El, { "data-standardinstance": true, ref: proxyRef, style, ...props }) });
508
+ });
509
+ StandardInstance.displayName = "StandardInstance";
510
+
511
+ // src/spatial-react-components/SpatialReactComponent/PortalInstance.tsx
512
+ var import_react8 = require("react");
513
+ var import_react_dom = require("react-dom");
514
+
515
+ // src/spatial-react-components/SpatialReactComponent/usePortalContainer.tsx
516
+ var import_react6 = require("react");
517
+
518
+ // src/spatial-react-components/SpatialReactComponent/SpatialWindowManager.ts
519
+ var SpatialWindowManager = class {
520
+ static {
521
+ __name(this, "SpatialWindowManager");
522
+ }
523
+ initPromise;
524
+ entity;
525
+ webview;
526
+ window = null;
527
+ setDebugName(debugName) {
528
+ this.entity?._setName(debugName);
529
+ }
530
+ async initInternal(url) {
531
+ if (true) return;
532
+ this.entity = await getSession().createEntity();
533
+ this.webview = await getSession().createWindowComponent();
534
+ await this.webview.loadURL(url);
535
+ await this.entity.setCoordinateSpace("Dom");
536
+ await this.webview.setScrollWithParent(true);
537
+ await this.webview.setScrollEnabled(false);
538
+ await this.entity.setComponent(this.webview);
539
+ var wc = await getSession().getCurrentWindowComponent();
540
+ var ent = await wc.getEntity();
541
+ await this.entity.setParent(ent);
542
+ }
543
+ async initInternalFromWindow(parentSpatialWindowManager) {
544
+ if (true) return;
545
+ var w = await getSession().createWindowContext();
546
+ this.window = w;
547
+ this.entity = await getSession().createEntity();
548
+ this.webview = await getSession().createWindowComponent();
549
+ await this.webview.setFromWindow(w);
550
+ await this.entity.setCoordinateSpace("Dom");
551
+ await this.webview.setScrollWithParent(true);
552
+ await this.webview.setScrollEnabled(false);
553
+ await this.entity.setComponent(this.webview);
554
+ if (parentSpatialWindowManager !== void 0) {
555
+ if (parentSpatialWindowManager !== null) {
556
+ await parentSpatialWindowManager.initPromise;
557
+ this.entity.setParent(parentSpatialWindowManager.entity);
558
+ } else {
559
+ var wc = await getSession().getCurrentWindowComponent();
560
+ var ent = await wc.getEntity();
561
+ await this.entity.setParent(ent);
562
+ }
563
+ }
564
+ }
565
+ async init(url) {
566
+ this.initPromise = this.initInternal(url);
567
+ await this.initPromise;
568
+ }
569
+ async initFromWidow(parentSpatialWindowManager) {
570
+ this.initPromise = this.initInternalFromWindow(parentSpatialWindowManager);
571
+ await this.initPromise;
572
+ }
573
+ async resize(rect, offset, rotation = { x: 0, y: 0, z: 0, w: 1 }, scale = { x: 1, y: 1, z: 1 }, rotationOrigin = { x: 0, y: 0, z: 0 }) {
574
+ let targetPosX = rect.x + rect.width / 2;
575
+ let targetPosY = rect.y + rect.height / 2 + window.scrollY;
576
+ if (!this.webview) {
577
+ return;
578
+ }
579
+ var entity = this.entity;
580
+ entity.transform.position.x = targetPosX + (offset ? offset.x : 0);
581
+ entity.transform.position.y = targetPosY + (offset ? offset.y : 0);
582
+ entity.transform.position.z = offset ? offset.z : 0;
583
+ entity.transform.orientation.x = rotation.x;
584
+ entity.transform.orientation.y = rotation.y;
585
+ entity.transform.orientation.z = rotation.z;
586
+ entity.transform.orientation.w = rotation.w;
587
+ entity.transform.scale.x = scale.x;
588
+ entity.transform.scale.y = scale.y;
589
+ entity.transform.scale.z = scale.z;
590
+ await entity.updateTransform();
591
+ var webview = this.webview;
592
+ await webview.setResolution(rect.width, rect.height);
593
+ await webview.setRotationAnchor(rotationOrigin);
594
+ }
595
+ async setZIndex(zIndex) {
596
+ let entity = this.entity;
597
+ entity.updateZIndex(zIndex);
598
+ }
599
+ async destroy() {
600
+ if (this.initPromise) {
601
+ await this.initPromise;
602
+ this.entity?.destroy();
603
+ this.webview?.destroy();
604
+ this.window = null;
605
+ }
606
+ }
607
+ };
608
+
609
+ // src/spatial-react-components/SpatialReactComponent/SpatialWindowManagerContext.ts
610
+ var import_react5 = require("react");
611
+ var SpatialWindowManagerContext = (0, import_react5.createContext)(null);
612
+
613
+ // src/spatial-react-components/SpatialReactComponent/usePortalContainer.tsx
614
+ function usePortalContainer(options) {
615
+ const isStandard = (0, import_react6.useContext)(SpatialIsStandardInstanceContext);
616
+ const parentSpatialWindowManager = (0, import_react6.useContext)(SpatialWindowManagerContext);
617
+ const forceUpdate = useForceUpdate();
618
+ const spatialWindowManagerRef = (0, import_react6.useRef)();
619
+ (0, import_react6.useEffect)(() => {
620
+ let isDestroyed = false;
621
+ let spawnedResult;
622
+ async function asyncCreatePortalContainer() {
623
+ const session = getSession();
624
+ let windowMgr = new SpatialWindowManager();
625
+ await windowMgr.initFromWidow(parentSpatialWindowManager);
626
+ if (isDestroyed) {
627
+ windowMgr.destroy();
628
+ return;
629
+ }
630
+ spawnedResult = await options.onContainerSpawned(windowMgr);
631
+ if (isDestroyed) {
632
+ options.onContainerDestroyed(windowMgr, spawnedResult);
633
+ windowMgr.destroy();
634
+ return;
635
+ }
636
+ spatialWindowManagerRef.current = windowMgr;
637
+ forceUpdate();
638
+ }
639
+ __name(asyncCreatePortalContainer, "asyncCreatePortalContainer");
640
+ if (isStandard !== true) {
641
+ asyncCreatePortalContainer();
642
+ }
643
+ return () => {
644
+ isDestroyed = true;
645
+ const spatialWindowManager = spatialWindowManagerRef.current;
646
+ if (spatialWindowManager) {
647
+ options.onContainerDestroyed(spatialWindowManager, spawnedResult);
648
+ spatialWindowManager.destroy();
649
+ }
650
+ };
651
+ }, []);
652
+ return [spatialWindowManagerRef.current];
653
+ }
654
+ __name(usePortalContainer, "usePortalContainer");
655
+
656
+ // src/spatial-react-components/SpatialReactComponent/utils.ts
657
+ function getInheritedStyleProps(computedStyle) {
658
+ var propNames = [
659
+ "azimuth",
660
+ "borderCollapse",
661
+ "borderSpacing",
662
+ "captionSide",
663
+ "color",
664
+ "cursor",
665
+ "direction",
666
+ "elevation",
667
+ "emptyCells",
668
+ "fontFamily",
669
+ "fontSize",
670
+ "fontStyle",
671
+ "fontVariant",
672
+ "fontWeight",
673
+ "font",
674
+ "letterSpacing",
675
+ "lineHeight",
676
+ "listStyleImage",
677
+ "listStylePosition",
678
+ "listStyleType",
679
+ "listStyle",
680
+ "orphans",
681
+ "pitchRange",
682
+ "pitch",
683
+ "quotes",
684
+ "richness",
685
+ "speakHeader",
686
+ "speakNumeral",
687
+ "speakPunctuation",
688
+ "speak",
689
+ "speechRate",
690
+ "stress",
691
+ "textAlign",
692
+ "textIndent",
693
+ "textTransform",
694
+ "visibility",
695
+ "voiceFamily",
696
+ "volume",
697
+ "whiteSpace",
698
+ "widows",
699
+ "wordSpacing",
700
+ // background also need to be synced
701
+ "background",
702
+ // position also need to be synced
703
+ "position"
704
+ ];
705
+ var props = {};
706
+ for (var cssName of propNames) {
707
+ if (computedStyle[cssName]) {
708
+ props[cssName] = computedStyle[cssName];
709
+ }
710
+ }
711
+ return props;
712
+ }
713
+ __name(getInheritedStyleProps, "getInheritedStyleProps");
714
+ function domRect2rectType(from) {
715
+ return {
716
+ x: from.x,
717
+ y: from.y,
718
+ width: from.width,
719
+ height: from.height
720
+ };
721
+ }
722
+ __name(domRect2rectType, "domRect2rectType");
723
+ function parseTransformOrigin(computedStyle) {
724
+ const transformOriginProperty = computedStyle.getPropertyValue("transform-origin");
725
+ const [x, y] = transformOriginProperty.split(" ").map(parseFloat);
726
+ const width = parseFloat(computedStyle.getPropertyValue("width"));
727
+ const height = parseFloat(computedStyle.getPropertyValue("height"));
728
+ return {
729
+ x: width > 0 ? x / width : 0.5,
730
+ y: height > 0 ? y / height : 0.5,
731
+ z: 0.5
732
+ };
733
+ }
734
+ __name(parseTransformOrigin, "parseTransformOrigin");
735
+ function parseBorderRadius(borderProperty, width) {
736
+ if (borderProperty === "") {
737
+ return 0;
738
+ }
739
+ if (borderProperty.endsWith("%")) {
740
+ return width * parseFloat(borderProperty) / 100;
741
+ }
742
+ return parseFloat(borderProperty);
743
+ }
744
+ __name(parseBorderRadius, "parseBorderRadius");
745
+ function parseCornerRadius(computedStyle) {
746
+ const width = parseFloat(computedStyle.getPropertyValue("width"));
747
+ const topLeftPropertyValue = computedStyle.getPropertyValue(
748
+ "border-top-left-radius"
749
+ );
750
+ const topRightPropertyValue = computedStyle.getPropertyValue(
751
+ "border-top-right-radius"
752
+ );
753
+ const bottomLeftPropertyValue = computedStyle.getPropertyValue(
754
+ "border-bottom-left-radius"
755
+ );
756
+ const bottomRightPropertyValue = computedStyle.getPropertyValue(
757
+ "border-bottom-right-radius"
758
+ );
759
+ const cornerRadius = {
760
+ topLeading: parseBorderRadius(topLeftPropertyValue, width),
761
+ bottomLeading: parseBorderRadius(bottomLeftPropertyValue, width),
762
+ topTrailing: parseBorderRadius(topRightPropertyValue, width),
763
+ bottomTrailing: parseBorderRadius(bottomRightPropertyValue, width)
764
+ };
765
+ return cornerRadius;
766
+ }
767
+ __name(parseCornerRadius, "parseCornerRadius");
768
+
769
+ // src/spatial-react-components/SpatialReactComponent/SpatialDebugNameContext.ts
770
+ var import_react7 = require("react");
771
+ var SpatialDebugNameContext = (0, import_react7.createContext)("");
772
+
773
+ // src/spatial-react-components/SpatialReactComponent/PortalInstance.tsx
774
+ var import_jsx_runtime2 = require("react/jsx-runtime");
775
+ function renderJSXPortalInstance(inProps, elWidth, elHeight, inheritedPortalStyle, className) {
776
+ const { El, style: inStyle = {}, className: _, ...props } = inProps;
777
+ const extraStyle = {
778
+ visibility: "visible",
779
+ position: "",
780
+ top: "0px",
781
+ left: "0px",
782
+ margin: "0px",
783
+ marginLeft: "0px",
784
+ marginRight: "0px",
785
+ marginTop: "0px",
786
+ marginBottom: "0px",
787
+ borderRadius: "0px",
788
+ overflow: ""
789
+ };
790
+ const elWHStyle = {
791
+ width: `${elWidth}px`,
792
+ height: `${elHeight}px`
793
+ };
794
+ const style = {
795
+ ...inStyle,
796
+ ...inheritedPortalStyle,
797
+ ...extraStyle,
798
+ ...elWHStyle
799
+ };
800
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(El, { style, className, ...props });
801
+ }
802
+ __name(renderJSXPortalInstance, "renderJSXPortalInstance");
803
+ function setOpenWindowStyle(openedWindow) {
804
+ openedWindow.document.documentElement.style.cssText += document.documentElement.style.cssText;
805
+ openedWindow.document.documentElement.style.backgroundColor = "transparent";
806
+ openedWindow.document.body.style.margin = "0px";
807
+ }
808
+ __name(setOpenWindowStyle, "setOpenWindowStyle");
809
+ function handleOpenWindowDocumentClick(openedWindow) {
810
+ openedWindow.document.onclick = function(e) {
811
+ let element = e.target;
812
+ let found = false;
813
+ while (!found) {
814
+ if (element && element.tagName == "A") {
815
+ if (!element.onclick) {
816
+ window.location.href = element.href;
817
+ }
818
+ return false;
819
+ }
820
+ if (element && element.parentElement) {
821
+ element = element.parentElement;
822
+ } else {
823
+ break;
824
+ }
825
+ }
826
+ };
827
+ }
828
+ __name(handleOpenWindowDocumentClick, "handleOpenWindowDocumentClick");
829
+ function asyncLoadStyleToChildWindow(childWindow, n, debugName) {
830
+ return new Promise((resolve) => {
831
+ n.href += "?uniqueURL=" + Math.random();
832
+ n.onerror = function() {
833
+ console.error(
834
+ "Failed to load style link",
835
+ debugName,
836
+ n.href
837
+ );
838
+ resolve(false);
839
+ };
840
+ n.onload = function() {
841
+ resolve(true);
842
+ };
843
+ childWindow.document.head.appendChild(n);
844
+ });
845
+ }
846
+ __name(asyncLoadStyleToChildWindow, "asyncLoadStyleToChildWindow");
847
+ async function syncParentHeadToChild(childWindow, debugName) {
848
+ const styleLoadedPromises = [];
849
+ for (let i = document.head.children.length - 1; i >= 0; i--) {
850
+ let n = document.head.children[i].cloneNode(true);
851
+ if (n.nodeName == "LINK" && n.rel == "stylesheet" && n.href) {
852
+ const promise = asyncLoadStyleToChildWindow(
853
+ childWindow,
854
+ n,
855
+ debugName
856
+ );
857
+ styleLoadedPromises.push(promise);
858
+ } else {
859
+ childWindow.document.head.appendChild(n);
860
+ }
861
+ }
862
+ if (debugName) {
863
+ childWindow.document.title = debugName;
864
+ }
865
+ return Promise.all(styleLoadedPromises);
866
+ }
867
+ __name(syncParentHeadToChild, "syncParentHeadToChild");
868
+ async function syncHeaderStyle(openedWindow, debugName) {
869
+ await syncParentHeadToChild(openedWindow, debugName);
870
+ const headObserver = new MutationObserver((mutations) => {
871
+ syncParentHeadToChild(openedWindow, debugName);
872
+ });
873
+ headObserver.observe(document.head, { childList: true, subtree: true });
874
+ return headObserver;
875
+ }
876
+ __name(syncHeaderStyle, "syncHeaderStyle");
877
+ function syncDefaultSpatialStyle(openedWindow, debugName) {
878
+ const styleElement = document.createElement("style");
879
+ styleElement.type = "text/css";
880
+ styleElement.innerHTML = " .xr-spatial-default { --xr-back: 0.001; --xr-background-material: none } ";
881
+ openedWindow.document.head.appendChild(styleElement);
882
+ }
883
+ __name(syncDefaultSpatialStyle, "syncDefaultSpatialStyle");
884
+ function useSyncSpatialProps(spatialWindowManager, props, domRect, anchor, cornerRadiusFromStyle, opacity) {
885
+ let { allowScroll, scrollWithParent, style, spatialStyle = {} } = props;
886
+ let {
887
+ position = { x: 0, y: 0, z: 1 },
888
+ rotation = { x: 0, y: 0, z: 0, w: 1 },
889
+ scale = { x: 1, y: 1, z: 1 },
890
+ material = { type: "none" },
891
+ cornerRadius = cornerRadiusFromStyle,
892
+ zIndex = 0
893
+ } = spatialStyle;
894
+ let stylePosition = style?.position;
895
+ let styleOverflow = style?.overflow;
896
+ const visible = (0, import_react8.useMemo)(() => {
897
+ return spatialStyle.visible !== false && domRect.width > 0 && domRect.height > 0;
898
+ }, [spatialStyle.visible, domRect.width, domRect.height]);
899
+ if (position.x === void 0) position.x = 0;
900
+ if (position.y === void 0) position.y = 0;
901
+ if (position.z === void 0) position.z = 1;
902
+ if (scale.x === void 0) scale.x = 1;
903
+ if (scale.y === void 0) scale.y = 1;
904
+ if (scale.z === void 0) scale.z = 1;
905
+ const cornerRadiusObject = {
906
+ topLeading: 0,
907
+ bottomLeading: 0,
908
+ topTrailing: 0,
909
+ bottomTrailing: 0
910
+ };
911
+ if (typeof cornerRadius == "number") {
912
+ cornerRadiusObject.topLeading = cornerRadius;
913
+ cornerRadiusObject.bottomLeading = cornerRadius;
914
+ cornerRadiusObject.topTrailing = cornerRadius;
915
+ cornerRadiusObject.bottomTrailing = cornerRadius;
916
+ } else {
917
+ Object.assign(cornerRadiusObject, cornerRadius);
918
+ }
919
+ (0, import_react8.useEffect)(() => {
920
+ if (spatialWindowManager && spatialWindowManager.webview) {
921
+ const webview = spatialWindowManager.webview;
922
+ (async function() {
923
+ webview.setStyle({
924
+ material: { type: material.type },
925
+ cornerRadius: cornerRadiusObject
926
+ });
927
+ })();
928
+ }
929
+ }, [
930
+ spatialWindowManager,
931
+ material.type,
932
+ cornerRadiusObject.topLeading,
933
+ cornerRadiusObject.bottomLeading,
934
+ cornerRadiusObject.topTrailing,
935
+ cornerRadiusObject.bottomTrailing
936
+ ]);
937
+ (0, import_react8.useEffect)(() => {
938
+ if (spatialWindowManager && spatialWindowManager.webview) {
939
+ const webview = spatialWindowManager.webview;
940
+ (async function() {
941
+ webview.setScrollEnabled(allowScroll || styleOverflow == "scroll");
942
+ const isFixed = scrollWithParent == false || stylePosition == "fixed";
943
+ webview.setScrollWithParent(!isFixed);
944
+ })();
945
+ }
946
+ }, [
947
+ spatialWindowManager,
948
+ allowScroll,
949
+ scrollWithParent,
950
+ stylePosition,
951
+ styleOverflow
952
+ ]);
953
+ (0, import_react8.useEffect)(() => {
954
+ if (spatialWindowManager) {
955
+ ;
956
+ (async function() {
957
+ await spatialWindowManager.resize(
958
+ domRect,
959
+ position,
960
+ rotation,
961
+ scale,
962
+ anchor
963
+ );
964
+ spatialWindowManager?.setZIndex(zIndex);
965
+ })();
966
+ }
967
+ }, [
968
+ spatialWindowManager,
969
+ domRect.x,
970
+ domRect.y,
971
+ domRect.width,
972
+ domRect.height,
973
+ position,
974
+ rotation,
975
+ scale,
976
+ anchor,
977
+ zIndex
978
+ ]);
979
+ (0, import_react8.useEffect)(() => {
980
+ if (spatialWindowManager && spatialWindowManager.webview) {
981
+ const webview = spatialWindowManager.webview;
982
+ webview.setOpacity(opacity);
983
+ }
984
+ }, [spatialWindowManager, opacity]);
985
+ (0, import_react8.useEffect)(() => {
986
+ if (spatialWindowManager) {
987
+ spatialWindowManager.entity?.setVisible(visible);
988
+ }
989
+ }, [spatialWindowManager, visible]);
990
+ (0, import_react8.useEffect)(() => {
991
+ if (spatialWindowManager?.window && spatialWindowManager.webview) {
992
+ ;
993
+ (async function() {
994
+ const bodyWidth = document.body.getBoundingClientRect().width;
995
+ const viewport = spatialWindowManager.window?.document.querySelector(
996
+ 'meta[name="viewport"]'
997
+ );
998
+ viewport?.setAttribute(
999
+ "content",
1000
+ `width=${bodyWidth}, initial-scale=1.0 user-scalable=no`
1001
+ );
1002
+ await spatialWindowManager.webview?.setScrollEdgeInsets({
1003
+ top: 0,
1004
+ left: 0,
1005
+ bottom: 0,
1006
+ right: domRect.width - bodyWidth
1007
+ });
1008
+ })();
1009
+ }
1010
+ }, [spatialWindowManager, domRect.width]);
1011
+ }
1012
+ __name(useSyncSpatialProps, "useSyncSpatialProps");
1013
+ function useSyncDomRect(spatialId) {
1014
+ const [domRect, setDomRect] = (0, import_react8.useState)({
1015
+ x: 0,
1016
+ y: 0,
1017
+ width: 0,
1018
+ height: 0
1019
+ });
1020
+ const inheritedPortalStyleRef = (0, import_react8.useRef)({});
1021
+ const anchorRef = (0, import_react8.useRef)({
1022
+ x: 0.5,
1023
+ y: 0.5,
1024
+ z: 0.5
1025
+ });
1026
+ const cornerRadiusRef = (0, import_react8.useRef)({
1027
+ topLeading: 0,
1028
+ bottomLeading: 0,
1029
+ topTrailing: 0,
1030
+ bottomTrailing: 0
1031
+ });
1032
+ const opacityRef = (0, import_react8.useRef)(1);
1033
+ const spatialReactContextObject = (0, import_react8.useContext)(SpatialReactContext);
1034
+ const inheritedPortalClassNameRef = (0, import_react8.useRef)("");
1035
+ (0, import_react8.useEffect)(() => {
1036
+ const syncDomRect = /* @__PURE__ */ __name(() => {
1037
+ const dom = spatialReactContextObject?.querySpatialDom(spatialId);
1038
+ if (!dom) {
1039
+ return;
1040
+ }
1041
+ let domRect2 = dom.getBoundingClientRect();
1042
+ let rectType = domRect2rectType(domRect2);
1043
+ const parentDom = spatialReactContextObject?.queryParentSpatialDom(spatialId);
1044
+ if (parentDom) {
1045
+ const parentDomRect = parentDom.getBoundingClientRect();
1046
+ const parentRectType = domRect2rectType(parentDomRect);
1047
+ rectType.x -= parentRectType.x;
1048
+ rectType.y -= parentRectType.y;
1049
+ }
1050
+ const computedStyle = getComputedStyle(dom);
1051
+ inheritedPortalStyleRef.current = getInheritedStyleProps(computedStyle);
1052
+ const anchor = parseTransformOrigin(computedStyle);
1053
+ anchorRef.current = anchor;
1054
+ const cornerRadius = parseCornerRadius(computedStyle);
1055
+ cornerRadiusRef.current = cornerRadius;
1056
+ const opacity = parseFloat(computedStyle.getPropertyValue("opacity"));
1057
+ opacityRef.current = opacity;
1058
+ inheritedPortalClassNameRef.current = dom.className;
1059
+ setDomRect(rectType);
1060
+ }, "syncDomRect");
1061
+ spatialReactContextObject?.onDomChange(spatialId, syncDomRect);
1062
+ return () => {
1063
+ spatialReactContextObject?.offDomChange(spatialId);
1064
+ };
1065
+ }, []);
1066
+ return {
1067
+ domRect,
1068
+ inheritedPortalStyle: inheritedPortalStyleRef.current,
1069
+ anchor: anchorRef.current,
1070
+ cornerRadius: cornerRadiusRef.current,
1071
+ opacity: opacityRef.current,
1072
+ className: inheritedPortalClassNameRef.current
1073
+ };
1074
+ }
1075
+ __name(useSyncDomRect, "useSyncDomRect");
1076
+ function PortalInstance(inProps) {
1077
+ const { allowScroll, scrollWithParent, spatialStyle, isSubPortal, ...props } = inProps;
1078
+ const debugName = (0, import_react8.useContext)(SpatialDebugNameContext);
1079
+ const onContainerSpawned = (0, import_react8.useCallback)(
1080
+ async (spatialWindowManager2) => {
1081
+ const openWindow = spatialWindowManager2.window;
1082
+ setOpenWindowStyle(openWindow);
1083
+ handleOpenWindowDocumentClick(openWindow);
1084
+ syncDefaultSpatialStyle(openWindow, debugName);
1085
+ const headObserver = await syncHeaderStyle(openWindow, debugName);
1086
+ const spawnedResult = {
1087
+ headObserver
1088
+ };
1089
+ spatialWindowManager2.setDebugName(debugName);
1090
+ return spawnedResult;
1091
+ },
1092
+ []
1093
+ );
1094
+ const onContainerDestroyed = (0, import_react8.useCallback)(
1095
+ (spatialWindowManager2, spawnedResult) => {
1096
+ const { headObserver } = spawnedResult;
1097
+ headObserver.disconnect();
1098
+ },
1099
+ []
1100
+ );
1101
+ const [spatialWindowManager] = usePortalContainer({
1102
+ onContainerSpawned,
1103
+ onContainerDestroyed
1104
+ });
1105
+ const spatialId = props[SpatialID];
1106
+ const {
1107
+ domRect,
1108
+ inheritedPortalStyle,
1109
+ anchor,
1110
+ cornerRadius,
1111
+ opacity,
1112
+ className
1113
+ } = useSyncDomRect(spatialId);
1114
+ useSyncSpatialProps(
1115
+ spatialWindowManager,
1116
+ {
1117
+ style: props.style,
1118
+ allowScroll,
1119
+ scrollWithParent,
1120
+ spatialStyle
1121
+ },
1122
+ domRect,
1123
+ anchor,
1124
+ cornerRadius,
1125
+ opacity
1126
+ );
1127
+ const JSXPortalInstance = renderJSXPortalInstance(
1128
+ props,
1129
+ domRect.width,
1130
+ domRect.height,
1131
+ inheritedPortalStyle,
1132
+ className
1133
+ );
1134
+ const needRenderPlaceHolder = isSubPortal && inheritedPortalStyle.position !== "absolute";
1135
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(SpatialWindowManagerContext.Provider, { value: spatialWindowManager, children: [
1136
+ needRenderPlaceHolder && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1137
+ "div",
1138
+ {
1139
+ className,
1140
+ style: {
1141
+ position: "relative",
1142
+ width: `${domRect.width}px`,
1143
+ height: `${domRect.height}px`
1144
+ }
1145
+ }
1146
+ ),
1147
+ spatialWindowManager && spatialWindowManager.window && (0, import_react_dom.createPortal)(
1148
+ JSXPortalInstance,
1149
+ spatialWindowManager.window.document.body
1150
+ )
1151
+ ] });
1152
+ }
1153
+ __name(PortalInstance, "PortalInstance");
1154
+ PortalInstance.displayName = "PortalInstance";
1155
+
1156
+ // src/spatial-react-components/SpatialReactComponent/SpatialLayerContext.ts
1157
+ var import_react9 = require("react");
1158
+ var SpatialLayerContext = (0, import_react9.createContext)(0);
1159
+
1160
+ // src/spatial-react-components/SpatialReactComponent/SpatialReactComponent.tsx
1161
+ var import_jsx_runtime3 = require("react/jsx-runtime");
1162
+ function parseProps(inProps) {
1163
+ const {
1164
+ debugShowStandardInstance,
1165
+ debugName = "",
1166
+ component,
1167
+ allowScroll,
1168
+ spatialStyle,
1169
+ scrollWithParent,
1170
+ ...props
1171
+ } = inProps;
1172
+ const El = component ? component : "div";
1173
+ const componentDesc = { El };
1174
+ const spatialDesc = { spatialStyle, allowScroll, scrollWithParent };
1175
+ const debugDesc = { debugName, debugShowStandardInstance };
1176
+ return { componentDesc, spatialDesc, debugDesc, props };
1177
+ }
1178
+ __name(parseProps, "parseProps");
1179
+ function renderWebReactComponent(inProps, ref) {
1180
+ const { componentDesc, props } = parseProps(inProps);
1181
+ const { El } = componentDesc;
1182
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(El, { ...props, ref });
1183
+ }
1184
+ __name(renderWebReactComponent, "renderWebReactComponent");
1185
+ function renderSpatialReactComponent(inProps, ref) {
1186
+ const { componentDesc, spatialDesc, debugDesc, props } = parseProps(inProps);
1187
+ const standardInstanceProps = {
1188
+ ...props,
1189
+ ...componentDesc,
1190
+ debugShowStandardInstance: debugDesc.debugShowStandardInstance
1191
+ };
1192
+ const portalInstanceProps = {
1193
+ ...props,
1194
+ ...componentDesc,
1195
+ ...spatialDesc
1196
+ };
1197
+ const spatialReactContextObject = (0, import_react10.useMemo)(
1198
+ () => new SpatialReactContextObject(debugDesc.debugName),
1199
+ []
1200
+ );
1201
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(SpatialReactContext.Provider, { value: spatialReactContextObject, children: [
1202
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StandardInstance, { ...standardInstanceProps, ref }),
1203
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PortalInstance, { isSubPortal: false, ...portalInstanceProps })
1204
+ ] });
1205
+ }
1206
+ __name(renderSpatialReactComponent, "renderSpatialReactComponent");
1207
+ function renderSubPortalInstance(inProps) {
1208
+ const { componentDesc, spatialDesc, props } = parseProps(inProps);
1209
+ const portalInstanceProps = {
1210
+ ...props,
1211
+ ...componentDesc,
1212
+ ...spatialDesc
1213
+ };
1214
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PortalInstance, { isSubPortal: true, ...portalInstanceProps });
1215
+ }
1216
+ __name(renderSubPortalInstance, "renderSubPortalInstance");
1217
+ function SpatialReactComponentRefactor(inProps, ref) {
1218
+ const layer = (0, import_react10.useContext)(SpatialLayerContext) + 1;
1219
+ const parentSpatialReactContextObject = (0, import_react10.useContext)(SpatialReactContext);
1220
+ const isRootInstance = !parentSpatialReactContextObject;
1221
+ const isInStandardInstance = !!(0, import_react10.useContext)(SpatialIsStandardInstanceContext);
1222
+ const spatialID = (0, import_react10.useMemo)(() => {
1223
+ return isRootInstance ? layer.toString() : parentSpatialReactContextObject.getSpatialID(
1224
+ layer,
1225
+ isInStandardInstance,
1226
+ inProps.debugName
1227
+ );
1228
+ }, []);
1229
+ const props = { ...inProps, [SpatialID]: spatialID };
1230
+ const contentInLayer = renderContentInLayer(props, ref);
1231
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SpatialDebugNameContext.Provider, { value: inProps.debugName || "", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SpatialLayerContext.Provider, { value: layer, children: contentInLayer }) });
1232
+ }
1233
+ __name(SpatialReactComponentRefactor, "SpatialReactComponentRefactor");
1234
+ function renderContentInLayer(inProps, ref) {
1235
+ const isInStandardInstance = (0, import_react10.useContext)(SpatialIsStandardInstanceContext);
1236
+ const isWebSpatialEnv = getSession() !== null;
1237
+ if (isInStandardInstance || !isWebSpatialEnv) {
1238
+ return renderWebReactComponent(inProps, ref);
1239
+ } else {
1240
+ const parentSpatialReactContextObject = (0, import_react10.useContext)(SpatialReactContext);
1241
+ if (parentSpatialReactContextObject) {
1242
+ return renderSubPortalInstance(inProps);
1243
+ } else {
1244
+ return renderSpatialReactComponent(inProps, ref);
1245
+ }
1246
+ }
1247
+ }
1248
+ __name(renderContentInLayer, "renderContentInLayer");
1249
+ var SpatialReactComponent = (0, import_react10.forwardRef)(SpatialReactComponentRefactor);
1250
+ SpatialReactComponent.displayName = "SpatialReactComponent";
1251
+
1252
+ // src/spatial-react-components/SpatialPrimitive.tsx
1253
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1254
+ var cachedWithSpatialType = /* @__PURE__ */ new Map();
1255
+ function withSpatial(Component) {
1256
+ if (cachedWithSpatialType.has(Component)) {
1257
+ return cachedWithSpatialType.get(Component);
1258
+ } else {
1259
+ const WithSpatialComponent = (0, import_react11.forwardRef)(
1260
+ (givenProps, givenRef) => {
1261
+ const { component: ignoreComponent, ...props } = givenProps;
1262
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1263
+ SpatialReactComponent,
1264
+ {
1265
+ component: Component,
1266
+ ...props,
1267
+ ref: givenRef
1268
+ }
1269
+ );
1270
+ }
1271
+ );
1272
+ WithSpatialComponent.displayName = `WithSpatial(${typeof Component === "string" ? Component : Component.displayName || Component.name})`;
1273
+ cachedWithSpatialType.set(Component, WithSpatialComponent);
1274
+ cachedWithSpatialType.set(WithSpatialComponent, WithSpatialComponent);
1275
+ return WithSpatialComponent;
1276
+ }
1277
+ }
1278
+ __name(withSpatial, "withSpatial");
1279
+ var SpatialPrimitive = {};
1280
+ (/* @__PURE__ */ __name(function createSpatialPrimitive(SpatialPrimitive2) {
1281
+ primitives.forEach((primitive) => {
1282
+ SpatialPrimitive2[primitive] = withSpatial(primitive);
1283
+ });
1284
+ }, "createSpatialPrimitive"))(SpatialPrimitive);
1285
+ var SpatialDiv = SpatialPrimitive.div;
1286
+
1287
+ // src/spatial-react-components/hooks/useMonitorDomChange.tsx
1288
+ var import_react12 = require("react");
1289
+
1290
+ // src/spatial-react-components/notifyUpdateStandInstanceLayout.ts
1291
+ function notifyUpdateStandInstanceLayout() {
1292
+ document.dispatchEvent(
1293
+ new CustomEvent("standInstanceLayout" /* standInstanceLayout */, {
1294
+ detail: {}
1295
+ })
1296
+ );
1297
+ }
1298
+ __name(notifyUpdateStandInstanceLayout, "notifyUpdateStandInstanceLayout");
1299
+ function notifyDOMUpdate(mutationsList) {
1300
+ document.dispatchEvent(
1301
+ new CustomEvent("domUpdated" /* domUpdated */, {
1302
+ detail: mutationsList
1303
+ })
1304
+ );
1305
+ }
1306
+ __name(notifyDOMUpdate, "notifyDOMUpdate");
1307
+
1308
+ // src/spatial-react-components/hooks/useMonitorDomChange.tsx
1309
+ function useMonitorDomChange() {
1310
+ const ref = (0, import_react12.useRef)(void 0);
1311
+ (0, import_react12.useEffect)(() => {
1312
+ const observer = new MutationObserver((mutationsList) => {
1313
+ notifyDOMUpdate(mutationsList);
1314
+ });
1315
+ const config = {
1316
+ childList: true,
1317
+ subtree: true,
1318
+ attributes: true,
1319
+ attributeFilter: ["style", "class"]
1320
+ };
1321
+ ref.current && observer.observe(ref.current, config);
1322
+ return () => {
1323
+ observer.disconnect();
1324
+ };
1325
+ }, []);
1326
+ return ref;
1327
+ }
1328
+ __name(useMonitorDomChange, "useMonitorDomChange");
1329
+
1330
+ // src/spatial-react-components/hooks/useMonitorDocumentHeaderChange.tsx
1331
+ var import_react13 = require("react");
1332
+ function useMonitorDocumentHeaderChange() {
1333
+ (0, import_react13.useEffect)(() => {
1334
+ const observer = new MutationObserver((mutationsList) => {
1335
+ notifyUpdateStandInstanceLayout();
1336
+ });
1337
+ const config = {
1338
+ childList: true,
1339
+ subtree: true,
1340
+ attributes: true
1341
+ };
1342
+ observer.observe(document.head, config);
1343
+ return () => {
1344
+ observer.disconnect();
1345
+ };
1346
+ }, []);
1347
+ }
1348
+ __name(useMonitorDocumentHeaderChange, "useMonitorDocumentHeaderChange");
1349
+
1350
+ // src/spatial-react-components/SpatialMonitor.tsx
1351
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1352
+ function SpatialMonitor(props) {
1353
+ const { children, ...otherProps } = props;
1354
+ const ref = useMonitorDomChange();
1355
+ useMonitorDocumentHeaderChange();
1356
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { ref, ...otherProps, children: [
1357
+ " ",
1358
+ children,
1359
+ " "
1360
+ ] });
1361
+ }
1362
+ __name(SpatialMonitor, "SpatialMonitor");
1363
+
1364
+ // src/spatial-react-components/CSSSpatialDiv/CSSSpatialDiv.tsx
1365
+ var import_react20 = require("react");
1366
+
1367
+ // src/spatial-react-components/CSSSpatialDiv/CSSSpatialComponent.tsx
1368
+ var import_react19 = require("react");
1369
+
1370
+ // src/spatial-react-components/CSSSpatialDiv/useSpatialStyle.ts
1371
+ var import_react14 = require("react");
1372
+ var import_lodash = __toESM(require("lodash.isequal"));
1373
+
1374
+ // src/spatial-react-components/CSSSpatialDiv/math/index.ts
1375
+ var import_Matrix4 = require("three/src/math/Matrix4.js");
1376
+ var import_Vector3 = require("three/src/math/Vector3.js");
1377
+ var import_Quaternion = require("three/src/math/Quaternion.js");
1378
+
1379
+ // src/spatial-react-components/CSSSpatialDiv/const.ts
1380
+ var SpatialCustomVars = {
1381
+ back: "--xr-back",
1382
+ backgroundMaterial: "--xr-background-material"
1383
+ };
1384
+ var BackgroundMaterialDefault = "none";
1385
+
1386
+ // src/spatial-react-components/CSSSpatialDiv/useSpatialStyle.ts
1387
+ function parse2dMatrix(transformDataArray) {
1388
+ const [n11, n21, n12, n22, n13, n23] = transformDataArray;
1389
+ const matrix4 = new import_Matrix4.Matrix4(
1390
+ n11,
1391
+ n12,
1392
+ 0,
1393
+ n13,
1394
+ n21,
1395
+ n22,
1396
+ 0,
1397
+ n23,
1398
+ 0,
1399
+ 0,
1400
+ 1,
1401
+ 0,
1402
+ 0,
1403
+ 0,
1404
+ 0,
1405
+ 1
1406
+ );
1407
+ return matrix4;
1408
+ }
1409
+ __name(parse2dMatrix, "parse2dMatrix");
1410
+ function parse3dMatrix(transformDataArray) {
1411
+ const matrix4 = new import_Matrix4.Matrix4().fromArray(transformDataArray);
1412
+ return matrix4;
1413
+ }
1414
+ __name(parse3dMatrix, "parse3dMatrix");
1415
+ function parseTransform(computedStyle) {
1416
+ let transform = computedStyle.getPropertyValue("transform");
1417
+ const matrixFlagString = "matrix(";
1418
+ const idxOfMatrix = transform.indexOf(matrixFlagString);
1419
+ if (idxOfMatrix !== -1) {
1420
+ const transformDataArray = transform.substring(matrixFlagString.length, transform.length - 1).split(",").map((item) => parseFloat(item));
1421
+ return parse2dMatrix(transformDataArray);
1422
+ } else {
1423
+ const matrix3dFlagString = "matrix3d(";
1424
+ const idxOfMatrix3d = transform.indexOf(matrix3dFlagString);
1425
+ if (idxOfMatrix3d !== -1) {
1426
+ const transform3dDataArray = transform.substring(matrix3dFlagString.length, transform.length - 1).split(",").map((item) => parseFloat(item));
1427
+ return parse3dMatrix(transform3dDataArray);
1428
+ } else {
1429
+ return new import_Matrix4.Matrix4();
1430
+ }
1431
+ }
1432
+ }
1433
+ __name(parseTransform, "parseTransform");
1434
+ function parseBack(computedStyle) {
1435
+ let useBackProperty = computedStyle.position === "absolute" || computedStyle.position === "relative";
1436
+ if (!useBackProperty) return new import_Matrix4.Matrix4();
1437
+ let backProperty = computedStyle.getPropertyValue(SpatialCustomVars.back);
1438
+ let back = void 0;
1439
+ try {
1440
+ back = parseFloat(backProperty);
1441
+ } catch (error) {
1442
+ }
1443
+ return new import_Matrix4.Matrix4().makeTranslation(0, 0, back || 1);
1444
+ }
1445
+ __name(parseBack, "parseBack");
1446
+ function parseSpatialStyle(node) {
1447
+ const computedStyle = getComputedStyle(node);
1448
+ const mat4ForBack = parseBack(computedStyle);
1449
+ const mat4ForTransform = parseTransform(computedStyle);
1450
+ const resultMatrix = new import_Matrix4.Matrix4();
1451
+ resultMatrix.multiplyMatrices(mat4ForBack, mat4ForTransform);
1452
+ const position = new import_Vector3.Vector3();
1453
+ const quaternion = new import_Quaternion.Quaternion();
1454
+ const scale = new import_Vector3.Vector3();
1455
+ resultMatrix.decompose(position, quaternion, scale);
1456
+ const zIndex = parseFloat(computedStyle.getPropertyValue("z-index"));
1457
+ const visible = computedStyle.getPropertyValue("visibility") === "visible";
1458
+ const backgroundMaterialType = computedStyle.getPropertyValue(
1459
+ SpatialCustomVars.backgroundMaterial
1460
+ );
1461
+ return {
1462
+ position: { x: position.x, y: position.y, z: position.z },
1463
+ rotation: {
1464
+ x: quaternion.x,
1465
+ y: quaternion.y,
1466
+ z: quaternion.z,
1467
+ w: quaternion.w
1468
+ },
1469
+ scale: { x: scale.x, y: scale.y, z: scale.z },
1470
+ zIndex,
1471
+ material: {
1472
+ type: backgroundMaterialType
1473
+ },
1474
+ visible
1475
+ };
1476
+ }
1477
+ __name(parseSpatialStyle, "parseSpatialStyle");
1478
+ function useSpatialStyle() {
1479
+ const ref = (0, import_react14.useRef)(null);
1480
+ const [spatialStyle, setSpatialStyle] = (0, import_react14.useState)({
1481
+ position: { x: 0, y: 0, z: 1 },
1482
+ rotation: { x: 0, y: 0, z: 0, w: 1 },
1483
+ scale: { x: 1, y: 1, z: 1 },
1484
+ zIndex: 0,
1485
+ material: {
1486
+ type: "none"
1487
+ },
1488
+ visible: true
1489
+ });
1490
+ const [ready, setReady] = (0, import_react14.useState)(false);
1491
+ const checkSpatialStyleUpdate = (0, import_react14.useCallback)(() => {
1492
+ const nextSpatialStyle = parseSpatialStyle(ref.current);
1493
+ if (!(0, import_lodash.default)(spatialStyle, nextSpatialStyle)) {
1494
+ setSpatialStyle(nextSpatialStyle);
1495
+ }
1496
+ }, []);
1497
+ (0, import_react14.useEffect)(() => {
1498
+ if (!ref.current) {
1499
+ return;
1500
+ }
1501
+ const spatialStyle2 = parseSpatialStyle(ref.current);
1502
+ setSpatialStyle(spatialStyle2);
1503
+ setReady(true);
1504
+ }, []);
1505
+ (0, import_react14.useEffect)(() => {
1506
+ if (!ref.current) {
1507
+ return;
1508
+ }
1509
+ const observer = new MutationObserver((mutationsList) => {
1510
+ checkSpatialStyleUpdate();
1511
+ });
1512
+ const config = {
1513
+ childList: true,
1514
+ subtree: true,
1515
+ attributes: true,
1516
+ // attributeOldValue: true,
1517
+ attributeFilter: ["style", "class"]
1518
+ };
1519
+ observer.observe(ref.current, config);
1520
+ return () => {
1521
+ observer.disconnect();
1522
+ };
1523
+ }, []);
1524
+ (0, import_react14.useEffect)(() => {
1525
+ if (!ref.current) {
1526
+ return;
1527
+ }
1528
+ function isDescendant(child, parent) {
1529
+ if (child === parent) {
1530
+ return true;
1531
+ }
1532
+ let node = child;
1533
+ while (node) {
1534
+ if (node === parent) {
1535
+ return true;
1536
+ }
1537
+ node = node.parentElement;
1538
+ }
1539
+ return false;
1540
+ }
1541
+ __name(isDescendant, "isDescendant");
1542
+ const onDomUpdated = /* @__PURE__ */ __name((event) => {
1543
+ const mutationsList = event.detail;
1544
+ const spatialReactComponentDiv = ref.current.previousElementSibling;
1545
+ const targets = mutationsList.map((m) => m.target).filter(
1546
+ (node) => node !== ref.current && !isDescendant(node, spatialReactComponentDiv)
1547
+ );
1548
+ if (targets.length > 0) {
1549
+ checkSpatialStyleUpdate();
1550
+ }
1551
+ }, "onDomUpdated");
1552
+ document.addEventListener(
1553
+ "domUpdated" /* domUpdated */,
1554
+ onDomUpdated
1555
+ );
1556
+ return () => {
1557
+ document.removeEventListener(
1558
+ "domUpdated" /* domUpdated */,
1559
+ onDomUpdated
1560
+ );
1561
+ };
1562
+ }, []);
1563
+ return { ref, ready, spatialStyle };
1564
+ }
1565
+ __name(useSpatialStyle, "useSpatialStyle");
1566
+
1567
+ // src/spatial-react-components/CSSSpatialDiv/CSSSpatialDebugNameContext.ts
1568
+ var import_react15 = require("react");
1569
+ var CSSSpatialDebugNameContext = (0, import_react15.createContext)("");
1570
+
1571
+ // src/spatial-react-components/CSSSpatialDiv/useHijackSpatialDivRef.ts
1572
+ var import_react16 = require("react");
1573
+
1574
+ // src/spatial-react-components/CSSSpatialDiv/injectClassStyle.ts
1575
+ var InjectClassName = "xr-css-spatial-default";
1576
+ function injectClassStyle() {
1577
+ const style = document.createElement("style");
1578
+ style.innerHTML = `
1579
+ .${InjectClassName} {
1580
+ ${SpatialCustomVars.backgroundMaterial}: ${BackgroundMaterialDefault};
1581
+ }
1582
+ `;
1583
+ document.head.prepend(style);
1584
+ }
1585
+ __name(injectClassStyle, "injectClassStyle");
1586
+ injectClassStyle();
1587
+
1588
+ // src/spatial-react-components/CSSSpatialDiv/utils.ts
1589
+ function extractAndRemoveCustomProperties(cssText, properties) {
1590
+ if (!cssText) {
1591
+ return { extractedValues: {}, filteredCssText: "" };
1592
+ }
1593
+ const extractedValues = {};
1594
+ const rules = cssText.split(";");
1595
+ const filteredRules = rules.filter((rule) => {
1596
+ const [key, value] = rule.split(":").map((part) => part.trim());
1597
+ if (properties.includes(key)) {
1598
+ extractedValues[key] = value;
1599
+ return false;
1600
+ }
1601
+ return true;
1602
+ });
1603
+ const filteredCssText = filteredRules.join(";").trim();
1604
+ return { extractedValues, filteredCssText };
1605
+ }
1606
+ __name(extractAndRemoveCustomProperties, "extractAndRemoveCustomProperties");
1607
+ function joinToCSSText(cssKV) {
1608
+ const rules = Object.entries(cssKV).map(([key, value]) => `${key}: ${value}`);
1609
+ return rules.join(";");
1610
+ }
1611
+ __name(joinToCSSText, "joinToCSSText");
1612
+
1613
+ // src/spatial-react-components/CSSSpatialDiv/useHijackSpatialDivRef.ts
1614
+ function makeOriginalKey(key) {
1615
+ return `__original_${key}`;
1616
+ }
1617
+ __name(makeOriginalKey, "makeOriginalKey");
1618
+ function useHijackSpatialDivRef(refIn, cssParserRef) {
1619
+ const ref = cssParserRef;
1620
+ const spatialDivRef = (0, import_react16.useCallback)(
1621
+ (domElement) => {
1622
+ if (domElement && refIn) {
1623
+ const domStyle = domElement.style;
1624
+ const domStyleProxy = new Proxy(domStyle, {
1625
+ get(target, prop) {
1626
+ if (typeof target[prop] === "function") {
1627
+ return function(...args) {
1628
+ if (prop === "setProperty") {
1629
+ const [property, value] = args;
1630
+ if (property === SpatialCustomVars.backgroundMaterial) {
1631
+ ref.current?.style.setProperty(
1632
+ SpatialCustomVars.backgroundMaterial,
1633
+ value
1634
+ );
1635
+ } else if (property === SpatialCustomVars.back) {
1636
+ ref.current?.style.setProperty(
1637
+ SpatialCustomVars.back,
1638
+ value
1639
+ );
1640
+ } else if (property === "transform") {
1641
+ ref.current?.style.setProperty(property, value);
1642
+ return true;
1643
+ }
1644
+ } else if (prop === "removeProperty") {
1645
+ const [property] = args;
1646
+ if (property === SpatialCustomVars.backgroundMaterial || property === SpatialCustomVars.back || property === "transform") {
1647
+ ref.current?.style.removeProperty(property);
1648
+ }
1649
+ } else if (prop === "getPropertyValue") {
1650
+ const [property] = args;
1651
+ if (property === "transform") {
1652
+ return ref.current?.style[property];
1653
+ }
1654
+ }
1655
+ return target[prop](
1656
+ ...args
1657
+ );
1658
+ };
1659
+ }
1660
+ if (prop === "transform") {
1661
+ return ref.current?.style[prop];
1662
+ }
1663
+ if (prop === "visibility") {
1664
+ return ref.current?.style.visibility;
1665
+ }
1666
+ if (prop === "cssText") {
1667
+ }
1668
+ return Reflect.get(target, prop);
1669
+ },
1670
+ set(target, property, value) {
1671
+ if (property === SpatialCustomVars.backgroundMaterial) {
1672
+ ref.current?.style.setProperty(
1673
+ SpatialCustomVars.backgroundMaterial,
1674
+ value
1675
+ );
1676
+ } else if (property === SpatialCustomVars.back) {
1677
+ ref.current?.style.setProperty(
1678
+ SpatialCustomVars.back,
1679
+ value
1680
+ );
1681
+ } else if (property === "transform") {
1682
+ ref.current?.style.setProperty(property, value);
1683
+ return true;
1684
+ } else if (property === "visibility") {
1685
+ ref.current?.style.setProperty(property, value);
1686
+ return true;
1687
+ } else if (property === "cssText") {
1688
+ const toFilteredCSSProperties = [
1689
+ "transform",
1690
+ "visibility",
1691
+ SpatialCustomVars.back,
1692
+ SpatialCustomVars.backgroundMaterial
1693
+ ];
1694
+ const { extractedValues, filteredCssText } = extractAndRemoveCustomProperties(
1695
+ value,
1696
+ toFilteredCSSProperties
1697
+ );
1698
+ toFilteredCSSProperties.forEach((key) => {
1699
+ if (extractedValues[key]) {
1700
+ ref.current?.style.setProperty(key, extractedValues[key]);
1701
+ } else {
1702
+ ref.current?.style.removeProperty(key);
1703
+ }
1704
+ });
1705
+ const appendedCSSText = joinToCSSText({
1706
+ transform: "none",
1707
+ visibility: "hidden"
1708
+ });
1709
+ return Reflect.set(
1710
+ target,
1711
+ property,
1712
+ [appendedCSSText, filteredCssText].join(";")
1713
+ );
1714
+ }
1715
+ return Reflect.set(target, property, value);
1716
+ }
1717
+ });
1718
+ const domClassList = domElement.classList;
1719
+ const domClassMethodKeys = ["add", "remove", "toggle", "replace"];
1720
+ domClassMethodKeys.forEach((key) => {
1721
+ const hiddenKey = makeOriginalKey(key);
1722
+ const hiddenKeyExist = domClassList[hiddenKey] !== void 0;
1723
+ const originalMethod = hiddenKeyExist ? domClassList[hiddenKey] : domClassList[key].bind(domClassList);
1724
+ domClassList[hiddenKey] = originalMethod;
1725
+ domClassList[key] = function(...args) {
1726
+ const result = originalMethod(...args);
1727
+ if (ref.current) {
1728
+ ref.current.className = domElement.className + " " + InjectClassName;
1729
+ }
1730
+ return result;
1731
+ };
1732
+ });
1733
+ const __getComputedStyle = /* @__PURE__ */ __name((originalGetComputedStyle, pseudoElt) => {
1734
+ return originalGetComputedStyle(domElement, pseudoElt);
1735
+ }, "__getComputedStyle");
1736
+ const proxyDomElement = new Proxy(domElement, {
1737
+ get(target, prop) {
1738
+ if (prop === "style") {
1739
+ return domStyleProxy;
1740
+ }
1741
+ if (prop === "__isSpatialDiv") {
1742
+ return true;
1743
+ }
1744
+ if (prop === "__getComputedStyle") {
1745
+ return __getComputedStyle;
1746
+ }
1747
+ if (typeof target[prop] === "function") {
1748
+ return function(...args) {
1749
+ if ("removeAttribute" === prop) {
1750
+ const [property] = args;
1751
+ if (property === "style") {
1752
+ domStyleProxy.cssText = "";
1753
+ return true;
1754
+ }
1755
+ if (property === "class") {
1756
+ proxyDomElement.className = "";
1757
+ return true;
1758
+ }
1759
+ }
1760
+ return target[prop](...args);
1761
+ };
1762
+ }
1763
+ return Reflect.get(target, prop, target);
1764
+ },
1765
+ set(target, prop, value) {
1766
+ if (ref.current) {
1767
+ if (prop === "className") {
1768
+ ref.current.className = value + " " + InjectClassName;
1769
+ }
1770
+ if (prop === "style") {
1771
+ domStyleProxy.cssText = joinToCSSText(value);
1772
+ return true;
1773
+ }
1774
+ }
1775
+ return Reflect.set(target, prop, value);
1776
+ }
1777
+ });
1778
+ if (typeof refIn === "function") {
1779
+ refIn(proxyDomElement);
1780
+ } else {
1781
+ refIn.current = proxyDomElement;
1782
+ }
1783
+ } else if (refIn) {
1784
+ if (typeof refIn === "function") {
1785
+ refIn(null);
1786
+ } else {
1787
+ refIn.current = null;
1788
+ }
1789
+ }
1790
+ },
1791
+ [refIn]
1792
+ );
1793
+ return spatialDivRef;
1794
+ }
1795
+ __name(useHijackSpatialDivRef, "useHijackSpatialDivRef");
1796
+
1797
+ // src/spatial-react-components/CSSSpatialDiv/CSSSpatialLayerContext.ts
1798
+ var import_react17 = require("react");
1799
+ var CSSSpatialLayerContext = (0, import_react17.createContext)(0);
1800
+
1801
+ // src/spatial-react-components/CSSSpatialDiv/CSSSpatialRootContext.ts
1802
+ var import_react18 = require("react");
1803
+ var CSSSpatialID = "CSSSpatialID";
1804
+ var CSSSpatialRootContextObject = class {
1805
+ static {
1806
+ __name(this, "CSSSpatialRootContextObject");
1807
+ }
1808
+ prefix = "css";
1809
+ domSpatialId = null;
1810
+ fns = {};
1811
+ // cache dom for each spatialId
1812
+ spatialId2dom = {};
1813
+ // layer : [standardInstance sequence, portalInstance sequence]
1814
+ layerSequences = {};
1815
+ getSpatialID(layer, isInStandardInstance, debugName = "") {
1816
+ if (this.layerSequences[layer] === void 0) {
1817
+ this.layerSequences[layer] = [0, 0];
1818
+ }
1819
+ const idx = isInStandardInstance ? 0 : 1;
1820
+ const sequenceId = this.layerSequences[layer][idx];
1821
+ this.layerSequences[layer][idx] = sequenceId + 1;
1822
+ const spatialId = `${this.prefix}_${debugName}_${layer}_${sequenceId}`;
1823
+ return spatialId;
1824
+ }
1825
+ onDomChange(spatialId, fn) {
1826
+ this.fns[spatialId] = fn;
1827
+ }
1828
+ offDomChange(spatialId, fn) {
1829
+ delete this.fns[spatialId];
1830
+ }
1831
+ setCSSParserRef(cssSpatialID, domElement) {
1832
+ if (domElement) {
1833
+ this.spatialId2dom[cssSpatialID] = domElement;
1834
+ } else {
1835
+ delete this.spatialId2dom[cssSpatialID];
1836
+ }
1837
+ this.fns[cssSpatialID]?.(domElement);
1838
+ }
1839
+ };
1840
+ var CSSSpatialRootContext = (0, import_react18.createContext)(null);
1841
+
1842
+ // src/spatial-react-components/CSSSpatialDiv/CSSSpatialComponent.tsx
1843
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1844
+ function renderRootCSSSpatialComponent(inProps, refIn) {
1845
+ const cssSpatialRootContextObject = (0, import_react19.useMemo)(
1846
+ () => new CSSSpatialRootContextObject(),
1847
+ []
1848
+ );
1849
+ const {
1850
+ style = {},
1851
+ className = "",
1852
+ children,
1853
+ debugName,
1854
+ debugShowStandardInstance,
1855
+ ...props
1856
+ } = inProps;
1857
+ const { ref, spatialStyle, ready } = useSpatialStyle();
1858
+ const divRefStyle = {
1859
+ ...style,
1860
+ width: 0,
1861
+ height: 0,
1862
+ transition: "none"
1863
+ };
1864
+ const spatialDivStyle = {
1865
+ ...style,
1866
+ transform: "none"
1867
+ };
1868
+ const El = inProps.component || "div";
1869
+ const spatialDivRef = useHijackSpatialDivRef(refIn, ref);
1870
+ const divRefClassName = className + " " + InjectClassName;
1871
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(CSSSpatialRootContext.Provider, { value: cssSpatialRootContextObject, children: [
1872
+ ready && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1873
+ SpatialReactComponent,
1874
+ {
1875
+ style: spatialDivStyle,
1876
+ className,
1877
+ children,
1878
+ ...props,
1879
+ spatialStyle,
1880
+ debugName,
1881
+ debugShowStandardInstance,
1882
+ ref: spatialDivRef
1883
+ }
1884
+ ),
1885
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1886
+ El,
1887
+ {
1888
+ style: divRefStyle,
1889
+ className: divRefClassName,
1890
+ ...props,
1891
+ ref
1892
+ }
1893
+ )
1894
+ ] });
1895
+ }
1896
+ __name(renderRootCSSSpatialComponent, "renderRootCSSSpatialComponent");
1897
+ function renderInWebEnv(props, ref) {
1898
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SpatialReactComponent, { ...props, ref });
1899
+ }
1900
+ __name(renderInWebEnv, "renderInWebEnv");
1901
+ function renderInStandardInstance(cssSpatialRootContextObject, cssSpatialID, inProps, refIn) {
1902
+ const { style: inStyle = {}, ...props } = inProps;
1903
+ const style = {
1904
+ ...inStyle,
1905
+ transform: "none",
1906
+ visibility: "hidden"
1907
+ };
1908
+ var cssParserRef = (0, import_react19.useRef)(null);
1909
+ const spatialDivRef = useHijackSpatialDivRef(refIn, cssParserRef);
1910
+ (0, import_react19.useEffect)(() => {
1911
+ const onDomChangeAction = /* @__PURE__ */ __name((dom) => {
1912
+ cssParserRef.current = dom;
1913
+ }, "onDomChangeAction");
1914
+ cssSpatialRootContextObject.onDomChange(cssSpatialID, onDomChangeAction);
1915
+ return () => {
1916
+ cssSpatialRootContextObject.offDomChange(cssSpatialID, onDomChangeAction);
1917
+ };
1918
+ }, []);
1919
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SpatialReactComponent, { style, ...props, ref: spatialDivRef });
1920
+ }
1921
+ __name(renderInStandardInstance, "renderInStandardInstance");
1922
+ function renderInPortalInstance(cssSpatialRootContextObject, cssSpatialID, inProps) {
1923
+ const {
1924
+ style = {},
1925
+ className = "",
1926
+ children,
1927
+ debugName,
1928
+ debugShowStandardInstance,
1929
+ ...props
1930
+ } = inProps;
1931
+ const { ref, spatialStyle, ready } = useSpatialStyle();
1932
+ const divRefStyle = {
1933
+ ...style,
1934
+ width: 0,
1935
+ height: 0,
1936
+ transition: "none"
1937
+ };
1938
+ const spatialDivStyle = {
1939
+ ...style,
1940
+ transform: "none"
1941
+ };
1942
+ const El = inProps.component || "div";
1943
+ const divRefClassName = className + " " + InjectClassName;
1944
+ (0, import_react19.useEffect)(() => {
1945
+ cssSpatialRootContextObject.setCSSParserRef(cssSpatialID, ref.current);
1946
+ }, [ref.current]);
1947
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1948
+ ready && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1949
+ SpatialReactComponent,
1950
+ {
1951
+ style: spatialDivStyle,
1952
+ className,
1953
+ children,
1954
+ ...props,
1955
+ spatialStyle,
1956
+ debugName,
1957
+ debugShowStandardInstance
1958
+ }
1959
+ ),
1960
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1961
+ El,
1962
+ {
1963
+ style: divRefStyle,
1964
+ className: divRefClassName,
1965
+ ...props,
1966
+ ref
1967
+ }
1968
+ )
1969
+ ] });
1970
+ }
1971
+ __name(renderInPortalInstance, "renderInPortalInstance");
1972
+ function CSSSpatialComponentBase(inProps, ref) {
1973
+ const { [CSSSpatialID]: cssSpatialID, ...props } = inProps;
1974
+ const isWebEnv = true;
1975
+ if (isWebEnv) {
1976
+ return renderInWebEnv(props, ref);
1977
+ } else {
1978
+ const cssSpatialRootContextObject = (0, import_react19.useContext)(CSSSpatialRootContext);
1979
+ if (cssSpatialRootContextObject) {
1980
+ const isInStandardInstance = !!(0, import_react19.useContext)(
1981
+ SpatialIsStandardInstanceContext
1982
+ );
1983
+ if (isInStandardInstance) {
1984
+ return renderInStandardInstance(
1985
+ cssSpatialRootContextObject,
1986
+ cssSpatialID,
1987
+ props,
1988
+ ref
1989
+ );
1990
+ } else {
1991
+ return renderInPortalInstance(
1992
+ cssSpatialRootContextObject,
1993
+ cssSpatialID,
1994
+ props
1995
+ );
1996
+ }
1997
+ } else {
1998
+ return renderRootCSSSpatialComponent(props, ref);
1999
+ }
2000
+ }
2001
+ }
2002
+ __name(CSSSpatialComponentBase, "CSSSpatialComponentBase");
2003
+ var CSSSpatialComponentBaseWithRef = (0, import_react19.forwardRef)(CSSSpatialComponentBase);
2004
+ function CSSSpatialComponentWithRef(inProps, ref) {
2005
+ const layer = (0, import_react19.useContext)(CSSSpatialLayerContext) + 1;
2006
+ const cssSpatialRootContextObject = (0, import_react19.useContext)(CSSSpatialRootContext);
2007
+ const isRootInstance = !cssSpatialRootContextObject;
2008
+ const isInStandardInstance = !!(0, import_react19.useContext)(SpatialIsStandardInstanceContext);
2009
+ const cssSpatialID = (0, import_react19.useMemo)(() => {
2010
+ return isRootInstance ? layer.toString() : cssSpatialRootContextObject.getSpatialID(
2011
+ layer,
2012
+ isInStandardInstance,
2013
+ inProps.debugName
2014
+ );
2015
+ }, []);
2016
+ const props = { ...inProps, [CSSSpatialID]: cssSpatialID };
2017
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CSSSpatialDebugNameContext.Provider, { value: inProps.debugName || "", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CSSSpatialLayerContext.Provider, { value: layer, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CSSSpatialComponentBaseWithRef, { ...props, ref }) }) });
2018
+ }
2019
+ __name(CSSSpatialComponentWithRef, "CSSSpatialComponentWithRef");
2020
+ var CSSSpatialComponent = (0, import_react19.forwardRef)(CSSSpatialComponentWithRef);
2021
+
2022
+ // src/spatial-react-components/CSSSpatialDiv/CSSSpatialDiv.tsx
2023
+ var import_jsx_runtime7 = require("react/jsx-runtime");
2024
+ var cachedWithCSSSpatialType = /* @__PURE__ */ new Map();
2025
+ function withCSSSpatial(Component) {
2026
+ if (cachedWithCSSSpatialType.has(Component)) {
2027
+ return cachedWithCSSSpatialType.get(Component);
2028
+ } else {
2029
+ const WithCSSSpatialComponent = (0, import_react20.forwardRef)(
2030
+ (givenProps, givenRef) => {
2031
+ const {
2032
+ component: ignoreComponent,
2033
+ className: origClassName = "",
2034
+ ...props
2035
+ } = givenProps;
2036
+ const className = "xr-spatial-default " + origClassName;
2037
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2038
+ CSSSpatialComponent,
2039
+ {
2040
+ component: Component,
2041
+ className,
2042
+ ...props,
2043
+ ref: givenRef
2044
+ }
2045
+ );
2046
+ }
2047
+ );
2048
+ WithCSSSpatialComponent.displayName = `WithCSSSpatial(${typeof Component === "string" ? Component : Component.displayName || Component.name})`;
2049
+ cachedWithCSSSpatialType.set(Component, WithCSSSpatialComponent);
2050
+ cachedWithCSSSpatialType.set(
2051
+ WithCSSSpatialComponent,
2052
+ WithCSSSpatialComponent
2053
+ );
2054
+ return WithCSSSpatialComponent;
2055
+ }
2056
+ }
2057
+ __name(withCSSSpatial, "withCSSSpatial");
2058
+ var CSSSpatialPrimitive = {};
2059
+ (/* @__PURE__ */ __name(function createSpatialPrimitive2(CSSSpatialPrimitive2) {
2060
+ primitives.forEach((primitive) => {
2061
+ CSSSpatialPrimitive2[primitive] = withCSSSpatial(primitive);
2062
+ });
2063
+ }, "createSpatialPrimitive"))(CSSSpatialPrimitive);
2064
+ var CSSSpatialDiv = CSSSpatialPrimitive.div;
2065
+
2066
+ // src/spatial-react-components/Model3D/Model3D.tsx
2067
+ var import_react26 = require("react");
2068
+
2069
+ // src/spatial-react-components/Model3D/useDetectLayoutDomUpdated.ts
2070
+ var import_react21 = require("react");
2071
+ function useDetectLayoutDomUpdated(onDomUpdated) {
2072
+ const ref = (0, import_react21.useRef)(null);
2073
+ (0, import_react21.useEffect)(() => {
2074
+ if (!ref.current) {
2075
+ console.warn("Ref is not attached to the DOM");
2076
+ return;
2077
+ }
2078
+ let ro = new ResizeObserver((elements) => {
2079
+ onDomUpdated();
2080
+ });
2081
+ ro.observe(ref.current);
2082
+ return () => {
2083
+ ro.disconnect();
2084
+ };
2085
+ }, []);
2086
+ (0, import_react21.useEffect)(() => {
2087
+ if (!ref.current) {
2088
+ console.warn("Ref is not attached to the DOM");
2089
+ return;
2090
+ }
2091
+ let ro = new MutationObserver((elements) => {
2092
+ onDomUpdated();
2093
+ });
2094
+ ro.observe(ref.current, {
2095
+ attributeFilter: ["class", "style"],
2096
+ subtree: true,
2097
+ attributeOldValue: false
2098
+ });
2099
+ return () => {
2100
+ ro.disconnect();
2101
+ };
2102
+ }, []);
2103
+ return ref;
2104
+ }
2105
+ __name(useDetectLayoutDomUpdated, "useDetectLayoutDomUpdated");
2106
+
2107
+ // src/spatial-react-components/Model3D/useModel3DNative.ts
2108
+ var import_react22 = require("react");
2109
+
2110
+ // src/spatial-react-components/Model3D/utils.ts
2111
+ function PopulatePartialSpatialTransformType(spatialTransform = {}) {
2112
+ const {
2113
+ position = { x: 0, y: 0, z: 0 },
2114
+ rotation = { x: 0, y: 0, z: 0, w: 1 },
2115
+ scale = { x: 1, y: 1, z: 1 }
2116
+ } = spatialTransform;
2117
+ const { x: tx = 0, y: ty = 0, z: tz = 0 } = position;
2118
+ const { x: rx = 0, y: ry = 0, z: rz = 0, w = 1 } = rotation;
2119
+ const { x: sx = 1, y: sy = 1, z: sz = 1 } = scale;
2120
+ return {
2121
+ position: { x: tx, y: ty, z: tz },
2122
+ rotation: { x: rx, y: ry, z: rz, w },
2123
+ scale: { x: sx, y: sy, z: sz }
2124
+ };
2125
+ }
2126
+ __name(PopulatePartialSpatialTransformType, "PopulatePartialSpatialTransformType");
2127
+ function getAbsoluteURL(url) {
2128
+ if (!url) {
2129
+ return "";
2130
+ }
2131
+ if (url.startsWith("http")) {
2132
+ return url;
2133
+ }
2134
+ return `${location.origin}${url}`;
2135
+ }
2136
+ __name(getAbsoluteURL, "getAbsoluteURL");
2137
+
2138
+ // src/spatial-react-components/Model3D/Model3DNative.ts
2139
+ var Model3DNative = class {
2140
+ static {
2141
+ __name(this, "Model3DNative");
2142
+ }
2143
+ constructor(parentEntity) {
2144
+ this.parentEntity = parentEntity;
2145
+ }
2146
+ parentEntity;
2147
+ initPromise;
2148
+ entity;
2149
+ spatialModel3DComponent;
2150
+ // private modelUrl: string
2151
+ isDestroyed = false;
2152
+ _onDragStart;
2153
+ _onDrag;
2154
+ _onDragEnd;
2155
+ _onTap;
2156
+ _onDoubleTap;
2157
+ _onLongPress;
2158
+ async init(modelUrl, onSuccess, onFailure) {
2159
+ if (this.isDestroyed) {
2160
+ return;
2161
+ }
2162
+ this.initPromise = this.initInternal(modelUrl, onSuccess, onFailure);
2163
+ return this.initPromise;
2164
+ }
2165
+ async initInternal(modelUrl, onSuccess, onFailure) {
2166
+ if (true) return;
2167
+ var session = getSession();
2168
+ if (!session) {
2169
+ return;
2170
+ }
2171
+ const entity = await session.createEntity();
2172
+ await entity.setCoordinateSpace("Dom");
2173
+ const spatialModel3DComponent = await session.createModel3DComponent({
2174
+ url: getAbsoluteURL(modelUrl)
2175
+ });
2176
+ await entity.setComponent(spatialModel3DComponent);
2177
+ if (this.isDestroyed) {
2178
+ return;
2179
+ }
2180
+ if (this.parentEntity) {
2181
+ await entity.setParent(this.parentEntity);
2182
+ } else {
2183
+ var wc = session.getCurrentWindowComponent();
2184
+ var ent = await wc.getEntity();
2185
+ await entity.setParent(ent);
2186
+ }
2187
+ this.entity = entity;
2188
+ this.spatialModel3DComponent = spatialModel3DComponent;
2189
+ this.spatialModel3DComponent.onSuccess = onSuccess;
2190
+ this.spatialModel3DComponent.onFailure = onFailure;
2191
+ this.spatialModel3DComponent.onDragStart = this._onDragStart;
2192
+ this.spatialModel3DComponent.onDrag = this._onDrag;
2193
+ this.spatialModel3DComponent.onDragEnd = this._onDragEnd;
2194
+ this.spatialModel3DComponent.onTap = this._onTap;
2195
+ this.spatialModel3DComponent.onDoubleTap = this._onDoubleTap;
2196
+ this.spatialModel3DComponent.onLongPress = this._onLongPress;
2197
+ }
2198
+ async setVisible(visible) {
2199
+ if (this.entity) {
2200
+ await this.entity.setVisible(visible);
2201
+ }
2202
+ }
2203
+ async setContentMode(contentMode) {
2204
+ if (this.spatialModel3DComponent) {
2205
+ await this.spatialModel3DComponent.setContentMode(contentMode);
2206
+ }
2207
+ }
2208
+ async setResizable(resizable) {
2209
+ if (this.spatialModel3DComponent) {
2210
+ await this.spatialModel3DComponent.setResizable(resizable);
2211
+ }
2212
+ }
2213
+ async setAspectRatio(aspectRatio) {
2214
+ if (this.spatialModel3DComponent) {
2215
+ await this.spatialModel3DComponent.setAspectRatio(aspectRatio);
2216
+ }
2217
+ }
2218
+ async updateByDom(dom, options) {
2219
+ if (!this.entity || !this.spatialModel3DComponent) {
2220
+ return;
2221
+ }
2222
+ const rect = dom.getBoundingClientRect();
2223
+ const targetPosX = rect.left + (rect.right - rect.left) / 2;
2224
+ const targetPosY = rect.bottom + (rect.top - rect.bottom) / 2 + window.scrollY;
2225
+ const { spatialTransform } = options;
2226
+ const { position, rotation, scale } = spatialTransform;
2227
+ const entity = this.entity;
2228
+ entity.transform.position.x = targetPosX + position.x;
2229
+ entity.transform.position.y = targetPosY + position.y;
2230
+ entity.transform.position.z = position.z;
2231
+ entity.transform.orientation.x = rotation.x;
2232
+ entity.transform.orientation.y = rotation.y;
2233
+ entity.transform.orientation.z = rotation.z;
2234
+ entity.transform.orientation.w = rotation.w;
2235
+ entity.transform.scale.x = scale.x;
2236
+ entity.transform.scale.y = scale.y;
2237
+ entity.transform.scale.z = scale.z;
2238
+ await entity.updateTransform();
2239
+ const spatialModel3DComponent = this.spatialModel3DComponent;
2240
+ await spatialModel3DComponent.setResolution(rect.width, rect.height);
2241
+ const computedStyle = getComputedStyle(dom);
2242
+ const opacity = parseFloat(computedStyle.getPropertyValue("opacity"));
2243
+ await spatialModel3DComponent.setOpacity(opacity);
2244
+ const anchor = parseTransformOrigin(computedStyle);
2245
+ await spatialModel3DComponent.setRotationAnchor(anchor);
2246
+ }
2247
+ async updateRectAndTransform(rect, spatialTransform) {
2248
+ if (!this.entity || !this.spatialModel3DComponent) {
2249
+ return;
2250
+ }
2251
+ const targetPosX = rect.x + (rect.width - rect.x) / 2;
2252
+ const targetPosY = rect.y + (rect.height - rect.y) / 2 + window.scrollY;
2253
+ const { position, rotation, scale } = spatialTransform;
2254
+ const entity = this.entity;
2255
+ entity.transform.position.x = targetPosX + position.x;
2256
+ entity.transform.position.y = targetPosY + position.y;
2257
+ entity.transform.position.z = position.z;
2258
+ entity.transform.orientation.x = rotation.x;
2259
+ entity.transform.orientation.y = rotation.y;
2260
+ entity.transform.orientation.z = rotation.z;
2261
+ entity.transform.orientation.w = rotation.w;
2262
+ entity.transform.scale.x = scale.x;
2263
+ entity.transform.scale.y = scale.y;
2264
+ entity.transform.scale.z = scale.z;
2265
+ await entity.updateTransform();
2266
+ const spatialModel3DComponent = this.spatialModel3DComponent;
2267
+ await spatialModel3DComponent.setResolution(rect.width, rect.height);
2268
+ }
2269
+ async setRotationAnchor(anchor) {
2270
+ if (this.spatialModel3DComponent) {
2271
+ await this.spatialModel3DComponent.setRotationAnchor(anchor);
2272
+ }
2273
+ }
2274
+ async setOpacity(opacity) {
2275
+ if (this.spatialModel3DComponent) {
2276
+ this.spatialModel3DComponent.setOpacity(opacity);
2277
+ }
2278
+ }
2279
+ set onDragStart(callback) {
2280
+ if (this.spatialModel3DComponent) {
2281
+ this.spatialModel3DComponent.onDragStart = callback;
2282
+ }
2283
+ this._onDragStart = callback;
2284
+ }
2285
+ set onDrag(callback) {
2286
+ if (this.spatialModel3DComponent) {
2287
+ this.spatialModel3DComponent.onDrag = callback;
2288
+ }
2289
+ this._onDrag = callback;
2290
+ }
2291
+ set onDragEnd(callback) {
2292
+ if (this.spatialModel3DComponent) {
2293
+ this.spatialModel3DComponent.onDragEnd = callback;
2294
+ }
2295
+ this._onDragEnd = callback;
2296
+ }
2297
+ set onTap(callback) {
2298
+ if (this.spatialModel3DComponent) {
2299
+ this.spatialModel3DComponent.onTap = callback;
2300
+ }
2301
+ this._onTap = callback;
2302
+ }
2303
+ set onDoubleTap(callback) {
2304
+ if (this.spatialModel3DComponent) {
2305
+ this.spatialModel3DComponent.onDoubleTap = callback;
2306
+ }
2307
+ this._onDoubleTap = callback;
2308
+ }
2309
+ set onLongPress(callback) {
2310
+ if (this.spatialModel3DComponent) {
2311
+ this.spatialModel3DComponent.onLongPress = callback;
2312
+ }
2313
+ this._onLongPress = callback;
2314
+ }
2315
+ /**
2316
+ * Destroys the current 3D model instance
2317
+ * 1. Marks the instance as destroyed
2318
+ * 2. Waits for initialization to complete (if in progress)
2319
+ * 3. Destroys the spatial entity
2320
+ * 4. Cleans up all related references
2321
+ */
2322
+ async destroy() {
2323
+ this.isDestroyed = true;
2324
+ if (this.initPromise) {
2325
+ await this.initPromise;
2326
+ }
2327
+ this.entity?.destroy();
2328
+ this.entity = void 0;
2329
+ this.spatialModel3DComponent = void 0;
2330
+ this.initPromise = void 0;
2331
+ }
2332
+ };
2333
+
2334
+ // src/spatial-react-components/Model3D/useModel3DNative.ts
2335
+ function useModel3DNative(modelUrl, parentEntity, eventHandlers = {}, onModel3DNativeReadyCb) {
2336
+ let model3DNativeRef = (0, import_react22.useRef)(null);
2337
+ const [phase, setPhase] = (0, import_react22.useState)(
2338
+ "loading"
2339
+ );
2340
+ const [failureReason, setFailureReason] = (0, import_react22.useState)("");
2341
+ (0, import_react22.useEffect)(() => {
2342
+ let isDestroyed = false;
2343
+ const model3DContainer = new Model3DNative(parentEntity);
2344
+ model3DContainer.init(
2345
+ modelUrl,
2346
+ () => {
2347
+ setPhase("success");
2348
+ },
2349
+ (error) => {
2350
+ setPhase("failure");
2351
+ setFailureReason(error);
2352
+ }
2353
+ ).then(() => {
2354
+ if (!isDestroyed) {
2355
+ model3DNativeRef.current = model3DContainer;
2356
+ if (onModel3DNativeReadyCb) {
2357
+ onModel3DNativeReadyCb(model3DContainer);
2358
+ }
2359
+ }
2360
+ });
2361
+ return () => {
2362
+ isDestroyed = true;
2363
+ model3DContainer.destroy();
2364
+ model3DNativeRef.current = null;
2365
+ setPhase("loading");
2366
+ };
2367
+ }, [modelUrl]);
2368
+ (0, import_react22.useEffect)(() => {
2369
+ if (model3DNativeRef.current) {
2370
+ model3DNativeRef.current.onDragStart = eventHandlers.onDragStart;
2371
+ }
2372
+ }, [model3DNativeRef.current, eventHandlers.onDragStart]);
2373
+ (0, import_react22.useEffect)(() => {
2374
+ if (model3DNativeRef.current) {
2375
+ model3DNativeRef.current.onDrag = eventHandlers.onDrag;
2376
+ }
2377
+ }, [model3DNativeRef.current, eventHandlers.onDrag]);
2378
+ (0, import_react22.useEffect)(() => {
2379
+ if (model3DNativeRef.current) {
2380
+ model3DNativeRef.current.onDragEnd = eventHandlers.onDragEnd;
2381
+ }
2382
+ });
2383
+ (0, import_react22.useEffect)(() => {
2384
+ if (model3DNativeRef.current) {
2385
+ model3DNativeRef.current.onTap = eventHandlers.onTap;
2386
+ }
2387
+ }, [model3DNativeRef.current, eventHandlers.onTap]);
2388
+ (0, import_react22.useEffect)(() => {
2389
+ if (model3DNativeRef.current) {
2390
+ model3DNativeRef.current.onDoubleTap = eventHandlers.onDoubleTap;
2391
+ }
2392
+ }, [model3DNativeRef.current, eventHandlers.onDoubleTap]);
2393
+ (0, import_react22.useEffect)(() => {
2394
+ if (model3DNativeRef.current) {
2395
+ model3DNativeRef.current.onLongPress = eventHandlers.onLongPress;
2396
+ }
2397
+ }, [model3DNativeRef.current, eventHandlers.onLongPress]);
2398
+ return { model3DNativeRef, phase, failureReason };
2399
+ }
2400
+ __name(useModel3DNative, "useModel3DNative");
2401
+
2402
+ // src/spatial-react-components/Model3D/Model3DNotInSpatialDiv.tsx
2403
+ var import_react23 = require("react");
2404
+ var import_jsx_runtime8 = require("react/jsx-runtime");
2405
+ function renderModel3DNotInSpatialDiv(props, refIn) {
2406
+ const {
2407
+ className,
2408
+ style = {},
2409
+ modelUrl,
2410
+ visible,
2411
+ spatialTransform,
2412
+ contentMode = "fit",
2413
+ resizable = true,
2414
+ aspectRatio = 0,
2415
+ onLoad,
2416
+ children,
2417
+ onDragStart,
2418
+ onDrag,
2419
+ onDragEnd,
2420
+ onTap,
2421
+ onDoubleTap,
2422
+ onLongPress
2423
+ } = props;
2424
+ const theSpatialTransform = PopulatePartialSpatialTransformType(spatialTransform);
2425
+ const onDomUpdated = (0, import_react23.useCallback)(() => {
2426
+ if (model3DNativeRef.current && layoutInstanceRef.current) {
2427
+ const model3DNative = model3DNativeRef.current;
2428
+ model3DNative.updateByDom(layoutInstanceRef.current, {
2429
+ spatialTransform: theSpatialTransform
2430
+ });
2431
+ }
2432
+ }, [
2433
+ theSpatialTransform.position.x,
2434
+ theSpatialTransform.position.y,
2435
+ theSpatialTransform.position.z,
2436
+ theSpatialTransform.rotation.x,
2437
+ theSpatialTransform.rotation.y,
2438
+ theSpatialTransform.rotation.z,
2439
+ theSpatialTransform.rotation.w,
2440
+ theSpatialTransform.scale.x,
2441
+ theSpatialTransform.scale.y,
2442
+ theSpatialTransform.scale.z
2443
+ ]);
2444
+ const onModel3DContainerReadyCb = (0, import_react23.useCallback)(() => {
2445
+ if (model3DNativeRef.current && layoutInstanceRef.current) {
2446
+ model3DNativeRef.current.updateByDom(layoutInstanceRef.current, {
2447
+ spatialTransform: theSpatialTransform
2448
+ });
2449
+ }
2450
+ }, [
2451
+ theSpatialTransform.position.x,
2452
+ theSpatialTransform.position.y,
2453
+ theSpatialTransform.position.z,
2454
+ theSpatialTransform.rotation.x,
2455
+ theSpatialTransform.rotation.y,
2456
+ theSpatialTransform.rotation.z,
2457
+ theSpatialTransform.rotation.w,
2458
+ theSpatialTransform.scale.x,
2459
+ theSpatialTransform.scale.y,
2460
+ theSpatialTransform.scale.z
2461
+ ]);
2462
+ const onDragStartCb = (0, import_react23.useCallback)(
2463
+ (spatialDragEvent) => {
2464
+ if (onDragStart) {
2465
+ const dragEvent = {
2466
+ ...spatialDragEvent,
2467
+ target: layoutInstanceRef.current
2468
+ };
2469
+ onDragStart(dragEvent);
2470
+ }
2471
+ },
2472
+ [onDragStart]
2473
+ );
2474
+ const onDragCb = (0, import_react23.useCallback)(
2475
+ (spatialDragEvent) => {
2476
+ if (onDrag) {
2477
+ const dragEvent = {
2478
+ ...spatialDragEvent,
2479
+ target: layoutInstanceRef.current
2480
+ };
2481
+ onDrag(dragEvent);
2482
+ }
2483
+ },
2484
+ [onDrag]
2485
+ );
2486
+ const onDragEndCb = (0, import_react23.useCallback)(
2487
+ (spatialDragEvent) => {
2488
+ if (onDragEnd) {
2489
+ const dragEvent = {
2490
+ ...spatialDragEvent,
2491
+ target: layoutInstanceRef.current
2492
+ };
2493
+ onDragEnd(dragEvent);
2494
+ }
2495
+ },
2496
+ [onDragEnd]
2497
+ );
2498
+ const onTapCb = (0, import_react23.useCallback)(() => {
2499
+ if (onTap) {
2500
+ const event = {
2501
+ target: layoutInstanceRef.current
2502
+ };
2503
+ onTap(event);
2504
+ }
2505
+ }, [onTap]);
2506
+ const onDoubleTapCb = (0, import_react23.useCallback)(() => {
2507
+ if (onDoubleTap) {
2508
+ const event = {
2509
+ target: layoutInstanceRef.current
2510
+ };
2511
+ onDoubleTap(event);
2512
+ }
2513
+ }, [onDoubleTap]);
2514
+ const onLongPressCb = (0, import_react23.useCallback)(() => {
2515
+ if (onLongPress) {
2516
+ const event = {
2517
+ target: layoutInstanceRef.current
2518
+ };
2519
+ onLongPress(event);
2520
+ }
2521
+ }, [onLongPress]);
2522
+ const layoutInstanceRef = useDetectLayoutDomUpdated(onDomUpdated);
2523
+ const { model3DNativeRef, phase, failureReason } = useModel3DNative(
2524
+ modelUrl,
2525
+ void 0,
2526
+ {
2527
+ onDragStart: onDragStart ? onDragStartCb : void 0,
2528
+ onDrag: onDrag ? onDragCb : void 0,
2529
+ onDragEnd: onDragEnd ? onDragEndCb : void 0,
2530
+ onTap: onTap ? onTapCb : void 0,
2531
+ onDoubleTap: onDoubleTap ? onDoubleTapCb : void 0,
2532
+ onLongPress: onLongPress ? onLongPressCb : void 0
2533
+ },
2534
+ onModel3DContainerReadyCb
2535
+ );
2536
+ const onSuccess = (0, import_react23.useCallback)(() => {
2537
+ ;
2538
+ layoutInstanceRef.current.ready = true;
2539
+ if (onLoad) {
2540
+ onLoad({
2541
+ target: layoutInstanceRef.current
2542
+ });
2543
+ }
2544
+ }, [onLoad]);
2545
+ const onFailure = (0, import_react23.useCallback)(
2546
+ (_) => {
2547
+ const modelElement = layoutInstanceRef.current;
2548
+ modelElement.ready = false;
2549
+ if (onLoad) {
2550
+ onLoad({
2551
+ target: layoutInstanceRef.current
2552
+ });
2553
+ }
2554
+ },
2555
+ [onLoad]
2556
+ );
2557
+ (0, import_react23.useEffect)(() => {
2558
+ if (phase === "failure") {
2559
+ onFailure(failureReason);
2560
+ } else if (phase === "success") {
2561
+ onSuccess();
2562
+ }
2563
+ }, [phase]);
2564
+ (0, import_react23.useEffect)(() => {
2565
+ if (model3DNativeRef.current) {
2566
+ model3DNativeRef.current.setVisible(visible);
2567
+ }
2568
+ }, [model3DNativeRef.current, visible]);
2569
+ (0, import_react23.useEffect)(() => {
2570
+ if (model3DNativeRef.current && layoutInstanceRef.current) {
2571
+ model3DNativeRef.current.updateByDom(layoutInstanceRef.current, {
2572
+ spatialTransform: theSpatialTransform
2573
+ });
2574
+ }
2575
+ }, [
2576
+ theSpatialTransform.position.x,
2577
+ theSpatialTransform.position.y,
2578
+ theSpatialTransform.position.z,
2579
+ theSpatialTransform.rotation.x,
2580
+ theSpatialTransform.rotation.y,
2581
+ theSpatialTransform.rotation.z,
2582
+ theSpatialTransform.rotation.w,
2583
+ theSpatialTransform.scale.x,
2584
+ theSpatialTransform.scale.y,
2585
+ theSpatialTransform.scale.z
2586
+ ]);
2587
+ (0, import_react23.useEffect)(() => {
2588
+ if (model3DNativeRef.current) {
2589
+ model3DNativeRef.current.setContentMode(contentMode);
2590
+ }
2591
+ }, [model3DNativeRef.current, contentMode]);
2592
+ (0, import_react23.useEffect)(() => {
2593
+ if (model3DNativeRef.current) {
2594
+ model3DNativeRef.current.setResizable(resizable);
2595
+ }
2596
+ }, [model3DNativeRef.current, resizable]);
2597
+ (0, import_react23.useEffect)(() => {
2598
+ if (model3DNativeRef.current) {
2599
+ model3DNativeRef.current.setAspectRatio(aspectRatio);
2600
+ }
2601
+ }, [model3DNativeRef.current, aspectRatio]);
2602
+ const layoutDomStyle = {
2603
+ ...style,
2604
+ visibility: phase === "failure" ? "visible" : "hidden",
2605
+ transform: ""
2606
+ };
2607
+ const proxyRef = (0, import_react23.useMemo)(
2608
+ () => new Proxy(layoutInstanceRef, {
2609
+ get(target, prop, receiver) {
2610
+ return Reflect.get(target, prop, receiver);
2611
+ },
2612
+ set(target, prop, value, receiver) {
2613
+ if (prop === "current") {
2614
+ const domElement = value;
2615
+ if (domElement) {
2616
+ domElement.ready = false;
2617
+ domElement.currentSrc = modelUrl;
2618
+ }
2619
+ if (refIn) {
2620
+ if (typeof refIn === "function") {
2621
+ refIn(domElement);
2622
+ } else {
2623
+ refIn.current = domElement;
2624
+ }
2625
+ }
2626
+ }
2627
+ return Reflect.set(target, prop, value, receiver);
2628
+ }
2629
+ }),
2630
+ [layoutInstanceRef, refIn]
2631
+ );
2632
+ (0, import_react23.useEffect)(() => {
2633
+ return () => {
2634
+ if (layoutInstanceRef.current) {
2635
+ const modelElement = layoutInstanceRef.current;
2636
+ modelElement.ready = false;
2637
+ modelElement.currentSrc = modelUrl;
2638
+ }
2639
+ };
2640
+ }, [modelUrl]);
2641
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className, style: layoutDomStyle, ref: proxyRef, children: phase === "failure" && children });
2642
+ }
2643
+ __name(renderModel3DNotInSpatialDiv, "renderModel3DNotInSpatialDiv");
2644
+
2645
+ // src/spatial-react-components/Model3D/Model3DStandardInstance.tsx
2646
+ var import_jsx_runtime9 = require("react/jsx-runtime");
2647
+ function renderModel3DStandardInstance(spatialId, props, refIn) {
2648
+ const { className, style } = props;
2649
+ const extraProps = {
2650
+ [SpatialID]: spatialId
2651
+ };
2652
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2653
+ "div",
2654
+ {
2655
+ "data-model3d-spatialid": spatialId,
2656
+ className,
2657
+ style,
2658
+ ref: refIn,
2659
+ ...extraProps
2660
+ }
2661
+ );
2662
+ }
2663
+ __name(renderModel3DStandardInstance, "renderModel3DStandardInstance");
2664
+
2665
+ // src/spatial-react-components/Model3D/Model3DPortalInstance.tsx
2666
+ var import_react25 = require("react");
2667
+
2668
+ // src/spatial-react-components/Model3D/useSyncDomInfoFromStandardInstance.ts
2669
+ var import_react24 = require("react");
2670
+ function useSyncDomInfoFromStandardInstance(spatialId) {
2671
+ const [domRect, setDomRect] = (0, import_react24.useState)({
2672
+ x: 0,
2673
+ y: 0,
2674
+ width: 0,
2675
+ height: 0
2676
+ });
2677
+ const inheritedPortalStyleRef = (0, import_react24.useRef)({});
2678
+ const anchorRef = (0, import_react24.useRef)({
2679
+ x: 0.5,
2680
+ y: 0.5,
2681
+ z: 0.5
2682
+ });
2683
+ const opacityRef = (0, import_react24.useRef)(1);
2684
+ const spatialReactContextObject = (0, import_react24.useContext)(SpatialReactContext);
2685
+ const inheritedPortalClassNameRef = (0, import_react24.useRef)("");
2686
+ const modelRef = (0, import_react24.useRef)(null);
2687
+ (0, import_react24.useEffect)(() => {
2688
+ const syncDomRect = /* @__PURE__ */ __name(() => {
2689
+ const dom = spatialReactContextObject?.querySpatialDom(spatialId);
2690
+ if (!dom) {
2691
+ return;
2692
+ }
2693
+ modelRef.current = dom;
2694
+ let domRect2 = dom.getBoundingClientRect();
2695
+ let rectType = domRect2rectType(domRect2);
2696
+ const parentDom = spatialReactContextObject?.queryParentSpatialDom(spatialId);
2697
+ if (parentDom) {
2698
+ const parentDomRect = parentDom.getBoundingClientRect();
2699
+ const parentRectType = domRect2rectType(parentDomRect);
2700
+ rectType.x -= parentRectType.x;
2701
+ rectType.y -= parentRectType.y;
2702
+ }
2703
+ const computedStyle = getComputedStyle(dom);
2704
+ inheritedPortalStyleRef.current = getInheritedStyleProps(computedStyle);
2705
+ const anchor = parseTransformOrigin(computedStyle);
2706
+ anchorRef.current = anchor;
2707
+ const opacity = parseFloat(computedStyle.getPropertyValue("opacity"));
2708
+ opacityRef.current = opacity;
2709
+ inheritedPortalClassNameRef.current = dom.className;
2710
+ setDomRect(rectType);
2711
+ }, "syncDomRect");
2712
+ spatialReactContextObject?.onDomChange(spatialId, syncDomRect);
2713
+ return () => {
2714
+ spatialReactContextObject?.offDomChange(spatialId);
2715
+ };
2716
+ }, []);
2717
+ return {
2718
+ modelRef,
2719
+ domRect,
2720
+ inheritedPortalStyle: inheritedPortalStyleRef.current,
2721
+ anchor: anchorRef.current,
2722
+ opacity: opacityRef.current,
2723
+ className: inheritedPortalClassNameRef.current
2724
+ };
2725
+ }
2726
+ __name(useSyncDomInfoFromStandardInstance, "useSyncDomInfoFromStandardInstance");
2727
+
2728
+ // src/spatial-react-components/Model3D/Model3DPortalInstance.tsx
2729
+ var import_jsx_runtime10 = require("react/jsx-runtime");
2730
+ function useModelEvents(props, modelRef) {
2731
+ const {
2732
+ onDragStart,
2733
+ onDrag,
2734
+ onDragEnd,
2735
+ onTap,
2736
+ onDoubleTap,
2737
+ onLongPress
2738
+ } = props;
2739
+ const onDragStartCb = (0, import_react25.useCallback)(
2740
+ (spatialDragEvent) => {
2741
+ if (onDragStart) {
2742
+ const dragEvent = {
2743
+ ...spatialDragEvent,
2744
+ target: modelRef.current
2745
+ };
2746
+ onDragStart(dragEvent);
2747
+ }
2748
+ },
2749
+ [onDragStart]
2750
+ );
2751
+ const onDragCb = (0, import_react25.useCallback)(
2752
+ (spatialDragEvent) => {
2753
+ if (onDrag) {
2754
+ const dragEvent = {
2755
+ ...spatialDragEvent,
2756
+ target: modelRef.current
2757
+ };
2758
+ onDrag(dragEvent);
2759
+ }
2760
+ },
2761
+ [onDrag]
2762
+ );
2763
+ const onDragEndCb = (0, import_react25.useCallback)(
2764
+ (spatialDragEvent) => {
2765
+ if (onDragEnd) {
2766
+ const dragEvent = {
2767
+ ...spatialDragEvent,
2768
+ target: modelRef.current
2769
+ };
2770
+ onDragEnd(dragEvent);
2771
+ }
2772
+ },
2773
+ [onDragEnd]
2774
+ );
2775
+ const onTapCb = (0, import_react25.useCallback)(() => {
2776
+ if (onTap) {
2777
+ const event = {
2778
+ target: modelRef.current
2779
+ };
2780
+ onTap(event);
2781
+ }
2782
+ }, [onTap]);
2783
+ const onDoubleTapCb = (0, import_react25.useCallback)(() => {
2784
+ if (onDoubleTap) {
2785
+ const event = {
2786
+ target: modelRef.current
2787
+ };
2788
+ onDoubleTap(event);
2789
+ }
2790
+ }, [onDoubleTap]);
2791
+ const onLongPressCb = (0, import_react25.useCallback)(() => {
2792
+ if (onLongPress) {
2793
+ const event = {
2794
+ target: modelRef.current
2795
+ };
2796
+ onLongPress(event);
2797
+ }
2798
+ }, [onLongPress]);
2799
+ return {
2800
+ onDragStart: onDragStartCb,
2801
+ onDrag: onDragCb,
2802
+ onDragEnd: onDragEndCb,
2803
+ onTap: onTapCb,
2804
+ onDoubleTap: onDoubleTapCb,
2805
+ onLongPress: onLongPressCb
2806
+ };
2807
+ }
2808
+ __name(useModelEvents, "useModelEvents");
2809
+ function renderModel3DPortalInstance(spatialId, props) {
2810
+ const {
2811
+ style: _,
2812
+ modelUrl,
2813
+ visible,
2814
+ spatialTransform,
2815
+ contentMode = "fit",
2816
+ resizable = true,
2817
+ aspectRatio = 0,
2818
+ onLoad,
2819
+ children
2820
+ } = props;
2821
+ const theSpatialTransform = (0, import_react25.useMemo)(() => {
2822
+ return PopulatePartialSpatialTransformType(spatialTransform);
2823
+ }, [spatialTransform]);
2824
+ const {
2825
+ modelRef,
2826
+ domRect,
2827
+ inheritedPortalStyle,
2828
+ anchor,
2829
+ opacity,
2830
+ className
2831
+ } = useSyncDomInfoFromStandardInstance(spatialId);
2832
+ const parentSpatialWindowManager = (0, import_react25.useContext)(SpatialWindowManagerContext);
2833
+ const eventHandlers = useModelEvents(
2834
+ props,
2835
+ modelRef
2836
+ );
2837
+ const { model3DNativeRef, phase, failureReason } = useModel3DNative(
2838
+ modelUrl,
2839
+ parentSpatialWindowManager.entity,
2840
+ eventHandlers
2841
+ );
2842
+ (0, import_react25.useEffect)(() => {
2843
+ if (model3DNativeRef.current) {
2844
+ model3DNativeRef.current.updateRectAndTransform(
2845
+ domRect,
2846
+ theSpatialTransform
2847
+ );
2848
+ }
2849
+ }, [model3DNativeRef.current, domRect, theSpatialTransform]);
2850
+ (0, import_react25.useEffect)(() => {
2851
+ if (model3DNativeRef.current) {
2852
+ model3DNativeRef.current.setRotationAnchor(anchor);
2853
+ }
2854
+ }, [model3DNativeRef.current, anchor]);
2855
+ (0, import_react25.useEffect)(() => {
2856
+ if (model3DNativeRef.current) {
2857
+ model3DNativeRef.current.setVisible(visible);
2858
+ }
2859
+ }, [model3DNativeRef.current, visible]);
2860
+ (0, import_react25.useEffect)(() => {
2861
+ if (model3DNativeRef.current) {
2862
+ model3DNativeRef.current.setContentMode(contentMode);
2863
+ }
2864
+ }, [model3DNativeRef.current, contentMode]);
2865
+ (0, import_react25.useEffect)(() => {
2866
+ if (model3DNativeRef.current) {
2867
+ model3DNativeRef.current.setResizable(resizable);
2868
+ }
2869
+ }, [model3DNativeRef.current, resizable]);
2870
+ (0, import_react25.useEffect)(() => {
2871
+ if (model3DNativeRef.current) {
2872
+ model3DNativeRef.current.setAspectRatio(aspectRatio);
2873
+ }
2874
+ }, [model3DNativeRef.current, aspectRatio]);
2875
+ (0, import_react25.useEffect)(() => {
2876
+ if (model3DNativeRef.current) {
2877
+ model3DNativeRef.current.setOpacity(opacity);
2878
+ }
2879
+ }, [model3DNativeRef.current, opacity]);
2880
+ const onSuccess = (0, import_react25.useCallback)(() => {
2881
+ ;
2882
+ modelRef.current.ready = true;
2883
+ if (onLoad) {
2884
+ onLoad({
2885
+ target: modelRef.current
2886
+ });
2887
+ }
2888
+ }, [onLoad]);
2889
+ const onFailure = (0, import_react25.useCallback)(
2890
+ (_2) => {
2891
+ const modelElement = modelRef.current;
2892
+ modelElement.ready = false;
2893
+ if (onLoad) {
2894
+ onLoad({
2895
+ target: modelRef.current
2896
+ });
2897
+ }
2898
+ },
2899
+ [onLoad]
2900
+ );
2901
+ (0, import_react25.useEffect)(() => {
2902
+ if (phase === "failure") {
2903
+ onFailure(failureReason);
2904
+ } else if (phase === "success") {
2905
+ onSuccess();
2906
+ }
2907
+ }, [phase]);
2908
+ (0, import_react25.useEffect)(() => {
2909
+ return () => {
2910
+ const modelElement = modelRef.current;
2911
+ if (modelElement) {
2912
+ modelElement.ready = false;
2913
+ modelElement.currentSrc = modelUrl;
2914
+ }
2915
+ };
2916
+ }, [modelUrl]);
2917
+ const needRenderPlaceHolder = inheritedPortalStyle.position !== "absolute";
2918
+ if (!needRenderPlaceHolder && phase !== "failure") {
2919
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, {});
2920
+ } else {
2921
+ const extraStyle = {
2922
+ visibility: "visible",
2923
+ top: "0px",
2924
+ left: "0px",
2925
+ margin: "0px",
2926
+ marginLeft: "0px",
2927
+ marginRight: "0px",
2928
+ marginTop: "0px",
2929
+ marginBottom: "0px",
2930
+ borderRadius: "0px",
2931
+ overflow: "",
2932
+ width: `${domRect.width}px`,
2933
+ height: `${domRect.height}px`
2934
+ };
2935
+ const style = {
2936
+ ...inheritedPortalStyle,
2937
+ ...extraStyle
2938
+ };
2939
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2940
+ "div",
2941
+ {
2942
+ "data-model3d-spatialid": spatialId,
2943
+ className,
2944
+ style,
2945
+ children: phase === "failure" && children
2946
+ }
2947
+ );
2948
+ }
2949
+ }
2950
+ __name(renderModel3DPortalInstance, "renderModel3DPortalInstance");
2951
+
2952
+ // src/spatial-react-components/Model3D/Model3D.tsx
2953
+ function Model3DBase(props, refIn) {
2954
+ const parentSpatialReactContextObject = (0, import_react26.useContext)(SpatialReactContext);
2955
+ const isInSpatialDiv = !!parentSpatialReactContextObject;
2956
+ if (isInSpatialDiv) {
2957
+ const layer = (0, import_react26.useContext)(SpatialLayerContext) + 1;
2958
+ const isInStandardInstance = !!(0, import_react26.useContext)(SpatialIsStandardInstanceContext);
2959
+ const spatialId = (0, import_react26.useMemo)(() => {
2960
+ return parentSpatialReactContextObject.getSpatialID(
2961
+ layer,
2962
+ isInStandardInstance,
2963
+ "Model3D"
2964
+ );
2965
+ }, []);
2966
+ if (isInStandardInstance) {
2967
+ return renderModel3DStandardInstance(spatialId, props, refIn);
2968
+ } else {
2969
+ return renderModel3DPortalInstance(spatialId, props);
2970
+ }
2971
+ } else {
2972
+ return renderModel3DNotInSpatialDiv(props, refIn);
2973
+ }
2974
+ }
2975
+ __name(Model3DBase, "Model3DBase");
2976
+ var Model3D = (0, import_react26.forwardRef)(Model3DBase);
2977
+ Model3D.displayName = "Model3D";
2978
+
2979
+ // src/spatial-react-components/Model3D/CSSModel3D.tsx
2980
+ var import_react29 = require("react");
2981
+
2982
+ // src/spatial-react-components/Model3D/CSSModel3DNotInSpatialDiv.tsx
2983
+ var import_jsx_runtime11 = require("react/jsx-runtime");
2984
+ function renderCSSModel3DNotInSpatialDiv(inProps, refIn) {
2985
+ const { className, style = {}, ...props } = inProps;
2986
+ const cssParserDomStyle = {
2987
+ ...style,
2988
+ width: 0,
2989
+ height: 0
2990
+ };
2991
+ const { ref: cssParserDomRef, spatialStyle, ready } = useSpatialStyle();
2992
+ const ref = useHijackSpatialDivRef(
2993
+ refIn,
2994
+ cssParserDomRef
2995
+ );
2996
+ const spatialTransform = {
2997
+ position: spatialStyle.position,
2998
+ rotation: spatialStyle.rotation,
2999
+ scale: spatialStyle.scale
3000
+ };
3001
+ const visible = spatialStyle.visible;
3002
+ const model3DStyle = {
3003
+ ...style,
3004
+ transform: "none"
3005
+ };
3006
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
3007
+ ready && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3008
+ Model3D,
3009
+ {
3010
+ className,
3011
+ style: model3DStyle,
3012
+ ref,
3013
+ spatialTransform,
3014
+ visible,
3015
+ ...props
3016
+ }
3017
+ ),
3018
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3019
+ "div",
3020
+ {
3021
+ className,
3022
+ style: cssParserDomStyle,
3023
+ ref: cssParserDomRef
3024
+ }
3025
+ )
3026
+ ] });
3027
+ }
3028
+ __name(renderCSSModel3DNotInSpatialDiv, "renderCSSModel3DNotInSpatialDiv");
3029
+
3030
+ // src/spatial-react-components/Model3D/CSSModel3DStandardInstance.tsx
3031
+ var import_react27 = require("react");
3032
+ var import_jsx_runtime12 = require("react/jsx-runtime");
3033
+ function renderCSSModel3DStandardInstance(spatialId, inProps, refIn) {
3034
+ const { style: inStyle = {}, ...props } = inProps;
3035
+ const style = {
3036
+ ...inStyle,
3037
+ transform: "none",
3038
+ visibility: "hidden"
3039
+ };
3040
+ var cssParserRef = (0, import_react27.useRef)(null);
3041
+ const ref = useHijackSpatialDivRef(
3042
+ refIn,
3043
+ cssParserRef
3044
+ );
3045
+ const rootSpatialReactContextObject = (0, import_react27.useContext)(SpatialReactContext);
3046
+ (0, import_react27.useEffect)(() => {
3047
+ const onSubEvent = /* @__PURE__ */ __name((dom) => {
3048
+ cssParserRef.current = dom;
3049
+ }, "onSubEvent");
3050
+ rootSpatialReactContextObject.onSubDivEvent(spatialId, onSubEvent);
3051
+ return () => {
3052
+ rootSpatialReactContextObject.offSubDivEvent(spatialId);
3053
+ };
3054
+ }, []);
3055
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Model3D, { style, ...props, ref, visible: true });
3056
+ }
3057
+ __name(renderCSSModel3DStandardInstance, "renderCSSModel3DStandardInstance");
3058
+
3059
+ // src/spatial-react-components/Model3D/CSSModel3DPortalInstance.tsx
3060
+ var import_react28 = require("react");
3061
+ var import_jsx_runtime13 = require("react/jsx-runtime");
3062
+ function renderCSSModel3DPortalInstance(spatialId, inProps) {
3063
+ const { className, style = {}, ...props } = inProps;
3064
+ const rootSpatialReactContextObject = (0, import_react28.useContext)(SpatialReactContext);
3065
+ const { ref, spatialStyle, ready } = useSpatialStyle();
3066
+ const spatialTransform = {
3067
+ position: spatialStyle.position,
3068
+ rotation: spatialStyle.rotation,
3069
+ scale: spatialStyle.scale
3070
+ };
3071
+ const visible = spatialStyle.visible;
3072
+ (0, import_react28.useEffect)(() => {
3073
+ rootSpatialReactContextObject.notifySubDivEvent(spatialId, ref.current);
3074
+ }, [ref.current]);
3075
+ const cssParserDomStyle = {
3076
+ ...style,
3077
+ width: 0,
3078
+ height: 0
3079
+ };
3080
+ const model3DStyle = {
3081
+ ...style,
3082
+ transform: "none"
3083
+ };
3084
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
3085
+ ready && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
3086
+ Model3D,
3087
+ {
3088
+ className,
3089
+ style: model3DStyle,
3090
+ spatialTransform,
3091
+ visible,
3092
+ ...props
3093
+ }
3094
+ ),
3095
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className, style: cssParserDomStyle, ref })
3096
+ ] });
3097
+ }
3098
+ __name(renderCSSModel3DPortalInstance, "renderCSSModel3DPortalInstance");
3099
+
3100
+ // src/spatial-react-components/Model3D/CSSModel3D.tsx
3101
+ function CSSModel3DBase(props, refIn) {
3102
+ const rootSpatialReactContextObject = (0, import_react29.useContext)(SpatialReactContext);
3103
+ const isInSpatialDiv = !!rootSpatialReactContextObject;
3104
+ if (isInSpatialDiv) {
3105
+ const layer = (0, import_react29.useContext)(SpatialLayerContext) + 1;
3106
+ const isInStandardInstance = !!(0, import_react29.useContext)(SpatialIsStandardInstanceContext);
3107
+ const spatialId = (0, import_react29.useMemo)(() => {
3108
+ return rootSpatialReactContextObject.getSubDivSpatialID(
3109
+ layer,
3110
+ isInStandardInstance,
3111
+ "CSSModel3D"
3112
+ );
3113
+ }, []);
3114
+ if (isInStandardInstance) {
3115
+ return renderCSSModel3DStandardInstance(spatialId, props, refIn);
3116
+ } else {
3117
+ return renderCSSModel3DPortalInstance(spatialId, props);
3118
+ }
3119
+ } else {
3120
+ return renderCSSModel3DNotInSpatialDiv(props, refIn);
3121
+ }
3122
+ }
3123
+ __name(CSSModel3DBase, "CSSModel3DBase");
3124
+ var CSSModel3D = (0, import_react29.forwardRef)(CSSModel3DBase);
3125
+ CSSModel3D.displayName = "CSSModel3D";
3126
+
3127
+ // src/spatial-react-components/SpatialView.tsx
3128
+ var import_react30 = require("react");
3129
+ var import_jsx_runtime14 = require("react/jsx-runtime");
3130
+ var runAsync = /* @__PURE__ */ __name((fn) => {
3131
+ return fn();
3132
+ }, "runAsync");
3133
+ var SpatialViewEl = (0, import_react30.forwardRef)(
3134
+ (props, ref) => {
3135
+ const divRef = (0, import_react30.useRef)(null);
3136
+ const spatialEntity = (0, import_react30.useRef)(null);
3137
+ const activePromise = (0, import_react30.useRef)(null);
3138
+ (0, import_react30.useImperativeHandle)(ref, () => ({
3139
+ ...divRef.current,
3140
+ getViewEntity: /* @__PURE__ */ __name(async () => {
3141
+ if (activePromise.current) {
3142
+ await activePromise.current;
3143
+ }
3144
+ return spatialEntity.current;
3145
+ }, "getViewEntity")
3146
+ }));
3147
+ if (getSession() == null) {
3148
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ref: divRef, ...props, children: "WebSpatial is not supported in this browser" });
3149
+ }
3150
+ (0, import_react30.useEffect)(() => {
3151
+ if (true) return;
3152
+ activePromise.current = runAsync(async () => {
3153
+ if (activePromise.current) {
3154
+ await activePromise.current;
3155
+ }
3156
+ let sh = new SpatialHelper(getSession());
3157
+ let x = await sh.dom.attachSpatialView(divRef.current);
3158
+ spatialEntity.current = x.entity;
3159
+ if (props.onViewLoad) {
3160
+ props.onViewLoad(x.entity);
3161
+ }
3162
+ });
3163
+ return () => {
3164
+ if (true) return;
3165
+ runAsync(async () => {
3166
+ await activePromise.current;
3167
+ spatialEntity.current?.destroy();
3168
+ if (props.onViewUnload) {
3169
+ props.onViewUnload();
3170
+ }
3171
+ });
3172
+ };
3173
+ }, []);
3174
+ const { onViewLoad, onViewUnload, ...divProps } = props;
3175
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ref: divRef, ...divProps });
3176
+ }
3177
+ );
3178
+ var SpatialView = SpatialViewEl;
3179
+
3180
+ // src/spatial-react-components/Model/index.tsx
3181
+ var import_react31 = require("react");
3182
+ var import_model_viewer = require("@google/model-viewer");
3183
+ var import_jsx_runtime15 = require("react/jsx-runtime");
3184
+ function renderInModel3D(inProps, ref, modelUrl, placeHolder) {
3185
+ const { poster, ...props } = inProps;
3186
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(CSSModel3D, { modelUrl, ...props, ref, children: [
3187
+ " ",
3188
+ placeHolder,
3189
+ " "
3190
+ ] });
3191
+ }
3192
+ __name(renderInModel3D, "renderInModel3D");
3193
+ function parseChildren(child) {
3194
+ if (child === void 0) {
3195
+ throw new Error("children with <source> required ");
3196
+ }
3197
+ const children = import_react31.Children.toArray(child);
3198
+ const sourceElements = children.filter(
3199
+ (node) => node.type === "source"
3200
+ );
3201
+ if (sourceElements.length === 0) {
3202
+ throw new Error("children with at least one <source> required ");
3203
+ }
3204
+ const gltfSources = sourceElements.filter((node) => {
3205
+ const type = node.props?.type.trim();
3206
+ return type.startsWith("model/gltf-binary") || type.startsWith("model/gltf+json");
3207
+ });
3208
+ const usdzSources = sourceElements.filter(
3209
+ (node) => node.props?.type.trim().startsWith("model/vnd.usdz+zip")
3210
+ );
3211
+ let lastChild = children[children.length - 1];
3212
+ const placeHolder = sourceElements.indexOf(lastChild) < 0 ? lastChild : void 0;
3213
+ const gltfSourceURL = gltfSources.length > 0 && gltfSources[0].props?.src;
3214
+ const usdzSourceURL = usdzSources.length > 0 && usdzSources[0].props?.src;
3215
+ return {
3216
+ placeHolder,
3217
+ gltfSourceURL: getAbsoluteURL(gltfSourceURL),
3218
+ usdzSourceURL: getAbsoluteURL(usdzSourceURL)
3219
+ };
3220
+ }
3221
+ __name(parseChildren, "parseChildren");
3222
+ function ModelBase(inProps, ref) {
3223
+ const { children, ...props } = inProps;
3224
+ const { placeHolder, gltfSourceURL, usdzSourceURL } = (0, import_react31.useMemo)(
3225
+ () => parseChildren(children),
3226
+ [children]
3227
+ );
3228
+ const isWebEnv = !getSession();
3229
+ if (isWebEnv) {
3230
+ const myModelViewer = (0, import_react31.useRef)(null);
3231
+ const { className, style = {}, ...props2 } = inProps;
3232
+ (0, import_react31.useEffect)(() => {
3233
+ myModelViewer.current.addEventListener("load", (event) => {
3234
+ if (props2.onLoad) {
3235
+ props2.onLoad({
3236
+ target: { ready: true, currentSrc: gltfSourceURL }
3237
+ });
3238
+ }
3239
+ });
3240
+ myModelViewer.current.addEventListener("pointerdown", (event) => {
3241
+ if (props2.onDragStart) {
3242
+ props2.onDragStart({
3243
+ eventType: "dragstart",
3244
+ translation3D: { x: 0, y: 0, z: 0 },
3245
+ startLocation3D: { x: 0, y: 0, z: 0 },
3246
+ target: ref.current
3247
+ });
3248
+ }
3249
+ });
3250
+ myModelViewer.current.addEventListener("pointermove", (event) => {
3251
+ if (props2.onDrag) {
3252
+ props2.onDrag({
3253
+ eventType: "drag",
3254
+ translation3D: { x: 0, y: 0, z: 0 },
3255
+ startLocation3D: { x: 0, y: 0, z: 0 },
3256
+ target: ref.current
3257
+ });
3258
+ }
3259
+ });
3260
+ myModelViewer.current.addEventListener("pointerup", (event) => {
3261
+ if (props2.onDragEnd) {
3262
+ props2.onDragEnd({
3263
+ eventType: "dragend",
3264
+ translation3D: { x: 0, y: 0, z: 0 },
3265
+ startLocation3D: { x: 0, y: 0, z: 0 },
3266
+ target: ref.current
3267
+ });
3268
+ }
3269
+ });
3270
+ }, []);
3271
+ (0, import_react31.useEffect)(() => {
3272
+ if (props2.contentMode !== void 0 && props2.contentMode !== "fit") {
3273
+ console.warn(
3274
+ "Model element contentMode != fit isn't supported on 2D screens"
3275
+ );
3276
+ }
3277
+ if (props2.resizable !== void 0 && props2.resizable !== false) {
3278
+ console.warn(
3279
+ "Model element resizable != false isn't supported on 2D screens"
3280
+ );
3281
+ }
3282
+ if (props2.aspectRatio !== void 0 && props2.aspectRatio !== 1) {
3283
+ console.warn(
3284
+ "Model element aspectRatio != 1 isn't supported on 2D screens"
3285
+ );
3286
+ }
3287
+ }, [props2.contentMode, props2.resizable, props2.aspectRatio]);
3288
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { ref, className, style, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3289
+ "model-viewer",
3290
+ {
3291
+ ref: myModelViewer,
3292
+ style: {
3293
+ width: "100%",
3294
+ height: "100%"
3295
+ },
3296
+ src: gltfSourceURL,
3297
+ "camera-controls": true,
3298
+ "touch-action": "pan-y",
3299
+ poster: props2.poster
3300
+ }
3301
+ ) });
3302
+ } else {
3303
+ return renderInModel3D(props, ref, usdzSourceURL, placeHolder);
3304
+ }
3305
+ }
3306
+ __name(ModelBase, "ModelBase");
3307
+ var Model = (0, import_react31.forwardRef)(ModelBase);
3308
+ Model.displayName = "Model";
3309
+
3310
+ // src/XRApp.ts
3311
+ var defaultSceneConfig = {
3312
+ defaultSize: {
3313
+ width: 900,
3314
+ height: 700
3315
+ },
3316
+ resizability: "automatic"
3317
+ };
3318
+ var CONTEXT_WINDOW_URL = "webspatial://createWindowContext";
3319
+ var originalOpen = window.open;
3320
+ var XRApp = class _XRApp {
3321
+ static {
3322
+ __name(this, "XRApp");
3323
+ }
3324
+ static instance;
3325
+ static getInstance() {
3326
+ if (!_XRApp.instance) {
3327
+ _XRApp.instance = new _XRApp();
3328
+ }
3329
+ return _XRApp.instance;
3330
+ }
3331
+ handleATag(event) {
3332
+ const targetElement = event.target;
3333
+ if (targetElement.tagName === "A") {
3334
+ const link = targetElement;
3335
+ const target = link.target;
3336
+ const url = link.href;
3337
+ if (target && target !== "_self") {
3338
+ event.preventDefault();
3339
+ window.open(url, target);
3340
+ }
3341
+ }
3342
+ }
3343
+ init() {
3344
+ ;
3345
+ window.open = this.open;
3346
+ document.addEventListener("click", this.handleATag);
3347
+ }
3348
+ deinit() {
3349
+ ;
3350
+ window.open = originalOpen;
3351
+ document.removeEventListener("click", this.handleATag);
3352
+ }
3353
+ configMap = {};
3354
+ // name=>config
3355
+ getConfig(name) {
3356
+ if (name === void 0 || !this.configMap[name]) return void 0;
3357
+ return this.configMap[name];
3358
+ }
3359
+ async show(window2, cfg) {
3360
+ try {
3361
+ let session = getSession();
3362
+ await session._createScene(
3363
+ "Plain",
3364
+ // only support Plain for now
3365
+ {
3366
+ sceneData: {
3367
+ method: "showRoot",
3368
+ sceneConfig: cfg,
3369
+ // url: url,
3370
+ window: window2
3371
+ }
3372
+ }
3373
+ );
3374
+ } catch (error) {
3375
+ console.error(error);
3376
+ }
3377
+ }
3378
+ open = /* @__PURE__ */ __name((url, target, features) => {
3379
+ const newWindow = originalOpen(url, target, features);
3380
+ if (url === CONTEXT_WINDOW_URL) return newWindow;
3381
+ if (target === "_self" || target === "_parent" || target === "_top") {
3382
+ return newWindow;
3383
+ }
3384
+ let cnt = 2;
3385
+ let timer = setInterval(async () => {
3386
+ cnt -= 1;
3387
+ if (cnt < 0) {
3388
+ clearInterval(timer);
3389
+ return;
3390
+ }
3391
+ if (newWindow._webSpatialID) {
3392
+ clearInterval(timer);
3393
+ let session = getSession();
3394
+ if (!session) {
3395
+ console.error("no session");
3396
+ } else {
3397
+ const cfg = this.getConfig(target);
3398
+ try {
3399
+ await session._createScene(
3400
+ "Plain",
3401
+ // only support Plain for now
3402
+ {
3403
+ sceneData: {
3404
+ method: "createRoot",
3405
+ sceneConfig: cfg,
3406
+ url,
3407
+ window: newWindow
3408
+ // windowID: (newWindow as any)._webSpatialID,
3409
+ // windowContainerID: (newWindow as any)._webSpatialGroupID,
3410
+ }
3411
+ }
3412
+ );
3413
+ if (typeof target === "string" && this.configMap[target]) {
3414
+ delete this.configMap[target];
3415
+ }
3416
+ } catch (error) {
3417
+ console.error(error);
3418
+ }
3419
+ }
3420
+ }
3421
+ }, 0);
3422
+ return newWindow;
3423
+ }, "open");
3424
+ initScene(name, callback) {
3425
+ this.configMap[name] = callback({ ...defaultSceneConfig });
3426
+ }
3427
+ };
3428
+ function initScene(name, callback) {
3429
+ return XRApp.getInstance().initScene(name, callback);
3430
+ }
3431
+ __name(initScene, "initScene");
3432
+ //# sourceMappingURL=index.js.map