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