@webspatial/react-sdk 1.0.5 → 1.1.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.
- package/dist/default/index.js +117 -88
- package/dist/default/index.js.map +1 -1
- package/dist/jsx/jsx-dev-runtime.js +1 -1
- package/dist/jsx/jsx-dev-runtime.web.js +1 -1
- package/dist/jsx/jsx-runtime.js +1 -1
- package/dist/jsx/jsx-runtime.web.js +1 -1
- package/dist/web/index.js +117 -88
- package/dist/web/index.js.map +1 -1
- package/package.json +2 -2
package/dist/web/index.js.map
CHANGED
|
@@ -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/transform-utils.ts","../../src/spatialized-container/hooks/useSync2DFrame.ts","../../src/spatialized-container/hooks/useSpatializedElement.ts","../../src/spatialized-container/hooks/useSpatialEvents.ts","../../src/ssr/SSRContext.tsx","../../src/ssr/withSSRSupported.tsx","../../src/ssr/useSSRPhase.tsx","../../src/spatialized-container/Spatialized2DElementContainer.tsx","../../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/context/RealityContext.tsx","../../src/reality/context/ParentContext.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/useEntityId.tsx","../../src/reality/hooks/useEntity.tsx","../../src/reality/hooks/useEntityRef.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/Model.tsx","../../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?:\n | ((domProxy: T) => Record<string, () => any>)\n | undefined\n\n constructor(\n ref: ForwardedRef<SpatializedElementRef<T>>,\n extraRefProps?: (domProxy: T) => Record<string, () => any>,\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, () => any> | 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 === 'clientDepth') {\n return target.style.getPropertyValue(SpatialCustomStyleVars.depth)\n }\n if (prop === 'offsetBack') {\n return target.style.getPropertyValue(SpatialCustomStyleVars.back)\n }\n if (prop === 'getBoundingClientRect') {\n return (dom as any).__getBoundingClientRect\n }\n if (prop === 'getBoundingClientCube') {\n return (dom as any).__getBoundingClientCube\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') {\n return self.transformVisibilityTaskContainerDom?.style.getPropertyValue(\n 'visibility',\n )\n }\n if (prop === 'transform') {\n return self.transformVisibilityTaskContainerDom?.style.getPropertyValue(\n 'transform',\n )\n }\n const value = Reflect.get(target, prop)\n if (typeof value === 'function') {\n return value.bind(target)\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 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, () => any>,\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 SpatialRotateEvent as CoreSpatialRotateEvent,\n SpatialMagnifyEvent as CoreSpatialMagnifyEvent,\n SpatializedStatic3DElement,\n} from '@webspatial/core-sdk'\n\nexport type { Point3D, Vec3 } from '@webspatial/core-sdk'\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 onSpatialRotateStart?: (event: SpatialRotateStartEvent<T>) => void\n onSpatialRotate?: (event: SpatialRotateEvent<T>) => void\n onSpatialRotateEnd?: (event: SpatialRotateEndEvent<T>) => void\n onSpatialMagnifyStart?: (event: SpatialMagnifyStartEvent<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 RealityProps = SpatialEventProps<SpatializedElementRef> &\n React.ComponentPropsWithRef<'div'>\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\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, () => any>\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 }\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 }\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: DOMMatrix\n}\n\ntype CurrentTarget<T extends SpatializedElementRef> = {\n currentTarget: T\n}\n\nexport type SpatialTapEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialTapEvent & CurrentTarget<T>\n\nexport type SpatialDragStartEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialDragEvent & CurrentTarget<T>\n\nexport type SpatialDragEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialDragEvent & CurrentTarget<T>\n\nexport type SpatialDragEndEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialDragEvent & CurrentTarget<T>\n\nexport type SpatialRotateStartEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialRotateEvent & CurrentTarget<T>\n\nexport type SpatialRotateEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialRotateEvent & CurrentTarget<T>\n\nexport type SpatialRotateEndEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialRotateEvent & CurrentTarget<T>\n\nexport type SpatialMagnifyStartEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialMagnifyEvent & CurrentTarget<T>\n\nexport type SpatialMagnifyEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialMagnifyEvent & CurrentTarget<T>\n\nexport type SpatialMagnifyEndEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialMagnifyEvent & 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 ModelSpatialRotateStartEvent =\n SpatialRotateStartEvent<SpatializedStatic3DElementRef>\nexport type ModelSpatialRotateEvent =\n SpatialRotateEvent<SpatializedStatic3DElementRef>\nexport type ModelSpatialRotateEndEvent =\n SpatialRotateEndEvent<SpatializedStatic3DElementRef>\nexport type ModelSpatialMagnifyStartEvent =\n SpatialMagnifyStartEvent<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 ' .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 {\n useSpatialEvents,\n useSpatialEventsWhenSpatializedContainerExist,\n} from './hooks/useSpatialEvents'\nimport { withSSRSupported } from '../ssr'\nexport function SpatializedContainerBase<T extends SpatializedElementRef>(\n inprops: SpatializedContainerProps<T>,\n ref: ForwardedRef<SpatializedElementRef<T>>,\n) {\n const isWebSpatialEnv = getSession() !== null\n if (!isWebSpatialEnv) {\n const {\n component: Component,\n spatializedContent,\n createSpatializedElement,\n getExtraSpatializedElementProperties,\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n extraRefProps,\n ...restProps\n } = inprops\n // make sure SpatializedContainer can work on web env\n return <Component ref={ref} {...restProps} />\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 onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\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 onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\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 ...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 onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\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 ...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","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 { PortalSpatializedContainerProps, SpatializedElementRef } from './types'\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 onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\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 useEffect(() => {\n if (spatializedElement) {\n // @ts-ignore\n spatializedElement.onSpatialRotateStart = onSpatialRotateStart\n }\n }, [spatializedElement, onSpatialRotateStart])\n\n useEffect(() => {\n if (spatializedElement) {\n // @ts-ignore\n spatializedElement.onSpatialMagnifyStart = onSpatialMagnifyStart\n }\n }, [spatializedElement, onSpatialMagnifyStart])\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'\nimport { convertDOMRectToSceneSpace } from '../transform-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 // attach __getBoundingClientCube to dom\n const __getBoundingClientCube = () => {\n return this.spatializedElement?.cubeInfo\n }\n const __getBoundingClientRect = () => {\n if (!this.spatializedElement?.transform) {\n return null\n }\n\n const domRect = new DOMRect(\n 0,\n 0,\n this.domRect?.width,\n this.domRect?.height,\n )\n return convertDOMRectToSceneSpace(\n domRect,\n this.spatializedElement?.transform as DOMMatrix,\n )\n }\n const __toSceneSpace = (point: Point3D): DOMPoint => {\n return new DOMPoint(point.x, point.y, point.z).matrixTransform(\n this.spatializedElement?.transform,\n )\n }\n const __toLocalSpace = (point: Point3D): DOMPoint => {\n return new DOMPoint(point.x, point.y, point.z).matrixTransform(\n this.spatializedElement?.transformInv,\n )\n }\n\n const __innerSpatializedElement = () => this.spatializedElement\n\n Object.assign(dom, {\n __getBoundingClientCube,\n __getBoundingClientRect,\n __toSceneSpace,\n __toLocalSpace,\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 { Point3D, SpatializedElementRef } from './types'\n\nexport function toSceneSpatial(\n point: Point3D,\n spatializedElement: SpatializedElementRef,\n): DOMPoint {\n return (spatializedElement as any).__toSceneSpace(point)\n}\n\nexport function toLocalSpace(\n point: Point3D,\n spatializedElement: SpatializedElementRef,\n): DOMPoint {\n return (spatializedElement as any).__toLocalSpace(point)\n}\n\nexport function convertDOMRectToSceneSpace(\n originalRect: DOMRect,\n matrix: DOMMatrix,\n) {\n const topLeft = new DOMPoint(originalRect.left, originalRect.top)\n const topRight = new DOMPoint(originalRect.right, originalRect.top)\n const bottomRight = new DOMPoint(originalRect.right, originalRect.bottom)\n const bottomLeft = new DOMPoint(originalRect.left, originalRect.bottom)\n const transformedTopLeft = matrix.transformPoint(topLeft)\n const transformedTopRight = matrix.transformPoint(topRight)\n const transformedBottomRight = matrix.transformPoint(bottomRight)\n const transformedBottomLeft = matrix.transformPoint(bottomLeft)\n\n const allPoints = [\n transformedTopLeft,\n transformedTopRight,\n transformedBottomRight,\n transformedBottomLeft,\n ]\n const xCoords = allPoints.map(point => point.x)\n const yCoords = allPoints.map(point => point.y)\n\n const newMinX = Math.min(...xCoords)\n const newMaxX = Math.max(...xCoords)\n const newMinY = Math.min(...yCoords)\n const newMaxY = Math.max(...yCoords)\n\n return new DOMRect(newMinX, newMinY, newMaxX - newMinX, newMaxY - newMinY)\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, useState } from 'react'\nimport { PortalInstanceObject } from '../context/PortalInstanceContext'\nimport { SpatializedElement } from '@webspatial/core-sdk'\n\nexport function useSpatializedElement(\n createSpatializedElement: () => Promise<SpatializedElement>,\n portalInstanceObject: PortalInstanceObject,\n) {\n const [spatializedElement, setSpatializedElement] =\n useState<SpatializedElement>()\n\n useEffect(() => {\n let isDestroyed = false\n let spatializedElement: SpatializedElement | undefined\n createSpatializedElement().then(\n (inSpatializedElement: SpatializedElement) => {\n if (!isDestroyed) {\n spatializedElement = inSpatializedElement\n portalInstanceObject.attachSpatializedElement(spatializedElement)\n\n setSpatializedElement(spatializedElement)\n } else {\n inSpatializedElement?.destroy()\n }\n },\n )\n\n return () => {\n isDestroyed = true\n if (spatializedElement) {\n spatializedElement.destroy()\n spatializedElement = undefined\n }\n }\n }, [createSpatializedElement, portalInstanceObject])\n\n return spatializedElement\n}\n","import { RefObject } from 'react'\nimport { SpatialContainerRefProxy } from './useDomProxy'\nimport {\n SpatialDragEndEvent,\n SpatialDragEvent,\n SpatialRotateEvent,\n SpatialTapEvent,\n SpatializedElementRef,\n SpatialRotateEndEvent,\n SpatialMagnifyEndEvent,\n SpatialMagnifyEvent,\n SpatialRotateStartEvent,\n SpatialMagnifyStartEvent,\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: SpatialDragEvent<T>) => void\n onSpatialDrag?: (event: SpatialDragEvent<T>) => void\n onSpatialDragEnd?: (event: SpatialDragEndEvent<T>) => void\n onSpatialRotateStart?: (event: SpatialRotateStartEvent<T>) => void\n onSpatialRotate?: (event: SpatialRotateEvent<T>) => void\n onSpatialRotateEnd?: (event: SpatialRotateEndEvent<T>) => void\n onSpatialMagnifyStart?: (event: SpatialMagnifyStartEvent<T>) => void\n onSpatialMagnify?: (event: SpatialMagnifyEvent<T>) => void\n onSpatialMagnifyEnd?: (event: SpatialMagnifyEndEvent<T>) => void\n}\n\n// Create a generic event proxy factory function\nfunction createEventProxy<\n T extends SpatializedElementRef,\n E extends { currentTarget: T },\n>(event: E, currentTargetGetter: () => T): 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 return Reflect.get(target, prop)\n },\n })\n}\n\n// Create an event handler factory function\nfunction createEventHandler<\n T extends SpatializedElementRef,\n E extends { currentTarget: T },\n>(\n handler: ((event: E) => void) | undefined,\n currentTargetGetter: () => T,\n): ((event: E) => void) | undefined {\n return handler\n ? (event: E) => {\n const proxyEvent = createEventProxy<T, E>(event, currentTargetGetter)\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 )\n\n const onSpatialDrag = createEventHandler<T, SpatialDragEvent<T>>(\n spatialEvents.onSpatialDrag,\n currentTargetGetter,\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 )\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 )\n\n const onSpatialMagnifyEnd = createEventHandler<T, SpatialMagnifyEndEvent<T>>(\n spatialEvents.onSpatialMagnifyEnd,\n currentTargetGetter,\n )\n\n const onSpatialDragStart = createEventHandler<T, SpatialDragEvent<T>>(\n spatialEvents.onSpatialDragStart,\n currentTargetGetter,\n )\n\n const onSpatialRotateStart = createEventHandler<\n T,\n SpatialRotateStartEvent<T>\n >(spatialEvents.onSpatialRotateStart, currentTargetGetter)\n\n const onSpatialMagnifyStart = createEventHandler<\n T,\n SpatialMagnifyStartEvent<T>\n >(spatialEvents.onSpatialMagnifyStart, currentTargetGetter)\n\n return {\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\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 React, {\n CSSProperties,\n ElementType,\n ForwardedRef,\n forwardRef,\n useContext,\n useEffect,\n} from 'react'\nimport { SpatializedContainer } from './SpatializedContainer'\nimport { getSession } from '../utils'\nimport {\n SpatialCustomStyleVars,\n Spatialized2DElementContainerProps,\n SpatializedElementRef,\n SpatializedContentProps,\n SpatializedDivElementRef,\n} from './types'\nimport {\n PortalInstanceContext,\n PortalInstanceObject,\n} from './context/PortalInstanceContext'\nimport { Spatialized2DElement } from '@webspatial/core-sdk'\nimport { createPortal } from 'react-dom'\nimport { getInheritedStyleProps, parseCornerRadius } from './utils'\n\nfunction asyncLoadStyleToChildWindow(\n childWindow: WindowProxy,\n n: HTMLLinkElement,\n) {\n return new Promise(resolve => {\n // Safari seems to have a bug where\n // ~1/50 loads, if the same url is loaded very quickly in a window and a child window,\n // the second load request never is fired resulting in css not to be applied.\n // Workaround this by making the css stylesheet request unique\n n.href += '?uniqueURL=' + Math.random()\n n.onerror = function (error) {\n console.error('Failed to load style link', (n as HTMLLinkElement).href)\n resolve(false)\n }\n n.onload = function () {\n resolve(true)\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 setTimeout(() => {\n childWindow.document.head.appendChild(n)\n }, 50)\n })\n}\n\nfunction 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\nasync function syncParentHeadToChild(childWindow: WindowProxy) {\n const styleLoadedPromises = []\n\n for (let i = 0; i < document.head.children.length; i++) {\n let n = document.head.children[i].cloneNode(true)\n if (\n n.nodeName == 'LINK' &&\n (n as HTMLLinkElement).rel == 'stylesheet' &&\n (n as HTMLLinkElement).href\n ) {\n const promise = asyncLoadStyleToChildWindow(\n childWindow,\n n as HTMLLinkElement,\n )\n styleLoadedPromises.push(promise)\n } else {\n childWindow.document.head.appendChild(n)\n }\n }\n\n // sync className\n childWindow.document.documentElement.className =\n document.documentElement.className\n\n return Promise.all(styleLoadedPromises)\n}\n\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 useSyncHeaderStyle(windowProxy: WindowProxy) {\n useEffect(() => {\n // sync parent head to child when document header style changed\n const headObserver = new MutationObserver(_ => {\n syncParentHeadToChild(windowProxy)\n })\n\n headObserver.observe(document.head, { childList: true, subtree: true })\n return () => {\n headObserver.disconnect()\n }\n }, [])\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.windowProxy\n\n useSyncHeaderStyle(windowProxy)\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.windowProxy\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","import {\n ForwardedRef,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\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 if (url.startsWith('http') || url.startsWith('//')) {\n return url\n }\n return window.location.origin + url\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\nasync function createSpatializedElement() {\n return getSession()!.createSpatializedStatic3DElement()\n}\n\nfunction SpatializedStatic3DElementContainerBase(\n props: SpatializedStatic3DContainerProps,\n ref: ForwardedRef<SpatializedStatic3DElementRef>,\n) {\n const extraRefProps = useCallback(\n (domProxy: SpatializedStatic3DElementRef) => {\n const modelTransform = new DOMMatrix()\n let needupdate = false\n const triggerUpdate = () => {\n const spatializedElement = (domProxy as any)\n .__spatializedElement as SpatializedStatic3DElement\n spatializedElement.updateModelTransform(modelTransform)\n needupdate = false\n }\n const domMatrixProxy = new Proxy(modelTransform, {\n get(target, prop, receiver) {\n const value = Reflect.get(target, prop, receiver)\n if (typeof value === 'function') {\n return function (...args: any[]) {\n requestAnimationFrame(triggerUpdate)\n return value.apply(target, args)\n }\n } else {\n return value\n }\n },\n set(target, prop, value) {\n const success = Reflect.set(target, prop, value)\n if (!needupdate) {\n needupdate = true\n requestAnimationFrame(triggerUpdate)\n }\n return success\n },\n })\n\n return {\n currentSrc: () => getAbsoluteURL(props.src),\n ready: () => {\n const spatializedElement = (domProxy as any)\n .__spatializedElement as SpatializedStatic3DElement\n\n const promise = spatializedElement.ready.then((success: boolean) => {\n if (success) {\n return createLoadSuccessEvent(() => domProxy)\n }\n throw createLoadFailureEvent(() => domProxy)\n })\n return promise\n },\n entityTransform: () => domMatrixProxy,\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 SpatialRotateStartEvent,\n type SpatialRotateEvent,\n type SpatialRotateEndEvent,\n type SpatialMagnifyStartEvent,\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 ModelSpatialRotateStartEvent,\n type ModelSpatialRotateEvent,\n type ModelSpatialRotateEndEvent,\n type ModelSpatialMagnifyEvent,\n type ModelSpatialMagnifyEndEvent,\n type ModelLoadEvent,\n} from './types'\n\nexport { toSceneSpatial, toLocalSpace } from './transform-utils'\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 { ParentContext, useRealityContext } from '../context'\nimport { EntityProps, EntityEventHandler } from '../type'\nimport { EntityRefShape, useEntity, useEntityRef } from '../hooks'\n\ntype Props = EntityProps & EntityEventHandler & { children?: React.ReactNode }\n\nexport const Entity = forwardRef<EntityRefShape, Props>(\n ({ id, children, position, rotation, scale, onSpatialTap, name }, ref) => {\n const ctx = useRealityContext()\n const entity = useEntity({\n ref,\n id,\n position,\n rotation,\n scale,\n onSpatialTap,\n createEntity: async () => ctx!.session.createEntity({ id, name }),\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'\n\nexport type RealityContextValue = {\n session: SpatialSession\n reality: SpatializedDynamic3DElement\n resourceRegistry: ResourceRegistry\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 { 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())\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 => promise.then(spatialObj => spatialObj.destroy()))\n }\n}\n","export function shallowEqualVec3(\n a?: { x: number; y: number; z: number },\n b?: { x: number; y: number; z: number },\n) {\n if (a === b) return true\n if (!a || !b) return false\n return a.x === b.x && a.y === b.y && a.z === b.z\n}\n\nexport function shallowEqualRotation(a?: any, b?: any) {\n if (a === b) return true\n if (!a || !b) return false\n // support Vec3 / Vec4\n return (\n a.x === b.x && a.y === b.y && a.z === b.z && ('w' in a ? a.w === b.w : true)\n )\n}\n","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 } from 'react'\nimport { EntityEventHandler, eventMap } from '../type'\nimport { EntityRef } from './useEntityRef'\n\nfunction createEventProxy(ev: any, instance: EntityRef) {\n return new Proxy(ev, {\n get(target, prop: PropertyKey) {\n if (prop === 'target' || prop === 'currentTarget') {\n return instance\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 useEffect(() => {\n const entity = instance.entity\n if (!entity) return\n\n const boundHandlers: (() => void)[] = []\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 entity.addEvent(spatialEvent as any, wrapped)\n boundHandlers.push(() => entity.removeEvent(spatialEvent as any))\n })\n return () => {\n boundHandlers.forEach(unbind => unbind())\n }\n }, [instance.entity, ...Object.values(handlers)])\n\n return null\n}\n","import { Vec3 } from '@webspatial/core-sdk'\nimport { EntityRefShape } from './hooks'\nimport { SpatialTapEvent as CoreSpatialTapEvent } from '@webspatial/core-sdk'\nimport { SpatialDragEvent as CoreSpatialDragEvent } 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'\n\nexport type EntityProps = {\n id?: string\n name?: string\n position?: Vec3\n rotation?: Vec3\n scale?: Vec3\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 & allTarget<T>\n// drag\nexport type SpatialDragEntityEvent<T extends EntityRefShape = EntityRefShape> =\n CoreSpatialDragEvent & allTarget<T>\n// rotate\nexport type SpatialRotateEntityEvent<\n T extends EntityRefShape = EntityRefShape,\n> = CoreSpatialRotateEvent & allTarget<T>\nexport type SpatialRotateEndEntityEvent<\n T extends EntityRefShape = EntityRefShape,\n> = CoreSpatialRotateEndEvent & allTarget<T>\n// magnify\nexport type SpatialMagnifyEntityEvent<\n T extends EntityRefShape = EntityRefShape,\n> = CoreSpatialMagnifyEvent & allTarget<T>\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: SpatialDragEntityEvent) => void\n onSpatialDrag?: (event: SpatialDragEntityEvent) => void\n onSpatialDragEnd?: (event: SpatialDragEntityEvent) => void\n // rotate\n onSpatialRotateStart?: (event: SpatialRotateEntityEvent) => void\n onSpatialRotate?: (event: SpatialRotateEntityEvent) => void\n onSpatialRotateEnd?: (event: SpatialRotateEndEntityEvent) => void\n // magnify\n onSpatialMagnifyStart?: (event: SpatialMagnifyEntityEvent) => void\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 onSpatialRotateStart: 'spatialrotatestart',\n onSpatialRotate: 'spatialrotate',\n onSpatialRotateEnd: 'spatialrotateend',\n // magnify\n onSpatialMagnifyStart: 'spatialmagnifystart',\n onSpatialMagnify: 'spatialmagnify',\n onSpatialMagnifyEnd: 'spatialmagnifyend',\n} as const\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 { 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} & EntityProps &\n EntityEventHandler & { ref: ForwardedRef<EntityRefShape> }\n\nexport const useEntity = ({\n ref,\n id,\n position,\n rotation,\n scale,\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n // TODO: add other event handlers\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 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 useEntityEvent({\n instance: instanceRef.current,\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n })\n\n return instanceRef.current.entity\n}\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, { 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, EntityEventHandler } 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 EntityEventHandler & {\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 { ParentContext, useRealityContext } from '../context'\nimport { EntityProps, EntityEventHandler } from '../type'\nimport { useEntityRef, EntityRefShape, useEntity } from '../hooks'\nimport { SpatialMaterial, SpatialGeometry } from '@webspatial/core-sdk'\nimport { AbortResourceManager } from '../utils'\n\ntype GeometryEntityProps = EntityProps &\n EntityEventHandler & {\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 {\n id,\n position,\n rotation,\n scale,\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n // TODO: add other event handlers\n children,\n name,\n materials,\n geometryOptions,\n createGeometry,\n },\n ref,\n ) => {\n const ctx = useRealityContext()\n const entity = useEntity({\n ref,\n id,\n position,\n rotation,\n scale,\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n\n createEntity: async (signal: AbortSignal) => {\n const manager = new AbortResourceManager(signal)\n\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\n if (!entity) return null\n return (\n <ParentContext.Provider value={entity}>{children}</ParentContext.Provider>\n )\n },\n)\n","import React, { useEffect, useRef } from 'react'\nimport {\n SpatialUnlitMaterial,\n SpatialUnlitMaterialOptions,\n} from '@webspatial/core-sdk'\nimport { useRealityContext } from '../context'\ntype Props = {\n children?: React.ReactNode\n id: string // user id\n} & SpatialUnlitMaterialOptions\nexport const UnlitMaterial: React.FC<Props> = ({ children, ...options }) => {\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, EntityEventHandler } 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 EntityEventHandler & {\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, EntityEventHandler } 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 EntityEventHandler & {\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, EntityEventHandler } 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 EntityEventHandler & {\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, EntityEventHandler } 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 EntityEventHandler & {\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 const resolvedUrl = resolveAssetUrl(options.src)\n const modelAssetPromise = session.createModelAsset({ url: resolvedUrl })\n resourceRegistry.add(options.id, modelAssetPromise)\n\n try {\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 { ParentContext, useRealityContext } from '../context'\nimport { EntityProps, EntityEventHandler } from '../type'\nimport { EntityRefShape, useEntity, useEntityRef } from '../hooks'\n\ntype Props = EntityProps & { model: string } & EntityEventHandler & {\n children?: React.ReactNode\n }\n\nexport const ModelEntity = forwardRef<EntityRefShape, Props>(\n (\n { id, model, position, rotation, scale, onSpatialTap, children, name },\n ref,\n ) => {\n const ctx = useRealityContext()\n const entity = useEntity({\n ref,\n id,\n position,\n rotation,\n scale,\n onSpatialTap,\n createEntity: async (signal: AbortSignal) => {\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) {\n return null\n }\n\n return ctx!.session.createSpatialModelEntity(\n {\n modelAssetId: modelAsset.id,\n name,\n },\n { id, name },\n )\n } catch (error) {\n console.error('ModelEntity error:', error)\n return null as any\n }\n },\n })\n\n if (!entity) return null\n return (\n <ParentContext.Provider value={entity}>{children}</ParentContext.Provider>\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 { getSession } from '../../utils/getSession'\nimport { ResourceRegistry } from '../utils'\nimport {\n RealityProps,\n SpatializedElementRef,\n} from '../../spatialized-container/types'\nimport { SpatializedElement } from '@webspatial/core-sdk'\n\nexport const Reality = forwardRef<SpatializedElementRef, RealityProps>(\n function RealityBase({ children, ...props }, ref) {\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?.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 session = await getSession()\n if (!session) {\n resourceRegistry.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 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 reality.destroy()\n return null\n }\n\n cleanupReality()\n\n ctxRef.current = { session, reality, resourceRegistry }\n setIsReady(true)\n return reality as SpatializedElement\n } catch (err) {\n console.error('[createReality] failed', err)\n resourceRegistry.destroy()\n reality.destroy()\n return null\n }\n }, [cleanupReality])\n\n const content = useCallback(() => <></>, [])\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 { ForwardedRef, forwardRef } from 'react'\nimport {\n SpatializedStatic3DContainerProps,\n SpatializedStatic3DElementContainer,\n SpatializedStatic3DElementRef,\n} from './spatialized-container'\nimport { withSSRSupported } from './ssr'\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 { 'enable-xr': enableXR, ...restProps } = props\n if (!enableXR || !spatial.runInSpatialWeb()) {\n const {\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n ...modelProps\n } = restProps\n // map to VisionOS26 model tag\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 { 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'\n\nexport const version = __WEBSPATIAL_REACT_SDK_VERSION__\n\nif (typeof window !== 'undefined') {\n initPolyfill()\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAuB,aAAa,WAAW,cAAc;;;ACqFtD,IAAM,yBAAyB;AAAA,EACpC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,oBAAoB;AAAA,EACpB,UAAU;AACZ;;;ACxFO,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,IACA;AAAA,IAEA;AAAA;AAAA,IAGA;AAAA,EACF;AACA,MAAI,QAAuB,CAAC;AAC5B,WAAS,WAAW,WAAW;AAC7B,QAAK,cAAsB,OAAO,GAAG;AACnC,YAAM,OAAO,IAAK,cAAsB,OAAO;AAAA,IACjD;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,qBAAqB,eAAoC;AACvE,QAAM,0BACJ,cAAc,iBAAiB,kBAAkB;AACnD,QAAM,CAAC,GAAG,CAAC,IAAI,wBA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,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","useState","createSpatializedElement","spatializedElement","jsx","createSpatializedElement","getExtraSpatializedElementProperties","useContext","useEffect","createContext","useState","useEffect","jsx","forwardRef","useContext","useState","useEffect","useContext","useState","useEffect","jsx","forwardRef","jsx","jsxs","createSpatializedElement","getExtraSpatializedElementProperties","onSpatialTap","onSpatialDragStart","onSpatialDrag","onSpatialDragEnd","onSpatialRotateStart","onSpatialRotate","onSpatialRotateEnd","onSpatialMagnifyStart","onSpatialMagnify","onSpatialMagnifyEnd","extraRefProps","useContext","useMemo","useEffect","forwardRef","forwardRef","useContext","useEffect","createPortal","jsx","useEffect","useContext","createPortal","forwardRef","forwardRef","useCallback","useContext","useEffect","useMemo","Fragment","jsx","SpatializedContent","useContext","useMemo","useEffect","createSpatializedElement","useCallback","forwardRef","forwardRef","jsx","forwardRef","forwardRef","useRef","useEffect","useMemo","useRef","useEffect","useMemo","useEffect","useEffect","forwardRef","jsx","jsx","forwardRef","forwardRef","createContext","useContext","createContext","useContext","useEffect","useRef","useRef","useEffect","useEffect","createEventProxy","useEffect","useEffect","useEffect","useEffect","useRef","useRef","useForceUpdate","useEffect","useCallback","useState","useForceUpdate","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","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/transform-utils.ts","../../src/spatialized-container/hooks/useSync2DFrame.ts","../../src/spatialized-container/hooks/useSpatializedElement.ts","../../src/spatialized-container/hooks/useSpatialEvents.ts","../../src/ssr/SSRContext.tsx","../../src/ssr/withSSRSupported.tsx","../../src/ssr/useSSRPhase.tsx","../../src/spatialized-container/Spatialized2DElementContainer.tsx","../../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/context/RealityContext.tsx","../../src/reality/context/ParentContext.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/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/Model.tsx","../../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?:\n | ((domProxy: T) => Record<string, () => any>)\n | undefined\n\n constructor(\n ref: ForwardedRef<SpatializedElementRef<T>>,\n extraRefProps?: (domProxy: T) => Record<string, () => any>,\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, () => any> | 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 === 'clientDepth') {\n return target.style.getPropertyValue(SpatialCustomStyleVars.depth)\n }\n if (prop === 'offsetBack') {\n return target.style.getPropertyValue(SpatialCustomStyleVars.back)\n }\n if (prop === 'getBoundingClientRect') {\n return (dom as any).__getBoundingClientRect\n }\n if (prop === 'getBoundingClientCube') {\n return (dom as any).__getBoundingClientCube\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 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, () => any>,\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 SpatialRotateEvent as CoreSpatialRotateEvent,\n SpatialMagnifyEvent as CoreSpatialMagnifyEvent,\n SpatializedStatic3DElement,\n} from '@webspatial/core-sdk'\n\nexport type { Point3D, Vec3 } from '@webspatial/core-sdk'\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 onSpatialRotateStart?: (event: SpatialRotateStartEvent<T>) => void\n onSpatialRotate?: (event: SpatialRotateEvent<T>) => void\n onSpatialRotateEnd?: (event: SpatialRotateEndEvent<T>) => void\n onSpatialMagnifyStart?: (event: SpatialMagnifyStartEvent<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 RealityProps = SpatialEventProps<SpatializedElementRef> &\n React.ComponentPropsWithRef<'div'>\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\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, () => any>\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 }\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 }\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: DOMMatrix\n}\n\ntype CurrentTarget<T extends SpatializedElementRef> = {\n currentTarget: T\n}\n\nexport type SpatialTapEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialTapEvent & CurrentTarget<T>\n\nexport type SpatialDragStartEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialDragEvent & CurrentTarget<T>\n\nexport type SpatialDragEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialDragEvent & CurrentTarget<T>\n\nexport type SpatialDragEndEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialDragEvent & CurrentTarget<T>\n\nexport type SpatialRotateStartEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialRotateEvent & CurrentTarget<T>\n\nexport type SpatialRotateEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialRotateEvent & CurrentTarget<T>\n\nexport type SpatialRotateEndEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialRotateEvent & CurrentTarget<T>\n\nexport type SpatialMagnifyStartEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialMagnifyEvent & CurrentTarget<T>\n\nexport type SpatialMagnifyEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialMagnifyEvent & CurrentTarget<T>\n\nexport type SpatialMagnifyEndEvent<\n T extends SpatializedElementRef = SpatializedElementRef,\n> = CoreSpatialMagnifyEvent & 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 ModelSpatialRotateStartEvent =\n SpatialRotateStartEvent<SpatializedStatic3DElementRef>\nexport type ModelSpatialRotateEvent =\n SpatialRotateEvent<SpatializedStatic3DElementRef>\nexport type ModelSpatialRotateEndEvent =\n SpatialRotateEndEvent<SpatializedStatic3DElementRef>\nexport type ModelSpatialMagnifyStartEvent =\n SpatialMagnifyStartEvent<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 ' .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 {\n useSpatialEvents,\n useSpatialEventsWhenSpatializedContainerExist,\n} from './hooks/useSpatialEvents'\nimport { withSSRSupported } from '../ssr'\nexport function SpatializedContainerBase<T extends SpatializedElementRef>(\n inprops: SpatializedContainerProps<T>,\n ref: ForwardedRef<SpatializedElementRef<T>>,\n) {\n const isWebSpatialEnv = getSession() !== null\n if (!isWebSpatialEnv) {\n const {\n component: Component,\n spatializedContent,\n createSpatializedElement,\n getExtraSpatializedElementProperties,\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n extraRefProps,\n ...restProps\n } = inprops\n // make sure SpatializedContainer can work on web env\n return <Component ref={ref} {...restProps} />\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 onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\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 onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\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 ...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 onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\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 ...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","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 { PortalSpatializedContainerProps, SpatializedElementRef } from './types'\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 onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\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 useEffect(() => {\n if (spatializedElement) {\n // @ts-ignore\n spatializedElement.onSpatialRotateStart = onSpatialRotateStart\n }\n }, [spatializedElement, onSpatialRotateStart])\n\n useEffect(() => {\n if (spatializedElement) {\n // @ts-ignore\n spatializedElement.onSpatialMagnifyStart = onSpatialMagnifyStart\n }\n }, [spatializedElement, onSpatialMagnifyStart])\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'\nimport { convertDOMRectToSceneSpace } from '../transform-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 // attach __getBoundingClientCube to dom\n const __getBoundingClientCube = () => {\n return this.spatializedElement?.cubeInfo\n }\n const __getBoundingClientRect = () => {\n if (!this.spatializedElement?.transform) {\n return null\n }\n\n const domRect = new DOMRect(\n 0,\n 0,\n this.domRect?.width,\n this.domRect?.height,\n )\n return convertDOMRectToSceneSpace(\n domRect,\n this.spatializedElement?.transform as DOMMatrix,\n )\n }\n const __toSceneSpace = (point: Point3D): DOMPoint => {\n return new DOMPoint(point.x, point.y, point.z).matrixTransform(\n this.spatializedElement?.transform,\n )\n }\n const __toLocalSpace = (point: Point3D): DOMPoint => {\n return new DOMPoint(point.x, point.y, point.z).matrixTransform(\n this.spatializedElement?.transformInv,\n )\n }\n\n const __innerSpatializedElement = () => this.spatializedElement\n\n Object.assign(dom, {\n __getBoundingClientCube,\n __getBoundingClientRect,\n __toSceneSpace,\n __toLocalSpace,\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 { Point3D, SpatializedElementRef } from './types'\n\nexport function toSceneSpatial(\n point: Point3D,\n spatializedElement: SpatializedElementRef,\n): DOMPoint {\n return (spatializedElement as any).__toSceneSpace(point)\n}\n\nexport function toLocalSpace(\n point: Point3D,\n spatializedElement: SpatializedElementRef,\n): DOMPoint {\n return (spatializedElement as any).__toLocalSpace(point)\n}\n\nexport function convertDOMRectToSceneSpace(\n originalRect: DOMRect,\n matrix: DOMMatrix,\n) {\n const topLeft = new DOMPoint(originalRect.left, originalRect.top)\n const topRight = new DOMPoint(originalRect.right, originalRect.top)\n const bottomRight = new DOMPoint(originalRect.right, originalRect.bottom)\n const bottomLeft = new DOMPoint(originalRect.left, originalRect.bottom)\n const transformedTopLeft = matrix.transformPoint(topLeft)\n const transformedTopRight = matrix.transformPoint(topRight)\n const transformedBottomRight = matrix.transformPoint(bottomRight)\n const transformedBottomLeft = matrix.transformPoint(bottomLeft)\n\n const allPoints = [\n transformedTopLeft,\n transformedTopRight,\n transformedBottomRight,\n transformedBottomLeft,\n ]\n const xCoords = allPoints.map(point => point.x)\n const yCoords = allPoints.map(point => point.y)\n\n const newMinX = Math.min(...xCoords)\n const newMaxX = Math.max(...xCoords)\n const newMinY = Math.min(...yCoords)\n const newMaxY = Math.max(...yCoords)\n\n return new DOMRect(newMinX, newMinY, newMaxX - newMinX, newMaxY - newMinY)\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, useState } from 'react'\nimport { PortalInstanceObject } from '../context/PortalInstanceContext'\nimport { SpatializedElement } from '@webspatial/core-sdk'\n\nexport function useSpatializedElement(\n createSpatializedElement: () => Promise<SpatializedElement>,\n portalInstanceObject: PortalInstanceObject,\n) {\n const [spatializedElement, setSpatializedElement] =\n useState<SpatializedElement>()\n\n useEffect(() => {\n let isDestroyed = false\n let spatializedElement: SpatializedElement | undefined\n createSpatializedElement().then(\n (inSpatializedElement: SpatializedElement) => {\n if (!isDestroyed) {\n spatializedElement = inSpatializedElement\n portalInstanceObject.attachSpatializedElement(spatializedElement)\n\n setSpatializedElement(spatializedElement)\n } else {\n inSpatializedElement?.destroy()\n }\n },\n )\n\n return () => {\n isDestroyed = true\n if (spatializedElement) {\n spatializedElement.destroy()\n spatializedElement = undefined\n }\n }\n }, [createSpatializedElement, portalInstanceObject])\n\n return spatializedElement\n}\n","import { RefObject } from 'react'\nimport { SpatialContainerRefProxy } from './useDomProxy'\nimport {\n SpatialDragEndEvent,\n SpatialDragEvent,\n SpatialRotateEvent,\n SpatialTapEvent,\n SpatializedElementRef,\n SpatialRotateEndEvent,\n SpatialMagnifyEndEvent,\n SpatialMagnifyEvent,\n SpatialRotateStartEvent,\n SpatialMagnifyStartEvent,\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: SpatialDragEvent<T>) => void\n onSpatialDrag?: (event: SpatialDragEvent<T>) => void\n onSpatialDragEnd?: (event: SpatialDragEndEvent<T>) => void\n onSpatialRotateStart?: (event: SpatialRotateStartEvent<T>) => void\n onSpatialRotate?: (event: SpatialRotateEvent<T>) => void\n onSpatialRotateEnd?: (event: SpatialRotateEndEvent<T>) => void\n onSpatialMagnifyStart?: (event: SpatialMagnifyStartEvent<T>) => void\n onSpatialMagnify?: (event: SpatialMagnifyEvent<T>) => void\n onSpatialMagnifyEnd?: (event: SpatialMagnifyEndEvent<T>) => void\n}\n\n// Create a generic event proxy factory function\nfunction createEventProxy<\n T extends SpatializedElementRef,\n E extends { currentTarget: T },\n>(event: E, currentTargetGetter: () => T): 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 return Reflect.get(target, prop)\n },\n })\n}\n\n// Create an event handler factory function\nfunction createEventHandler<\n T extends SpatializedElementRef,\n E extends { currentTarget: T },\n>(\n handler: ((event: E) => void) | undefined,\n currentTargetGetter: () => T,\n): ((event: E) => void) | undefined {\n return handler\n ? (event: E) => {\n const proxyEvent = createEventProxy<T, E>(event, currentTargetGetter)\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 )\n\n const onSpatialDrag = createEventHandler<T, SpatialDragEvent<T>>(\n spatialEvents.onSpatialDrag,\n currentTargetGetter,\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 )\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 )\n\n const onSpatialMagnifyEnd = createEventHandler<T, SpatialMagnifyEndEvent<T>>(\n spatialEvents.onSpatialMagnifyEnd,\n currentTargetGetter,\n )\n\n const onSpatialDragStart = createEventHandler<T, SpatialDragEvent<T>>(\n spatialEvents.onSpatialDragStart,\n currentTargetGetter,\n )\n\n const onSpatialRotateStart = createEventHandler<\n T,\n SpatialRotateStartEvent<T>\n >(spatialEvents.onSpatialRotateStart, currentTargetGetter)\n\n const onSpatialMagnifyStart = createEventHandler<\n T,\n SpatialMagnifyStartEvent<T>\n >(spatialEvents.onSpatialMagnifyStart, currentTargetGetter)\n\n return {\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\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 React, {\n CSSProperties,\n ElementType,\n ForwardedRef,\n forwardRef,\n useContext,\n useEffect,\n} from 'react'\nimport { SpatializedContainer } from './SpatializedContainer'\nimport { getSession } from '../utils'\nimport {\n SpatialCustomStyleVars,\n Spatialized2DElementContainerProps,\n SpatializedElementRef,\n SpatializedContentProps,\n SpatializedDivElementRef,\n} from './types'\nimport {\n PortalInstanceContext,\n PortalInstanceObject,\n} from './context/PortalInstanceContext'\nimport { Spatialized2DElement } from '@webspatial/core-sdk'\nimport { createPortal } from 'react-dom'\nimport { getInheritedStyleProps, parseCornerRadius } from './utils'\n\nfunction asyncLoadStyleToChildWindow(\n childWindow: WindowProxy,\n n: HTMLLinkElement,\n) {\n return new Promise(resolve => {\n // Safari seems to have a bug where\n // ~1/50 loads, if the same url is loaded very quickly in a window and a child window,\n // the second load request never is fired resulting in css not to be applied.\n // Workaround this by making the css stylesheet request unique\n n.href += '?uniqueURL=' + Math.random()\n n.onerror = function (error) {\n console.error('Failed to load style link', (n as HTMLLinkElement).href)\n resolve(false)\n }\n n.onload = function () {\n resolve(true)\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 setTimeout(() => {\n childWindow.document.head.appendChild(n)\n }, 50)\n })\n}\n\nfunction 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\nasync function syncParentHeadToChild(childWindow: WindowProxy) {\n const styleLoadedPromises = []\n\n for (let i = 0; i < document.head.children.length; i++) {\n let n = document.head.children[i].cloneNode(true)\n if (\n n.nodeName == 'LINK' &&\n (n as HTMLLinkElement).rel == 'stylesheet' &&\n (n as HTMLLinkElement).href\n ) {\n const promise = asyncLoadStyleToChildWindow(\n childWindow,\n n as HTMLLinkElement,\n )\n styleLoadedPromises.push(promise)\n } else {\n childWindow.document.head.appendChild(n)\n }\n }\n\n // sync className\n childWindow.document.documentElement.className =\n document.documentElement.className\n\n return Promise.all(styleLoadedPromises)\n}\n\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 useSyncHeaderStyle(windowProxy: WindowProxy) {\n useEffect(() => {\n // sync parent head to child when document header style changed\n const headObserver = new MutationObserver(_ => {\n syncParentHeadToChild(windowProxy)\n })\n\n headObserver.observe(document.head, { childList: true, subtree: true })\n return () => {\n headObserver.disconnect()\n }\n }, [])\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.windowProxy\n\n useSyncHeaderStyle(windowProxy)\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.windowProxy\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","import {\n ForwardedRef,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\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 if (url.startsWith('http') || url.startsWith('//')) {\n return url\n }\n return window.location.origin + url\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\nasync function createSpatializedElement() {\n return getSession()!.createSpatializedStatic3DElement()\n}\n\nfunction SpatializedStatic3DElementContainerBase(\n props: SpatializedStatic3DContainerProps,\n ref: ForwardedRef<SpatializedStatic3DElementRef>,\n) {\n const extraRefProps = useCallback(\n (domProxy: SpatializedStatic3DElementRef) => {\n const modelTransform = new DOMMatrix()\n let needupdate = false\n const triggerUpdate = () => {\n const spatializedElement = (domProxy as any)\n .__spatializedElement as SpatializedStatic3DElement\n spatializedElement.updateModelTransform(modelTransform)\n needupdate = false\n }\n const domMatrixProxy = new Proxy(modelTransform, {\n get(target, prop, receiver) {\n const value = Reflect.get(target, prop, receiver)\n if (typeof value === 'function') {\n return function (...args: any[]) {\n requestAnimationFrame(triggerUpdate)\n return value.apply(target, args)\n }\n } else {\n return value\n }\n },\n set(target, prop, value) {\n const success = Reflect.set(target, prop, value)\n if (!needupdate) {\n needupdate = true\n requestAnimationFrame(triggerUpdate)\n }\n return success\n },\n })\n\n return {\n currentSrc: () => getAbsoluteURL(props.src),\n ready: () => {\n const spatializedElement = (domProxy as any)\n .__spatializedElement as SpatializedStatic3DElement\n\n const promise = spatializedElement.ready.then((success: boolean) => {\n if (success) {\n return createLoadSuccessEvent(() => domProxy)\n }\n throw createLoadFailureEvent(() => domProxy)\n })\n return promise\n },\n entityTransform: () => domMatrixProxy,\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 SpatialRotateStartEvent,\n type SpatialRotateEvent,\n type SpatialRotateEndEvent,\n type SpatialMagnifyStartEvent,\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 ModelSpatialRotateStartEvent,\n type ModelSpatialRotateEvent,\n type ModelSpatialRotateEndEvent,\n type ModelSpatialMagnifyEvent,\n type ModelSpatialMagnifyEndEvent,\n type ModelLoadEvent,\n} from './types'\n\nexport { toSceneSpatial, toLocalSpace } from './transform-utils'\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 { ParentContext, useRealityContext } from '../context'\nimport { EntityProps, EntityEventHandler } from '../type'\nimport { EntityRefShape, useEntity, useEntityRef } from '../hooks'\n\ntype Props = EntityProps & EntityEventHandler & { children?: React.ReactNode }\n\nexport const Entity = forwardRef<EntityRefShape, Props>(\n ({ id, children, position, rotation, scale, onSpatialTap, name }, ref) => {\n const ctx = useRealityContext()\n const entity = useEntity({\n ref,\n id,\n position,\n rotation,\n scale,\n onSpatialTap,\n createEntity: async () => ctx!.session.createEntity({ id, name }),\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'\n\nexport type RealityContextValue = {\n session: SpatialSession\n reality: SpatializedDynamic3DElement\n resourceRegistry: ResourceRegistry\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 { 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())\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 => promise.then(spatialObj => spatialObj.destroy()))\n }\n}\n","export function shallowEqualVec3(\n a?: { x: number; y: number; z: number },\n b?: { x: number; y: number; z: number },\n) {\n if (a === b) return true\n if (!a || !b) return false\n return a.x === b.x && a.y === b.y && a.z === b.z\n}\n\nexport function shallowEqualRotation(a?: any, b?: any) {\n if (a === b) return true\n if (!a || !b) return false\n // support Vec3 / Vec4\n return (\n a.x === b.x && a.y === b.y && a.z === b.z && ('w' in a ? a.w === b.w : true)\n )\n}\n","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 } from 'react'\nimport { EntityEventHandler, eventMap } 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 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 useEffect(() => {\n const entity = instance.entity\n if (!entity) return\n\n const boundHandlers: (() => void)[] = []\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 entity.addEvent(spatialEvent as any, wrapped)\n boundHandlers.push(() => entity.removeEvent(spatialEvent as any))\n })\n return () => {\n boundHandlers.forEach(unbind => unbind())\n }\n }, [instance.entity, ...Object.values(handlers)])\n\n return null\n}\n","import { Vec3 } from '@webspatial/core-sdk'\nimport { EntityRefShape } from './hooks'\nimport { SpatialTapEvent as CoreSpatialTapEvent } from '@webspatial/core-sdk'\nimport { SpatialDragEvent as CoreSpatialDragEvent } 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'\n\nexport type EntityProps = {\n id?: string\n name?: string\n position?: Vec3\n rotation?: Vec3\n scale?: Vec3\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 & allTarget<T>\n// drag\nexport type SpatialDragEntityEvent<T extends EntityRefShape = EntityRefShape> =\n CoreSpatialDragEvent & allTarget<T>\n// rotate\nexport type SpatialRotateEntityEvent<\n T extends EntityRefShape = EntityRefShape,\n> = CoreSpatialRotateEvent & allTarget<T>\nexport type SpatialRotateEndEntityEvent<\n T extends EntityRefShape = EntityRefShape,\n> = CoreSpatialRotateEndEvent & allTarget<T>\n// magnify\nexport type SpatialMagnifyEntityEvent<\n T extends EntityRefShape = EntityRefShape,\n> = CoreSpatialMagnifyEvent & allTarget<T>\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: SpatialDragEntityEvent) => void\n onSpatialDrag?: (event: SpatialDragEntityEvent) => void\n onSpatialDragEnd?: (event: SpatialDragEntityEvent) => void\n // rotate\n onSpatialRotateStart?: (event: SpatialRotateEntityEvent) => void\n onSpatialRotate?: (event: SpatialRotateEntityEvent) => void\n onSpatialRotateEnd?: (event: SpatialRotateEndEntityEvent) => void\n // magnify\n onSpatialMagnifyStart?: (event: SpatialMagnifyEntityEvent) => void\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 onSpatialRotateStart: 'spatialrotatestart',\n onSpatialRotate: 'spatialrotate',\n onSpatialRotateEnd: 'spatialrotateend',\n // magnify\n onSpatialMagnifyStart: 'spatialmagnifystart',\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 { 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 { 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} & EntityProps &\n EntityEventHandler & { ref: ForwardedRef<EntityRefShape> }\n\nexport const useEntity = ({\n ref,\n id,\n position,\n rotation,\n scale,\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n // TODO: add other event handlers\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 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 useEntityEvent({\n instance: instanceRef.current,\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n })\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, EntityEventHandler } 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 EntityEventHandler & {\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 { ParentContext, useRealityContext } from '../context'\nimport { EntityProps, EntityEventHandler } from '../type'\nimport { useEntityRef, EntityRefShape, useEntity } from '../hooks'\nimport { SpatialMaterial, SpatialGeometry } from '@webspatial/core-sdk'\nimport { AbortResourceManager } from '../utils'\n\ntype GeometryEntityProps = EntityProps &\n EntityEventHandler & {\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 {\n id,\n position,\n rotation,\n scale,\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n // TODO: add other event handlers\n children,\n name,\n materials,\n geometryOptions,\n createGeometry,\n },\n ref,\n ) => {\n const ctx = useRealityContext()\n const entity = useEntity({\n ref,\n id,\n position,\n rotation,\n scale,\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n\n createEntity: async (signal: AbortSignal) => {\n const manager = new AbortResourceManager(signal)\n\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 console.error(error)\n await manager.dispose()\n return null as any\n }\n },\n })\n\n if (!entity) return null\n return (\n <ParentContext.Provider value={entity}>{children}</ParentContext.Provider>\n )\n },\n)\n","import React, { useEffect, useRef } from 'react'\nimport {\n SpatialUnlitMaterial,\n SpatialUnlitMaterialOptions,\n} from '@webspatial/core-sdk'\nimport { useRealityContext } from '../context'\ntype Props = {\n children?: React.ReactNode\n id: string // user id\n} & SpatialUnlitMaterialOptions\nexport const UnlitMaterial: React.FC<Props> = ({ children, ...options }) => {\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, EntityEventHandler } 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 EntityEventHandler & {\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, EntityEventHandler } 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 EntityEventHandler & {\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, EntityEventHandler } 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 EntityEventHandler & {\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, EntityEventHandler } 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 EntityEventHandler & {\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 const resolvedUrl = resolveAssetUrl(options.src)\n const modelAssetPromise = session.createModelAsset({ url: resolvedUrl })\n resourceRegistry.add(options.id, modelAssetPromise)\n\n try {\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 { ParentContext, useRealityContext } from '../context'\nimport { EntityProps, EntityEventHandler } from '../type'\nimport { EntityRefShape, useEntity, useEntityRef } from '../hooks'\n\ntype Props = EntityProps & { model: string } & EntityEventHandler & {\n children?: React.ReactNode\n }\n\nexport const ModelEntity = forwardRef<EntityRefShape, Props>(\n (\n { id, model, position, rotation, scale, onSpatialTap, children, name },\n ref,\n ) => {\n const ctx = useRealityContext()\n const entity = useEntity({\n ref,\n id,\n position,\n rotation,\n scale,\n onSpatialTap,\n createEntity: async (signal: AbortSignal) => {\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) {\n return null\n }\n\n return ctx!.session.createSpatialModelEntity(\n {\n modelAssetId: modelAsset.id,\n name,\n },\n { id, name },\n )\n } catch (error) {\n console.error('ModelEntity error:', error)\n return null as any\n }\n },\n })\n\n if (!entity) return null\n return (\n <ParentContext.Provider value={entity}>{children}</ParentContext.Provider>\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 { getSession } from '../../utils/getSession'\nimport { ResourceRegistry } from '../utils'\nimport {\n RealityProps,\n SpatializedElementRef,\n} from '../../spatialized-container/types'\nimport { SpatializedElement } from '@webspatial/core-sdk'\n\nexport const Reality = forwardRef<SpatializedElementRef, RealityProps>(\n function RealityBase({ children, ...props }, ref) {\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?.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 session = await getSession()\n if (!session) {\n resourceRegistry.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 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 reality.destroy()\n return null\n }\n\n cleanupReality()\n\n ctxRef.current = { session, reality, resourceRegistry }\n setIsReady(true)\n return reality as SpatializedElement\n } catch (err) {\n console.error('[createReality] failed', err)\n resourceRegistry.destroy()\n reality.destroy()\n return null\n }\n }, [cleanupReality])\n\n const content = useCallback(() => <></>, [])\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 { ForwardedRef, forwardRef } from 'react'\nimport {\n SpatializedStatic3DContainerProps,\n SpatializedStatic3DElementContainer,\n SpatializedStatic3DElementRef,\n} from './spatialized-container'\nimport { withSSRSupported } from './ssr'\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 { 'enable-xr': enableXR, ...restProps } = props\n if (!enableXR || !spatial.runInSpatialWeb()) {\n const {\n onSpatialTap,\n onSpatialDragStart,\n onSpatialDrag,\n onSpatialDragEnd,\n onSpatialRotateStart,\n onSpatialRotate,\n onSpatialRotateEnd,\n onSpatialMagnifyStart,\n onSpatialMagnify,\n onSpatialMagnifyEnd,\n ...modelProps\n } = restProps\n // map to VisionOS26 model tag\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 { 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'\n\nexport const version = __WEBSPATIAL_REACT_SDK_VERSION__\n\nif (typeof window !== 'undefined') {\n initPolyfill()\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAuB,aAAa,WAAW,cAAc;;;ACqFtD,IAAM,yBAAyB;AAAA,EACpC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,oBAAoB;AAAA,EACpB,UAAU;AACZ;;;ACxFO,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,IACA;AAAA,IAEA;AAAA;AAAA,IAGA;AAAA,EACF;AACA,MA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AQ;AACzB,gBAAQ,QAAQ;AAChB,eAAO;AAAA,MACT;AAAA,IACF,GAAG,CAAC,cAAc,CAAC;AAEnB,UAAM,UAAUA,aAAY,MAAM,gBAAAL,MAAAD,WAAA,EAAE,GAAK,CAAC,CAAC;AAE3C,WACE,gBAAAE,MAAC,eAAe,UAAf,EAAwB,OAAO,OAAO,SACrC;AAAA,sBAAAD;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV;AAAA,UAEA,0BAA0B;AAAA,UAC1B,oBAAoB;AAAA,UACnB,GAAG;AAAA;AAAA,MACN;AAAA,MACC,WAAW;AAAA,OACd;AAAA,EAEJ;AACF;;;AClGA,SAAuB,cAAAO,oBAAkB;AAoC9B,gBAAAC,aAAA;AApBX,IAAMC,WAAU,IAAI,QAAQ;AAE5B,SAAS,UAAU,OAAmB,KAA6B;AACjE,QAAM,EAAE,aAAa,UAAU,GAAG,UAAU,IAAI;AAChD,MAAI,CAAC,YAAY,CAACA,SAAQ,gBAAgB,GAAG;AAC3C,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AAGJ,WAAO,gBAAAD,MAAC,WAAM,KAAW,GAAG,YAAY;AAAA,EAC1C;AAEA,SAAO,gBAAAA,MAAC,uCAAoC,KAAW,GAAG,WAAW;AACvE;AAEO,IAAM,QAAQ,iBAAiBE,aAAW,SAAS,CAAC;AAC3D,MAAM,cAAc;;;ACjCb,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","useState","createSpatializedElement","spatializedElement","jsx","createSpatializedElement","getExtraSpatializedElementProperties","useContext","useEffect","createContext","useState","useEffect","jsx","forwardRef","useContext","useState","useEffect","useContext","useState","useEffect","jsx","forwardRef","jsx","jsxs","createSpatializedElement","getExtraSpatializedElementProperties","onSpatialTap","onSpatialDragStart","onSpatialDrag","onSpatialDragEnd","onSpatialRotateStart","onSpatialRotate","onSpatialRotateEnd","onSpatialMagnifyStart","onSpatialMagnify","onSpatialMagnifyEnd","extraRefProps","useContext","useMemo","useEffect","forwardRef","forwardRef","useContext","useEffect","createPortal","jsx","useEffect","useContext","createPortal","forwardRef","forwardRef","useCallback","useContext","useEffect","useMemo","Fragment","jsx","SpatializedContent","useContext","useMemo","useEffect","createSpatializedElement","useCallback","forwardRef","forwardRef","jsx","forwardRef","forwardRef","useRef","useEffect","useMemo","useRef","useEffect","useMemo","useEffect","useEffect","forwardRef","jsx","jsx","forwardRef","forwardRef","createContext","useContext","createContext","useContext","useEffect","useRef","useRef","useEffect","useEffect","createEventProxy","useEffect","useEffect","useEffect","useEffect","useRef","useRef","useForceUpdate","useEffect","useCallback","useState","useForceUpdate","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","forwardRef","jsx","spatial","forwardRef"]}
|