@webspatial/react-sdk 1.4.0 → 1.5.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/spatialized-container/hooks/useDomProxy.ts","../../src/spatialized-container/types.ts","../../src/spatialized-container/utils.ts","../../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/utils/debugTool.ts","../../src/spatialized-container/hooks/useSync2DFrame.ts","../../src/spatialized-container/hooks/useSpatializedElement.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/SpatializedStatic3DElementContainer.tsx","../../src/spatialized-container/Spatialized2DElementContainerFactory.tsx","../../src/spatialized-container/index.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/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 { ForwardedRef, useCallback, useEffect, useRef } from 'react'\nimport { SpatialCustomStyleVars, SpatializedElementRef } from '../types'\nimport { BackgroundMaterialType } from '@webspatial/core-sdk'\nimport { extractAndRemoveCustomProperties, joinToCSSText } from '../utils'\n\nfunction makeOriginalKey(key: string) {\n return `__original_${key}`\n}\n\nexport class SpatialContainerRefProxy<T extends SpatializedElementRef> {\n private transformVisibilityTaskContainerDom: HTMLElement | null = null\n private ref: ForwardedRef<SpatializedElementRef<T>>\n public domProxy?: T | null\n private styleProxy?: CSSStyleDeclaration\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 updateStandardSpatializedContainerDom(dom: HTMLElement | null) {\n const self = this\n\n if (dom) {\n let cacheExtraRefProps: Record<string, unknown> | undefined\n const domProxy = new Proxy<SpatializedElementRef<T>>(\n dom as SpatializedElementRef<T>,\n {\n get(target, prop) {\n if (prop === '__raw') {\n return target\n }\n if (prop === 'xrClientDepth') {\n return target.style.getPropertyValue(SpatialCustomStyleVars.depth)\n }\n if (prop === 'xrOffsetBack') {\n return target.style.getPropertyValue(SpatialCustomStyleVars.back)\n }\n if (prop === 'style') {\n if (!self.styleProxy) {\n self.styleProxy = new Proxy<CSSStyleDeclaration>(target.style, {\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 validProperties = ['visibility', 'transform']\n const [property] = args\n\n if (validProperties.includes(property)) {\n if (prop === 'setProperty') {\n const [, kValue] = args\n self.transformVisibilityTaskContainerDom?.style.setProperty(\n property,\n kValue as string,\n )\n } else if (prop === 'removeProperty') {\n self.transformVisibilityTaskContainerDom?.style.removeProperty(\n property,\n )\n } else if (prop === 'getPropertyValue') {\n return self.transformVisibilityTaskContainerDom?.style.getPropertyValue(\n property,\n )\n }\n } else {\n return value.apply(this, args)\n }\n }.bind(target)\n } else {\n return value.bind(target)\n }\n } else {\n return value\n }\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 (prop === SpatialCustomStyleVars.backgroundMaterial) {\n target.setProperty(\n SpatialCustomStyleVars.backgroundMaterial,\n value as BackgroundMaterialType,\n )\n } else if (prop === SpatialCustomStyleVars.back) {\n target.setProperty(\n SpatialCustomStyleVars.back,\n value as string,\n )\n } else if (prop === SpatialCustomStyleVars.xrZIndex) {\n target.setProperty(\n SpatialCustomStyleVars.xrZIndex,\n value as string,\n )\n } else if (prop === SpatialCustomStyleVars.depth) {\n target.setProperty(\n SpatialCustomStyleVars.depth,\n value as string,\n )\n } else if (prop === 'cssText') {\n // parse cssText, filter out spatialStyle like back/transform/visibility/xrZIndex/backgroundMaterial\n const toFilteredCSSProperties = [\n 'transform',\n 'visibility',\n ]\n const { extractedValues, filteredCssText } =\n extractAndRemoveCustomProperties(\n value as string,\n toFilteredCSSProperties,\n )\n\n // update cssText for transformVisibilityTaskContainerDom\n toFilteredCSSProperties.forEach(key => {\n // update cssText for transformVisibilityTaskContainerDom according to extractedValues\n if (extractedValues[key]) {\n self.transformVisibilityTaskContainerDom?.style.setProperty(\n key,\n extractedValues[key],\n )\n } else {\n target.removeProperty(key)\n }\n })\n\n const appendedCSSText = joinToCSSText({\n transform: 'none',\n visibility: 'hidden',\n })\n\n // set cssText for spatialDiv\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\n return self.styleProxy\n }\n\n if (typeof prop === 'string' && self.extraRefProps) {\n if (!cacheExtraRefProps) {\n cacheExtraRefProps = self.extraRefProps(domProxy)\n }\n const extraProps = cacheExtraRefProps\n if (extraProps.hasOwnProperty(prop)) {\n return extraProps[prop]\n }\n }\n const value = Reflect.get(target, prop)\n if (typeof value === 'function') {\n if ('removeAttribute' === prop) {\n return function (this: any, ...args: any[]) {\n const [property] = args\n if (property === 'style') {\n dom.style.cssText =\n 'visibility: hidden; transition: none; transform: none;'\n if (self.transformVisibilityTaskContainerDom) {\n self.transformVisibilityTaskContainerDom.style.visibility =\n ''\n self.transformVisibilityTaskContainerDom.style.transform =\n ''\n }\n return true\n }\n if (property === 'class') {\n domProxy.className = 'xr-spatial-default'\n return true\n }\n }\n }\n\n return value.bind(target)\n }\n return value\n },\n set(target, prop, value) {\n if (prop === 'className') {\n if (value && value.indexOf('xr-spatial-default') === -1) {\n value = value + ' xr-spatial-default'\n }\n\n if (self.transformVisibilityTaskContainerDom) {\n self.transformVisibilityTaskContainerDom.className = value\n }\n }\n\n // check extraRefProps setter\n if (typeof prop === 'string' && self.extraRefProps) {\n if (!cacheExtraRefProps) {\n cacheExtraRefProps = self.extraRefProps(domProxy)\n }\n cacheExtraRefProps[prop] = value\n }\n\n return Reflect.set(target, prop, value)\n },\n },\n )\n this.domProxy = domProxy\n\n // hijack classList\n const domClassList = dom.classList\n const domClassMethodKeys: Array<'add' | 'remove' | 'toggle' | 'replace'> =\n ['add', 'remove', 'toggle', 'replace']\n domClassMethodKeys.forEach(key => {\n const hiddenKey = makeOriginalKey(key)\n const hiddenKeyExist = (domClassList as any)[hiddenKey] !== undefined\n const originalMethod = hiddenKeyExist\n ? (domClassList as any)[hiddenKey]\n : domClassList[key].bind(domClassList)\n\n ;(domClassList as any)[hiddenKey] = originalMethod\n\n domClassList[key] = function (this: any, ...args: any[]) {\n const result = (originalMethod as Function)(...args)\n // update transformVisibilityTaskContainerDom className\n if (self.transformVisibilityTaskContainerDom) {\n self.transformVisibilityTaskContainerDom.className = dom.className\n }\n\n return result\n }\n })\n\n // clear styleProxy\n this.styleProxy = undefined\n this.updateDomProxyToRef()\n\n // assign domProxy to dom\n Object.assign(dom, {\n __targetProxy: domProxy,\n })\n }\n }\n\n updateTransformVisibilityTaskContainerDom(dom: HTMLElement | null) {\n this.transformVisibilityTaskContainerDom = dom\n this.updateDomProxyToRef()\n }\n\n private updateDomProxyToRef() {\n const ref = this.ref\n if (!ref) {\n return\n }\n if (this.domProxy && this.transformVisibilityTaskContainerDom) {\n if (typeof ref === 'function') {\n ref(this.domProxy)\n } else {\n ref.current = this.domProxy\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 this.ref = ref\n }\n}\n\n// hijack getComputedStyle to get raw dom\nexport function hijackGetComputedStyle() {\n const rawFn = window.getComputedStyle.bind(window)\n window.getComputedStyle = (element, pseudoElt) => {\n const dom = (element as any).__raw\n\n if (dom) {\n return rawFn(dom, pseudoElt)\n }\n return rawFn(element, pseudoElt)\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 React, { ElementType } from 'react'\nimport { SpatialID } from './SpatialID'\nimport {\n CubeInfo,\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/** 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\nexport type SpatializedContentProps<\n T extends SpatializedElementRef,\n P extends ElementType,\n> = Omit<PortalSpatializedContainerProps<T>, 'spatializedContent'> & {\n spatializedElement: SpatializedElement\n}\n\nexport type Spatialized2DElementContainerProps<P extends ElementType> =\n SpatialEventProps<SpatializedElementRef> &\n React.ComponentPropsWithRef<'div'> & {\n component: P\n spatialEventOptions?: SpatialEventOptions\n }\n\nexport type SpatializedStatic3DContainerProps =\n SpatialEventProps<SpatializedStatic3DElementRef> &\n Omit<React.ComponentPropsWithoutRef<'div'>, 'onLoad' | 'onError'> & {\n src?: string\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 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}\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 { 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 {\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","import {\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 extraStyle = {\n visibility: 'hidden',\n transition: 'none',\n transform: transformExist ? 'translateZ(0)' : 'none',\n }\n const style = { ...inStyle, ...extraStyle }\n\n const classNames = className\n ? `${className} xr-spatial-default`\n : 'xr-spatial-default'\n\n return (\n <Component\n ref={refInternalCallback}\n style={style}\n className={classNames}\n {...restProps}\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\nexport function injectSpatialDefaultStyle() {\n // inject xr-spatial-default style to head\n const styleElement = document.createElement('style')\n styleElement.type = 'text/css'\n styleElement.innerHTML =\n ' :where(.xr-spatial-default) { --xr-back: 0; --xr-depth: 0; --xr-z-index: 0; --xr-background-material: none; } '\n document.head.appendChild(styleElement)\n}\n","import React, {\n CSSProperties,\n ForwardedRef,\n forwardRef,\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 { ForwardedRef, forwardRef, useContext, useEffect, useMemo } 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 ...inprops\n}: SpatializedContainerProps<T> & {\n innerRef: ForwardedRef<SpatializedElementRef<T>>\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 ...restProps\n } = inprops as DegradedProps\n return (\n <Component ref={innerRef} {...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 <DegradedContainer {...inprops} innerRef={ref} />\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 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 ...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={props.className}\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 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 ...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={props.className}\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\nexport class Spatial {\n /**\n * Requests a session object from the browser\n * @returns The session or null if not availible 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\n */\n getNativeVersion() {\n return null\n }\n /**\n * Gets the client version, format is \"x.x.x\"\n * @returns client version string\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 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!.getPropertyPriority('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) {\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 {\n SpatialCustomStyleVars,\n Point3D,\n SpatialTransformVisibility,\n} 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 { 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","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 { 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 useContext,\n useEffect,\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'\nfunction getJSXPortalInstance<P extends ElementType>(\n inProps: Omit<\n SpatializedContentProps<SpatializedElementRef, P>,\n 'spatializedElement'\n >,\n portalInstanceObject: PortalInstanceObject,\n) {\n const { component: El, style: inStyle = {}, ...props } = inProps\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 return <El 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, ...restProps } = props\n const spatialized2DElement = spatializedElement as Spatialized2DElement\n const { windowProxy } = spatialized2DElement\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 portalInstanceObject: PortalInstanceObject = useContext(\n PortalInstanceContext,\n )!\n const JSXPortalInstance = getJSXPortalInstance(\n restProps,\n portalInstanceObject,\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\nfunction defaultShouldSync(mutations?: MutationRecord[] | null) {\n if (!Array.isArray(mutations) || mutations.length === 0) return false\n for (const mutation of mutations) {\n const nodes: Node[] = [\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 true\n if (tag === 'LINK') {\n const { rel } = node as HTMLLinkElement\n if (rel && rel.toLowerCase() === 'stylesheet') return true\n }\n }\n }\n return false\n}\n\nexport function useSyncHeadStyles(\n childWindow: WindowProxy | null | undefined,\n options?: Options,\n) {\n const delayMs = 100\n const subtree = options?.subtree ?? false\n const immediate = options?.immediate ?? true\n\n useEffect(() => {\n if (!childWindow) return\n\n let timer: number | undefined\n const scheduleSync = () => {\n if (timer) window.clearTimeout(timer)\n timer = window.setTimeout(() => {\n syncParentHeadToChild(childWindow)\n }, delayMs)\n }\n\n if (immediate) scheduleSync()\n\n const observer = new MutationObserver(mutations => {\n if (!defaultShouldSync(mutations)) return\n scheduleSync()\n })\n observer.observe(document.head, { childList: true, subtree })\n\n return () => {\n if (timer) window.clearTimeout(timer)\n observer.disconnect()\n }\n }, [childWindow, delayMs, subtree, immediate])\n}\n","import {\n ForwardedRef,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from 'react'\nimport { SpatializedContainer } from './SpatializedContainer'\nimport { getSession } from '../utils'\nimport {\n ModelLoadEvent,\n SpatializedStatic3DContainerProps,\n SpatializedStatic3DContentProps,\n SpatializedStatic3DElementRef,\n} from './types'\nimport { SpatializedStatic3DElement } from '@webspatial/core-sdk'\nimport {\n PortalInstanceObject,\n PortalInstanceContext,\n} from './context/PortalInstanceContext'\n\nfunction getAbsoluteURL(url?: string) {\n if (!url) {\n return ''\n }\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 SpatializedContent(props: SpatializedStatic3DContentProps) {\n const { src, spatializedElement, onLoad, onError } = props\n const spatializedStatic3DElement =\n spatializedElement as SpatializedStatic3DElement\n\n const portalInstanceObject: PortalInstanceObject = useContext(\n PortalInstanceContext,\n )!\n\n const currentSrc: string = useMemo(() => getAbsoluteURL(src), [src])\n\n useEffect(() => {\n if (src) {\n spatializedStatic3DElement.updateProperties({ modelURL: currentSrc })\n }\n }, [currentSrc])\n\n useEffect(() => {\n if (onLoad) {\n spatializedStatic3DElement.onLoadCallback = () => {\n onLoad(\n createLoadSuccessEvent(\n () => (portalInstanceObject.dom as any).__targetProxy,\n ),\n )\n }\n } else {\n spatializedStatic3DElement.onLoadCallback = undefined\n }\n }, [onLoad])\n\n useEffect(() => {\n if (onError) {\n spatializedStatic3DElement.onLoadFailureCallback = () => {\n onError(\n createLoadFailureEvent(\n () => (portalInstanceObject.dom as any).__targetProxy,\n ),\n )\n }\n } else {\n spatializedStatic3DElement.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 const url = getAbsoluteURL(props.src)\n promiseRef.current = getSession()!.createSpatializedStatic3DElement(url)\n return promiseRef.current\n }, [])\n const extraRefProps = useCallback(\n (domProxy: SpatializedStatic3DElementRef) => {\n let modelTransform = new DOMMatrixReadOnly()\n\n return {\n get currentSrc(): string {\n return getAbsoluteURL(props.src)\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 }\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 { hijackGetComputedStyle } from './hooks/useDomProxy'\nimport { 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} from './types'\n\nexport function initPolyfill() {\n hijackGetComputedStyle()\n injectSpatialDefaultStyle()\n initCSSParserDivContainer()\n}\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 } from '../type'\nimport { EntityRefShape, useEntity } from '../hooks'\n\ntype BaseEntityProps = EntityProps & {\n children?: React.ReactNode\n createEntity: (\n ctx: RealityContextValue,\n signal: AbortSignal,\n ) => Promise<SpatialEntity>\n}\n\nexport const BaseEntity = forwardRef<EntityRefShape, BaseEntityProps>(\n ({ children, createEntity, ...rest }, ref) => {\n const ctx = useRealityContext()\n const entity = useEntity({\n ...rest,\n ref,\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 {\n SpatializedDynamic3DElement,\n SpatialObject,\n SpatialSession,\n} from '@webspatial/core-sdk'\nexport class ResourceRegistry {\n private resources: Map<string, Promise<SpatialObject>> = new Map()\n add<T extends SpatialObject>(id: string, resource: Promise<T>) {\n this.resources.set(id, resource)\n }\n remove(id: string) {\n this.resources.delete(id)\n }\n\n // Remove the resource by id and destroy it once resolved\n // This does not cancel in-flight creation; it schedules destruction after resolution\n removeAndDestroy(id: string) {\n const p = this.resources.get(id)\n if (p) {\n // Schedule destruction when the resource becomes available\n p.then(spatialObj => spatialObj.destroy()).catch(() => {\n // swallow rejection to avoid unhandled promise errors during teardown\n })\n }\n this.resources.delete(id)\n }\n get<T extends SpatialObject>(id: string) {\n return this.resources.get(id) as Promise<T>\n }\n destroy() {\n // Collect pending resources and clear registry immediately\n const pending = Array.from(this.resources.values())\n this.resources.clear()\n\n // Best-effort destroy for all resolved and future-resolving resources\n pending.forEach(promise =>\n promise\n .then(spatialObj => spatialObj.destroy())\n .catch(() => {\n // swallow rejection to avoid unhandled promise errors during teardown\n }),\n )\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","export class AbortResourceManager {\n private resources: { destroy: () => Promise<void> | void }[] = []\n private aborted = false\n\n constructor(private 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 { useEffect, useImperativeHandle, useRef } from 'react'\nimport { Vec3, SpatialEntity } from '@webspatial/core-sdk'\nimport { RealityContextValue, useRealityContext } 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 React, { 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, useState } from 'react'\nimport { SpatialEntity, Vec3 } from '@webspatial/core-sdk'\nimport { useRealityContext, useParentContext } from '../context'\nimport { EntityProps } from '../type'\nimport {\n EntityRefShape,\n EntityRef,\n useEntityId,\n useEntityRef,\n useEntityTransform,\n useForceUpdate,\n} from '../hooks'\n\ntype UseEntityOptions = {\n createEntity: (signal: AbortSignal) => Promise<SpatialEntity>\n} & EntityProps & { ref: ForwardedRef<EntityRefShape> }\n\nexport const useEntity = ({\n ref,\n id,\n position,\n rotation,\n scale,\n enableInput,\n createEntity,\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 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])\n\n useEntityId({ id, entity: instanceRef.current.entity })\n useEntityTransform(instanceRef.current.entity, { position, rotation, scale })\n useEntityRef(ref, instanceRef.current)\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 React, { useCallback, useState } from 'react'\ntype Props = {\n children?: React.ReactNode\n}\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 } from 'react'\nimport { EntityProps } from '../type'\nimport { EntityRefShape } from '../hooks'\nimport { SpatialMaterial, SpatialGeometry } from '@webspatial/core-sdk'\nimport { AbortResourceManager } from '../utils'\nimport { BaseEntity } from './BaseEntity'\n\ntype GeometryEntityProps = EntityProps & {\n children?: React.ReactNode\n materials?: string[]\n geometryOptions: any\n createGeometry: (options: any) => Promise<SpatialGeometry>\n}\n\nexport const GeometryEntity = forwardRef<EntityRefShape, GeometryEntityProps>(\n (\n { id, children, name, materials, geometryOptions, createGeometry, ...rest },\n ref,\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: SpatialMaterial[] = await Promise.all(\n materials\n ?.map(id => ctx!.resourceRegistry.get<SpatialMaterial>(id))\n .filter(Boolean) ?? [],\n )\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 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 } from 'react'\nimport {\n SpatialUnlitMaterial,\n SpatialUnlitMaterialOptions,\n} from '@webspatial/core-sdk'\nimport { useRealityContext } from '../context'\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>()\n useEffect(() => {\n if (!ctx) return\n const { session, reality, resourceRegistry } = ctx\n const init = async () => {\n const materialPromise = session.createUnlitMaterial(options)\n resourceRegistry.add(options.id, materialPromise)\n try {\n const mat = await materialPromise\n materialRef.current = mat\n } catch (error) {\n console.error(' ~ UnlitMaterial ~ error:', error)\n }\n }\n init()\n\n return () => {\n // Use registry to schedule destruction after promise resolves\n resourceRegistry.removeAndDestroy(options.id)\n }\n }, [ctx])\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'\ntype Props = {\n children?: React.ReactNode\n id: string // user id\n src: string // model url\n onLoad?: () => void\n onError?: (error: any) => void\n}\n\n// Resolve relative URLs to absolute for the native bridge\nconst resolveAssetUrl = (url: string): string => {\n if (url.startsWith('http://') || url.startsWith('https://')) {\n return url\n }\n return new URL(url, window.location.href).href\n}\n\nexport const ModelAsset: React.FC<Props> = ({ children, ...options }) => {\n const ctx = useRealityContext()\n const materialRef = useRef<SpatialModelAsset>()\n useEffect(() => {\n const controller = new AbortController()\n if (!ctx) return\n const { session, reality, resourceRegistry } = ctx\n const init = async () => {\n try {\n const resolvedUrl = resolveAssetUrl(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 } from 'react'\nimport { EntityProps } from '../type'\nimport { EntityRefShape } from '../hooks'\nimport { BaseEntity } from './BaseEntity'\n\ntype Props = EntityProps & { model: string } & {\n children?: React.ReactNode\n}\n\nexport const ModelEntity = forwardRef<EntityRefShape, Props>(\n ({ id, model, children, name, ...rest }, ref) => {\n return (\n <BaseEntity\n {...rest}\n id={id}\n ref={ref}\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 return ctx!.session.createSpatialModelEntity(\n {\n modelAssetId: modelAsset.id,\n name,\n },\n { id, name },\n )\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 = React.ComponentPropsWithRef<'div'> &\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, { subtree: false })\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 //@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) {\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'\nimport { SpatialID } from '../spatialized-container/SpatialID'\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 -> DOM proxy to underlying SpatializedElement.id\n const dom: any = (target as any)?.__raw ?? (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 { 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'\n\nexport const version = __WEBSPATIAL_REACT_SDK_VERSION__\n\nif (typeof window !== 'undefined') {\n initPolyfill()\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAuB,aAAa,WAAW,cAAc;;;ACkGtD,IAAM,yBAAyB;AAAA,EACpC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,oBAAoB;AAAA,EACpB,UAAU;AACZ;;;ACrGO,SAAS,uBACd,eACe;AAEf,MAAI,YAAqC;AAAA,IACvC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA,IAGA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,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;;AC1DA,SAAS,uBAAuB,QAA8C;AAE5E,MAAI,OAAO,WAAW,eAAe,WAAW,QAAQ;AACtD,UAAM,QAAQ,WAAW,GAAG,gBAAgB;AAC5C,WAAO,OAAO,MAAM;AAAA,EACtB;AAGA,QAAM,cAAc;AACpB,MACE,eACA,OAAO,gBAAgB,YACvB,YAAY,aACZ;AACA,WAAO,YAAY,QAAQ,MAAM;AAAA,EACnC;AAGA,QAAM,MAAY,QAAgB,SAAU;AAC5C,MAAI,OAAO,OAAO,QAAQ,UAAU;AAClC,UAAM,qBACJ,IAAI,wBAAwB,IAAI,4BAA4B;AAC9D,QAAI,sBAAsB,mBAAmB,IAAI;AAC/C,aAAO,mBAAmB;AAAA,IAC5B;AAAA,EACF;AAEA,SAAO;AACT;AAEA,eAAsB,kBACpB,UACA,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;;;AC1DO,IAAM,UAAU;AAEvB,IAAI,OAAO,WAAW,aAAa;AACjC,eAAa;AACf;","names":["target","prop","value","useEffect","useCallback","useCallback","useEffect","useCallback","useContext","useEffect","useRef","useContext","useEffect","useRef","useCallback","forwardRef","useCallback","useRef","useCallback","useContext","useEffect","useContext","useCallback","useEffect","jsx","useInternalRef","useRef","useCallback","cssParserDivContainer","forwardRef","forwardRef","useContext","useEffect","useMemo","createContext","useContext","useEffect","createContext","getExtraSpatializedElementProperties","createContext","useEffect","useState","useEffect","useRef","useState","createSpatializedElement","jsx","createSpatializedElement","getExtraSpatializedElementProperties","useContext","useEffect","createContext","useContext","createContext","useState","useEffect","jsx","forwardRef","useContext","useState","useEffect","useContext","useState","useEffect","jsx","forwardRef","jsx","jsxs","useContext","useMemo","useEffect","createSpatializedElement","getExtraSpatializedElementProperties","forwardRef","createPortal","forwardRef","useContext","useEffect","version","useEffect","useEffect","jsx","useEffect","useContext","createPortal","forwardRef","forwardRef","useCallback","useContext","useEffect","useMemo","useRef","Fragment","jsx","SpatializedContent","useContext","useMemo","useEffect","useRef","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","useEffect","useRef","createEventProxy","useRef","useEffect","useEffect","useEffect","useEffect","useRef","useRef","useForceUpdate","useEffect","useCallback","useState","useForceUpdate","jsx","forwardRef","jsx","forwardRef","forwardRef","forwardRef","jsx","forwardRef","id","jsx","forwardRef","useEffect","useRef","useRef","useEffect","forwardRef","jsx","forwardRef","forwardRef","jsx","forwardRef","forwardRef","jsx","forwardRef","forwardRef","jsx","forwardRef","jsx","useEffect","useRef","useRef","useEffect","forwardRef","jsx","forwardRef","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"]}
1
+ {"version":3,"sources":["../../src/spatialized-container/hooks/useDomProxy.ts","../../src/spatialized-container/types.ts","../../src/spatialized-container/utils.ts","../../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/utils/debugTool.ts","../../src/spatialized-container/hooks/useSync2DFrame.ts","../../src/spatialized-container/hooks/useSpatializedElement.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/SpatializedStatic3DElementContainer.tsx","../../src/spatialized-container/Spatialized2DElementContainerFactory.tsx","../../src/spatialized-container/index.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/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 { ForwardedRef, useCallback, useEffect, useRef } from 'react'\nimport { SpatialCustomStyleVars, SpatializedElementRef } from '../types'\nimport { BackgroundMaterialType } from '@webspatial/core-sdk'\nimport { extractAndRemoveCustomProperties, joinToCSSText } from '../utils'\n\nfunction makeOriginalKey(key: string) {\n return `__original_${key}`\n}\n\nexport class SpatialContainerRefProxy<T extends SpatializedElementRef> {\n private transformVisibilityTaskContainerDom: HTMLElement | null = null\n private ref: ForwardedRef<SpatializedElementRef<T>>\n public domProxy?: T | null\n private styleProxy?: CSSStyleDeclaration\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 updateStandardSpatializedContainerDom(dom: HTMLElement | null) {\n const self = this\n\n if (dom) {\n let cacheExtraRefProps: Record<string, unknown> | undefined\n const domProxy = new Proxy<SpatializedElementRef<T>>(\n dom as SpatializedElementRef<T>,\n {\n get(target, prop) {\n if (prop === '__raw') {\n return target\n }\n if (prop === 'xrClientDepth') {\n return target.style.getPropertyValue(SpatialCustomStyleVars.depth)\n }\n if (prop === 'xrOffsetBack') {\n return target.style.getPropertyValue(SpatialCustomStyleVars.back)\n }\n if (prop === 'style') {\n if (!self.styleProxy) {\n self.styleProxy = new Proxy<CSSStyleDeclaration>(target.style, {\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 validProperties = ['visibility', 'transform']\n const [property] = args\n\n if (validProperties.includes(property)) {\n if (prop === 'setProperty') {\n const [, kValue] = args\n self.transformVisibilityTaskContainerDom?.style.setProperty(\n property,\n kValue as string,\n )\n } else if (prop === 'removeProperty') {\n self.transformVisibilityTaskContainerDom?.style.removeProperty(\n property,\n )\n } else if (prop === 'getPropertyValue') {\n return self.transformVisibilityTaskContainerDom?.style.getPropertyValue(\n property,\n )\n }\n } else {\n return value.apply(this, args)\n }\n }.bind(target)\n } else {\n return value.bind(target)\n }\n } else {\n return value\n }\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 (prop === SpatialCustomStyleVars.backgroundMaterial) {\n target.setProperty(\n SpatialCustomStyleVars.backgroundMaterial,\n value as BackgroundMaterialType,\n )\n } else if (prop === SpatialCustomStyleVars.back) {\n target.setProperty(\n SpatialCustomStyleVars.back,\n value as string,\n )\n } else if (prop === SpatialCustomStyleVars.xrZIndex) {\n target.setProperty(\n SpatialCustomStyleVars.xrZIndex,\n value as string,\n )\n } else if (prop === SpatialCustomStyleVars.depth) {\n target.setProperty(\n SpatialCustomStyleVars.depth,\n value as string,\n )\n } else if (prop === 'cssText') {\n // parse cssText, filter out spatialStyle like back/transform/visibility/xrZIndex/backgroundMaterial\n const toFilteredCSSProperties = [\n 'transform',\n 'visibility',\n ]\n const { extractedValues, filteredCssText } =\n extractAndRemoveCustomProperties(\n value as string,\n toFilteredCSSProperties,\n )\n\n // update cssText for transformVisibilityTaskContainerDom\n toFilteredCSSProperties.forEach(key => {\n // update cssText for transformVisibilityTaskContainerDom according to extractedValues\n if (extractedValues[key]) {\n self.transformVisibilityTaskContainerDom?.style.setProperty(\n key,\n extractedValues[key],\n )\n } else {\n target.removeProperty(key)\n }\n })\n\n const appendedCSSText = joinToCSSText({\n transform: 'none',\n visibility: 'hidden',\n })\n\n // set cssText for spatialDiv\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\n return self.styleProxy\n }\n\n if (typeof prop === 'string' && self.extraRefProps) {\n if (!cacheExtraRefProps) {\n cacheExtraRefProps = self.extraRefProps(domProxy)\n }\n const extraProps = cacheExtraRefProps\n if (extraProps.hasOwnProperty(prop)) {\n return extraProps[prop]\n }\n }\n const value = Reflect.get(target, prop)\n if (typeof value === 'function') {\n if ('removeAttribute' === prop) {\n return function (this: any, ...args: any[]) {\n const [property] = args\n if (property === 'style') {\n dom.style.cssText =\n 'visibility: hidden; transition: none; transform: none;'\n if (self.transformVisibilityTaskContainerDom) {\n self.transformVisibilityTaskContainerDom.style.visibility =\n ''\n self.transformVisibilityTaskContainerDom.style.transform =\n ''\n }\n return true\n }\n if (property === 'class') {\n domProxy.className = 'xr-spatial-default'\n return true\n }\n }\n }\n\n return value.bind(target)\n }\n return value\n },\n set(target, prop, value) {\n if (prop === 'className') {\n if (value && value.indexOf('xr-spatial-default') === -1) {\n value = value + ' xr-spatial-default'\n }\n\n if (self.transformVisibilityTaskContainerDom) {\n self.transformVisibilityTaskContainerDom.className = value\n }\n }\n\n // check extraRefProps setter\n if (typeof prop === 'string' && self.extraRefProps) {\n if (!cacheExtraRefProps) {\n cacheExtraRefProps = self.extraRefProps(domProxy)\n }\n cacheExtraRefProps[prop] = value\n }\n\n return Reflect.set(target, prop, value)\n },\n },\n )\n this.domProxy = domProxy\n\n // hijack classList\n const domClassList = dom.classList\n const domClassMethodKeys: Array<'add' | 'remove' | 'toggle' | 'replace'> =\n ['add', 'remove', 'toggle', 'replace']\n domClassMethodKeys.forEach(key => {\n const hiddenKey = makeOriginalKey(key)\n const hiddenKeyExist = (domClassList as any)[hiddenKey] !== undefined\n const originalMethod = hiddenKeyExist\n ? (domClassList as any)[hiddenKey]\n : domClassList[key].bind(domClassList)\n\n ;(domClassList as any)[hiddenKey] = originalMethod\n\n domClassList[key] = function (this: any, ...args: any[]) {\n const result = (originalMethod as Function)(...args)\n // update transformVisibilityTaskContainerDom className\n if (self.transformVisibilityTaskContainerDom) {\n self.transformVisibilityTaskContainerDom.className = dom.className\n }\n\n return result\n }\n })\n\n // clear styleProxy\n this.styleProxy = undefined\n this.updateDomProxyToRef()\n\n // assign domProxy to dom\n Object.assign(dom, {\n __targetProxy: domProxy,\n })\n }\n }\n\n updateTransformVisibilityTaskContainerDom(dom: HTMLElement | null) {\n this.transformVisibilityTaskContainerDom = dom\n this.updateDomProxyToRef()\n }\n\n private updateDomProxyToRef() {\n const ref = this.ref\n if (!ref) {\n return\n }\n if (this.domProxy && this.transformVisibilityTaskContainerDom) {\n if (typeof ref === 'function') {\n ref(this.domProxy)\n } else {\n ref.current = this.domProxy\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 this.ref = ref\n }\n}\n\n// hijack getComputedStyle to get raw dom\nexport function hijackGetComputedStyle() {\n const rawFn = window.getComputedStyle.bind(window)\n window.getComputedStyle = (element, pseudoElt) => {\n const dom = (element as any).__raw\n\n if (dom) {\n return rawFn(dom, pseudoElt)\n }\n return rawFn(element, pseudoElt)\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 React, { ElementType } from 'react'\nimport { SpatialID } from './SpatialID'\nimport {\n CubeInfo,\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/** 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\nexport type SpatializedContentProps<\n T extends SpatializedElementRef,\n P extends ElementType,\n> = Omit<PortalSpatializedContainerProps<T>, 'spatializedContent'> & {\n spatializedElement: SpatializedElement\n}\n\nexport type Spatialized2DElementContainerProps<P extends ElementType> =\n SpatialEventProps<SpatializedElementRef> &\n React.ComponentPropsWithRef<'div'> & {\n component: P\n spatialEventOptions?: SpatialEventOptions\n }\n\nexport type SpatializedStatic3DContainerProps =\n SpatialEventProps<SpatializedStatic3DElementRef> &\n Omit<React.ComponentPropsWithoutRef<'div'>, 'onLoad' | 'onError'> & {\n src?: string\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 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}\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 { 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 {\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","import {\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 extraStyle = {\n visibility: 'hidden',\n transition: 'none',\n transform: transformExist ? 'translateZ(0)' : 'none',\n }\n const style = { ...inStyle, ...extraStyle }\n\n const classNames = className\n ? `${className} xr-spatial-default`\n : 'xr-spatial-default'\n\n return (\n <Component\n ref={refInternalCallback}\n style={style}\n className={classNames}\n {...restProps}\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\nexport function injectSpatialDefaultStyle() {\n // inject xr-spatial-default style to head\n const styleElement = document.createElement('style')\n styleElement.type = 'text/css'\n styleElement.innerHTML =\n ' :where(.xr-spatial-default) { --xr-back: 0; --xr-depth: 0; --xr-z-index: 0; --xr-background-material: none; } '\n document.head.appendChild(styleElement)\n}\n","import React, {\n CSSProperties,\n ForwardedRef,\n forwardRef,\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 { ForwardedRef, forwardRef, useContext, useEffect, useMemo } 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 ...inprops\n}: SpatializedContainerProps<T> & {\n innerRef: ForwardedRef<SpatializedElementRef<T>>\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 ...restProps\n } = inprops as DegradedProps\n return (\n <Component ref={innerRef} {...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 <DegradedContainer {...inprops} innerRef={ref} />\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 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 ...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={props.className}\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 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 ...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={props.className}\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\nexport class Spatial {\n /**\n * Requests a session object from the browser\n * @returns The session or null if not availible 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\n */\n getNativeVersion() {\n return null\n }\n /**\n * Gets the client version, format is \"x.x.x\"\n * @returns client version string\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 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!.getPropertyPriority('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) {\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 {\n SpatialCustomStyleVars,\n Point3D,\n SpatialTransformVisibility,\n} 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 { 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","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 { 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 useContext,\n useEffect,\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'\nfunction getJSXPortalInstance<P extends ElementType>(\n inProps: Omit<\n SpatializedContentProps<SpatializedElementRef, P>,\n 'spatializedElement'\n >,\n portalInstanceObject: PortalInstanceObject,\n) {\n const { component: El, style: inStyle = {}, ...props } = inProps\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 return <El 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, ...restProps } = props\n const spatialized2DElement = spatializedElement as Spatialized2DElement\n const { windowProxy } = spatialized2DElement\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 portalInstanceObject: PortalInstanceObject = useContext(\n PortalInstanceContext,\n )!\n const JSXPortalInstance = getJSXPortalInstance(\n restProps,\n portalInstanceObject,\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\nfunction defaultShouldSync(mutations?: MutationRecord[] | null) {\n if (!Array.isArray(mutations) || mutations.length === 0) return false\n for (const mutation of mutations) {\n const nodes: Node[] = [\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 true\n if (tag === 'LINK') {\n const { rel } = node as HTMLLinkElement\n if (rel && rel.toLowerCase() === 'stylesheet') return true\n }\n }\n }\n return false\n}\n\nexport function useSyncHeadStyles(\n childWindow: WindowProxy | null | undefined,\n options?: Options,\n) {\n const delayMs = 100\n const subtree = options?.subtree ?? false\n const immediate = options?.immediate ?? true\n\n useEffect(() => {\n if (!childWindow) return\n\n let timer: number | undefined\n const scheduleSync = () => {\n if (timer) window.clearTimeout(timer)\n timer = window.setTimeout(() => {\n syncParentHeadToChild(childWindow)\n }, delayMs)\n }\n\n if (immediate) scheduleSync()\n\n const observer = new MutationObserver(mutations => {\n if (!defaultShouldSync(mutations)) return\n scheduleSync()\n })\n observer.observe(document.head, { childList: true, subtree })\n\n return () => {\n if (timer) window.clearTimeout(timer)\n observer.disconnect()\n }\n }, [childWindow, delayMs, subtree, immediate])\n}\n","import {\n ForwardedRef,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from 'react'\nimport { SpatializedContainer } from './SpatializedContainer'\nimport { getSession } from '../utils'\nimport {\n ModelLoadEvent,\n SpatializedStatic3DContainerProps,\n SpatializedStatic3DContentProps,\n SpatializedStatic3DElementRef,\n} from './types'\nimport { SpatializedStatic3DElement } from '@webspatial/core-sdk'\nimport {\n PortalInstanceObject,\n PortalInstanceContext,\n} from './context/PortalInstanceContext'\n\nfunction getAbsoluteURL(url?: string) {\n if (!url) {\n return ''\n }\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 SpatializedContent(props: SpatializedStatic3DContentProps) {\n const { src, spatializedElement, onLoad, onError } = props\n const spatializedStatic3DElement =\n spatializedElement as SpatializedStatic3DElement\n\n const portalInstanceObject: PortalInstanceObject = useContext(\n PortalInstanceContext,\n )!\n\n const currentSrc: string = useMemo(() => getAbsoluteURL(src), [src])\n\n useEffect(() => {\n if (src) {\n spatializedStatic3DElement.updateProperties({ modelURL: currentSrc })\n }\n }, [currentSrc])\n\n useEffect(() => {\n if (onLoad) {\n spatializedStatic3DElement.onLoadCallback = () => {\n onLoad(\n createLoadSuccessEvent(\n () => (portalInstanceObject.dom as any).__targetProxy,\n ),\n )\n }\n } else {\n spatializedStatic3DElement.onLoadCallback = undefined\n }\n }, [onLoad])\n\n useEffect(() => {\n if (onError) {\n spatializedStatic3DElement.onLoadFailureCallback = () => {\n onError(\n createLoadFailureEvent(\n () => (portalInstanceObject.dom as any).__targetProxy,\n ),\n )\n }\n } else {\n spatializedStatic3DElement.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 const url = getAbsoluteURL(props.src)\n promiseRef.current = getSession()!.createSpatializedStatic3DElement(url)\n return promiseRef.current\n }, [])\n const extraRefProps = useCallback(\n (domProxy: SpatializedStatic3DElementRef) => {\n let modelTransform = new DOMMatrixReadOnly()\n\n return {\n get currentSrc(): string {\n return getAbsoluteURL(props.src)\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 }\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 { hijackGetComputedStyle } from './hooks/useDomProxy'\nimport { 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} from './types'\n\nexport function initPolyfill() {\n hijackGetComputedStyle()\n injectSpatialDefaultStyle()\n initCSSParserDivContainer()\n}\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 {\n SpatializedDynamic3DElement,\n SpatialObject,\n SpatialSession,\n} from '@webspatial/core-sdk'\nexport class ResourceRegistry {\n private resources: Map<string, Promise<SpatialObject>> = new Map()\n add<T extends SpatialObject>(id: string, resource: Promise<T>) {\n this.resources.set(id, resource)\n }\n remove(id: string) {\n this.resources.delete(id)\n }\n\n // Remove the resource by id and destroy it once resolved\n // This does not cancel in-flight creation; it schedules destruction after resolution\n removeAndDestroy(id: string) {\n const p = this.resources.get(id)\n if (p) {\n // Schedule destruction when the resource becomes available\n p.then(spatialObj => spatialObj.destroy()).catch(() => {\n // swallow rejection to avoid unhandled promise errors during teardown\n })\n }\n this.resources.delete(id)\n }\n get<T extends SpatialObject>(id: string) {\n return this.resources.get(id) as Promise<T>\n }\n destroy() {\n // Collect pending resources and clear registry immediately\n const pending = Array.from(this.resources.values())\n this.resources.clear()\n\n // Best-effort destroy for all resolved and future-resolving resources\n pending.forEach(promise =>\n promise\n .then(spatialObj => spatialObj.destroy())\n .catch(() => {\n // swallow rejection to avoid unhandled promise errors during teardown\n }),\n )\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(private 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 { useEffect, useImperativeHandle, useRef } from 'react'\nimport { Vec3, SpatialEntity } from '@webspatial/core-sdk'\nimport { RealityContextValue, useRealityContext } 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 React, { 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 React, { useCallback, useState } from 'react'\ntype Props = {\n children?: React.ReactNode\n}\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: SpatialMaterial[] = await Promise.all(\n materials\n ?.map(mid => ctx.resourceRegistry.get<SpatialMaterial>(mid))\n .filter(Boolean) ?? [],\n )\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: SpatialMaterial[] = await Promise.all(\n materials\n ?.map(id => ctx!.resourceRegistry.get<SpatialMaterial>(id))\n .filter(Boolean) ?? [],\n )\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 } from 'react'\nimport {\n SpatialUnlitMaterial,\n SpatialUnlitMaterialOptions,\n} from '@webspatial/core-sdk'\nimport { useRealityContext } from '../context'\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>()\n const isInitializedRef = useRef(false)\n\n useEffect(() => {\n if (!ctx) return\n const { session, reality, resourceRegistry } = ctx\n const init = async () => {\n const materialPromise = session.createUnlitMaterial(options)\n resourceRegistry.add(options.id, materialPromise)\n try {\n const mat = await materialPromise\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 // Use registry to schedule destruction after promise resolves\n resourceRegistry.removeAndDestroy(options.id)\n materialRef.current = undefined\n isInitializedRef.current = false\n }\n }, [ctx])\n\n // Dynamic property updates\n useEffect(() => {\n if (!isInitializedRef.current || !materialRef.current) return\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 (Object.keys(updates).length > 0) {\n materialRef.current.updateProperties(updates)\n }\n }, [options.color, options.transparent, options.opacity])\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'\ntype Props = {\n children?: React.ReactNode\n id: string // user id\n src: string // model url\n onLoad?: () => void\n onError?: (error: any) => void\n}\n\n// Resolve relative URLs to absolute for the native bridge\nconst resolveAssetUrl = (url: string): string => {\n if (url.startsWith('http://') || url.startsWith('https://')) {\n return url\n }\n return new URL(url, window.location.href).href\n}\n\nexport const ModelAsset: React.FC<Props> = ({ children, ...options }) => {\n const ctx = useRealityContext()\n const materialRef = useRef<SpatialModelAsset>()\n useEffect(() => {\n const controller = new AbortController()\n if (!ctx) return\n const { session, reality, resourceRegistry } = ctx\n const init = async () => {\n try {\n const resolvedUrl = resolveAssetUrl(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: SpatialMaterial[] = (\n await Promise.all(\n next.map(mid => ctx.resourceRegistry.get<SpatialMaterial>(mid)),\n )\n ).filter(Boolean)\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: SpatialMaterial[] = (\n await Promise.all(\n materials.map(mid =>\n ctx!.resourceRegistry.get<SpatialMaterial>(mid),\n ),\n )\n ).filter(Boolean)\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 = React.ComponentPropsWithRef<'div'> &\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, { subtree: false })\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 //@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) {\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'\nimport { SpatialID } from '../spatialized-container/SpatialID'\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 -> DOM proxy to underlying SpatializedElement.id\n const dom: any = (target as any)?.__raw ?? (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 { 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'\n\nexport const version = __WEBSPATIAL_REACT_SDK_VERSION__\n\nif (typeof window !== 'undefined') {\n initPolyfill()\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAuB,aAAa,WAAW,cAAc;;;ACkGtD,IAAM,yBAAyB;AAAA,EACpC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,oBAAoB;AAAA,EACpB,UAAU;AACZ;;;ACrGO,SAAS,uBACd,eACe;AAEf,MAAI,YAAqC;AAAA,IACvC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA,IAGA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA,IAGA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA;AAAA,IAEA;AAAA,IAEA;AAAA,IAC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nD;;;AC1DA,SAAS,uBAAuB,QAA8C;AAE5E,MAAI,OAAO,WAAW,eAAe,WAAW,QAAQ;AACtD,UAAM,QAAQ,WAAW,GAAG,gBAAgB;AAC5C,WAAO,OAAO,MAAM;AAAA,EACtB;AAGA,QAAM,cAAc;AACpB,MACE,eACA,OAAO,gBAAgB,YACvB,YAAY,aACZ;AACA,WAAO,YAAY,QAAQ,MAAM;AAAA,EACnC;AAGA,QAAM,MAAY,QAAgB,SAAU;AAC5C,MAAI,OAAO,OAAO,QAAQ,UAAU;AAClC,UAAM,qBACJ,IAAI,wBAAwB,IAAI,4BAA4B;AAC9D,QAAI,sBAAsB,mBAAmB,IAAI;AAC/C,aAAO,mBAAmB;AAAA,IAC5B;AAAA,EACF;AAEA,SAAO;AACT;AAEA,eAAsB,kBACpB,UACA,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;;;AC1DO,IAAM,UAAU;AAEvB,IAAI,OAAO,WAAW,aAAa;AACjC,eAAa;AACf;","names":["target","prop","value","useEffect","useCallback","useCallback","useEffect","useCallback","useContext","useEffect","useRef","useContext","useEffect","useRef","useCallback","forwardRef","useCallback","useRef","useCallback","useContext","useEffect","useContext","useCallback","useEffect","jsx","useInternalRef","useRef","useCallback","cssParserDivContainer","forwardRef","forwardRef","useContext","useEffect","useMemo","createContext","useContext","useEffect","createContext","getExtraSpatializedElementProperties","createContext","useEffect","useState","useEffect","useRef","useState","createSpatializedElement","jsx","createSpatializedElement","getExtraSpatializedElementProperties","useContext","useEffect","createContext","useContext","createContext","useState","useEffect","jsx","forwardRef","useContext","useState","useEffect","useContext","useState","useEffect","jsx","forwardRef","jsx","jsxs","useContext","useMemo","useEffect","createSpatializedElement","getExtraSpatializedElementProperties","forwardRef","createPortal","forwardRef","useContext","useEffect","version","useEffect","useEffect","jsx","useEffect","useContext","createPortal","forwardRef","forwardRef","useCallback","useContext","useEffect","useMemo","useRef","Fragment","jsx","SpatializedContent","useContext","useMemo","useEffect","useRef","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","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"]}