oomi-ai 0.2.38 → 0.2.40
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/README.md +24 -14
- package/agent_instructions.md +9 -0
- package/bin/oomi-ai.js +1 -1
- package/lib/openclawPaths.js +27 -18
- package/lib/personaRuntimeManager.js +181 -61
- package/lib/personaRuntimeProcess.js +392 -49
- package/lib/personaRuntimeSupervisor.js +20 -7
- package/lib/scaffold.js +14 -14
- package/openclaw.plugin.json +1 -1
- package/package.json +10 -8
- package/templates/persona-app/package.json +6 -4
- package/templates/persona-app/src/App.css +564 -79
- package/templates/persona-app/src/App.tsx +2 -2
- package/templates/persona-app/src/main.tsx +13 -0
- package/templates/persona-app/src/pages/HomePage.tsx +120 -39
- package/templates/persona-app/src/pages/ScenePage.tsx +2 -15
- package/templates/persona-app/src/persona/notes.ts +3 -1
- package/templates/persona-app/src/spatial.ts +82 -0
- package/templates/persona-app/template.json +1 -1
- package/templates/persona-app/vendor/webspatial/FORK.md +6 -0
- package/templates/persona-app/vendor/webspatial/core-sdk/LICENSE +21 -0
- package/templates/persona-app/vendor/webspatial/core-sdk/dist/iife/index.d.ts +906 -0
- package/templates/persona-app/vendor/webspatial/core-sdk/dist/iife/index.global.js +75 -0
- package/templates/persona-app/vendor/webspatial/core-sdk/dist/iife/index.global.js.map +1 -0
- package/templates/persona-app/vendor/webspatial/core-sdk/dist/index.d.ts +906 -0
- package/templates/persona-app/vendor/webspatial/core-sdk/dist/index.js +3131 -0
- package/templates/persona-app/vendor/webspatial/core-sdk/dist/index.js.map +1 -0
- package/templates/persona-app/vendor/webspatial/core-sdk/package.json +45 -0
- package/templates/persona-app/vendor/webspatial/react-sdk/LICENSE +21 -0
- package/templates/persona-app/vendor/webspatial/react-sdk/dist/default/index.d.ts +365 -0
- package/templates/persona-app/vendor/webspatial/react-sdk/dist/default/index.js +4296 -0
- package/templates/persona-app/vendor/webspatial/react-sdk/dist/default/index.js.map +1 -0
- package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-dev-runtime.d.ts +82 -0
- package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-dev-runtime.js +66 -0
- package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-dev-runtime.js.map +1 -0
- package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-dev-runtime.web.d.ts +2 -0
- package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-dev-runtime.web.js +18 -0
- package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-dev-runtime.web.js.map +1 -0
- package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-runtime.d.ts +5 -0
- package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-runtime.js +66 -0
- package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-runtime.js.map +1 -0
- package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-runtime.web.d.ts +1 -0
- package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-runtime.web.js +18 -0
- package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-runtime.web.js.map +1 -0
- package/templates/persona-app/vendor/webspatial/react-sdk/dist/web/index.d.ts +365 -0
- package/templates/persona-app/vendor/webspatial/react-sdk/dist/web/index.js +4336 -0
- package/templates/persona-app/vendor/webspatial/react-sdk/dist/web/index.js.map +1 -0
- package/templates/persona-app/vendor/webspatial/react-sdk/package.json +94 -0
- package/templates/persona-app/vite.config.ts +13 -0
|
@@ -0,0 +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/utils/androidBitmapCapture.ts","../../src/utils/BitmapCaptureCoordinator.ts","../../src/spatialized-container/transform-utils.ts","../../src/spatialized-container/hooks/useSync2DFrame.ts","../../src/spatialized-container/hooks/useSpatializedElement.ts","../../src/reality/context/InsideAttachmentContext.tsx","../../src/spatialized-container/hooks/useSpatialEvents.ts","../../src/ssr/SSRContext.tsx","../../src/ssr/withSSRSupported.tsx","../../src/ssr/useSSRPhase.tsx","../../src/spatialized-container/Spatialized2DElementContainer.tsx","../../src/utils/windowStyleSync.ts","../../src/utils/useSyncHeadStyles.ts","../../src/spatialized-container/SpatializedStatic3DElementContainer.tsx","../../src/spatialized-container/Spatialized2DElementContainerFactory.tsx","../../src/spatialized-container/index.ts","../../src/initScene.web.ts","../../src/spatialized-container-monitor/withSpatialMonitor.tsx","../../src/spatialized-container-monitor/useMonitorDomChange.tsx","../../src/spatialized-container-monitor/useMonitorDocumentHeaderChange.tsx","../../src/spatialized-container-monitor/SpatialMonitor.tsx","../../src/reality/components/Entity.tsx","../../src/reality/components/BaseEntity.tsx","../../src/reality/context/RealityContext.tsx","../../src/reality/context/ParentContext.tsx","../../src/reality/context/AttachmentContext.tsx","../../src/reality/hooks/useEntityTransform.tsx","../../src/reality/utils/ResourceRegistry.ts","../../src/reality/utils/equal.ts","../../src/reality/utils/AbortResourceManager.ts","../../src/reality/hooks/useEntityEvent.tsx","../../src/reality/type.ts","../../src/reality/hooks/useEntityRef.tsx","../../src/reality/hooks/useEntityId.tsx","../../src/reality/hooks/useEntity.tsx","../../src/reality/hooks/useForceUpdate.tsx","../../src/reality/components/BoxEntity.tsx","../../src/reality/components/GeometryEntity.tsx","../../src/reality/components/UnlitMaterial.tsx","../../src/reality/components/SphereEntity.tsx","../../src/reality/components/ConeEntity.tsx","../../src/reality/components/CylinderEntity.tsx","../../src/reality/components/PlaneEntity.tsx","../../src/reality/components/SceneGraph.tsx","../../src/reality/components/ModelAsset.tsx","../../src/reality/components/ModelEntity.tsx","../../src/reality/components/Reality.tsx","../../src/reality/components/AttachmentAsset.tsx","../../src/reality/components/AttachmentEntity.tsx","../../src/Model.tsx","../../src/index.ts"],"sourcesContent":["import { ForwardedRef, useCallback, useEffect, useRef } from 'react'\r\nimport { SpatialCustomStyleVars, SpatializedElementRef } from '../types'\r\nimport { BackgroundMaterialType } from '@webspatial/core-sdk'\r\nimport { extractAndRemoveCustomProperties, joinToCSSText } from '../utils'\r\n\r\nfunction makeOriginalKey(key: string) {\r\n return `__original_${key}`\r\n}\r\n\r\nexport class SpatialContainerRefProxy<T extends SpatializedElementRef> {\r\n private transformVisibilityTaskContainerDom: HTMLElement | null = null\r\n private ref: ForwardedRef<SpatializedElementRef<T>>\r\n public domProxy?: T | null\r\n private styleProxy?: CSSStyleDeclaration\r\n\r\n // extre ref props, used to add extra props to ref\r\n private extraRefProps?: ((domProxy: T) => Record<string, unknown>) | undefined\r\n\r\n constructor(\r\n ref: ForwardedRef<SpatializedElementRef<T>>,\r\n extraRefProps?: (domProxy: T) => Record<string, unknown>,\r\n ) {\r\n this.ref = ref\r\n this.extraRefProps = extraRefProps\r\n }\r\n\r\n updateStandardSpatializedContainerDom(dom: HTMLElement | null) {\r\n const self = this\r\n\r\n if (dom) {\r\n let cacheExtraRefProps: Record<string, unknown> | undefined\r\n const domProxy = new Proxy<SpatializedElementRef<T>>(\r\n dom as SpatializedElementRef<T>,\r\n {\r\n get(target, prop) {\r\n if (prop === '__raw') {\r\n return target\r\n }\r\n if (prop === 'clientDepth') {\r\n return target.style.getPropertyValue(SpatialCustomStyleVars.depth)\r\n }\r\n if (prop === 'offsetBack') {\r\n return target.style.getPropertyValue(SpatialCustomStyleVars.back)\r\n }\r\n if (prop === 'getBoundingClientRect') {\r\n return (dom as any).__getBoundingClientRect\r\n }\r\n if (prop === 'getBoundingClientCube') {\r\n return (dom as any).__getBoundingClientCube\r\n }\r\n if (prop === 'style') {\r\n if (!self.styleProxy) {\r\n self.styleProxy = new Proxy<CSSStyleDeclaration>(target.style, {\r\n get(target, prop) {\r\n if (prop === 'visibility' || prop === 'transform') {\r\n return self.transformVisibilityTaskContainerDom?.style.getPropertyValue(\r\n prop as string,\r\n )\r\n }\r\n const value = Reflect.get(target, prop)\r\n if (typeof value === 'function') {\r\n if (\r\n prop === 'setProperty' ||\r\n prop === 'removeProperty' ||\r\n prop === 'getPropertyValue'\r\n ) {\r\n return function (this: any, ...args: any[]) {\r\n const validProperties = ['visibility', 'transform']\r\n const [property] = args\r\n\r\n if (validProperties.includes(property)) {\r\n if (prop === 'setProperty') {\r\n const [, kValue] = args\r\n self.transformVisibilityTaskContainerDom?.style.setProperty(\r\n property,\r\n kValue as string,\r\n )\r\n } else if (prop === 'removeProperty') {\r\n self.transformVisibilityTaskContainerDom?.style.removeProperty(\r\n property,\r\n )\r\n } else if (prop === 'getPropertyValue') {\r\n return self.transformVisibilityTaskContainerDom?.style.getPropertyValue(\r\n property,\r\n )\r\n }\r\n } else {\r\n return value.apply(this, args)\r\n }\r\n }.bind(target)\r\n } else {\r\n return value.bind(target)\r\n }\r\n } else {\r\n return value\r\n }\r\n },\r\n set(target, prop, value) {\r\n if (prop === 'visibility') {\r\n self.transformVisibilityTaskContainerDom?.style.setProperty(\r\n 'visibility',\r\n value,\r\n )\r\n return true\r\n }\r\n if (prop === 'transform') {\r\n self.transformVisibilityTaskContainerDom?.style.setProperty(\r\n 'transform',\r\n value,\r\n )\r\n return true\r\n }\r\n\r\n if (prop === SpatialCustomStyleVars.backgroundMaterial) {\r\n target.setProperty(\r\n SpatialCustomStyleVars.backgroundMaterial,\r\n value as BackgroundMaterialType,\r\n )\r\n } else if (prop === SpatialCustomStyleVars.back) {\r\n target.setProperty(\r\n SpatialCustomStyleVars.back,\r\n value as string,\r\n )\r\n } else if (prop === SpatialCustomStyleVars.xrZIndex) {\r\n target.setProperty(\r\n SpatialCustomStyleVars.xrZIndex,\r\n value as string,\r\n )\r\n } else if (prop === SpatialCustomStyleVars.depth) {\r\n target.setProperty(\r\n SpatialCustomStyleVars.depth,\r\n value as string,\r\n )\r\n } else if (prop === 'cssText') {\r\n // parse cssText, filter out spatialStyle like back/transform/visibility/xrZIndex/backgroundMaterial\r\n const toFilteredCSSProperties = [\r\n 'transform',\r\n 'visibility',\r\n ]\r\n const { extractedValues, filteredCssText } =\r\n extractAndRemoveCustomProperties(\r\n value as string,\r\n toFilteredCSSProperties,\r\n )\r\n\r\n // update cssText for transformVisibilityTaskContainerDom\r\n toFilteredCSSProperties.forEach(key => {\r\n // update cssText for transformVisibilityTaskContainerDom according to extractedValues\r\n if (extractedValues[key]) {\r\n self.transformVisibilityTaskContainerDom?.style.setProperty(\r\n key,\r\n extractedValues[key],\r\n )\r\n } else {\r\n target.removeProperty(key)\r\n }\r\n })\r\n\r\n const appendedCSSText = joinToCSSText({\r\n transform: 'none',\r\n visibility: 'hidden',\r\n })\r\n\r\n // set cssText for spatialDiv\r\n return Reflect.set(\r\n target,\r\n prop,\r\n [appendedCSSText, filteredCssText].join(';'),\r\n )\r\n }\r\n return Reflect.set(target, prop, value)\r\n },\r\n })\r\n }\r\n\r\n return self.styleProxy\r\n }\r\n\r\n if (typeof prop === 'string' && self.extraRefProps) {\r\n if (!cacheExtraRefProps) {\r\n cacheExtraRefProps = self.extraRefProps(domProxy)\r\n }\r\n const extraProps = cacheExtraRefProps\r\n if (extraProps.hasOwnProperty(prop)) {\r\n return extraProps[prop]\r\n }\r\n }\r\n const value = Reflect.get(target, prop)\r\n if (typeof value === 'function') {\r\n if ('removeAttribute' === prop) {\r\n return function (this: any, ...args: any[]) {\r\n const [property] = args\r\n if (property === 'style') {\r\n dom.style.cssText =\r\n 'visibility: hidden; transition: none; transform: none;'\r\n if (self.transformVisibilityTaskContainerDom) {\r\n self.transformVisibilityTaskContainerDom.style.visibility =\r\n ''\r\n self.transformVisibilityTaskContainerDom.style.transform =\r\n ''\r\n }\r\n return true\r\n }\r\n if (property === 'class') {\r\n domProxy.className = 'xr-spatial-default'\r\n return true\r\n }\r\n }\r\n }\r\n\r\n return value.bind(target)\r\n }\r\n return value\r\n },\r\n set(target, prop, value) {\r\n if (prop === 'className') {\r\n if (value && value.indexOf('xr-spatial-default') === -1) {\r\n value = value + ' xr-spatial-default'\r\n }\r\n\r\n if (self.transformVisibilityTaskContainerDom) {\r\n self.transformVisibilityTaskContainerDom.className = value\r\n }\r\n }\r\n\r\n // check extraRefProps setter\r\n if (typeof prop === 'string' && self.extraRefProps) {\r\n if (!cacheExtraRefProps) {\r\n cacheExtraRefProps = self.extraRefProps(domProxy)\r\n }\r\n cacheExtraRefProps[prop] = value\r\n }\r\n\r\n return Reflect.set(target, prop, value)\r\n },\r\n },\r\n )\r\n this.domProxy = domProxy\r\n\r\n // hijack classList\r\n const domClassList = dom.classList\r\n const domClassMethodKeys: Array<'add' | 'remove' | 'toggle' | 'replace'> =\r\n ['add', 'remove', 'toggle', 'replace']\r\n domClassMethodKeys.forEach(key => {\r\n const hiddenKey = makeOriginalKey(key)\r\n const hiddenKeyExist = (domClassList as any)[hiddenKey] !== undefined\r\n const originalMethod = hiddenKeyExist\r\n ? (domClassList as any)[hiddenKey]\r\n : domClassList[key].bind(domClassList)\r\n\r\n ;(domClassList as any)[hiddenKey] = originalMethod\r\n\r\n domClassList[key] = function (this: any, ...args: any[]) {\r\n const result = (originalMethod as Function)(...args)\r\n // update transformVisibilityTaskContainerDom className\r\n if (self.transformVisibilityTaskContainerDom) {\r\n self.transformVisibilityTaskContainerDom.className = dom.className\r\n }\r\n\r\n return result\r\n }\r\n })\r\n\r\n // clear styleProxy\r\n this.styleProxy = undefined\r\n this.updateDomProxyToRef()\r\n\r\n // assign domProxy to dom\r\n Object.assign(dom, {\r\n __targetProxy: domProxy,\r\n })\r\n }\r\n }\r\n\r\n updateTransformVisibilityTaskContainerDom(dom: HTMLElement | null) {\r\n this.transformVisibilityTaskContainerDom = dom\r\n this.updateDomProxyToRef()\r\n }\r\n\r\n private updateDomProxyToRef() {\r\n const ref = this.ref\r\n if (!ref) {\r\n return\r\n }\r\n if (this.domProxy && this.transformVisibilityTaskContainerDom) {\r\n if (typeof ref === 'function') {\r\n ref(this.domProxy)\r\n } else {\r\n ref.current = this.domProxy\r\n }\r\n } else {\r\n if (typeof ref === 'function') {\r\n ref(null)\r\n } else {\r\n ref.current = null\r\n }\r\n }\r\n }\r\n\r\n updateRef(ref: ForwardedRef<SpatializedElementRef<T>>) {\r\n this.ref = ref\r\n }\r\n}\r\n\r\n// hijack getComputedStyle to get raw dom\r\nexport function hijackGetComputedStyle() {\r\n const rawFn = window.getComputedStyle.bind(window)\r\n window.getComputedStyle = (element, pseudoElt) => {\r\n const dom = (element as any).__raw\r\n\r\n if (dom) {\r\n return rawFn(dom, pseudoElt)\r\n }\r\n return rawFn(element, pseudoElt)\r\n }\r\n}\r\n\r\nexport function useDomProxy<T extends SpatializedElementRef>(\r\n ref: ForwardedRef<T>,\r\n extraRefProps?: (domProxy: T) => Record<string, unknown>,\r\n) {\r\n const spatialContainerRefProxy = useRef<SpatialContainerRefProxy<T>>(\r\n new SpatialContainerRefProxy<T>(ref, extraRefProps),\r\n )\r\n\r\n useEffect(() => {\r\n spatialContainerRefProxy.current.updateRef(ref)\r\n }, [ref])\r\n\r\n const transformVisibilityTaskContainerCallback = useCallback(\r\n (el: HTMLElement | null) => {\r\n spatialContainerRefProxy.current.updateTransformVisibilityTaskContainerDom(\r\n el,\r\n )\r\n },\r\n [],\r\n )\r\n\r\n const standardSpatializedContainerCallback = useCallback(\r\n (el: HTMLElement | null) => {\r\n spatialContainerRefProxy.current.updateStandardSpatializedContainerDom(el)\r\n },\r\n [],\r\n )\r\n\r\n return {\r\n transformVisibilityTaskContainerCallback,\r\n standardSpatializedContainerCallback,\r\n spatialContainerRefProxy,\r\n }\r\n}\r\n","import React, { ElementType } from 'react'\r\nimport { SpatialID } from './SpatialID'\r\nimport {\r\n CubeInfo,\r\n SpatializedElement,\r\n SpatialTapEvent as CoreSpatialTapEvent,\r\n SpatialDragEvent as CoreSpatialDragEvent,\r\n SpatialDragStartEvent as CoreSpatialDragStartEvent,\r\n SpatialDragEndEvent as CoreSpatialDragEndEvent,\r\n SpatialRotateEvent as CoreSpatialRotateEvent,\r\n SpatialRotateEndEvent as CoreSpatialRotateEndEvent,\r\n SpatialMagnifyEvent as CoreSpatialMagnifyEvent,\r\n SpatialMagnifyEndEvent as CoreSpatialMagnifyEndEvent,\r\n SpatializedStatic3DElement,\r\n} from '@webspatial/core-sdk'\r\n\r\nexport type { Point3D, Vec3 } from '@webspatial/core-sdk'\r\nexport type { Quaternion } from '@webspatial/core-sdk'\r\n\r\n// SpatialEvents\r\ntype SpatialEventProps<T extends SpatializedElementRef> = {\r\n onSpatialTap?: (event: SpatialTapEvent<T>) => void\r\n onSpatialDragStart?: (event: SpatialDragStartEvent<T>) => void\r\n onSpatialDrag?: (event: SpatialDragEvent<T>) => void\r\n onSpatialDragEnd?: (event: SpatialDragEndEvent<T>) => void\r\n onSpatialRotate?: (event: SpatialRotateEvent<T>) => void\r\n onSpatialRotateEnd?: (event: SpatialRotateEndEvent<T>) => void\r\n onSpatialMagnify?: (event: SpatialMagnifyEvent<T>) => void\r\n onSpatialMagnifyEnd?: (event: SpatialMagnifyEndEvent<T>) => void\r\n}\r\n\r\nexport interface StandardSpatializedContainerProps\r\n extends React.ComponentPropsWithoutRef<'div'> {\r\n component: ElementType\r\n inStandardSpatializedContainer?: boolean\r\n [SpatialID]: string\r\n}\r\n\r\ntype RealityForbiddenSpatialEventProps = {\r\n onSpatialTap?: never\r\n onSpatialDragStart?: never\r\n onSpatialDrag?: never\r\n onSpatialDragEnd?: never\r\n onSpatialRotate?: never\r\n onSpatialRotateEnd?: never\r\n onSpatialMagnify?: never\r\n onSpatialMagnifyEnd?: never\r\n}\r\n\r\nexport type RealityProps = React.ComponentPropsWithRef<'div'> &\r\n RealityForbiddenSpatialEventProps\r\nexport type PortalSpatializedContainerProps<T extends SpatializedElementRef> =\r\n SpatialEventProps<T> &\r\n React.ComponentPropsWithoutRef<'div'> & {\r\n component: ElementType\r\n spatializedContent: ElementType\r\n createSpatializedElement: () => Promise<SpatializedElement>\r\n getExtraSpatializedElementProperties?: (\r\n computedStyle: CSSStyleDeclaration,\r\n ) => Record<string, any>\r\n\r\n [SpatialID]: string\r\n }\r\n\r\nexport type SpatializedContainerProps<T extends SpatializedElementRef> = Omit<\r\n StandardSpatializedContainerProps & PortalSpatializedContainerProps<T>,\r\n typeof SpatialID | 'onLoad' | 'onError'\r\n> & {\r\n extraRefProps?: (domProxy: T) => Record<string, unknown>\r\n}\r\n\r\nexport type SpatializedContentProps<\r\n T extends SpatializedElementRef,\r\n P extends ElementType,\r\n> = Omit<PortalSpatializedContainerProps<T>, 'spatializedContent'> & {\r\n spatializedElement: SpatializedElement\r\n}\r\n\r\nexport type Spatialized2DElementContainerProps<P extends ElementType> =\r\n SpatialEventProps<SpatializedElementRef> &\r\n React.ComponentPropsWithRef<'div'> & {\r\n component: P\r\n }\r\n\r\nexport type SpatializedStatic3DContainerProps =\r\n SpatialEventProps<SpatializedStatic3DElementRef> &\r\n Omit<React.ComponentPropsWithoutRef<'div'>, 'onLoad' | 'onError'> & {\r\n src?: string\r\n onLoad?: (event: ModelLoadEvent) => void\r\n onError?: (event: ModelLoadEvent) => void\r\n }\r\n\r\nexport type SpatializedStatic3DContentProps = {\r\n spatializedElement: SpatializedStatic3DElement\r\n src?: string\r\n onLoad?: (event: ModelLoadEvent) => void\r\n onError?: (event: ModelLoadEvent) => void\r\n}\r\n\r\nexport const SpatialCustomStyleVars = {\r\n back: '--xr-back',\r\n depth: '--xr-depth',\r\n backgroundMaterial: '--xr-background-material',\r\n xrZIndex: '--xr-z-index',\r\n}\r\n\r\nexport interface SpatialTransformVisibility {\r\n transform: string\r\n visibility: string\r\n}\r\n\r\nexport type SpatializedElementRef<T extends HTMLElement = HTMLElement> = T\r\n\r\nexport type SpatializedDivElementRef = SpatializedElementRef<HTMLDivElement>\r\n\r\nexport type SpatializedStatic3DElementRef = SpatializedDivElementRef & {\r\n currentSrc: string\r\n ready: Promise<ModelLoadEvent>\r\n entityTransform: DOMMatrixReadOnly\r\n}\r\n\r\ntype CurrentTarget<T extends SpatializedElementRef> = {\r\n currentTarget: T\r\n}\r\n\r\nexport type SpatialTapEvent<\r\n T extends SpatializedElementRef = SpatializedElementRef,\r\n> = CoreSpatialTapEvent &\r\n CurrentTarget<T> & {\r\n readonly offsetX: number\r\n readonly offsetY: number\r\n readonly offsetZ: number\r\n readonly clientX: number\r\n readonly clientY: number\r\n readonly clientZ: number\r\n }\r\n\r\nexport type SpatialDragStartEvent<\r\n T extends SpatializedElementRef = SpatializedElementRef,\r\n> = CoreSpatialDragStartEvent &\r\n CurrentTarget<T> & {\r\n readonly offsetX: number\r\n readonly offsetY: number\r\n readonly offsetZ: number\r\n readonly clientX: number\r\n readonly clientY: number\r\n readonly clientZ: number\r\n }\r\n\r\nexport type SpatialDragEvent<\r\n T extends SpatializedElementRef = SpatializedElementRef,\r\n> = CoreSpatialDragEvent &\r\n CurrentTarget<T> & {\r\n readonly translationX: number\r\n readonly translationY: number\r\n readonly translationZ: number\r\n }\r\n\r\nexport type SpatialDragEndEvent<\r\n T extends SpatializedElementRef = SpatializedElementRef,\r\n> = CoreSpatialDragEndEvent & CurrentTarget<T>\r\n\r\nexport type SpatialRotateEvent<\r\n T extends SpatializedElementRef = SpatializedElementRef,\r\n> = CoreSpatialRotateEvent &\r\n CurrentTarget<T> & {\r\n readonly quaternion: import('@webspatial/core-sdk').Quaternion\r\n }\r\n\r\nexport type SpatialRotateEndEvent<\r\n T extends SpatializedElementRef = SpatializedElementRef,\r\n> = CoreSpatialRotateEndEvent & CurrentTarget<T>\r\n\r\nexport type SpatialMagnifyEvent<\r\n T extends SpatializedElementRef = SpatializedElementRef,\r\n> = CoreSpatialMagnifyEvent &\r\n CurrentTarget<T> & {\r\n readonly magnification: number\r\n }\r\n\r\nexport type SpatialMagnifyEndEvent<\r\n T extends SpatializedElementRef = SpatializedElementRef,\r\n> = CoreSpatialMagnifyEndEvent & CurrentTarget<T>\r\n\r\n// Model Spatial Event\r\nexport type ModelSpatialTapEvent =\r\n SpatialTapEvent<SpatializedStatic3DElementRef>\r\nexport type ModelSpatialDragStartEvent =\r\n SpatialDragStartEvent<SpatializedStatic3DElementRef>\r\nexport type ModelSpatialDragEvent =\r\n SpatialDragEvent<SpatializedStatic3DElementRef>\r\nexport type ModelSpatialDragEndEvent =\r\n SpatialDragEndEvent<SpatializedStatic3DElementRef>\r\nexport type ModelSpatialRotateEvent =\r\n SpatialRotateEvent<SpatializedStatic3DElementRef>\r\nexport type ModelSpatialRotateEndEvent =\r\n SpatialRotateEndEvent<SpatializedStatic3DElementRef>\r\nexport type ModelSpatialMagnifyEvent =\r\n SpatialMagnifyEvent<SpatializedStatic3DElementRef>\r\nexport type ModelSpatialMagnifyEndEvent =\r\n SpatialMagnifyEndEvent<SpatializedStatic3DElementRef>\r\n\r\nexport type ModelLoadEvent = CustomEvent & {\r\n target: SpatializedStatic3DElementRef\r\n}\r\n","import { CSSProperties } from 'react'\r\n\r\nexport function getInheritedStyleProps(\r\n computedStyle: CSSStyleDeclaration,\r\n): CSSProperties {\r\n //https://stackoverflow.com/questions/5612302/which-css-properties-are-inherited\r\n var propNames: (keyof CSSProperties)[] = [\r\n 'azimuth',\r\n 'borderCollapse',\r\n 'borderSpacing',\r\n 'captionSide',\r\n 'color',\r\n 'cursor',\r\n 'direction',\r\n // 'elevation',\r\n 'emptyCells',\r\n 'fontFamily',\r\n 'fontSize',\r\n 'fontStyle',\r\n 'fontVariant',\r\n 'fontWeight',\r\n 'font',\r\n 'letterSpacing',\r\n 'lineHeight',\r\n 'listStyleImage',\r\n 'listStylePosition',\r\n 'listStyleType',\r\n 'listStyle',\r\n 'orphans',\r\n // 'pitchRange',\r\n // 'pitch',\r\n 'quotes',\r\n // 'richness',\r\n // 'speakHeader',\r\n // 'speakNumeral',\r\n // 'speakPunctuation',\r\n // 'speak',\r\n // 'speechRate',\r\n // 'stress',\r\n 'textAlign',\r\n 'textIndent',\r\n 'textTransform',\r\n 'visibility',\r\n // 'voiceFamily',\r\n // 'volume',\r\n 'whiteSpace',\r\n 'widows',\r\n 'wordSpacing',\r\n // background also need to be synced\r\n 'background',\r\n // position also need to be synced\r\n 'position',\r\n\r\n 'width',\r\n 'height',\r\n\r\n 'display',\r\n\r\n // content-visibility also need to be synced\r\n 'contentVisibility',\r\n ]\r\n var props: CSSProperties = {}\r\n for (var cssName of propNames) {\r\n if ((computedStyle as any)[cssName]) {\r\n props[cssName] = (computedStyle as any)[cssName]\r\n }\r\n }\r\n return props\r\n}\r\n\r\nexport function parseTransformOrigin(computedStyle: CSSStyleDeclaration) {\r\n const transformOriginProperty =\r\n computedStyle.getPropertyValue('transform-origin')\r\n const [x, y] = transformOriginProperty.split(' ').map(parseFloat)\r\n const width = parseFloat(computedStyle.getPropertyValue('width'))\r\n const height = parseFloat(computedStyle.getPropertyValue('height'))\r\n\r\n return {\r\n x: width > 0 ? x / width : 0.5,\r\n y: height > 0 ? y / height : 0.5,\r\n z: 0.5,\r\n }\r\n}\r\n\r\nfunction parseBorderRadius(borderProperty: string, width: number) {\r\n if (borderProperty === '') {\r\n return 0\r\n }\r\n if (borderProperty.endsWith('%')) {\r\n return (width * parseFloat(borderProperty)) / 100\r\n }\r\n return parseFloat(borderProperty)\r\n}\r\n\r\nexport function parseCornerRadius(computedStyle: CSSStyleDeclaration) {\r\n const width = parseFloat(computedStyle.getPropertyValue('width'))\r\n\r\n const topLeftPropertyValue = computedStyle.getPropertyValue(\r\n 'border-top-left-radius',\r\n )\r\n const topRightPropertyValue = computedStyle.getPropertyValue(\r\n 'border-top-right-radius',\r\n )\r\n const bottomLeftPropertyValue = computedStyle.getPropertyValue(\r\n 'border-bottom-left-radius',\r\n )\r\n const bottomRightPropertyValue = computedStyle.getPropertyValue(\r\n 'border-bottom-right-radius',\r\n )\r\n\r\n const cornerRadius = {\r\n topLeading: parseBorderRadius(topLeftPropertyValue, width),\r\n bottomLeading: parseBorderRadius(bottomLeftPropertyValue, width),\r\n topTrailing: parseBorderRadius(topRightPropertyValue, width),\r\n bottomTrailing: parseBorderRadius(bottomRightPropertyValue, width),\r\n }\r\n\r\n return cornerRadius\r\n}\r\n\r\nexport function extractAndRemoveCustomProperties(\r\n cssText: string,\r\n properties: string[],\r\n) {\r\n if (!cssText) {\r\n return { extractedValues: {}, filteredCssText: '' }\r\n }\r\n\r\n const extractedValues: Record<string, string> = {}\r\n const rules = cssText.split(';')\r\n\r\n const filteredRules = rules.filter(rule => {\r\n const [key, value] = rule.split(':').map(part => part.trim())\r\n if (properties.includes(key)) {\r\n extractedValues[key] = value\r\n return false\r\n }\r\n return true\r\n })\r\n\r\n const filteredCssText = filteredRules.join(';').trim()\r\n return { extractedValues, filteredCssText }\r\n}\r\n\r\nexport function splitCSSText(cssText: string) {\r\n const rules = cssText.split(';')\r\n const filteredRules = rules.filter(rule => rule.trim() !== '')\r\n return filteredRules\r\n}\r\n\r\nexport function joinToCSSText(cssKV: Record<string, string>) {\r\n const rules = Object.entries(cssKV).map(([key, value]) => `${key}: ${value}`)\r\n return rules.join(';')\r\n}\r\n","import {\r\n useContext,\r\n useLayoutEffect,\r\n useEffect,\r\n useCallback,\r\n MutableRefObject,\r\n} from 'react'\r\n\r\nimport {\r\n SpatializedContainerContext,\r\n SpatializedContainerObject,\r\n} from '../context/SpatializedContainerContext'\r\n\r\nexport function use2DFrameDetector(ref: MutableRefObject<HTMLElement | null>) {\r\n const spatializedContainerObject: SpatializedContainerObject = useContext(\r\n SpatializedContainerContext,\r\n )!\r\n\r\n const notify2DFrameChange = useCallback(() => {\r\n ref.current &&\r\n spatializedContainerObject.notify2DFramePlaceHolderChange(ref.current)\r\n }, [ref.current, spatializedContainerObject])\r\n\r\n useLayoutEffect(notify2DFrameChange, [notify2DFrameChange])\r\n\r\n // listen to webview container size change and notifyDomChange\r\n // document.body.clientWidth may change as page loads.\r\n // when creating a new scene, clientWidth changes from 0 to some positive value.\r\n // this cannot be detected by ResizeObserver which only observe the dom element itself\r\n useEffect(() => {\r\n if (!ref.current || !spatializedContainerObject) {\r\n console.warn(\r\n 'Ref is not attached to the DOM or spatializedContainerObject is not available',\r\n )\r\n return\r\n }\r\n\r\n window.addEventListener('resize', notify2DFrameChange)\r\n\r\n return () => {\r\n window.removeEventListener('resize', notify2DFrameChange)\r\n }\r\n }, [])\r\n\r\n // detect dom resize\r\n // Trigger native resize on web resize events\r\n useEffect(() => {\r\n if (!ref.current) {\r\n console.warn('Ref is not attached to the DOM')\r\n return\r\n }\r\n\r\n const ro = new ResizeObserver(notify2DFrameChange)\r\n ro.observe(ref.current!)\r\n return () => {\r\n ro.disconnect()\r\n }\r\n }, [])\r\n\r\n // detect dom style and class change\r\n useEffect(() => {\r\n if (!ref.current) {\r\n console.warn('Ref is not attached to the DOM')\r\n return\r\n }\r\n const ro = new MutationObserver(notify2DFrameChange)\r\n ro.observe(ref.current!, {\r\n attributeFilter: ['class', 'style'],\r\n subtree: true,\r\n })\r\n return () => {\r\n ro.disconnect()\r\n }\r\n }, [])\r\n}\r\n","import { createContext } from 'react'\r\nimport { SpatialID } from '../SpatialID'\r\nimport { SpatializedElementRef, SpatialTransformVisibility } from '../types'\r\nimport { SpatialContainerRefProxy } from '../hooks/useDomProxy'\r\n\r\nexport class SpatializedContainerObject<\r\n T extends SpatializedElementRef = SpatializedElementRef,\r\n> {\r\n dom: HTMLElement | null = null\r\n domSpatialId: string | null = null\r\n\r\n private fns: Record<string, () => void> = {}\r\n // cache dom for each spatialId\r\n private spatialId2dom: Record<string, HTMLElement> = {}\r\n private spatialId2parentSpatialDom: Record<string, HTMLElement> = {}\r\n\r\n // layer : [standardInstance sequence, portalInstance sequence]\r\n private layerSequences: Record<number, [number, number]> = {}\r\n\r\n public notify2DFramePlaceHolderChange(dom: HTMLElement) {\r\n this.dom = dom\r\n this.domSpatialId = dom.getAttribute(SpatialID)\r\n Object.values(this.fns).forEach(fn => fn())\r\n }\r\n\r\n private spatialId2transformVisibility: Record<\r\n string,\r\n SpatialTransformVisibility\r\n > = {}\r\n public updateSpatialTransformVisibility(\r\n spatialId: string,\r\n spatialTransformVisibility: SpatialTransformVisibility,\r\n ) {\r\n this.spatialId2transformVisibility[spatialId] = spatialTransformVisibility\r\n // notify\r\n this.fnsForSpatialTransformVisibility[spatialId]?.forEach(fn =>\r\n fn(spatialTransformVisibility),\r\n )\r\n }\r\n\r\n // this is used by onSpatialEvent.currentTarget property\r\n private spatialId2ContainerRefProxy: Record<\r\n string,\r\n SpatialContainerRefProxy<T>\r\n > = {}\r\n\r\n // this is called in sub standardInstance env\r\n public updateSpatialContainerRefProxyInfo(\r\n spatialId: string,\r\n spatialContainerRefProxy: SpatialContainerRefProxy<T>,\r\n ) {\r\n this.spatialId2ContainerRefProxy[spatialId] =\r\n spatialContainerRefProxy as unknown as SpatialContainerRefProxy<T>\r\n }\r\n\r\n public getSpatialContainerRefProxyBySpatialId<\r\n T extends SpatializedElementRef,\r\n >(spatialId: string) {\r\n return this.spatialId2ContainerRefProxy[\r\n spatialId\r\n ] as unknown as SpatialContainerRefProxy<T>\r\n }\r\n\r\n // notify when TransformVisibilityTaskContainer data change\r\n private fnsForSpatialTransformVisibility: Record<\r\n string,\r\n Array<(spatialTransformVisibility: SpatialTransformVisibility) => void>\r\n > = {}\r\n\r\n // used by StandardSpatializedContainer and PortalSpatializedContainer\r\n public onSpatialTransformVisibilityChange(\r\n spatialId: string,\r\n fn: (spatialTransformVisibility: SpatialTransformVisibility) => void,\r\n ) {\r\n if (!this.fnsForSpatialTransformVisibility[spatialId]) {\r\n this.fnsForSpatialTransformVisibility[spatialId] = []\r\n }\r\n this.fnsForSpatialTransformVisibility[spatialId].push(fn)\r\n if (this.spatialId2transformVisibility[spatialId]) {\r\n fn(this.spatialId2transformVisibility[spatialId])\r\n }\r\n }\r\n\r\n public offSpatialTransformVisibilityChange(\r\n spatialId: string,\r\n fn: (spatialTransformVisibility: SpatialTransformVisibility) => void,\r\n ) {\r\n const fns = this.fnsForSpatialTransformVisibility[spatialId]\r\n if (fns) {\r\n this.fnsForSpatialTransformVisibility[spatialId] = fns.filter(\r\n f => f !== fn,\r\n )\r\n }\r\n }\r\n\r\n public on2DFrameChange(spatialId: string, fn: () => void) {\r\n this.fns[spatialId] = fn\r\n if (this.dom) {\r\n fn()\r\n }\r\n }\r\n\r\n public off2DFrameChange(spatialId: string) {\r\n delete this.fns[spatialId]\r\n delete this.spatialId2dom[spatialId]\r\n delete this.spatialId2parentSpatialDom[spatialId]\r\n }\r\n\r\n public querySpatialDomBySpatialId(spatialId: string) {\r\n if (this.domSpatialId === spatialId) {\r\n return this.dom\r\n }\r\n if (!this.dom) {\r\n return null\r\n }\r\n if (!this.spatialId2dom[spatialId]) {\r\n const spatialDom = this.dom.querySelector(`[${SpatialID}=\"${spatialId}\"]`)\r\n\r\n if (spatialDom) {\r\n this.spatialId2dom[spatialId] = spatialDom as HTMLElement\r\n }\r\n }\r\n return this.spatialId2dom[spatialId]\r\n }\r\n\r\n public queryParentSpatialDomBySpatialId(spatialId: string) {\r\n if (this.domSpatialId === spatialId) {\r\n return null\r\n }\r\n\r\n if (this.spatialId2parentSpatialDom[spatialId]) {\r\n // early return if already found\r\n return this.spatialId2parentSpatialDom[spatialId]\r\n }\r\n\r\n let spatialDom = this.querySpatialDomBySpatialId(spatialId)\r\n if (spatialDom) {\r\n if (spatialDom === this.dom) return null\r\n let parentSpatialDom = spatialDom.parentElement as HTMLElement\r\n while (parentSpatialDom && spatialDom !== this.dom) {\r\n if (parentSpatialDom.hasAttribute(SpatialID)) {\r\n break\r\n } else {\r\n parentSpatialDom = parentSpatialDom.parentElement as HTMLElement\r\n }\r\n }\r\n\r\n this.spatialId2parentSpatialDom[spatialId] = parentSpatialDom\r\n return parentSpatialDom\r\n }\r\n return null\r\n }\r\n\r\n public getSpatialId(\r\n layer: number,\r\n isInStandardInstance: boolean,\r\n name: string = '',\r\n ): string {\r\n if (this.layerSequences[layer] === undefined) {\r\n this.layerSequences[layer] = [0, 0]\r\n }\r\n const idx = isInStandardInstance ? 0 : 1\r\n const sequenceId = this.layerSequences[layer][idx]\r\n this.layerSequences[layer][idx] = sequenceId + 1\r\n const spatialId = `${name}_${layer}_${sequenceId}`\r\n return spatialId\r\n }\r\n}\r\n\r\nexport const SpatializedContainerContext =\r\n createContext<SpatializedContainerObject | null>(null)\r\n","export const SpatialID = 'data-spatial-id'\r\n","import {\r\n SpatializedElementRef,\r\n SpatialTransformVisibility,\r\n StandardSpatializedContainerProps,\r\n} from './types'\r\nimport { use2DFrameDetector } from './hooks/use2DFrameDetector'\r\nimport {\r\n ForwardedRef,\r\n forwardRef,\r\n useCallback,\r\n useContext,\r\n useEffect,\r\n useRef,\r\n useState,\r\n} from 'react'\r\nimport { SpatializedContainerContext } from './context/SpatializedContainerContext'\r\nimport { SpatialID } from './SpatialID'\r\n\r\nfunction useSpatialTransformVisibilityWatcher(spatialId: string) {\r\n const [transformExist, setTransformExist] = useState(false)\r\n\r\n const spatializedContainerObject = useContext(SpatializedContainerContext)!\r\n useEffect(() => {\r\n const fn = (spatialTransform: SpatialTransformVisibility) => {\r\n setTransformExist(spatialTransform.transform !== 'none')\r\n }\r\n spatializedContainerObject.onSpatialTransformVisibilityChange(spatialId, fn)\r\n return () => {\r\n spatializedContainerObject.offSpatialTransformVisibilityChange(\r\n spatialId,\r\n fn,\r\n )\r\n }\r\n }, [spatialId, spatializedContainerObject])\r\n\r\n return transformExist\r\n}\r\n\r\nfunction useInternalRef(ref: ForwardedRef<HTMLElement | null>) {\r\n const refInternal = useRef<HTMLElement | null>(null)\r\n const refInternalCallback = useCallback(\r\n (node: HTMLElement | null) => {\r\n refInternal.current = node\r\n\r\n if (typeof ref === 'function') {\r\n ref(node)\r\n } else if (ref) {\r\n ref.current = node\r\n }\r\n },\r\n [ref],\r\n )\r\n\r\n return { refInternal, refInternalCallback }\r\n}\r\n\r\nexport function StandardSpatializedContainerBase(\r\n props: StandardSpatializedContainerProps,\r\n ref: ForwardedRef<HTMLElement | null>,\r\n) {\r\n const {\r\n component: Component,\r\n style: inStyle = {},\r\n className,\r\n inStandardSpatializedContainer = false,\r\n ...restProps\r\n } = props\r\n\r\n const { refInternal, refInternalCallback } = useInternalRef(ref)\r\n if (!inStandardSpatializedContainer) {\r\n use2DFrameDetector(refInternal)\r\n }\r\n const transformExist = useSpatialTransformVisibilityWatcher(props[SpatialID])\r\n\r\n const extraStyle = {\r\n visibility: 'hidden',\r\n transition: 'none',\r\n transform: transformExist ? 'translateZ(0)' : 'none',\r\n }\r\n const style = { ...inStyle, ...extraStyle }\r\n\r\n const classNames = className\r\n ? `${className} xr-spatial-default`\r\n : 'xr-spatial-default'\r\n\r\n return (\r\n <Component\r\n ref={refInternalCallback}\r\n style={style}\r\n className={classNames}\r\n {...restProps}\r\n />\r\n )\r\n}\r\n\r\nexport const StandardSpatializedContainer = forwardRef(\r\n StandardSpatializedContainerBase,\r\n) as <T extends SpatializedElementRef>(\r\n props: StandardSpatializedContainerProps & {\r\n ref?: ForwardedRef<SpatializedElementRef<T>>\r\n },\r\n) => React.ReactElement | null\r\n\r\nexport function injectSpatialDefaultStyle() {\r\n // inject xr-spatial-default style to head\r\n const styleElement = document.createElement('style')\r\n styleElement.type = 'text/css'\r\n styleElement.innerHTML =\r\n ' :where(.xr-spatial-default) { --xr-back: 0; --xr-depth: 0; --xr-z-index: 0; --xr-background-material: none; } '\r\n document.head.appendChild(styleElement)\r\n}\r\n","import React, {\r\n CSSProperties,\r\n ForwardedRef,\r\n forwardRef,\r\n useCallback,\r\n useRef,\r\n} from 'react'\r\nimport { SpatialID } from './SpatialID'\r\nimport { createPortal } from 'react-dom'\r\nimport { useSpatialTransformVisibility } from './hooks/useSpatialTransformVisibility'\r\n\r\n// used as root container for all TransformVisibilityTaskContainer\r\nlet cssParserDivContainer: HTMLDivElement | null = null\r\n\r\nexport function initCSSParserDivContainer() {\r\n cssParserDivContainer = document?.createElement('div')\r\n if (cssParserDivContainer) {\r\n cssParserDivContainer.style.position = 'absolute'\r\n cssParserDivContainer.setAttribute('data-id', 'css-parser-div-container')\r\n }\r\n}\r\n\r\nfunction createOrGetCSSParserDivContainer() {\r\n if (cssParserDivContainer && !cssParserDivContainer.parentElement) {\r\n document?.body.appendChild(cssParserDivContainer)\r\n }\r\n return cssParserDivContainer\r\n}\r\n\r\nfunction useInternalRef(ref: ForwardedRef<HTMLElement | null>) {\r\n const refInternal = useRef<HTMLElement | null>(null)\r\n const refInternalCallback = useCallback(\r\n (node: HTMLElement | null) => {\r\n refInternal.current = node\r\n\r\n if (typeof ref === 'function') {\r\n ref(node)\r\n } else if (ref) {\r\n ref.current = node\r\n }\r\n },\r\n [ref],\r\n )\r\n\r\n return { refInternal, refInternalCallback }\r\n}\r\n\r\ninterface TransformVisibilityTaskContainerProps {\r\n className?: string\r\n style?: CSSProperties\r\n [SpatialID]: string\r\n}\r\n\r\n// using css layout engine to calculate SpatializedContainer transform and visibility\r\nexport function TransformVisibilityTaskContainerBase(\r\n props: TransformVisibilityTaskContainerProps,\r\n ref: ForwardedRef<HTMLElement | null>,\r\n) {\r\n const { style: inStyle, ...restProps } = props\r\n const extraStyle: CSSProperties = {\r\n // when width/height equal to zero, transform: translateX(-50%) won't work\r\n // to make sure the element is not visible, we set left/top to a very large negative value\r\n left: -10000,\r\n top: -10000,\r\n pointerEvents: 'none',\r\n opacity: 0,\r\n // width: 0,\r\n // height: 0,\r\n padding: 0,\r\n transition: 'none',\r\n position: 'absolute',\r\n }\r\n\r\n const { refInternal, refInternalCallback } = useInternalRef(ref)\r\n\r\n const style: CSSProperties = { ...inStyle, ...extraStyle }\r\n useSpatialTransformVisibility(props[SpatialID], refInternal)\r\n\r\n const cssParserDivContainer = createOrGetCSSParserDivContainer()\r\n\r\n if (!cssParserDivContainer) {\r\n return null\r\n }\r\n\r\n return createPortal(\r\n <div ref={refInternalCallback} style={style} {...restProps} />,\r\n cssParserDivContainer,\r\n )\r\n}\r\n\r\nexport const TransformVisibilityTaskContainer = forwardRef(\r\n TransformVisibilityTaskContainerBase,\r\n)\r\n","import { RefObject, useCallback, useContext, useEffect } from 'react'\r\nimport { SpatialStyleInfoUpdateEvent } from '../../notifyUpdateStandInstanceLayout'\r\nimport { SpatialTransformVisibility } from '../types'\r\nimport { SpatializedContainerContext } from '../context/SpatializedContainerContext'\r\n\r\nfunction parseTransformAndVisibilityProperties(\r\n node: HTMLElement,\r\n): SpatialTransformVisibility {\r\n const computedStyle = getComputedStyle(node)\r\n\r\n // handle transform properties\r\n const transform = computedStyle.getPropertyValue('transform')\r\n\r\n // parse visibility\r\n const visibility = computedStyle.getPropertyValue('visibility')\r\n\r\n return {\r\n visibility,\r\n transform,\r\n }\r\n}\r\n\r\nexport function useSpatialTransformVisibility(\r\n spatialId: string,\r\n ref: RefObject<HTMLElement | null>,\r\n) {\r\n const spatializedContainerObject = useContext(SpatializedContainerContext)!\r\n\r\n const checkSpatialStyleUpdate = useCallback(() => {\r\n if (!ref.current) {\r\n return\r\n }\r\n const spatialTransformVisibility = parseTransformAndVisibilityProperties(\r\n ref.current!,\r\n )\r\n\r\n // notify SpatializedContainerContext\r\n spatializedContainerObject.updateSpatialTransformVisibility(\r\n spatialId,\r\n spatialTransformVisibility,\r\n )\r\n }, [])\r\n\r\n useEffect(() => {\r\n checkSpatialStyleUpdate()\r\n }, [checkSpatialStyleUpdate])\r\n\r\n useEffect(() => {\r\n // sync spatial style when this dom or sub dom change\r\n const observer = new MutationObserver(mutationsList => {\r\n checkSpatialStyleUpdate()\r\n })\r\n const config = {\r\n childList: false,\r\n subtree: false,\r\n attributes: true,\r\n // attributeOldValue: true,\r\n attributeFilter: ['style', 'class'],\r\n }\r\n observer.observe(ref.current!, config)\r\n\r\n return () => {\r\n observer.disconnect()\r\n }\r\n }, [])\r\n\r\n useEffect(() => {\r\n const headObserver = new MutationObserver(mutations => {\r\n checkSpatialStyleUpdate()\r\n })\r\n headObserver.observe(document.head, { childList: true, subtree: true })\r\n return () => {\r\n headObserver.disconnect()\r\n }\r\n }, [])\r\n\r\n useEffect(() => {\r\n const onDomUpdated = (event: Event) => {\r\n checkSpatialStyleUpdate()\r\n }\r\n\r\n // check style property change when some external style change\r\n document.addEventListener(\r\n SpatialStyleInfoUpdateEvent.domUpdated,\r\n onDomUpdated,\r\n )\r\n\r\n return () => {\r\n document.removeEventListener(\r\n SpatialStyleInfoUpdateEvent.domUpdated,\r\n onDomUpdated,\r\n )\r\n }\r\n }, [])\r\n}\r\n","export enum SpatialStyleInfoUpdateEvent {\r\n standInstanceLayout = 'standInstanceLayout',\r\n domUpdated = 'domUpdated',\r\n}\r\n\r\n/**\r\n * External-developers can call this function to sync the standardInstance layout to PortalInstance.\r\n *\r\n * Currently: notifyUpdateStandInstanceLayout is called when the document head changed\r\n * or when the monitored div changed (in both cases spatialDiv's layout may be changed, so we need to update the layout)\r\n */\r\nexport function notifyUpdateStandInstanceLayout() {\r\n document.dispatchEvent(\r\n new CustomEvent(SpatialStyleInfoUpdateEvent.standInstanceLayout, {\r\n detail: {},\r\n }),\r\n )\r\n}\r\n\r\nexport function notifyDOMUpdate(mutationsList: MutationRecord[]) {\r\n document.dispatchEvent(\r\n new CustomEvent(SpatialStyleInfoUpdateEvent.domUpdated, {\r\n detail: mutationsList,\r\n }),\r\n )\r\n}\r\n","import { ForwardedRef, forwardRef, useContext, useEffect, useMemo } from 'react'\r\nimport {\r\n SpatializedContainerContext,\r\n SpatializedContainerObject,\r\n} from './context/SpatializedContainerContext'\r\nimport { getSession } from '../utils/getSession'\r\nimport { SpatialLayerContext } from './context/SpatialLayerContext'\r\nimport { SpatializedElementRef, SpatializedContainerProps } from './types'\r\nimport { StandardSpatializedContainer } from './StandardSpatializedContainer'\r\nimport { PortalSpatializedContainer } from './PortalSpatializedContainer'\r\nimport { PortalInstanceContext } from './context/PortalInstanceContext'\r\nimport { SpatialID } from './SpatialID'\r\nimport { TransformVisibilityTaskContainer } from './TransformVisibilityTaskContainer'\r\nimport { useDomProxy } from './hooks/useDomProxy'\r\nimport { useInsideAttachment } from '../reality/context/InsideAttachmentContext'\r\nimport {\r\n useSpatialEvents,\r\n useSpatialEventsWhenSpatializedContainerExist,\r\n} from './hooks/useSpatialEvents'\r\nimport { withSSRSupported } from '../ssr'\r\n\r\n/**\r\n * Degraded fallback: strips spatial-only props and renders plain HTML.\r\n * This is a separate component so that SpatializedContainerBase never\r\n * has to conditionally skip its hooks.\r\n */\r\nfunction DegradedContainer<T extends SpatializedElementRef>({\r\n innerRef,\r\n ...inprops\r\n}: SpatializedContainerProps<T> & {\r\n innerRef: ForwardedRef<SpatializedElementRef<T>>\r\n}) {\r\n type DegradedProps = SpatializedContainerProps<T> & {\r\n 'enable-xr'?: unknown\r\n sizingMode?: unknown\r\n }\r\n const {\r\n component: Component,\r\n children,\r\n ['enable-xr']: _enableXR,\r\n onSpatialTap: _onSpatialTap,\r\n onSpatialDragStart: _onSpatialDragStart,\r\n onSpatialDrag: _onSpatialDrag,\r\n onSpatialDragEnd: _onSpatialDragEnd,\r\n onSpatialRotate: _onSpatialRotate,\r\n onSpatialRotateEnd: _onSpatialRotateEnd,\r\n onSpatialMagnify: _onSpatialMagnify,\r\n onSpatialMagnifyEnd: _onSpatialMagnifyEnd,\r\n spatializedContent: _content,\r\n createSpatializedElement: _create,\r\n getExtraSpatializedElementProperties: _getExtra,\r\n extraRefProps: _extraRef,\r\n sizingMode: _sizingMode,\r\n ...restProps\r\n } = inprops as DegradedProps\r\n return (\r\n <Component ref={innerRef} {...restProps}>\r\n {children}\r\n </Component>\r\n )\r\n}\r\n\r\nexport function SpatializedContainerBase<T extends SpatializedElementRef>(\r\n inprops: SpatializedContainerProps<T>,\r\n ref: ForwardedRef<SpatializedElementRef<T>>,\r\n) {\r\n const isWebSpatialEnv = getSession() !== null\r\n const insideAttachment = useInsideAttachment()\r\n\r\n if (!isWebSpatialEnv || insideAttachment) {\r\n if (insideAttachment) {\r\n console.warn(\r\n `[WebSpatial] ${inprops.component || 'Spatial element'} cannot be used inside AttachmentAsset. Rendering as plain HTML.`,\r\n )\r\n }\r\n return <DegradedContainer {...inprops} innerRef={ref} />\r\n }\r\n\r\n const layer = useContext(SpatialLayerContext) + 1\r\n const rootSpatializedContainerObject = useContext(\r\n SpatializedContainerContext,\r\n ) as unknown as SpatializedContainerObject<T>\r\n const inSpatializedContainer = !!rootSpatializedContainerObject\r\n const portalInstanceObject = useContext(PortalInstanceContext)\r\n const inPortalInstanceEnv = !!portalInstanceObject\r\n const isInStandardInstance = !inPortalInstanceEnv\r\n\r\n const spatialId = useMemo(() => {\r\n return !inSpatializedContainer\r\n ? `root_container`\r\n : rootSpatializedContainerObject.getSpatialId(layer, isInStandardInstance)\r\n }, [])\r\n const spatialIdProps = {\r\n [SpatialID]: spatialId,\r\n }\r\n const {\r\n onSpatialTap,\r\n onSpatialDragStart,\r\n onSpatialDrag,\r\n onSpatialDragEnd,\r\n onSpatialRotate,\r\n onSpatialRotateEnd,\r\n onSpatialMagnify,\r\n onSpatialMagnifyEnd,\r\n extraRefProps,\r\n ...props\r\n } = inprops\r\n\r\n if (inSpatializedContainer) {\r\n if (inPortalInstanceEnv) {\r\n const spatialEvents = useSpatialEventsWhenSpatializedContainerExist<T>(\r\n {\r\n onSpatialTap,\r\n onSpatialDragStart,\r\n onSpatialDrag,\r\n onSpatialDragEnd,\r\n onSpatialRotate,\r\n onSpatialRotateEnd,\r\n onSpatialMagnify,\r\n onSpatialMagnifyEnd,\r\n },\r\n spatialId,\r\n rootSpatializedContainerObject,\r\n )\r\n\r\n // nested in another PortalSpatializedContainer\r\n return (\r\n <SpatialLayerContext.Provider value={layer}>\r\n <PortalSpatializedContainer<T>\r\n {...spatialIdProps}\r\n {...props}\r\n {...spatialEvents}\r\n />\r\n </SpatialLayerContext.Provider>\r\n )\r\n } else {\r\n // in standard instance env\r\n const {\r\n transformVisibilityTaskContainerCallback,\r\n standardSpatializedContainerCallback,\r\n spatialContainerRefProxy,\r\n } = useDomProxy<T>(ref, extraRefProps)\r\n\r\n useEffect(() => {\r\n rootSpatializedContainerObject.updateSpatialContainerRefProxyInfo(\r\n spatialId,\r\n spatialContainerRefProxy.current,\r\n )\r\n }, [spatialContainerRefProxy.current])\r\n\r\n const {\r\n spatializedContent,\r\n createSpatializedElement,\r\n getExtraSpatializedElementProperties,\r\n ...restProps\r\n } = props\r\n return (\r\n <SpatialLayerContext.Provider value={layer}>\r\n <StandardSpatializedContainer<T>\r\n ref={standardSpatializedContainerCallback}\r\n {...spatialIdProps}\r\n {...restProps}\r\n inStandardSpatializedContainer={true}\r\n />\r\n <TransformVisibilityTaskContainer\r\n ref={transformVisibilityTaskContainerCallback}\r\n {...spatialIdProps}\r\n className={props.className}\r\n style={props.style}\r\n />\r\n </SpatialLayerContext.Provider>\r\n )\r\n }\r\n } else {\r\n const {\r\n transformVisibilityTaskContainerCallback,\r\n standardSpatializedContainerCallback,\r\n spatialContainerRefProxy,\r\n } = useDomProxy<T>(ref, extraRefProps)\r\n\r\n const spatialEvents = useSpatialEvents<T>(\r\n {\r\n onSpatialTap,\r\n onSpatialDragStart,\r\n onSpatialDrag,\r\n onSpatialDragEnd,\r\n onSpatialRotate,\r\n onSpatialRotateEnd,\r\n onSpatialMagnify,\r\n onSpatialMagnifyEnd,\r\n },\r\n spatialContainerRefProxy,\r\n )\r\n\r\n // This is the root spatialized container\r\n const spatializedContainerObject = useMemo(\r\n () => new SpatializedContainerObject(),\r\n [],\r\n )\r\n const {\r\n spatializedContent,\r\n createSpatializedElement,\r\n getExtraSpatializedElementProperties,\r\n ...restProps\r\n } = props\r\n\r\n return (\r\n <SpatialLayerContext.Provider value={layer}>\r\n <SpatializedContainerContext.Provider\r\n value={spatializedContainerObject}\r\n >\r\n <StandardSpatializedContainer<T>\r\n ref={standardSpatializedContainerCallback}\r\n {...spatialIdProps}\r\n {...restProps}\r\n inStandardSpatializedContainer={false}\r\n />\r\n <PortalSpatializedContainer<T>\r\n {...spatialIdProps}\r\n {...props}\r\n {...spatialEvents}\r\n />\r\n <TransformVisibilityTaskContainer\r\n ref={transformVisibilityTaskContainerCallback}\r\n {...spatialIdProps}\r\n className={props.className}\r\n style={props.style}\r\n />\r\n </SpatializedContainerContext.Provider>\r\n </SpatialLayerContext.Provider>\r\n )\r\n }\r\n}\r\n\r\nexport const SpatializedContainer = withSSRSupported(\r\n forwardRef(SpatializedContainerBase),\r\n) as <T extends SpatializedElementRef>(\r\n props: SpatializedContainerProps<T> & {\r\n ref?: ForwardedRef<SpatializedElementRef<T>>\r\n },\r\n) => React.ReactElement | null\r\n","// Redirect to empty module for treeshaking\r\nexport default {}\r\n\r\nexport const SpatialHelper = {}\r\n\r\nexport class Spatial {\r\n /**\r\n * Requests a session object from the browser\r\n * @returns The session or null if not availible in the current browser\r\n * [TODO] discuss implications of this not being async\r\n */\r\n requestSession() {\r\n return null\r\n }\r\n /**\r\n * Checks if the current page is running in a spatial web environment.\r\n * This method detects if the application is running in a WebSpatial-compatible browser.\r\n * @returns True if running in a spatial web environment, false otherwise\r\n */\r\n runInSpatialWeb() {\r\n return false\r\n }\r\n /**\r\n * @returns true if web spatial is supported by this webpage\r\n */\r\n isSupported() {\r\n return false\r\n }\r\n /**\r\n * Gets the native version, format is \"x.x.x\"\r\n * @returns native version string\r\n */\r\n getNativeVersion() {\r\n return null\r\n }\r\n /**\r\n * Gets the client version, format is \"x.x.x\"\r\n * @returns client version string\r\n */\r\n getClientVersion() {\r\n return null\r\n }\r\n}\r\n\r\nexport const version = undefined // no runtime so this should set undefined\r\n\r\nexport class SpatialScene {}\r\n\r\nexport function isSSREnv() {\r\n return false\r\n}\r\n","import { isSSREnv, Spatial, SpatialSession } from '@webspatial/core-sdk'\r\n// Create the default Spatial session for the app\r\nlet spatial: Spatial | null = null\r\nlet _currentSession: SpatialSession | null = null\r\n/** @hidden */\r\nexport function getSession() {\r\n if (isSSREnv()) return null\r\n if (!spatial) {\r\n spatial = new Spatial()\r\n }\r\n if (!spatial.isSupported()) {\r\n return null\r\n }\r\n if (_currentSession) {\r\n return _currentSession\r\n }\r\n _currentSession = spatial.requestSession()\r\n return _currentSession\r\n}\r\n\r\nexport { spatial }\r\n","import { createContext } from 'react'\r\n\r\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.\r\nexport const SpatialLayerContext = createContext(0)\r\n","import { useMemo, useContext, useEffect } from 'react'\r\nimport {\r\n PortalInstanceObject,\r\n PortalInstanceContext,\r\n} from './context/PortalInstanceContext'\r\nimport { PortalSpatializedContainerProps, SpatializedElementRef } from './types'\r\n\r\nimport { SpatialID } from './SpatialID'\r\nimport { useSync2DFrame } from './hooks/useSync2DFrame'\r\nimport { useSpatializedElement } from './hooks/useSpatializedElement'\r\nimport {\r\n SpatializedContainerContext,\r\n SpatializedContainerObject,\r\n} from './context/SpatializedContainerContext'\r\n\r\nfunction renderPlaceholderInSubPortal(\r\n portalInstanceObject: PortalInstanceObject,\r\n El: React.ElementType,\r\n) {\r\n const spatialId = portalInstanceObject.spatialId\r\n const inPortalInstanceEnv = !!portalInstanceObject.parentPortalInstanceObject\r\n const position =\r\n portalInstanceObject.computedStyle?.getPropertyValue('position')\r\n\r\n const shouldRenderPlaceHolder =\r\n inPortalInstanceEnv &&\r\n portalInstanceObject &&\r\n portalInstanceObject.domRect &&\r\n position !== 'absolute' &&\r\n position !== 'fixed'\r\n\r\n if (!shouldRenderPlaceHolder) {\r\n return <></>\r\n }\r\n\r\n const { width, height } = portalInstanceObject.domRect\r\n const display =\r\n portalInstanceObject.computedStyle!.getPropertyPriority('display')\r\n\r\n const spatialIdProps = { [SpatialID]: spatialId }\r\n return (\r\n <El\r\n {...spatialIdProps}\r\n style={{\r\n position: 'relative',\r\n width: `${width}px`,\r\n height: `${height}px`,\r\n visibility: 'hidden',\r\n display,\r\n }}\r\n />\r\n )\r\n}\r\n\r\nexport function PortalSpatializedContainer<T extends SpatializedElementRef>(\r\n props: PortalSpatializedContainerProps<T>,\r\n) {\r\n const {\r\n spatializedContent: Content,\r\n createSpatializedElement,\r\n getExtraSpatializedElementProperties,\r\n onSpatialTap,\r\n onSpatialDragStart,\r\n onSpatialDrag,\r\n onSpatialDragEnd,\r\n onSpatialRotate,\r\n onSpatialRotateEnd,\r\n onSpatialMagnify,\r\n onSpatialMagnifyEnd,\r\n [SpatialID]: spatialId,\r\n ...restProps\r\n } = props\r\n\r\n const spatializedContainerObject: SpatializedContainerObject = useContext(\r\n SpatializedContainerContext,\r\n )!\r\n\r\n const parentPortalInstanceObject = useContext(PortalInstanceContext)\r\n const portalInstanceObject = useMemo(\r\n () =>\r\n new PortalInstanceObject(\r\n spatialId,\r\n spatializedContainerObject,\r\n parentPortalInstanceObject,\r\n getExtraSpatializedElementProperties,\r\n ),\r\n [],\r\n )\r\n useEffect(() => {\r\n portalInstanceObject.init()\r\n return () => {\r\n portalInstanceObject.destroy()\r\n }\r\n }, [])\r\n\r\n useSync2DFrame(spatialId, portalInstanceObject, spatializedContainerObject)\r\n\r\n const spatializedElement = useSpatializedElement(\r\n createSpatializedElement,\r\n portalInstanceObject,\r\n )\r\n\r\n const PlaceholderEl = renderPlaceholderInSubPortal(\r\n portalInstanceObject,\r\n props.component,\r\n )\r\n\r\n useEffect(() => {\r\n if (spatializedElement) {\r\n // @ts-ignore\r\n spatializedElement.onSpatialTap = onSpatialTap\r\n }\r\n }, [spatializedElement, onSpatialTap])\r\n\r\n useEffect(() => {\r\n if (spatializedElement) {\r\n // @ts-ignore\r\n spatializedElement.onSpatialDrag = onSpatialDrag\r\n }\r\n }, [spatializedElement, onSpatialDrag])\r\n\r\n useEffect(() => {\r\n if (spatializedElement) {\r\n // @ts-ignore\r\n spatializedElement.onSpatialDragEnd = onSpatialDragEnd\r\n }\r\n }, [spatializedElement, onSpatialDragEnd])\r\n\r\n useEffect(() => {\r\n if (spatializedElement) {\r\n // @ts-ignore\r\n spatializedElement.onSpatialRotate = onSpatialRotate\r\n }\r\n }, [spatializedElement, onSpatialRotate])\r\n\r\n useEffect(() => {\r\n if (spatializedElement) {\r\n // @ts-ignore\r\n spatializedElement.onSpatialRotateEnd = onSpatialRotateEnd\r\n }\r\n }, [spatializedElement, onSpatialRotateEnd])\r\n\r\n useEffect(() => {\r\n if (spatializedElement) {\r\n // @ts-ignore\r\n spatializedElement.onSpatialMagnify = onSpatialMagnify\r\n }\r\n }, [spatializedElement, onSpatialMagnify])\r\n\r\n useEffect(() => {\r\n if (spatializedElement) {\r\n // @ts-ignore\r\n spatializedElement.onSpatialMagnifyEnd = onSpatialMagnifyEnd\r\n }\r\n }, [spatializedElement, onSpatialMagnifyEnd])\r\n\r\n useEffect(() => {\r\n if (spatializedElement) {\r\n // @ts-ignore\r\n spatializedElement.onSpatialDragStart = onSpatialDragStart\r\n }\r\n }, [spatializedElement, onSpatialDragStart])\r\n\r\n return (\r\n <PortalInstanceContext.Provider value={portalInstanceObject}>\r\n {spatializedElement && portalInstanceObject.dom && (\r\n <Content spatializedElement={spatializedElement} {...restProps} />\r\n )}\r\n {PlaceholderEl}\r\n </PortalInstanceContext.Provider>\r\n )\r\n}\r\n","import { Spatialized2DElement, SpatializedElement } from '@webspatial/core-sdk'\r\nimport { createContext } from 'react'\r\nimport { SpatializedContainerObject } from './SpatializedContainerContext'\r\nimport { parseTransformOrigin } from '../utils'\r\nimport {\r\n SpatialCustomStyleVars,\r\n Point3D,\r\n SpatialTransformVisibility,\r\n} from '../types'\r\nimport { getSession } from '../../utils'\r\nimport { convertDOMRectToSceneSpace } from '../transform-utils'\r\nimport {\r\n observeContentChanges,\r\n usesAndroidBitmapCapture,\r\n} from '../../utils/androidBitmapCapture'\r\nimport { BitmapCaptureCoordinator } from '../../utils/BitmapCaptureCoordinator'\r\n\r\ntype DomRect = {\r\n x: number\r\n y: number\r\n width: number\r\n height: number\r\n}\r\n\r\ntype CachedDomInfo = {\r\n // point to 2DFrame dom in StandardInstanceContainer\r\n dom: HTMLElement\r\n computedStyle: CSSStyleDeclaration\r\n isFixedPosition: boolean\r\n}\r\n\r\ntype CachedTransformVisibilityInfo = {\r\n visibility: string\r\n transformMatrix: DOMMatrix\r\n}\r\n\r\nexport class PortalInstanceObject {\r\n readonly spatialId: string\r\n readonly spatializedContainerObject: SpatializedContainerObject\r\n readonly parentPortalInstanceObject: PortalInstanceObject | null\r\n spatializedElement?: SpatializedElement\r\n\r\n // cachedDomInfo used for cache dom info\r\n // when dom is updated, this property should be updated as well\r\n private cachedDomInfo?: CachedDomInfo\r\n\r\n get dom(): HTMLElement | undefined {\r\n return this.cachedDomInfo?.dom\r\n }\r\n\r\n get computedStyle(): CSSStyleDeclaration | undefined {\r\n return this.cachedDomInfo?.computedStyle\r\n }\r\n\r\n get isFixedPosition(): boolean | undefined {\r\n return this.cachedDomInfo?.isFixedPosition\r\n }\r\n\r\n // cachedDomRect used for cache dom rect\r\n private cachedDomRect?: DomRect\r\n get domRect(): DomRect | undefined {\r\n return this.cachedDomRect\r\n }\r\n\r\n // cachedTransformVisibilityInfo used for cache transform visibility info\r\n private cachedTransformVisibilityInfo?: CachedTransformVisibilityInfo\r\n get transformMatrix() {\r\n return this.cachedTransformVisibilityInfo?.transformMatrix\r\n }\r\n get visibility() {\r\n return this.cachedTransformVisibilityInfo?.visibility\r\n }\r\n\r\n // spatializedElementPromise used for get spatialized element\r\n // SpatializedElement is when attachSpatializedElement is called\r\n private spatializedElementPromise?: Promise<SpatializedElement>\r\n private spatializedElementResolver?: (\r\n spatializedElement: SpatializedElement,\r\n ) => void\r\n\r\n // used for get extra spatialized element properties\r\n private getExtraSpatializedElementProperties?: (\r\n computedStyle: CSSStyleDeclaration,\r\n ) => Record<string, string | number>\r\n\r\n // Bitmap capture state for Android\r\n private pendingBitmapCapture: ReturnType<typeof setTimeout> | null = null\r\n // Initial delay before first capture (0ms = start immediately, content detection handles fonts/images)\r\n private bitmapCaptureInitialDelayMs = 0\r\n // Track if capture has been requested via coordinator\r\n private captureRequested = false\r\n private observedContentDom: HTMLElement | null = null\r\n private stopObservingContentChanges: (() => void) | null = null\r\n\r\n constructor(\r\n spatialId: string,\r\n spatializedContainerObject: SpatializedContainerObject,\r\n parentPortalInstanceObject: PortalInstanceObject | null,\r\n getExtraSpatializedElementProperties?: (\r\n computedStyle: CSSStyleDeclaration,\r\n ) => Record<string, string>,\r\n ) {\r\n this.spatialId = spatialId\r\n this.spatializedContainerObject = spatializedContainerObject\r\n this.parentPortalInstanceObject = parentPortalInstanceObject\r\n this.getExtraSpatializedElementProperties =\r\n getExtraSpatializedElementProperties\r\n\r\n this.spatializedElementPromise = new Promise<SpatializedElement>(\r\n resolve => {\r\n this.spatializedElementResolver = resolve\r\n },\r\n )\r\n }\r\n\r\n // called when PortalSpatializedContainer is mounted\r\n init() {\r\n this.spatializedContainerObject.onSpatialTransformVisibilityChange(\r\n this.spatialId,\r\n this.onSpatialTransformVisibilityChange,\r\n )\r\n }\r\n\r\n // called when PortalSpatializedContainer is unmounted\r\n destroy() {\r\n this.spatializedContainerObject.offSpatialTransformVisibilityChange(\r\n this.spatialId,\r\n this.onSpatialTransformVisibilityChange,\r\n )\r\n // Clear any pending bitmap capture\r\n if (this.pendingBitmapCapture) {\r\n clearTimeout(this.pendingBitmapCapture)\r\n this.pendingBitmapCapture = null\r\n }\r\n // Clear capture state in coordinator\r\n if (this.spatializedElement) {\r\n BitmapCaptureCoordinator.clearElement(this.spatializedElement.id)\r\n }\r\n this.stopObservingContentChanges?.()\r\n this.observedContentDom = null\r\n this.stopObservingContentChanges = null\r\n }\r\n\r\n private onSpatialTransformVisibilityChange = (\r\n spatialTransform: SpatialTransformVisibility,\r\n ) => {\r\n this.cachedTransformVisibilityInfo = {\r\n transformMatrix: new DOMMatrix(spatialTransform.transform),\r\n visibility: spatialTransform.visibility,\r\n }\r\n this.updateSpatializedElementProperties()\r\n }\r\n\r\n // called when 2D frame change\r\n notify2DFrameChange() {\r\n const dom = this.spatializedContainerObject.querySpatialDomBySpatialId(\r\n this.spatialId,\r\n )\r\n if (!dom) {\r\n return\r\n }\r\n const computedStyle = getComputedStyle(dom)\r\n this.cachedDomInfo = {\r\n dom,\r\n computedStyle,\r\n isFixedPosition: computedStyle.getPropertyValue('position') === 'fixed',\r\n }\r\n\r\n if (usesAndroidBitmapCapture()) {\r\n this.ensureContentObserver(dom)\r\n }\r\n\r\n this.updateSpatializedElementProperties()\r\n\r\n // attach __getBoundingClientCube to dom\r\n const __getBoundingClientCube = () => {\r\n return this.spatializedElement?.cubeInfo\r\n }\r\n const __getBoundingClientRect = () => {\r\n if (!this.spatializedElement?.transform) {\r\n return null\r\n }\r\n\r\n const domRect = new DOMRect(\r\n 0,\r\n 0,\r\n this.domRect?.width,\r\n this.domRect?.height,\r\n )\r\n return convertDOMRectToSceneSpace(\r\n domRect,\r\n this.spatializedElement?.transform as DOMMatrix,\r\n )\r\n }\r\n const __toSceneSpace = (point: Point3D): DOMPoint => {\r\n return new DOMPoint(point.x, point.y, point.z).matrixTransform(\r\n this.spatializedElement?.transform,\r\n )\r\n }\r\n const __toLocalSpace = (point: Point3D): DOMPoint => {\r\n return new DOMPoint(point.x, point.y, point.z).matrixTransform(\r\n this.spatializedElement?.transformInv,\r\n )\r\n }\r\n\r\n const __innerSpatializedElement = () => this.spatializedElement\r\n\r\n Object.assign(dom, {\r\n __getBoundingClientCube,\r\n __getBoundingClientRect,\r\n __toSceneSpace,\r\n __toLocalSpace,\r\n __innerSpatializedElement,\r\n })\r\n\r\n }\r\n\r\n private ensureContentObserver(dom: HTMLElement) {\r\n if (!usesAndroidBitmapCapture()) {\r\n return\r\n }\r\n if (this.observedContentDom === dom && this.stopObservingContentChanges) {\r\n return\r\n }\r\n\r\n this.stopObservingContentChanges?.()\r\n this.observedContentDom = dom\r\n this.stopObservingContentChanges = observeContentChanges(dom, () => {\r\n this.scheduleBitmapCapture(true)\r\n })\r\n }\r\n\r\n private async getSpatializedElement() {\r\n return this.spatializedElementPromise\r\n }\r\n\r\n // called when SpatializedElement is created\r\n attachSpatializedElement(spatializedElement: SpatializedElement) {\r\n this.spatializedElement = spatializedElement\r\n // attach to spatializedContainerObject\r\n this.addToParent(spatializedElement)\r\n this.spatializedElementResolver?.(spatializedElement)\r\n\r\n this.updateSpatializedElementProperties()\r\n }\r\n\r\n private inAddingToParent: boolean = false\r\n\r\n private async addToParent(spatializedElement: SpatializedElement) {\r\n if (this.inAddingToParent) {\r\n return\r\n }\r\n this.inAddingToParent = true\r\n\r\n if (this.isFixedPosition || !this.parentPortalInstanceObject) {\r\n // Add as a child of the current page\r\n var spatialScene = await getSession()!.getSpatialScene()\r\n await spatialScene.addSpatializedElement(spatializedElement!)\r\n } else {\r\n const parentSpatialized2DElement =\r\n (await this.parentPortalInstanceObject.getSpatializedElement()) as Spatialized2DElement\r\n // Add as a child of the parent\r\n parentSpatialized2DElement.addSpatializedElement(spatializedElement!)\r\n }\r\n this.inAddingToParent = false\r\n }\r\n\r\n /**\r\n * Captures the DOM element as a bitmap for Android XR rendering.\r\n * Uses BitmapCaptureCoordinator to prevent duplicate captures across instances.\r\n * The initial capture is delayed to allow images to load.\r\n */\r\n private scheduleBitmapCapture(forceRecapture: boolean = false) {\r\n if (!usesAndroidBitmapCapture()) return\r\n if (!this.dom || !this.spatializedElement) return\r\n\r\n const elementId = this.spatializedElement.id\r\n\r\n // Check if capture already requested for this element\r\n if (this.captureRequested) {\r\n return\r\n }\r\n this.captureRequested = true\r\n\r\n // Clear any existing timeout\r\n if (this.pendingBitmapCapture) {\r\n clearTimeout(this.pendingBitmapCapture)\r\n }\r\n\r\n console.log(\r\n `[WebSpatial] Scheduling capture for: ${elementId} (in ${this.bitmapCaptureInitialDelayMs}ms)`,\r\n )\r\n\r\n // Schedule the capture with a short delay to allow content to load\r\n this.pendingBitmapCapture = setTimeout(async () => {\r\n this.pendingBitmapCapture = null\r\n\r\n if (!this.dom || !this.spatializedElement) {\r\n console.log(`[WebSpatial] Capture cancelled - element gone: ${elementId}`)\r\n return\r\n }\r\n\r\n try {\r\n // Inject a global style to make ALL spatial elements visible during capture\r\n // This is more reliable than inline styles because it affects cloned DOMs too\r\n const captureStyleId = '__webspatial_capture_style__'\r\n let captureStyle = document.getElementById(captureStyleId) as HTMLStyleElement | null\r\n if (!captureStyle) {\r\n captureStyle = document.createElement('style')\r\n captureStyle.id = captureStyleId\r\n document.head.appendChild(captureStyle)\r\n }\r\n captureStyle.textContent = `\r\n .xr-spatial-default,\r\n [enable-xr],\r\n .xr-spatial-default * {\r\n visibility: visible !important;\r\n }\r\n `\r\n\r\n // Also set inline visibility for good measure\r\n const originalVisibility = this.dom.style.visibility\r\n const originalCssText = this.dom.style.cssText\r\n this.dom.style.setProperty('visibility', 'visible', 'important')\r\n\r\n // Find and make visible all nested spatial elements\r\n const nestedSpatialElements = this.dom.querySelectorAll('.xr-spatial-default')\r\n const nestedOriginalVisibilities: { element: HTMLElement; visibility: string; cssText: string }[] = []\r\n nestedSpatialElements.forEach(el => {\r\n const htmlEl = el as HTMLElement\r\n nestedOriginalVisibilities.push({\r\n element: htmlEl,\r\n visibility: htmlEl.style.visibility,\r\n cssText: htmlEl.style.cssText,\r\n })\r\n htmlEl.style.setProperty('visibility', 'visible', 'important')\r\n })\r\n\r\n\r\n // CRITICAL: Hide position:fixed children during parent capture\r\n // Fixed-position elements are captured separately as their own spatial elements.\r\n // If we don't hide them during parent capture, they appear at their viewport-fixed\r\n // positions and overlay the parent content, causing black/covered areas.\r\n const fixedElements: { element: HTMLElement; display: string }[] = []\r\n this.dom.querySelectorAll('*').forEach(el => {\r\n const htmlEl = el as HTMLElement\r\n const style = window.getComputedStyle(htmlEl)\r\n if (style.position === 'fixed') {\r\n fixedElements.push({\r\n element: htmlEl,\r\n display: htmlEl.style.display,\r\n })\r\n htmlEl.style.display = 'none'\r\n }\r\n })\r\n\r\n console.log(\r\n `[WebSpatial] Capturing ${elementId} with ${nestedSpatialElements.length} nested spatial elements made visible, ${fixedElements.length} fixed elements hidden`,\r\n )\r\n\r\n // Use coordinator to prevent duplicate captures\r\n const bitmap =\r\n forceRecapture || BitmapCaptureCoordinator.hasCaptured(elementId)\r\n ? await BitmapCaptureCoordinator.requestRecapture(\r\n elementId,\r\n this.dom,\r\n )\r\n : await BitmapCaptureCoordinator.requestCapture(\r\n elementId,\r\n this.dom,\r\n )\r\n\r\n // Restore visibility for all elements\r\n // Remove the global capture style\r\n const captureStyleToRemove = document.getElementById('__webspatial_capture_style__')\r\n if (captureStyleToRemove) {\r\n captureStyleToRemove.textContent = ''\r\n }\r\n\r\n this.dom.style.cssText = originalCssText\r\n if (originalVisibility) {\r\n this.dom.style.visibility = originalVisibility\r\n }\r\n nestedOriginalVisibilities.forEach(({ element, visibility, cssText }) => {\r\n element.style.cssText = cssText\r\n if (visibility) {\r\n element.style.visibility = visibility\r\n }\r\n })\r\n\r\n // Restore fixed elements\r\n fixedElements.forEach(({ element, display }) => {\r\n element.style.display = display\r\n })\r\n\r\n if (bitmap) {\r\n this.spatializedElement.updateProperties({ bitmap })\r\n }\r\n } catch (error) {\r\n console.error(`[WebSpatial] Capture failed: ${elementId}`, error)\r\n } finally {\r\n this.captureRequested = false\r\n }\r\n }, this.bitmapCaptureInitialDelayMs)\r\n }\r\n\r\n private updateSpatializedElementProperties() {\r\n // read from spatializedContainerContext\r\n const dom = this.dom\r\n const spatializedElement = this.spatializedElement\r\n const visibility = this.visibility\r\n\r\n if (!dom || !spatializedElement || !visibility || !this.transformMatrix) {\r\n return\r\n }\r\n\r\n const computedStyle = this.computedStyle!\r\n const isFixedPosition = this.isFixedPosition!\r\n\r\n let domRect = dom.getBoundingClientRect()\r\n\r\n let { x, y } = domRect\r\n if (!isFixedPosition) {\r\n const parentDom =\r\n this.spatializedContainerObject.queryParentSpatialDomBySpatialId(\r\n this.spatialId,\r\n )\r\n if (parentDom) {\r\n const parentDomRect = parentDom.getBoundingClientRect()\r\n x -= parentDomRect.x\r\n y -= parentDomRect.y\r\n } else {\r\n // Adjust to get the page relative to document instead of viewport\r\n x += window.scrollX\r\n y += window.scrollY\r\n }\r\n }\r\n\r\n // update cachedDomRect\r\n this.cachedDomRect = {\r\n x: domRect.x,\r\n y: domRect.y,\r\n width: domRect.width,\r\n height: domRect.height,\r\n }\r\n\r\n // console.log('updateSpatializedElementProperties', domRect)\r\n\r\n const width = domRect.width\r\n const height = domRect.height\r\n const opacity = parseFloat(computedStyle.getPropertyValue('opacity'))\r\n const scrollWithParent = !isFixedPosition\r\n\r\n const display = computedStyle.getPropertyValue('display')\r\n const visible = visibility === 'visible' && display !== 'none'\r\n\r\n const zIndex =\r\n parseFloat(\r\n computedStyle.getPropertyValue(SpatialCustomStyleVars.xrZIndex),\r\n ) || 0\r\n const backOffset =\r\n parseFloat(computedStyle.getPropertyValue(SpatialCustomStyleVars.back)) ||\r\n 0\r\n\r\n const depth =\r\n parseFloat(\r\n computedStyle.getPropertyValue(SpatialCustomStyleVars.depth),\r\n ) || 0\r\n\r\n const rotationAnchor = parseTransformOrigin(computedStyle)\r\n const extraProperties =\r\n this.getExtraSpatializedElementProperties?.(computedStyle) || {}\r\n\r\n spatializedElement.updateProperties({\r\n clientX: x,\r\n clientY: y,\r\n width,\r\n height,\r\n depth,\r\n opacity,\r\n scrollWithParent,\r\n zIndex,\r\n visible,\r\n backOffset,\r\n rotationAnchor,\r\n ...extraProperties,\r\n })\r\n\r\n // update transform\r\n spatializedElement.updateTransform(this.transformMatrix!)\r\n\r\n // assign spatializedElement to dom\r\n Object.assign(this.dom, {\r\n __spatializedElement: spatializedElement,\r\n })\r\n\r\n if (usesAndroidBitmapCapture()) {\r\n // Bitmap mode captures the element content and sends it to native for rendering.\r\n this.scheduleBitmapCapture()\r\n }\r\n }\r\n}\r\n\r\nexport const PortalInstanceContext = createContext<PortalInstanceObject | null>(\r\n null,\r\n)\r\n","import { isSSREnv, Spatialized2DElement } from '@webspatial/core-sdk'\r\nimport { getSession } from './getSession'\r\n\r\nasync function inspectCurrentSpatialScene() {\r\n const spatialScene = getSession()!.getSpatialScene()\r\n return spatialScene.inspect()\r\n}\r\n\r\nfunction getSpatialized2DElement(\r\n spatialized2DElement: HTMLDivElement,\r\n): Spatialized2DElement {\r\n return (\r\n spatialized2DElement as any\r\n ).__innerSpatializedElement?.() as Spatialized2DElement\r\n}\r\n\r\nexport function enableDebugTool() {\r\n if (isSSREnv()) return\r\n\r\n Object.assign(window, {\r\n inspectCurrentSpatialScene,\r\n getSpatialized2DElement,\r\n })\r\n}\r\n","/**\r\n * Bitmap capture utility for Android XR platform.\r\n *\r\n * On visionOS, each spatialized element gets its own WKWebView that renders HTML.\r\n * On Android XR, we use a single WebView + bitmap capture approach:\r\n * 1. Render HTML in the main WebView\r\n * 2. Capture enable-xr element content as bitmaps\r\n * 3. Transfer bitmaps to native via the bridge\r\n * 4. Render bitmaps on SpatialPanels at specified Z-depths\r\n *\r\n * Performance: Uses snapdom (30-100x faster than html2canvas) when available,\r\n * with html2canvas as fallback.\r\n */\r\n\r\n// Capture library loader state\r\nlet snapdomModule: any = null\r\nlet snapdomChecked = false\r\nlet snapdomAvailable = false\r\n\r\nlet html2canvasModule: any = null\r\nlet html2canvasChecked = false\r\nlet html2canvasAvailable = false\r\n\r\n/**\r\n * Dynamically loads snapdom library (preferred, 30-100x faster).\r\n * First checks for global, then tries dynamic import.\r\n * Retries a few times in case of race conditions.\r\n */\r\nasync function loadSnapdom(): Promise<any | null> {\r\n if (snapdomModule) return snapdomModule\r\n if (snapdomChecked && !snapdomAvailable) return null\r\n\r\n // Debug: log window.snapdom state\r\n console.log('[WebSpatial] Checking for snapdom...', {\r\n windowExists: typeof window !== 'undefined',\r\n snapdomOnWindow: typeof (window as any)?.snapdom,\r\n html2canvasOnWindow: typeof (window as any)?.html2canvas,\r\n })\r\n\r\n // Check for global snapdom (retry up to 3 times with short delays)\r\n for (let attempt = 0; attempt < 3; attempt++) {\r\n if (typeof window !== 'undefined' && (window as any).snapdom) {\r\n snapdomModule = (window as any).snapdom\r\n snapdomChecked = true\r\n snapdomAvailable = true\r\n console.log('[WebSpatial] Using globally provided snapdom (fast mode)')\r\n return snapdomModule\r\n }\r\n // Wait a bit before retrying (in case of module loading race)\r\n if (attempt < 2) {\r\n console.log(`[WebSpatial] snapdom not on window, retry ${attempt + 1}/3...`)\r\n await new Promise(resolve => setTimeout(resolve, 100))\r\n }\r\n }\r\n\r\n try {\r\n // Try dynamic import\r\n console.log('[WebSpatial] Trying dynamic import of @zumer/snapdom...')\r\n const moduleName = '@zumer/snapdom'\r\n const dynamicImport = new Function('moduleName', 'return import(moduleName)')\r\n const module = await dynamicImport(moduleName)\r\n snapdomModule = module.snapdom || module.default || module\r\n snapdomChecked = true\r\n snapdomAvailable = true\r\n console.log('[WebSpatial] Loaded snapdom via dynamic import (fast mode)')\r\n return snapdomModule\r\n } catch (error) {\r\n snapdomChecked = true\r\n snapdomAvailable = false\r\n console.log('[WebSpatial] snapdom not available:', (error as Error).message)\r\n console.log('[WebSpatial] Falling back to html2canvas')\r\n return null\r\n }\r\n}\r\n\r\n/**\r\n * Dynamically loads html2canvas library (fallback).\r\n */\r\nasync function loadHtml2Canvas(): Promise<any | null> {\r\n if (html2canvasModule) return html2canvasModule\r\n if (html2canvasChecked && !html2canvasAvailable) return null\r\n\r\n // Check for global html2canvas\r\n if (typeof window !== 'undefined' && (window as any).html2canvas) {\r\n html2canvasModule = (window as any).html2canvas\r\n html2canvasChecked = true\r\n html2canvasAvailable = true\r\n console.log('[WebSpatial] Using globally provided html2canvas (fallback mode)')\r\n return html2canvasModule\r\n }\r\n\r\n try {\r\n const moduleName = 'html2canvas'\r\n const dynamicImport = new Function('moduleName', 'return import(moduleName)')\r\n const module = await dynamicImport(moduleName)\r\n html2canvasModule = module.default || module\r\n html2canvasChecked = true\r\n html2canvasAvailable = true\r\n console.log('[WebSpatial] Loaded html2canvas via dynamic import (fallback mode)')\r\n return html2canvasModule\r\n } catch (error) {\r\n html2canvasChecked = true\r\n html2canvasAvailable = false\r\n console.warn(\r\n '[WebSpatial] Neither snapdom nor html2canvas available. ' +\r\n 'Bitmap capture for Android XR is disabled. ' +\r\n 'Install @zumer/snapdom (recommended) or html2canvas.',\r\n )\r\n return null\r\n }\r\n}\r\n\r\n/**\r\n * Check if we're running on Android XR platform.\r\n */\r\nexport function isAndroidPlatform(): boolean {\r\n if (typeof window === 'undefined') return false\r\n\r\n const ua = window.navigator.userAgent\r\n const hasWebSpatialBridge =\r\n typeof (window as any).webspatialBridge !== 'undefined'\r\n\r\n return hasWebSpatialBridge && (ua.includes('Android') || ua.includes('Linux'))\r\n}\r\n\r\ntype AndroidRenderMode = 'bitmap-capture' | 'live-window'\r\n\r\nexport function getAndroidRenderMode(): AndroidRenderMode | null {\r\n if (typeof window === 'undefined') {\r\n return null\r\n }\r\n\r\n const bridgeMode = (window as any).webspatialBridge?.getRenderMode?.()\r\n if (bridgeMode === 'live-window' || bridgeMode === 'bitmap-capture') {\r\n return bridgeMode as AndroidRenderMode\r\n }\r\n\r\n const configuredMode = (window as any).__WebSpatialAndroidConfig?.renderMode\r\n if (configuredMode === 'live-window' || configuredMode === 'bitmap-capture') {\r\n return configuredMode as AndroidRenderMode\r\n }\r\n\r\n if (!isAndroidPlatform()) {\r\n return null\r\n }\r\n\r\n return (\r\n 'bitmap-capture'\r\n ) as AndroidRenderMode\r\n}\r\n\r\nexport function supportsAndroidLiveWindowProxy(): boolean {\r\n return getAndroidRenderMode() === 'live-window'\r\n}\r\n\r\nexport function usesAndroidBitmapCapture(): boolean {\r\n return isAndroidPlatform() && !supportsAndroidLiveWindowProxy()\r\n}\r\n\r\n/**\r\n * Default background color for captures (dark theme).\r\n * Used when element has transparent/no background to prevent black panels in XR.\r\n */\r\nconst DEFAULT_CAPTURE_BACKGROUND = '#1a1a2e'\r\n\r\n/**\r\n * Check if element has a transparent or no background.\r\n * Returns true if we need to inject a temporary background for capture.\r\n */\r\nfunction hasTransparentBackground(element: HTMLElement): boolean {\r\n const style = window.getComputedStyle(element)\r\n const bg = style.backgroundColor\r\n const bgImage = style.backgroundImage\r\n\r\n // Check for transparent backgrounds\r\n if (\r\n bg === 'transparent' ||\r\n bg === 'rgba(0, 0, 0, 0)' ||\r\n bg === '' ||\r\n bg === 'initial'\r\n ) {\r\n // Only consider it transparent if there's no background image either\r\n if (bgImage === 'none' || bgImage === '' || bgImage === 'initial') {\r\n return true\r\n }\r\n }\r\n\r\n return false\r\n}\r\n\r\n/**\r\n * Temporarily inject a background color for capture.\r\n * Returns a cleanup function to restore original styles.\r\n *\r\n * On Android XR, we inject background on the element AND all child elements\r\n * that have transparent backgrounds. This is critical because:\r\n * 1. Spatial mode CSS sets `background: none` on many elements (product cards, etc.)\r\n * 2. These transparent children would render as black holes in the capture\r\n * 3. We need to fill ALL transparent areas with a solid background\r\n */\r\nfunction injectCaptureBackground(\r\n element: HTMLElement,\r\n backgroundColor: string = DEFAULT_CAPTURE_BACKGROUND,\r\n): () => void {\r\n const restoreFunctions: (() => void)[] = []\r\n\r\n // Inject background on the element itself\r\n const originalBg = element.style.backgroundColor\r\n const wasTransparent = hasTransparentBackground(element)\r\n element.style.backgroundColor = backgroundColor\r\n restoreFunctions.push(() => {\r\n element.style.backgroundColor = originalBg\r\n })\r\n\r\n // Find and inject background on ALL child elements with transparent backgrounds\r\n // This is crucial for spatial mode where many elements have `background: none`\r\n const allDescendants = element.querySelectorAll('*')\r\n let injectedCount = 0\r\n\r\n allDescendants.forEach(el => {\r\n const htmlEl = el as HTMLElement\r\n if (hasTransparentBackground(htmlEl)) {\r\n const childOriginalBg = htmlEl.style.backgroundColor\r\n htmlEl.style.backgroundColor = backgroundColor\r\n injectedCount++\r\n restoreFunctions.push(() => {\r\n htmlEl.style.backgroundColor = childOriginalBg\r\n })\r\n }\r\n })\r\n\r\n console.log(\r\n `[WebSpatial] Injected background ${backgroundColor} for capture (parent transparent: ${wasTransparent}, ${injectedCount} children)`,\r\n )\r\n\r\n return () => {\r\n restoreFunctions.forEach(restore => restore())\r\n }\r\n}\r\n\r\n// Track if initial render delay has been applied this session\r\nlet initialRenderDelayApplied = false\r\n\r\n/**\r\n * Wait for fonts and images to be ready.\r\n * Uses smart detection instead of fixed delay.\r\n * On first capture, waits longer to allow React to hydrate and data to load.\r\n */\r\nasync function waitForContent(\r\n element: HTMLElement,\r\n imageTimeoutMs: number = 2000,\r\n): Promise<void> {\r\n // On first capture, wait longer to allow React hydration and data loading\r\n // This is critical for pages that load data via useEffect\r\n if (!initialRenderDelayApplied) {\r\n initialRenderDelayApplied = true\r\n console.log('[WebSpatial] Applying initial render delay (1500ms) for first capture')\r\n await new Promise(resolve => setTimeout(resolve, 1500))\r\n }\r\n\r\n // Wait for fonts (up to 500ms)\r\n try {\r\n await Promise.race([\r\n document.fonts.ready,\r\n new Promise(resolve => setTimeout(resolve, 500)),\r\n ])\r\n } catch {\r\n // fonts.ready not supported, continue\r\n }\r\n\r\n // Wait for images (up to imageTimeoutMs)\r\n // This is crucial for external images (like Unsplash) that may take longer to load\r\n const images = element.querySelectorAll('img')\r\n console.log(`[WebSpatial] Found ${images.length} images in element`)\r\n\r\n if (images.length > 0) {\r\n // Log status of each image\r\n Array.from(images).forEach((img, i) => {\r\n const src = img.src?.substring(0, 80) || 'no-src'\r\n console.log(\r\n `[WebSpatial] Image ${i}: complete=${img.complete}, naturalWidth=${img.naturalWidth}, src=${src}...`,\r\n )\r\n })\r\n\r\n const incompleteImages = Array.from(images).filter(img => !img.complete)\r\n if (incompleteImages.length > 0) {\r\n console.log(`[WebSpatial] Waiting for ${incompleteImages.length} images to load (timeout: ${imageTimeoutMs}ms)`)\r\n\r\n const imagePromises = incompleteImages.map(img => {\r\n return new Promise<void>(resolve => {\r\n const handler = () => resolve()\r\n img.addEventListener('load', handler, { once: true })\r\n img.addEventListener('error', handler, { once: true })\r\n })\r\n })\r\n\r\n await Promise.race([\r\n Promise.all(imagePromises),\r\n new Promise(resolve => setTimeout(resolve, imageTimeoutMs)),\r\n ])\r\n\r\n // Log how many images loaded\r\n const stillIncomplete = incompleteImages.filter(img => !img.complete).length\r\n console.log(`[WebSpatial] Image wait complete. ${stillIncomplete} images still loading.`)\r\n } else {\r\n console.log(`[WebSpatial] All ${images.length} images already complete`)\r\n }\r\n }\r\n\r\n // Additional wait for dynamically loaded content (like product cards)\r\n // Check if element has minimal content and wait more if needed\r\n const textContent = element.innerText?.trim() || ''\r\n if (textContent.length < 100) {\r\n console.log(`[WebSpatial] Element has minimal content (${textContent.length} chars), waiting 500ms more`)\r\n await new Promise(resolve => setTimeout(resolve, 500))\r\n }\r\n}\r\n\r\n/**\r\n * Maximum bitmap dimension in pixels.\r\n * Android XR SpatialPanel max is 2560x1800dp, we cap at 2048px for safety and performance.\r\n */\r\nconst MAX_BITMAP_DIMENSION = 2048\r\n\r\n/**\r\n * Resize canvas if it exceeds max dimensions.\r\n * Maintains aspect ratio while capping both width and height.\r\n */\r\nfunction resizeCanvasIfNeeded(canvas: HTMLCanvasElement): HTMLCanvasElement {\r\n const { width, height } = canvas\r\n if (width <= MAX_BITMAP_DIMENSION && height <= MAX_BITMAP_DIMENSION) {\r\n return canvas\r\n }\r\n\r\n // Calculate scale factor to fit within max dimensions\r\n const scaleFactor = Math.min(\r\n MAX_BITMAP_DIMENSION / width,\r\n MAX_BITMAP_DIMENSION / height,\r\n )\r\n\r\n const newWidth = Math.round(width * scaleFactor)\r\n const newHeight = Math.round(height * scaleFactor)\r\n\r\n console.log(\r\n `[WebSpatial] Resizing bitmap from ${width}x${height} to ${newWidth}x${newHeight}`,\r\n )\r\n\r\n // Create resized canvas\r\n const resizedCanvas = document.createElement('canvas')\r\n resizedCanvas.width = newWidth\r\n resizedCanvas.height = newHeight\r\n\r\n const ctx = resizedCanvas.getContext('2d')\r\n if (ctx) {\r\n // Use high quality scaling\r\n ctx.imageSmoothingEnabled = true\r\n ctx.imageSmoothingQuality = 'high'\r\n ctx.drawImage(canvas, 0, 0, newWidth, newHeight)\r\n }\r\n\r\n return resizedCanvas\r\n}\r\n\r\n/**\r\n * Capture using snapdom (30-100x faster than html2canvas).\r\n * Note: snapdom has issues with cross-origin images and certain CSS layouts,\r\n * so html2canvas is preferred as the primary capture method on Android.\r\n */\r\nasync function captureWithSnapdom(\r\n snapdom: any,\r\n element: HTMLElement,\r\n scale: number,\r\n): Promise<string | null> {\r\n try {\r\n const cappedScale = Math.min(scale, 1.5)\r\n const rect = element.getBoundingClientRect()\r\n console.log(`[WebSpatial] snapdom capturing: rect=(${rect.x.toFixed(0)},${rect.y.toFixed(0)},${rect.width.toFixed(0)},${rect.height.toFixed(0)}), scale=${cappedScale}`)\r\n\r\n const result = await snapdom(element, {\r\n scale: cappedScale,\r\n embedFonts: false,\r\n })\r\n\r\n let canvas = await result.toCanvas()\r\n canvas = resizeCanvasIfNeeded(canvas)\r\n\r\n const dataUrl = canvas.toDataURL('image/webp', 0.85)\r\n return dataUrl\r\n } catch (error) {\r\n console.error('[WebSpatial] snapdom capture failed:', error)\r\n return null\r\n }\r\n}\r\n\r\n/**\r\n * Find elements with position:relative offsets that affect the captured element.\r\n * Returns a list of elements to reset and their original values.\r\n */\r\nfunction findOffsetElements(element: HTMLElement): Array<{\r\n element: HTMLElement\r\n originalTop: string\r\n originalLeft: string\r\n topValue: number\r\n leftValue: number\r\n}> {\r\n const offsetElements: Array<{\r\n element: HTMLElement\r\n originalTop: string\r\n originalLeft: string\r\n topValue: number\r\n leftValue: number\r\n }> = []\r\n\r\n // Check the element itself\r\n const style = window.getComputedStyle(element)\r\n if (style.position === 'relative') {\r\n const top = parseFloat(style.top) || 0\r\n const left = parseFloat(style.left) || 0\r\n if (top !== 0 || left !== 0) {\r\n offsetElements.push({\r\n element,\r\n originalTop: element.style.top,\r\n originalLeft: element.style.left,\r\n topValue: top,\r\n leftValue: left,\r\n })\r\n }\r\n }\r\n\r\n // Check parent elements that might have position:relative offsets\r\n let parent = element.parentElement\r\n let depth = 0\r\n const maxDepth = 5\r\n\r\n while (parent && depth < maxDepth) {\r\n const parentStyle = window.getComputedStyle(parent)\r\n if (parentStyle.position === 'relative') {\r\n const parentTop = parseFloat(parentStyle.top) || 0\r\n const parentLeft = parseFloat(parentStyle.left) || 0\r\n if (parentTop !== 0 || parentLeft !== 0) {\r\n console.log(\r\n `[WebSpatial] Found offset element: ${parent.tagName}.${parent.className?.split(' ')[0] || ''} ` +\r\n `top=${parentTop}px, left=${parentLeft}px`,\r\n )\r\n offsetElements.push({\r\n element: parent,\r\n originalTop: parent.style.top,\r\n originalLeft: parent.style.left,\r\n topValue: parentTop,\r\n leftValue: parentLeft,\r\n })\r\n }\r\n }\r\n parent = parent.parentElement\r\n depth++\r\n }\r\n\r\n return offsetElements\r\n}\r\n\r\n/**\r\n * Get total content offset from all offset elements.\r\n */\r\nfunction getContentOffset(element: HTMLElement): { top: number; left: number } {\r\n const offsetElements = findOffsetElements(element)\r\n return {\r\n top: offsetElements.reduce((sum, el) => sum + el.topValue, 0),\r\n left: offsetElements.reduce((sum, el) => sum + el.leftValue, 0),\r\n }\r\n}\r\n\r\n/**\r\n * Temporarily make element visible for capture.\r\n * Spatialized elements have visibility: hidden by default.\r\n * Returns a cleanup function to restore original visibility.\r\n */\r\nfunction makeElementVisible(element: HTMLElement): () => void {\r\n const restoreFunctions: (() => void)[] = []\r\n\r\n // Make the element itself visible\r\n const originalVisibility = element.style.visibility\r\n const computedVisibility = window.getComputedStyle(element).visibility\r\n if (computedVisibility === 'hidden') {\r\n element.style.visibility = 'visible'\r\n console.log(`[WebSpatial] Made element visible for capture (was: ${computedVisibility})`)\r\n restoreFunctions.push(() => {\r\n element.style.visibility = originalVisibility\r\n })\r\n }\r\n\r\n // Also make all child elements visible (they may be hidden too)\r\n const allDescendants = element.querySelectorAll('*')\r\n allDescendants.forEach(el => {\r\n const htmlEl = el as HTMLElement\r\n const childComputedVisibility = window.getComputedStyle(htmlEl).visibility\r\n if (childComputedVisibility === 'hidden') {\r\n const childOriginalVisibility = htmlEl.style.visibility\r\n htmlEl.style.visibility = 'visible'\r\n restoreFunctions.push(() => {\r\n htmlEl.style.visibility = childOriginalVisibility\r\n })\r\n }\r\n })\r\n\r\n if (restoreFunctions.length > 1) {\r\n console.log(`[WebSpatial] Made ${restoreFunctions.length} elements visible for capture`)\r\n }\r\n\r\n return () => {\r\n restoreFunctions.forEach(restore => restore())\r\n }\r\n}\r\n\r\n/**\r\n * Capture using html2canvas (fallback).\r\n * Optimized settings for faster capture on mobile.\r\n */\r\nasync function captureWithHtml2Canvas(\r\n html2canvas: any,\r\n element: HTMLElement,\r\n scale: number,\r\n backgroundColor: string | null,\r\n): Promise<string | null> {\r\n try {\r\n const rect = element.getBoundingClientRect()\r\n const contentOffset = getContentOffset(element)\r\n\r\n console.log(`[WebSpatial] html2canvas capturing: rect=(${rect.x.toFixed(0)},${rect.y.toFixed(0)},${rect.width.toFixed(0)},${rect.height.toFixed(0)}), contentOffset=(${contentOffset.top},${contentOffset.left})`)\r\n\r\n // Calculate window scroll position\r\n const scrollX = window.scrollX || window.pageXOffset || 0\r\n const scrollY = window.scrollY || window.pageYOffset || 0\r\n\r\n // The element's absolute position in the document\r\n const absoluteX = rect.x + scrollX\r\n const absoluteY = rect.y + scrollY\r\n\r\n // Find all elements with position:relative offsets that affect the capture\r\n const offsetElements = findOffsetElements(element)\r\n\r\n // Temporarily reset ALL offset elements to capture content at correct position\r\n // This prevents the \"black at top\" issue caused by CSS like `.main-window { top: 70px }`\r\n if (offsetElements.length > 0) {\r\n console.log(\r\n `[WebSpatial] Temporarily resetting ${offsetElements.length} offset elements for capture`,\r\n )\r\n offsetElements.forEach(({ element: el, topValue, leftValue }) => {\r\n el.style.top = '0px'\r\n el.style.left = '0px'\r\n console.log(\r\n `[WebSpatial] Reset: ${el.tagName}.${el.className?.split(' ')[0] || ''} ` +\r\n `from top=${topValue}px, left=${leftValue}px to 0`,\r\n )\r\n })\r\n\r\n // Force browser reflow to ensure layout is updated before capture\r\n // Without this, html2canvas may clone the DOM before new positions are applied\r\n void element.offsetHeight\r\n await new Promise(resolve => setTimeout(resolve, 50))\r\n console.log('[WebSpatial] Reflow complete after offset reset')\r\n }\r\n\r\n // Create restore function that resets all elements\r\n const restorePositions = () => {\r\n offsetElements.forEach(({ element: el, originalTop, originalLeft }) => {\r\n el.style.top = originalTop\r\n el.style.left = originalLeft\r\n })\r\n }\r\n\r\n // Ensure element is scrolled to top if it has internal scroll\r\n if (element.scrollTop !== 0) {\r\n console.log(`[WebSpatial] Resetting element scroll from ${element.scrollTop} to 0`)\r\n element.scrollTop = 0\r\n }\r\n\r\n // CRITICAL: Make element visible for capture\r\n // Spatialized elements have visibility: hidden by default in StandardSpatializedContainer\r\n // We need to temporarily make them visible so html2canvas can capture actual content\r\n const restoreVisibility = makeElementVisible(element)\r\n\r\n // Ensure window is scrolled to show the element\r\n const viewportTop = scrollY\r\n const viewportBottom = scrollY + window.innerHeight\r\n const elementTop = rect.y + scrollY\r\n const elementBottom = elementTop + rect.height\r\n\r\n console.log(\r\n `[WebSpatial] Capture context: viewport=(${viewportTop}-${viewportBottom}), ` +\r\n `element=(${elementTop}-${elementBottom}), innerHeight=${window.innerHeight}`,\r\n )\r\n\r\n let canvas: HTMLCanvasElement\r\n try {\r\n // Calculate the capture position accounting for parent offsets\r\n // We reset the parent offsets above, so the element should now be at its natural position\r\n // Use the CURRENT rect after offset reset\r\n const currentRect = element.getBoundingClientRect()\r\n const captureX = currentRect.x + scrollX\r\n const captureY = currentRect.y + scrollY\r\n\r\n console.log(\r\n `[WebSpatial] Capture bounds: original=(${absoluteX},${absoluteY}), ` +\r\n `afterReset=(${captureX},${captureY}), size=(${currentRect.width}x${currentRect.height})`,\r\n )\r\n\r\n // Capture the element by cropping to its document position\r\n // html2canvas renders the full document, then crops to x/y/width/height\r\n canvas = await html2canvas(element, {\r\n backgroundColor,\r\n logging: true, // Enable logging to debug\r\n scale: Math.min(scale, 1.5),\r\n useCORS: true,\r\n allowTaint: true,\r\n imageTimeout: 5000,\r\n removeContainer: true,\r\n foreignObjectRendering: false,\r\n // Don't set scroll offset - let html2canvas use default (current scroll)\r\n // scrollX and scrollY would affect rendering position but we want document coordinates\r\n // Crop to element's document position\r\n // x/y define the top-left corner of the crop region in document coordinates\r\n x: captureX,\r\n y: captureY,\r\n width: currentRect.width,\r\n height: currentRect.height,\r\n // Use onclone to MOVE the element to (0,0) in the cloned document\r\n // This is the key fix for elements far down the page (like footer at Y=1142)\r\n // By moving to absolute position (0,0), html2canvas will render at the top-left\r\n onclone: (clonedDoc: Document, clonedElement: HTMLElement) => {\r\n // Log position for debugging\r\n const originalRect = clonedElement.getBoundingClientRect()\r\n console.log(`[WebSpatial] CLONE: Element position in clone (${originalRect.x.toFixed(0)},${originalRect.y.toFixed(0)})`)\r\n\r\n // CRITICAL: Make all elements in the cloned document VISIBLE\r\n // Spatialized elements have visibility: hidden by default\r\n // In the clone, we MUST make them visible so html2canvas renders content\r\n clonedElement.style.visibility = 'visible'\r\n const hiddenElements = clonedElement.querySelectorAll('*')\r\n let visibilityFixCount = 0\r\n hiddenElements.forEach(el => {\r\n const htmlEl = el as HTMLElement\r\n const style = clonedDoc.defaultView?.getComputedStyle(htmlEl)\r\n if (style && style.visibility === 'hidden') {\r\n htmlEl.style.visibility = 'visible'\r\n visibilityFixCount++\r\n }\r\n })\r\n if (visibilityFixCount > 0) {\r\n console.log(`[WebSpatial] CLONE: Made ${visibilityFixCount + 1} elements visible`)\r\n }\r\n\r\n // Find and reset all offset parents in the CLONED document\r\n let parent = clonedElement.parentElement\r\n let depth = 0\r\n const maxDepth = 10\r\n\r\n while (parent && depth < maxDepth) {\r\n const parentStyle = clonedDoc.defaultView?.getComputedStyle(parent)\r\n if (parentStyle && parentStyle.position === 'relative') {\r\n const parentTop = parseFloat(parentStyle.top) || 0\r\n const parentLeft = parseFloat(parentStyle.left) || 0\r\n if (parentTop !== 0 || parentLeft !== 0) {\r\n console.log(\r\n `[WebSpatial] CLONE: Reset ${parent.tagName}.${parent.className?.split(' ')[0] || ''} ` +\r\n `from top=${parentTop}px, left=${parentLeft}px to 0`,\r\n )\r\n parent.style.top = '0px'\r\n parent.style.left = '0px'\r\n }\r\n }\r\n parent = parent.parentElement\r\n depth++\r\n }\r\n\r\n // Force reflow in cloned document\r\n void clonedElement.offsetHeight\r\n\r\n const clonedRect = clonedElement.getBoundingClientRect()\r\n const clonedStyle = clonedDoc.defaultView?.getComputedStyle(clonedElement)\r\n console.log(\r\n `[WebSpatial] Cloned element (after visibility fix): rect=(${clonedRect.x.toFixed(0)},${clonedRect.y.toFixed(0)},${clonedRect.width.toFixed(0)},${clonedRect.height.toFixed(0)}), ` +\r\n `visibility=${clonedStyle?.visibility}`,\r\n )\r\n\r\n // Log first few children to verify content structure\r\n const numChildren = Math.min(5, clonedElement.children.length)\r\n for (let i = 0; i < numChildren; i++) {\r\n const child = clonedElement.children[i] as HTMLElement\r\n const childRect = child.getBoundingClientRect()\r\n const childStyle = clonedDoc.defaultView?.getComputedStyle(child)\r\n console.log(\r\n `[WebSpatial] Child ${i}: ${child.tagName}.${child.className?.split(' ')[0] || ''}, ` +\r\n `rect=(${childRect.x.toFixed(0)},${childRect.y.toFixed(0)},${childRect.width.toFixed(0)},${childRect.height.toFixed(0)}), ` +\r\n `vis=${childStyle?.visibility}, display=${childStyle?.display}`,\r\n )\r\n }\r\n\r\n // Find and log the product grid specifically\r\n const productGrid = clonedElement.querySelector('.auto-fill-grid') as HTMLElement\r\n if (productGrid) {\r\n const gridRect = productGrid.getBoundingClientRect()\r\n const gridStyle = clonedDoc.defaultView?.getComputedStyle(productGrid)\r\n console.log(\r\n `[WebSpatial] Product grid: rect=(${gridRect.x.toFixed(0)},${gridRect.y.toFixed(0)},${gridRect.width.toFixed(0)},${gridRect.height.toFixed(0)}), ` +\r\n `columns=${gridStyle?.gridTemplateColumns?.substring(0, 100)}`,\r\n )\r\n // Log first product card\r\n const firstCard = productGrid.children[0] as HTMLElement\r\n if (firstCard) {\r\n const cardRect = firstCard.getBoundingClientRect()\r\n console.log(`[WebSpatial] First product card: rect=(${cardRect.x.toFixed(0)},${cardRect.y.toFixed(0)},${cardRect.width.toFixed(0)},${cardRect.height.toFixed(0)})`)\r\n }\r\n }\r\n },\r\n })\r\n } finally {\r\n // Restore visibility and position offsets after capture\r\n restoreVisibility()\r\n restorePositions()\r\n }\r\n\r\n // Debug: Sample pixels to verify content and find where it actually is\r\n const ctx = canvas.getContext('2d')\r\n if (ctx) {\r\n // Sample a grid of positions across the entire canvas\r\n const xPositions = [50, Math.floor(canvas.width / 4), Math.floor(canvas.width / 2), Math.floor(canvas.width * 3 / 4)]\r\n const yPositions = [50, 100, 200, 400, 600, 800, 1000, 1200, 1400]\r\n const samples: { name: string; x: number; y: number }[] = []\r\n yPositions.forEach(y => {\r\n if (y < canvas.height) {\r\n xPositions.forEach(x => {\r\n if (x < canvas.width) {\r\n samples.push({ name: `(${x},${y})`, x, y })\r\n }\r\n })\r\n }\r\n })\r\n\r\n console.log(`[WebSpatial] Canvas size: ${canvas.width}x${canvas.height}, scale=${scale}`)\r\n let bgCount = 0\r\n let contentCount = 0\r\n let contentPixels: string[] = []\r\n samples.forEach(s => {\r\n const pixel = ctx.getImageData(s.x, s.y, 1, 1).data\r\n const isBackground = pixel[0] === 26 && pixel[1] === 26 && pixel[2] === 46 // #1a1a2e\r\n if (isBackground) {\r\n bgCount++\r\n } else {\r\n contentCount++\r\n contentPixels.push(`${s.name}=rgba(${pixel[0]},${pixel[1]},${pixel[2]})`)\r\n }\r\n })\r\n console.log(`[WebSpatial] Grid sample: ${bgCount} BG, ${contentCount} CONTENT`)\r\n if (contentPixels.length > 0) {\r\n console.log(`[WebSpatial] Content pixels: ${contentPixels.slice(0, 10).join(', ')}`)\r\n }\r\n\r\n // If no content found in grid, do a more thorough scan\r\n if (contentCount === 0) {\r\n console.log(`[WebSpatial] No content in grid sample - scanning center column...`)\r\n for (let y = 0; y < canvas.height; y += 30) {\r\n const pixel = ctx.getImageData(Math.floor(canvas.width / 2), y, 1, 1).data\r\n const isBackground = pixel[0] === 26 && pixel[1] === 26 && pixel[2] === 46\r\n if (!isBackground) {\r\n console.log(`[WebSpatial] First content at Y=${y}: rgba(${pixel[0]},${pixel[1]},${pixel[2]})`)\r\n break\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Resize if needed to prevent oversized bitmaps\r\n canvas = resizeCanvasIfNeeded(canvas)\r\n\r\n // Use WebP for smaller size\r\n const dataUrl = canvas.toDataURL('image/webp', 0.85)\r\n return dataUrl\r\n } catch (error) {\r\n console.error('[WebSpatial] html2canvas capture failed:', error)\r\n return null\r\n }\r\n}\r\n\r\n/**\r\n * Captures an HTML element as a base64-encoded bitmap.\r\n * Uses snapdom (fast) when available, html2canvas as fallback.\r\n *\r\n * @param element The HTML element to capture\r\n * @param options Capture options\r\n * @returns Base64-encoded data URL, or null if capture failed\r\n */\r\nexport async function captureElementBitmap(\r\n element: HTMLElement,\r\n options?: {\r\n scale?: number\r\n backgroundColor?: string | null\r\n waitForImages?: boolean\r\n },\r\n): Promise<string | null> {\r\n if (!usesAndroidBitmapCapture()) {\r\n return null\r\n }\r\n\r\n const scale = options?.scale ?? (window.devicePixelRatio || 1)\r\n const startTime = performance.now()\r\n\r\n // Wait for content to be ready (fonts, images)\r\n if (options?.waitForImages !== false) {\r\n await waitForContent(element, 500)\r\n }\r\n\r\n // Inject background if element has transparent/no background\r\n // This prevents black panels in XR when rendered on transparent SpatialPanels\r\n const restoreBackground = injectCaptureBackground(\r\n element,\r\n options?.backgroundColor || DEFAULT_CAPTURE_BACKGROUND,\r\n )\r\n\r\n let result: string | null = null\r\n\r\n try {\r\n // Try html2canvas FIRST for better cross-origin image handling\r\n // snapdom has issues rendering cross-origin images on some platforms\r\n const html2canvas = await loadHtml2Canvas()\r\n if (html2canvas) {\r\n console.log('[WebSpatial] Using html2canvas (primary)')\r\n result = await captureWithHtml2Canvas(\r\n html2canvas,\r\n element,\r\n scale,\r\n options?.backgroundColor ?? DEFAULT_CAPTURE_BACKGROUND,\r\n )\r\n if (result) {\r\n const elapsed = Math.round(performance.now() - startTime)\r\n console.log(`[WebSpatial] Capture complete (html2canvas, ${elapsed}ms)`)\r\n return result\r\n }\r\n }\r\n\r\n // Fall back to snapdom\r\n const snapdom = await loadSnapdom()\r\n if (snapdom) {\r\n console.log('[WebSpatial] Falling back to snapdom')\r\n result = await captureWithSnapdom(snapdom, element, scale)\r\n if (result) {\r\n const elapsed = Math.round(performance.now() - startTime)\r\n console.log(`[WebSpatial] Capture complete (snapdom, ${elapsed}ms)`)\r\n return result\r\n }\r\n }\r\n\r\n console.error('[WebSpatial] No capture library available')\r\n return null\r\n } finally {\r\n // Always restore original background\r\n restoreBackground()\r\n }\r\n}\r\n\r\n/**\r\n * Throttled bitmap capture for performance.\r\n */\r\nexport function createThrottledBitmapCapture(delayMs: number = 500) {\r\n let pending: ReturnType<typeof setTimeout> | null = null\r\n let lastCapture: string | null = null\r\n\r\n return async (\r\n element: HTMLElement,\r\n callback: (bitmap: string | null) => void,\r\n ) => {\r\n if (pending) {\r\n clearTimeout(pending)\r\n }\r\n\r\n pending = setTimeout(async () => {\r\n pending = null\r\n const bitmap = await captureElementBitmap(element)\r\n\r\n if (bitmap !== lastCapture) {\r\n lastCapture = bitmap\r\n callback(bitmap)\r\n }\r\n }, delayMs)\r\n }\r\n}\r\n\r\n/**\r\n * Sets up a MutationObserver to detect content changes.\r\n */\r\nexport function observeContentChanges(\r\n element: HTMLElement,\r\n onContentChange: () => void,\r\n): () => void {\r\n const observer = new MutationObserver(_mutations => {\r\n onContentChange()\r\n })\r\n\r\n observer.observe(element, {\r\n childList: true,\r\n subtree: true,\r\n characterData: true,\r\n attributes: true,\r\n attributeFilter: ['class', 'style'],\r\n })\r\n\r\n let resizeObserver: ResizeObserver | null = null\r\n if (typeof ResizeObserver !== 'undefined') {\r\n resizeObserver = new ResizeObserver(_entries => {\r\n onContentChange()\r\n })\r\n resizeObserver.observe(element)\r\n }\r\n\r\n return () => {\r\n observer.disconnect()\r\n resizeObserver?.disconnect()\r\n }\r\n}\r\n","/**\r\n * Global coordinator for bitmap captures on Android XR.\r\n *\r\n * Problem: Multiple PortalInstanceObjects can trigger captures for the same\r\n * element (e.g., all using spatialId \"root_container\"), resulting in duplicate\r\n * work and performance degradation.\r\n *\r\n * Solution: Track captures globally by element UUID, not by spatialId.\r\n * Only one capture per element is allowed. Captures are serialized (one at a time)\r\n * to prevent thread contention and ensure consistent performance.\r\n */\r\n\r\nimport { captureElementBitmap } from './androidBitmapCapture'\r\n\r\ninterface CaptureRequest {\r\n promise: Promise<string | null>\r\n timestamp: number\r\n}\r\n\r\ninterface QueuedCapture {\r\n elementId: string\r\n dom: HTMLElement\r\n resolve: (value: string | null) => void\r\n reject: (error: Error) => void\r\n}\r\n\r\nclass BitmapCaptureCoordinatorClass {\r\n // Track completed captures by element UUID\r\n private capturedElements = new Set<string>()\r\n\r\n // Track in-flight capture requests\r\n private pendingCaptures = new Map<string, CaptureRequest>()\r\n\r\n // Minimum time between recaptures of the same element (ms)\r\n private recaptureThrottleMs = 750\r\n\r\n // Capture queue for serialized processing (prevents thread contention)\r\n private captureQueue: QueuedCapture[] = []\r\n private isProcessingQueue = false\r\n\r\n /**\r\n * Request a bitmap capture for an element.\r\n * Returns null immediately if the element has already been captured.\r\n * Deduplicates concurrent requests for the same element.\r\n * Captures are serialized to prevent thread contention.\r\n *\r\n * @param elementId Unique element ID (UUID, not spatialId)\r\n * @param dom The DOM element to capture\r\n * @returns Promise resolving to bitmap data URL, or null if already captured\r\n */\r\n async requestCapture(\r\n elementId: string,\r\n dom: HTMLElement,\r\n ): Promise<string | null> {\r\n // Skip if already captured\r\n if (this.capturedElements.has(elementId)) {\r\n console.log(`[WebSpatial] Skipping capture for ${elementId} (already captured)`)\r\n return null\r\n }\r\n\r\n // Check for in-flight request\r\n const pending = this.pendingCaptures.get(elementId)\r\n if (pending) {\r\n console.log(`[WebSpatial] Joining existing capture for ${elementId}`)\r\n return pending.promise\r\n }\r\n\r\n // Mark as captured immediately to prevent race conditions\r\n this.capturedElements.add(elementId)\r\n\r\n // Create promise that will be resolved when capture completes\r\n const promise = new Promise<string | null>((resolve, reject) => {\r\n // Add to queue\r\n this.captureQueue.push({ elementId, dom, resolve, reject })\r\n console.log(`[WebSpatial] Queued capture for ${elementId} (queue size: ${this.captureQueue.length})`)\r\n })\r\n\r\n this.pendingCaptures.set(elementId, {\r\n promise,\r\n timestamp: Date.now(),\r\n })\r\n\r\n // Clean up after capture completes\r\n promise.finally(() => {\r\n this.pendingCaptures.delete(elementId)\r\n })\r\n\r\n // Start processing queue if not already running\r\n this.processQueue()\r\n\r\n return promise\r\n }\r\n\r\n /**\r\n * Process the capture queue one at a time.\r\n * This prevents thread contention and ensures consistent capture performance.\r\n */\r\n private async processQueue(): Promise<void> {\r\n if (this.isProcessingQueue) return\r\n this.isProcessingQueue = true\r\n\r\n while (this.captureQueue.length > 0) {\r\n const item = this.captureQueue.shift()!\r\n const { elementId, dom, resolve, reject } = item\r\n\r\n try {\r\n console.log(`[WebSpatial] Processing capture for ${elementId} (${this.captureQueue.length} remaining)`)\r\n const bitmap = await this.doCapture(elementId, dom)\r\n resolve(bitmap)\r\n } catch (error) {\r\n reject(error as Error)\r\n }\r\n\r\n // Small delay between captures to allow UI to breathe\r\n await new Promise(r => setTimeout(r, 50))\r\n }\r\n\r\n this.isProcessingQueue = false\r\n }\r\n\r\n /**\r\n * Force a recapture of an element (e.g., after content change).\r\n * Respects throttling to prevent excessive recaptures.\r\n */\r\n async requestRecapture(\r\n elementId: string,\r\n dom: HTMLElement,\r\n ): Promise<string | null> {\r\n // Check throttle\r\n const pending = this.pendingCaptures.get(elementId)\r\n if (pending && Date.now() - pending.timestamp < this.recaptureThrottleMs) {\r\n console.log(`[WebSpatial] Throttling recapture for ${elementId}`)\r\n return pending.promise\r\n }\r\n\r\n // Allow recapture\r\n this.capturedElements.delete(elementId)\r\n return this.requestCapture(elementId, dom)\r\n }\r\n\r\n /**\r\n * Perform the actual capture.\r\n */\r\n private async doCapture(\r\n elementId: string,\r\n dom: HTMLElement,\r\n ): Promise<string | null> {\r\n console.log(`[WebSpatial] Starting capture for ${elementId}`)\r\n\r\n // Diagnostic: Log element structure and CSS before capture\r\n this.logElementDiagnostics(elementId, dom)\r\n\r\n try {\r\n const bitmap = await captureElementBitmap(dom)\r\n\r\n if (bitmap) {\r\n const sizeKB = Math.round(bitmap.length / 1024)\r\n console.log(`[WebSpatial] Capture complete for ${elementId} (${sizeKB}KB)`)\r\n } else {\r\n console.log(`[WebSpatial] Capture returned null for ${elementId}`)\r\n }\r\n\r\n return bitmap\r\n } catch (error) {\r\n console.error(`[WebSpatial] Capture failed for ${elementId}:`, error)\r\n // Remove from captured set so it can be retried\r\n this.capturedElements.delete(elementId)\r\n return null\r\n }\r\n }\r\n\r\n /**\r\n * Clear the capture state for an element (e.g., when destroyed).\r\n */\r\n clearElement(elementId: string): void {\r\n this.capturedElements.delete(elementId)\r\n this.pendingCaptures.delete(elementId)\r\n }\r\n\r\n /**\r\n * Clear all capture state (e.g., on page navigation).\r\n */\r\n clearAll(): void {\r\n this.capturedElements.clear()\r\n this.pendingCaptures.clear()\r\n }\r\n\r\n /**\r\n * Check if an element has been captured.\r\n */\r\n hasCaptured(elementId: string): boolean {\r\n return this.capturedElements.has(elementId)\r\n }\r\n\r\n /**\r\n * Log detailed diagnostics about an element before capture.\r\n * This helps debug issues like content being shifted or hidden.\r\n */\r\n private logElementDiagnostics(elementId: string, dom: HTMLElement): void {\r\n const rect = dom.getBoundingClientRect()\r\n const style = window.getComputedStyle(dom)\r\n\r\n console.log(`[WebSpatial] === CAPTURE DIAGNOSTICS: ${elementId} ===`)\r\n console.log(`[WebSpatial] Element: ${dom.tagName}.${dom.className}`)\r\n console.log(`[WebSpatial] BoundingRect: (${rect.x.toFixed(0)}, ${rect.y.toFixed(0)}, ${rect.width.toFixed(0)}, ${rect.height.toFixed(0)})`)\r\n console.log(`[WebSpatial] Position: ${style.position}, Top: ${style.top}, Left: ${style.left}`)\r\n console.log(`[WebSpatial] Padding: ${style.paddingTop} / ${style.paddingRight} / ${style.paddingBottom} / ${style.paddingLeft}`)\r\n console.log(`[WebSpatial] Margin: ${style.marginTop} / ${style.marginRight} / ${style.marginBottom} / ${style.marginLeft}`)\r\n console.log(`[WebSpatial] Visibility: ${style.visibility}, Display: ${style.display}`)\r\n console.log(`[WebSpatial] Overflow: ${style.overflow}, OverflowY: ${style.overflowY}`)\r\n\r\n // Check parent styles that might affect layout\r\n const parent = dom.parentElement\r\n if (parent) {\r\n const parentStyle = window.getComputedStyle(parent)\r\n const parentRect = parent.getBoundingClientRect()\r\n console.log(`[WebSpatial] Parent: ${parent.tagName}.${parent.className}`)\r\n console.log(`[WebSpatial] Parent BoundingRect: (${parentRect.x.toFixed(0)}, ${parentRect.y.toFixed(0)}, ${parentRect.width.toFixed(0)}, ${parentRect.height.toFixed(0)})`)\r\n console.log(`[WebSpatial] Parent Position: ${parentStyle.position}, Top: ${parentStyle.top}`)\r\n }\r\n\r\n // Log first few children to understand content layout\r\n const children = dom.children\r\n console.log(`[WebSpatial] Children count: ${children.length}`)\r\n for (let i = 0; i < Math.min(5, children.length); i++) {\r\n const child = children[i] as HTMLElement\r\n const childRect = child.getBoundingClientRect()\r\n const childStyle = window.getComputedStyle(child)\r\n console.log(`[WebSpatial] Child ${i}: ${child.tagName}.${child.className?.substring(0, 30)}...`)\r\n console.log(`[WebSpatial] Rect: (${childRect.x.toFixed(0)}, ${childRect.y.toFixed(0)}, ${childRect.width.toFixed(0)}, ${childRect.height.toFixed(0)})`)\r\n console.log(`[WebSpatial] Position: ${childStyle.position}, Visibility: ${childStyle.visibility}`)\r\n }\r\n console.log(`[WebSpatial] === END DIAGNOSTICS ===`)\r\n }\r\n}\r\n\r\n// Global singleton instance\r\nexport const BitmapCaptureCoordinator = new BitmapCaptureCoordinatorClass()\r\n","import { Point3D, SpatializedElementRef } from './types'\r\n\r\nexport function toSceneSpatial(\r\n point: Point3D,\r\n spatializedElement: SpatializedElementRef,\r\n): DOMPoint {\r\n return (spatializedElement as any).__toSceneSpace(point)\r\n}\r\n\r\nexport function toLocalSpace(\r\n point: Point3D,\r\n spatializedElement: SpatializedElementRef,\r\n): DOMPoint {\r\n return (spatializedElement as any).__toLocalSpace(point)\r\n}\r\n\r\nexport function convertDOMRectToSceneSpace(\r\n originalRect: DOMRect,\r\n matrix: DOMMatrix,\r\n) {\r\n const topLeft = new DOMPoint(originalRect.left, originalRect.top)\r\n const topRight = new DOMPoint(originalRect.right, originalRect.top)\r\n const bottomRight = new DOMPoint(originalRect.right, originalRect.bottom)\r\n const bottomLeft = new DOMPoint(originalRect.left, originalRect.bottom)\r\n const transformedTopLeft = matrix.transformPoint(topLeft)\r\n const transformedTopRight = matrix.transformPoint(topRight)\r\n const transformedBottomRight = matrix.transformPoint(bottomRight)\r\n const transformedBottomLeft = matrix.transformPoint(bottomLeft)\r\n\r\n const allPoints = [\r\n transformedTopLeft,\r\n transformedTopRight,\r\n transformedBottomRight,\r\n transformedBottomLeft,\r\n ]\r\n const xCoords = allPoints.map(point => point.x)\r\n const yCoords = allPoints.map(point => point.y)\r\n\r\n const newMinX = Math.min(...xCoords)\r\n const newMaxX = Math.max(...xCoords)\r\n const newMinY = Math.min(...yCoords)\r\n const newMaxY = Math.max(...yCoords)\r\n\r\n return new DOMRect(newMinX, newMinY, newMaxX - newMinX, newMaxY - newMinY)\r\n}\r\n","import { useEffect, useState } from 'react'\r\nimport { SpatializedContainerObject } from '../context/SpatializedContainerContext'\r\nimport { PortalInstanceObject } from '../context/PortalInstanceContext'\r\n\r\nfunction useForceUpdate() {\r\n const [, setToggle] = useState(false)\r\n return () => setToggle(toggle => !toggle)\r\n}\r\n\r\nexport function useSync2DFrame(\r\n spatialId: string,\r\n portalInstanceObject: PortalInstanceObject,\r\n spatializedContainerObject: SpatializedContainerObject,\r\n) {\r\n const forceUpdate = useForceUpdate()\r\n\r\n useEffect(() => {\r\n spatializedContainerObject.on2DFrameChange(spatialId, () => {\r\n portalInstanceObject.notify2DFrameChange()\r\n forceUpdate()\r\n })\r\n\r\n return () => {\r\n spatializedContainerObject.off2DFrameChange(spatialId)\r\n }\r\n }, [])\r\n}\r\n","import { useEffect, useState } from 'react'\r\nimport { PortalInstanceObject } from '../context/PortalInstanceContext'\r\nimport { SpatializedElement } from '@webspatial/core-sdk'\r\n\r\nexport function useSpatializedElement(\r\n createSpatializedElement: () => Promise<SpatializedElement>,\r\n portalInstanceObject: PortalInstanceObject,\r\n) {\r\n const [spatializedElement, setSpatializedElement] =\r\n useState<SpatializedElement>()\r\n\r\n useEffect(() => {\r\n let isDestroyed = false\r\n let spatializedElement: SpatializedElement | undefined\r\n createSpatializedElement().then(\r\n (inSpatializedElement: SpatializedElement) => {\r\n if (!isDestroyed) {\r\n spatializedElement = inSpatializedElement\r\n portalInstanceObject.attachSpatializedElement(spatializedElement)\r\n\r\n setSpatializedElement(spatializedElement)\r\n } else {\r\n inSpatializedElement?.destroy()\r\n }\r\n },\r\n )\r\n\r\n return () => {\r\n isDestroyed = true\r\n if (spatializedElement) {\r\n spatializedElement.destroy()\r\n spatializedElement = undefined\r\n }\r\n }\r\n }, [createSpatializedElement, portalInstanceObject])\r\n\r\n return spatializedElement\r\n}\r\n","import { createContext, useContext } from 'react'\r\n\r\nexport const InsideAttachmentContext = createContext(false)\r\nexport const useInsideAttachment = () => useContext(InsideAttachmentContext)\r\n","import { RefObject } from 'react'\r\nimport { SpatialContainerRefProxy } from './useDomProxy'\r\nimport {\r\n SpatializedElementRef,\r\n SpatialTapEvent,\r\n SpatialDragStartEvent,\r\n SpatialDragEndEvent,\r\n SpatialDragEvent,\r\n SpatialRotateEvent,\r\n SpatialRotateEndEvent,\r\n SpatialMagnifyEndEvent,\r\n SpatialMagnifyEvent,\r\n} from '../types'\r\nimport { SpatializedContainerObject } from '../context/SpatializedContainerContext'\r\n\r\nexport interface SpatialEvents<\r\n T extends SpatializedElementRef = SpatializedElementRef,\r\n> {\r\n onSpatialTap?: (event: SpatialTapEvent<T>) => void\r\n onSpatialDragStart?: (event: SpatialDragStartEvent<T>) => void\r\n onSpatialDrag?: (event: SpatialDragEvent<T>) => void\r\n onSpatialDragEnd?: (event: SpatialDragEndEvent<T>) => void\r\n onSpatialRotate?: (event: SpatialRotateEvent<T>) => void\r\n onSpatialRotateEnd?: (event: SpatialRotateEndEvent<T>) => void\r\n onSpatialMagnify?: (event: SpatialMagnifyEvent<T>) => void\r\n onSpatialMagnifyEnd?: (event: SpatialMagnifyEndEvent<T>) => void\r\n}\r\n\r\nfunction createEventProxy<\r\n T extends SpatializedElementRef,\r\n E extends { currentTarget: T },\r\n>(\r\n event: E,\r\n currentTargetGetter: () => T,\r\n offsetXGetter?: (event: E) => number | undefined,\r\n offsetYGetter?: (event: E) => number | undefined,\r\n offsetZGetter?: (event: E) => number | undefined,\r\n clientXGetter?: (event: E) => number | undefined,\r\n clientYGetter?: (event: E) => number | undefined,\r\n clientZGetter?: (event: E) => number | undefined,\r\n translationXGetter?: (event: E) => number | undefined,\r\n translationYGetter?: (event: E) => number | undefined,\r\n translationZGetter?: (event: E) => number | undefined,\r\n quaternionGetter?: (\r\n event: E,\r\n ) => import('@webspatial/core-sdk').Quaternion | undefined,\r\n magnificationGetter?: (event: E) => number | undefined,\r\n): E {\r\n return new Proxy(event, {\r\n get(target, prop) {\r\n if (prop === 'currentTarget') {\r\n return currentTargetGetter()\r\n }\r\n if (prop === 'isTrusted') {\r\n return true\r\n }\r\n if (prop === 'bubbles') {\r\n return false\r\n }\r\n if (prop === 'offsetX' && offsetXGetter) {\r\n return offsetXGetter(target) ?? 0\r\n }\r\n if (prop === 'offsetY' && offsetYGetter) {\r\n return offsetYGetter(target) ?? 0\r\n }\r\n if (prop === 'offsetZ' && offsetZGetter) {\r\n return offsetZGetter(target) ?? 0\r\n }\r\n if (prop === 'clientX' && clientXGetter) {\r\n return clientXGetter(target) ?? 0\r\n }\r\n if (prop === 'clientY' && clientYGetter) {\r\n return clientYGetter(target) ?? 0\r\n }\r\n if (prop === 'clientZ' && clientZGetter) {\r\n return clientZGetter(target) ?? 0\r\n }\r\n if (prop === 'translationX' && translationXGetter) {\r\n return translationXGetter(target) ?? 0\r\n }\r\n if (prop === 'translationY' && translationYGetter) {\r\n return translationYGetter(target) ?? 0\r\n }\r\n if (prop === 'translationZ' && translationZGetter) {\r\n return translationZGetter(target) ?? 0\r\n }\r\n if (prop === 'quaternion' && quaternionGetter) {\r\n return quaternionGetter(target) ?? { x: 0, y: 0, z: 0, w: 1 }\r\n }\r\n if (prop === 'magnification' && magnificationGetter) {\r\n return magnificationGetter(target) ?? 1\r\n }\r\n return Reflect.get(target, prop)\r\n },\r\n })\r\n}\r\n\r\nfunction createEventHandler<\r\n T extends SpatializedElementRef,\r\n E extends { currentTarget: T },\r\n>(\r\n handler: ((event: E) => void) | undefined,\r\n currentTargetGetter: () => T,\r\n offsetXGetter?: (event: E) => number | undefined,\r\n offsetYGetter?: (event: E) => number | undefined,\r\n offsetZGetter?: (event: E) => number | undefined,\r\n clientXGetter?: (event: E) => number | undefined,\r\n clientYGetter?: (event: E) => number | undefined,\r\n clientZGetter?: (event: E) => number | undefined,\r\n translationXGetter?: (event: E) => number | undefined,\r\n translationYGetter?: (event: E) => number | undefined,\r\n translationZGetter?: (event: E) => number | undefined,\r\n quaternionGetter?: (\r\n event: E,\r\n ) => import('@webspatial/core-sdk').Quaternion | undefined,\r\n magnificationGetter?: (event: E) => number | undefined,\r\n): ((event: E) => void) | undefined {\r\n return handler\r\n ? (event: E) => {\r\n const proxyEvent = createEventProxy<T, E>(\r\n event,\r\n currentTargetGetter,\r\n offsetXGetter,\r\n offsetYGetter,\r\n offsetZGetter,\r\n clientXGetter,\r\n clientYGetter,\r\n clientZGetter,\r\n translationXGetter,\r\n translationYGetter,\r\n translationZGetter,\r\n quaternionGetter,\r\n magnificationGetter,\r\n )\r\n handler(proxyEvent)\r\n }\r\n : undefined\r\n}\r\n\r\nexport function useSpatialEventsBase<T extends SpatializedElementRef>(\r\n spatialEvents: SpatialEvents<T>,\r\n currentTargetGetter: () => T,\r\n) {\r\n const onSpatialTap = createEventHandler<T, SpatialTapEvent<T>>(\r\n spatialEvents.onSpatialTap,\r\n currentTargetGetter,\r\n // offsetX/Y/Z come from local coordinates\r\n (ev: SpatialTapEvent<T>) => ev.detail?.location3D?.x,\r\n (ev: SpatialTapEvent<T>) => ev.detail?.location3D?.y,\r\n (ev: SpatialTapEvent<T>) => ev.detail?.location3D?.z,\r\n // clientX/Y/Z come from global scene coordinates\r\n (ev: SpatialTapEvent<T>) => ev.detail?.globalLocation3D?.x,\r\n (ev: SpatialTapEvent<T>) => ev.detail?.globalLocation3D?.y,\r\n (ev: SpatialTapEvent<T>) => ev.detail?.globalLocation3D?.z,\r\n )\r\n const onSpatialDrag = createEventHandler<T, SpatialDragEvent<T>>(\r\n spatialEvents.onSpatialDrag,\r\n currentTargetGetter,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n (ev: SpatialDragEvent<T>) => ev.detail?.translation3D?.x,\r\n (ev: SpatialDragEvent<T>) => ev.detail?.translation3D?.y,\r\n (ev: SpatialDragEvent<T>) => ev.detail?.translation3D?.z,\r\n )\r\n\r\n const onSpatialDragEnd = createEventHandler<T, SpatialDragEndEvent<T>>(\r\n spatialEvents.onSpatialDragEnd,\r\n currentTargetGetter,\r\n )\r\n\r\n const onSpatialRotate = createEventHandler<T, SpatialRotateEvent<T>>(\r\n spatialEvents.onSpatialRotate,\r\n currentTargetGetter,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n (ev: SpatialRotateEvent<T>) => ev.detail?.quaternion,\r\n )\r\n\r\n const onSpatialRotateEnd = createEventHandler<T, SpatialRotateEndEvent<T>>(\r\n spatialEvents.onSpatialRotateEnd,\r\n currentTargetGetter,\r\n )\r\n\r\n const onSpatialMagnify = createEventHandler<T, SpatialMagnifyEvent<T>>(\r\n spatialEvents.onSpatialMagnify,\r\n currentTargetGetter,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n (ev: SpatialMagnifyEvent<T>) => ev.detail?.magnification,\r\n )\r\n\r\n const onSpatialMagnifyEnd = createEventHandler<T, SpatialMagnifyEndEvent<T>>(\r\n spatialEvents.onSpatialMagnifyEnd,\r\n currentTargetGetter,\r\n )\r\n\r\n const onSpatialDragStart = createEventHandler<T, SpatialDragStartEvent<T>>(\r\n spatialEvents.onSpatialDragStart,\r\n currentTargetGetter,\r\n (ev: SpatialDragStartEvent<T>) => ev.detail?.startLocation3D?.x,\r\n (ev: SpatialDragStartEvent<T>) => ev.detail?.startLocation3D?.y,\r\n (ev: SpatialDragStartEvent<T>) => ev.detail?.startLocation3D?.z,\r\n (ev: SpatialDragStartEvent<T>) => ev.detail?.globalLocation3D?.x,\r\n (ev: SpatialDragStartEvent<T>) => ev.detail?.globalLocation3D?.y,\r\n (ev: SpatialDragStartEvent<T>) => ev.detail?.globalLocation3D?.z,\r\n )\r\n\r\n return {\r\n onSpatialTap,\r\n onSpatialDragStart,\r\n onSpatialDrag,\r\n onSpatialDragEnd,\r\n onSpatialRotate,\r\n onSpatialRotateEnd,\r\n onSpatialMagnify,\r\n onSpatialMagnifyEnd,\r\n }\r\n}\r\n\r\nexport function useSpatialEvents<T extends SpatializedElementRef>(\r\n spatialEvents: SpatialEvents<T>,\r\n spatialContainerRefProxy: RefObject<SpatialContainerRefProxy<T>>,\r\n) {\r\n return useSpatialEventsBase<T>(\r\n spatialEvents,\r\n () => spatialContainerRefProxy.current?.domProxy!,\r\n )\r\n}\r\n\r\nexport function useSpatialEventsWhenSpatializedContainerExist<\r\n T extends SpatializedElementRef,\r\n>(\r\n spatialEvents: SpatialEvents<T>,\r\n spatialId: string,\r\n spatializedContainerObject: SpatializedContainerObject<T>,\r\n) {\r\n return useSpatialEventsBase<T>(spatialEvents, () => {\r\n const spatialContainerRefProxy =\r\n spatializedContainerObject.getSpatialContainerRefProxyBySpatialId(\r\n spatialId,\r\n )\r\n return spatialContainerRefProxy?.domProxy as T\r\n })\r\n}\r\n","import React, { createContext, useState, useEffect } from 'react'\r\n\r\nexport const SSRContext = createContext(false)\r\n\r\nexport const SSRProvider = ({\r\n isSSR: initialIsSSR = true,\r\n children,\r\n}: {\r\n isSSR?: boolean\r\n children: React.ReactNode\r\n}) => {\r\n const [isSSR, setIsSSR] = useState(initialIsSSR)\r\n\r\n useEffect(() => {\r\n if (isSSR) {\r\n setIsSSR(false)\r\n }\r\n }, [])\r\n\r\n return <SSRContext.Provider value={isSSR}>{children}</SSRContext.Provider>\r\n}\r\n","import React, { ComponentType, forwardRef, PropsWithoutRef } from 'react'\r\nimport { useSSRPhase } from './useSSRPhase'\r\n\r\nexport type SSRPhase = 'ssr' | 'hydrate' | 'after-hydrate'\r\n\r\n/**\r\n * A HOC that ensures a component is only rendered on the client side.\r\n * It returns null during server-side rendering.\r\n * @param Component The component to be rendered only on the client.\r\n */\r\nexport function withSSRSupported<T extends {}>(Component: ComponentType<T>) {\r\n const ClientOnlyComponent = (\r\n props: PropsWithoutRef<T>,\r\n ref: React.ForwardedRef<any>,\r\n ) => {\r\n const phase = useSSRPhase()\r\n\r\n let renderType: 'fake' | 'real' = 'real'\r\n\r\n if (phase === 'ssr' || phase === 'hydrate') {\r\n renderType = 'fake'\r\n }\r\n\r\n if (renderType === 'fake') {\r\n const { style, className } = props as any\r\n // keep style and className for SSR, prevent style flicker on hydration\r\n return <div style={style} className={className} ref={ref}></div>\r\n } else {\r\n return <Component {...(props as T)} ref={ref} />\r\n }\r\n }\r\n\r\n ClientOnlyComponent.displayName = `withClientOnly(${Component.displayName || Component.name || 'Component'})`\r\n\r\n return forwardRef(ClientOnlyComponent)\r\n}\r\n","import { useContext, useState, useEffect } from 'react'\r\nimport { SSRContext } from './SSRContext'\r\nimport type { SSRPhase } from './withSSRSupported'\r\n/**\r\n * A hook to determine the current phase of Server-Side Rendering (SSR).\r\n *\r\n * This hook is crucial for components that need to behave differently during\r\n * various stages of the SSR lifecycle. It helps prevent hydration mismatches\r\n * in React by providing a clear state for each phase.\r\n *\r\n * @returns {SSRPhase} The current SSR phase, which can be one of the following:\r\n * - `'ssr'`: The component is rendering on the server.\r\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.\r\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.\r\n *\r\n * @example\r\n * ```tsx\r\n * const ssrPhase = useSSRPhase();\r\n *\r\n * if (ssrPhase === 'ssr' || ssrPhase === 'hydrate') {\r\n * return <Spinner />;\r\n * }\r\n *\r\n * return <MyClientOnlyComponent />;\r\n * ```\r\n */\r\nexport function useSSRPhase(): SSRPhase {\r\n const isSSRContext = useContext(SSRContext)\r\n const isServer = typeof window === 'undefined'\r\n const [hydrated, setHydrated] = useState(false)\r\n\r\n useEffect(() => setHydrated(true), [])\r\n\r\n // Server-side rendering (SSR mode)\r\n if (isServer) {\r\n return 'ssr' as const\r\n }\r\n\r\n // Client-side\r\n if (isSSRContext) {\r\n // SSR mode: check hydration state\r\n return hydrated ? ('after-hydrate' as const) : ('hydrate' as const)\r\n } else {\r\n // CSR mode: directly return after-hydrate\r\n return 'after-hydrate' as const\r\n }\r\n}\r\n","import { createPortal } from 'react-dom'\nimport React, {\n CSSProperties,\n ElementType,\n ForwardedRef,\n forwardRef,\n useContext,\n useEffect,\n} from 'react'\n\nimport { Spatialized2DElement } from '@webspatial/core-sdk'\n\nimport {\n ensureWindowDocumentStructure,\n setOpenWindowStyle,\n syncParentHeadToChild,\n} from '../utils/windowStyleSync'\nimport { useSyncHeadStyles } from '../utils/useSyncHeadStyles'\nimport { getSession } from '../utils'\nimport { usesAndroidBitmapCapture } from '../utils/androidBitmapCapture'\nimport { getInheritedStyleProps, parseCornerRadius } from './utils'\nimport {\n SpatialCustomStyleVars,\n Spatialized2DElementContainerProps,\n SpatializedElementRef,\n SpatializedContentProps,\n SpatializedDivElementRef,\n} from './types'\nimport { SpatializedContainer } from './SpatializedContainer'\nimport {\n PortalInstanceContext,\n PortalInstanceObject,\n} from './context/PortalInstanceContext'\nfunction getJSXPortalInstance<P extends ElementType>(\n inProps: Omit<\n SpatializedContentProps<SpatializedElementRef, P>,\n 'spatializedElement'\n >,\n portalInstanceObject: PortalInstanceObject,\n) {\n const { component: El, style: inStyle = {}, ...props } = inProps\n const extraStyle: CSSProperties = {\n visibility: 'visible',\n position: 'relative',\n top: '0px',\n left: '0px',\n margin: '0px',\n marginLeft: '0px',\n marginRight: '0px',\n marginTop: '0px',\n marginBottom: '0px',\n borderRadius: '0px',\n // overflow: '',\n transform: 'none',\n }\n\n const computedStyle = portalInstanceObject.computedStyle!\n const inheritedPortalStyle: CSSProperties =\n getInheritedStyleProps(computedStyle)\n\n const style = {\n ...inStyle,\n ...inheritedPortalStyle,\n ...extraStyle,\n }\n\n return <El style={style} {...props} />\n}\n\nfunction useSyncDocumentTitle(\n windowProxy: WindowProxy,\n spatializedElement: Spatialized2DElement,\n name: string,\n) {\n useEffect(() => {\n const childDocument = ensureWindowDocumentStructure(windowProxy)\n if (!childDocument) return\n childDocument.document.title = name\n spatializedElement.updateProperties({\n name,\n })\n }, [name])\n}\n\nfunction SpatializedContent<P extends ElementType>(\n props: SpatializedContentProps<SpatializedElementRef, P>,\n) {\n const { spatializedElement, ...restProps } = props\n const spatialized2DElement = spatializedElement as Spatialized2DElement\n const { windowProxy } = spatialized2DElement\n\n // Bitmap mode uses a fake WindowProxy and captures from the root WebView instead.\n const isAndroidBitmapMode = usesAndroidBitmapCapture()\n\n // Live window mode needs styles synced just like visionOS.\n useSyncHeadStyles(isAndroidBitmapMode ? null : windowProxy, {\n subtree: false,\n })\n\n const name: string = (restProps as any)['data-name'] || ''\n useSyncDocumentTitle(windowProxy, spatialized2DElement, name)\n\n const portalInstanceObject: PortalInstanceObject = useContext(\n PortalInstanceContext,\n )!\n\n if (isAndroidBitmapMode) {\n return null\n }\n\n const childDocument = ensureWindowDocumentStructure(windowProxy)\n if (!childDocument?.body) {\n return null\n }\n\n const JSXPortalInstance = getJSXPortalInstance(\n restProps,\n portalInstanceObject,\n )\n\n return createPortal(JSXPortalInstance, childDocument.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\n // Bitmap mode renders from the root WebView instead of per-element child windows.\n if (usesAndroidBitmapCapture()) {\n console.log(\n '[WebSpatial] Android: Skipping WindowProxy setup, using bitmap capture',\n )\n return spatializedElement\n }\n\n // VisionOS: Each element gets a real WKWebView, set up its styles\n setOpenWindowStyle(windowProxy)\n await syncParentHeadToChild(windowProxy)\n\n const childDocument = ensureWindowDocumentStructure(windowProxy)\n if (!childDocument) {\n return spatializedElement\n }\n\n const viewport = childDocument.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 = childDocument.document.createElement('meta')\n meta.name = 'viewport'\n meta.content = 'initial-scale=1.0, maximum-scale=1.0, user-scalable=no'\n childDocument.head.appendChild(meta)\n }\n\n return spatializedElement\n}\n\nfunction Spatialized2DElementContainerBase<P extends ElementType>(\n props: Spatialized2DElementContainerProps<P>,\n ref: ForwardedRef<SpatializedDivElementRef>,\n) {\n return (\n <SpatializedContainer<SpatializedElementRef>\n ref={ref as any}\n createSpatializedElement={createSpatializedElement}\n getExtraSpatializedElementProperties={\n getExtraSpatializedElementProperties\n }\n spatializedContent={SpatializedContent}\n {...props}\n />\n )\n}\n\nexport const Spatialized2DElementContainer = forwardRef(\n Spatialized2DElementContainerBase,\n) as <P extends ElementType>(\n props: Spatialized2DElementContainerProps<P> & {\n ref: ForwardedRef<SpatializedElementRef>\n },\n) => React.ReactElement | null\n","export function ensureWindowDocumentStructure(openedWindow: WindowProxy) {\n try {\n const { document } = openedWindow\n let documentElement = document.documentElement\n if (!documentElement) {\n documentElement = document.createElement('html')\n document.appendChild(documentElement)\n }\n\n let head = document.head\n if (!head) {\n head = document.createElement('head') as HTMLHeadElement\n if (documentElement.firstChild) {\n documentElement.insertBefore(head, documentElement.firstChild)\n } else {\n documentElement.appendChild(head)\n }\n }\n\n let body = document.body\n if (!body) {\n body = document.createElement('body') as HTMLBodyElement\n documentElement.appendChild(body)\n }\n\n return {\n document,\n documentElement,\n head,\n body,\n }\n } catch (error) {\n console.warn(\n '[WebSpatial] Failed to ensure child window document structure',\n error,\n )\n return null\n }\n}\n\nexport function asyncLoadStyleToChildWindow(\n childWindow: WindowProxy,\n link: HTMLLinkElement,\n isCurrent: () => boolean,\n): Promise<boolean> {\n return new Promise(resolve => {\n const { href } = link\n const sep = href.includes('?') ? '&' : '?'\n link.href = `${href}${sep}uniqueURL=${Math.random()}`\n\n let finished = false\n const finish = (ok: boolean) => {\n if (finished) return\n finished = true\n resolve(ok)\n }\n\n // need to wait for some time to make sure the style is loaded\n // otherwise, the style may not be applied\n link.onerror = () => {\n finish(false)\n }\n link.onload = () => {\n if (!isCurrent()) {\n link.parentNode?.removeChild(link)\n finish(false)\n return\n }\n finish(true)\n }\n\n setTimeout(() => {\n if (!isCurrent()) {\n finish(false)\n return\n }\n const childDocument = ensureWindowDocumentStructure(childWindow)\n if (!childDocument) {\n finish(false)\n return\n }\n childDocument.head.appendChild(link)\n }, 50)\n })\n}\n\nconst WEBSPATIAL_SYNC_ATTR = 'data-webspatial-sync'\nconst WEBSPATIAL_SYNC_KEY_ATTR = 'data-webspatial-sync-key'\n\nexport function setOpenWindowStyle(openedWindow: WindowProxy) {\n const childDocument = ensureWindowDocumentStructure(openedWindow)\n if (!childDocument) return\n\n childDocument.documentElement.style.cssText +=\n document.documentElement.style.cssText\n childDocument.documentElement.style.backgroundColor = 'transparent'\n childDocument.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 childDocument.body.style.display = 'inline-block'\n childDocument.body.style.minWidth = 'auto'\n childDocument.body.style.minHeight = 'auto'\n childDocument.body.style.maxWidth = 'fit-content'\n childDocument.body.style.minWidth = 'fit-content'\n childDocument.body.style.background = 'transparent'\n}\n\ninterface SyncController {\n version: number\n}\n\nconst controllers = new WeakMap<WindowProxy, SyncController>()\n\nfunction getController(childWindow: WindowProxy): SyncController {\n const prev = controllers.get(childWindow)\n if (prev) return prev\n const next: SyncController = { version: 0 }\n controllers.set(childWindow, next)\n return next\n}\n\nexport async function syncParentHeadToChild(childWindow: WindowProxy) {\n const controller = getController(childWindow)\n const version = ++controller.version\n const styleLoadedPromises: Promise<boolean>[] = []\n const childDocument = ensureWindowDocumentStructure(childWindow)\n if (!childDocument) {\n return []\n }\n const { head } = childDocument\n\n const isCurrent = () => controller.version === version\n\n const parentStyles = Array.from(document.head.querySelectorAll('style'))\n const parentStylesheets = Array.from(\n document.head.querySelectorAll('link[rel=\"stylesheet\"][href]'),\n ) as HTMLLinkElement[]\n\n const desiredStylesheetKeys = new Set<string>()\n for (const link of parentStylesheets) {\n if (link.href) desiredStylesheetKeys.add(link.href)\n }\n\n const existingSyncedLinks = Array.from(\n head.querySelectorAll(\n `link[rel=\"stylesheet\"][${WEBSPATIAL_SYNC_ATTR}=\"1\"]`,\n ),\n ) as HTMLLinkElement[]\n for (const link of existingSyncedLinks) {\n const key = link.getAttribute(WEBSPATIAL_SYNC_KEY_ATTR) ?? link.href\n if (!desiredStylesheetKeys.has(key)) link.parentNode?.removeChild(link)\n }\n\n const prevSyncedStyles = head.querySelectorAll(\n `style[${WEBSPATIAL_SYNC_ATTR}=\"1\"]`,\n )\n prevSyncedStyles.forEach(n => n.parentNode?.removeChild(n))\n\n for (const styleEl of parentStyles) {\n const node = styleEl.cloneNode(true) as HTMLStyleElement\n node.setAttribute(WEBSPATIAL_SYNC_ATTR, '1')\n head.appendChild(node)\n }\n\n const currentKeys = new Set<string>()\n const currentSyncedLinks = Array.from(\n head.querySelectorAll(\n `link[rel=\"stylesheet\"][${WEBSPATIAL_SYNC_ATTR}=\"1\"]`,\n ),\n ) as HTMLLinkElement[]\n for (const link of currentSyncedLinks) {\n currentKeys.add(link.getAttribute(WEBSPATIAL_SYNC_KEY_ATTR) ?? link.href)\n }\n\n for (const link of parentStylesheets) {\n const key = link.href\n if (!key || currentKeys.has(key)) continue\n const node = link.cloneNode(true) as HTMLLinkElement\n node.setAttribute(WEBSPATIAL_SYNC_ATTR, '1')\n node.setAttribute(WEBSPATIAL_SYNC_KEY_ATTR, key)\n styleLoadedPromises.push(\n asyncLoadStyleToChildWindow(childWindow, node, isCurrent),\n )\n }\n\n // sync className\n childDocument.documentElement.className = document.documentElement.className\n\n return Promise.all(styleLoadedPromises)\n}\n","import { useEffect } from 'react'\r\n\r\nimport { syncParentHeadToChild } from './windowStyleSync'\r\n\r\ninterface Options {\r\n subtree?: boolean\r\n immediate?: boolean\r\n}\r\n\r\nfunction defaultShouldSync(mutations?: MutationRecord[] | null) {\r\n if (!Array.isArray(mutations) || mutations.length === 0) return false\r\n for (const mutation of mutations) {\r\n const nodes: Node[] = [\r\n ...Array.from(mutation.addedNodes),\r\n ...Array.from(mutation.removedNodes),\r\n ]\r\n for (const node of nodes) {\r\n if (!(node instanceof Element)) continue\r\n const tag = node.tagName\r\n if (tag === 'STYLE') return true\r\n if (tag === 'LINK') {\r\n const { rel } = node as HTMLLinkElement\r\n if (rel && rel.toLowerCase() === 'stylesheet') return true\r\n }\r\n }\r\n }\r\n return false\r\n}\r\n\r\nexport function useSyncHeadStyles(\r\n childWindow: WindowProxy | null | undefined,\r\n options?: Options,\r\n) {\r\n const delayMs = 100\r\n const subtree = options?.subtree ?? false\r\n const immediate = options?.immediate ?? true\r\n\r\n useEffect(() => {\r\n if (!childWindow) return\r\n\r\n let timer: number | undefined\r\n const scheduleSync = () => {\r\n if (timer) window.clearTimeout(timer)\r\n timer = window.setTimeout(() => {\r\n syncParentHeadToChild(childWindow)\r\n }, delayMs)\r\n }\r\n\r\n if (immediate) scheduleSync()\r\n\r\n const observer = new MutationObserver(mutations => {\r\n if (!defaultShouldSync(mutations)) return\r\n scheduleSync()\r\n })\r\n observer.observe(document.head, { childList: true, subtree })\r\n\r\n return () => {\r\n if (timer) window.clearTimeout(timer)\r\n observer.disconnect()\r\n }\r\n }, [childWindow, delayMs, subtree, immediate])\r\n}\r\n","import {\r\n ForwardedRef,\r\n forwardRef,\r\n useCallback,\r\n useContext,\r\n useEffect,\r\n useMemo,\r\n useRef,\r\n} from 'react'\r\nimport { SpatializedContainer } from './SpatializedContainer'\r\nimport { getSession } from '../utils'\r\nimport {\r\n ModelLoadEvent,\r\n SpatializedStatic3DContainerProps,\r\n SpatializedStatic3DContentProps,\r\n SpatializedStatic3DElementRef,\r\n} from './types'\r\nimport { SpatializedStatic3DElement } from '@webspatial/core-sdk'\r\nimport {\r\n PortalInstanceObject,\r\n PortalInstanceContext,\r\n} from './context/PortalInstanceContext'\r\n\r\nfunction getAbsoluteURL(url?: string) {\r\n if (!url) {\r\n return ''\r\n }\r\n try {\r\n return new URL(url, document.baseURI).toString()\r\n } catch {\r\n return url\r\n }\r\n}\r\n\r\nfunction createLoadEvent(\r\n type: string,\r\n targetGetter: () => SpatializedStatic3DElementRef,\r\n): ModelLoadEvent {\r\n const event = new CustomEvent(type, {\r\n bubbles: false,\r\n cancelable: false,\r\n })\r\n const proxyEvent = new Proxy(event, {\r\n get(target, prop) {\r\n if (prop === 'target') {\r\n return targetGetter()\r\n }\r\n return Reflect.get(target, prop)\r\n },\r\n })\r\n return proxyEvent as ModelLoadEvent\r\n}\r\n\r\nfunction createLoadFailureEvent(\r\n targetGetter: () => SpatializedStatic3DElementRef,\r\n): ModelLoadEvent {\r\n return createLoadEvent('modelloadfailed', targetGetter)\r\n}\r\n\r\nfunction createLoadSuccessEvent(\r\n targetGetter: () => SpatializedStatic3DElementRef,\r\n): ModelLoadEvent {\r\n return createLoadEvent('modelloaded', targetGetter)\r\n}\r\n\r\nfunction SpatializedContent(props: SpatializedStatic3DContentProps) {\r\n const { src, spatializedElement, onLoad, onError } = props\r\n const spatializedStatic3DElement =\r\n spatializedElement as SpatializedStatic3DElement\r\n\r\n const portalInstanceObject: PortalInstanceObject = useContext(\r\n PortalInstanceContext,\r\n )!\r\n\r\n const currentSrc: string = useMemo(() => getAbsoluteURL(src), [src])\r\n\r\n useEffect(() => {\r\n if (src) {\r\n spatializedStatic3DElement.updateProperties({ modelURL: currentSrc })\r\n }\r\n }, [currentSrc])\r\n\r\n useEffect(() => {\r\n if (onLoad) {\r\n spatializedStatic3DElement.onLoadCallback = () => {\r\n onLoad(\r\n createLoadSuccessEvent(\r\n () => (portalInstanceObject.dom as any).__targetProxy,\r\n ),\r\n )\r\n }\r\n } else {\r\n spatializedStatic3DElement.onLoadCallback = undefined\r\n }\r\n }, [onLoad])\r\n\r\n useEffect(() => {\r\n if (onError) {\r\n spatializedStatic3DElement.onLoadFailureCallback = () => {\r\n onError(\r\n createLoadFailureEvent(\r\n () => (portalInstanceObject.dom as any).__targetProxy,\r\n ),\r\n )\r\n }\r\n } else {\r\n spatializedStatic3DElement.onLoadFailureCallback = undefined\r\n }\r\n }, [onError])\r\n\r\n return <></>\r\n}\r\n\r\nfunction SpatializedStatic3DElementContainerBase(\r\n props: SpatializedStatic3DContainerProps,\r\n ref: ForwardedRef<SpatializedStatic3DElementRef>,\r\n) {\r\n const promiseRef = useRef<Promise<SpatializedStatic3DElement> | null>(null)\r\n\r\n const createSpatializedElement = useCallback(() => {\r\n const url = getAbsoluteURL(props.src)\r\n promiseRef.current = getSession()!.createSpatializedStatic3DElement(url)\r\n return promiseRef.current\r\n }, [])\r\n const extraRefProps = useCallback(\r\n (domProxy: SpatializedStatic3DElementRef) => {\r\n let modelTransform = new DOMMatrixReadOnly()\r\n\r\n return {\r\n get currentSrc(): string {\r\n return getAbsoluteURL(props.src)\r\n },\r\n get ready(): Promise<ModelLoadEvent> {\r\n return promiseRef\r\n .current!.then(spatializedElement => spatializedElement.ready)\r\n .then(success => {\r\n if (success) return createLoadSuccessEvent(() => domProxy)\r\n throw createLoadFailureEvent(() => domProxy)\r\n })\r\n },\r\n get entityTransform(): DOMMatrixReadOnly {\r\n return modelTransform\r\n },\r\n set entityTransform(value: DOMMatrixReadOnly) {\r\n modelTransform = value\r\n const spatializedElement = (domProxy as any).__spatializedElement as\r\n | SpatializedStatic3DElement\r\n | undefined\r\n spatializedElement?.updateModelTransform(modelTransform)\r\n },\r\n }\r\n },\r\n [],\r\n )\r\n\r\n return (\r\n <SpatializedContainer<SpatializedStatic3DElementRef>\r\n ref={ref}\r\n component=\"div\"\r\n createSpatializedElement={createSpatializedElement}\r\n spatializedContent={SpatializedContent}\r\n extraRefProps={extraRefProps}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\nexport const SpatializedStatic3DElementContainer = forwardRef(\r\n SpatializedStatic3DElementContainerBase,\r\n)\r\n","import { ElementType, ForwardedRef, forwardRef } from 'react'\r\nimport { Spatialized2DElementContainer } from './Spatialized2DElementContainer'\r\nimport {\r\n Spatialized2DElementContainerProps,\r\n SpatializedElementRef,\r\n} from './types'\r\n\r\nconst CachedSpatialized2DElementContainerType = new Map()\r\n\r\nexport function withSpatialized2DElementContainer<P extends ElementType>(\r\n Component: P,\r\n) {\r\n if (CachedSpatialized2DElementContainerType.has(Component)) {\r\n return CachedSpatialized2DElementContainerType.get(Component) as P\r\n } else {\r\n const TypedSpatialized2DElementContainer = forwardRef(\r\n (\r\n givenProps: Spatialized2DElementContainerProps<P>,\r\n ref: ForwardedRef<SpatializedElementRef>,\r\n ) => {\r\n const { component: ignoreComponent, ...props } = givenProps\r\n return (\r\n <Spatialized2DElementContainer<P>\r\n component={Component}\r\n {...props}\r\n ref={ref as any}\r\n />\r\n )\r\n },\r\n )\r\n\r\n CachedSpatialized2DElementContainerType.set(\r\n Component,\r\n TypedSpatialized2DElementContainer,\r\n )\r\n CachedSpatialized2DElementContainerType.set(\r\n TypedSpatialized2DElementContainer,\r\n TypedSpatialized2DElementContainer,\r\n )\r\n return TypedSpatialized2DElementContainer\r\n }\r\n}\r\n","import { hijackGetComputedStyle } from './hooks/useDomProxy'\r\nimport { injectSpatialDefaultStyle } from './StandardSpatializedContainer'\r\nimport { initCSSParserDivContainer } from './TransformVisibilityTaskContainer'\r\n\r\nexport { SpatializedContainer } from './SpatializedContainer'\r\nexport { Spatialized2DElementContainer } from './Spatialized2DElementContainer'\r\nexport { SpatializedStatic3DElementContainer } from './SpatializedStatic3DElementContainer'\r\nexport { withSpatialized2DElementContainer } from './Spatialized2DElementContainerFactory'\r\nexport {\r\n type Point3D,\r\n type Vec3,\r\n type SpatializedElementRef,\r\n type SpatialTapEvent,\r\n type SpatialDragStartEvent,\r\n type SpatialDragEvent,\r\n type SpatialDragEndEvent,\r\n type SpatialRotateEvent,\r\n type SpatialRotateEndEvent,\r\n type SpatialMagnifyEvent,\r\n type SpatialMagnifyEndEvent,\r\n type SpatializedStatic3DContainerProps,\r\n type Spatialized2DElementContainerProps,\r\n type SpatializedStatic3DElementRef,\r\n type ModelSpatialTapEvent,\r\n type ModelSpatialDragStartEvent,\r\n type ModelSpatialDragEvent,\r\n type ModelSpatialDragEndEvent,\r\n type ModelSpatialRotateEvent,\r\n type ModelSpatialRotateEndEvent,\r\n type ModelSpatialMagnifyEvent,\r\n type ModelSpatialMagnifyEndEvent,\r\n type ModelLoadEvent,\r\n} from './types'\r\n\r\nexport { toSceneSpatial, toLocalSpace } from './transform-utils'\r\n\r\nexport function initPolyfill() {\r\n hijackGetComputedStyle()\r\n injectSpatialDefaultStyle()\r\n initCSSParserDivContainer()\r\n}\r\n","import type { SpatialSceneCreationOptions } from '@webspatial/core-sdk'\r\n\r\nexport function initScene(\r\n name: string,\r\n callback: (pre: SpatialSceneCreationOptions) => SpatialSceneCreationOptions,\r\n) {\r\n return\r\n}\r\n","import React, { forwardRef, Ref } from 'react'\r\nimport { SpatialMonitor } from './SpatialMonitor'\r\n\r\nconst cachedWithSpatialMonitorType = new Map()\r\n\r\nexport function withSpatialMonitor(El: React.ElementType) {\r\n if (cachedWithSpatialMonitorType.has(El)) {\r\n return cachedWithSpatialMonitorType.get(El)\r\n } else {\r\n const WithSpatialMonitorComponent = forwardRef(\r\n (givenProps: any, givenRef: Ref<any>) => {\r\n const {\r\n El: _,\r\n\r\n ...props\r\n } = givenProps\r\n\r\n return <SpatialMonitor El={El} {...props} ref={givenRef} />\r\n },\r\n )\r\n WithSpatialMonitorComponent.displayName = `WithSpatialMonitor(${typeof El === 'string' ? El : El.displayName || El.name})`\r\n\r\n cachedWithSpatialMonitorType.set(El, WithSpatialMonitorComponent)\r\n cachedWithSpatialMonitorType.set(\r\n cachedWithSpatialMonitorType,\r\n cachedWithSpatialMonitorType,\r\n )\r\n return WithSpatialMonitorComponent\r\n }\r\n}\r\n","import { useRef, useEffect, ForwardedRef, useMemo } from 'react'\r\nimport { notifyDOMUpdate } from '../notifyUpdateStandInstanceLayout'\r\n\r\nexport function useMonitorDomChange(inRef: ForwardedRef<HTMLElement>) {\r\n const ref = useRef<HTMLElement>(null)\r\n\r\n useEffect(() => {\r\n const observer = new MutationObserver(mutationsList => {\r\n notifyDOMUpdate(mutationsList)\r\n })\r\n\r\n const config = {\r\n childList: true,\r\n subtree: true,\r\n attributes: true,\r\n attributeFilter: ['style', 'class'],\r\n }\r\n\r\n ref.current && observer.observe(ref.current, config)\r\n\r\n return () => {\r\n observer.disconnect()\r\n }\r\n }, [])\r\n\r\n const proxyRef = useMemo(\r\n () =>\r\n new Proxy(ref, {\r\n set: function (target, key, value) {\r\n if (key === 'current') {\r\n if (inRef) {\r\n if (typeof inRef === 'function') {\r\n inRef(value)\r\n } else if (inRef) {\r\n inRef.current = value\r\n }\r\n }\r\n }\r\n return Reflect.set(target, key, value)\r\n },\r\n }),\r\n [],\r\n )\r\n\r\n return proxyRef\r\n}\r\n","import { useEffect } from 'react'\r\nimport { notifyUpdateStandInstanceLayout } from '../notifyUpdateStandInstanceLayout'\r\n\r\nexport function useMonitorDocumentHeaderChange() {\r\n useEffect(() => {\r\n const observer = new MutationObserver(mutationsList => {\r\n notifyUpdateStandInstanceLayout()\r\n })\r\n\r\n const config = {\r\n childList: true,\r\n subtree: true,\r\n attributes: true,\r\n }\r\n\r\n observer.observe(document.head, config)\r\n\r\n return () => {\r\n observer.disconnect()\r\n }\r\n }, [])\r\n}\r\n","import { useMonitorDomChange } from './useMonitorDomChange'\r\nimport { useMonitorDocumentHeaderChange } from './useMonitorDocumentHeaderChange'\r\nimport { ElementType, ForwardedRef, forwardRef } from 'react'\r\n\r\ntype SpatialMonitorProps = {\r\n El?: ElementType\r\n}\r\n\r\n/**\r\n * Component that add MutationObserver to monitor all dom changes including its children.\r\n * If any dom changes, it will notify all SpatialDiv to render again for the purpose of sync standInstance layout to portalInstance.\r\n */\r\nfunction SpatialMonitorBase(\r\n inProps: SpatialMonitorProps,\r\n inRef: ForwardedRef<HTMLElement>,\r\n) {\r\n const { El = 'div', ...props } = inProps\r\n const ref = useMonitorDomChange(inRef)\r\n useMonitorDocumentHeaderChange()\r\n\r\n return <El {...props} ref={ref} />\r\n}\r\n\r\nexport const SpatialMonitor = forwardRef(SpatialMonitorBase)\r\n","import React, { forwardRef } from 'react'\r\nimport { EntityProps, EntityEventHandler } from '../type'\r\nimport { EntityRefShape } from '../hooks'\r\nimport { BaseEntity } from './BaseEntity'\r\n\r\ntype Props = EntityProps & EntityEventHandler & { children?: React.ReactNode }\r\n\r\nexport const Entity = forwardRef<EntityRefShape, Props>((props, ref) => {\r\n const { id, name, children, ...rest } = props\r\n return (\r\n <BaseEntity\r\n {...rest}\r\n id={id}\r\n ref={ref}\r\n createEntity={async ctxVal => ctxVal!.session.createEntity({ id, name })}\r\n >\r\n {children}\r\n </BaseEntity>\r\n )\r\n})\r\n","import React, { forwardRef } from 'react'\r\nimport { SpatialEntity } from '@webspatial/core-sdk'\r\nimport {\r\n ParentContext,\r\n RealityContextValue,\r\n useRealityContext,\r\n} from '../context'\r\nimport { EntityProps, EntityEventHandler } from '../type'\r\nimport { EntityRefShape, useEntity } from '../hooks'\r\n\r\ntype BaseEntityProps = EntityProps &\r\n EntityEventHandler & {\r\n children?: React.ReactNode\r\n createEntity: (\r\n ctx: RealityContextValue,\r\n signal: AbortSignal,\r\n ) => Promise<SpatialEntity>\r\n }\r\n\r\nexport const BaseEntity = forwardRef<EntityRefShape, BaseEntityProps>(\r\n ({ children, createEntity, ...rest }, ref) => {\r\n const ctx = useRealityContext()\r\n const entity = useEntity({\r\n ...rest,\r\n ref,\r\n createEntity: (signal: AbortSignal) => createEntity(ctx, signal),\r\n })\r\n\r\n if (!entity) return null\r\n return (\r\n <ParentContext.Provider value={entity}>{children}</ParentContext.Provider>\r\n )\r\n },\r\n)\r\n","import {\r\n SpatializedDynamic3DElement,\r\n SpatialSession,\r\n} from '@webspatial/core-sdk'\r\nimport { createContext, useContext } from 'react'\r\nimport { ResourceRegistry } from '../utils'\r\nimport { AttachmentRegistry } from './AttachmentContext'\r\n\r\nexport type RealityContextValue = {\r\n session: SpatialSession\r\n reality: SpatializedDynamic3DElement\r\n resourceRegistry: ResourceRegistry\r\n attachmentRegistry: AttachmentRegistry\r\n} | null\r\nexport const RealityContext = createContext<RealityContextValue>(null)\r\nexport const useRealityContext = () => useContext(RealityContext)\r\n","import { SpatialEntity } from '@webspatial/core-sdk'\r\nimport { createContext, useContext } from 'react'\r\n\r\nexport const ParentContext = createContext<SpatialEntity | null>(null)\r\nexport const useParentContext = () => useContext(ParentContext)\r\n","import { createContext, useContext } from 'react'\r\n\r\ntype ContainersChangeCallback = (containers: HTMLElement[]) => void\r\n\r\nexport class AttachmentRegistry {\r\n // name → (instanceId → container)\r\n private containers = new Map<string, Map<string, HTMLElement>>()\r\n private listeners = new Map<string, ContainersChangeCallback>()\r\n\r\n addContainer(name: string, instanceId: string, container: HTMLElement) {\r\n if (!this.containers.has(name)) {\r\n this.containers.set(name, new Map())\r\n }\r\n this.containers.get(name)!.set(instanceId, container)\r\n this.notifyListeners(name)\r\n }\r\n\r\n removeContainer(name: string, instanceId: string) {\r\n this.containers.get(name)?.delete(instanceId)\r\n if (this.containers.get(name)?.size === 0) {\r\n this.containers.delete(name)\r\n }\r\n this.notifyListeners(name)\r\n }\r\n\r\n getContainers(name: string): HTMLElement[] {\r\n const map = this.containers.get(name)\r\n return map ? Array.from(map.values()) : []\r\n }\r\n\r\n onContainersChange(name: string, cb: ContainersChangeCallback): () => void {\r\n const current = this.getContainers(name)\r\n if (current.length > 0) {\r\n cb(current)\r\n }\r\n const prev = this.listeners.get(name)\r\n if (prev) prev([])\r\n this.listeners.set(name, cb)\r\n return () => {\r\n if (this.listeners.get(name) === cb) {\r\n this.listeners.delete(name)\r\n }\r\n }\r\n }\r\n\r\n private notifyListeners(name: string) {\r\n const cs = this.getContainers(name)\r\n this.listeners.get(name)?.(cs)\r\n }\r\n\r\n destroy() {\r\n this.containers.clear()\r\n this.listeners.clear()\r\n }\r\n}\r\n\r\nexport const AttachmentContext = createContext<AttachmentRegistry | null>(null)\r\nexport const useAttachmentContext = () => useContext(AttachmentContext)\r\n","import { SpatialEntity } from '@webspatial/core-sdk'\r\nimport { useEffect, useRef } from 'react'\r\nimport { EntityProps } from '../type'\r\nimport { shallowEqualRotation, shallowEqualVec3 } from '../utils'\r\n\r\nexport function useEntityTransform(\r\n entity: SpatialEntity | null,\r\n { position, rotation, scale }: EntityProps,\r\n) {\r\n const last = useRef<{ position?: any; rotation?: any; scale?: any }>({})\r\n\r\n useEffect(() => {\r\n if (!entity) return\r\n\r\n const shouldUpdate =\r\n !shallowEqualVec3(last.current.position, position) ||\r\n !shallowEqualRotation(last.current.rotation, rotation) ||\r\n !shallowEqualVec3(last.current.scale, scale)\r\n\r\n if (!shouldUpdate) return\r\n\r\n last.current = { position, rotation, scale }\r\n\r\n const updateTransform = async () => {\r\n try {\r\n await entity.updateTransform({ position, rotation, scale })\r\n } catch (err) {\r\n console.error('[useEntityTransform] Failed to update transform:', err)\r\n }\r\n }\r\n\r\n updateTransform()\r\n\r\n return () => {}\r\n }, [entity, position, rotation, scale])\r\n}\r\n","import {\r\n SpatializedDynamic3DElement,\r\n SpatialObject,\r\n SpatialSession,\r\n} from '@webspatial/core-sdk'\r\nexport class ResourceRegistry {\r\n private resources: Map<string, Promise<SpatialObject>> = new Map()\r\n add<T extends SpatialObject>(id: string, resource: Promise<T>) {\r\n this.resources.set(id, resource)\r\n }\r\n remove(id: string) {\r\n this.resources.delete(id)\r\n }\r\n\r\n // Remove the resource by id and destroy it once resolved\r\n // This does not cancel in-flight creation; it schedules destruction after resolution\r\n removeAndDestroy(id: string) {\r\n const p = this.resources.get(id)\r\n if (p) {\r\n // Schedule destruction when the resource becomes available\r\n p.then(spatialObj => spatialObj.destroy()).catch(() => {\r\n // swallow rejection to avoid unhandled promise errors during teardown\r\n })\r\n }\r\n this.resources.delete(id)\r\n }\r\n get<T extends SpatialObject>(id: string) {\r\n return this.resources.get(id) as Promise<T>\r\n }\r\n destroy() {\r\n // Collect pending resources and clear registry immediately\r\n const pending = Array.from(this.resources.values())\r\n this.resources.clear()\r\n\r\n // Best-effort destroy for all resolved and future-resolving resources\r\n pending.forEach(promise =>\r\n promise\r\n .then(spatialObj => spatialObj.destroy())\r\n .catch(() => {\r\n // swallow rejection to avoid unhandled promise errors during teardown\r\n }),\r\n )\r\n }\r\n}\r\n","export function shallowEqualVec3(\r\n a?: { x: number; y: number; z: number },\r\n b?: { x: number; y: number; z: number },\r\n) {\r\n if (a === b) return true\r\n if (!a || !b) return false\r\n return a.x === b.x && a.y === b.y && a.z === b.z\r\n}\r\n\r\nexport function shallowEqualRotation(a?: any, b?: any) {\r\n if (a === b) return true\r\n if (!a || !b) return false\r\n // support Vec3 / Vec4\r\n return (\r\n a.x === b.x && a.y === b.y && a.z === b.z && ('w' in a ? a.w === b.w : true)\r\n )\r\n}\r\n","export class AbortResourceManager {\r\n private resources: { destroy: () => Promise<void> | void }[] = []\r\n private aborted = false\r\n\r\n constructor(private signal: AbortSignal) {\r\n signal.addEventListener('abort', () => {\r\n this.aborted = true\r\n void this.dispose()\r\n })\r\n }\r\n\r\n async addResource<T extends { destroy: () => Promise<void> | void }>(\r\n factory: () => Promise<T>,\r\n ): Promise<T> {\r\n if (this.aborted) throw new DOMException('Aborted', 'AbortError')\r\n const resource = await factory()\r\n if (this.aborted) {\r\n await resource.destroy()\r\n throw new DOMException('Aborted', 'AbortError')\r\n }\r\n this.resources.push(resource)\r\n return resource\r\n }\r\n\r\n async dispose() {\r\n const resources = this.resources.splice(0)\r\n for (const r of resources) {\r\n try {\r\n await r.destroy()\r\n } catch (e) {\r\n console.error('AbortResourceManager dispose error:', e, r)\r\n }\r\n }\r\n }\r\n}\r\n","import React, { useEffect, useRef } from 'react'\r\nimport {\r\n EntityEventHandler,\r\n eventMap,\r\n SpatialDragEntityEvent,\r\n SpatialMagnifyEntityEvent,\r\n SpatialRotateEntityEvent,\r\n SpatialDragStartEntityEvent,\r\n SpatialTapEntityEvent,\r\n} from '../type'\r\nimport { EntityRef } from './useEntityRef'\r\nimport { SpatialEntity } from '@webspatial/core-sdk'\r\n\r\nfunction createEventProxy(ev: any, instance: EntityRef) {\r\n return new Proxy(ev, {\r\n get(target, prop: PropertyKey) {\r\n // Align with W3C: currentTarget is the listener owner\r\n if (prop === 'currentTarget') {\r\n return instance\r\n }\r\n // Align with W3C: target is the original dispatch target\r\n if (prop === 'target') {\r\n const origin = (target as any).__origin as SpatialEntity | undefined\r\n if (origin) {\r\n // Create a lightweight EntityRef for original target\r\n return new EntityRef(origin, null)\r\n }\r\n // Fallback: if origin not set, return current instance\r\n return instance\r\n }\r\n if (prop === 'bubbles') {\r\n return true\r\n }\r\n if (prop === 'offsetX') {\r\n const type = (target as any).type\r\n if (type === 'spatialtap') {\r\n return (target as SpatialTapEntityEvent).detail?.location3D?.x ?? 0\r\n }\r\n if (type === 'spatialdragstart') {\r\n return (\r\n (target as SpatialDragStartEntityEvent).detail?.startLocation3D\r\n ?.x ?? 0\r\n )\r\n }\r\n return undefined\r\n }\r\n if (prop === 'offsetY') {\r\n const type = (target as any).type\r\n if (type === 'spatialtap') {\r\n return (target as SpatialTapEntityEvent).detail?.location3D?.y ?? 0\r\n }\r\n if (type === 'spatialdragstart') {\r\n return (\r\n (target as SpatialDragStartEntityEvent).detail?.startLocation3D\r\n ?.y ?? 0\r\n )\r\n }\r\n return undefined\r\n }\r\n if (prop === 'offsetZ') {\r\n const type = (target as any).type\r\n if (type === 'spatialtap') {\r\n return (target as any).detail?.location3D?.z ?? 0\r\n }\r\n if (type === 'spatialdragstart') {\r\n return (target as any).detail?.startLocation3D?.z ?? 0\r\n }\r\n return undefined\r\n }\r\n if (prop === 'translationX') {\r\n const type = (target as any).type\r\n if (type === 'spatialdrag') {\r\n return (\r\n (target as SpatialDragEntityEvent).detail?.translation3D?.x ?? 0\r\n )\r\n }\r\n return undefined\r\n }\r\n if (prop === 'translationY') {\r\n const type = (target as any).type\r\n if (type === 'spatialdrag') {\r\n return (\r\n (target as SpatialDragEntityEvent).detail?.translation3D?.y ?? 0\r\n )\r\n }\r\n return undefined\r\n }\r\n if (prop === 'translationZ') {\r\n const type = (target as any).type\r\n if (type === 'spatialdrag') {\r\n return (\r\n (target as SpatialDragEntityEvent).detail?.translation3D?.z ?? 0\r\n )\r\n }\r\n return undefined\r\n }\r\n if (prop === 'quaternion') {\r\n const type = (target as any).type\r\n if (type === 'spatialrotate') {\r\n return (\r\n (target as SpatialRotateEntityEvent).detail?.quaternion ?? {\r\n x: 0,\r\n y: 0,\r\n z: 0,\r\n w: 1,\r\n }\r\n )\r\n }\r\n return undefined\r\n }\r\n if (prop === 'magnification') {\r\n const type = (target as any).type\r\n if (type === 'spatialmagnify') {\r\n return (\r\n (target as SpatialMagnifyEntityEvent).detail?.magnification ?? 1\r\n )\r\n }\r\n return undefined\r\n }\r\n if (prop === 'clientX') {\r\n const type = (target as any).type\r\n if (type === 'spatialtap' || type === 'spatialdragstart') {\r\n return (\r\n (target as SpatialTapEntityEvent).detail?.globalLocation3D?.x ?? 0\r\n )\r\n }\r\n\r\n return undefined\r\n }\r\n if (prop === 'clientY') {\r\n const type = (target as any).type\r\n if (type === 'spatialtap' || type === 'spatialdragstart') {\r\n return (\r\n (target as SpatialTapEntityEvent).detail?.globalLocation3D?.y ?? 0\r\n )\r\n }\r\n\r\n return undefined\r\n }\r\n if (prop === 'clientZ') {\r\n const type = (target as any).type\r\n if (type === 'spatialtap' || type === 'spatialdragstart') {\r\n return (\r\n (target as SpatialTapEntityEvent).detail?.globalLocation3D?.z ?? 0\r\n )\r\n }\r\n\r\n return undefined\r\n }\r\n const val = (target as any)[prop]\r\n return typeof val === 'function' ? val.bind(target) : val\r\n },\r\n })\r\n}\r\n\r\ntype Props = {\r\n instance: EntityRef\r\n} & EntityEventHandler\r\nexport const useEntityEvent: React.FC<Props> = ({ instance, ...handlers }) => {\r\n const eventsSetRef = useRef<Set<string>>(new Set())\r\n\r\n useEffect(() => {\r\n const entity = instance.entity\r\n if (!entity) return\r\n\r\n Object.entries(eventMap).forEach(([reactKey, spatialEvent]) => {\r\n // add/update handler\r\n const handlerFn = (handlers as any)[reactKey]\r\n if (!handlerFn) return\r\n const wrapped = (ev: any) => handlerFn(createEventProxy(ev, instance))\r\n entity.addEvent(spatialEvent as any, wrapped)\r\n eventsSetRef.current.add(reactKey)\r\n })\r\n return () => {}\r\n }, [instance.entity, ...Object.values(handlers)])\r\n\r\n useEffect(() => {\r\n const entity = instance.entity\r\n if (!entity) return\r\n\r\n return () => {\r\n // remove all\r\n for (let x of eventsSetRef.current) {\r\n entity.removeEvent(x as any)\r\n }\r\n eventsSetRef.current.clear()\r\n }\r\n }, [instance.entity])\r\n\r\n return null\r\n}\r\n","import type { Quaternion, Vec3 } from '@webspatial/core-sdk'\r\nimport { EntityRefShape } from './hooks'\r\nimport { SpatialTapEvent as CoreSpatialTapEvent } from '@webspatial/core-sdk'\r\nimport { SpatialDragStartEvent as CoreSpatialDragStartEvent } from '@webspatial/core-sdk'\r\nimport { SpatialDragEvent as CoreSpatialDragEvent } from '@webspatial/core-sdk'\r\nimport { SpatialDragEndEvent as CoreSpatialDragEndEvent } from '@webspatial/core-sdk'\r\nimport { SpatialRotateEvent as CoreSpatialRotateEvent } from '@webspatial/core-sdk'\r\nimport { SpatialRotateEndEvent as CoreSpatialRotateEndEvent } from '@webspatial/core-sdk'\r\nimport { SpatialMagnifyEvent as CoreSpatialMagnifyEvent } from '@webspatial/core-sdk'\r\nimport { SpatialMagnifyEndEvent as CoreSpatialMagnifyEndEvent } from '@webspatial/core-sdk'\r\n\r\nexport type EntityProps = {\r\n id?: string\r\n name?: string\r\n position?: Vec3\r\n rotation?: Vec3\r\n scale?: Vec3\r\n}\r\n\r\ntype allTarget<T extends EntityRefShape> = {\r\n target: T\r\n currentTarget: T\r\n}\r\n// tap\r\nexport type SpatialTapEntityEvent<T extends EntityRefShape = EntityRefShape> =\r\n CoreSpatialTapEvent &\r\n allTarget<T> & {\r\n readonly offsetX: number\r\n readonly offsetY: number\r\n readonly offsetZ: number\r\n readonly clientX: number\r\n readonly clientY: number\r\n readonly clientZ: number\r\n }\r\n\r\n// drag\r\nexport type SpatialDragStartEntityEvent<\r\n T extends EntityRefShape = EntityRefShape,\r\n> = CoreSpatialDragStartEvent &\r\n allTarget<T> & {\r\n readonly offsetX: number\r\n readonly offsetY: number\r\n readonly offsetZ: number\r\n readonly clientX: number\r\n readonly clientY: number\r\n readonly clientZ: number\r\n }\r\n\r\nexport type SpatialDragEntityEvent<T extends EntityRefShape = EntityRefShape> =\r\n CoreSpatialDragEvent &\r\n allTarget<T> & {\r\n readonly translationX: number\r\n readonly translationY: number\r\n readonly translationZ: number\r\n }\r\n\r\nexport type SpatialDragEndEntityEvent<\r\n T extends EntityRefShape = EntityRefShape,\r\n> = CoreSpatialDragEndEvent & allTarget<T>\r\n// rotate\r\nexport type SpatialRotateEntityEvent<\r\n T extends EntityRefShape = EntityRefShape,\r\n> = CoreSpatialRotateEvent &\r\n allTarget<T> & {\r\n readonly quaternion: Quaternion\r\n }\r\nexport type SpatialRotateEndEntityEvent<\r\n T extends EntityRefShape = EntityRefShape,\r\n> = CoreSpatialRotateEndEvent & allTarget<T>\r\n// magnify\r\nexport type SpatialMagnifyEntityEvent<\r\n T extends EntityRefShape = EntityRefShape,\r\n> = CoreSpatialMagnifyEvent &\r\n allTarget<T> & {\r\n readonly magnification: number\r\n }\r\nexport type SpatialMagnifyEndEntityEvent<\r\n T extends EntityRefShape = EntityRefShape,\r\n> = CoreSpatialMagnifyEndEvent & allTarget<T>\r\n\r\nexport type EntityEventHandler = {\r\n // tap\r\n onSpatialTap?: (event: SpatialTapEntityEvent) => void\r\n // drag\r\n onSpatialDragStart?: (event: SpatialDragStartEntityEvent) => void\r\n onSpatialDrag?: (event: SpatialDragEntityEvent) => void\r\n onSpatialDragEnd?: (event: SpatialDragEndEntityEvent) => void\r\n // rotate\r\n onSpatialRotate?: (event: SpatialRotateEntityEvent) => void\r\n onSpatialRotateEnd?: (event: SpatialRotateEndEntityEvent) => void\r\n // magnify\r\n onSpatialMagnify?: (event: SpatialMagnifyEntityEvent) => void\r\n onSpatialMagnifyEnd?: (event: SpatialMagnifyEndEntityEvent) => void\r\n}\r\n\r\nexport const eventMap = {\r\n // tap\r\n onSpatialTap: 'spatialtap',\r\n // drag\r\n onSpatialDragStart: 'spatialdragstart',\r\n onSpatialDrag: 'spatialdrag',\r\n onSpatialDragEnd: 'spatialdragend',\r\n // rotate\r\n onSpatialRotateStart: 'spatialrotatestart',\r\n onSpatialRotate: 'spatialrotate',\r\n onSpatialRotateEnd: 'spatialrotateend',\r\n // magnify\r\n onSpatialMagnifyStart: 'spatialmagnifystart',\r\n onSpatialMagnify: 'spatialmagnify',\r\n onSpatialMagnifyEnd: 'spatialmagnifyend',\r\n} as const\r\n","import { useEffect, useImperativeHandle, useRef } from 'react'\r\nimport { Vec3, SpatialEntity } from '@webspatial/core-sdk'\r\nimport { RealityContextValue, useRealityContext } from '../context'\r\n\r\nexport interface EntityRefShape {\r\n convertFromEntityToEntity: (\r\n fromEntityId: string,\r\n toEntityId: string,\r\n position: Vec3,\r\n ) => Promise<Vec3>\r\n convertFromEntityToReality: (\r\n entityId: string,\r\n position: Vec3,\r\n ) => Promise<Vec3>\r\n convertFromRealityToEntity: (\r\n entityId: string,\r\n position: Vec3,\r\n ) => Promise<Vec3>\r\n id: string | undefined\r\n name: string | undefined\r\n entity: SpatialEntity | null\r\n}\r\n\r\nexport const useEntityRef = (\r\n ref: React.Ref<EntityRefShape>,\r\n instance: EntityRef,\r\n) => {\r\n useImperativeHandle(ref, () => instance)\r\n}\r\n\r\nexport class EntityRef implements EntityRefShape {\r\n private _entity: SpatialEntity | null\r\n private _ctx: RealityContextValue | null\r\n\r\n constructor(\r\n entity: SpatialEntity | null = null,\r\n ctx: RealityContextValue | null = null,\r\n ) {\r\n this._entity = entity\r\n this._ctx = ctx\r\n }\r\n\r\n updateEntity(entity?: SpatialEntity | null) {\r\n if (entity) this._entity = entity\r\n }\r\n\r\n updateCtx(ctx?: RealityContextValue | null) {\r\n if (ctx) this._ctx = ctx\r\n }\r\n\r\n destroy() {\r\n this._entity?.destroy()\r\n }\r\n\r\n get entity() {\r\n return this._entity\r\n }\r\n get id() {\r\n return this._entity?.userData?.id\r\n }\r\n get name() {\r\n return this._entity?.userData?.name\r\n }\r\n\r\n async convertFromEntityToEntity(\r\n fromEntityId: string,\r\n toEntityId: string,\r\n position: Vec3,\r\n ): Promise<Vec3> {\r\n if (!this._entity) return position\r\n try {\r\n const fromEnt = await this._ctx?.resourceRegistry.get(fromEntityId)\r\n const toEnt = await this._ctx?.resourceRegistry.get(toEntityId)\r\n if (!fromEnt || !toEnt) return position\r\n const ret = await this._entity.convertFromEntityToEntity(\r\n fromEnt.id,\r\n toEnt.id,\r\n position,\r\n )\r\n return ret?.data ?? position\r\n } catch {\r\n return position\r\n }\r\n }\r\n\r\n async convertFromEntityToReality(\r\n entityId: string,\r\n position: Vec3,\r\n ): Promise<Vec3> {\r\n if (!this._entity) return position\r\n try {\r\n const ent = await this._ctx?.resourceRegistry.get(entityId)\r\n if (!ent) return position\r\n const ret = await this._entity.convertFromEntityToScene(ent.id, position)\r\n return ret?.data ?? position\r\n } catch {\r\n return position\r\n }\r\n }\r\n\r\n async convertFromRealityToEntity(\r\n entityId: string,\r\n position: Vec3,\r\n ): Promise<Vec3> {\r\n if (!this._entity) return position\r\n try {\r\n const ent = await this._ctx?.resourceRegistry.get(entityId)\r\n if (!ent) return position\r\n const ret = await this._entity.convertFromSceneToEntity(ent.id, position)\r\n return ret?.data ?? position\r\n } catch {\r\n return position\r\n }\r\n }\r\n}\r\n\r\nexport function createEntityRefProxy(\r\n entity: SpatialEntity | null,\r\n ctx?: RealityContextValue | null,\r\n): EntityRefShape {\r\n return new EntityRef(entity, ctx)\r\n}\r\n","import { SpatialEntity } from '@webspatial/core-sdk'\r\nimport React, { useEffect } from 'react'\r\nimport { useRealityContext } from '../context'\r\ntype Props = {\r\n id?: string\r\n entity?: SpatialEntity | null\r\n}\r\nexport const useEntityId: React.FC<Props> = ({ id, entity }) => {\r\n const ctx = useRealityContext()\r\n useEffect(() => {\r\n if (!id || !entity || !ctx) return\r\n ctx.resourceRegistry.add(id, Promise.resolve(entity))\r\n return () => {\r\n ctx.resourceRegistry.remove(id)\r\n }\r\n }, [id, entity, ctx])\r\n\r\n return null\r\n}\r\n","import { ForwardedRef, useEffect, useRef, useState } from 'react'\r\nimport { SpatialEntity, Vec3 } from '@webspatial/core-sdk'\r\nimport { useRealityContext, useParentContext } from '../context'\r\nimport { EntityEventHandler, EntityProps } from '../type'\r\nimport {\r\n EntityRefShape,\r\n EntityRef,\r\n useEntityEvent,\r\n useEntityId,\r\n useEntityRef,\r\n useEntityTransform,\r\n useForceUpdate,\r\n} from '../hooks'\r\n\r\ntype UseEntityOptions = {\r\n createEntity: (signal: AbortSignal) => Promise<SpatialEntity>\r\n} & EntityProps &\r\n EntityEventHandler & { ref: ForwardedRef<EntityRefShape> }\r\n\r\nexport const useEntity = ({\r\n ref,\r\n id,\r\n position,\r\n rotation,\r\n scale,\r\n onSpatialTap,\r\n onSpatialDragStart,\r\n onSpatialDrag,\r\n onSpatialDragEnd,\r\n // onSpatialRotateStart,\r\n onSpatialRotate,\r\n onSpatialRotateEnd,\r\n // onSpatialMagnifyStart,\r\n onSpatialMagnify,\r\n onSpatialMagnifyEnd,\r\n // TODO: add other event handlers\r\n createEntity,\r\n}: UseEntityOptions) => {\r\n const ctx = useRealityContext()\r\n const parent = useParentContext()\r\n const instanceRef = useRef<EntityRef>(new EntityRef(null, ctx))\r\n\r\n const forceUpdate = useForceUpdate()\r\n\r\n useEffect(() => {\r\n if (!ctx) return\r\n const controller = new AbortController()\r\n\r\n const init = async () => {\r\n try {\r\n const ent = await createEntity(controller.signal)\r\n if (!ent) return\r\n if (controller.signal.aborted) {\r\n ent.destroy()\r\n return\r\n }\r\n if (parent) {\r\n const result = await parent.addEntity(ent)\r\n if (!result.success) throw new Error('parent.addEntity failed')\r\n } else {\r\n const result = await ctx.reality.addEntity(ent)\r\n if (!result.success) throw new Error('ctx.reality.addEntity failed')\r\n }\r\n\r\n instanceRef.current?.updateEntity(ent)\r\n forceUpdate()\r\n } catch (error) {\r\n console.error('useEntity init ~ error:', error)\r\n }\r\n }\r\n\r\n init()\r\n\r\n return () => {\r\n controller.abort()\r\n instanceRef.current?.destroy()\r\n }\r\n }, [ctx, parent])\r\n\r\n useEntityId({ id, entity: instanceRef.current.entity })\r\n useEntityTransform(instanceRef.current.entity, { position, rotation, scale })\r\n useEntityRef(ref, instanceRef.current)\r\n\r\n useEntityEvent({\r\n instance: instanceRef.current,\r\n onSpatialTap,\r\n onSpatialDragStart,\r\n onSpatialDrag,\r\n onSpatialDragEnd,\r\n // onSpatialRotateStart,\r\n onSpatialRotate,\r\n onSpatialRotateEnd,\r\n // onSpatialMagnifyStart,\r\n onSpatialMagnify,\r\n onSpatialMagnifyEnd,\r\n })\r\n\r\n return instanceRef.current.entity\r\n}\r\n","import React, { useCallback, useState } from 'react'\r\ntype Props = {\r\n children?: React.ReactNode\r\n}\r\nexport const useForceUpdate = () => {\r\n const [, setTick] = useState(0)\r\n return useCallback(() => setTick(tick => tick + 1), [])\r\n}\r\n","import React, { forwardRef } from 'react'\r\nimport { EntityProps, EntityEventHandler } from '../type'\r\nimport { EntityRefShape } from '../hooks'\r\nimport { SpatialBoxGeometryOptions } from '@webspatial/core-sdk'\r\nimport { GeometryEntity } from './GeometryEntity'\r\nimport { useRealityContext } from '../context'\r\n\r\ntype BoxEntityProps = EntityProps &\r\n EntityEventHandler & {\r\n children?: React.ReactNode\r\n materials?: string[]\r\n } & SpatialBoxGeometryOptions\r\n\r\nexport const BoxEntity = forwardRef<EntityRefShape, BoxEntityProps>(\r\n ({ children, ...props }, ref) => {\r\n const ctx = useRealityContext()\r\n return (\r\n <GeometryEntity\r\n {...props}\r\n ref={ref}\r\n createGeometry={options => ctx!.session.createBoxGeometry(options)}\r\n geometryOptions={{\r\n width: props.width,\r\n height: props.height,\r\n depth: props.depth,\r\n cornerRadius: props.cornerRadius,\r\n splitFaces: props.splitFaces,\r\n }}\r\n >\r\n {children}\r\n </GeometryEntity>\r\n )\r\n },\r\n)\r\n","import React, { forwardRef } from 'react'\r\nimport { EntityProps, EntityEventHandler } from '../type'\r\nimport { EntityRefShape } from '../hooks'\r\nimport { SpatialMaterial, SpatialGeometry } from '@webspatial/core-sdk'\r\nimport { AbortResourceManager } from '../utils'\r\nimport { BaseEntity } from './BaseEntity'\r\n\r\ntype GeometryEntityProps = EntityProps &\r\n EntityEventHandler & {\r\n children?: React.ReactNode\r\n materials?: string[]\r\n geometryOptions: any\r\n createGeometry: (options: any) => Promise<SpatialGeometry>\r\n }\r\n\r\nexport const GeometryEntity = forwardRef<EntityRefShape, GeometryEntityProps>(\r\n (\r\n { id, children, name, materials, geometryOptions, createGeometry, ...rest },\r\n ref,\r\n ) => {\r\n return (\r\n <BaseEntity\r\n {...rest}\r\n id={id}\r\n ref={ref}\r\n createEntity={async (ctx, signal) => {\r\n const manager = new AbortResourceManager(signal)\r\n try {\r\n const ent = await manager.addResource(() =>\r\n ctx!.session.createEntity({ id, name }),\r\n )\r\n\r\n const geometry = await manager.addResource(() =>\r\n createGeometry(geometryOptions),\r\n )\r\n\r\n const materialList: SpatialMaterial[] = await Promise.all(\r\n materials\r\n ?.map(id => ctx!.resourceRegistry.get<SpatialMaterial>(id))\r\n .filter(Boolean) ?? [],\r\n )\r\n const modelComponent = await manager.addResource(() =>\r\n ctx!.session.createModelComponent({\r\n mesh: geometry,\r\n materials: materialList,\r\n }),\r\n )\r\n\r\n await ent.addComponent(modelComponent)\r\n return ent\r\n } catch (error) {\r\n await manager.dispose()\r\n return null as any\r\n }\r\n }}\r\n >\r\n {children}\r\n </BaseEntity>\r\n )\r\n },\r\n)\r\n","import React, { useEffect, useRef } from 'react'\r\nimport {\r\n SpatialUnlitMaterial,\r\n SpatialUnlitMaterialOptions,\r\n} from '@webspatial/core-sdk'\r\nimport { useRealityContext } from '../context'\r\ntype Props = {\r\n children?: React.ReactNode\r\n id: string // user id\r\n} & SpatialUnlitMaterialOptions\r\nexport const UnlitMaterial: React.FC<Props> = ({ children, ...options }) => {\r\n const ctx = useRealityContext()\r\n const materialRef = useRef<SpatialUnlitMaterial>()\r\n useEffect(() => {\r\n if (!ctx) return\r\n const { session, reality, resourceRegistry } = ctx\r\n const init = async () => {\r\n const materialPromise = session.createUnlitMaterial(options)\r\n resourceRegistry.add(options.id, materialPromise)\r\n try {\r\n const mat = await materialPromise\r\n materialRef.current = mat\r\n } catch (error) {\r\n console.error(' ~ UnlitMaterial ~ error:', error)\r\n }\r\n }\r\n init()\r\n\r\n return () => {\r\n // Use registry to schedule destruction after promise resolves\r\n resourceRegistry.removeAndDestroy(options.id)\r\n }\r\n }, [ctx])\r\n\r\n return null\r\n}\r\n","import React, { forwardRef } from 'react'\r\nimport { EntityProps, EntityEventHandler } from '../type'\r\nimport { EntityRefShape } from '../hooks'\r\nimport { SpatialSphereGeometryOptions } from '@webspatial/core-sdk'\r\nimport { GeometryEntity } from './GeometryEntity'\r\nimport { useRealityContext } from '../context'\r\n\r\ntype SphereEntityProps = EntityProps &\r\n EntityEventHandler & {\r\n children?: React.ReactNode\r\n materials?: string[]\r\n } & SpatialSphereGeometryOptions\r\n\r\nexport const SphereEntity = forwardRef<EntityRefShape, SphereEntityProps>(\r\n ({ children, ...props }, ref) => {\r\n const ctx = useRealityContext()\r\n return (\r\n <GeometryEntity\r\n {...props}\r\n ref={ref}\r\n createGeometry={options => ctx!.session.createSphereGeometry(options)}\r\n geometryOptions={{\r\n radius: props.radius,\r\n }}\r\n >\r\n {children}\r\n </GeometryEntity>\r\n )\r\n },\r\n)\r\n","import React, { forwardRef } from 'react'\r\nimport { EntityProps, EntityEventHandler } from '../type'\r\nimport { EntityRefShape } from '../hooks'\r\nimport { SpatialConeGeometryOptions } from '@webspatial/core-sdk'\r\nimport { GeometryEntity } from './GeometryEntity'\r\nimport { useRealityContext } from '../context'\r\n\r\ntype ConeEntityProps = EntityProps &\r\n EntityEventHandler & {\r\n children?: React.ReactNode\r\n materials?: string[]\r\n } & SpatialConeGeometryOptions\r\n\r\nexport const ConeEntity = forwardRef<EntityRefShape, ConeEntityProps>(\r\n ({ children, ...props }, ref) => {\r\n const ctx = useRealityContext()\r\n return (\r\n <GeometryEntity\r\n {...props}\r\n ref={ref}\r\n createGeometry={options => ctx!.session.createConeGeometry(options)}\r\n geometryOptions={{\r\n radius: props.radius,\r\n height: props.height,\r\n }}\r\n >\r\n {children}\r\n </GeometryEntity>\r\n )\r\n },\r\n)\r\n","import React, { forwardRef } from 'react'\r\nimport { EntityProps, EntityEventHandler } from '../type'\r\nimport { EntityRefShape } from '../hooks'\r\nimport { SpatialCylinderGeometryOptions } from '@webspatial/core-sdk'\r\nimport { GeometryEntity } from './GeometryEntity'\r\nimport { useRealityContext } from '../context'\r\n\r\ntype CylinderEntityProps = EntityProps &\r\n EntityEventHandler & {\r\n children?: React.ReactNode\r\n materials?: string[]\r\n } & SpatialCylinderGeometryOptions\r\n\r\nexport const CylinderEntity = forwardRef<EntityRefShape, CylinderEntityProps>(\r\n ({ children, ...props }, ref) => {\r\n const ctx = useRealityContext()\r\n return (\r\n <GeometryEntity\r\n {...props}\r\n ref={ref}\r\n createGeometry={options => ctx!.session.createCylinderGeometry(options)}\r\n geometryOptions={{\r\n radius: props.radius,\r\n height: props.height,\r\n }}\r\n >\r\n {children}\r\n </GeometryEntity>\r\n )\r\n },\r\n)\r\n","import React, { forwardRef } from 'react'\r\nimport { EntityProps, EntityEventHandler } from '../type'\r\nimport { EntityRefShape } from '../hooks'\r\nimport { SpatialPlaneGeometryOptions } from '@webspatial/core-sdk'\r\nimport { GeometryEntity } from './GeometryEntity'\r\nimport { useRealityContext } from '../context'\r\n\r\ntype PlaneEntityProps = EntityProps &\r\n EntityEventHandler & {\r\n children?: React.ReactNode\r\n materials?: string[]\r\n } & SpatialPlaneGeometryOptions\r\n\r\nexport const PlaneEntity = forwardRef<EntityRefShape, PlaneEntityProps>(\r\n ({ children, ...props }, ref) => {\r\n const ctx = useRealityContext()\r\n return (\r\n <GeometryEntity\r\n {...props}\r\n ref={ref}\r\n createGeometry={options => ctx!.session.createPlaneGeometry(options)}\r\n geometryOptions={{\r\n width: props.width,\r\n height: props.height,\r\n cornerRadius: props.cornerRadius,\r\n }}\r\n >\r\n {children}\r\n </GeometryEntity>\r\n )\r\n },\r\n)\r\n","import React from 'react'\r\nimport { ParentContext } from '../context'\r\ntype Props = {\r\n children?: React.ReactNode\r\n}\r\nexport const SceneGraph: React.FC<Props> = ({ children }) => {\r\n return (\r\n <ParentContext.Provider value={null}>{children}</ParentContext.Provider>\r\n )\r\n}\r\n","import React, { useEffect, useRef } from 'react'\r\nimport { useRealityContext } from '../context'\r\nimport { SpatialModelAsset } from '@webspatial/core-sdk'\r\ntype Props = {\r\n children?: React.ReactNode\r\n id: string // user id\r\n src: string // model url\r\n onLoad?: () => void\r\n onError?: (error: any) => void\r\n}\r\n\r\n// Resolve relative URLs to absolute for the native bridge\r\nconst resolveAssetUrl = (url: string): string => {\r\n if (url.startsWith('http://') || url.startsWith('https://')) {\r\n return url\r\n }\r\n return new URL(url, window.location.href).href\r\n}\r\n\r\nexport const ModelAsset: React.FC<Props> = ({ children, ...options }) => {\r\n const ctx = useRealityContext()\r\n const materialRef = useRef<SpatialModelAsset>()\r\n useEffect(() => {\r\n const controller = new AbortController()\r\n if (!ctx) return\r\n const { session, reality, resourceRegistry } = ctx\r\n const init = async () => {\r\n try {\r\n const resolvedUrl = resolveAssetUrl(options.src)\r\n const modelAssetPromise = session.createModelAsset({ url: resolvedUrl })\r\n resourceRegistry.add(options.id, modelAssetPromise)\r\n\r\n const mat = await modelAssetPromise\r\n if (controller.signal.aborted) {\r\n mat.destroy()\r\n return\r\n }\r\n materialRef.current = mat\r\n options.onLoad?.()\r\n } catch (error: any) {\r\n options.onError?.(error)\r\n }\r\n }\r\n init()\r\n\r\n return () => {\r\n controller.abort()\r\n materialRef.current?.destroy()\r\n }\r\n }, [ctx])\r\n\r\n return null\r\n}\r\n","import React, { forwardRef } from 'react'\r\nimport { EntityProps, EntityEventHandler } from '../type'\r\nimport { EntityRefShape } from '../hooks'\r\nimport { BaseEntity } from './BaseEntity'\r\n\r\ntype Props = EntityProps & { model: string } & EntityEventHandler & {\r\n children?: React.ReactNode\r\n }\r\n\r\nexport const ModelEntity = forwardRef<EntityRefShape, Props>(\r\n ({ id, model, children, name, ...rest }, ref) => {\r\n return (\r\n <BaseEntity\r\n {...rest}\r\n id={id}\r\n ref={ref}\r\n createEntity={async (ctx, signal) => {\r\n try {\r\n const modelAsset = await ctx!.resourceRegistry.get(model)\r\n if (!modelAsset)\r\n throw new Error(`ModelEntity: model not found ${model}`)\r\n if (signal.aborted) return null as any\r\n\r\n return ctx!.session.createSpatialModelEntity(\r\n {\r\n modelAssetId: modelAsset.id,\r\n name,\r\n },\r\n { id, name },\r\n )\r\n } catch (error) {\r\n return null as any\r\n }\r\n }}\r\n >\r\n {children}\r\n </BaseEntity>\r\n )\r\n },\r\n)\r\n","import React, {\r\n forwardRef,\r\n useCallback,\r\n useEffect,\r\n useRef,\r\n useState,\r\n} from 'react'\r\nimport { SpatializedContainer } from '../../spatialized-container/SpatializedContainer'\r\nimport { RealityContext, RealityContextValue } from '../context'\r\nimport { useInsideAttachment } from '../context/InsideAttachmentContext'\r\nimport { getSession } from '../../utils/getSession'\r\nimport { ResourceRegistry } from '../utils'\r\nimport { AttachmentRegistry } from '../context/AttachmentContext'\r\nimport {\r\n RealityProps,\r\n SpatializedElementRef,\r\n} from '../../spatialized-container/types'\r\nimport { SpatializedElement } from '@webspatial/core-sdk'\r\n\r\nexport const Reality = forwardRef<SpatializedElementRef, RealityProps>(\r\n function RealityBase({ children, ...inProps }, ref) {\r\n const insideAttachment = useInsideAttachment()\r\n if (insideAttachment) {\r\n console.warn(\r\n '[WebSpatial] Reality cannot be used inside AttachmentAsset.',\r\n )\r\n return null\r\n }\r\n const {\r\n onSpatialTap,\r\n onSpatialDragStart,\r\n onSpatialDrag,\r\n onSpatialDragEnd,\r\n onSpatialRotate,\r\n onSpatialRotateEnd,\r\n onSpatialMagnify,\r\n onSpatialMagnifyEnd,\r\n ...props\r\n } = inProps\r\n const ctxRef = useRef<RealityContextValue | null>(null)\r\n\r\n const creationId = useRef(0)\r\n\r\n const [isReady, setIsReady] = useState(false)\r\n\r\n const cleanupReality = useCallback(() => {\r\n ctxRef.current?.attachmentRegistry.destroy()\r\n ctxRef.current?.resourceRegistry.destroy()\r\n ctxRef.current?.reality.destroy()\r\n ctxRef.current = null\r\n setIsReady(false)\r\n }, [])\r\n\r\n useEffect(() => {\r\n return () => {\r\n creationId.current++\r\n cleanupReality()\r\n }\r\n }, [cleanupReality])\r\n\r\n const createReality = useCallback(async () => {\r\n const id = ++creationId.current\r\n const resourceRegistry = new ResourceRegistry()\r\n const attachmentRegistry = new AttachmentRegistry()\r\n const session = await getSession()\r\n if (!session) {\r\n resourceRegistry.destroy()\r\n attachmentRegistry.destroy()\r\n return null\r\n }\r\n\r\n const reality = await session.createSpatializedDynamic3DElement()\r\n\r\n const isCancelled = () => id !== creationId.current\r\n\r\n if (isCancelled()) {\r\n resourceRegistry.destroy()\r\n attachmentRegistry.destroy()\r\n reality.destroy()\r\n return null\r\n }\r\n\r\n try {\r\n const result = await session\r\n .getSpatialScene()\r\n .addSpatializedElement(reality)\r\n\r\n if (!result.success || isCancelled()) {\r\n resourceRegistry.destroy()\r\n attachmentRegistry.destroy()\r\n reality.destroy()\r\n return null\r\n }\r\n\r\n cleanupReality()\r\n\r\n ctxRef.current = {\r\n session,\r\n reality,\r\n resourceRegistry,\r\n attachmentRegistry,\r\n }\r\n setIsReady(true)\r\n return reality as SpatializedElement\r\n } catch (err) {\r\n console.error('[createReality] failed', err)\r\n resourceRegistry.destroy()\r\n attachmentRegistry.destroy()\r\n reality.destroy()\r\n return null\r\n }\r\n }, [cleanupReality])\r\n\r\n const content = useCallback(() => <></>, [])\r\n\r\n return (\r\n <RealityContext.Provider value={ctxRef.current}>\r\n <SpatializedContainer<SpatializedElementRef>\r\n component=\"div\"\r\n ref={ref}\r\n // @ts-ignore\r\n createSpatializedElement={createReality}\r\n spatializedContent={content}\r\n {...props}\r\n />\r\n {isReady && children}\r\n </RealityContext.Provider>\r\n )\r\n },\r\n)\r\n","import React, { useEffect, useState } from 'react'\r\nimport { createPortal } from 'react-dom'\r\nimport { useRealityContext } from '../context'\r\nimport { InsideAttachmentContext } from '../context/InsideAttachmentContext'\r\n\r\ntype AttachmentAssetProps = {\r\n name: string\r\n children?: React.ReactNode\r\n}\r\n\r\nexport const AttachmentAsset: React.FC<AttachmentAssetProps> = ({\r\n name,\r\n children,\r\n}) => {\r\n const ctx = useRealityContext()\r\n const [containers, setContainers] = useState<HTMLElement[]>([])\r\n\r\n useEffect(() => {\r\n if (!ctx) return\r\n return ctx.attachmentRegistry.onContainersChange(name, setContainers)\r\n }, [ctx, name])\r\n\r\n if (!containers.length) return null\r\n return (\r\n <InsideAttachmentContext.Provider value={true}>\r\n {containers.map((c, idx) => createPortal(children, c, `${name}-${idx}`))}\r\n </InsideAttachmentContext.Provider>\r\n )\r\n}\r\n","import React, { useEffect, useRef, useState } from 'react'\r\nimport { Attachment } from '@webspatial/core-sdk'\r\n\r\nimport { useRealityContext, useParentContext } from '../context'\r\nimport {\r\n setOpenWindowStyle,\r\n syncParentHeadToChild,\r\n} from '../../utils/windowStyleSync'\r\nimport { useSyncHeadStyles } from '../../utils/useSyncHeadStyles'\r\n\r\nlet instanceCounter = 0\r\n\r\ninterface AttachmentEntityProps {\r\n attachment: string\r\n position?: [number, number, number]\r\n size: { width: number; height: number }\r\n}\r\n\r\nexport const AttachmentEntity: React.FC<AttachmentEntityProps> = ({\r\n attachment: attachmentName,\r\n position,\r\n size,\r\n}) => {\r\n const ctx = useRealityContext()\r\n const parent = useParentContext()\r\n // React 18 types require `| null` for mutable refs; useRef<T>(null) without it returns readonly RefObject.\r\n const attachmentRef = useRef<Attachment | null>(null)\r\n const parentIdRef = useRef<string | null>(null)\r\n const instanceIdRef = useRef(`att_${++instanceCounter}`)\r\n const attachmentNameRef = useRef(attachmentName)\r\n const [childWindow, setChildWindow] = useState<WindowProxy | null>(null)\r\n\r\n // Create the attachment when the parent entity is ready\r\n useEffect(() => {\r\n if (!ctx || !parent) return\r\n\r\n const parentId = parent.id\r\n parentIdRef.current = parentId\r\n\r\n let cancelled = false\r\n\r\n const init = async () => {\r\n try {\r\n const att = await ctx.session.createAttachmentEntity({\r\n parentEntityId: parentId,\r\n position: position ?? [0, 0, 0],\r\n size,\r\n })\r\n if (cancelled) {\r\n att.destroy()\r\n return\r\n }\r\n // Initial style sync for attachment window\r\n const windowProxy = att.getWindowProxy()\r\n setOpenWindowStyle(windowProxy)\r\n // setOpenWindowStyle() above applies SpatialDiv defaults (inline-block, fit-content)\r\n // which shrink the body to its content. Attachments need the opposite — the body\r\n // must fill the RealityKit attachment frame — so override to block/100%.\r\n windowProxy.document.body.style.display = 'block'\r\n windowProxy.document.body.style.minWidth = '100%'\r\n windowProxy.document.body.style.maxWidth = '100%'\r\n windowProxy.document.body.style.minHeight = '100%'\r\n await syncParentHeadToChild(windowProxy)\r\n\r\n // Ensure viewport meta\r\n const viewport = windowProxy.document.querySelector(\r\n 'meta[name=\"viewport\"]',\r\n )\r\n if (!viewport) {\r\n const meta = windowProxy.document.createElement('meta')\r\n meta.name = 'viewport'\r\n meta.content =\r\n 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no'\r\n windowProxy.document.head.appendChild(meta)\r\n }\r\n\r\n // Ensure base href for relative URLs\r\n const base = windowProxy.document.createElement('base')\r\n base.href = document.baseURI\r\n windowProxy.document.head.appendChild(base)\r\n\r\n attachmentRef.current = att\r\n setChildWindow(windowProxy)\r\n ctx.attachmentRegistry.addContainer(\r\n attachmentNameRef.current,\r\n instanceIdRef.current,\r\n att.getContainer(),\r\n )\r\n } catch (error) {\r\n console.error('[AttachmentEntity] init error:', error)\r\n }\r\n }\r\n\r\n init()\r\n\r\n return () => {\r\n cancelled = true\r\n const att = attachmentRef.current\r\n if (att) {\r\n ctx.attachmentRegistry.removeContainer(\r\n attachmentNameRef.current,\r\n instanceIdRef.current,\r\n )\r\n att.destroy()\r\n attachmentRef.current = null\r\n setChildWindow(null)\r\n }\r\n }\r\n }, [ctx, parent])\r\n\r\n // If attachment name changes at runtime, migrate the container mapping\r\n useEffect(() => {\r\n if (!ctx) return\r\n const att = attachmentRef.current\r\n const prevName = attachmentNameRef.current\r\n if (att && prevName !== attachmentName) {\r\n ctx.attachmentRegistry.removeContainer(prevName, instanceIdRef.current)\r\n ctx.attachmentRegistry.addContainer(\r\n attachmentName,\r\n instanceIdRef.current,\r\n att.getContainer(),\r\n )\r\n attachmentNameRef.current = attachmentName\r\n } else {\r\n attachmentNameRef.current = attachmentName\r\n }\r\n }, [ctx, attachmentName])\r\n\r\n useSyncHeadStyles(childWindow, { subtree: false })\r\n\r\n // Update position/size when they change\r\n useEffect(() => {\r\n if (!attachmentRef.current) return\r\n attachmentRef.current.update({ position, size })\r\n }, [position?.[0], position?.[1], position?.[2], size?.width, size?.height])\r\n\r\n return null\r\n}\r\n","import { ForwardedRef, forwardRef } from 'react'\r\nimport {\r\n SpatializedStatic3DContainerProps,\r\n SpatializedStatic3DElementContainer,\r\n SpatializedStatic3DElementRef,\r\n} from './spatialized-container'\r\nimport { withSSRSupported } from './ssr'\r\nimport { useInsideAttachment } from './reality/context/InsideAttachmentContext'\r\n\r\nimport { Spatial } from '@webspatial/core-sdk'\r\n\r\nexport type ModelProps = SpatializedStatic3DContainerProps & {\r\n 'enable-xr'?: boolean\r\n}\r\n\r\nexport type ModelRef = SpatializedStatic3DElementRef\r\n\r\nconst spatial = new Spatial()\r\n\r\nfunction ModelBase(props: ModelProps, ref: ForwardedRef<ModelRef>) {\r\n const insideAttachment = useInsideAttachment()\r\n const { 'enable-xr': enableXR, ...restProps } = props\r\n // Model must handle insideAttachment itself because\r\n // SpatializedStatic3DElementContainer passes component=\"div\" to the base,\r\n // but the correct degraded element for a Model is a <model> tag, not a <div>.\r\n if (!enableXR || !spatial.runInSpatialWeb() || insideAttachment) {\r\n const {\r\n onSpatialTap,\r\n onSpatialDragStart,\r\n onSpatialDrag,\r\n onSpatialDragEnd,\r\n onSpatialRotate,\r\n onSpatialRotateEnd,\r\n onSpatialMagnify,\r\n onSpatialMagnifyEnd,\r\n ...modelProps\r\n } = restProps\r\n // map to VisionOS26 model tag outside attachments\r\n // @ts-ignore\r\n return <model ref={ref} {...modelProps} />\r\n }\r\n\r\n return <SpatializedStatic3DElementContainer ref={ref} {...restProps} />\r\n}\r\n\r\nexport const Model = withSSRSupported(forwardRef(ModelBase))\r\nModel.displayName = 'Model'\r\n","import { initPolyfill } from './spatialized-container'\r\n\r\nexport { enableDebugTool } from './utils'\r\nexport * from './initScene'\r\nexport * from './spatialized-container'\r\nexport * from './spatialized-container-monitor'\r\nexport * from './reality'\r\nexport * from './Model'\r\nexport { SSRProvider } from './ssr'\r\n\r\nexport const version = __WEBSPATIAL_REACT_SDK_VERSION__\r\n\r\nif (typeof window !== 'undefined') {\r\n initPolyfill()\r\n}\r\n"],"mappings":";;;;;;;;;;AAAA,SAAuB,aAAa,WAAW,cAAc;;;ACmGtD,IAAM,yBAAyB;AAAA,EACpC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,oBAAoB;AAAA,EACpB,UAAU;AACZ;;;ACtGO,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,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a;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","useContext","createContext","useState","useEffect","jsx","forwardRef","useContext","useState","useEffect","useContext","useState","useEffect","jsx","forwardRef","jsx","jsxs","useContext","useMemo","useEffect","createSpatializedElement","getExtraSpatializedElementProperties","forwardRef","createPortal","forwardRef","useContext","useEffect","document","version","useEffect","useEffect","jsx","useEffect","useContext","createPortal","forwardRef","forwardRef","useCallback","useContext","useEffect","useMemo","useRef","Fragment","jsx","SpatializedContent","useContext","useMemo","useEffect","useRef","createSpatializedElement","useCallback","forwardRef","forwardRef","jsx","forwardRef","forwardRef","useRef","useEffect","useMemo","useRef","useEffect","useMemo","useEffect","useEffect","forwardRef","jsx","jsx","forwardRef","forwardRef","forwardRef","createContext","useContext","createContext","useContext","createContext","useContext","useEffect","useRef","useRef","useEffect","useEffect","useRef","createEventProxy","useRef","useEffect","useEffect","useEffect","useEffect","useRef","useRef","useForceUpdate","useEffect","useCallback","useState","useForceUpdate","jsx","forwardRef","jsx","forwardRef","forwardRef","forwardRef","jsx","forwardRef","id","jsx","forwardRef","useEffect","useRef","useRef","useEffect","forwardRef","jsx","forwardRef","forwardRef","jsx","forwardRef","forwardRef","jsx","forwardRef","forwardRef","jsx","forwardRef","jsx","useEffect","useRef","useRef","useEffect","forwardRef","jsx","forwardRef","forwardRef","useCallback","useEffect","useRef","useState","Fragment","jsx","jsxs","forwardRef","useRef","useState","useCallback","useEffect","useEffect","useState","createPortal","jsx","useState","useEffect","createPortal","useEffect","useRef","useState","useRef","useState","useEffect","forwardRef","jsx","spatial","forwardRef"]}
|