@webspatial/react-sdk 1.7.0 → 2.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 (66) hide show
  1. package/README.md +265 -4
  2. package/dist/Model-DO5ps8NA.d.ts +35 -0
  3. package/dist/Reality-BDyKL6th.d.ts +256 -0
  4. package/dist/Reality-DO-itiWW.d.ts +33 -0
  5. package/dist/SceneGraph-DxH74y6-.d.ts +214 -0
  6. package/dist/chunk-6JSRUX7P.js +2 -0
  7. package/dist/chunk-6JSRUX7P.js.map +1 -0
  8. package/dist/chunk-BTLTBCA7.js +2 -0
  9. package/dist/chunk-BTLTBCA7.js.map +1 -0
  10. package/dist/chunk-GG2QK5MA.js +2 -0
  11. package/dist/chunk-GG2QK5MA.js.map +1 -0
  12. package/dist/chunk-IOLNY4GP.js +2 -0
  13. package/dist/chunk-IOLNY4GP.js.map +1 -0
  14. package/dist/chunk-NWVQY6CN.js +2 -0
  15. package/dist/chunk-NWVQY6CN.js.map +1 -0
  16. package/dist/chunk-NXEOIP4Z.js +2 -0
  17. package/dist/chunk-NXEOIP4Z.js.map +1 -0
  18. package/dist/chunk-PDUEHFTO.js +2 -0
  19. package/dist/chunk-PDUEHFTO.js.map +1 -0
  20. package/dist/chunk-QHUROD77.js +2 -0
  21. package/dist/chunk-QHUROD77.js.map +1 -0
  22. package/dist/chunk-UHEO47WY.js +2 -0
  23. package/dist/chunk-UHEO47WY.js.map +1 -0
  24. package/dist/chunk-WDOPCAA3.js +19 -0
  25. package/dist/chunk-WDOPCAA3.js.map +1 -0
  26. package/dist/eager.d.ts +46 -0
  27. package/dist/eager.js +8 -0
  28. package/dist/eager.js.map +1 -0
  29. package/dist/experimental.d.ts +24 -0
  30. package/dist/experimental.js +8 -0
  31. package/dist/experimental.js.map +1 -0
  32. package/dist/index.d.ts +70 -0
  33. package/dist/index.js +8 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/internal/facades-client.d.ts +50 -0
  36. package/dist/internal/facades-client.js +3 -0
  37. package/dist/internal/facades-client.js.map +1 -0
  38. package/dist/jsx/jsx-dev-runtime.d.ts +7 -83
  39. package/dist/jsx/jsx-dev-runtime.js +1 -67
  40. package/dist/jsx/jsx-dev-runtime.js.map +1 -1
  41. package/dist/jsx/jsx-runtime.d.ts +81 -2
  42. package/dist/jsx/jsx-runtime.js +1 -67
  43. package/dist/jsx/jsx-runtime.js.map +1 -1
  44. package/dist/jsx-shared-CFDVUVpc.d.ts +16 -0
  45. package/dist/motionBindingTypes-CjxIC5bP.d.ts +25 -0
  46. package/dist/runtime/registerEagerEntry.d.ts +8 -0
  47. package/dist/runtime/registerEagerEntry.js +2 -0
  48. package/dist/runtime/registerEagerEntry.js.map +1 -0
  49. package/dist/spatial.d.ts +25 -0
  50. package/dist/spatial.js +7 -0
  51. package/dist/spatial.js.map +1 -0
  52. package/dist/useAnimation-C1LXt-xO.d.ts +28 -0
  53. package/dist/useMetrics-Bm_Urbtp.d.ts +96 -0
  54. package/package.json +51 -31
  55. package/dist/default/index.d.ts +0 -475
  56. package/dist/default/index.js +0 -4269
  57. package/dist/default/index.js.map +0 -1
  58. package/dist/jsx/jsx-dev-runtime.web.d.ts +0 -2
  59. package/dist/jsx/jsx-dev-runtime.web.js +0 -18
  60. package/dist/jsx/jsx-dev-runtime.web.js.map +0 -1
  61. package/dist/jsx/jsx-runtime.web.d.ts +0 -1
  62. package/dist/jsx/jsx-runtime.web.js +0 -18
  63. package/dist/jsx/jsx-runtime.web.js.map +0 -1
  64. package/dist/web/index.d.ts +0 -475
  65. package/dist/web/index.js +0 -4333
  66. package/dist/web/index.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/spatialized-container/hooks/use2DFrameDetector.ts","../../src/spatialized-container/context/SpatializedContainerContext.ts","../../src/spatialized-container/SpatialID.ts","../../src/spatialized-container/StandardSpatializedContainer.tsx","../../src/spatialized-container/TransformVisibilityTaskContainer.tsx","../../src/spatialized-container/hooks/useSpatialTransformVisibility.ts","../../src/notifyUpdateStandInstanceLayout.ts","../../src/spatialized-container/SpatializedContainer.tsx","../../src/noRuntime.ts","../../src/utils/getSession.ts","../../src/spatialized-container/context/SpatialLayerContext.ts","../../src/spatialized-container/PortalSpatializedContainer.tsx","../../src/spatialized-container/context/PortalInstanceContext.ts","../../src/spatialized-container/utils.ts","../../src/spatialized-container/types.ts","../../src/utils/debugTool.ts","../../src/utils/urlUtils.ts","../../src/spatialized-container/hooks/useSync2DFrame.ts","../../src/spatialized-container/hooks/useSpatializedElement.ts","../../src/spatialized-container/hooks/useDomProxy.ts","../../src/reality/context/InsideAttachmentContext.tsx","../../src/spatialized-container/hooks/useSpatialEvents.ts","../../src/ssr/SSRContext.tsx","../../src/ssr/withSSRSupported.tsx","../../src/ssr/useSSRPhase.tsx","../../src/spatialized-container/Spatialized2DElementContainer.tsx","../../src/utils/windowStyleSync.ts","../../src/utils/useSyncHeadStyles.ts","../../src/spatialized-container/hooks/useSpatialContentReady.ts","../../src/spatialized-container/SpatializedStatic3DElementContainer.tsx","../../src/spatialized-container/Spatialized2DElementContainerFactory.tsx","../../src/spatialized-container/index.ts","../../src/webSpatialRuntime.ts","../../src/initScene.web.ts","../../src/spatialized-container-monitor/withSpatialMonitor.tsx","../../src/spatialized-container-monitor/useMonitorDomChange.tsx","../../src/spatialized-container-monitor/useMonitorDocumentHeaderChange.tsx","../../src/spatialized-container-monitor/SpatialMonitor.tsx","../../src/reality/components/Entity.tsx","../../src/reality/components/BaseEntity.tsx","../../src/reality/context/RealityContext.tsx","../../src/reality/context/ParentContext.tsx","../../src/reality/context/AttachmentContext.tsx","../../src/reality/hooks/useEntityTransform.tsx","../../src/reality/utils/ResourceRegistry.ts","../../src/reality/utils/equal.ts","../../src/reality/utils/AbortResourceManager.ts","../../src/reality/hooks/useEntityEvent.tsx","../../src/reality/type.ts","../../src/reality/hooks/useEntityRef.tsx","../../src/reality/hooks/useRealityEvents.tsx","../../src/reality/hooks/useEntityId.tsx","../../src/reality/hooks/useEntity.tsx","../../src/reality/hooks/useForceUpdate.tsx","../../src/reality/components/BoxEntity.tsx","../../src/reality/components/GeometryEntity.tsx","../../src/reality/components/UnlitMaterial.tsx","../../src/reality/components/Texture.tsx","../../src/reality/components/SphereEntity.tsx","../../src/reality/components/ConeEntity.tsx","../../src/reality/components/CylinderEntity.tsx","../../src/reality/components/PlaneEntity.tsx","../../src/reality/components/SceneGraph.tsx","../../src/reality/components/ModelAsset.tsx","../../src/reality/components/ModelEntity.tsx","../../src/reality/components/Reality.tsx","../../src/reality/components/AttachmentAsset.tsx","../../src/reality/components/AttachmentEntity.tsx","../../src/reality/components/Material.tsx","../../src/Model.tsx","../../src/useMetrics.tsx","../../src/jsx/jsx-shared.ts","../../src/utils/convertCoordinate.ts","../../src/index.ts"],"sourcesContent":["import {\n useContext,\n useLayoutEffect,\n useEffect,\n useCallback,\n MutableRefObject,\n} from 'react'\n\nimport {\n SpatializedContainerContext,\n SpatializedContainerObject,\n} from '../context/SpatializedContainerContext'\n\nexport function use2DFrameDetector(ref: MutableRefObject<HTMLElement | null>) {\n const spatializedContainerObject: SpatializedContainerObject = useContext(\n SpatializedContainerContext,\n )!\n\n const notify2DFrameChange = useCallback(() => {\n ref.current &&\n spatializedContainerObject.notify2DFramePlaceHolderChange(ref.current)\n }, [ref.current, spatializedContainerObject])\n\n useLayoutEffect(notify2DFrameChange, [notify2DFrameChange])\n\n // listen to webview container size change and notifyDomChange\n // document.body.clientWidth may change as page loads.\n // when creating a new scene, clientWidth changes from 0 to some positive value.\n // this cannot be detected by ResizeObserver which only observe the dom element itself\n useEffect(() => {\n if (!ref.current || !spatializedContainerObject) {\n console.warn(\n 'Ref is not attached to the DOM or spatializedContainerObject is not available',\n )\n return\n }\n\n window.addEventListener('resize', notify2DFrameChange)\n\n return () => {\n window.removeEventListener('resize', notify2DFrameChange)\n }\n }, [])\n\n // detect dom resize\n // Trigger native resize on web resize events\n useEffect(() => {\n if (!ref.current) {\n console.warn('Ref is not attached to the DOM')\n return\n }\n\n const ro = new ResizeObserver(notify2DFrameChange)\n ro.observe(ref.current!)\n return () => {\n ro.disconnect()\n }\n }, [])\n\n // detect dom style and class change\n useEffect(() => {\n if (!ref.current) {\n console.warn('Ref is not attached to the DOM')\n return\n }\n const ro = new MutationObserver(notify2DFrameChange)\n ro.observe(ref.current!, {\n attributeFilter: ['class', 'style'],\n subtree: true,\n })\n return () => {\n ro.disconnect()\n }\n }, [])\n}\n","import { createContext } from 'react'\nimport { SpatialID } from '../SpatialID'\nimport { SpatializedElementRef, SpatialTransformVisibility } from '../types'\nimport { SpatialContainerRefProxy } from '../hooks/useDomProxy'\n\nexport class SpatializedContainerObject<\n T extends SpatializedElementRef = SpatializedElementRef,\n> {\n dom: HTMLElement | null = null\n domSpatialId: string | null = null\n\n private fns: Record<string, () => void> = {}\n // cache dom for each spatialId\n private spatialId2dom: Record<string, HTMLElement> = {}\n private spatialId2parentSpatialDom: Record<string, HTMLElement> = {}\n\n // layer : [standardInstance sequence, portalInstance sequence]\n private layerSequences: Record<number, [number, number]> = {}\n\n public notify2DFramePlaceHolderChange(dom: HTMLElement) {\n this.dom = dom\n this.domSpatialId = dom.getAttribute(SpatialID)\n Object.values(this.fns).forEach(fn => fn())\n }\n\n private spatialId2transformVisibility: Record<\n string,\n SpatialTransformVisibility\n > = {}\n public updateSpatialTransformVisibility(\n spatialId: string,\n spatialTransformVisibility: SpatialTransformVisibility,\n ) {\n this.spatialId2transformVisibility[spatialId] = spatialTransformVisibility\n // notify\n this.fnsForSpatialTransformVisibility[spatialId]?.forEach(fn =>\n fn(spatialTransformVisibility),\n )\n }\n\n // this is used by onSpatialEvent.currentTarget property\n private spatialId2ContainerRefProxy: Record<\n string,\n SpatialContainerRefProxy<T>\n > = {}\n\n // this is called in sub standardInstance env\n public updateSpatialContainerRefProxyInfo(\n spatialId: string,\n spatialContainerRefProxy: SpatialContainerRefProxy<T>,\n ) {\n this.spatialId2ContainerRefProxy[spatialId] =\n spatialContainerRefProxy as unknown as SpatialContainerRefProxy<T>\n }\n\n public getSpatialContainerRefProxyBySpatialId<\n T extends SpatializedElementRef,\n >(spatialId: string) {\n return this.spatialId2ContainerRefProxy[\n spatialId\n ] as unknown as SpatialContainerRefProxy<T>\n }\n\n // notify when TransformVisibilityTaskContainer data change\n private fnsForSpatialTransformVisibility: Record<\n string,\n Array<(spatialTransformVisibility: SpatialTransformVisibility) => void>\n > = {}\n\n // used by StandardSpatializedContainer and PortalSpatializedContainer\n public onSpatialTransformVisibilityChange(\n spatialId: string,\n fn: (spatialTransformVisibility: SpatialTransformVisibility) => void,\n ) {\n if (!this.fnsForSpatialTransformVisibility[spatialId]) {\n this.fnsForSpatialTransformVisibility[spatialId] = []\n }\n this.fnsForSpatialTransformVisibility[spatialId].push(fn)\n if (this.spatialId2transformVisibility[spatialId]) {\n fn(this.spatialId2transformVisibility[spatialId])\n }\n }\n\n public offSpatialTransformVisibilityChange(\n spatialId: string,\n fn: (spatialTransformVisibility: SpatialTransformVisibility) => void,\n ) {\n const fns = this.fnsForSpatialTransformVisibility[spatialId]\n if (fns) {\n this.fnsForSpatialTransformVisibility[spatialId] = fns.filter(\n f => f !== fn,\n )\n }\n }\n\n public on2DFrameChange(spatialId: string, fn: () => void) {\n this.fns[spatialId] = fn\n if (this.dom) {\n fn()\n }\n }\n\n public off2DFrameChange(spatialId: string) {\n delete this.fns[spatialId]\n delete this.spatialId2dom[spatialId]\n delete this.spatialId2parentSpatialDom[spatialId]\n }\n\n public querySpatialDomBySpatialId(spatialId: string) {\n if (this.domSpatialId === spatialId) {\n return this.dom\n }\n if (!this.dom) {\n return null\n }\n if (!this.spatialId2dom[spatialId]) {\n const spatialDom = this.dom.querySelector(`[${SpatialID}=\"${spatialId}\"]`)\n\n if (spatialDom) {\n this.spatialId2dom[spatialId] = spatialDom as HTMLElement\n }\n }\n return this.spatialId2dom[spatialId]\n }\n\n public queryParentSpatialDomBySpatialId(spatialId: string) {\n if (this.domSpatialId === spatialId) {\n return null\n }\n\n if (this.spatialId2parentSpatialDom[spatialId]) {\n // early return if already found\n return this.spatialId2parentSpatialDom[spatialId]\n }\n\n let spatialDom = this.querySpatialDomBySpatialId(spatialId)\n if (spatialDom) {\n if (spatialDom === this.dom) return null\n let parentSpatialDom = spatialDom.parentElement as HTMLElement\n while (parentSpatialDom && spatialDom !== this.dom) {\n if (parentSpatialDom.hasAttribute(SpatialID)) {\n break\n } else {\n parentSpatialDom = parentSpatialDom.parentElement as HTMLElement\n }\n }\n\n this.spatialId2parentSpatialDom[spatialId] = parentSpatialDom\n return parentSpatialDom\n }\n return null\n }\n\n public getSpatialId(\n layer: number,\n isInStandardInstance: boolean,\n name: string = '',\n ): string {\n if (this.layerSequences[layer] === undefined) {\n this.layerSequences[layer] = [0, 0]\n }\n const idx = isInStandardInstance ? 0 : 1\n const sequenceId = this.layerSequences[layer][idx]\n this.layerSequences[layer][idx] = sequenceId + 1\n const spatialId = `${name}_${layer}_${sequenceId}`\n return spatialId\n }\n}\n\nexport const SpatializedContainerContext =\n createContext<SpatializedContainerObject | null>(null)\n","export const SpatialID = 'data-spatial-id'\n","// Renders the standard host: the visible 2D placeholder of a spatial\n// container. The host is permanently hidden via class-scoped CSS rules\n// (`.xr-spatial-default[data-xr-host]`) and exposed to consumers as\n// `ref.current`. See `./ARCHITECTURE.md` for the invariants this component\n// must preserve and the reasoning behind the data-attribute / CSS approach.\nimport {\n SpatializedElementRef,\n SpatialTransformVisibility,\n StandardSpatializedContainerProps,\n} from './types'\nimport { use2DFrameDetector } from './hooks/use2DFrameDetector'\nimport {\n ForwardedRef,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react'\nimport { SpatializedContainerContext } from './context/SpatializedContainerContext'\nimport { SpatialID } from './SpatialID'\n\nfunction useSpatialTransformVisibilityWatcher(spatialId: string) {\n const [transformExist, setTransformExist] = useState(false)\n\n const spatializedContainerObject = useContext(SpatializedContainerContext)!\n useEffect(() => {\n const fn = (spatialTransform: SpatialTransformVisibility) => {\n setTransformExist(spatialTransform.transform !== 'none')\n }\n spatializedContainerObject.onSpatialTransformVisibilityChange(spatialId, fn)\n return () => {\n spatializedContainerObject.offSpatialTransformVisibilityChange(\n spatialId,\n fn,\n )\n }\n }, [spatialId, spatializedContainerObject])\n\n return transformExist\n}\n\nfunction useInternalRef(ref: ForwardedRef<HTMLElement | null>) {\n const refInternal = useRef<HTMLElement | null>(null)\n const refInternalCallback = useCallback(\n (node: HTMLElement | null) => {\n refInternal.current = node\n\n if (typeof ref === 'function') {\n ref(node)\n } else if (ref) {\n ref.current = node\n }\n },\n [ref],\n )\n\n return { refInternal, refInternalCallback }\n}\n\nexport function StandardSpatializedContainerBase(\n props: StandardSpatializedContainerProps,\n ref: ForwardedRef<HTMLElement | null>,\n) {\n const {\n component: Component,\n style: inStyle = {},\n className,\n inStandardSpatializedContainer = false,\n ...restProps\n } = props\n\n const { refInternal, refInternalCallback } = useInternalRef(ref)\n if (!inStandardSpatializedContainer) {\n use2DFrameDetector(refInternal)\n }\n const transformExist = useSpatialTransformVisibilityWatcher(props[SpatialID])\n\n const classNames = className\n ? `${className} xr-spatial-default`\n : 'xr-spatial-default'\n\n // Apply spatial host appearance (visibility / transition / transform) via a\n // CSS rule scoped to `.xr-spatial-default[data-xr-host]`, NOT via inline\n // style. The standard host has a styleProxy installed on it (see\n // SpatialContainerRefProxy) that forwards `style.transform` /\n // `style.visibility` writes to the probe so user code like\n // `ref.current.style.transform = 'rotate(45deg)'` reaches the platform\n // layer. If we wrote `transform: translateZ(0)` inline here, React's commit\n // would hit that proxy and clobber the user's value on the probe\n // (https://github.com/webspatial/webspatial-sdk/pull/1194).\n //\n // The SDK-controlled `data-xr-host` / `data-xr-transform-active` attributes\n // are placed AFTER `restProps` so user-supplied values cannot override\n // them — losing `data-xr-host` would un-hide the 2D placeholder, and\n // forcing `data-xr-transform-active` would diverge the host's stacking\n // state from the spatial transform watcher.\n return (\n <Component\n ref={refInternalCallback}\n style={inStyle}\n className={classNames}\n {...restProps}\n data-xr-host=\"\"\n data-xr-transform-active={transformExist ? '' : undefined}\n />\n )\n}\n\nexport const StandardSpatializedContainer = forwardRef(\n StandardSpatializedContainerBase,\n) as <T extends SpatializedElementRef>(\n props: StandardSpatializedContainerProps & {\n ref?: ForwardedRef<SpatializedElementRef<T>>\n },\n) => React.ReactElement | null\n\n/**\n * The hidden-host rules apply only to the visible 2D placeholder\n * (StandardSpatializedContainer's host element). They are intentionally\n * NOT written as inline style on that element — see the comment in\n * StandardSpatializedContainerBase. The selector is scoped via\n * `.xr-spatial-default` (always present on a spatial host) so that\n * unrelated DOM that happens to carry a `data-xr-host` attribute is not\n * affected. `!important` matches the previous inline-style behavior\n * where user-supplied inline visibility/transform could not override the\n * host's hidden / stacking-context state. The class observer mirrors\n * `class` (not `data-*`) onto the probe, so the probe never matches\n * because it lacks `data-xr-host`.\n */\nconst SPATIAL_DEFAULT_STYLE_CSS = `\n :where(.xr-spatial-default) {\n --xr-back: 0;\n --xr-depth: 0;\n --xr-z-index: 0;\n --xr-background-material: none;\n }\n .xr-spatial-default[data-xr-host] {\n visibility: hidden !important;\n transition: none !important;\n transform: none !important;\n }\n .xr-spatial-default[data-xr-host][data-xr-transform-active] {\n transform: translateZ(0) !important;\n }\n`\n\n/**\n * Marker attribute used to dedupe injected stylesheets per root.\n * Anyone querying for `style[data-xr-spatial-default-style]` should be able\n * to find the SDK's stylesheet and skip re-injecting.\n */\nconst SPATIAL_DEFAULT_STYLE_MARKER = 'data-xr-spatial-default-style'\n\n/**\n * Idempotently install the spatial default stylesheet into a tree root.\n *\n * Document-level stylesheets do not cross shadow boundaries, so a spatial\n * container rendered inside a `ShadowRoot` would miss the\n * `.xr-spatial-default[data-xr-host]` hiding rule and show the bare 2D\n * placeholder. Calling this for each host's root (Document or ShadowRoot)\n * keeps the rules reachable wherever the host actually lives.\n *\n * Safe to call repeatedly for the same root — uses an attribute marker on\n * the inserted `<style>` element to short-circuit duplicates.\n */\nexport function ensureSpatialDefaultStyleInRoot(root: Document | ShadowRoot) {\n const queryRoot = root === document ? document.head : root\n if (queryRoot.querySelector(`style[${SPATIAL_DEFAULT_STYLE_MARKER}]`)) {\n return\n }\n const ownerDoc =\n root === document\n ? document\n : (root as ShadowRoot).ownerDocument || document\n const styleElement = ownerDoc.createElement('style')\n styleElement.type = 'text/css'\n styleElement.setAttribute(SPATIAL_DEFAULT_STYLE_MARKER, '')\n styleElement.innerHTML = SPATIAL_DEFAULT_STYLE_CSS\n if (root === document) {\n document.head.appendChild(styleElement)\n } else {\n ;(root as ShadowRoot).appendChild(styleElement)\n }\n}\n\n/**\n * Polyfill entry point: ensure the document carries the spatial default\n * stylesheet. Hosts mounted inside shadow roots are covered by a separate\n * per-mount call from `SpatialContainerRefProxy`. Kept as a stable export\n * because it is referenced by `initPolyfill`.\n */\nexport function injectSpatialDefaultStyle() {\n ensureSpatialDefaultStyleInRoot(document)\n}\n","import {\n forwardRef,\n type CSSProperties,\n type ForwardedRef,\n useCallback,\n useRef,\n} from 'react'\nimport { SpatialID } from './SpatialID'\nimport { createPortal } from 'react-dom'\nimport { useSpatialTransformVisibility } from './hooks/useSpatialTransformVisibility'\n\n// used as root container for all TransformVisibilityTaskContainer\nlet cssParserDivContainer: HTMLDivElement | null = null\n\nexport function initCSSParserDivContainer() {\n cssParserDivContainer = document?.createElement('div')\n if (cssParserDivContainer) {\n cssParserDivContainer.style.position = 'absolute'\n cssParserDivContainer.setAttribute('data-id', 'css-parser-div-container')\n }\n}\n\nfunction createOrGetCSSParserDivContainer() {\n if (cssParserDivContainer && !cssParserDivContainer.parentElement) {\n document?.body.appendChild(cssParserDivContainer)\n }\n return cssParserDivContainer\n}\n\nfunction useInternalRef(ref: ForwardedRef<HTMLElement | null>) {\n const refInternal = useRef<HTMLElement | null>(null)\n const refInternalCallback = useCallback(\n (node: HTMLElement | null) => {\n refInternal.current = node\n\n if (typeof ref === 'function') {\n ref(node)\n } else if (ref) {\n ref.current = node\n }\n },\n [ref],\n )\n\n return { refInternal, refInternalCallback }\n}\n\ninterface TransformVisibilityTaskContainerProps {\n className?: string\n style?: CSSProperties\n [SpatialID]: string\n}\n\n// using css layout engine to calculate SpatializedContainer transform and visibility\nexport function TransformVisibilityTaskContainerBase(\n props: TransformVisibilityTaskContainerProps,\n ref: ForwardedRef<HTMLElement | null>,\n) {\n const { style: inStyle, ...restProps } = props\n const extraStyle: CSSProperties = {\n // when width/height equal to zero, transform: translateX(-50%) won't work\n // to make sure the element is not visible, we set left/top to a very large negative value\n left: -10000,\n top: -10000,\n pointerEvents: 'none',\n opacity: 0,\n // width: 0,\n // height: 0,\n padding: 0,\n transition: 'none',\n position: 'absolute',\n }\n\n const { refInternal, refInternalCallback } = useInternalRef(ref)\n\n const style: CSSProperties = { ...inStyle, ...extraStyle }\n useSpatialTransformVisibility(props[SpatialID], refInternal)\n\n const cssParserDivContainer = createOrGetCSSParserDivContainer()\n\n if (!cssParserDivContainer) {\n return null\n }\n\n return createPortal(\n <div ref={refInternalCallback} style={style} {...restProps} />,\n cssParserDivContainer,\n )\n}\n\nexport const TransformVisibilityTaskContainer = forwardRef(\n TransformVisibilityTaskContainerBase,\n)\n","import { RefObject, useCallback, useContext, useEffect } from 'react'\nimport { SpatialStyleInfoUpdateEvent } from '../../notifyUpdateStandInstanceLayout'\nimport { SpatialTransformVisibility } from '../types'\nimport { SpatializedContainerContext } from '../context/SpatializedContainerContext'\n\nfunction parseTransformAndVisibilityProperties(\n node: HTMLElement,\n): SpatialTransformVisibility {\n const computedStyle = getComputedStyle(node)\n\n // handle transform properties\n const transform = computedStyle.getPropertyValue('transform')\n\n // parse visibility\n const visibility = computedStyle.getPropertyValue('visibility')\n\n return {\n visibility,\n transform,\n }\n}\n\nexport function useSpatialTransformVisibility(\n spatialId: string,\n ref: RefObject<HTMLElement | null>,\n) {\n const spatializedContainerObject = useContext(SpatializedContainerContext)!\n\n const checkSpatialStyleUpdate = useCallback(() => {\n if (!ref.current) {\n return\n }\n const spatialTransformVisibility = parseTransformAndVisibilityProperties(\n ref.current!,\n )\n\n // notify SpatializedContainerContext\n spatializedContainerObject.updateSpatialTransformVisibility(\n spatialId,\n spatialTransformVisibility,\n )\n }, [])\n\n useEffect(() => {\n checkSpatialStyleUpdate()\n }, [checkSpatialStyleUpdate])\n\n useEffect(() => {\n // sync spatial style when this dom or sub dom change\n const observer = new MutationObserver(mutationsList => {\n checkSpatialStyleUpdate()\n })\n const config = {\n childList: false,\n subtree: false,\n attributes: true,\n // attributeOldValue: true,\n attributeFilter: ['style', 'class'],\n }\n observer.observe(ref.current!, config)\n\n return () => {\n observer.disconnect()\n }\n }, [])\n\n useEffect(() => {\n const headObserver = new MutationObserver(mutations => {\n checkSpatialStyleUpdate()\n })\n headObserver.observe(document.head, { childList: true, subtree: true })\n return () => {\n headObserver.disconnect()\n }\n }, [])\n\n useEffect(() => {\n const onDomUpdated = (event: Event) => {\n checkSpatialStyleUpdate()\n }\n\n // check style property change when some external style change\n document.addEventListener(\n SpatialStyleInfoUpdateEvent.domUpdated,\n onDomUpdated,\n )\n\n return () => {\n document.removeEventListener(\n SpatialStyleInfoUpdateEvent.domUpdated,\n onDomUpdated,\n )\n }\n }, [])\n}\n","export enum SpatialStyleInfoUpdateEvent {\n standInstanceLayout = 'standInstanceLayout',\n domUpdated = 'domUpdated',\n}\n\n/**\n * External-developers can call this function to sync the standardInstance layout to PortalInstance.\n *\n * Currently: notifyUpdateStandInstanceLayout is called when the document head changed\n * or when the monitored div changed (in both cases spatialDiv's layout may be changed, so we need to update the layout)\n */\nexport function notifyUpdateStandInstanceLayout() {\n document.dispatchEvent(\n new CustomEvent(SpatialStyleInfoUpdateEvent.standInstanceLayout, {\n detail: {},\n }),\n )\n}\n\nexport function notifyDOMUpdate(mutationsList: MutationRecord[]) {\n document.dispatchEvent(\n new CustomEvent(SpatialStyleInfoUpdateEvent.domUpdated, {\n detail: mutationsList,\n }),\n )\n}\n","import {\n ForwardedRef,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport {\n SpatializedContainerContext,\n SpatializedContainerObject,\n} from './context/SpatializedContainerContext'\nimport { getSession } from '../utils/getSession'\nimport { SpatialLayerContext } from './context/SpatialLayerContext'\nimport { SpatializedElementRef, SpatializedContainerProps } from './types'\nimport { StandardSpatializedContainer } from './StandardSpatializedContainer'\nimport { PortalSpatializedContainer } from './PortalSpatializedContainer'\nimport { PortalInstanceContext } from './context/PortalInstanceContext'\nimport { SpatialID } from './SpatialID'\nimport { TransformVisibilityTaskContainer } from './TransformVisibilityTaskContainer'\nimport { useDomProxy } from './hooks/useDomProxy'\nimport { useInsideAttachment } from '../reality/context/InsideAttachmentContext'\nimport {\n useSpatialEvents,\n useSpatialEventsWhenSpatializedContainerExist,\n} from './hooks/useSpatialEvents'\nimport { withSSRSupported } from '../ssr'\n\n/**\n * Degraded fallback: strips spatial-only props and renders plain HTML.\n * This is a separate component so that SpatializedContainerBase never\n * has to conditionally skip its hooks.\n */\nfunction DegradedContainer<T extends SpatializedElementRef>({\n innerRef,\n enableOnSpatialContentReadyFallback,\n ...inprops\n}: SpatializedContainerProps<T> & {\n innerRef: ForwardedRef<SpatializedElementRef<T>>\n enableOnSpatialContentReadyFallback: boolean\n}) {\n type DegradedProps = SpatializedContainerProps<T> & {\n 'enable-xr'?: unknown\n sizingMode?: unknown\n }\n const {\n component: Component,\n children,\n ['enable-xr']: _enableXR,\n onSpatialTap: _onSpatialTap,\n onSpatialDragStart: _onSpatialDragStart,\n onSpatialDrag: _onSpatialDrag,\n onSpatialDragEnd: _onSpatialDragEnd,\n onSpatialRotate: _onSpatialRotate,\n onSpatialRotateEnd: _onSpatialRotateEnd,\n onSpatialMagnify: _onSpatialMagnify,\n onSpatialMagnifyEnd: _onSpatialMagnifyEnd,\n spatialEventOptions: _spatialEventOptions,\n spatializedContent: _content,\n createSpatializedElement: _create,\n getExtraSpatializedElementProperties: _getExtra,\n extraRefProps: _extraRef,\n sizingMode: _sizingMode,\n onSpatialContentReady: _onSpatialContentReady,\n ...restProps\n } = inprops as DegradedProps\n\n const [hostEl, setHostEl] = useState<HTMLElement | null>(null)\n const callbackRef = useRef(_onSpatialContentReady)\n callbackRef.current = _onSpatialContentReady\n\n useLayoutEffect(() => {\n if (\n !enableOnSpatialContentReadyFallback ||\n !hostEl ||\n !hostEl.isConnected ||\n !callbackRef.current\n ) {\n return () => {}\n }\n\n let cleanup: void | (() => void)\n try {\n cleanup = callbackRef.current({ host: hostEl })\n } catch (e) {\n if (process.env.NODE_ENV !== 'production') {\n console.error('[WebSpatial] onSpatialContentReady threw', e)\n }\n }\n\n return () => {\n if (typeof cleanup !== 'function') return\n try {\n cleanup()\n } catch (e) {\n if (process.env.NODE_ENV !== 'production') {\n console.error('[WebSpatial] onSpatialContentReady cleanup threw', e)\n }\n }\n }\n }, [enableOnSpatialContentReadyFallback, hostEl])\n\n const setHostRef = useCallback(\n (node: SpatializedElementRef<T> | null) => {\n if (typeof innerRef === 'function') {\n innerRef(node)\n } else if (innerRef != null) {\n innerRef.current = node\n }\n setHostEl(node as HTMLElement | null)\n },\n [innerRef],\n )\n\n return (\n <Component ref={setHostRef} {...restProps}>\n {children}\n </Component>\n )\n}\n\nexport function SpatializedContainerBase<T extends SpatializedElementRef>(\n inprops: SpatializedContainerProps<T>,\n ref: ForwardedRef<SpatializedElementRef<T>>,\n) {\n const isWebSpatialEnv = getSession() !== null\n const insideAttachment = useInsideAttachment()\n\n if (!isWebSpatialEnv || insideAttachment) {\n if (insideAttachment) {\n console.warn(\n `[WebSpatial] ${inprops.component || 'Spatial element'} cannot be used inside AttachmentAsset. Rendering as plain HTML.`,\n )\n }\n return (\n <DegradedContainer\n {...inprops}\n innerRef={ref}\n enableOnSpatialContentReadyFallback={\n !isWebSpatialEnv && !insideAttachment\n }\n />\n )\n }\n\n const layer = useContext(SpatialLayerContext) + 1\n const rootSpatializedContainerObject = useContext(\n SpatializedContainerContext,\n ) as unknown as SpatializedContainerObject<T>\n const inSpatializedContainer = !!rootSpatializedContainerObject\n const portalInstanceObject = useContext(PortalInstanceContext)\n const inPortalInstanceEnv = !!portalInstanceObject\n const isInStandardInstance = !inPortalInstanceEnv\n\n const spatialId = useMemo(() => {\n return !inSpatializedContainer\n ? `root_container`\n : rootSpatializedContainerObject.getSpatialId(layer, isInStandardInstance)\n }, [])\n const spatialIdProps = {\n [SpatialID]: spatialId,\n }\n const {\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n extraRefProps,\n ...props\n } = inprops\n\n if (inSpatializedContainer) {\n if (inPortalInstanceEnv) {\n const spatialEvents = useSpatialEventsWhenSpatializedContainerExist<T>(\n {\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n },\n spatialId,\n rootSpatializedContainerObject,\n )\n\n // nested in another PortalSpatializedContainer\n return (\n <SpatialLayerContext.Provider value={layer}>\n <PortalSpatializedContainer<T>\n {...spatialIdProps}\n {...props}\n {...spatialEvents}\n />\n </SpatialLayerContext.Provider>\n )\n } else {\n // in standard instance env\n const {\n transformVisibilityTaskContainerCallback,\n standardSpatializedContainerCallback,\n spatialContainerRefProxy,\n } = useDomProxy<T>(ref, extraRefProps)\n\n const [probeClassName, setProbeClassName] = useState(\n () => props.className ?? '',\n )\n const notifyProbeClass = useCallback((name: string) => {\n setProbeClassName(prev => (prev === name ? prev : name))\n }, [])\n useEffect(() => {\n spatialContainerRefProxy.current.setMirrorClassNotify?.(\n notifyProbeClass,\n )\n return () => {\n spatialContainerRefProxy.current.setMirrorClassNotify?.(null)\n }\n }, [spatialContainerRefProxy, notifyProbeClass])\n\n useEffect(() => {\n rootSpatializedContainerObject.updateSpatialContainerRefProxyInfo(\n spatialId,\n spatialContainerRefProxy.current,\n )\n }, [spatialContainerRefProxy.current])\n\n const {\n spatializedContent,\n createSpatializedElement,\n getExtraSpatializedElementProperties,\n spatialEventOptions: _nestedSpatialEventOptions,\n onSpatialContentReady: _nestedOnSpatialContentReady,\n ...restProps\n } = props\n return (\n <SpatialLayerContext.Provider value={layer}>\n <StandardSpatializedContainer<T>\n ref={standardSpatializedContainerCallback}\n {...spatialIdProps}\n {...restProps}\n inStandardSpatializedContainer={true}\n />\n <TransformVisibilityTaskContainer\n ref={transformVisibilityTaskContainerCallback}\n {...spatialIdProps}\n className={probeClassName}\n style={props.style}\n />\n </SpatialLayerContext.Provider>\n )\n }\n } else {\n const {\n transformVisibilityTaskContainerCallback,\n standardSpatializedContainerCallback,\n spatialContainerRefProxy,\n } = useDomProxy<T>(ref, extraRefProps)\n\n const [probeClassName, setProbeClassName] = useState(\n () => props.className ?? '',\n )\n const notifyProbeClass = useCallback((name: string) => {\n setProbeClassName(prev => (prev === name ? prev : name))\n }, [])\n useEffect(() => {\n spatialContainerRefProxy.current.setMirrorClassNotify?.(notifyProbeClass)\n return () => {\n spatialContainerRefProxy.current.setMirrorClassNotify?.(null)\n }\n }, [spatialContainerRefProxy, notifyProbeClass])\n\n const spatialEvents = useSpatialEvents<T>(\n {\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n },\n spatialContainerRefProxy,\n )\n\n // This is the root spatialized container\n const spatializedContainerObject = useMemo(\n () => new SpatializedContainerObject(),\n [],\n )\n const {\n spatializedContent,\n createSpatializedElement,\n getExtraSpatializedElementProperties,\n spatialEventOptions: _rootSpatialEventOptions,\n onSpatialContentReady: _rootOnSpatialContentReady,\n ...restProps\n } = props\n\n return (\n <SpatialLayerContext.Provider value={layer}>\n <SpatializedContainerContext.Provider\n value={spatializedContainerObject}\n >\n <StandardSpatializedContainer<T>\n ref={standardSpatializedContainerCallback}\n {...spatialIdProps}\n {...restProps}\n inStandardSpatializedContainer={false}\n />\n <PortalSpatializedContainer<T>\n {...spatialIdProps}\n {...props}\n {...spatialEvents}\n />\n <TransformVisibilityTaskContainer\n ref={transformVisibilityTaskContainerCallback}\n {...spatialIdProps}\n className={probeClassName}\n style={props.style}\n />\n </SpatializedContainerContext.Provider>\n </SpatialLayerContext.Provider>\n )\n }\n}\n\nexport const SpatializedContainer = withSSRSupported(\n forwardRef(SpatializedContainerBase),\n) as <T extends SpatializedElementRef>(\n props: SpatializedContainerProps<T> & {\n ref?: ForwardedRef<SpatializedElementRef<T>>\n },\n) => React.ReactElement | null\n","// Redirect to empty module for treeshaking\nexport default {}\n\nexport const SpatialHelper = {}\n\n/** Minimal `Vec3` shape for the web no-runtime bundle (see real type in `@webspatial/core-sdk`). */\nexport interface Vec3 {\n x: number\n y: number\n z: number\n}\n\n/**\n * Web bundle stub: no native WebSpatial runtime — capability checks are conservative.\n * Metrics/coordinate helpers stay available so plain-browser demos keep working.\n */\nexport function supports(name: string, _tokens?: readonly string[]): boolean {\n if (name === 'useMetrics' || name === 'convertCoordinate') {\n return true\n }\n return false\n}\n\nexport class WebSpatialRuntimeError extends Error {\n public readonly capability: string\n\n constructor(capability: string, message?: string) {\n super(\n message ??\n `Capability \"${capability}\" is not supported in this WebSpatial runtime`,\n )\n this.name = 'WebSpatialRuntimeError'\n this.capability = capability\n }\n}\n\nexport class Spatial {\n /**\n * Requests a session object from the browser\n * @returns The session or null if not available in the current browser\n * [TODO] discuss implications of this not being async\n */\n requestSession() {\n return null\n }\n /**\n * Checks if the current page is running in a spatial web environment.\n * This method detects if the application is running in a WebSpatial-compatible browser.\n * @returns True if running in a spatial web environment, false otherwise\n */\n runInSpatialWeb() {\n return false\n }\n /**\n * @returns true if web spatial is supported by this webpage\n */\n isSupported() {\n return false\n }\n /**\n * Gets the native version, format is \"x.x.x\"\n * @returns native version string, or null when runtime is unavailable\n */\n getNativeVersion() {\n return null\n }\n /**\n * Gets the client version, format is \"x.x.x\"\n * @returns client version string, or null when runtime is unavailable\n */\n getClientVersion() {\n return null\n }\n}\n\nexport const version = undefined // no runtime so this should set undefined\n\nexport class SpatialScene {}\n\nexport function isSSREnv() {\n return false\n}\n\nexport const PhysicalMetrics = {\n pointToPhysical: (point: number, options?: any) => {\n return point / 1360\n },\n physicalToPoint: (physical: number, options?: any) => {\n return physical * 1360\n },\n getValue: () => ({\n meterToPtUnscaled: 1360,\n meterToPtScaled: 1360,\n }),\n subscribe: (cb: any) => () => {},\n}\n","import { isSSREnv, Spatial, SpatialSession } from '@webspatial/core-sdk'\n// Create the default Spatial session for the app\nlet spatial: Spatial | null = null\nlet _currentSession: SpatialSession | null = null\n/** @hidden */\nexport function getSession() {\n if (isSSREnv()) return null\n if (!spatial) {\n spatial = new Spatial()\n }\n if (!spatial.isSupported()) {\n return null\n }\n if (_currentSession) {\n return _currentSession\n }\n _currentSession = spatial.requestSession()\n return _currentSession\n}\n\nexport { spatial }\n","import { createContext } from 'react'\n\n// SpatialLayerContext is used to mark the spatial layer of the spatial div, which is used to help portal instance find the correct layer standard instance div.\nexport const SpatialLayerContext = createContext(0)\n","import { useMemo, useContext, useEffect } from 'react'\nimport {\n PortalInstanceObject,\n PortalInstanceContext,\n} from './context/PortalInstanceContext'\nimport {\n PortalSpatializedContainerProps,\n SpatialContentReadyCallback,\n SpatialEventOptions,\n SpatializedElementRef,\n} from './types'\nimport type { Vec3 } from '@webspatial/core-sdk'\n\nfunction constrainedAxisToVec3(\n input: SpatialEventOptions['constrainedToAxis'] | undefined,\n): Vec3 {\n if (input == null) return { x: 0, y: 0, z: 0 }\n if (Array.isArray(input)) {\n return { x: input[0] ?? 0, y: input[1] ?? 0, z: input[2] ?? 0 }\n }\n const v = input as Vec3\n return { x: v.x, y: v.y, z: v.z }\n}\n\nfunction constrainedAxisKey(\n input: SpatialEventOptions['constrainedToAxis'] | undefined,\n): string {\n const v = constrainedAxisToVec3(input)\n return `${v.x},${v.y},${v.z}`\n}\n\nimport { SpatialID } from './SpatialID'\nimport { useSync2DFrame } from './hooks/useSync2DFrame'\nimport { useSpatializedElement } from './hooks/useSpatializedElement'\nimport {\n SpatializedContainerContext,\n SpatializedContainerObject,\n} from './context/SpatializedContainerContext'\n\nfunction renderPlaceholderInSubPortal(\n portalInstanceObject: PortalInstanceObject,\n El: React.ElementType,\n) {\n const spatialId = portalInstanceObject.spatialId\n const inPortalInstanceEnv = !!portalInstanceObject.parentPortalInstanceObject\n const position =\n portalInstanceObject.computedStyle?.getPropertyValue('position')\n\n const shouldRenderPlaceHolder =\n inPortalInstanceEnv &&\n portalInstanceObject &&\n portalInstanceObject.domRect &&\n position !== 'absolute' &&\n position !== 'fixed'\n\n if (!shouldRenderPlaceHolder) {\n return <></>\n }\n\n const { width, height } = portalInstanceObject.domRect\n const display =\n portalInstanceObject.computedStyle!.getPropertyValue('display')\n\n const spatialIdProps = { [SpatialID]: spatialId }\n return (\n <El\n {...spatialIdProps}\n style={{\n position: 'relative',\n width: `${width}px`,\n height: `${height}px`,\n visibility: 'hidden',\n display,\n }}\n />\n )\n}\n\nexport function PortalSpatializedContainer<T extends SpatializedElementRef>(\n props: PortalSpatializedContainerProps<T> & {\n /** Forwarded to 2D `SpatializedContent` only (SpatialDiv). Ignored elsewhere. */\n onSpatialContentReady?: SpatialContentReadyCallback\n },\n) {\n const {\n spatializedContent: Content,\n createSpatializedElement,\n getExtraSpatializedElementProperties,\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n spatialEventOptions,\n [SpatialID]: spatialId,\n ...restProps\n } = props\n\n const spatializedContainerObject: SpatializedContainerObject = useContext(\n SpatializedContainerContext,\n )!\n\n const parentPortalInstanceObject = useContext(PortalInstanceContext)\n const portalInstanceObject = useMemo(\n () =>\n new PortalInstanceObject(\n spatialId,\n spatializedContainerObject,\n parentPortalInstanceObject,\n getExtraSpatializedElementProperties,\n ),\n [],\n )\n useEffect(() => {\n portalInstanceObject.init()\n return () => {\n portalInstanceObject.destroy()\n }\n }, [])\n\n useSync2DFrame(spatialId, portalInstanceObject, spatializedContainerObject)\n\n const spatializedElement = useSpatializedElement(\n createSpatializedElement,\n portalInstanceObject,\n )\n\n const PlaceholderEl = renderPlaceholderInSubPortal(\n portalInstanceObject,\n props.component,\n )\n\n useEffect(() => {\n if (spatializedElement) {\n // @ts-ignore\n spatializedElement.onSpatialTap = onSpatialTap\n }\n }, [spatializedElement, onSpatialTap])\n\n useEffect(() => {\n if (spatializedElement) {\n // @ts-ignore\n spatializedElement.onSpatialDrag = onSpatialDrag\n }\n }, [spatializedElement, onSpatialDrag])\n\n useEffect(() => {\n if (spatializedElement) {\n // @ts-ignore\n spatializedElement.onSpatialDragEnd = onSpatialDragEnd\n }\n }, [spatializedElement, onSpatialDragEnd])\n\n useEffect(() => {\n if (spatializedElement) {\n // @ts-ignore\n spatializedElement.onSpatialRotate = onSpatialRotate\n }\n }, [spatializedElement, onSpatialRotate])\n\n useEffect(() => {\n if (spatializedElement) {\n // @ts-ignore\n spatializedElement.onSpatialRotateEnd = onSpatialRotateEnd\n }\n }, [spatializedElement, onSpatialRotateEnd])\n\n useEffect(() => {\n if (spatializedElement) {\n // @ts-ignore\n spatializedElement.onSpatialMagnify = onSpatialMagnify\n }\n }, [spatializedElement, onSpatialMagnify])\n\n useEffect(() => {\n if (spatializedElement) {\n // @ts-ignore\n spatializedElement.onSpatialMagnifyEnd = onSpatialMagnifyEnd\n }\n }, [spatializedElement, onSpatialMagnifyEnd])\n\n useEffect(() => {\n if (spatializedElement) {\n // @ts-ignore\n spatializedElement.onSpatialDragStart = onSpatialDragStart\n }\n }, [spatializedElement, onSpatialDragStart])\n\n const rotateConstraintKey = constrainedAxisKey(\n spatialEventOptions?.constrainedToAxis,\n )\n\n useEffect(() => {\n if (!spatializedElement) return\n const axis = constrainedAxisToVec3(spatialEventOptions?.constrainedToAxis)\n void spatializedElement.updateProperties({ rotateConstrainedToAxis: axis })\n }, [spatializedElement, rotateConstraintKey])\n\n return (\n <PortalInstanceContext.Provider value={portalInstanceObject}>\n {spatializedElement && portalInstanceObject.dom && (\n <Content spatializedElement={spatializedElement} {...restProps} />\n )}\n {PlaceholderEl}\n </PortalInstanceContext.Provider>\n )\n}\n","import { Spatialized2DElement, SpatializedElement } from '@webspatial/core-sdk'\nimport { createContext } from 'react'\nimport { SpatializedContainerObject } from './SpatializedContainerContext'\nimport { parseTransformOrigin } from '../utils'\nimport { SpatialCustomStyleVars, SpatialTransformVisibility } from '../types'\nimport { getSession } from '../../utils'\n\ntype DomRect = {\n x: number\n y: number\n width: number\n height: number\n}\n\ntype CachedDomInfo = {\n // point to 2DFrame dom in StandardInstanceContainer\n dom: HTMLElement\n computedStyle: CSSStyleDeclaration\n isFixedPosition: boolean\n}\n\ntype CachedTransformVisibilityInfo = {\n visibility: string\n transformMatrix: DOMMatrix\n}\n\nexport class PortalInstanceObject {\n readonly spatialId: string\n readonly spatializedContainerObject: SpatializedContainerObject\n readonly parentPortalInstanceObject: PortalInstanceObject | null\n spatializedElement?: SpatializedElement\n\n // cachedDomInfo used for cache dom info\n // when dom is updated, this property should be updated as well\n private cachedDomInfo?: CachedDomInfo\n\n get dom(): HTMLElement | undefined {\n return this.cachedDomInfo?.dom\n }\n\n get computedStyle(): CSSStyleDeclaration | undefined {\n return this.cachedDomInfo?.computedStyle\n }\n\n get isFixedPosition(): boolean | undefined {\n return this.cachedDomInfo?.isFixedPosition\n }\n\n // cachedDomRect used for cache dom rect\n private cachedDomRect?: DomRect\n get domRect(): DomRect | undefined {\n return this.cachedDomRect\n }\n\n // cachedTransformVisibilityInfo used for cache transform visibility info\n private cachedTransformVisibilityInfo?: CachedTransformVisibilityInfo\n get transformMatrix() {\n return this.cachedTransformVisibilityInfo?.transformMatrix\n }\n get visibility() {\n return this.cachedTransformVisibilityInfo?.visibility\n }\n\n // spatializedElementPromise used for get spatialized element\n // SpatializedElement is when attachSpatializedElement is called\n private spatializedElementPromise?: Promise<SpatializedElement>\n private spatializedElementResolver?: (\n spatializedElement: SpatializedElement,\n ) => void\n\n // used for get extra spatialized element properties\n private getExtraSpatializedElementProperties?: (\n computedStyle: CSSStyleDeclaration,\n ) => Record<string, string | number>\n\n constructor(\n spatialId: string,\n spatializedContainerObject: SpatializedContainerObject,\n parentPortalInstanceObject: PortalInstanceObject | null,\n getExtraSpatializedElementProperties?: (\n computedStyle: CSSStyleDeclaration,\n ) => Record<string, string>,\n ) {\n this.spatialId = spatialId\n this.spatializedContainerObject = spatializedContainerObject\n this.parentPortalInstanceObject = parentPortalInstanceObject\n this.getExtraSpatializedElementProperties =\n getExtraSpatializedElementProperties\n\n this.spatializedElementPromise = new Promise<SpatializedElement>(\n resolve => {\n this.spatializedElementResolver = resolve\n },\n )\n }\n\n // called when PortalSpatializedContainer is mounted\n init() {\n this.spatializedContainerObject.onSpatialTransformVisibilityChange(\n this.spatialId,\n this.onSpatialTransformVisibilityChange,\n )\n }\n\n // called when PortalSpatializedContainer is unmounted\n destroy() {\n this.spatializedContainerObject.offSpatialTransformVisibilityChange(\n this.spatialId,\n this.onSpatialTransformVisibilityChange,\n )\n }\n\n private onSpatialTransformVisibilityChange = (\n spatialTransform: SpatialTransformVisibility,\n ) => {\n this.cachedTransformVisibilityInfo = {\n transformMatrix: new DOMMatrix(spatialTransform.transform),\n visibility: spatialTransform.visibility,\n }\n this.updateSpatializedElementProperties()\n }\n\n // called when 2D frame change\n notify2DFrameChange() {\n const dom = this.spatializedContainerObject.querySpatialDomBySpatialId(\n this.spatialId,\n )\n if (!dom) {\n return\n }\n const computedStyle = getComputedStyle(dom)\n this.cachedDomInfo = {\n dom,\n computedStyle,\n isFixedPosition: computedStyle.getPropertyValue('position') === 'fixed',\n }\n\n this.updateSpatializedElementProperties()\n\n const __innerSpatializedElement = () => this.spatializedElement\n\n Object.assign(dom, {\n __innerSpatializedElement,\n })\n }\n\n private async getSpatializedElement() {\n return this.spatializedElementPromise\n }\n\n // called when SpatializedElement is created\n attachSpatializedElement(spatializedElement: SpatializedElement) {\n this.spatializedElement = spatializedElement\n // attach to spatializedContainerObject\n this.addToParent(spatializedElement)\n this.spatializedElementResolver?.(spatializedElement)\n\n this.updateSpatializedElementProperties()\n }\n\n private inAddingToParent: boolean = false\n\n private async addToParent(spatializedElement: SpatializedElement) {\n if (this.inAddingToParent) {\n return\n }\n this.inAddingToParent = true\n\n if (this.isFixedPosition || !this.parentPortalInstanceObject) {\n // Add as a child of the current page\n var spatialScene = await getSession()!.getSpatialScene()\n await spatialScene.addSpatializedElement(spatializedElement!)\n } else {\n const parentSpatialized2DElement =\n (await this.parentPortalInstanceObject.getSpatializedElement()) as Spatialized2DElement\n // Add as a child of the parent\n parentSpatialized2DElement.addSpatializedElement(spatializedElement!)\n }\n this.inAddingToParent = false\n }\n\n private updateSpatializedElementProperties() {\n // console.log('updateSpatializedElement', this.spatializedElement)\n // read from spatializedContainerContext\n const dom = this.dom\n const spatializedElement = this.spatializedElement\n const visibility = this.visibility\n if (!dom || !spatializedElement || !visibility || !this.transformMatrix) {\n // console.log(\n // `not ready to updateSpatializedElementProperties! dom is ${!!dom} spatializedElement is ${spatializedElement} visibility is ${visibility}`,\n // )\n return\n }\n\n const computedStyle = this.computedStyle!\n const isFixedPosition = this.isFixedPosition!\n\n let domRect = dom.getBoundingClientRect()\n\n let { x, y } = domRect\n if (!isFixedPosition) {\n const parentDom =\n this.spatializedContainerObject.queryParentSpatialDomBySpatialId(\n this.spatialId,\n )\n if (parentDom) {\n const parentDomRect = parentDom.getBoundingClientRect()\n x -= parentDomRect.x\n y -= parentDomRect.y\n } else {\n // Adjust to get the page relative to document instead of viewport\n x += window.scrollX\n y += window.scrollY\n }\n }\n\n // update cachedDomRect\n this.cachedDomRect = {\n x: domRect.x,\n y: domRect.y,\n width: domRect.width,\n height: domRect.height,\n }\n\n // console.log('updateSpatializedElementProperties', domRect)\n\n const width = domRect.width\n const height = domRect.height\n const opacity = parseFloat(computedStyle.getPropertyValue('opacity'))\n const scrollWithParent = !isFixedPosition\n\n const display = computedStyle.getPropertyValue('display')\n const visible = visibility === 'visible' && display !== 'none'\n\n const zIndex =\n parseFloat(\n computedStyle.getPropertyValue(SpatialCustomStyleVars.xrZIndex),\n ) || 0\n const backOffset =\n parseFloat(computedStyle.getPropertyValue(SpatialCustomStyleVars.back)) ||\n 0\n\n const depth =\n parseFloat(\n computedStyle.getPropertyValue(SpatialCustomStyleVars.depth),\n ) || 0\n\n const rotationAnchor = parseTransformOrigin(computedStyle)\n const extraProperties =\n this.getExtraSpatializedElementProperties?.(computedStyle) || {}\n\n spatializedElement.updateProperties({\n clientX: x,\n clientY: y,\n width,\n height,\n depth,\n opacity,\n scrollWithParent,\n zIndex,\n visible,\n backOffset,\n rotationAnchor,\n ...extraProperties,\n })\n\n // update transform\n spatializedElement.updateTransform(this.transformMatrix!)\n\n // assign spatializedElement to dom\n Object.assign(this.dom, {\n __spatializedElement: spatializedElement,\n })\n }\n}\n\nexport const PortalInstanceContext = createContext<PortalInstanceObject | null>(\n null,\n)\n","import { CSSProperties } from 'react'\n\nexport function getInheritedStyleProps(\n computedStyle: CSSStyleDeclaration,\n): CSSProperties {\n //https://stackoverflow.com/questions/5612302/which-css-properties-are-inherited\n var propNames: (keyof CSSProperties)[] = [\n 'azimuth',\n 'borderCollapse',\n 'borderSpacing',\n 'captionSide',\n 'color',\n 'cursor',\n 'direction',\n // 'elevation',\n 'emptyCells',\n 'fontFamily',\n 'fontSize',\n 'fontStyle',\n 'fontVariant',\n 'fontWeight',\n 'font',\n 'letterSpacing',\n 'lineHeight',\n 'listStyleImage',\n 'listStylePosition',\n 'listStyleType',\n 'listStyle',\n 'orphans',\n // 'pitchRange',\n // 'pitch',\n 'quotes',\n // 'richness',\n // 'speakHeader',\n // 'speakNumeral',\n // 'speakPunctuation',\n // 'speak',\n // 'speechRate',\n // 'stress',\n 'textAlign',\n 'textIndent',\n 'textTransform',\n 'visibility',\n // 'voiceFamily',\n // 'volume',\n 'whiteSpace',\n 'widows',\n 'wordSpacing',\n // background also need to be synced\n 'background',\n // position also need to be synced\n 'position',\n\n 'width',\n 'height',\n\n 'display',\n\n // content-visibility also need to be synced\n 'contentVisibility',\n ]\n var props: CSSProperties = {}\n for (var cssName of propNames) {\n if ((computedStyle as any)[cssName]) {\n props[cssName] = (computedStyle as any)[cssName]\n }\n }\n return props\n}\n\nexport function parseTransformOrigin(computedStyle: CSSStyleDeclaration) {\n const transformOriginProperty =\n computedStyle.getPropertyValue('transform-origin')\n const [x, y] = transformOriginProperty.split(' ').map(parseFloat)\n const width = parseFloat(computedStyle.getPropertyValue('width'))\n const height = parseFloat(computedStyle.getPropertyValue('height'))\n\n return {\n x: width > 0 ? x / width : 0.5,\n y: height > 0 ? y / height : 0.5,\n z: 0.5,\n }\n}\n\nfunction parseBorderRadius(borderProperty: string, width: number) {\n if (borderProperty === '') {\n return 0\n }\n if (borderProperty.endsWith('%')) {\n return (width * parseFloat(borderProperty)) / 100\n }\n return parseFloat(borderProperty)\n}\n\nexport function parseCornerRadius(computedStyle: CSSStyleDeclaration) {\n const width = parseFloat(computedStyle.getPropertyValue('width'))\n\n const topLeftPropertyValue = computedStyle.getPropertyValue(\n 'border-top-left-radius',\n )\n const topRightPropertyValue = computedStyle.getPropertyValue(\n 'border-top-right-radius',\n )\n const bottomLeftPropertyValue = computedStyle.getPropertyValue(\n 'border-bottom-left-radius',\n )\n const bottomRightPropertyValue = computedStyle.getPropertyValue(\n 'border-bottom-right-radius',\n )\n\n const cornerRadius = {\n topLeading: parseBorderRadius(topLeftPropertyValue, width),\n bottomLeading: parseBorderRadius(bottomLeftPropertyValue, width),\n topTrailing: parseBorderRadius(topRightPropertyValue, width),\n bottomTrailing: parseBorderRadius(bottomRightPropertyValue, width),\n }\n\n return cornerRadius\n}\n\nexport function extractAndRemoveCustomProperties(\n cssText: string,\n properties: string[],\n) {\n if (!cssText) {\n return { extractedValues: {}, filteredCssText: '' }\n }\n\n const extractedValues: Record<string, string> = {}\n const rules = cssText.split(';')\n\n const filteredRules = rules.filter(rule => {\n const [key, value] = rule.split(':').map(part => part.trim())\n if (properties.includes(key)) {\n extractedValues[key] = value\n return false\n }\n return true\n })\n\n const filteredCssText = filteredRules.join(';').trim()\n return { extractedValues, filteredCssText }\n}\n\nexport function splitCSSText(cssText: string) {\n const rules = cssText.split(';')\n const filteredRules = rules.filter(rule => rule.trim() !== '')\n return filteredRules\n}\n\nexport function joinToCSSText(cssKV: Record<string, string>) {\n const rules = Object.entries(cssKV).map(([key, value]) => `${key}: ${value}`)\n return rules.join(';')\n}\n","import React, { ElementType } from 'react'\nimport { SpatialID } from './SpatialID'\nimport {\n ModelLoadingMode,\n SpatializedElement,\n SpatialTapEvent as CoreSpatialTapEvent,\n SpatialDragEvent as CoreSpatialDragEvent,\n SpatialDragStartEvent as CoreSpatialDragStartEvent,\n SpatialDragEndEvent as CoreSpatialDragEndEvent,\n SpatialRotateEvent as CoreSpatialRotateEvent,\n SpatialRotateEndEvent as CoreSpatialRotateEndEvent,\n SpatialMagnifyEvent as CoreSpatialMagnifyEvent,\n SpatialMagnifyEndEvent as CoreSpatialMagnifyEndEvent,\n SpatializedStatic3DElement,\n type Vec3,\n} from '@webspatial/core-sdk'\n\nexport type { Point3D, Vec3 } from '@webspatial/core-sdk'\nexport type { Quaternion } from '@webspatial/core-sdk'\n\n/** Connected content root for imperative mounting (portal root or web fallback host). */\nexport type SpatialContentReadyContext = {\n host: HTMLElement\n}\n\nexport type SpatialContentReadyCallback = (\n ctx: SpatialContentReadyContext,\n) => void | (() => void)\n\n/** Options for spatial pointer/gesture behavior (not DOM attributes). */\nexport type SpatialEventOptions = {\n /**\n * Direction vector for rotate gesture constraint. `[0, 0, 0]` or omit = unconstrained.\n */\n constrainedToAxis?: Vec3 | readonly [number, number, number]\n}\n\n// SpatialEvents\ntype SpatialEventProps<T extends SpatializedElementRef> = {\n onSpatialTap?: (event: SpatialTapEvent<T>) => void\n onSpatialDragStart?: (event: SpatialDragStartEvent<T>) => void\n onSpatialDrag?: (event: SpatialDragEvent<T>) => void\n onSpatialDragEnd?: (event: SpatialDragEndEvent<T>) => void\n onSpatialRotate?: (event: SpatialRotateEvent<T>) => void\n onSpatialRotateEnd?: (event: SpatialRotateEndEvent<T>) => void\n onSpatialMagnify?: (event: SpatialMagnifyEvent<T>) => void\n onSpatialMagnifyEnd?: (event: SpatialMagnifyEndEvent<T>) => void\n}\n\nexport interface StandardSpatializedContainerProps\n extends React.ComponentPropsWithoutRef<'div'> {\n component: ElementType\n inStandardSpatializedContainer?: boolean\n [SpatialID]: string\n}\n\nexport type PortalSpatializedContainerProps<T extends SpatializedElementRef> =\n SpatialEventProps<T> &\n React.ComponentPropsWithoutRef<'div'> & {\n component: ElementType\n spatializedContent: ElementType\n createSpatializedElement: () => Promise<SpatializedElement>\n getExtraSpatializedElementProperties?: (\n computedStyle: CSSStyleDeclaration,\n ) => Record<string, any>\n spatialEventOptions?: SpatialEventOptions\n\n [SpatialID]: string\n }\n\nexport type SpatializedContainerProps<T extends SpatializedElementRef> = Omit<\n StandardSpatializedContainerProps & PortalSpatializedContainerProps<T>,\n typeof SpatialID | 'onLoad' | 'onError'\n> & {\n extraRefProps?: (domProxy: T) => Record<string, unknown>\n /**\n * SpatialDiv only — fired when `ctx.host` is connected (portal root or web fallback host).\n * Not part of `Model` / `Reality` public APIs.\n */\n onSpatialContentReady?: SpatialContentReadyCallback\n}\n\nexport type SpatializedContentProps<\n T extends SpatializedElementRef,\n P extends ElementType,\n> = Omit<PortalSpatializedContainerProps<T>, 'spatializedContent'> & {\n spatializedElement: SpatializedElement\n /** SpatialDiv (2D) portal content only. */\n onSpatialContentReady?: SpatialContentReadyCallback\n}\n\nexport type Spatialized2DElementContainerProps<P extends ElementType> =\n SpatialEventProps<SpatializedElementRef> &\n React.ComponentPropsWithRef<'div'> & {\n component: P\n spatialEventOptions?: SpatialEventOptions\n onSpatialContentReady?: SpatialContentReadyCallback\n }\n\nexport type SpatializedStatic3DContainerProps =\n SpatialEventProps<SpatializedStatic3DElementRef> &\n Omit<React.ComponentPropsWithoutRef<'div'>, 'onLoad' | 'onError'> & {\n src?: string\n poster?: string\n autoPlay?: boolean\n loop?: boolean\n loading?: ModelLoadingMode\n children?: React.ReactNode\n onLoad?: (event: ModelLoadEvent) => void\n onError?: (event: ModelLoadEvent) => void\n spatialEventOptions?: SpatialEventOptions\n }\n\nexport type SpatializedStatic3DContentProps = {\n spatializedElement: SpatializedStatic3DElement\n src?: string\n poster?: string\n autoPlay?: boolean\n loop?: boolean\n loading?: ModelLoadingMode\n children?: React.ReactNode\n onLoad?: (event: ModelLoadEvent) => void\n onError?: (event: ModelLoadEvent) => void\n}\n\nexport const SpatialCustomStyleVars = {\n back: '--xr-back',\n depth: '--xr-depth',\n backgroundMaterial: '--xr-background-material',\n xrZIndex: '--xr-z-index',\n}\n\nexport interface SpatialTransformVisibility {\n transform: string\n visibility: string\n}\n\nexport type SpatializedElementRef<T extends HTMLElement = HTMLElement> = T\n\nexport type SpatializedDivElementRef = SpatializedElementRef<HTMLDivElement>\n\nexport type SpatializedStatic3DElementRef = SpatializedDivElementRef & {\n currentSrc: string\n ready: Promise<ModelLoadEvent>\n entityTransform: DOMMatrixReadOnly\n play(): Promise<void>\n pause(): Promise<void>\n readonly paused: boolean\n readonly duration: number\n playbackRate: number\n currentTime: number\n}\n\ntype CurrentTarget<T extends SpatializedElementRef> = {\n currentTarget: T\n}\n\nexport type SpatialTapEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialTapEvent &\n CurrentTarget<T> & {\n readonly offsetX: number\n readonly offsetY: number\n readonly offsetZ: number\n readonly clientX: number\n readonly clientY: number\n readonly clientZ: number\n }\n\nexport type SpatialDragStartEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialDragStartEvent &\n CurrentTarget<T> & {\n readonly offsetX: number\n readonly offsetY: number\n readonly offsetZ: number\n readonly clientX: number\n readonly clientY: number\n readonly clientZ: number\n }\n\nexport type SpatialDragEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialDragEvent &\n CurrentTarget<T> & {\n readonly translationX: number\n readonly translationY: number\n readonly translationZ: number\n }\n\nexport type SpatialDragEndEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialDragEndEvent & CurrentTarget<T>\n\nexport type SpatialRotateEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialRotateEvent &\n CurrentTarget<T> & {\n readonly quaternion: import('@webspatial/core-sdk').Quaternion\n }\n\nexport type SpatialRotateEndEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialRotateEndEvent & CurrentTarget<T>\n\nexport type SpatialMagnifyEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialMagnifyEvent &\n CurrentTarget<T> & {\n readonly magnification: number\n }\n\nexport type SpatialMagnifyEndEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialMagnifyEndEvent & CurrentTarget<T>\n\n// Model Spatial Event\nexport type ModelSpatialTapEvent =\n SpatialTapEvent<SpatializedStatic3DElementRef>\nexport type ModelSpatialDragStartEvent =\n SpatialDragStartEvent<SpatializedStatic3DElementRef>\nexport type ModelSpatialDragEvent =\n SpatialDragEvent<SpatializedStatic3DElementRef>\nexport type ModelSpatialDragEndEvent =\n SpatialDragEndEvent<SpatializedStatic3DElementRef>\nexport type ModelSpatialRotateEvent =\n SpatialRotateEvent<SpatializedStatic3DElementRef>\nexport type ModelSpatialRotateEndEvent =\n SpatialRotateEndEvent<SpatializedStatic3DElementRef>\nexport type ModelSpatialMagnifyEvent =\n SpatialMagnifyEvent<SpatializedStatic3DElementRef>\nexport type ModelSpatialMagnifyEndEvent =\n SpatialMagnifyEndEvent<SpatializedStatic3DElementRef>\n\nexport type ModelLoadEvent = CustomEvent & {\n target: SpatializedStatic3DElementRef\n}\n","import { isSSREnv, Spatialized2DElement } from '@webspatial/core-sdk'\nimport { getSession } from './getSession'\n\nasync function inspectCurrentSpatialScene() {\n const spatialScene = getSession()!.getSpatialScene()\n return spatialScene.inspect()\n}\n\nfunction getSpatialized2DElement(\n spatialized2DElement: HTMLDivElement,\n): Spatialized2DElement {\n return (\n spatialized2DElement as any\n ).__innerSpatializedElement?.() as Spatialized2DElement\n}\n\nexport function enableDebugTool() {\n if (isSSREnv()) return\n\n Object.assign(window, {\n inspectCurrentSpatialScene,\n getSpatialized2DElement,\n })\n}\n","/**\n * Resolve asset URLs for the native bridge: relative paths become absolute against the\n * current document (typical dev server is `http://localhost/...`).\n *\n * With no `window` (SSR), returns `url` unchanged — pass absolute `http(s)` URLs if needed.\n */\nexport function getAbsoluteUrl(url: string): string {\n if (typeof window === 'undefined' || !window.location?.href) {\n return url\n }\n try {\n return new URL(url, window.location.href).href\n } catch {\n return url\n }\n}\n","import { useEffect, useState } from 'react'\nimport { SpatializedContainerObject } from '../context/SpatializedContainerContext'\nimport { PortalInstanceObject } from '../context/PortalInstanceContext'\n\nfunction useForceUpdate() {\n const [, setToggle] = useState(false)\n return () => setToggle(toggle => !toggle)\n}\n\nexport function useSync2DFrame(\n spatialId: string,\n portalInstanceObject: PortalInstanceObject,\n spatializedContainerObject: SpatializedContainerObject,\n) {\n const forceUpdate = useForceUpdate()\n\n useEffect(() => {\n spatializedContainerObject.on2DFrameChange(spatialId, () => {\n portalInstanceObject.notify2DFrameChange()\n forceUpdate()\n })\n\n return () => {\n spatializedContainerObject.off2DFrameChange(spatialId)\n }\n }, [])\n}\n","import { useEffect, useRef, useState } from 'react'\nimport { PortalInstanceObject } from '../context/PortalInstanceContext'\nimport { SpatializedElement } from '@webspatial/core-sdk'\n\nexport function useSpatializedElement(\n createSpatializedElement: () => Promise<SpatializedElement | null>,\n portalInstanceObject: PortalInstanceObject,\n) {\n const [spatializedElement, setSpatializedElement] =\n useState<SpatializedElement>()\n // State drives re-renders and the returned value; it can't be in the effect\n // deps or we get an infinite loop (set → effect re-runs → create → set).\n // The element is created inside .then(), so cleanup may run before or after\n // the promise resolves. The ref is the shared store so cleanup can always\n // find and destroy the current element.\n const elementRef = useRef<SpatializedElement | undefined>(undefined)\n\n useEffect(() => {\n let isDestroyed = false\n\n createSpatializedElement().then(\n (inSpatializedElement: SpatializedElement | null) => {\n // createSpatializedElement can resolve to null on cancellation/failure\n if (!inSpatializedElement) return\n if (!isDestroyed) {\n elementRef.current = inSpatializedElement\n portalInstanceObject.attachSpatializedElement(inSpatializedElement)\n setSpatializedElement(inSpatializedElement)\n } else {\n inSpatializedElement?.destroy()\n }\n },\n )\n\n return () => {\n isDestroyed = true\n const el = elementRef.current\n if (el) {\n el.destroy()\n elementRef.current = undefined\n setSpatializedElement(undefined)\n }\n }\n }, [createSpatializedElement, portalInstanceObject])\n\n return spatializedElement\n}\n","import { ForwardedRef, useCallback, useEffect, useRef } from 'react'\nimport { SpatialCustomStyleVars, SpatializedElementRef } from '../types'\nimport { supports } from '@webspatial/core-sdk'\nimport { extractAndRemoveCustomProperties, joinToCSSText } from '../utils'\nimport { ensureSpatialDefaultStyleInRoot } from '../StandardSpatializedContainer'\n\n/**\n * Owns the spatialized behavior installed on the standard host element and\n * keeps the host ↔ probe pair (`StandardSpatializedContainer` ↔\n * `TransformVisibilityTaskContainer`) in sync.\n *\n * The host is exposed to consumers as `ref.current` — a real `HTMLElement` —\n * with property descriptors layered on via `Object.defineProperty` (style,\n * className, removeAttribute, xrClientDepth, xrOffsetBack, extraRefProps).\n * `style.transform` / `style.visibility` writes are forwarded to the probe\n * so they reach the platform via `useSpatialTransformVisibility`.\n *\n * Several non-trivial invariants must hold for the hidden-host CSS rules to\n * keep working — `xr-spatial-default` always present as a class token,\n * `data-xr-host` always present, transform/visibility never written inline\n * on the host. See `../ARCHITECTURE.md` (Invariants) for the full list and\n * the reasoning behind each.\n */\nexport class SpatialContainerRefProxy<T extends SpatializedElementRef> {\n private transformVisibilityTaskContainerDom: HTMLElement | null = null\n /** Raw Standard host element (styled root). Used to mirror class onto the transform probe. */\n private standardRawDom: HTMLElement | null = null\n private standardClassObserver: MutationObserver | null = null\n /**\n * When set, Standard's DOM className is forwarded here so TransformVisibilityTaskContainer\n * can render it from React state (avoids React clobbering imperative class updates).\n */\n private mirrorClassNotify: ((className: string) => void) | null = null\n /** Last class string applied to the probe + used to skip redundant syncs. */\n private lastMirroredClassName: string | null = null\n /** Coalesce multiple class sync triggers in the same turn (Observer + classList, etc.). */\n private classSyncMicrotaskQueued = false\n private ref: ForwardedRef<SpatializedElementRef<T>>\n public domProxy?: T | null\n /** Last value dispatched to `ref` (undefined = none yet); avoids duplicate null/proxy writes. */\n private lastOutgoingToRef: T | null | undefined = undefined\n private installedProperties: PropertyKey[] = []\n\n // extre ref props, used to add extra props to ref\n private extraRefProps?: ((domProxy: T) => Record<string, unknown>) | undefined\n\n constructor(\n ref: ForwardedRef<SpatializedElementRef<T>>,\n extraRefProps?: (domProxy: T) => Record<string, unknown>,\n ) {\n this.ref = ref\n this.extraRefProps = extraRefProps\n }\n\n setMirrorClassNotify(fn: ((className: string) => void) | null) {\n this.mirrorClassNotify = fn\n if (fn && this.standardRawDom) {\n this.flushSyncTransformClassFromStandard(true)\n }\n }\n\n private disconnectStandardClassObserver() {\n this.standardClassObserver?.disconnect()\n this.standardClassObserver = null\n }\n\n private attachStandardClassObserver() {\n this.disconnectStandardClassObserver()\n if (!this.standardRawDom) {\n return\n }\n this.standardClassObserver = new MutationObserver(() => {\n // The hidden-placeholder CSS rule is scoped to\n // `.xr-spatial-default[data-xr-host]`, so any native path that strips\n // the class (`setAttribute('class', …)`, `classList.remove(...)`,\n // `classList.replace(...)`, third-party DOM helpers) would un-hide the\n // 2D host. The className descriptor only intercepts `el.className =`\n // assignment; restore the class here so all attribute-mutation paths\n // converge on the same invariant.\n this.ensureSpatialDefaultClass()\n this.scheduleSyncTransformClassFromStandard()\n })\n this.standardClassObserver.observe(this.standardRawDom, {\n attributes: true,\n attributeFilter: ['class'],\n })\n }\n\n private ensureSpatialDefaultClass() {\n const dom = this.standardRawDom\n if (!dom) return\n // Token-based check via classList rather than `indexOf('xr-spatial-default')`,\n // so a class like `foo-xr-spatial-default-theme` does not satisfy the\n // invariant — the CSS rule is keyed on the real `.xr-spatial-default`\n // class token, not a substring.\n if (dom.classList.contains('xr-spatial-default')) return\n dom.classList.add('xr-spatial-default')\n }\n\n /**\n * Merge multiple sync requests (e.g. classList hook + MutationObserver) into one microtask.\n */\n private scheduleSyncTransformClassFromStandard() {\n if (this.classSyncMicrotaskQueued) {\n return\n }\n this.classSyncMicrotaskQueued = true\n queueMicrotask(() => {\n this.classSyncMicrotaskQueued = false\n this.flushSyncTransformClassFromStandard(false)\n })\n }\n\n /**\n * Source of truth: Standard host DOM (incl. styled-components runtime class changes).\n * @param force when true, skip same-string short-circuit (e.g. mirror notify just registered).\n */\n private flushSyncTransformClassFromStandard(force: boolean) {\n if (!this.standardRawDom) {\n return\n }\n const name = this.standardRawDom.className\n const probe = this.transformVisibilityTaskContainerDom\n if (\n !force &&\n probe &&\n probe.className === name &&\n this.lastMirroredClassName === name\n ) {\n return\n }\n this.lastMirroredClassName = name\n if (probe) {\n probe.className = name\n }\n this.mirrorClassNotify?.(name)\n }\n\n updateStandardSpatializedContainerDom(dom: HTMLElement | null) {\n if (!dom) {\n this.disconnectStandardClassObserver()\n this.clearInstalledProperties()\n this.standardRawDom = null\n this.lastMirroredClassName = null\n this.domProxy = undefined\n this.updateDomProxyToRef()\n return\n }\n\n if (this.standardRawDom === dom && this.domProxy) {\n this.scheduleSyncTransformClassFromStandard()\n return\n }\n\n this.clearInstalledProperties()\n this.standardRawDom = dom\n this.domProxy = dom as SpatializedElementRef<T>\n this.installSpatialRefBehavior(dom as SpatializedElementRef<T>)\n\n // Make sure the spatial default stylesheet is reachable from this host.\n // initPolyfill() injects it into `document`, but document-level rules do\n // not cross shadow boundaries — so a host mounted inside a ShadowRoot\n // would otherwise miss the `.xr-spatial-default[data-xr-host]` hiding\n // rule (and the spatial CSS variable defaults). The helper is idempotent\n // per root.\n const root = dom.getRootNode()\n if (root === document || root instanceof ShadowRoot) {\n ensureSpatialDefaultStyleInRoot(root as Document | ShadowRoot)\n }\n\n // Attach the class observer BEFORE publishing the ref. If a user-supplied\n // callback ref synchronously mutates the class via a native API that\n // bypasses the className descriptor (`node.setAttribute('class', …)`,\n // `node.classList.remove('xr-spatial-default')`, …), the resulting\n // MutationRecord must reach the self-heal in `attachStandardClassObserver`\n // — otherwise xr-spatial-default would be lost without restoration and\n // the host would un-hide. Do not reorder these two calls without a\n // regression test.\n this.attachStandardClassObserver()\n this.updateDomProxyToRef()\n this.scheduleSyncTransformClassFromStandard()\n }\n\n private clearInstalledProperties() {\n const dom = this.standardRawDom\n if (!dom) return\n for (const prop of this.installedProperties) {\n delete (dom as any)[prop]\n }\n this.installedProperties = []\n }\n\n private defineDomProperty(\n dom: HTMLElement,\n prop: PropertyKey,\n descriptor: PropertyDescriptor,\n ) {\n Object.defineProperty(dom, prop, {\n configurable: true,\n ...descriptor,\n })\n this.installedProperties.push(prop)\n }\n\n private installSpatialRefBehavior(dom: SpatializedElementRef<T>) {\n const self = this\n\n const rawStyle = dom.style\n const rawRemoveProperty = rawStyle.removeProperty.bind(rawStyle)\n const rawGetPropertyValue = rawStyle.getPropertyValue.bind(rawStyle)\n const rawRemoveAttribute = dom.removeAttribute.bind(dom)\n const spatialStyleProperties = ['visibility', 'transform']\n const styleProxy = new Proxy<CSSStyleDeclaration>(rawStyle, {\n get(target, prop) {\n if (prop === 'visibility' || prop === 'transform') {\n return self.transformVisibilityTaskContainerDom?.style.getPropertyValue(\n prop as string,\n )\n }\n const value = Reflect.get(target, prop)\n if (typeof value === 'function') {\n if (\n prop === 'setProperty' ||\n prop === 'removeProperty' ||\n prop === 'getPropertyValue'\n ) {\n return function (this: any, ...args: any[]) {\n const [property] = args\n\n if (spatialStyleProperties.includes(property)) {\n if (prop === 'setProperty') {\n const [, kValue, priority] = args\n self.transformVisibilityTaskContainerDom?.style.setProperty(\n property,\n kValue as string,\n priority as string | undefined,\n )\n } else if (prop === 'removeProperty') {\n return self.transformVisibilityTaskContainerDom?.style.removeProperty(\n property,\n )\n } else if (prop === 'getPropertyValue') {\n return self.transformVisibilityTaskContainerDom?.style.getPropertyValue(\n property,\n )\n }\n return undefined\n }\n return value.apply(this, args)\n }.bind(target)\n }\n return value.bind(target)\n }\n return value\n },\n set(target, prop, value) {\n if (prop === 'visibility') {\n self.transformVisibilityTaskContainerDom?.style.setProperty(\n 'visibility',\n value,\n )\n return true\n }\n if (prop === 'transform') {\n self.transformVisibilityTaskContainerDom?.style.setProperty(\n 'transform',\n value,\n )\n return true\n }\n\n if (Object.values(SpatialCustomStyleVars).includes(prop as string)) {\n target.setProperty(prop as string, value as string)\n return true\n }\n if (prop === 'cssText') {\n // parse cssText, filter out spatialStyle like transform/visibility\n const { extractedValues, filteredCssText } =\n extractAndRemoveCustomProperties(\n value as string,\n spatialStyleProperties,\n )\n\n // update cssText for transformVisibilityTaskContainerDom\n spatialStyleProperties.forEach(key => {\n if (extractedValues[key]) {\n self.transformVisibilityTaskContainerDom?.style.setProperty(\n key,\n extractedValues[key],\n )\n } else {\n rawRemoveProperty(key)\n }\n })\n\n const appendedCSSText = joinToCSSText({\n transform: 'none',\n visibility: 'hidden',\n })\n\n return Reflect.set(\n target,\n prop,\n [appendedCSSText, filteredCssText].join(';'),\n )\n }\n return Reflect.set(target, prop, value)\n },\n })\n\n this.defineDomProperty(dom, 'style', {\n get() {\n return styleProxy\n },\n set(value) {\n styleProxy.cssText = String(value)\n },\n })\n\n this.defineDomProperty(dom, 'className', {\n get() {\n return dom.getAttribute('class') ?? ''\n },\n set(value) {\n // Always preserve the real `xr-spatial-default` class token. Without\n // it the host loses both the spatial CSS vars and the\n // `.xr-spatial-default[data-xr-host]` hidden-placeholder rule, which\n // would un-hide the 2D host. Apply the value first, then re-append\n // via classList (which uses spec-correct token semantics) so values\n // like `foo-xr-spatial-default-theme` — substring-matching but not a\n // real token — still trigger restoration.\n dom.setAttribute('class', String(value))\n if (!dom.classList.contains('xr-spatial-default')) {\n dom.classList.add('xr-spatial-default')\n }\n self.scheduleSyncTransformClassFromStandard()\n },\n })\n\n this.defineDomProperty(dom, 'removeAttribute', {\n value(property: string) {\n if (property === 'style') {\n rawStyle.cssText =\n 'visibility: hidden; transition: none; transform: none;'\n self.transformVisibilityTaskContainerDom?.style.removeProperty(\n 'visibility',\n )\n self.transformVisibilityTaskContainerDom?.style.removeProperty(\n 'transform',\n )\n return\n }\n if (property === 'class') {\n dom.className = 'xr-spatial-default'\n return\n }\n return rawRemoveAttribute(property)\n },\n })\n\n if (supports('xrClientDepth')) {\n this.defineDomProperty(dom, 'xrClientDepth', {\n get() {\n return rawGetPropertyValue(SpatialCustomStyleVars.depth)\n },\n })\n }\n if (supports('xrOffsetBack')) {\n this.defineDomProperty(dom, 'xrOffsetBack', {\n get() {\n return rawGetPropertyValue(SpatialCustomStyleVars.back)\n },\n })\n }\n\n if (this.extraRefProps) {\n const extraProps = this.extraRefProps(dom)\n for (const prop of Object.keys(extraProps)) {\n this.defineDomProperty(dom, prop, {\n get() {\n return extraProps[prop]\n },\n set(value) {\n extraProps[prop] = value\n },\n })\n }\n }\n }\n\n updateTransformVisibilityTaskContainerDom(dom: HTMLElement | null) {\n this.transformVisibilityTaskContainerDom = dom\n if (!dom) {\n this.lastMirroredClassName = null\n }\n this.scheduleSyncTransformClassFromStandard()\n this.updateDomProxyToRef()\n }\n\n private updateDomProxyToRef() {\n const ref = this.ref\n if (!ref) {\n return\n }\n const next: T | null =\n this.domProxy && this.transformVisibilityTaskContainerDom\n ? this.domProxy\n : null\n if (this.lastOutgoingToRef === next) {\n return\n }\n this.lastOutgoingToRef = next\n if (next) {\n if (typeof ref === 'function') {\n ref(next)\n } else {\n ref.current = next\n }\n } else {\n if (typeof ref === 'function') {\n ref(null)\n } else {\n ref.current = null\n }\n }\n }\n\n updateRef(ref: ForwardedRef<SpatializedElementRef<T>>) {\n if (this.ref === ref) {\n return\n }\n this.ref = ref\n this.lastOutgoingToRef = undefined\n this.updateDomProxyToRef()\n }\n}\n\nexport function useDomProxy<T extends SpatializedElementRef>(\n ref: ForwardedRef<T>,\n extraRefProps?: (domProxy: T) => Record<string, unknown>,\n) {\n const spatialContainerRefProxy = useRef<SpatialContainerRefProxy<T>>(\n new SpatialContainerRefProxy<T>(ref, extraRefProps),\n )\n\n useEffect(() => {\n spatialContainerRefProxy.current.updateRef(ref)\n }, [ref])\n\n const transformVisibilityTaskContainerCallback = useCallback(\n (el: HTMLElement | null) => {\n spatialContainerRefProxy.current.updateTransformVisibilityTaskContainerDom(\n el,\n )\n },\n [],\n )\n\n const standardSpatializedContainerCallback = useCallback(\n (el: HTMLElement | null) => {\n spatialContainerRefProxy.current.updateStandardSpatializedContainerDom(el)\n },\n [],\n )\n\n return {\n transformVisibilityTaskContainerCallback,\n standardSpatializedContainerCallback,\n spatialContainerRefProxy,\n }\n}\n","import { createContext, useContext } from 'react'\n\nexport const InsideAttachmentContext = createContext(false)\nexport const useInsideAttachment = () => useContext(InsideAttachmentContext)\n","import { RefObject } from 'react'\nimport { SpatialContainerRefProxy } from './useDomProxy'\nimport {\n SpatializedElementRef,\n SpatialTapEvent,\n SpatialDragStartEvent,\n SpatialDragEndEvent,\n SpatialDragEvent,\n SpatialRotateEvent,\n SpatialRotateEndEvent,\n SpatialMagnifyEndEvent,\n SpatialMagnifyEvent,\n} from '../types'\nimport { SpatializedContainerObject } from '../context/SpatializedContainerContext'\n\nexport interface SpatialEvents<\n T extends SpatializedElementRef = SpatializedElementRef,\n> {\n onSpatialTap?: (event: SpatialTapEvent<T>) => void\n onSpatialDragStart?: (event: SpatialDragStartEvent<T>) => void\n onSpatialDrag?: (event: SpatialDragEvent<T>) => void\n onSpatialDragEnd?: (event: SpatialDragEndEvent<T>) => void\n onSpatialRotate?: (event: SpatialRotateEvent<T>) => void\n onSpatialRotateEnd?: (event: SpatialRotateEndEvent<T>) => void\n onSpatialMagnify?: (event: SpatialMagnifyEvent<T>) => void\n onSpatialMagnifyEnd?: (event: SpatialMagnifyEndEvent<T>) => void\n}\n\nfunction createEventProxy<\n T extends SpatializedElementRef,\n E extends { currentTarget: T },\n>(\n event: E,\n currentTargetGetter: () => T,\n offsetXGetter?: (event: E) => number | undefined,\n offsetYGetter?: (event: E) => number | undefined,\n offsetZGetter?: (event: E) => number | undefined,\n clientXGetter?: (event: E) => number | undefined,\n clientYGetter?: (event: E) => number | undefined,\n clientZGetter?: (event: E) => number | undefined,\n translationXGetter?: (event: E) => number | undefined,\n translationYGetter?: (event: E) => number | undefined,\n translationZGetter?: (event: E) => number | undefined,\n quaternionGetter?: (\n event: E,\n ) => import('@webspatial/core-sdk').Quaternion | undefined,\n magnificationGetter?: (event: E) => number | undefined,\n): E {\n return new Proxy(event, {\n get(target, prop) {\n if (prop === 'currentTarget') {\n return currentTargetGetter()\n }\n if (prop === 'isTrusted') {\n return true\n }\n if (prop === 'bubbles') {\n return false\n }\n if (prop === 'offsetX' && offsetXGetter) {\n return offsetXGetter(target) ?? 0\n }\n if (prop === 'offsetY' && offsetYGetter) {\n return offsetYGetter(target) ?? 0\n }\n if (prop === 'offsetZ' && offsetZGetter) {\n return offsetZGetter(target) ?? 0\n }\n if (prop === 'clientX' && clientXGetter) {\n return clientXGetter(target) ?? 0\n }\n if (prop === 'clientY' && clientYGetter) {\n return clientYGetter(target) ?? 0\n }\n if (prop === 'clientZ' && clientZGetter) {\n return clientZGetter(target) ?? 0\n }\n if (prop === 'translationX' && translationXGetter) {\n return translationXGetter(target) ?? 0\n }\n if (prop === 'translationY' && translationYGetter) {\n return translationYGetter(target) ?? 0\n }\n if (prop === 'translationZ' && translationZGetter) {\n return translationZGetter(target) ?? 0\n }\n if (prop === 'quaternion' && quaternionGetter) {\n return quaternionGetter(target) ?? { x: 0, y: 0, z: 0, w: 1 }\n }\n if (prop === 'magnification' && magnificationGetter) {\n return magnificationGetter(target) ?? 1\n }\n return Reflect.get(target, prop)\n },\n })\n}\n\nfunction createEventHandler<\n T extends SpatializedElementRef,\n E extends { currentTarget: T },\n>(\n handler: ((event: E) => void) | undefined,\n currentTargetGetter: () => T,\n offsetXGetter?: (event: E) => number | undefined,\n offsetYGetter?: (event: E) => number | undefined,\n offsetZGetter?: (event: E) => number | undefined,\n clientXGetter?: (event: E) => number | undefined,\n clientYGetter?: (event: E) => number | undefined,\n clientZGetter?: (event: E) => number | undefined,\n translationXGetter?: (event: E) => number | undefined,\n translationYGetter?: (event: E) => number | undefined,\n translationZGetter?: (event: E) => number | undefined,\n quaternionGetter?: (\n event: E,\n ) => import('@webspatial/core-sdk').Quaternion | undefined,\n magnificationGetter?: (event: E) => number | undefined,\n): ((event: E) => void) | undefined {\n return handler\n ? (event: E) => {\n const proxyEvent = createEventProxy<T, E>(\n event,\n currentTargetGetter,\n offsetXGetter,\n offsetYGetter,\n offsetZGetter,\n clientXGetter,\n clientYGetter,\n clientZGetter,\n translationXGetter,\n translationYGetter,\n translationZGetter,\n quaternionGetter,\n magnificationGetter,\n )\n handler(proxyEvent)\n }\n : undefined\n}\n\nexport function useSpatialEventsBase<T extends SpatializedElementRef>(\n spatialEvents: SpatialEvents<T>,\n currentTargetGetter: () => T,\n) {\n const onSpatialTap = createEventHandler<T, SpatialTapEvent<T>>(\n spatialEvents.onSpatialTap,\n currentTargetGetter,\n // offsetX/Y/Z come from local coordinates\n (ev: SpatialTapEvent<T>) => ev.detail?.location3D?.x,\n (ev: SpatialTapEvent<T>) => ev.detail?.location3D?.y,\n (ev: SpatialTapEvent<T>) => ev.detail?.location3D?.z,\n // clientX/Y/Z come from global scene coordinates\n (ev: SpatialTapEvent<T>) => ev.detail?.globalLocation3D?.x,\n (ev: SpatialTapEvent<T>) => ev.detail?.globalLocation3D?.y,\n (ev: SpatialTapEvent<T>) => ev.detail?.globalLocation3D?.z,\n )\n const onSpatialDrag = createEventHandler<T, SpatialDragEvent<T>>(\n spatialEvents.onSpatialDrag,\n currentTargetGetter,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n (ev: SpatialDragEvent<T>) => ev.detail?.translation3D?.x,\n (ev: SpatialDragEvent<T>) => ev.detail?.translation3D?.y,\n (ev: SpatialDragEvent<T>) => ev.detail?.translation3D?.z,\n )\n\n const onSpatialDragEnd = createEventHandler<T, SpatialDragEndEvent<T>>(\n spatialEvents.onSpatialDragEnd,\n currentTargetGetter,\n )\n\n const onSpatialRotate = createEventHandler<T, SpatialRotateEvent<T>>(\n spatialEvents.onSpatialRotate,\n currentTargetGetter,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n (ev: SpatialRotateEvent<T>) => ev.detail?.quaternion,\n )\n\n const onSpatialRotateEnd = createEventHandler<T, SpatialRotateEndEvent<T>>(\n spatialEvents.onSpatialRotateEnd,\n currentTargetGetter,\n )\n\n const onSpatialMagnify = createEventHandler<T, SpatialMagnifyEvent<T>>(\n spatialEvents.onSpatialMagnify,\n currentTargetGetter,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n (ev: SpatialMagnifyEvent<T>) => ev.detail?.magnification,\n )\n\n const onSpatialMagnifyEnd = createEventHandler<T, SpatialMagnifyEndEvent<T>>(\n spatialEvents.onSpatialMagnifyEnd,\n currentTargetGetter,\n )\n\n const onSpatialDragStart = createEventHandler<T, SpatialDragStartEvent<T>>(\n spatialEvents.onSpatialDragStart,\n currentTargetGetter,\n (ev: SpatialDragStartEvent<T>) => ev.detail?.startLocation3D?.x,\n (ev: SpatialDragStartEvent<T>) => ev.detail?.startLocation3D?.y,\n (ev: SpatialDragStartEvent<T>) => ev.detail?.startLocation3D?.z,\n (ev: SpatialDragStartEvent<T>) => ev.detail?.globalLocation3D?.x,\n (ev: SpatialDragStartEvent<T>) => ev.detail?.globalLocation3D?.y,\n (ev: SpatialDragStartEvent<T>) => ev.detail?.globalLocation3D?.z,\n )\n\n return {\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n }\n}\n\nexport function useSpatialEvents<T extends SpatializedElementRef>(\n spatialEvents: SpatialEvents<T>,\n spatialContainerRefProxy: RefObject<SpatialContainerRefProxy<T>>,\n) {\n return useSpatialEventsBase<T>(\n spatialEvents,\n () => spatialContainerRefProxy.current?.domProxy!,\n )\n}\n\nexport function useSpatialEventsWhenSpatializedContainerExist<\n T extends SpatializedElementRef,\n>(\n spatialEvents: SpatialEvents<T>,\n spatialId: string,\n spatializedContainerObject: SpatializedContainerObject<T>,\n) {\n return useSpatialEventsBase<T>(spatialEvents, () => {\n const spatialContainerRefProxy =\n spatializedContainerObject.getSpatialContainerRefProxyBySpatialId(\n spatialId,\n )\n return spatialContainerRefProxy?.domProxy as T\n })\n}\n","import React, { createContext, useState, useEffect } from 'react'\n\nexport const SSRContext = createContext(false)\n\nexport const SSRProvider = ({\n isSSR: initialIsSSR = true,\n children,\n}: {\n isSSR?: boolean\n children: React.ReactNode\n}) => {\n const [isSSR, setIsSSR] = useState(initialIsSSR)\n\n useEffect(() => {\n if (isSSR) {\n setIsSSR(false)\n }\n }, [])\n\n return <SSRContext.Provider value={isSSR}>{children}</SSRContext.Provider>\n}\n","import React, { ComponentType, forwardRef, PropsWithoutRef } from 'react'\nimport { useSSRPhase } from './useSSRPhase'\n\nexport type SSRPhase = 'ssr' | 'hydrate' | 'after-hydrate'\n\n/**\n * A HOC that ensures a component is only rendered on the client side.\n * It returns null during server-side rendering.\n * @param Component The component to be rendered only on the client.\n */\nexport function withSSRSupported<T extends {}>(Component: ComponentType<T>) {\n const ClientOnlyComponent = (\n props: PropsWithoutRef<T>,\n ref: React.ForwardedRef<any>,\n ) => {\n const phase = useSSRPhase()\n\n let renderType: 'fake' | 'real' = 'real'\n\n if (phase === 'ssr' || phase === 'hydrate') {\n renderType = 'fake'\n }\n\n if (renderType === 'fake') {\n const { style, className } = props as any\n // keep style and className for SSR, prevent style flicker on hydration\n return <div style={style} className={className} ref={ref}></div>\n } else {\n return <Component {...(props as T)} ref={ref} />\n }\n }\n\n ClientOnlyComponent.displayName = `withClientOnly(${Component.displayName || Component.name || 'Component'})`\n\n return forwardRef(ClientOnlyComponent)\n}\n","import { useContext, useState, useEffect } from 'react'\nimport { SSRContext } from './SSRContext'\nimport type { SSRPhase } from './withSSRSupported'\n/**\n * A hook to determine the current phase of Server-Side Rendering (SSR).\n *\n * This hook is crucial for components that need to behave differently during\n * various stages of the SSR lifecycle. It helps prevent hydration mismatches\n * in React by providing a clear state for each phase.\n *\n * @returns {SSRPhase} The current SSR phase, which can be one of the following:\n * - `'ssr'`: The component is rendering on the server.\n * - `'hydrate'`: The component is in the hydration phase on the client. This is the first render on the client, which must match the server-rendered output.\n * - `'after-hydrate'`: The component has finished hydrating and is now running purely on the client. This is also the state for apps in Client-Side Rendering (CSR) mode.\n *\n * @example\n * ```tsx\n * const ssrPhase = useSSRPhase();\n *\n * if (ssrPhase === 'ssr' || ssrPhase === 'hydrate') {\n * return <Spinner />;\n * }\n *\n * return <MyClientOnlyComponent />;\n * ```\n */\nexport function useSSRPhase(): SSRPhase {\n const isSSRContext = useContext(SSRContext)\n const isServer = typeof window === 'undefined'\n const [hydrated, setHydrated] = useState(false)\n\n useEffect(() => setHydrated(true), [])\n\n // Server-side rendering (SSR mode)\n if (isServer) {\n return 'ssr' as const\n }\n\n // Client-side\n if (isSSRContext) {\n // SSR mode: check hydration state\n return hydrated ? ('after-hydrate' as const) : ('hydrate' as const)\n } else {\n // CSR mode: directly return after-hydrate\n return 'after-hydrate' as const\n }\n}\n","import { createPortal } from 'react-dom'\nimport React, {\n CSSProperties,\n ElementType,\n ForwardedRef,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useState,\n} from 'react'\n\nimport { Spatialized2DElement } from '@webspatial/core-sdk'\n\nimport {\n setOpenWindowStyle,\n syncParentHeadToChild,\n} from '../utils/windowStyleSync'\nimport { useSyncHeadStyles } from '../utils/useSyncHeadStyles'\nimport { getInheritedStyleProps, parseCornerRadius } from './utils'\nimport {\n SpatialCustomStyleVars,\n Spatialized2DElementContainerProps,\n SpatializedElementRef,\n SpatializedContentProps,\n SpatializedDivElementRef,\n} from './types'\nimport { SpatializedContainer } from './SpatializedContainer'\nimport {\n PortalInstanceContext,\n PortalInstanceObject,\n} from './context/PortalInstanceContext'\nimport { getSession } from '../utils'\nimport { useSpatialContentReady } from './hooks/useSpatialContentReady'\n\nfunction mergeRefs<T>(\n ...refs: Array<React.Ref<T> | undefined | null>\n): React.RefCallback<T> {\n return value => {\n for (const ref of refs) {\n if (ref == null) continue\n if (typeof ref === 'function') {\n ref(value)\n } else {\n ;(ref as React.MutableRefObject<T | null>).current = value\n }\n }\n }\n}\n\nfunction getJSXPortalInstance<P extends ElementType>(\n inProps: Omit<\n SpatializedContentProps<SpatializedElementRef, P>,\n 'spatializedElement' | 'onSpatialContentReady'\n >,\n portalInstanceObject: PortalInstanceObject,\n hostRef?: React.RefCallback<HTMLElement | null>,\n) {\n const {\n component: El,\n style: inStyle = {},\n ref: userRef,\n ...props\n } = inProps as React.ComponentPropsWithRef<P> & {\n component: P\n }\n const extraStyle: CSSProperties = {\n visibility: 'visible',\n position: 'relative',\n top: '0px',\n left: '0px',\n margin: '0px',\n marginLeft: '0px',\n marginRight: '0px',\n marginTop: '0px',\n marginBottom: '0px',\n borderRadius: '0px',\n // overflow: '',\n transform: 'none',\n }\n\n const computedStyle = portalInstanceObject.computedStyle!\n const inheritedPortalStyle: CSSProperties =\n getInheritedStyleProps(computedStyle)\n\n const style = {\n ...inStyle,\n ...inheritedPortalStyle,\n ...extraStyle,\n }\n\n const mergedRef = hostRef != null ? mergeRefs(hostRef, userRef) : userRef\n\n return <El ref={mergedRef} style={style} {...props} />\n}\n\nfunction useSyncDocumentTitle(\n windowProxy: WindowProxy,\n spatializedElement: Spatialized2DElement,\n name: string,\n) {\n useEffect(() => {\n windowProxy.document.title = name\n spatializedElement.updateProperties({\n name,\n })\n }, [name])\n}\n\nfunction SpatializedContent<P extends ElementType>(\n props: SpatializedContentProps<SpatializedElementRef, P>,\n) {\n const { spatializedElement, onSpatialContentReady, ...restProps } = props\n const spatialized2DElement = spatializedElement as Spatialized2DElement\n const { windowProxy } = spatialized2DElement\n\n const [hostEl, setHostEl] = useState<HTMLElement | null>(null)\n const portalInstanceObject: PortalInstanceObject = useContext(\n PortalInstanceContext,\n )!\n\n useSpatialContentReady({\n spatializedElement,\n portalInstanceObject,\n hostElement: hostEl,\n onSpatialContentReady,\n })\n\n useSyncHeadStyles(windowProxy, {\n subtree: false,\n })\n\n const name: string = (restProps as any)['data-name'] || ''\n useSyncDocumentTitle(windowProxy, spatialized2DElement, name)\n\n const setHostCallback = useCallback((el: HTMLElement | null) => {\n setHostEl(el)\n }, [])\n\n const JSXPortalInstance = getJSXPortalInstance(\n restProps,\n portalInstanceObject,\n setHostCallback,\n )\n\n return createPortal(JSXPortalInstance, windowProxy.document.body)\n}\n\nfunction getExtraSpatializedElementProperties(\n computedStyle: CSSStyleDeclaration,\n) {\n // get extra spatialized element properties for Spatialized2DElement\n const overflow = computedStyle.getPropertyValue('overflow')\n const scrollPageEnabled = ['visible', 'hidden', 'clip'].indexOf(overflow) >= 0\n const material = computedStyle.getPropertyValue(\n SpatialCustomStyleVars.backgroundMaterial,\n )\n\n const properties: Record<string, any> = {}\n properties.scrollPageEnabled = scrollPageEnabled\n properties.cornerRadius = parseCornerRadius(computedStyle)\n if (material) {\n properties.material = material\n }\n\n // may need add scrollEdgeInsetsMarginRight in future\n return properties\n}\n\nasync function createSpatializedElement() {\n const spatializedElement = await getSession()!.createSpatialized2DElement()\n const { windowProxy } = spatializedElement\n setOpenWindowStyle(windowProxy)\n await syncParentHeadToChild(windowProxy)\n\n const viewport = windowProxy.document.querySelector('meta[name=\"viewport\"]')\n if (viewport) {\n viewport?.setAttribute(\n 'content',\n ' initial-scale=1.0, maximum-scale=1.0, user-scalable=no',\n )\n } else {\n const meta = windowProxy.document.createElement('meta')\n meta.name = 'viewport'\n meta.content = 'initial-scale=1.0, maximum-scale=1.0, user-scalable=no'\n windowProxy.document.head.appendChild(meta)\n }\n\n return spatializedElement\n}\n\nfunction Spatialized2DElementContainerBase<P extends ElementType>(\n props: Spatialized2DElementContainerProps<P>,\n ref: ForwardedRef<SpatializedDivElementRef>,\n) {\n return (\n <SpatializedContainer<SpatializedElementRef>\n ref={ref as any}\n createSpatializedElement={createSpatializedElement}\n getExtraSpatializedElementProperties={\n getExtraSpatializedElementProperties\n }\n spatializedContent={SpatializedContent}\n {...props}\n />\n )\n}\n\nexport const Spatialized2DElementContainer = forwardRef(\n Spatialized2DElementContainerBase,\n) as <P extends ElementType>(\n props: Spatialized2DElementContainerProps<P> & {\n ref: ForwardedRef<SpatializedElementRef>\n },\n) => React.ReactElement | null\n","export function asyncLoadStyleToChildWindow(\n childWindow: WindowProxy,\n link: HTMLLinkElement,\n isCurrent: () => boolean,\n): Promise<boolean> {\n return new Promise(resolve => {\n const { href } = link\n const sep = href.includes('?') ? '&' : '?'\n link.href = `${href}${sep}uniqueURL=${Math.random()}`\n\n let finished = false\n const finish = (ok: boolean) => {\n if (finished) return\n finished = true\n resolve(ok)\n }\n\n // need to wait for some time to make sure the style is loaded\n // otherwise, the style may not be applied\n link.onerror = () => {\n finish(false)\n }\n link.onload = () => {\n if (!isCurrent()) {\n link.parentNode?.removeChild(link)\n finish(false)\n return\n }\n finish(true)\n }\n\n setTimeout(() => {\n if (!isCurrent()) {\n finish(false)\n return\n }\n childWindow.document.head.appendChild(link)\n }, 50)\n })\n}\n\nconst WEBSPATIAL_SYNC_ATTR = 'data-webspatial-sync'\nconst WEBSPATIAL_SYNC_KEY_ATTR = 'data-webspatial-sync-key'\n\nexport function setOpenWindowStyle(openedWindow: WindowProxy) {\n openedWindow.document.documentElement.style.cssText +=\n document.documentElement.style.cssText\n openedWindow.document.documentElement.style.backgroundColor = 'transparent'\n openedWindow.document.body.style.margin = '0px'\n\n // openedWindow body's width and height should be set to inline-block to make sure the width and height are correct\n openedWindow.document.body.style.display = 'inline-block'\n openedWindow.document.body.style.minWidth = 'auto'\n openedWindow.document.body.style.minHeight = 'auto'\n openedWindow.document.body.style.maxWidth = 'fit-content'\n openedWindow.document.body.style.minWidth = 'fit-content'\n openedWindow.document.body.style.background = 'transparent'\n}\n\ninterface SyncController {\n version: number\n}\n\nconst controllers = new WeakMap<WindowProxy, SyncController>()\n\nfunction getController(childWindow: WindowProxy): SyncController {\n const prev = controllers.get(childWindow)\n if (prev) return prev\n const next: SyncController = { version: 0 }\n controllers.set(childWindow, next)\n return next\n}\n\nexport async function syncParentHeadToChild(childWindow: WindowProxy) {\n const controller = getController(childWindow)\n const version = ++controller.version\n const styleLoadedPromises: Promise<boolean>[] = []\n const { head } = childWindow.document\n\n const isCurrent = () => controller.version === version\n\n const parentStyles = Array.from(document.head.querySelectorAll('style'))\n const parentStylesheets = Array.from(\n document.head.querySelectorAll('link[rel=\"stylesheet\"][href]'),\n ) as HTMLLinkElement[]\n\n const desiredStylesheetKeys = new Set<string>()\n for (const link of parentStylesheets) {\n if (link.href) desiredStylesheetKeys.add(link.href)\n }\n\n const existingSyncedLinks = Array.from(\n head.querySelectorAll(\n `link[rel=\"stylesheet\"][${WEBSPATIAL_SYNC_ATTR}=\"1\"]`,\n ),\n ) as HTMLLinkElement[]\n for (const link of existingSyncedLinks) {\n const key = link.getAttribute(WEBSPATIAL_SYNC_KEY_ATTR) ?? link.href\n if (!desiredStylesheetKeys.has(key)) link.parentNode?.removeChild(link)\n }\n\n const prevSyncedStyles = head.querySelectorAll(\n `style[${WEBSPATIAL_SYNC_ATTR}=\"1\"]`,\n )\n prevSyncedStyles.forEach(n => n.parentNode?.removeChild(n))\n\n for (const styleEl of parentStyles) {\n const node = styleEl.cloneNode(true) as HTMLStyleElement\n node.setAttribute(WEBSPATIAL_SYNC_ATTR, '1')\n head.appendChild(node)\n }\n\n const currentKeys = new Set<string>()\n const currentSyncedLinks = Array.from(\n head.querySelectorAll(\n `link[rel=\"stylesheet\"][${WEBSPATIAL_SYNC_ATTR}=\"1\"]`,\n ),\n ) as HTMLLinkElement[]\n for (const link of currentSyncedLinks) {\n currentKeys.add(link.getAttribute(WEBSPATIAL_SYNC_KEY_ATTR) ?? link.href)\n }\n\n for (const link of parentStylesheets) {\n const key = link.href\n if (!key || currentKeys.has(key)) continue\n const node = link.cloneNode(true) as HTMLLinkElement\n node.setAttribute(WEBSPATIAL_SYNC_ATTR, '1')\n node.setAttribute(WEBSPATIAL_SYNC_KEY_ATTR, key)\n styleLoadedPromises.push(\n asyncLoadStyleToChildWindow(childWindow, node, isCurrent),\n )\n }\n\n // sync className\n childWindow.document.documentElement.className =\n document.documentElement.className\n\n return Promise.all(styleLoadedPromises)\n}\n","import { useEffect } from 'react'\n\nimport { syncParentHeadToChild } from './windowStyleSync'\n\ninterface Options {\n subtree?: boolean\n immediate?: boolean\n}\n\ntype SyncTiming = 'immediate' | 'delayed'\n\nfunction getSyncTiming(mutations?: MutationRecord[] | null): SyncTiming | null {\n if (!Array.isArray(mutations) || mutations.length === 0) return null\n // Scan the whole batch and take the highest priority across all records.\n // `immediate` (inline <style> changes) wins over `delayed` (<link rel=stylesheet>),\n // so a mixed batch is never downgraded to `delayed` by record ordering.\n let hasDelayed = false\n for (const mutation of mutations) {\n if (mutation.type === 'characterData') {\n const parent = mutation.target.parentElement\n if (parent?.tagName === 'STYLE') return 'immediate'\n }\n\n const nodes: Node[] = [\n mutation.target,\n ...Array.from(mutation.addedNodes),\n ...Array.from(mutation.removedNodes),\n ]\n for (const node of nodes) {\n if (!(node instanceof Element)) continue\n const tag = node.tagName\n if (tag === 'STYLE') return 'immediate'\n if (tag === 'LINK') {\n const { rel } = node as HTMLLinkElement\n if (rel && rel.toLowerCase() === 'stylesheet') hasDelayed = true\n }\n }\n }\n return hasDelayed ? 'delayed' : null\n}\n\nexport function useSyncHeadStyles(\n childWindow: WindowProxy | null | undefined,\n options?: Options,\n) {\n const delayMs = 100\n const subtree = options?.subtree ?? true\n const immediate = options?.immediate ?? true\n\n useEffect(() => {\n if (!childWindow) return\n\n let timer: number | undefined\n let immediateQueued = false\n let disposed = false\n const scheduleSync = (timing: SyncTiming = 'delayed') => {\n if (timer) window.clearTimeout(timer)\n if (timing === 'immediate') {\n if (immediateQueued) return\n immediateQueued = true\n queueMicrotask(() => {\n immediateQueued = false\n if (disposed) return\n syncParentHeadToChild(childWindow)\n })\n return\n }\n timer = window.setTimeout(() => {\n if (disposed) return\n syncParentHeadToChild(childWindow)\n }, delayMs)\n }\n\n if (immediate) scheduleSync()\n\n const observer = new MutationObserver(mutations => {\n const timing = getSyncTiming(mutations)\n if (!timing) return\n scheduleSync(timing)\n })\n observer.observe(document.head, {\n childList: true,\n characterData: true,\n subtree,\n })\n\n return () => {\n disposed = true\n if (timer) window.clearTimeout(timer)\n observer.disconnect()\n }\n }, [childWindow, delayMs, subtree, immediate])\n}\n","import { useLayoutEffect, useRef } from 'react'\nimport type { SpatializedElement } from '@webspatial/core-sdk'\nimport type { SpatialContentReadyCallback } from '../types'\nimport type { PortalInstanceObject } from '../context/PortalInstanceContext'\n\nconst isDev = process.env.NODE_ENV !== 'production'\n\nfunction safeInvokeCleanup(cleanup: (() => void) | undefined) {\n if (!cleanup) return\n try {\n cleanup()\n } catch (e) {\n if (isDev) {\n console.error('[WebSpatial] onSpatialContentReady cleanup threw', e)\n }\n }\n}\n\n/**\n * Edge-triggered portal readiness for `onSpatialContentReady`: fires once per rising edge\n * (`false → true`) in useLayoutEffect timing; cleanup runs from the layout-effect dispose\n * path (falling edge, deps change, unmount).\n */\nexport function useSpatialContentReady(params: {\n spatializedElement: SpatializedElement | undefined\n portalInstanceObject: PortalInstanceObject\n /** Portal subtree root element (connected when ready). */\n hostElement: HTMLElement | null\n onSpatialContentReady?: SpatialContentReadyCallback | undefined\n}) {\n const {\n spatializedElement,\n portalInstanceObject,\n hostElement,\n onSpatialContentReady,\n } = params\n\n const callbackRef = useRef(onSpatialContentReady)\n callbackRef.current = onSpatialContentReady\n\n useLayoutEffect(() => {\n const dom = portalInstanceObject.dom\n const isReady = !!(\n spatializedElement &&\n dom &&\n hostElement &&\n hostElement.isConnected\n )\n\n if (!isReady || !hostElement) {\n return () => {}\n }\n\n const cb = callbackRef.current\n let cleanupFromCallback: (() => void) | undefined\n\n if (cb) {\n try {\n const ret = cb({ host: hostElement })\n cleanupFromCallback = typeof ret === 'function' ? ret : undefined\n } catch (e) {\n if (isDev) {\n console.error('[WebSpatial] onSpatialContentReady threw', e)\n }\n }\n }\n\n return () => {\n safeInvokeCleanup(cleanupFromCallback)\n }\n }, [spatializedElement, portalInstanceObject.dom, hostElement])\n}\n","import {\n Children,\n ForwardedRef,\n forwardRef,\n isValidElement,\n ReactElement,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport { SpatializedContainer } from './SpatializedContainer'\nimport { getSession } from '../utils'\nimport {\n ModelLoadEvent,\n SpatializedStatic3DContainerProps,\n SpatializedStatic3DContentProps,\n SpatializedStatic3DElementRef,\n} from './types'\nimport {\n ModelLoadingMode,\n ModelSource,\n SpatializedStatic3DElement,\n} from '@webspatial/core-sdk'\nimport { PortalInstanceContext } from './context/PortalInstanceContext'\n\nfunction getAbsoluteURL(url: string): string\nfunction getAbsoluteURL(url: undefined): undefined\nfunction getAbsoluteURL(url: string | undefined): string | undefined\nfunction getAbsoluteURL(url?: string) {\n if (!url) return url\n try {\n return new URL(url, document.baseURI).toString()\n } catch {\n return url\n }\n}\n\nfunction createLoadEvent(\n type: string,\n targetGetter: () => SpatializedStatic3DElementRef,\n): ModelLoadEvent {\n const event = new CustomEvent(type, {\n bubbles: false,\n cancelable: false,\n })\n const proxyEvent = new Proxy(event, {\n get(target, prop) {\n if (prop === 'target') {\n return targetGetter()\n }\n return Reflect.get(target, prop)\n },\n })\n return proxyEvent as ModelLoadEvent\n}\n\nfunction createLoadFailureEvent(\n targetGetter: () => SpatializedStatic3DElementRef,\n): ModelLoadEvent {\n return createLoadEvent('modelloadfailed', targetGetter)\n}\n\nfunction createLoadSuccessEvent(\n targetGetter: () => SpatializedStatic3DElementRef,\n): ModelLoadEvent {\n return createLoadEvent('modelloaded', targetGetter)\n}\n\nfunction collectSources(children: React.ReactNode): ModelSource[] {\n const sources: ModelSource[] = []\n Children.forEach(children, child => {\n if (\n isValidElement(child) &&\n (child as ReactElement<{ src?: string; type?: string }>).type === 'source'\n ) {\n const { src, type } = (\n child as ReactElement<{ src?: string; type?: string }>\n ).props\n if (src) {\n sources.push({ src: getAbsoluteURL(src), type })\n }\n }\n })\n return sources\n}\n\nfunction SpatializedContent(props: SpatializedStatic3DContentProps) {\n const {\n src,\n poster,\n children,\n spatializedElement,\n onLoad,\n onError,\n autoPlay,\n loop,\n loading = 'eager',\n } = props\n const portalInstanceObject = useContext(PortalInstanceContext)!\n const wasVisible = useRef(false)\n\n const modelURL = useMemo(() => getAbsoluteURL(src), [src])\n const posterURL = useMemo(() => getAbsoluteURL(poster), [poster])\n const sources = useMemo(() => collectSources(children), [children])\n const sourcesKey = useMemo(() => JSON.stringify(sources), [sources])\n\n // Observe when model becomes visible and then stop until sources change\n useEffect(() => {\n wasVisible.current = false\n const target = portalInstanceObject.dom\n if (loading !== 'lazy' || !target) {\n wasVisible.current = true\n return\n }\n const observer = new IntersectionObserver(entries => {\n if (entries.some(entry => entry.isIntersecting)) {\n wasVisible.current = true\n observer.disconnect()\n spatializedElement.updateProperties({ loading: 'eager' })\n }\n })\n observer.observe(target)\n return () => observer.disconnect()\n }, [modelURL, sourcesKey, portalInstanceObject])\n\n useEffect(() => {\n if (loading !== 'lazy') wasVisible.current = true\n // If modelURL was previously set and now is undefined then a dummy\n // value needs to be sent to clear the old value\n // TODO: Can native side handle null instead of ''\n spatializedElement.updateProperties({\n modelURL: modelURL ?? (spatializedElement.modelUrl ? '' : modelURL),\n sources,\n autoplay: autoPlay,\n loop,\n posterURL: posterURL ?? '',\n loading: loading === 'lazy' && wasVisible.current ? 'eager' : loading,\n })\n }, [modelURL, sourcesKey, autoPlay, loop, posterURL, loading])\n\n useEffect(() => {\n if (onLoad) {\n spatializedElement.onLoadCallback = () => {\n onLoad(\n createLoadSuccessEvent(\n () => portalInstanceObject.dom as SpatializedStatic3DElementRef,\n ),\n )\n }\n } else {\n spatializedElement.onLoadCallback = undefined\n }\n }, [onLoad])\n\n useEffect(() => {\n if (onError) {\n spatializedElement.onLoadFailureCallback = () => {\n onError(\n createLoadFailureEvent(\n () => portalInstanceObject.dom as SpatializedStatic3DElementRef,\n ),\n )\n }\n } else {\n spatializedElement.onLoadFailureCallback = undefined\n }\n }, [onError])\n\n return <></>\n}\n\nfunction SpatializedStatic3DElementContainerBase(\n props: SpatializedStatic3DContainerProps,\n ref: ForwardedRef<SpatializedStatic3DElementRef>,\n) {\n const promiseRef = useRef<Promise<SpatializedStatic3DElement> | null>(null)\n\n const createSpatializedElement = useCallback(() => {\n promiseRef.current = getSession()!.createSpatializedStatic3DElement(\n getAbsoluteURL(props.src),\n collectSources(props.children),\n props.loading === 'lazy' ? 'lazy' : 'eager',\n )\n return promiseRef.current\n }, [])\n const extraRefProps = useCallback(\n (domProxy: SpatializedStatic3DElementRef) => {\n let modelTransform = new DOMMatrixReadOnly()\n return {\n get currentSrc(): string {\n const spatializedElement = (domProxy as any).__spatializedElement as\n | SpatializedStatic3DElement\n | undefined\n return spatializedElement?.currentSrc ?? ''\n },\n get ready(): Promise<ModelLoadEvent> {\n return promiseRef\n .current!.then(spatializedElement => spatializedElement.ready)\n .then(success => {\n if (success) return createLoadSuccessEvent(() => domProxy)\n throw createLoadFailureEvent(() => domProxy)\n })\n },\n get entityTransform(): DOMMatrixReadOnly {\n return modelTransform\n },\n set entityTransform(value: DOMMatrixReadOnly) {\n modelTransform = value\n const spatializedElement = (domProxy as any).__spatializedElement as\n | SpatializedStatic3DElement\n | undefined\n spatializedElement?.updateModelTransform(modelTransform)\n },\n async play(): Promise<void> {\n const spatializedElement = (domProxy as any).__spatializedElement as\n | SpatializedStatic3DElement\n | undefined\n await spatializedElement?.play()\n },\n async pause(): Promise<void> {\n const spatializedElement = (domProxy as any).__spatializedElement as\n | SpatializedStatic3DElement\n | undefined\n await spatializedElement?.pause()\n },\n get paused(): boolean {\n const spatializedElement = (domProxy as any).__spatializedElement as\n | SpatializedStatic3DElement\n | undefined\n return spatializedElement?.paused ?? true\n },\n get duration(): number {\n const spatializedElement = (domProxy as any).__spatializedElement as\n | SpatializedStatic3DElement\n | undefined\n return spatializedElement?.duration ?? 0\n },\n get playbackRate(): number {\n const spatializedElement = (domProxy as any).__spatializedElement as\n | SpatializedStatic3DElement\n | undefined\n return spatializedElement?.playbackRate ?? 1\n },\n set playbackRate(value: number) {\n const spatializedElement = (domProxy as any).__spatializedElement as\n | SpatializedStatic3DElement\n | undefined\n if (spatializedElement) {\n spatializedElement.playbackRate = value\n }\n },\n get currentTime(): number {\n const spatializedElement = (domProxy as any).__spatializedElement as\n | SpatializedStatic3DElement\n | undefined\n return spatializedElement?.currentTime ?? 0\n },\n set currentTime(value: number) {\n const spatializedElement = (domProxy as any).__spatializedElement as\n | SpatializedStatic3DElement\n | undefined\n if (spatializedElement) {\n spatializedElement.currentTime = value\n }\n },\n }\n },\n [],\n )\n\n return (\n <SpatializedContainer<SpatializedStatic3DElementRef>\n ref={ref}\n component=\"div\"\n createSpatializedElement={createSpatializedElement}\n spatializedContent={SpatializedContent}\n extraRefProps={extraRefProps}\n {...props}\n />\n )\n}\n\nexport const SpatializedStatic3DElementContainer = forwardRef(\n SpatializedStatic3DElementContainerBase,\n)\n","import { ElementType, ForwardedRef, forwardRef } from 'react'\nimport { Spatialized2DElementContainer } from './Spatialized2DElementContainer'\nimport {\n Spatialized2DElementContainerProps,\n SpatializedElementRef,\n} from './types'\n\nconst CachedSpatialized2DElementContainerType = new Map()\n\nexport function withSpatialized2DElementContainer<P extends ElementType>(\n Component: P,\n) {\n if (CachedSpatialized2DElementContainerType.has(Component)) {\n return CachedSpatialized2DElementContainerType.get(Component) as P\n } else {\n const TypedSpatialized2DElementContainer = forwardRef(\n (\n givenProps: Spatialized2DElementContainerProps<P>,\n ref: ForwardedRef<SpatializedElementRef>,\n ) => {\n const { component: ignoreComponent, ...props } = givenProps\n return (\n <Spatialized2DElementContainer<P>\n component={Component}\n {...props}\n ref={ref as any}\n />\n )\n },\n )\n\n CachedSpatialized2DElementContainerType.set(\n Component,\n TypedSpatialized2DElementContainer,\n )\n CachedSpatialized2DElementContainerType.set(\n TypedSpatialized2DElementContainer,\n TypedSpatialized2DElementContainer,\n )\n return TypedSpatialized2DElementContainer\n }\n}\n","import { injectSpatialDefaultStyle } from './StandardSpatializedContainer'\nimport { initCSSParserDivContainer } from './TransformVisibilityTaskContainer'\n\nexport { SpatializedContainer } from './SpatializedContainer'\nexport { Spatialized2DElementContainer } from './Spatialized2DElementContainer'\nexport { SpatializedStatic3DElementContainer } from './SpatializedStatic3DElementContainer'\nexport { withSpatialized2DElementContainer } from './Spatialized2DElementContainerFactory'\nexport {\n type Point3D,\n type Vec3,\n type SpatializedElementRef,\n type SpatialTapEvent,\n type SpatialDragStartEvent,\n type SpatialDragEvent,\n type SpatialDragEndEvent,\n type SpatialRotateEvent,\n type SpatialRotateEndEvent,\n type SpatialMagnifyEvent,\n type SpatialMagnifyEndEvent,\n type SpatializedStatic3DContainerProps,\n type Spatialized2DElementContainerProps,\n type SpatializedStatic3DElementRef,\n type ModelSpatialTapEvent,\n type ModelSpatialDragStartEvent,\n type ModelSpatialDragEvent,\n type ModelSpatialDragEndEvent,\n type ModelSpatialRotateEvent,\n type ModelSpatialRotateEndEvent,\n type ModelSpatialMagnifyEvent,\n type ModelSpatialMagnifyEndEvent,\n type ModelLoadEvent,\n type SpatialEventOptions,\n type SpatialContentReadyContext,\n type SpatialContentReadyCallback,\n} from './types'\n\nexport function initPolyfill() {\n injectSpatialDefaultStyle()\n initCSSParserDivContainer()\n}\n","import { supports } from '@webspatial/core-sdk'\n\n/**\n * Runtime capability checks (`supports('Model')`, `supports('WindowScene', ['defaultSize'])`, ...).\n * Spec: `openspec/specs/runtime-capabilities/spec.md`.\n */\nexport const WebSpatialRuntime = {\n supports,\n} as const\n","import type { SpatialSceneCreationOptions } from '@webspatial/core-sdk'\n\nexport function initScene(\n name: string,\n callback: (pre: SpatialSceneCreationOptions) => SpatialSceneCreationOptions,\n) {\n return\n}\n","import React, { forwardRef, Ref } from 'react'\nimport { SpatialMonitor } from './SpatialMonitor'\n\nconst cachedWithSpatialMonitorType = new Map()\n\nexport function withSpatialMonitor(El: React.ElementType) {\n if (cachedWithSpatialMonitorType.has(El)) {\n return cachedWithSpatialMonitorType.get(El)\n } else {\n const WithSpatialMonitorComponent = forwardRef(\n (givenProps: any, givenRef: Ref<any>) => {\n const {\n El: _,\n\n ...props\n } = givenProps\n\n return <SpatialMonitor El={El} {...props} ref={givenRef} />\n },\n )\n WithSpatialMonitorComponent.displayName = `WithSpatialMonitor(${typeof El === 'string' ? El : El.displayName || El.name})`\n\n cachedWithSpatialMonitorType.set(El, WithSpatialMonitorComponent)\n cachedWithSpatialMonitorType.set(\n cachedWithSpatialMonitorType,\n cachedWithSpatialMonitorType,\n )\n return WithSpatialMonitorComponent\n }\n}\n","import { useRef, useEffect, ForwardedRef, useMemo } from 'react'\nimport { notifyDOMUpdate } from '../notifyUpdateStandInstanceLayout'\n\nexport function useMonitorDomChange(inRef: ForwardedRef<HTMLElement>) {\n const ref = useRef<HTMLElement>(null)\n\n useEffect(() => {\n const observer = new MutationObserver(mutationsList => {\n notifyDOMUpdate(mutationsList)\n })\n\n const config = {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['style', 'class'],\n }\n\n ref.current && observer.observe(ref.current, config)\n\n return () => {\n observer.disconnect()\n }\n }, [])\n\n const proxyRef = useMemo(\n () =>\n new Proxy(ref, {\n set: function (target, key, value) {\n if (key === 'current') {\n if (inRef) {\n if (typeof inRef === 'function') {\n inRef(value)\n } else if (inRef) {\n inRef.current = value\n }\n }\n }\n return Reflect.set(target, key, value)\n },\n }),\n [],\n )\n\n return proxyRef\n}\n","import { useEffect } from 'react'\nimport { notifyUpdateStandInstanceLayout } from '../notifyUpdateStandInstanceLayout'\n\nexport function useMonitorDocumentHeaderChange() {\n useEffect(() => {\n const observer = new MutationObserver(mutationsList => {\n notifyUpdateStandInstanceLayout()\n })\n\n const config = {\n childList: true,\n subtree: true,\n attributes: true,\n }\n\n observer.observe(document.head, config)\n\n return () => {\n observer.disconnect()\n }\n }, [])\n}\n","import { useMonitorDomChange } from './useMonitorDomChange'\nimport { useMonitorDocumentHeaderChange } from './useMonitorDocumentHeaderChange'\nimport { ElementType, ForwardedRef, forwardRef } from 'react'\n\ntype SpatialMonitorProps = {\n El?: ElementType\n}\n\n/**\n * Component that add MutationObserver to monitor all dom changes including its children.\n * If any dom changes, it will notify all SpatialDiv to render again for the purpose of sync standInstance layout to portalInstance.\n */\nfunction SpatialMonitorBase(\n inProps: SpatialMonitorProps,\n inRef: ForwardedRef<HTMLElement>,\n) {\n const { El = 'div', ...props } = inProps\n const ref = useMonitorDomChange(inRef)\n useMonitorDocumentHeaderChange()\n\n return <El {...props} ref={ref} />\n}\n\nexport const SpatialMonitor = forwardRef(SpatialMonitorBase)\n","import React, { forwardRef } from 'react'\nimport { EntityProps } from '../type'\nimport { EntityRefShape } from '../hooks'\nimport { BaseEntity } from './BaseEntity'\n\ntype Props = EntityProps & { children?: React.ReactNode }\n\nexport const Entity = forwardRef<EntityRefShape, Props>((props, ref) => {\n const { id, name, children, ...rest } = props\n return (\n <BaseEntity\n {...rest}\n id={id}\n ref={ref}\n createEntity={async ctxVal => ctxVal!.session.createEntity({ id, name })}\n >\n {children}\n </BaseEntity>\n )\n})\n","import React, { forwardRef } from 'react'\nimport { SpatialEntity } from '@webspatial/core-sdk'\nimport {\n ParentContext,\n RealityContextValue,\n useRealityContext,\n} from '../context'\nimport { EntityProps, EntityEventHandler } from '../type'\nimport { EntityRefShape, useEntity } from '../hooks'\n\ntype BaseEntityProps = EntityProps &\n EntityEventHandler & {\n children?: React.ReactNode\n recreateKey?: string\n createEntity: (\n ctx: RealityContextValue,\n signal: AbortSignal,\n ) => Promise<SpatialEntity>\n }\n\nexport const BaseEntity = forwardRef<EntityRefShape, BaseEntityProps>(\n ({ children, createEntity, recreateKey, ...rest }, ref) => {\n const ctx = useRealityContext()\n const entity = useEntity({\n ...rest,\n ref,\n recreateKey,\n createEntity: (signal: AbortSignal) => createEntity(ctx, signal),\n })\n\n if (!entity) return null\n return (\n <ParentContext.Provider value={entity}>{children}</ParentContext.Provider>\n )\n },\n)\n","import {\n SpatializedDynamic3DElement,\n SpatialSession,\n} from '@webspatial/core-sdk'\nimport { createContext, useContext } from 'react'\nimport { ResourceRegistry } from '../utils'\nimport { AttachmentRegistry } from './AttachmentContext'\n\nexport type RealityContextValue = {\n session: SpatialSession\n reality: SpatializedDynamic3DElement\n resourceRegistry: ResourceRegistry\n attachmentRegistry: AttachmentRegistry\n} | null\nexport const RealityContext = createContext<RealityContextValue>(null)\nexport const useRealityContext = () => useContext(RealityContext)\n","import { SpatialEntity } from '@webspatial/core-sdk'\nimport { createContext, useContext } from 'react'\n\nexport const ParentContext = createContext<SpatialEntity | null>(null)\nexport const useParentContext = () => useContext(ParentContext)\n","import { createContext, useContext } from 'react'\n\nexport type ContainerEntry = { instanceId: string; container: HTMLElement }\n\ntype ContainersChangeCallback = (containers: ContainerEntry[]) => void\n\nexport class AttachmentRegistry {\n // name → (instanceId → container)\n private containers = new Map<string, Map<string, HTMLElement>>()\n private listeners = new Map<string, ContainersChangeCallback>()\n\n addContainer(name: string, instanceId: string, container: HTMLElement) {\n if (!this.containers.has(name)) {\n this.containers.set(name, new Map())\n }\n this.containers.get(name)!.set(instanceId, container)\n this.notifyListeners(name)\n }\n\n removeContainer(name: string, instanceId: string) {\n this.containers.get(name)?.delete(instanceId)\n if (this.containers.get(name)?.size === 0) {\n this.containers.delete(name)\n }\n this.notifyListeners(name)\n }\n\n getContainers(name: string): ContainerEntry[] {\n const map = this.containers.get(name)\n if (!map) return []\n return Array.from(map, ([instanceId, container]) => ({\n instanceId,\n container,\n }))\n }\n\n onContainersChange(name: string, cb: ContainersChangeCallback): () => void {\n const current = this.getContainers(name)\n if (current.length > 0) {\n cb(current)\n }\n const prev = this.listeners.get(name)\n if (prev) prev([])\n this.listeners.set(name, cb)\n return () => {\n if (this.listeners.get(name) === cb) {\n this.listeners.delete(name)\n }\n }\n }\n\n private notifyListeners(name: string) {\n const cs = this.getContainers(name)\n this.listeners.get(name)?.(cs)\n }\n\n destroy() {\n this.containers.clear()\n this.listeners.clear()\n }\n}\n\nexport const AttachmentContext = createContext<AttachmentRegistry | null>(null)\nexport const useAttachmentContext = () => useContext(AttachmentContext)\n","import { SpatialEntity } from '@webspatial/core-sdk'\nimport { useEffect, useRef } from 'react'\nimport { EntityProps } from '../type'\nimport { shallowEqualRotation, shallowEqualVec3 } from '../utils'\n\nexport function useEntityTransform(\n entity: SpatialEntity | null,\n { position, rotation, scale }: EntityProps,\n) {\n const last = useRef<{ position?: any; rotation?: any; scale?: any }>({})\n\n useEffect(() => {\n if (!entity) return\n\n const shouldUpdate =\n !shallowEqualVec3(last.current.position, position) ||\n !shallowEqualRotation(last.current.rotation, rotation) ||\n !shallowEqualVec3(last.current.scale, scale)\n\n if (!shouldUpdate) return\n\n last.current = { position, rotation, scale }\n\n const updateTransform = async () => {\n try {\n await entity.updateTransform({ position, rotation, scale })\n } catch (err) {\n console.error('[useEntityTransform] Failed to update transform:', err)\n }\n }\n\n updateTransform()\n\n return () => {}\n }, [entity, position, rotation, scale])\n}\n","import { SpatialObject } from '@webspatial/core-sdk'\n\n/**\n * Tracks spatial resources (textures, materials, entities, …) by string id under one Reality.\n *\n * Native creation is async (`createTexture`, `createUnlitMaterial`, …). The map\n * stores `Promise<SpatialObject>` so `add(id, pendingCreation)` can run after `get(id)` — sibling\n * JSX order does not need to match registration order. Callers are responsible for using the\n * correct id for each resource kind (same as with string ids today).\n *\n * Callers can `await get(id)` before `add(id, promise)` runs: `get` returns a promise that\n * settles when something later calls `add` with the same id.\n *\n * **Subscriptions:** `subscribe(id, listener)` runs `listener` whenever `notify(id)` is invoked.\n * The registry auto-notifies after each `add()` promise settles (then or catch), and on\n * `remove`, `removeAndDestroy`, and `destroy()`. Components such as `<Texture>` may call\n * `notify(id)` manually when a resource mutates in place without a new `add()` (e.g. same texture\n * id, new URL via `updateProperties`).\n */\nexport class ResourceRegistry {\n /** Every id maps to a promise — either the real resource from add(), or a placeholder until then. */\n private resources: Map<string, Promise<SpatialObject>> = new Map()\n /** If get() ran first, we stash resolve/reject so add() can complete the waiting promise. */\n private deferreds = new Map<\n string,\n {\n resolve: (value: SpatialObject) => void\n reject: (error: Error) => void\n }\n >()\n /** Subscribers are notified whenever an id gets a fresh resolved or failed resource attempt. */\n private listeners = new Map<string, Set<() => void>>()\n\n add<T extends SpatialObject>(id: string, resource: Promise<T>): void {\n this.resources.set(id, resource)\n\n // Anyone who awaited get(id) early is still holding the placeholder; wire them to this promise.\n const deferred = this.deferreds.get(id)\n if (deferred) {\n resource\n .then(deferred.resolve)\n .catch(err =>\n deferred.reject(err instanceof Error ? err : new Error(String(err))),\n )\n this.deferreds.delete(id)\n }\n\n // Resource users (e.g. materials bound to a texture id) may need to retry or refresh when\n // a creation attempt settles, even if the id string itself did not change.\n resource.then(() => this.notify(id)).catch(() => this.notify(id))\n }\n\n subscribe(id: string, listener: () => void): () => void {\n const listeners = this.listeners.get(id) ?? new Set<() => void>()\n listeners.add(listener)\n this.listeners.set(id, listeners)\n\n return () => {\n listeners.delete(listener)\n if (listeners.size === 0) {\n this.listeners.delete(id)\n }\n }\n }\n\n notify(id: string): void {\n const listeners = this.listeners.get(id)\n if (!listeners) return\n for (const listener of Array.from(listeners)) {\n listener()\n }\n }\n\n get(id: string): Promise<SpatialObject> {\n const existing = this.resources.get(id)\n if (existing) {\n return existing\n }\n\n // Nothing registered yet — return a promise that add() will resolve (or reject on failure).\n const promise = new Promise<SpatialObject>((resolve, reject) => {\n this.deferreds.set(id, { resolve, reject })\n })\n this.resources.set(id, promise)\n return promise\n }\n\n remove(id: string): void {\n this.resources.delete(id)\n this.deferreds.delete(id)\n this.notify(id)\n }\n\n // Same as remove, but when the promise resolves, destroy the spatial object (best-effort).\n removeAndDestroy(id: string): void {\n const p = this.resources.get(id)\n if (p) {\n p.then(obj => obj.destroy()).catch(() => {})\n }\n this.resources.delete(id)\n this.deferreds.delete(id)\n this.notify(id)\n }\n\n destroy(): void {\n // Reality is tearing down: fail any waiter that never saw add().\n for (const [id, deferred] of this.deferreds) {\n deferred.reject(\n new Error(`ResourceRegistry destroyed — \"${id}\" never resolved`),\n )\n }\n this.deferreds.clear()\n\n const ids = Array.from(this.resources.keys())\n for (const id of ids) {\n this.notify(id)\n }\n this.listeners.clear()\n\n const pending = Array.from(this.resources.values())\n this.resources.clear()\n // Destroy runs when each creation promise settles — may finish after React unmount; still\n // required so native objects are released. Failures/no-ops are swallowed per promise.\n void Promise.allSettled(pending.map(p => p.then(obj => obj.destroy())))\n }\n}\n","export function shallowEqualVec3(\n a?: { x: number; y: number; z: number },\n b?: { x: number; y: number; z: number },\n) {\n if (a === b) return true\n if (!a || !b) return false\n return a.x === b.x && a.y === b.y && a.z === b.z\n}\n\nexport function shallowEqualRotation(a?: any, b?: any) {\n if (a === b) return true\n if (!a || !b) return false\n // support Vec3 / Vec4\n return (\n a.x === b.x && a.y === b.y && a.z === b.z && ('w' in a ? a.w === b.w : true)\n )\n}\n\nexport function shallowEqualObject(\n a?: Record<string, any>,\n b?: Record<string, any>,\n) {\n if (a === b) return true\n if (!a || !b) return false\n const keysA = Object.keys(a)\n const keysB = Object.keys(b)\n if (keysA.length !== keysB.length) return false\n return keysA.every(key => a[key] === b[key])\n}\n\nexport function shallowEqualArray(a?: any[], b?: any[]) {\n if (a === b) return true\n if (!a || !b) return false\n if (a.length !== b.length) return false\n return a.every((val, i) => val === b[i])\n}\n","export class AbortResourceManager {\n private resources: { destroy: () => Promise<void> | void }[] = []\n private aborted = false\n\n constructor(signal: AbortSignal) {\n signal.addEventListener('abort', () => {\n this.aborted = true\n void this.dispose()\n })\n }\n\n async addResource<T extends { destroy: () => Promise<void> | void }>(\n factory: () => Promise<T>,\n ): Promise<T> {\n if (this.aborted) throw new DOMException('Aborted', 'AbortError')\n const resource = await factory()\n if (this.aborted) {\n await resource.destroy()\n throw new DOMException('Aborted', 'AbortError')\n }\n this.resources.push(resource)\n return resource\n }\n\n async dispose() {\n const resources = this.resources.splice(0)\n for (const r of resources) {\n try {\n await r.destroy()\n } catch (e) {\n console.error('AbortResourceManager dispose error:', e, r)\n }\n }\n }\n}\n","import React, { useEffect, useRef } from 'react'\nimport {\n EntityEventHandler,\n eventMap,\n SpatialDragEntityEvent,\n SpatialMagnifyEntityEvent,\n SpatialRotateEntityEvent,\n SpatialDragStartEntityEvent,\n SpatialTapEntityEvent,\n} from '../type'\nimport { EntityRef } from './useEntityRef'\nimport { SpatialEntity } from '@webspatial/core-sdk'\n\nfunction createEventProxy(ev: any, instance: EntityRef) {\n return new Proxy(ev, {\n get(target, prop: PropertyKey) {\n // Align with W3C: currentTarget is the listener owner\n if (prop === 'currentTarget') {\n return instance\n }\n // Align with W3C: target is the original dispatch target\n if (prop === 'target') {\n const origin = (target as any).__origin as SpatialEntity | undefined\n if (origin) {\n // Create a lightweight EntityRef for original target\n return new EntityRef(origin, null)\n }\n // Fallback: if origin not set, return current instance\n return instance\n }\n if (prop === 'bubbles') {\n return true\n }\n if (prop === 'offsetX') {\n const type = (target as any).type\n if (type === 'spatialtap') {\n return (target as SpatialTapEntityEvent).detail?.location3D?.x ?? 0\n }\n if (type === 'spatialdragstart') {\n return (\n (target as SpatialDragStartEntityEvent).detail?.startLocation3D\n ?.x ?? 0\n )\n }\n return undefined\n }\n if (prop === 'offsetY') {\n const type = (target as any).type\n if (type === 'spatialtap') {\n return (target as SpatialTapEntityEvent).detail?.location3D?.y ?? 0\n }\n if (type === 'spatialdragstart') {\n return (\n (target as SpatialDragStartEntityEvent).detail?.startLocation3D\n ?.y ?? 0\n )\n }\n return undefined\n }\n if (prop === 'offsetZ') {\n const type = (target as any).type\n if (type === 'spatialtap') {\n return (target as any).detail?.location3D?.z ?? 0\n }\n if (type === 'spatialdragstart') {\n return (target as any).detail?.startLocation3D?.z ?? 0\n }\n return undefined\n }\n if (prop === 'translationX') {\n const type = (target as any).type\n if (type === 'spatialdrag') {\n return (\n (target as SpatialDragEntityEvent).detail?.translation3D?.x ?? 0\n )\n }\n return undefined\n }\n if (prop === 'translationY') {\n const type = (target as any).type\n if (type === 'spatialdrag') {\n return (\n (target as SpatialDragEntityEvent).detail?.translation3D?.y ?? 0\n )\n }\n return undefined\n }\n if (prop === 'translationZ') {\n const type = (target as any).type\n if (type === 'spatialdrag') {\n return (\n (target as SpatialDragEntityEvent).detail?.translation3D?.z ?? 0\n )\n }\n return undefined\n }\n if (prop === 'quaternion') {\n const type = (target as any).type\n if (type === 'spatialrotate') {\n return (\n (target as SpatialRotateEntityEvent).detail?.quaternion ?? {\n x: 0,\n y: 0,\n z: 0,\n w: 1,\n }\n )\n }\n return undefined\n }\n if (prop === 'magnification') {\n const type = (target as any).type\n if (type === 'spatialmagnify') {\n return (\n (target as SpatialMagnifyEntityEvent).detail?.magnification ?? 1\n )\n }\n return undefined\n }\n if (prop === 'clientX') {\n const type = (target as any).type\n if (type === 'spatialtap' || type === 'spatialdragstart') {\n return (\n (target as SpatialTapEntityEvent).detail?.globalLocation3D?.x ?? 0\n )\n }\n\n return undefined\n }\n if (prop === 'clientY') {\n const type = (target as any).type\n if (type === 'spatialtap' || type === 'spatialdragstart') {\n return (\n (target as SpatialTapEntityEvent).detail?.globalLocation3D?.y ?? 0\n )\n }\n\n return undefined\n }\n if (prop === 'clientZ') {\n const type = (target as any).type\n if (type === 'spatialtap' || type === 'spatialdragstart') {\n return (\n (target as SpatialTapEntityEvent).detail?.globalLocation3D?.z ?? 0\n )\n }\n\n return undefined\n }\n const val = (target as any)[prop]\n return typeof val === 'function' ? val.bind(target) : val\n },\n })\n}\n\ntype Props = {\n instance: EntityRef\n} & EntityEventHandler\nexport const useEntityEvent: React.FC<Props> = ({ instance, ...handlers }) => {\n const eventsSetRef = useRef<Set<string>>(new Set())\n\n useEffect(() => {\n const entity = instance.entity\n if (!entity) return\n\n Object.entries(eventMap).forEach(([reactKey, spatialEvent]) => {\n // add/update handler\n const handlerFn = (handlers as any)[reactKey]\n if (!handlerFn) return\n const wrapped = (ev: any) => handlerFn(createEventProxy(ev, instance))\n entity.addEvent(spatialEvent, wrapped)\n eventsSetRef.current.add(reactKey)\n })\n return () => {}\n }, [instance.entity, ...Object.values(handlers)])\n\n useEffect(() => {\n const entity = instance.entity\n if (!entity) return\n\n return () => {\n // remove all\n for (let x of eventsSetRef.current) {\n entity.removeEvent(x as any)\n }\n eventsSetRef.current.clear()\n }\n }, [instance.entity])\n\n return null\n}\n","import type { Quaternion, Vec3 } from '@webspatial/core-sdk'\nimport { EntityRefShape } from './hooks'\nimport { SpatialTapEvent as CoreSpatialTapEvent } from '@webspatial/core-sdk'\nimport { SpatialDragStartEvent as CoreSpatialDragStartEvent } from '@webspatial/core-sdk'\nimport { SpatialDragEvent as CoreSpatialDragEvent } from '@webspatial/core-sdk'\nimport { SpatialDragEndEvent as CoreSpatialDragEndEvent } from '@webspatial/core-sdk'\nimport { SpatialRotateEvent as CoreSpatialRotateEvent } from '@webspatial/core-sdk'\nimport { SpatialRotateEndEvent as CoreSpatialRotateEndEvent } from '@webspatial/core-sdk'\nimport { SpatialMagnifyEvent as CoreSpatialMagnifyEvent } from '@webspatial/core-sdk'\nimport { SpatialMagnifyEndEvent as CoreSpatialMagnifyEndEvent } from '@webspatial/core-sdk'\nimport { SpatialEventOptions } from '..'\n\nexport type EntityProps = {\n id?: string\n name?: string\n position?: Vec3\n rotation?: Vec3\n scale?: Vec3\n enableInput?: boolean\n}\n\ntype allTarget<T extends EntityRefShape> = {\n target: T\n currentTarget: T\n}\n// tap\nexport type SpatialTapEntityEvent<T extends EntityRefShape = EntityRefShape> =\n CoreSpatialTapEvent &\n allTarget<T> & {\n readonly offsetX: number\n readonly offsetY: number\n readonly offsetZ: number\n readonly clientX: number\n readonly clientY: number\n readonly clientZ: number\n }\n\n// drag\nexport type SpatialDragStartEntityEvent<\n T extends EntityRefShape = EntityRefShape,\n> = CoreSpatialDragStartEvent &\n allTarget<T> & {\n readonly offsetX: number\n readonly offsetY: number\n readonly offsetZ: number\n readonly clientX: number\n readonly clientY: number\n readonly clientZ: number\n }\n\nexport type SpatialDragEntityEvent<T extends EntityRefShape = EntityRefShape> =\n CoreSpatialDragEvent &\n allTarget<T> & {\n readonly translationX: number\n readonly translationY: number\n readonly translationZ: number\n }\n\nexport type SpatialDragEndEntityEvent<\n T extends EntityRefShape = EntityRefShape,\n> = CoreSpatialDragEndEvent & allTarget<T>\n// rotate\nexport type SpatialRotateEntityEvent<\n T extends EntityRefShape = EntityRefShape,\n> = CoreSpatialRotateEvent &\n allTarget<T> & {\n readonly quaternion: Quaternion\n }\nexport type SpatialRotateEndEntityEvent<\n T extends EntityRefShape = EntityRefShape,\n> = CoreSpatialRotateEndEvent & allTarget<T>\n// magnify\nexport type SpatialMagnifyEntityEvent<\n T extends EntityRefShape = EntityRefShape,\n> = CoreSpatialMagnifyEvent &\n allTarget<T> & {\n readonly magnification: number\n }\nexport type SpatialMagnifyEndEntityEvent<\n T extends EntityRefShape = EntityRefShape,\n> = CoreSpatialMagnifyEndEvent & allTarget<T>\n\nexport type EntityEventHandler = {\n // tap\n onSpatialTap?: (event: SpatialTapEntityEvent) => void\n // drag\n onSpatialDragStart?: (event: SpatialDragStartEntityEvent) => void\n onSpatialDrag?: (event: SpatialDragEntityEvent) => void\n onSpatialDragEnd?: (event: SpatialDragEndEntityEvent) => void\n // rotate\n spatialEventOptions?: SpatialEventOptions\n onSpatialRotate?: (event: SpatialRotateEntityEvent) => void\n onSpatialRotateEnd?: (event: SpatialRotateEndEntityEvent) => void\n // magnify\n onSpatialMagnify?: (event: SpatialMagnifyEntityEvent) => void\n onSpatialMagnifyEnd?: (event: SpatialMagnifyEndEntityEvent) => void\n}\n\nexport const eventMap = {\n // tap\n onSpatialTap: 'spatialtap',\n // drag\n onSpatialDragStart: 'spatialdragstart',\n onSpatialDrag: 'spatialdrag',\n onSpatialDragEnd: 'spatialdragend',\n // rotate\n onSpatialRotate: 'spatialrotate',\n onSpatialRotateEnd: 'spatialrotateend',\n // magnify\n onSpatialMagnify: 'spatialmagnify',\n onSpatialMagnifyEnd: 'spatialmagnifyend',\n} as const\n","import { useImperativeHandle } from 'react'\nimport { Vec3, SpatialEntity } from '@webspatial/core-sdk'\nimport { RealityContextValue } from '../context'\n\nexport interface EntityRefShape {\n convertFromEntityToEntity: (\n fromEntityId: string,\n toEntityId: string,\n position: Vec3,\n ) => Promise<Vec3>\n convertFromEntityToReality: (\n entityId: string,\n position: Vec3,\n ) => Promise<Vec3>\n convertFromRealityToEntity: (\n entityId: string,\n position: Vec3,\n ) => Promise<Vec3>\n id: string | undefined\n name: string | undefined\n entity: SpatialEntity | null\n}\n\nexport const useEntityRef = (\n ref: React.Ref<EntityRefShape>,\n instance: EntityRef,\n) => {\n useImperativeHandle(ref, () => instance)\n}\n\nexport class EntityRef implements EntityRefShape {\n private _entity: SpatialEntity | null\n private _ctx: RealityContextValue | null\n\n constructor(\n entity: SpatialEntity | null = null,\n ctx: RealityContextValue | null = null,\n ) {\n this._entity = entity\n this._ctx = ctx\n }\n\n updateEntity(entity?: SpatialEntity | null) {\n if (entity) this._entity = entity\n }\n\n updateCtx(ctx?: RealityContextValue | null) {\n if (ctx) this._ctx = ctx\n }\n\n destroy() {\n this._entity?.destroy()\n }\n\n get entity() {\n return this._entity\n }\n get id() {\n return this._entity?.userData?.id\n }\n get name() {\n return this._entity?.userData?.name\n }\n\n async convertFromEntityToEntity(\n fromEntityId: string,\n toEntityId: string,\n position: Vec3,\n ): Promise<Vec3> {\n if (!this._entity) return position\n try {\n const fromEnt = await this._ctx?.resourceRegistry.get(fromEntityId)\n const toEnt = await this._ctx?.resourceRegistry.get(toEntityId)\n if (!fromEnt || !toEnt) return position\n const ret = await this._entity.convertFromEntityToEntity(\n fromEnt.id,\n toEnt.id,\n position,\n )\n return ret?.data ?? position\n } catch {\n return position\n }\n }\n\n async convertFromEntityToReality(\n entityId: string,\n position: Vec3,\n ): Promise<Vec3> {\n if (!this._entity) return position\n try {\n const ent = await this._ctx?.resourceRegistry.get(entityId)\n if (!ent) return position\n const ret = await this._entity.convertFromEntityToScene(ent.id, position)\n return ret?.data ?? position\n } catch {\n return position\n }\n }\n\n async convertFromRealityToEntity(\n entityId: string,\n position: Vec3,\n ): Promise<Vec3> {\n if (!this._entity) return position\n try {\n const ent = await this._ctx?.resourceRegistry.get(entityId)\n if (!ent) return position\n const ret = await this._entity.convertFromSceneToEntity(ent.id, position)\n return ret?.data ?? position\n } catch {\n return position\n }\n }\n}\n\nexport function createEntityRefProxy(\n entity: SpatialEntity | null,\n ctx?: RealityContextValue | null,\n): EntityRefShape {\n return new EntityRef(entity, ctx)\n}\n","import { useEffect, useRef } from 'react'\nimport {\n EntityEventHandler,\n eventMap,\n SpatialDragEntityEvent,\n SpatialMagnifyEntityEvent,\n SpatialRotateEntityEvent,\n SpatialDragStartEntityEvent,\n SpatialTapEntityEvent,\n} from '../type'\nimport {\n SpatializedDynamic3DElement,\n SpatialEntity,\n} from '@webspatial/core-sdk'\nimport { EntityRef } from './useEntityRef'\n\nfunction createEventProxy(ev: any, instance: any) {\n return new Proxy(ev, {\n get(target, prop: PropertyKey) {\n // Align with W3C: currentTarget is the listener owner\n if (prop === 'currentTarget') {\n return instance\n }\n // Align with W3C: target is the original dispatch target\n if (prop === 'target') {\n const origin = (target as any).__origin as SpatialEntity | undefined\n if (origin) {\n // Create a lightweight EntityRef for original target\n return new EntityRef(origin, null)\n }\n // Fallback: if origin not set, return current instance\n return instance\n }\n if (prop === 'bubbles') {\n return true\n }\n if (prop === 'offsetX') {\n const type = (target as any).type\n if (type === 'spatialtap') {\n return (target as SpatialTapEntityEvent).detail?.location3D?.x ?? 0\n }\n if (type === 'spatialdragstart') {\n return (\n (target as SpatialDragStartEntityEvent).detail?.startLocation3D\n ?.x ?? 0\n )\n }\n return undefined\n }\n if (prop === 'offsetY') {\n const type = (target as any).type\n if (type === 'spatialtap') {\n return (target as SpatialTapEntityEvent).detail?.location3D?.y ?? 0\n }\n if (type === 'spatialdragstart') {\n return (\n (target as SpatialDragStartEntityEvent).detail?.startLocation3D\n ?.y ?? 0\n )\n }\n return undefined\n }\n if (prop === 'offsetZ') {\n const type = (target as any).type\n if (type === 'spatialtap') {\n return (target as any).detail?.location3D?.z ?? 0\n }\n if (type === 'spatialdragstart') {\n return (target as any).detail?.startLocation3D?.z ?? 0\n }\n return undefined\n }\n if (prop === 'translationX') {\n const type = (target as any).type\n if (type === 'spatialdrag') {\n return (\n (target as SpatialDragEntityEvent).detail?.translation3D?.x ?? 0\n )\n }\n return undefined\n }\n if (prop === 'translationY') {\n const type = (target as any).type\n if (type === 'spatialdrag') {\n return (\n (target as SpatialDragEntityEvent).detail?.translation3D?.y ?? 0\n )\n }\n return undefined\n }\n if (prop === 'translationZ') {\n const type = (target as any).type\n if (type === 'spatialdrag') {\n return (\n (target as SpatialDragEntityEvent).detail?.translation3D?.z ?? 0\n )\n }\n return undefined\n }\n if (prop === 'quaternion') {\n const type = (target as any).type\n if (type === 'spatialrotate') {\n return (\n (target as SpatialRotateEntityEvent).detail?.quaternion ?? {\n x: 0,\n y: 0,\n z: 0,\n w: 1,\n }\n )\n }\n return undefined\n }\n if (prop === 'magnification') {\n const type = (target as any).type\n if (type === 'spatialmagnify') {\n return (\n (target as SpatialMagnifyEntityEvent).detail?.magnification ?? 1\n )\n }\n return undefined\n }\n if (prop === 'clientX') {\n const type = (target as any).type\n if (type === 'spatialtap' || type === 'spatialdragstart') {\n return (\n (target as SpatialTapEntityEvent).detail?.globalLocation3D?.x ?? 0\n )\n }\n\n return undefined\n }\n if (prop === 'clientY') {\n const type = (target as any).type\n if (type === 'spatialtap' || type === 'spatialdragstart') {\n return (\n (target as SpatialTapEntityEvent).detail?.globalLocation3D?.y ?? 0\n )\n }\n\n return undefined\n }\n if (prop === 'clientZ') {\n const type = (target as any).type\n if (type === 'spatialtap' || type === 'spatialdragstart') {\n return (\n (target as SpatialTapEntityEvent).detail?.globalLocation3D?.z ?? 0\n )\n }\n\n return undefined\n }\n const val = (target as any)[prop]\n return typeof val === 'function' ? val.bind(target) : val\n },\n })\n}\n\ntype Props = {\n instance: SpatializedDynamic3DElement | null\n} & EntityEventHandler\n\n/**\n * useRealityEvents is a hook that manages spatial events for a SpatializedDynamic3DElement.\n * Handlers receive CustomEvents with proxy to support common event properties.\n */\nexport const useRealityEvents = ({ instance, ...handlers }: Props) => {\n const eventsSetRef = useRef<Set<string>>(new Set())\n\n useEffect(() => {\n if (!instance) return\n\n Object.entries(eventMap).forEach(([reactKey, spatialEvent]) => {\n const handlerFn = (handlers as any)[reactKey]\n if (!handlerFn) return\n\n const wrapped = (ev: any) => handlerFn(createEventProxy(ev, instance))\n instance.addEvent(spatialEvent as any, wrapped)\n eventsSetRef.current.add(spatialEvent)\n })\n\n return () => {\n if (instance) {\n for (let x of eventsSetRef.current) {\n instance.removeEvent(x as any)\n }\n eventsSetRef.current.clear()\n }\n }\n }, [instance, ...Object.values(handlers)])\n}\n","import { SpatialEntity } from '@webspatial/core-sdk'\nimport React, { useEffect } from 'react'\nimport { useRealityContext } from '../context'\ntype Props = {\n id?: string\n entity?: SpatialEntity | null\n}\nexport const useEntityId: React.FC<Props> = ({ id, entity }) => {\n const ctx = useRealityContext()\n useEffect(() => {\n if (!id || !entity || !ctx) return\n ctx.resourceRegistry.add(id, Promise.resolve(entity))\n return () => {\n ctx.resourceRegistry.remove(id)\n }\n }, [id, entity, ctx])\n\n return null\n}\n","import { ForwardedRef, useEffect, useRef } from 'react'\nimport { SpatialEntity } from '@webspatial/core-sdk'\nimport { useRealityContext, useParentContext } from '../context'\nimport { EntityEventHandler, EntityProps } from '../type'\nimport {\n EntityRefShape,\n EntityRef,\n useEntityEvent,\n useEntityId,\n useEntityRef,\n useEntityTransform,\n useForceUpdate,\n} from '../hooks'\n\ntype UseEntityOptions = {\n createEntity: (signal: AbortSignal) => Promise<SpatialEntity>\n recreateKey?: string\n} & EntityProps &\n EntityEventHandler & { ref: ForwardedRef<EntityRefShape> }\n\nexport const useEntity = ({\n ref,\n id,\n position,\n rotation,\n scale,\n enableInput,\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n createEntity,\n recreateKey,\n}: UseEntityOptions) => {\n const ctx = useRealityContext()\n const parent = useParentContext()\n const instanceRef = useRef<EntityRef>(new EntityRef(null, ctx))\n\n const forceUpdate = useForceUpdate()\n\n useEffect(() => {\n if (!ctx) return\n\n const controller = new AbortController()\n\n const init = async () => {\n try {\n const ent = await createEntity(controller.signal)\n if (!ent) return\n if (controller.signal.aborted) {\n ent.destroy()\n return\n }\n // Apply transform before adding to scene so it never flashes at default scale\n await ent.updateTransform({ position, rotation, scale })\n if (controller.signal.aborted) {\n ent.destroy()\n return\n }\n if (parent) {\n const result = await parent.addEntity(ent)\n if (!result.success) throw new Error('parent.addEntity failed')\n } else {\n const result = await ctx.reality.addEntity(ent)\n if (!result.success) throw new Error('ctx.reality.addEntity failed')\n }\n\n instanceRef.current?.updateEntity(ent)\n forceUpdate()\n } catch (error) {\n console.error('useEntity init ~ error:', error)\n }\n }\n\n init()\n\n return () => {\n controller.abort()\n instanceRef.current?.destroy()\n }\n }, [ctx, parent, recreateKey])\n\n useEntityId({ id, entity: instanceRef.current.entity })\n useEntityTransform(instanceRef.current.entity, { position, rotation, scale })\n useEntityRef(ref, instanceRef.current)\n\n useEntityEvent({\n instance: instanceRef.current,\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n })\n\n useEffect(() => {\n const ent = instanceRef.current.entity\n if (!ent) return\n if (enableInput !== undefined) {\n ent.enableInput = !!enableInput\n }\n }, [instanceRef.current.entity, enableInput])\n\n return instanceRef.current.entity\n}\n","import { useCallback, useState } from 'react'\nexport const useForceUpdate = () => {\n const [, setTick] = useState(0)\n return useCallback(() => setTick(tick => tick + 1), [])\n}\n","import React, { forwardRef } from 'react'\nimport { EntityProps } from '../type'\nimport { EntityRefShape } from '../hooks'\nimport { SpatialBoxGeometryOptions } from '@webspatial/core-sdk'\nimport { GeometryEntity } from './GeometryEntity'\nimport { useRealityContext } from '../context'\n\ntype BoxEntityProps = EntityProps & {\n children?: React.ReactNode\n materials?: string[]\n} & SpatialBoxGeometryOptions\n\nexport const BoxEntity = forwardRef<EntityRefShape, BoxEntityProps>(\n ({ children, ...props }, ref) => {\n const ctx = useRealityContext()\n return (\n <GeometryEntity\n {...props}\n ref={ref}\n createGeometry={options => ctx!.session.createBoxGeometry(options)}\n geometryOptions={{\n width: props.width,\n height: props.height,\n depth: props.depth,\n cornerRadius: props.cornerRadius,\n splitFaces: props.splitFaces,\n }}\n >\n {children}\n </GeometryEntity>\n )\n },\n)\n","import React, { forwardRef, useEffect, useRef } from 'react'\nimport { EntityProps, EntityEventHandler } from '../type'\nimport { EntityRefShape } from '../hooks'\nimport {\n SpatialMaterial,\n SpatialGeometry,\n SpatialComponent,\n SpatialEntity,\n} from '@webspatial/core-sdk'\nimport { AbortResourceManager } from '../utils'\nimport { shallowEqualObject, shallowEqualArray } from '../utils'\nimport { BaseEntity } from './BaseEntity'\nimport { useRealityContext } from '../context'\n\ntype GeometryEntityProps = EntityProps &\n EntityEventHandler & {\n children?: React.ReactNode\n materials?: string[]\n geometryOptions: any\n createGeometry: (options: any) => Promise<SpatialGeometry>\n }\n\ntype LastGeometrySnapshot = {\n geometryOptions: any\n materials: string[] | undefined\n}\n\ntype GeometryEntityMutable = {\n lastSnapshot: LastGeometrySnapshot | null\n rebuildGen: number\n}\n\nexport const GeometryEntity = forwardRef<EntityRefShape, GeometryEntityProps>(\n (\n { id, children, name, materials, geometryOptions, createGeometry, ...rest },\n ref,\n ) => {\n const ctx = useRealityContext()\n const entityRef = useRef<SpatialEntity | null>(null)\n const componentRef = useRef<SpatialComponent | null>(null)\n // Tracks the last applied mesh + materials, plus a generation counter so\n // overlapping async rebuilds (e.g. fast sliders) cannot apply out of order.\n const mutableRef = useRef<GeometryEntityMutable>({\n lastSnapshot: null,\n rebuildGen: 0,\n })\n\n useEffect(() => {\n const { lastSnapshot } = mutableRef.current\n if (!ctx || !entityRef.current || lastSnapshot === null) return\n\n // Parents may pass a new options object each render with the same values;\n // shallow compare avoids ripping down the mesh when nothing meaningful changed.\n const geometryChanged = !shallowEqualObject(\n lastSnapshot.geometryOptions,\n geometryOptions,\n )\n const materialsChanged = !shallowEqualArray(\n lastSnapshot.materials,\n materials,\n )\n\n if (!geometryChanged && !materialsChanged) return\n\n mutableRef.current.lastSnapshot = { geometryOptions, materials }\n mutableRef.current.rebuildGen += 1\n const gen = mutableRef.current.rebuildGen\n\n const rebuild = async () => {\n const entity = entityRef.current\n if (!entity) return\n\n try {\n const oldComponent = componentRef.current\n if (oldComponent) {\n // TODO(P2): Rebuild removes/destroys the model component but not the previous mesh\n // `SpatialGeometry`; those objects stay registered until explicitly destroyed (native\n // `SpatialModelComponent.onDestroy` also only nils `mesh`). Destroy the prior mesh after\n // teardown or fix cascade destroy on the Swift side to cap memory on long-lived updates.\n await entity.removeComponent(oldComponent)\n await oldComponent.destroy()\n componentRef.current = null\n if (gen !== mutableRef.current.rebuildGen) return\n }\n\n const geometry = await createGeometry(geometryOptions)\n // A newer rebuild started; drop this mesh so it is not left orphaned.\n if (gen !== mutableRef.current.rebuildGen) {\n await geometry.destroy()\n return\n }\n\n const materialList = (await Promise.all(\n materials\n ?.map(mid => ctx.resourceRegistry.get(mid))\n .filter(Boolean) ?? [],\n )) as SpatialMaterial[]\n if (gen !== mutableRef.current.rebuildGen) {\n await geometry.destroy()\n return\n }\n\n const modelComponent = await ctx.session.createModelComponent({\n mesh: geometry,\n materials: materialList,\n })\n if (gen !== mutableRef.current.rebuildGen) {\n await modelComponent.destroy()\n await geometry.destroy()\n return\n }\n\n await entity.addComponent(modelComponent)\n componentRef.current = modelComponent\n } catch (error) {\n if (gen === mutableRef.current.rebuildGen) {\n console.error('GeometryEntity: rebuild failed', error)\n }\n }\n }\n rebuild()\n }, [ctx, geometryOptions, materials, createGeometry])\n\n return (\n <BaseEntity\n {...rest}\n id={id}\n ref={ref}\n createEntity={async (ctx, signal) => {\n const manager = new AbortResourceManager(signal)\n try {\n const ent = await manager.addResource(() =>\n ctx!.session.createEntity({ id, name }),\n )\n\n const geometry = await manager.addResource(() =>\n createGeometry(geometryOptions),\n )\n\n const materialList = (await Promise.all(\n materials\n ?.map(id => ctx!.resourceRegistry.get(id))\n .filter(Boolean) ?? [],\n )) as SpatialMaterial[]\n const modelComponent = await manager.addResource(() =>\n ctx!.session.createModelComponent({\n mesh: geometry,\n materials: materialList,\n }),\n )\n\n await ent.addComponent(modelComponent)\n\n entityRef.current = ent\n componentRef.current = modelComponent\n mutableRef.current.lastSnapshot = { geometryOptions, materials }\n\n return ent\n } catch (error) {\n await manager.dispose()\n return null as any\n }\n }}\n >\n {children}\n </BaseEntity>\n )\n },\n)\n","import React, { useEffect, useRef, useState } from 'react'\nimport {\n SpatialUnlitMaterial,\n SpatialUnlitMaterialOptions,\n} from '@webspatial/core-sdk'\nimport { useRealityContext } from '../context'\n\nexport type UnlitMaterialProps = {\n children?: React.ReactNode\n id: string // user id\n} & SpatialUnlitMaterialOptions\n\nexport const UnlitMaterial: React.FC<UnlitMaterialProps> = ({\n children,\n ...options\n}) => {\n const ctx = useRealityContext()\n const materialRef = useRef<SpatialUnlitMaterial | undefined>(undefined)\n const isInitializedRef = useRef(false)\n const [textureRevision, setTextureRevision] = useState(0)\n\n useEffect(() => {\n if (!ctx || !options.textureId) return\n return ctx.resourceRegistry.subscribe(options.textureId, () => {\n setTextureRevision(v => v + 1)\n })\n }, [ctx, options.textureId])\n\n useEffect(() => {\n if (!ctx) return\n let cancelled = false\n const materialId = options.id\n const { session, resourceRegistry } = ctx\n const init = async () => {\n try {\n let textureIdForNative: string | undefined = options.textureId\n if (options.textureId) {\n const texturePromise = resourceRegistry.get(options.textureId)\n try {\n const textureResource = await texturePromise\n if (cancelled) return\n textureIdForNative = textureResource.id\n } catch {\n // Texture failed: still create material so entities do not hang on materialId;\n // tint-only / no texture until the texture resolves.\n textureIdForNative = ''\n }\n }\n if (cancelled) return\n const commandOptions: SpatialUnlitMaterialOptions = {\n color: options.color,\n textureId: textureIdForNative,\n transparent: options.transparent,\n opacity: options.opacity,\n }\n const materialPromise = session.createUnlitMaterial(commandOptions)\n resourceRegistry.add(materialId, materialPromise)\n const mat = await materialPromise\n if (cancelled) return\n materialRef.current = mat\n isInitializedRef.current = true\n } catch (error) {\n console.error(' ~ UnlitMaterial ~ error:', error)\n }\n }\n init()\n\n return () => {\n cancelled = true\n // Use registry to schedule destruction after promise resolves\n resourceRegistry.removeAndDestroy(materialId)\n materialRef.current = undefined\n isInitializedRef.current = false\n }\n }, [ctx, options.id])\n\n // Dynamic property updates\n useEffect(() => {\n if (!ctx || !isInitializedRef.current || !materialRef.current) return\n let cancelled = false\n void (async () => {\n const updates: Partial<SpatialUnlitMaterialOptions> = {}\n if (options.color !== undefined) updates.color = options.color\n if (options.transparent !== undefined)\n updates.transparent = options.transparent\n if (options.opacity !== undefined) updates.opacity = options.opacity\n if (options.textureId !== undefined) {\n if (options.textureId === '') {\n updates.textureId = ''\n } else {\n const texturePromise = ctx.resourceRegistry.get(options.textureId)\n try {\n const textureResource = await texturePromise\n if (cancelled) return\n updates.textureId = textureResource.id\n } catch {\n updates.textureId = ''\n }\n }\n }\n if (cancelled || Object.keys(updates).length === 0) return\n const mat = materialRef.current\n if (mat) {\n void mat.updateProperties(updates).catch(() => {})\n }\n })()\n return () => {\n cancelled = true\n }\n }, [\n ctx,\n options.color,\n options.textureId,\n options.transparent,\n options.opacity,\n textureRevision,\n ])\n\n return null\n}\n","import React, { useEffect, useRef } from 'react'\nimport { SpatialTextureResource } from '@webspatial/core-sdk'\nimport { useRealityContext } from '../context'\nimport { getAbsoluteUrl } from '../../utils/urlUtils'\n\nexport type TextureProps = {\n children?: React.ReactNode\n id: string\n url: string\n onLoad?: () => void\n onError?: (error: unknown) => void\n}\n\nexport const Texture: React.FC<TextureProps> = ({\n children,\n id,\n url,\n onLoad,\n onError,\n}) => {\n const ctx = useRealityContext()\n const textureRef = useRef<SpatialTextureResource | null>(null)\n const urlRevisionRef = useRef(0)\n\n // Destroy only when the logical texture slot (ctx + id) goes away — not on url changes.\n useEffect(() => {\n if (!ctx) return\n const { resourceRegistry } = ctx\n const capturedId = id\n return () => {\n textureRef.current = null\n resourceRegistry.removeAndDestroy(capturedId)\n }\n }, [ctx, id])\n\n // Initial load and subsequent URL changes: keep the same native texture and use\n // updateProperties({ url }) so materials bound by native id stay valid.\n useEffect(() => {\n if (!ctx) return\n const { session, resourceRegistry } = ctx\n const revision = ++urlRevisionRef.current\n let cancelled = false\n\n void (async () => {\n const resolvedUrl = getAbsoluteUrl(url)\n try {\n if (textureRef.current) {\n await textureRef.current.updateProperties({ url: resolvedUrl })\n\n if (cancelled || revision !== urlRevisionRef.current) return\n\n resourceRegistry.notify(id)\n onLoad?.()\n return\n }\n\n const texturePromise = session.createTexture({ url: resolvedUrl })\n resourceRegistry.add(id, texturePromise)\n\n const tex = await texturePromise\n\n if (cancelled || revision !== urlRevisionRef.current) {\n tex.destroy()\n return\n }\n\n textureRef.current = tex\n onLoad?.()\n } catch (error: unknown) {\n if (cancelled || revision !== urlRevisionRef.current) return\n onError?.(error)\n }\n })()\n\n return () => {\n cancelled = true\n }\n }, [ctx, id, url])\n\n return null\n}\n","import React, { forwardRef } from 'react'\nimport { EntityProps } from '../type'\nimport { EntityRefShape } from '../hooks'\nimport { SpatialSphereGeometryOptions } from '@webspatial/core-sdk'\nimport { GeometryEntity } from './GeometryEntity'\nimport { useRealityContext } from '../context'\n\ntype SphereEntityProps = EntityProps & {\n children?: React.ReactNode\n materials?: string[]\n} & SpatialSphereGeometryOptions\n\nexport const SphereEntity = forwardRef<EntityRefShape, SphereEntityProps>(\n ({ children, ...props }, ref) => {\n const ctx = useRealityContext()\n return (\n <GeometryEntity\n {...props}\n ref={ref}\n createGeometry={options => ctx!.session.createSphereGeometry(options)}\n geometryOptions={{\n radius: props.radius,\n }}\n >\n {children}\n </GeometryEntity>\n )\n },\n)\n","import React, { forwardRef } from 'react'\nimport { EntityProps } from '../type'\nimport { EntityRefShape } from '../hooks'\nimport { SpatialConeGeometryOptions } from '@webspatial/core-sdk'\nimport { GeometryEntity } from './GeometryEntity'\nimport { useRealityContext } from '../context'\n\ntype ConeEntityProps = EntityProps & {\n children?: React.ReactNode\n materials?: string[]\n} & SpatialConeGeometryOptions\n\nexport const ConeEntity = forwardRef<EntityRefShape, ConeEntityProps>(\n ({ children, ...props }, ref) => {\n const ctx = useRealityContext()\n return (\n <GeometryEntity\n {...props}\n ref={ref}\n createGeometry={options => ctx!.session.createConeGeometry(options)}\n geometryOptions={{\n radius: props.radius,\n height: props.height,\n }}\n >\n {children}\n </GeometryEntity>\n )\n },\n)\n","import React, { forwardRef } from 'react'\nimport { EntityProps } from '../type'\nimport { EntityRefShape } from '../hooks'\nimport { SpatialCylinderGeometryOptions } from '@webspatial/core-sdk'\nimport { GeometryEntity } from './GeometryEntity'\nimport { useRealityContext } from '../context'\n\ntype CylinderEntityProps = EntityProps & {\n children?: React.ReactNode\n materials?: string[]\n} & SpatialCylinderGeometryOptions\n\nexport const CylinderEntity = forwardRef<EntityRefShape, CylinderEntityProps>(\n ({ children, ...props }, ref) => {\n const ctx = useRealityContext()\n return (\n <GeometryEntity\n {...props}\n ref={ref}\n createGeometry={options => ctx!.session.createCylinderGeometry(options)}\n geometryOptions={{\n radius: props.radius,\n height: props.height,\n }}\n >\n {children}\n </GeometryEntity>\n )\n },\n)\n","import React, { forwardRef } from 'react'\nimport { EntityProps } from '../type'\nimport { EntityRefShape } from '../hooks'\nimport { SpatialPlaneGeometryOptions } from '@webspatial/core-sdk'\nimport { GeometryEntity } from './GeometryEntity'\nimport { useRealityContext } from '../context'\n\ntype PlaneEntityProps = EntityProps & {\n children?: React.ReactNode\n materials?: string[]\n} & SpatialPlaneGeometryOptions\n\nexport const PlaneEntity = forwardRef<EntityRefShape, PlaneEntityProps>(\n ({ children, ...props }, ref) => {\n const ctx = useRealityContext()\n return (\n <GeometryEntity\n {...props}\n ref={ref}\n createGeometry={options => ctx!.session.createPlaneGeometry(options)}\n geometryOptions={{\n width: props.width,\n height: props.height,\n cornerRadius: props.cornerRadius,\n }}\n >\n {children}\n </GeometryEntity>\n )\n },\n)\n","import React from 'react'\nimport { ParentContext } from '../context'\ntype Props = {\n children?: React.ReactNode\n}\nexport const SceneGraph: React.FC<Props> = ({ children }) => {\n return (\n <ParentContext.Provider value={null}>{children}</ParentContext.Provider>\n )\n}\n","import React, { useEffect, useRef } from 'react'\nimport { useRealityContext } from '../context'\nimport { SpatialModelAsset } from '@webspatial/core-sdk'\nimport { getAbsoluteUrl } from '../../utils/urlUtils'\n\ntype Props = {\n children?: React.ReactNode\n id: string // user id\n src: string // model url\n onLoad?: () => void\n onError?: (error: unknown) => void\n}\n\nexport const ModelAsset: React.FC<Props> = ({ children, ...options }) => {\n const ctx = useRealityContext()\n const materialRef = useRef<SpatialModelAsset | undefined>(undefined)\n useEffect(() => {\n const controller = new AbortController()\n if (!ctx) return\n const { session, resourceRegistry } = ctx\n const init = async () => {\n try {\n const resolvedUrl = getAbsoluteUrl(options.src)\n const modelAssetPromise = session.createModelAsset({ url: resolvedUrl })\n resourceRegistry.add(options.id, modelAssetPromise)\n\n const mat = await modelAssetPromise\n if (controller.signal.aborted) {\n mat.destroy()\n return\n }\n materialRef.current = mat\n options.onLoad?.()\n } catch (error: any) {\n options.onError?.(error)\n }\n }\n init()\n\n return () => {\n controller.abort()\n materialRef.current?.destroy()\n }\n }, [ctx])\n\n return null\n}\n","import React, { forwardRef, useEffect, useRef } from 'react'\nimport {\n SpatialMaterial,\n SpatialModelEntity as CoreSpatialModelEntity,\n} from '@webspatial/core-sdk'\nimport { EntityProps, EntityEventHandler } from '../type'\nimport { EntityRefShape } from '../hooks'\nimport { BaseEntity } from './BaseEntity'\nimport { useRealityContext } from '../context'\nimport { shallowEqualArray } from '../utils'\n\ntype Props = EntityProps & {\n model: string\n materials?: string[]\n} & EntityEventHandler & {\n children?: React.ReactNode\n }\n\nexport const ModelEntity = forwardRef<EntityRefShape, Props>(\n ({ id, model, children, name, materials, ...rest }, ref) => {\n const ctx = useRealityContext()\n const entityRef = useRef<CoreSpatialModelEntity | null>(null)\n const lastMaterialsRef = useRef<string[] | undefined>(undefined)\n\n // TODO(P2): Material overrides run async (`Promise.all` + `setMaterials`) with no generation/abort\n // guard; a slower resolve can apply after a newer prop update and leave native materials stale vs\n // React. Mirror `rebuildGen` in GeometryEntity so only the latest apply runs after awaits.\n // Dynamic material override (including clearing: props may go from ids to undefined / [])\n useEffect(() => {\n if (!ctx || !entityRef.current) return\n const next = materials ?? []\n const prev = lastMaterialsRef.current ?? []\n if (shallowEqualArray(prev, next)) return\n lastMaterialsRef.current = next\n\n const apply = async () => {\n try {\n const materialList = (\n await Promise.all(next.map(mid => ctx.resourceRegistry.get(mid)))\n ).filter(Boolean) as SpatialMaterial[]\n if (entityRef.current) {\n await entityRef.current.setMaterials(materialList)\n }\n } catch (error) {\n console.error('ModelEntity: failed to set materials', error)\n }\n }\n apply()\n }, [ctx, materials])\n\n return (\n <BaseEntity\n {...rest}\n id={id}\n ref={ref}\n recreateKey={model}\n createEntity={async (ctx, signal) => {\n try {\n const modelAsset = await ctx!.resourceRegistry.get(model)\n if (!modelAsset)\n throw new Error(`ModelEntity: model not found ${model}`)\n if (signal.aborted) return null as any\n\n const ent = await ctx!.session.createSpatialModelEntity(\n {\n modelAssetId: modelAsset.id,\n name,\n },\n { id, name },\n )\n entityRef.current = ent as CoreSpatialModelEntity\n\n // Apply initial materials if specified; always record baseline for later clears.\n if (materials && materials.length > 0) {\n const materialList = (\n await Promise.all(\n materials.map(mid => ctx!.resourceRegistry.get(mid)),\n )\n ).filter(Boolean) as SpatialMaterial[]\n if (materialList.length > 0 && !signal.aborted) {\n await ent.setMaterials(materialList)\n }\n }\n lastMaterialsRef.current = materials ?? []\n\n return ent\n } catch (error) {\n return null as any\n }\n }}\n >\n {children}\n </BaseEntity>\n )\n },\n)\n","import React, {\n forwardRef,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react'\nimport { SpatializedContainer } from '../../spatialized-container/SpatializedContainer'\nimport { RealityContext, RealityContextValue } from '../context'\nimport { useInsideAttachment } from '../context/InsideAttachmentContext'\nimport { getSession } from '../../utils/getSession'\nimport { ResourceRegistry } from '../utils'\nimport { AttachmentRegistry } from '../context/AttachmentContext'\nimport { SpatializedElementRef } from '../../spatialized-container/types'\nimport { SpatializedElement } from '@webspatial/core-sdk'\nimport { EntityEventHandler } from '../type'\nimport { useRealityEvents } from '../hooks'\n\nexport type RealityProps = Omit<\n React.ComponentPropsWithRef<'div'>,\n 'onSpatialContentReady'\n> &\n EntityEventHandler\n\nexport const Reality = forwardRef<SpatializedElementRef, RealityProps>(\n function RealityBase({ children, ...inProps }, ref) {\n const insideAttachment = useInsideAttachment()\n if (insideAttachment) {\n console.warn(\n '[WebSpatial] Reality cannot be used inside AttachmentAsset.',\n )\n return null\n }\n const {\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n ...props\n } = inProps\n const ctxRef = useRef<RealityContextValue | null>(null)\n\n const creationId = useRef(0)\n\n const [isReady, setIsReady] = useState(false)\n\n const cleanupReality = useCallback(() => {\n ctxRef.current?.attachmentRegistry.destroy()\n ctxRef.current?.resourceRegistry.destroy()\n ctxRef.current?.reality.destroy()\n ctxRef.current = null\n setIsReady(false)\n }, [])\n\n useEffect(() => {\n return () => {\n creationId.current++\n cleanupReality()\n }\n }, [cleanupReality])\n\n const createReality = useCallback(async () => {\n const id = ++creationId.current\n const resourceRegistry = new ResourceRegistry()\n const attachmentRegistry = new AttachmentRegistry()\n const session = await getSession()\n if (!session) {\n resourceRegistry.destroy()\n attachmentRegistry.destroy()\n return null\n }\n\n const reality = await session.createSpatializedDynamic3DElement()\n\n const isCancelled = () => id !== creationId.current\n\n if (isCancelled()) {\n resourceRegistry.destroy()\n attachmentRegistry.destroy()\n reality.destroy()\n return null\n }\n\n try {\n const result = await session\n .getSpatialScene()\n .addSpatializedElement(reality)\n\n if (!result.success || isCancelled()) {\n resourceRegistry.destroy()\n attachmentRegistry.destroy()\n reality.destroy()\n return null\n }\n\n cleanupReality()\n\n ctxRef.current = {\n session,\n reality,\n resourceRegistry,\n attachmentRegistry,\n }\n setIsReady(true)\n return reality as SpatializedElement\n } catch (err) {\n console.error('[createReality] failed', err)\n resourceRegistry.destroy()\n attachmentRegistry.destroy()\n reality.destroy()\n return null\n }\n }, [cleanupReality])\n\n const content = useCallback(() => <></>, [])\n\n useRealityEvents({\n instance: ctxRef.current?.reality ?? null,\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n })\n\n return (\n <RealityContext.Provider value={ctxRef.current}>\n <SpatializedContainer<SpatializedElementRef>\n component=\"div\"\n ref={ref}\n // @ts-ignore\n createSpatializedElement={createReality}\n spatializedContent={content}\n {...props}\n />\n {isReady && children}\n </RealityContext.Provider>\n )\n },\n)\n","import React, { useEffect, useState } from 'react'\nimport { createPortal } from 'react-dom'\nimport { useRealityContext } from '../context'\nimport type { ContainerEntry } from '../context/AttachmentContext'\nimport { InsideAttachmentContext } from '../context/InsideAttachmentContext'\n\ntype AttachmentAssetProps = {\n name: string\n children?: React.ReactNode\n}\n\nexport const AttachmentAsset: React.FC<AttachmentAssetProps> = ({\n name,\n children,\n}) => {\n const ctx = useRealityContext()\n const [containers, setContainers] = useState<ContainerEntry[]>([])\n\n useEffect(() => {\n if (!ctx) return\n return ctx.attachmentRegistry.onContainersChange(name, setContainers)\n }, [ctx, name])\n\n if (!containers.length) return null\n return (\n <InsideAttachmentContext.Provider value={true}>\n {containers.map(({ instanceId, container }) =>\n createPortal(children, container, instanceId),\n )}\n </InsideAttachmentContext.Provider>\n )\n}\n","import React, { useEffect, useRef, useState } from 'react'\nimport { Attachment } from '@webspatial/core-sdk'\n\nimport { useRealityContext, useParentContext } from '../context'\nimport { setOpenWindowStyle } from '../../utils/windowStyleSync'\nimport { useSyncHeadStyles } from '../../utils/useSyncHeadStyles'\n\nlet instanceCounter = 0\n\ntype AttachmentEntityProps = {\n attachment: string\n position?: [number, number, number]\n size: { width: number; height: number }\n}\n\nexport const AttachmentEntity: React.FC<AttachmentEntityProps> = ({\n attachment: attachmentName,\n position,\n size,\n}) => {\n const ctx = useRealityContext()\n const parent = useParentContext()\n const attachmentRef = useRef<Attachment | null>(null)\n const parentIdRef = useRef<string | null>(null)\n const instanceIdRef = useRef(`att_${++instanceCounter}`)\n const attachmentNameRef = useRef(attachmentName)\n const [childWindow, setChildWindow] = useState<WindowProxy | null>(null)\n\n // Create the attachment when the parent entity is ready\n useEffect(() => {\n if (!ctx || !parent) return\n\n if (attachmentRef.current) return\n\n const parentId = parent.id\n parentIdRef.current = parentId\n\n let cancelled = false\n\n const init = async () => {\n try {\n const att = await ctx.session.createAttachmentEntity({\n parentEntityId: parentId,\n position: position ?? [0, 0, 0],\n size,\n ownerViewId: ctx.reality.id,\n })\n if (cancelled) {\n att.destroy()\n return\n }\n // Initial style sync for attachment window\n const windowProxy = att.getWindowProxy()\n setOpenWindowStyle(windowProxy)\n // setOpenWindowStyle() above applies SpatialDiv defaults (inline-block, fit-content)\n // which shrink the body to its content. Attachments need the opposite — the body\n // must fill the RealityKit attachment frame — so override to block/100%.\n windowProxy.document.body.style.display = 'block'\n windowProxy.document.body.style.minWidth = '100%'\n windowProxy.document.body.style.maxWidth = '100%'\n windowProxy.document.body.style.minHeight = '100%'\n\n // Ensure viewport meta\n const viewport = windowProxy.document.querySelector(\n 'meta[name=\"viewport\"]',\n )\n if (!viewport) {\n const meta = windowProxy.document.createElement('meta')\n meta.name = 'viewport'\n meta.content =\n 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no'\n windowProxy.document.head.appendChild(meta)\n }\n\n // Ensure base href for relative URLs\n const base = windowProxy.document.createElement('base')\n base.href = document.baseURI\n windowProxy.document.head.appendChild(base)\n\n attachmentRef.current = att\n setChildWindow(windowProxy)\n ctx.attachmentRegistry.addContainer(\n attachmentNameRef.current,\n instanceIdRef.current,\n att.getContainer(),\n )\n } catch (error) {\n console.error('[AttachmentEntity] init error:', error)\n }\n }\n\n init()\n\n return () => {\n cancelled = true\n const att = attachmentRef.current\n if (att) {\n ctx.attachmentRegistry.removeContainer(\n attachmentNameRef.current,\n instanceIdRef.current,\n )\n att.destroy()\n attachmentRef.current = null\n setChildWindow(null)\n }\n }\n }, [ctx, parent])\n\n // If attachment name changes at runtime, migrate the container mapping\n useEffect(() => {\n if (!ctx) return\n const att = attachmentRef.current\n const prevName = attachmentNameRef.current\n if (att && prevName !== attachmentName) {\n ctx.attachmentRegistry.removeContainer(prevName, instanceIdRef.current)\n ctx.attachmentRegistry.addContainer(\n attachmentName,\n instanceIdRef.current,\n att.getContainer(),\n )\n attachmentNameRef.current = attachmentName\n } else {\n attachmentNameRef.current = attachmentName\n }\n }, [ctx, attachmentName])\n\n useSyncHeadStyles(childWindow)\n\n // Update position/size when they change\n useEffect(() => {\n if (!attachmentRef.current) return\n attachmentRef.current.update({ position, size })\n }, [position?.[0], position?.[1], position?.[2], size?.width, size?.height])\n\n return null\n}\n","import React from 'react'\nimport { UnlitMaterial, UnlitMaterialProps } from './UnlitMaterial'\n\nexport type MaterialProps = { type: 'unlit' } & UnlitMaterialProps\n\nexport const Material: React.FC<MaterialProps> = props => {\n if (props.type === 'unlit') {\n const { type, ...rest } = props\n return <UnlitMaterial {...rest} />\n }\n return null\n}\n","import { ForwardedRef, forwardRef } from 'react'\nimport {\n SpatializedStatic3DContainerProps,\n SpatializedStatic3DElementContainer,\n SpatializedStatic3DElementRef,\n} from './spatialized-container'\nimport { withSSRSupported } from './ssr'\nimport { useInsideAttachment } from './reality/context/InsideAttachmentContext'\n\nimport { Spatial } from '@webspatial/core-sdk'\n\nexport type ModelProps = SpatializedStatic3DContainerProps & {\n 'enable-xr'?: boolean\n}\n\nexport type ModelRef = SpatializedStatic3DElementRef\n\nconst spatial = new Spatial()\n\nfunction ModelBase(props: ModelProps, ref: ForwardedRef<ModelRef>) {\n const insideAttachment = useInsideAttachment()\n const { 'enable-xr': enableXR, ...restProps } = props\n // Model must handle insideAttachment itself because\n // SpatializedStatic3DElementContainer passes component=\"div\" to the base,\n // but the correct degraded element for a Model is a <model> tag, not a <div>.\n if (!enableXR || !spatial.runInSpatialWeb() || insideAttachment) {\n const {\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n spatialEventOptions: _spatialEventOptions,\n ...modelProps\n } = restProps\n // map to VisionOS26 model tag outside attachments\n // @ts-ignore\n return <model ref={ref} {...modelProps} />\n }\n\n return <SpatializedStatic3DElementContainer ref={ref} {...restProps} />\n}\n\nexport const Model = withSSRSupported(forwardRef(ModelBase))\nModel.displayName = 'Model'\n","import { useSyncExternalStore } from 'react'\nimport { PhysicalMetrics } from '@webspatial/core-sdk'\n\nexport function useMetrics() {\n useSyncExternalStore(PhysicalMetrics.subscribe, PhysicalMetrics.getValue)\n const { pointToPhysical, physicalToPoint } = PhysicalMetrics\n return { pointToPhysical, physicalToPoint }\n}\n","import { jsxDEV as _jsxDEV, JSXSource } from 'react/jsx-dev-runtime'\nimport reactJSXRuntime from 'react/jsx-runtime'\nimport { createElement as reactCreateElement } from 'react'\nimport {\n withSpatialMonitor,\n withSpatialized2DElementContainer,\n Model,\n Reality,\n //@ts-ignore bypass ts check for external\n} from '@webspatial/react-sdk'\nconst attributeFlag = 'enable-xr'\nconst styleFlag = 'enableXr'\nconst classFlag = '__enableXr__'\nconst xrMonitorFlag = 'enable-xr-monitor'\n\nexport function replaceToSpatialPrimitiveType(\n type: React.ElementType,\n props: unknown,\n) {\n if (type === Model || type === Reality) {\n return type\n }\n\n const propsObject = props as Record<string, any>\n if (attributeFlag in propsObject) {\n delete propsObject[attributeFlag]\n return withSpatialized2DElementContainer(type)\n }\n\n if (xrMonitorFlag in propsObject) {\n delete propsObject[xrMonitorFlag]\n return withSpatialMonitor(type)\n }\n\n if (propsObject && propsObject.style && styleFlag in propsObject.style) {\n delete propsObject.style[styleFlag]\n return withSpatialized2DElementContainer(type)\n }\n\n if (propsObject && typeof propsObject.className === 'string') {\n const originalClassNames = propsObject.className.split(' ')\n const idx = originalClassNames.indexOf(classFlag)\n if (idx !== -1) {\n originalClassNames.splice(idx, 1)\n propsObject.className = originalClassNames.join(' ')\n return withSpatialized2DElementContainer(type)\n }\n }\n\n return type\n}\n\nexport function jsxs(type: React.ElementType, props: unknown, key?: React.Key) {\n type = replaceToSpatialPrimitiveType(type, props)\n return reactJSXRuntime.jsxs(type, props, key)\n}\n\nexport function jsx(type: React.ElementType, props: unknown, key?: React.Key) {\n type = replaceToSpatialPrimitiveType(type, props)\n return reactJSXRuntime.jsx(type, props, key)\n}\n\nexport function jsxDEV(\n type: React.ElementType,\n props: unknown,\n key: React.Key,\n isStatic: boolean,\n source?: JSXSource,\n self?: unknown,\n) {\n type = replaceToSpatialPrimitiveType(type, props)\n return _jsxDEV(type, props, key, isStatic, source, self)\n}\n\nexport function createElement(...args: Parameters<typeof reactCreateElement>) {\n const [type, props, ...rest] = args\n const newType = replaceToSpatialPrimitiveType(type as any, props)\n return reactCreateElement(newType, props, ...rest)\n}\n","/**\n * const e2e = await convertCoordinate(position, { from: elementOrEntity, to: elementOrEntity })\nconst e2w = await convertCoordinate(position, { from: elementOrEntity, to: window })\nconst w2e = await convertCoordinate(position, { from: window, to: elementOrEntity })\n * \n */\nimport type { Vec3 } from '@webspatial/core-sdk'\nimport type { SpatializedElementRef } from '../spatialized-container/types'\nimport type { EntityRef } from '../reality'\nimport type { ModelRef } from '../Model'\nimport { getSession } from './getSession'\n\ntype CoordinateConvertible =\n | Window\n | SpatializedElementRef<any>\n | EntityRef\n | ModelRef\n\nfunction resolveSpatialObjectId(target: CoordinateConvertible): string | null {\n // window -> current spatial scene id which is empty string\n if (typeof window !== 'undefined' && target === window) {\n const scene = getSession()?.getSpatialScene()\n return scene?.id ?? ''\n }\n\n // EntityRef -> underlying SpatialEntity.id\n const maybeEntity = target as EntityRef\n if (\n maybeEntity &&\n typeof maybeEntity === 'object' &&\n 'entity' in maybeEntity\n ) {\n return maybeEntity.entity?.id ?? null\n }\n\n // SpatializedElementRef / ModelRef -> underlying SpatializedElement.id\n const dom: any = target as any\n if (dom && typeof dom === 'object') {\n const spatializedElement =\n dom.__spatializedElement ?? dom.__innerSpatializedElement?.()\n if (spatializedElement && spatializedElement.id) {\n return spatializedElement.id as string\n }\n }\n\n return null\n}\n\nexport async function convertCoordinate(\n position: Vec3,\n { from, to }: { from: CoordinateConvertible; to: CoordinateConvertible },\n): Promise<Vec3> {\n try {\n const fromId = resolveSpatialObjectId(from)\n const toId = resolveSpatialObjectId(to)\n if (fromId === null || toId === null) {\n console.warn(\n 'convertCoordinate error: from or to is not a valid coordinate convertible',\n )\n return position\n }\n\n const spatialScene = getSession()?.getSpatialScene()\n if (!spatialScene) return position\n const ret = await spatialScene.convertCoordinate(position, fromId, toId)\n return ret ?? position\n } catch (error) {\n console.warn('convertCoordinate error:', error)\n return position\n }\n}\n","import { initPolyfill } from './spatialized-container'\n\nexport { WebSpatialRuntime } from './webSpatialRuntime'\nexport { WebSpatialRuntimeError } from '@webspatial/core-sdk'\nexport type { CapabilityKey } from '@webspatial/core-sdk'\nexport { enableDebugTool } from './utils'\nexport * from './initScene'\nexport * from './spatialized-container'\nexport * from './spatialized-container-monitor'\nexport * from './reality'\nexport * from './Model'\nexport { SSRProvider } from './ssr'\nexport { useMetrics } from './useMetrics'\nexport { createElement } from './jsx/jsx-shared'\nexport { convertCoordinate } from './utils/convertCoordinate'\nexport { getAbsoluteUrl } from './utils/urlUtils'\n\nexport const version = __WEBSPATIAL_REACT_SDK_VERSION__\n\nif (typeof window !== 'undefined') {\n initPolyfill()\n}\n"],"mappings":";;;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;ACNP,SAAS,qBAAqB;;;ACAvB,IAAM,YAAY;;;ADKlB,IAAM,6BAAN,MAEL;AAAA,EACA,MAA0B;AAAA,EAC1B,eAA8B;AAAA,EAEtB,MAAkC,CAAC;AAAA;AAAA,EAEnC,gBAA6C,CAAC;AAAA,EAC9C,6BAA0D,CAAC;AAAA;AAAA,EAG3D,iBAAmD,CAAC;AAAA,EAErD,+BAA+B,KAAkB;AACtD,SAAK,MAAM;AACX,SAAK,eAAe,IAAI,aAAa,SAAS;AAC9C,WAAO,OAAO,KAAK,GAAG,EAAE,QAAQ,QAAM,GAAG,CAAC;AAAA,EAC5C;AAAA,EAEQ,gCAGJ,CAAC;AAAA,EACE,iCACL,WACA,4BACA;AACA,SAAK,8BAA8B,SAAS,IAAI;AAEhD,SAAK,iCAAiC,SAAS,GAAG;AAAA,MAAQ,QACxD,GAAG,0BAA0B;AAAA,IAC/B;AAAA,EACF;AAAA;AAAA,EAGQ,8BAGJ,CAAC;AAAA;AAAA,EAGE,mCACL,WACA,0B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,EAAE,MAAM,GAAG,GACI;AACf,MAAI;AACF,UAAM,SAAS,uBAAuB,IAAI;AAC1C,UAAM,OAAO,uBAAuB,EAAE;AACtC,QAAI,WAAW,QAAQ,SAAS,MAAM;AACpC,cAAQ;AAAA,QACN;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAEA,UAAM,eAAe,WAAW,GAAG,gBAAgB;AACnD,QAAI,CAAC,aAAc,QAAO;AAC1B,UAAM,MAAM,MAAM,aAAa,kBAAkB,UAAU,QAAQ,IAAI;AACvE,WAAO,OAAO;AAAA,EAChB,SAAS,OAAO;AACd,YAAQ,KAAK,4BAA4B,KAAK;AAC9C,WAAO;AAAA,EACT;AACF;;;ACrDO,IAAM,UAAU;AAEvB,IAAI,OAAO,WAAW,aAAa;AACjC,eAAa;AACf;","names":["useCallback","useContext","useEffect","useContext","useEffect","useCallback","forwardRef","useCallback","useRef","useCallback","useContext","useEffect","useContext","useCallback","useEffect","jsx","useInternalRef","useRef","useCallback","cssParserDivContainer","forwardRef","forwardRef","useCallback","useContext","useEffect","useLayoutEffect","useMemo","useRef","useState","createContext","useContext","useEffect","createContext","getExtraSpatializedElementProperties","createContext","useEffect","useState","useEffect","useRef","useState","createSpatializedElement","jsx","createSpatializedElement","getExtraSpatializedElementProperties","useContext","useEffect","useCallback","useEffect","useRef","useRef","useEffect","useCallback","createContext","useContext","createContext","useState","useEffect","jsx","forwardRef","useContext","useState","useEffect","useContext","useState","useEffect","jsx","forwardRef","jsx","jsxs","useState","useRef","useLayoutEffect","useCallback","useContext","useMemo","useEffect","createSpatializedElement","getExtraSpatializedElementProperties","forwardRef","createPortal","forwardRef","useCallback","useContext","useEffect","useState","version","useEffect","useEffect","useLayoutEffect","useRef","jsx","useEffect","useState","useContext","useCallback","createPortal","forwardRef","forwardRef","useCallback","useContext","useEffect","useMemo","useRef","Fragment","jsx","SpatializedContent","useContext","useRef","useMemo","useEffect","createSpatializedElement","useCallback","forwardRef","forwardRef","jsx","forwardRef","forwardRef","useRef","useEffect","useMemo","useRef","useEffect","useMemo","useEffect","useEffect","forwardRef","jsx","jsx","forwardRef","forwardRef","forwardRef","createContext","useContext","createContext","useContext","createContext","useContext","useEffect","useRef","useRef","useEffect","useEffect","useRef","createEventProxy","useRef","useEffect","useEffect","useRef","createEventProxy","useRef","useEffect","useEffect","useEffect","useEffect","useRef","useRef","useForceUpdate","useEffect","useCallback","useState","useForceUpdate","jsx","forwardRef","jsx","forwardRef","forwardRef","forwardRef","useEffect","useRef","jsx","forwardRef","useRef","useEffect","ctx","id","jsx","forwardRef","useEffect","useRef","useState","useRef","useState","useEffect","useEffect","useRef","useRef","useEffect","forwardRef","jsx","forwardRef","forwardRef","jsx","forwardRef","forwardRef","jsx","forwardRef","forwardRef","jsx","forwardRef","jsx","useEffect","useRef","useRef","useEffect","forwardRef","useEffect","useRef","jsx","forwardRef","useRef","useEffect","ctx","forwardRef","useCallback","useEffect","useRef","useState","Fragment","jsx","jsxs","forwardRef","useRef","useState","useCallback","useEffect","useEffect","useState","createPortal","jsx","useState","useEffect","createPortal","useEffect","useRef","useState","useRef","useState","useEffect","jsx","forwardRef","jsx","spatial","forwardRef"]}