@webspatial/react-sdk 0.1.18 → 0.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/spatial-react-components/SpatialPrimitive.tsx","../../src/spatial-react-components/primitives.ts","../../src/spatial-react-components/SpatialReactComponent/SpatialReactComponent.tsx","../../src/noRuntime.ts","../../src/utils/getSession.ts","../../src/utils/debugTool.ts","../../src/spatial-react-components/SpatialReactComponent/StandardInstance.tsx","../../src/spatial-react-components/hooks/useForceUpdate.ts","../../src/spatial-react-components/SpatialReactComponent/SpatialIsStandardInstanceContext.ts","../../src/spatial-react-components/SpatialReactComponent/SpatialReactContext.ts","../../src/spatial-react-components/SpatialReactComponent/const.ts","../../src/spatial-react-components/SpatialReactComponent/PortalInstance.tsx","../../src/spatial-react-components/SpatialReactComponent/usePortalContainer.tsx","../../src/spatial-react-components/SpatialReactComponent/SpatialWindowManager.ts","../../src/spatial-react-components/SpatialReactComponent/SpatialWindowManagerContext.ts","../../src/spatial-react-components/SpatialReactComponent/utils.ts","../../src/spatial-react-components/SpatialReactComponent/SpatialDebugNameContext.ts","../../src/XRApp.ts","../../src/spatial-react-components/SpatialReactComponent/SpatialLayerContext.ts","../../src/spatial-react-components/SpatialMonitor/withSpatialMonitor.tsx","../../src/spatial-react-components/SpatialMonitor/useMonitorDomChange.tsx","../../src/spatial-react-components/notifyUpdateStandInstanceLayout.ts","../../src/spatial-react-components/SpatialMonitor/useMonitorDocumentHeaderChange.tsx","../../src/spatial-react-components/SpatialMonitor/SpatialMonitor.tsx","../../src/spatial-react-components/CSSSpatialDiv/CSSSpatialDiv.tsx","../../src/spatial-react-components/CSSSpatialDiv/CSSSpatialComponent.tsx","../../src/spatial-react-components/CSSSpatialDiv/useSpatialStyle.ts","../../src/spatial-react-components/CSSSpatialDiv/math/index.ts","../../src/spatial-react-components/CSSSpatialDiv/const.ts","../../src/spatial-react-components/CSSSpatialDiv/CSSSpatialDebugNameContext.ts","../../src/spatial-react-components/CSSSpatialDiv/useHijackSpatialDivRef.ts","../../src/spatial-react-components/CSSSpatialDiv/injectClassStyle.ts","../../src/spatial-react-components/CSSSpatialDiv/utils.ts","../../src/spatial-react-components/CSSSpatialDiv/CSSSpatialLayerContext.ts","../../src/spatial-react-components/CSSSpatialDiv/CSSSpatialRootContext.ts","../../src/spatial-react-components/SpatialView.tsx","../../src/spatial-react-components/Model/index.tsx","../../src/spatial-react-components/Model3D/Model3D.tsx","../../src/spatial-react-components/Model3D/useDetectLayoutDomUpdated.ts","../../src/spatial-react-components/Model3D/useModel3DNative.ts","../../src/spatial-react-components/Model3D/utils.ts","../../src/spatial-react-components/Model3D/Model3DNative.ts","../../src/spatial-react-components/Model3D/Model3DNotInSpatialDiv.tsx","../../src/spatial-react-components/Model3D/Model3DStandardInstance.tsx","../../src/spatial-react-components/Model3D/Model3DPortalInstance.tsx","../../src/spatial-react-components/Model3D/useSyncDomInfoFromStandardInstance.ts","../../src/spatial-react-components/Model3D/CSSModel3D.tsx","../../src/spatial-react-components/Model3D/CSSModel3DNotInSpatialDiv.tsx","../../src/spatial-react-components/Model3D/CSSModel3DStandardInstance.tsx","../../src/spatial-react-components/Model3D/CSSModel3DPortalInstance.tsx","../../src/initScene.web.ts","../../src/polyfill/injectSceneHook.ts","../../src/polyfill/spatialPolyfill.ts","../../src/index.ts"],"sourcesContent":["import { forwardRef, Ref } from 'react'\nimport { primitives } from './primitives'\nimport { SpatialReactComponent } from './SpatialReactComponent'\nimport React from 'react'\n\nconst cachedWithSpatialType = new Map()\n\nexport function withSpatial(Component: React.ElementType) {\n if (cachedWithSpatialType.has(Component)) {\n return cachedWithSpatialType.get(Component)\n } else {\n const WithSpatialComponent = forwardRef(\n (givenProps: any, givenRef: Ref<any>) => {\n const { component: ignoreComponent, ...props } = givenProps\n return (\n <SpatialReactComponent\n component={Component}\n {...props}\n ref={givenRef}\n />\n )\n },\n )\n WithSpatialComponent.displayName = `WithSpatial(${typeof Component === 'string' ? Component : Component.displayName || Component.name})`\n\n cachedWithSpatialType.set(Component, WithSpatialComponent)\n cachedWithSpatialType.set(WithSpatialComponent, WithSpatialComponent)\n return WithSpatialComponent\n }\n}\n\nexport const SpatialPrimitive: Record<string, typeof SpatialReactComponent> = {}\n;(function createSpatialPrimitive(SpatialPrimitive) {\n primitives.forEach(primitive => {\n SpatialPrimitive[primitive] = withSpatial(primitive)\n })\n})(SpatialPrimitive)\n\nexport const SpatialDiv = SpatialPrimitive.div\n","export type Primitives = keyof JSX.IntrinsicElements\nexport const primitives: Primitives[] = [\n 'a',\n 'abbr',\n 'address',\n 'area',\n 'article',\n 'aside',\n 'audio',\n 'b',\n 'base',\n 'bdi',\n 'bdo',\n 'big',\n 'blockquote',\n 'body',\n 'br',\n 'button',\n 'canvas',\n 'caption',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'data',\n 'datalist',\n 'dd',\n 'del',\n 'details',\n 'dfn',\n 'dialog',\n 'div',\n 'dl',\n 'dt',\n 'em',\n 'embed',\n 'fieldset',\n 'figcaption',\n 'figure',\n 'footer',\n 'form',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'head',\n 'header',\n 'hgroup',\n 'hr',\n 'html',\n 'i',\n 'iframe',\n 'img',\n 'input',\n 'ins',\n 'kbd',\n 'keygen',\n 'label',\n 'legend',\n 'li',\n 'link',\n 'main',\n 'map',\n 'mark',\n 'menu',\n 'menuitem',\n 'meta',\n 'meter',\n 'nav',\n 'noscript',\n 'object',\n 'ol',\n 'optgroup',\n 'option',\n 'output',\n 'p',\n 'param',\n 'picture',\n 'pre',\n 'progress',\n 'q',\n 'rp',\n 'rt',\n 'ruby',\n 's',\n 'samp',\n 'script',\n 'section',\n 'select',\n 'small',\n 'source',\n 'span',\n 'strong',\n 'style',\n 'sub',\n 'summary',\n 'sup',\n 'table',\n 'tbody',\n 'td',\n 'textarea',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n 'title',\n 'tr',\n 'track',\n 'u',\n 'ul',\n 'var',\n 'video',\n 'wbr',\n // SVG\n 'circle',\n 'clipPath',\n 'defs',\n 'ellipse',\n 'foreignObject',\n 'g',\n 'image',\n 'line',\n 'linearGradient',\n 'mask',\n 'path',\n 'pattern',\n 'polygon',\n 'polyline',\n 'radialGradient',\n 'rect',\n 'stop',\n 'svg',\n 'text',\n 'tspan',\n]\n","import { forwardRef, useMemo, useContext } from 'react'\nimport {\n SpatialReactComponentProps,\n SpatialReactComponentRef,\n SpatialReactComponentWithUniqueIDProps,\n} from './types'\nimport { getSession } from '../../utils'\nimport { StandardInstance } from './StandardInstance'\nimport { PortalInstance } from './PortalInstance'\nimport {\n SpatialReactContext,\n SpatialReactContextObject,\n} from './SpatialReactContext'\nimport { SpatialIsStandardInstanceContext } from './SpatialIsStandardInstanceContext'\nimport { SpatialID } from './const'\nimport { SpatialLayerContext } from './SpatialLayerContext'\nimport { SpatialDebugNameContext } from './SpatialDebugNameContext'\n\nfunction parseProps(inProps: SpatialReactComponentWithUniqueIDProps) {\n const {\n debugShowStandardInstance,\n debugName = '',\n component,\n allowScroll,\n spatialStyle,\n scrollWithParent,\n ...props\n } = inProps\n\n const El = component ? component : 'div'\n\n const componentDesc = { El }\n const spatialDesc = { spatialStyle, allowScroll, scrollWithParent }\n const debugDesc = { debugName, debugShowStandardInstance }\n return { componentDesc, spatialDesc, debugDesc, props }\n}\n\nfunction renderWebReactComponent(\n inProps: SpatialReactComponentWithUniqueIDProps,\n ref: SpatialReactComponentRef,\n) {\n const { componentDesc, props } = parseProps(inProps)\n const { El } = componentDesc\n return <El {...props} ref={ref} />\n}\n\nfunction renderSpatialReactComponent(\n inProps: SpatialReactComponentWithUniqueIDProps,\n ref: SpatialReactComponentRef,\n) {\n const { componentDesc, spatialDesc, debugDesc, props } = parseProps(inProps)\n\n const standardInstanceProps = {\n ...props,\n ...componentDesc,\n debugShowStandardInstance: debugDesc.debugShowStandardInstance,\n }\n\n const portalInstanceProps = {\n ...props,\n ...componentDesc,\n ...spatialDesc,\n }\n\n const spatialReactContextObject = useMemo(\n () => new SpatialReactContextObject(debugDesc.debugName),\n [],\n )\n\n return (\n <SpatialReactContext.Provider value={spatialReactContextObject}>\n <StandardInstance {...standardInstanceProps} ref={ref} />\n <PortalInstance isSubPortal={false} {...portalInstanceProps} />\n </SpatialReactContext.Provider>\n )\n}\n\nfunction renderSubPortalInstance(\n inProps: SpatialReactComponentWithUniqueIDProps,\n) {\n const { componentDesc, spatialDesc, props } = parseProps(inProps)\n const portalInstanceProps = {\n ...props,\n ...componentDesc,\n ...spatialDesc,\n }\n\n return <PortalInstance isSubPortal={true} {...portalInstanceProps} />\n}\n\nfunction SpatialReactComponentRefactor(\n inProps: SpatialReactComponentProps,\n ref: SpatialReactComponentRef,\n) {\n const layer = useContext(SpatialLayerContext) + 1\n\n const parentSpatialReactContextObject = useContext(SpatialReactContext)\n const isRootInstance = !parentSpatialReactContextObject\n const isInStandardInstance = !!useContext(SpatialIsStandardInstanceContext)\n const spatialID = useMemo(() => {\n return isRootInstance\n ? layer.toString()\n : parentSpatialReactContextObject.getSpatialID(\n layer,\n isInStandardInstance,\n inProps.debugName,\n )\n }, [])\n\n const props = { ...inProps, [SpatialID]: spatialID }\n\n const contentInLayer = renderContentInLayer(props, ref)\n return (\n <SpatialDebugNameContext.Provider value={inProps.debugName || ''}>\n <SpatialLayerContext.Provider value={layer}>\n {contentInLayer}\n </SpatialLayerContext.Provider>\n </SpatialDebugNameContext.Provider>\n )\n}\n\nfunction renderContentInLayer(\n inProps: SpatialReactComponentWithUniqueIDProps,\n ref: SpatialReactComponentRef,\n) {\n const isInStandardInstance = useContext(SpatialIsStandardInstanceContext)\n const isWebSpatialEnv = getSession() !== null\n if (isInStandardInstance || !isWebSpatialEnv) {\n return renderWebReactComponent(inProps, ref)\n } else {\n const parentSpatialReactContextObject = useContext(SpatialReactContext)\n if (parentSpatialReactContextObject) {\n return renderSubPortalInstance(inProps)\n } else {\n return renderSpatialReactComponent(inProps, ref)\n }\n }\n}\n\nexport const SpatialReactComponent = forwardRef(SpatialReactComponentRefactor)\n\nSpatialReactComponent.displayName = 'SpatialReactComponent'\n","// Redirect to empty module for treeshaking\nexport default {}\n\nexport const SpatialHelper = {}\n\nexport class Spatial {\n /**\n * Requests a session object from the browser\n * @returns The session or null if not availible in the current browser\n * [TODO] discuss implications of this not being async\n */\n requestSession() {\n return null\n }\n /**\n * @returns true if web spatial is supported by this webpage\n */\n isSupported() {\n return false\n }\n /**\n * Gets the native version, format is \"x.x.x\"\n * @returns native version string\n */\n getNativeVersion() {\n return null\n }\n /**\n * Gets the client version, format is \"x.x.x\"\n * @returns client version string\n */\n getClientVersion() {\n return null\n }\n}\n\nexport const version = undefined // no runtime so this should set undefined\n","import { Spatial, SpatialSession } from '@webspatial/core-sdk'\n// Create the default Spatial session for the app\nlet spatial: Spatial | null = null\nlet _currentSession: SpatialSession | null = null\n/** @hidden */\nexport function getSession() {\n if (!spatial) {\n spatial = new Spatial()\n }\n if (!spatial.isSupported()) {\n return null\n }\n if (_currentSession) {\n return _currentSession\n }\n _currentSession = spatial.requestSession()\n return _currentSession\n}\n\nexport { spatial }\n","import { getSession } from './getSession'\n\nasync function getStat() {\n const statsInfo = await getSession()!._getStats()\n\n return statsInfo\n}\n\nfunction simplifyEntityTree(rootTree: any) {\n const rootEntity = Object.values(rootTree.childEntities)[0]\n\n function traverseTree(node: any, parent: any, callback: any) {\n callback(node, parent)\n\n const childrenNodes = Object.values(node.childEntities)\n if (childrenNodes) {\n childrenNodes.forEach(child => {\n traverseTree(child, node, callback)\n })\n }\n }\n\n let rootNode\n const nodeMap: Record<string, any> = {}\n function visitNode(node: any, parent: any) {\n let newNode = {\n id: node.id,\n name: node.name,\n children: [],\n position: node.position,\n scale: node.scale,\n width: node.components[0].resolutionX,\n height: node.components[0].resolutionY,\n zIndex: node.zIndex,\n visible: node.visible,\n cornerRadius: node.components[0].cornerRadius,\n backgroundMaterial: node.components[0].backgroundMaterial,\n isOpaque: node.components[0].isOpaque,\n isScrollEnabled: node.components[0].isScrollEnabled,\n scrollWithParent: node.components[0].scrollWithParent,\n }\n nodeMap[node.id] = newNode\n\n if (!parent) {\n rootNode = newNode\n } else {\n const parentNode = nodeMap[parent.id]\n parentNode.children.push(newNode)\n }\n }\n\n traverseTree(rootEntity, null, visitNode)\n console.log('rootNode', rootNode)\n return rootNode\n}\n\nasync function inspectRootWindowContainer(simple?: boolean) {\n const rootWindowContainerInfo =\n await getSession()!._inspectRootWindowContainer()\n console.log(rootWindowContainerInfo)\n\n if (simple) {\n return simplifyEntityTree(rootWindowContainerInfo)\n }\n return rootWindowContainerInfo\n}\n\nexport function enableDebugTool() {\n const session = getSession()\n Object.assign(window, {\n session,\n getStat,\n inspectRootWindowContainer,\n })\n}\n","import React, {\n CSSProperties,\n useRef,\n ReactNode,\n useLayoutEffect,\n useEffect,\n useContext,\n forwardRef,\n} from 'react'\nimport { useForceUpdate } from '../hooks/useForceUpdate'\nimport { SpatialIsStandardInstanceContext } from './SpatialIsStandardInstanceContext'\nimport { SpatialReactContext } from './SpatialReactContext'\nimport { SpatialReactComponentRef } from './types'\n\nfunction useDetectDomRectChange() {\n const ref = useRef<HTMLElement>(null)\n\n const forceUpdate = useForceUpdate()\n\n const spatialReactContextObject = useContext(SpatialReactContext)\n\n useLayoutEffect(() => {\n ref.current && spatialReactContextObject?.notifyDomChange(ref.current)\n })\n\n // listen to webview container size change and notifyDomChange\n // document.body.clientWidth may change as page loads.\n // when creating a new scene, clientWidth changes from 0 to some positive value.\n // this cannot be detected by ResizeObserver which only observe the dom element itself\n useEffect(() => {\n if (!ref.current || !spatialReactContextObject) {\n console.warn(\n 'Ref is not attached to the DOM or spatialReactContextObject is not available',\n )\n return\n }\n\n const handleResize = () => {\n forceUpdate()\n }\n\n window.addEventListener('resize', handleResize)\n\n return () => {\n window.removeEventListener('resize', handleResize)\n }\n }, [spatialReactContextObject])\n\n // detect dom resize\n // Trigger native resize on web resize events\n useEffect(() => {\n if (!ref.current) {\n console.warn('Ref is not attached to the DOM')\n return\n }\n\n let ro = new ResizeObserver(elements => {\n forceUpdate()\n })\n\n ro.observe(ref.current!)\n return () => {\n ro.disconnect()\n }\n }, [])\n\n // detect dom style and class change\n useEffect(() => {\n if (!ref.current) {\n console.warn('Ref is not attached to the DOM')\n return\n }\n let ro = new MutationObserver(elements => {\n forceUpdate()\n })\n ro.observe(ref.current!, {\n attributeFilter: ['class', 'style'],\n subtree: true,\n })\n return () => {\n ro.disconnect()\n }\n }, [])\n\n return ref\n}\n\ninterface StandardInstanceProps {\n El: React.ElementType\n children?: ReactNode\n style?: CSSProperties | undefined\n\n // for debug\n debugShowStandardInstance?: boolean\n}\nexport const StandardInstance = forwardRef(function (\n inProps: StandardInstanceProps,\n refIn: SpatialReactComponentRef,\n) {\n const { El, style: inStyle, debugShowStandardInstance, ...props } = inProps\n const extraStyle = {\n visibility: debugShowStandardInstance ? undefined : 'hidden',\n transition: 'none',\n }\n const style = { ...inStyle, ...extraStyle }\n\n var ref = useDetectDomRectChange()\n\n const proxyRef = new Proxy<typeof ref>(ref, {\n get(target, prop, receiver) {\n return Reflect.get(target, prop, receiver)\n },\n set(target, prop, value, receiver) {\n if (prop === 'current') {\n const domElement = value as HTMLDivElement\n if (refIn) {\n if (typeof refIn === 'function') {\n refIn(domElement)\n } else {\n refIn.current = domElement\n }\n }\n }\n return Reflect.set(target, prop, value, receiver)\n },\n })\n\n return (\n <SpatialIsStandardInstanceContext.Provider value={true}>\n <El data-standardinstance ref={proxyRef} style={style} {...props} />\n </SpatialIsStandardInstanceContext.Provider>\n )\n})\n\nStandardInstance.displayName = 'StandardInstance'\n","import { useState } from 'react'\n\nexport function useForceUpdate() {\n const [, setToggle] = useState(false)\n return () => setToggle(toggle => !toggle)\n}\n","import { createContext } from 'react'\n\nexport const SpatialIsStandardInstanceContext = createContext(\n null as null | boolean,\n)\n","import { createContext } from 'react'\nimport { SpatialID } from './const'\n\nexport class SpatialReactContextObject {\n debugName: string\n\n constructor(debugName: string) {\n this.debugName = debugName\n }\n\n dom: HTMLElement | null = null\n domSpatialId: string | null = null\n\n private fns: Record<string, () => void> = {}\n // cache dom for each spatialId\n private spatialId2dom: Record<string, HTMLElement> = {}\n private spatialId2parentSpatialDom: Record<string, HTMLElement> = {}\n\n // layer : [standardInstance sequence, portalInstance sequence]\n private layerSequences: Record<number, [number, number]> = {}\n\n public getSpatialID(\n layer: number,\n isInStandardInstance: boolean,\n debugName: string = '',\n ): string {\n if (this.layerSequences[layer] === undefined) {\n this.layerSequences[layer] = [0, 0]\n }\n const idx = isInStandardInstance ? 0 : 1\n const sequenceId = this.layerSequences[layer][idx]\n this.layerSequences[layer][idx] = sequenceId + 1\n const spatialId = `${debugName}_${layer}_${sequenceId}`\n\n return spatialId\n }\n\n public onDomChange(spatialId: string, fn: () => void) {\n this.fns[spatialId] = fn\n if (this.dom) {\n fn()\n }\n }\n\n public offDomChange(spatialId: string) {\n delete this.fns[spatialId]\n delete this.spatialId2dom[spatialId]\n delete this.spatialId2parentSpatialDom[spatialId]\n }\n\n public notifyDomChange(dom: HTMLElement) {\n this.dom = dom\n this.domSpatialId = dom.getAttribute(SpatialID)\n Object.values(this.fns).forEach(fn => fn())\n }\n\n public querySpatialDom(spatialId: string) {\n if (this.domSpatialId === spatialId) {\n return this.dom\n }\n if (!this.dom) {\n return null\n }\n if (!this.spatialId2dom[spatialId]) {\n const spatialDom = this.dom.querySelector(`[${SpatialID}=\"${spatialId}\"]`)\n\n if (spatialDom) {\n this.spatialId2dom[spatialId] = spatialDom as HTMLElement\n }\n }\n return this.spatialId2dom[spatialId]\n }\n\n public queryParentSpatialDom(spatialId: string) {\n if (this.domSpatialId === spatialId) {\n return null\n }\n\n if (this.spatialId2parentSpatialDom[spatialId]) {\n // early return if already found\n return this.spatialId2parentSpatialDom[spatialId]\n }\n\n let spatialDom = this.querySpatialDom(spatialId)\n if (spatialDom) {\n if (spatialDom === this.dom) return null\n let parentSpatialDom = spatialDom.parentElement as HTMLElement\n while (parentSpatialDom && spatialDom !== this.dom) {\n if (parentSpatialDom.hasAttribute(SpatialID)) {\n break\n } else {\n parentSpatialDom = parentSpatialDom.parentElement as HTMLElement\n }\n }\n\n this.spatialId2parentSpatialDom[spatialId] = parentSpatialDom\n return parentSpatialDom\n }\n return null\n }\n\n // Used for CSSModel3D\n // layer : [standardInstance sequence, portalInstance sequence]\n private subDivLayerSequences: Record<number, [number, number]> = {}\n private subDivEventHandlers: Record<string, (args: any) => void> = {}\n\n public getSubDivSpatialID(\n layer: number,\n isInStandardInstance: boolean,\n prefix: string = '',\n ): string {\n if (this.subDivLayerSequences[layer] === undefined) {\n this.subDivLayerSequences[layer] = [0, 0]\n }\n const idx = isInStandardInstance ? 0 : 1\n const sequenceId = this.subDivLayerSequences[layer][idx]\n this.subDivLayerSequences[layer][idx] = sequenceId + 1\n const spatialId = `${prefix}_${layer}_${sequenceId}`\n\n return spatialId\n }\n\n public onSubDivEvent(\n subSpatialId: string,\n eventHandler: (args: any) => void,\n ) {\n this.subDivEventHandlers[subSpatialId] = eventHandler\n }\n\n public offSubDivEvent(subSpatialId: string) {\n delete this.subDivEventHandlers[subSpatialId]\n }\n public notifySubDivEvent(subSpatialId: string, args: any) {\n const eventHandler = this.subDivEventHandlers[subSpatialId]\n if (eventHandler) {\n eventHandler(args)\n }\n }\n}\n\nexport const SpatialReactContext =\n createContext<SpatialReactContextObject | null>(null)\n","export const SpatialID = 'data-spatial-id'\n","import React, {\n CSSProperties,\n useRef,\n ReactNode,\n useCallback,\n useEffect,\n useState,\n useContext,\n useMemo,\n} from 'react'\nimport { createPortal } from 'react-dom'\nimport { usePortalContainer } from './usePortalContainer'\nimport { SpatialWindowManagerContext } from './SpatialWindowManagerContext'\nimport { SpatialWindowManager } from './SpatialWindowManager'\n\nimport {\n domRect2rectType,\n getInheritedStyleProps,\n parseCornerRadius,\n parseTransformOrigin,\n} from './utils'\nimport { SpatialReactContext } from './SpatialReactContext'\nimport { SpatialID } from './const'\nimport { SpatialDebugNameContext } from './SpatialDebugNameContext'\nimport { CornerRadius } from '@webspatial/core-sdk'\nimport { RectType, vecType } from '../types'\nimport { spatialStyleDef } from './types'\nimport { XRApp } from '../../XRApp'\n\ninterface PortalInstanceProps {\n allowScroll?: boolean\n scrollWithParent?: boolean\n spatialStyle?: Partial<spatialStyleDef>\n\n El: React.ElementType\n children?: ReactNode\n style?: CSSProperties | undefined\n className?: string\n\n isSubPortal: boolean\n\n [SpatialID]: string\n}\n\nfunction renderJSXPortalInstance(\n inProps: Omit<\n PortalInstanceProps,\n 'allowScroll' | 'scrollWithParent' | 'spatialStyle' | 'isSubPortal'\n >,\n\n inheritedPortalStyle: CSSProperties,\n className: string,\n) {\n const { El, style: inStyle = {}, className: _, ...props } = inProps\n const extraStyle = {\n visibility: 'visible',\n position: '',\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 }\n\n const style = {\n ...inStyle,\n ...inheritedPortalStyle,\n ...extraStyle,\n }\n\n return <El style={style} className={className} {...props} />\n}\n\nfunction setOpenWindowStyle(openedWindow: Window) {\n openedWindow!.document.documentElement.style.cssText +=\n document.documentElement.style.cssText\n\n openedWindow!.document.documentElement.style.backgroundColor = 'transparent'\n openedWindow!.document.body.style.margin = '0px'\n}\n\nfunction handleOpenWindowDocumentClick(openedWindow: Window) {\n // Overwrite link href to navigate the parents page\n openedWindow!.document.onclick = function (e) {\n let element = e.target as HTMLElement | null\n let found = false\n\n // Look for <a> element in the clicked elements parents and if found override navigation behavior if needed\n while (!found) {\n if (element && element.tagName == 'A') {\n // When using libraries like react route's <Link> it sets an onclick event, when this happens we should do nothing and let that occur\n\n // if onClick is set for the element, the raw onclick will be noop() trapped so the onclick check is no longer trustable\n // we handle all the scenarios\n XRApp.getInstance().handleATag(e)\n return false // prevent default action and stop event propagation\n }\n if (element && element.parentElement) {\n element = element.parentElement\n } else {\n break\n }\n }\n }\n}\n\nfunction asyncLoadStyleToChildWindow(\n childWindow: WindowProxy,\n n: HTMLLinkElement,\n debugName: string,\n) {\n return new Promise(resolve => {\n // Safari seems to have a bug where\n // ~1/50 loads, if the same url is loaded very quickly in a window and a child window,\n // the second load request never is fired resulting in css not to be applied.\n // Workaround this by making the css stylesheet request unique\n n.href += '?uniqueURL=' + Math.random()\n n.onerror = function () {\n console.error(\n 'Failed to load style link',\n debugName,\n (n as HTMLLinkElement).href,\n )\n resolve(false)\n }\n n.onload = function () {\n resolve(true)\n }\n\n childWindow.document.head.appendChild(n)\n })\n}\n\nasync function syncParentHeadToChild(\n childWindow: WindowProxy,\n debugName: string,\n) {\n const styleLoadedPromises = []\n\n for (let i = 0; i < document.head.children.length; i++) {\n let n = document.head.children[i].cloneNode(true)\n if (\n n.nodeName == 'LINK' &&\n (n as HTMLLinkElement).rel == 'stylesheet' &&\n (n as HTMLLinkElement).href\n ) {\n const promise = asyncLoadStyleToChildWindow(\n childWindow,\n n as HTMLLinkElement,\n debugName,\n )\n styleLoadedPromises.push(promise)\n } else {\n childWindow.document.head.appendChild(n)\n }\n }\n\n if (debugName) {\n childWindow.document.title = debugName\n }\n\n // sync className\n childWindow.document.documentElement.className =\n document.documentElement.className\n\n return Promise.all(styleLoadedPromises)\n}\n\nasync function syncHeaderStyle(openedWindow: Window, debugName: string) {\n // Synchronize head of parent page to this page to ensure styles are in sync\n await syncParentHeadToChild(openedWindow, debugName)\n\n const headObserver = new MutationObserver(mutations => {\n syncParentHeadToChild(openedWindow, debugName)\n })\n\n headObserver.observe(document.head, { childList: true, subtree: true })\n\n return headObserver\n}\n\nfunction syncDefaultSpatialStyle(openedWindow: Window, debugName: string) {\n const styleElement = document.createElement('style')\n styleElement.type = 'text/css'\n styleElement.innerHTML =\n ' .xr-spatial-default { --xr-back: 0.001; --xr-background-material: none } '\n openedWindow.document.head.appendChild(styleElement)\n // openedWindow body's width and height should be set to inline-block to make sure the width and height are correct\n openedWindow.document.body.style.display = 'inline-block'\n openedWindow.document.body.style.minWidth = 'auto'\n openedWindow.document.body.style.minHeight = 'auto'\n openedWindow.document.body.style.maxWidth = 'fit-content'\n openedWindow.document.body.style.minWidth = 'fit-content'\n}\n\nfunction useSyncSpatialProps(\n spatialWindowManager: SpatialWindowManager | undefined,\n props: Pick<\n PortalInstanceProps,\n 'style' | 'allowScroll' | 'scrollWithParent' | 'spatialStyle'\n >,\n domRect: RectType,\n anchor: vecType,\n cornerRadiusFromStyle: CornerRadius,\n opacity: number,\n stylePosition: string | undefined,\n isSubPortal: boolean,\n) {\n let { allowScroll, scrollWithParent, style, spatialStyle = {} } = props\n let {\n position = { x: 0, y: 0, z: 0 },\n rotation = { x: 0, y: 0, z: 0, w: 1 },\n scale = { x: 1, y: 1, z: 1 },\n material = { type: 'none' },\n cornerRadius = cornerRadiusFromStyle,\n zIndex = 0,\n } = spatialStyle\n\n let styleOverflow = style?.overflow\n\n const visible = useMemo(() => {\n return (\n spatialStyle.visible !== false && domRect.width > 0 && domRect.height > 0\n )\n }, [spatialStyle.visible, domRect.width, domRect.height])\n\n // fill default values for position\n if (position.x === undefined) position.x = 0\n if (position.y === undefined) position.y = 0\n if (position.z === undefined) position.z = 1\n\n // fill default values for scale\n if (scale.x === undefined) scale.x = 1\n if (scale.y === undefined) scale.y = 1\n if (scale.z === undefined) scale.z = 1\n\n // fill cornerRadius Object\n const cornerRadiusObject: CornerRadius = {\n topLeading: 0,\n bottomLeading: 0,\n topTrailing: 0,\n bottomTrailing: 0,\n }\n if (typeof cornerRadius == 'number') {\n cornerRadiusObject.topLeading = cornerRadius\n cornerRadiusObject.bottomLeading = cornerRadius\n cornerRadiusObject.topTrailing = cornerRadius\n cornerRadiusObject.bottomTrailing = cornerRadius\n } else {\n Object.assign(cornerRadiusObject, cornerRadius)\n }\n\n const isFixedPosition = stylePosition == 'fixed'\n useEffect(() => {\n if (spatialWindowManager && spatialWindowManager.webview) {\n spatialWindowManager.updateCSSPosition(isFixedPosition)\n }\n }, [spatialWindowManager, isFixedPosition])\n\n // Sync prop updates\n useEffect(() => {\n if (spatialWindowManager && spatialWindowManager.webview) {\n const webview = spatialWindowManager.webview\n ;(async function () {\n webview.setStyle({\n material: { type: material.type },\n cornerRadius: cornerRadiusObject,\n })\n })()\n }\n }, [\n spatialWindowManager,\n material.type,\n cornerRadiusObject.topLeading,\n cornerRadiusObject.bottomLeading,\n cornerRadiusObject.topTrailing,\n cornerRadiusObject.bottomTrailing,\n ])\n\n useEffect(() => {\n if (spatialWindowManager && spatialWindowManager.webview) {\n const webview = spatialWindowManager.webview\n ;(async function () {\n webview.setScrollEnabled(allowScroll || styleOverflow == 'scroll')\n\n const isFixed = scrollWithParent == false || isFixedPosition\n webview.setScrollWithParent(!isFixed)\n })()\n }\n }, [\n spatialWindowManager,\n allowScroll,\n scrollWithParent,\n isFixedPosition,\n styleOverflow,\n ])\n\n useEffect(() => {\n if (spatialWindowManager && spatialWindowManager.webview) {\n const webview = spatialWindowManager.webview\n ;(async function () {\n webview.setScrollEnabled(allowScroll || styleOverflow == 'scroll')\n\n const isFixed = scrollWithParent == false || stylePosition == 'fixed'\n webview.setScrollWithParent(!isFixed)\n })()\n }\n }, [spatialWindowManager, allowScroll, scrollWithParent, stylePosition])\n\n useEffect(() => {\n if (spatialWindowManager) {\n ;(async function () {\n await spatialWindowManager.resize(\n domRect,\n position as vecType,\n rotation,\n scale as vecType,\n anchor,\n isSubPortal ? 0 : window.scrollY,\n )\n\n spatialWindowManager?.setZIndex(zIndex)\n })()\n }\n }, [\n spatialWindowManager,\n domRect.x,\n domRect.y,\n domRect.width,\n domRect.height,\n position,\n rotation,\n scale,\n anchor,\n zIndex,\n ])\n\n useEffect(() => {\n if (spatialWindowManager && spatialWindowManager.webview) {\n const webview = spatialWindowManager.webview\n webview.setOpacity(opacity)\n }\n }, [spatialWindowManager, opacity])\n\n useEffect(() => {\n if (spatialWindowManager) {\n spatialWindowManager.entity?.setVisible(visible)\n }\n }, [spatialWindowManager, visible])\n\n useEffect(() => {\n // sync viewport\n if (spatialWindowManager?.window && spatialWindowManager.webview) {\n ;(async function () {\n const bodyWidth = document.body.getBoundingClientRect().width\n const viewport = spatialWindowManager.window?.document.querySelector(\n 'meta[name=\"viewport\"]',\n )\n viewport?.setAttribute(\n 'content',\n `width=${bodyWidth}, initial-scale=1.0 user-scalable=no`,\n )\n await spatialWindowManager.webview?.setScrollEdgeInsets({\n top: 0,\n left: 0,\n bottom: 0,\n right: domRect.width - bodyWidth,\n })\n })()\n }\n }, [spatialWindowManager, domRect.width])\n}\n\nfunction useSyncDomRect(spatialId: string) {\n const [domRect, setDomRect] = useState({\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n })\n\n const inheritedPortalStyleRef = useRef<CSSProperties>({})\n\n const anchorRef = useRef({\n x: 0.5,\n y: 0.5,\n z: 0.5,\n })\n\n const cornerRadiusRef = useRef({\n topLeading: 0,\n bottomLeading: 0,\n topTrailing: 0,\n bottomTrailing: 0,\n })\n\n const opacityRef = useRef(1.0)\n\n const spatialReactContextObject = useContext(SpatialReactContext)\n\n const inheritedPortalClassNameRef = useRef('')\n\n useEffect(() => {\n const syncDomRect = () => {\n const dom = spatialReactContextObject?.querySpatialDom(spatialId)\n\n if (!dom) {\n return\n }\n\n const computedStyle = getComputedStyle(dom)\n inheritedPortalStyleRef.current = getInheritedStyleProps(computedStyle)\n\n const stylePosition = inheritedPortalStyleRef.current.position\n const isFixedPosition = stylePosition === 'fixed'\n\n let domRect = dom.getBoundingClientRect()\n let rectType = domRect2rectType(domRect)\n\n if (!isFixedPosition) {\n const parentDom =\n spatialReactContextObject?.queryParentSpatialDom(spatialId)\n if (parentDom) {\n const parentDomRect = parentDom.getBoundingClientRect()\n const parentRectType = domRect2rectType(parentDomRect)\n rectType.x -= parentRectType.x\n rectType.y -= parentRectType.y\n }\n }\n\n const anchor = parseTransformOrigin(computedStyle)\n anchorRef.current = anchor\n\n const cornerRadius = parseCornerRadius(computedStyle)\n cornerRadiusRef.current = cornerRadius\n\n const opacity = parseFloat(computedStyle.getPropertyValue('opacity'))\n opacityRef.current = opacity\n\n inheritedPortalClassNameRef.current = dom.className\n\n setDomRect(rectType)\n }\n\n spatialReactContextObject?.onDomChange(spatialId, syncDomRect)\n\n return () => {\n spatialReactContextObject?.offDomChange(spatialId)\n }\n }, [])\n\n return {\n domRect,\n inheritedPortalStyle: inheritedPortalStyleRef.current,\n anchor: anchorRef.current,\n cornerRadius: cornerRadiusRef.current,\n opacity: opacityRef.current,\n className: inheritedPortalClassNameRef.current,\n }\n}\n\nexport function PortalInstance(inProps: PortalInstanceProps) {\n const { allowScroll, scrollWithParent, spatialStyle, isSubPortal, ...props } =\n inProps\n\n const debugName = useContext(SpatialDebugNameContext)\n\n const onContainerSpawned = useCallback(\n async (spatialWindowManager: SpatialWindowManager) => {\n const openWindow = spatialWindowManager.window!\n setOpenWindowStyle(openWindow)\n handleOpenWindowDocumentClick(openWindow)\n\n syncDefaultSpatialStyle(openWindow, debugName)\n\n const headObserver = await syncHeaderStyle(openWindow, debugName)\n const spawnedResult = {\n headObserver,\n }\n\n spatialWindowManager.setDebugName(debugName)\n\n return spawnedResult\n },\n [],\n )\n\n const onContainerDestroyed = useCallback(\n (spatialWindowManager: SpatialWindowManager, spawnedResult: any) => {\n const { headObserver } = spawnedResult\n headObserver.disconnect()\n },\n [],\n )\n\n const [spatialWindowManager] = usePortalContainer({\n onContainerSpawned,\n onContainerDestroyed,\n })\n\n const spatialId = props[SpatialID]\n\n const {\n domRect,\n inheritedPortalStyle,\n anchor,\n cornerRadius,\n opacity,\n className,\n } = useSyncDomRect(spatialId)\n\n useSyncSpatialProps(\n spatialWindowManager,\n {\n style: props.style,\n allowScroll,\n scrollWithParent,\n spatialStyle,\n },\n domRect,\n anchor,\n cornerRadius,\n opacity,\n inheritedPortalStyle.position,\n isSubPortal,\n )\n\n const JSXPortalInstance = renderJSXPortalInstance(\n props,\n inheritedPortalStyle,\n className,\n )\n\n const needRenderPlaceHolder =\n isSubPortal &&\n inheritedPortalStyle.position !== 'absolute' &&\n inheritedPortalStyle.position !== 'fixed'\n\n const El = props.El\n\n return (\n <SpatialWindowManagerContext.Provider value={spatialWindowManager}>\n {needRenderPlaceHolder && (\n <El\n className={className}\n data-subportal-spatialid={spatialId}\n style={{\n position: 'relative',\n width: `${domRect.width}px`,\n height: `${domRect.height}px`,\n visibility: 'hidden',\n display: inheritedPortalStyle.display,\n }}\n />\n )}\n {spatialWindowManager &&\n spatialWindowManager.window &&\n createPortal(\n JSXPortalInstance,\n spatialWindowManager.window.document.body,\n )}\n </SpatialWindowManagerContext.Provider>\n )\n}\n\nPortalInstance.displayName = 'PortalInstance'\n","import { useContext, useRef, useEffect } from 'react'\nimport { SpatialIsStandardInstanceContext } from './SpatialIsStandardInstanceContext'\nimport { getSession } from '../../utils/getSession'\nimport { SpatialWindowManager } from './SpatialWindowManager'\nimport { SpatialWindowManagerContext } from './SpatialWindowManagerContext'\nimport { useForceUpdate } from '../hooks/useForceUpdate'\n\ntype PortalContainerOption = {\n onContainerSpawned: (\n spatialWindowManager: SpatialWindowManager,\n ) => Promise<any>\n onContainerDestroyed: (\n spatialWindowManager: SpatialWindowManager,\n spawnedResult: any,\n ) => void\n}\n\nexport function usePortalContainer(options: PortalContainerOption) {\n const isStandard = useContext(SpatialIsStandardInstanceContext) // Spatial components render both a standard (hidden) and spatial instance (displayed), this prop lets us know which context we are in\n const parentSpatialWindowManager = useContext(SpatialWindowManagerContext)\n\n const forceUpdate = useForceUpdate()\n\n const spatialWindowManagerRef = useRef<SpatialWindowManager>()\n\n useEffect(() => {\n let isDestroyed = false\n let spawnedResult: any\n\n async function asyncCreatePortalContainer() {\n const session = getSession()!\n // session?.log(\"TREVORX \" + props.debugName + \" \" + (parentSpatialReactComponent !== null ? \"hasParent\" : \"NoParent\"))\n\n // Create spatial window\n let windowMgr = new SpatialWindowManager({\n parentSpatialWindowManager: parentSpatialWindowManager || undefined,\n })\n await windowMgr.initFromWidow()\n\n if (isDestroyed) {\n windowMgr.destroy()\n return\n }\n\n spawnedResult = await options.onContainerSpawned(windowMgr)\n if (isDestroyed) {\n options.onContainerDestroyed(windowMgr, spawnedResult)\n windowMgr.destroy()\n return\n }\n\n spatialWindowManagerRef.current = windowMgr\n forceUpdate()\n }\n\n if (isStandard !== true) {\n asyncCreatePortalContainer()\n }\n\n return () => {\n isDestroyed = true\n const spatialWindowManager = spatialWindowManagerRef.current\n\n if (spatialWindowManager) {\n options.onContainerDestroyed(spatialWindowManager, spawnedResult)\n spatialWindowManager.destroy()\n }\n }\n }, [])\n\n return [spatialWindowManagerRef.current]\n}\n","import { SpatialEntity, SpatialWindowComponent } from '@webspatial/core-sdk'\nimport { getSession } from '../../utils'\nimport { vecType, quatType, RectType } from '../types'\n\n// Manager classes to handle resource creation/deletion\nexport class SpatialWindowManager {\n initPromise?: Promise<any>\n entity?: SpatialEntity\n webview?: SpatialWindowComponent\n window: WindowProxy | null = null\n\n private parentSpatialWindowManager?: SpatialWindowManager\n private isFixedPosition: boolean\n\n constructor(options: {\n parentSpatialWindowManager?: SpatialWindowManager\n isFixedPosition?: boolean\n }) {\n this.isFixedPosition = options.isFixedPosition || false\n this.parentSpatialWindowManager = options.parentSpatialWindowManager\n }\n\n setDebugName(debugName: string) {\n this.entity?._setName(debugName)\n }\n\n private async initInternal(url: string) {\n this.entity = await getSession()!.createEntity()\n this.webview = await getSession()!.createWindowComponent()\n await this.webview.loadURL(url)\n await this.entity.setCoordinateSpace('Dom')\n await this.webview.setScrollWithParent(true)\n await this.webview.setScrollEnabled(false)\n await this.entity.setComponent(this.webview)\n\n var wc = await getSession()!.getCurrentWindowComponent()\n var ent = await wc.getEntity()\n await this.entity.setParent(ent!)\n }\n\n private async initInternalFromWindow() {\n var w = await getSession()!.createWindowContext()\n this.window = w\n this.entity = await getSession()!.createEntity()\n this.webview = await getSession()!.createWindowComponent()\n await this.webview.setFromWindow(w)\n await this.entity.setCoordinateSpace('Dom')\n await this.webview.setScrollWithParent(true)\n await this.webview.setScrollEnabled(false)\n await this.entity.setComponent(this.webview)\n\n this.setEntityParentByCSSPosition(this.isFixedPosition)\n }\n\n async updateCSSPosition(isFixedPosition: boolean) {\n if (this.isFixedPosition === isFixedPosition) {\n return\n } else {\n this.isFixedPosition = isFixedPosition\n }\n return this.setEntityParentByCSSPosition(isFixedPosition)\n }\n\n private async setEntityParentByCSSPosition(isFixedPosition: boolean) {\n if (this.initPromise) {\n await this.initPromise\n if (isFixedPosition || !this.parentSpatialWindowManager) {\n // Add as a child of the current page\n var wc = await getSession()!.getCurrentWindowComponent()\n var ent = await wc.getEntity()\n await this.entity!.setParent(ent!)\n } else {\n const parentSpatialWindowManager = this.parentSpatialWindowManager!\n // Add as a child of the parent\n await parentSpatialWindowManager.initPromise\n this.entity!.setParent(parentSpatialWindowManager.entity!)\n }\n }\n }\n\n async init(url: string) {\n this.initPromise = this.initInternal(url)\n await this.initPromise\n }\n async initFromWidow() {\n this.initPromise = this.initInternalFromWindow()\n await this.initPromise\n }\n async resize(\n rect: RectType,\n offset: vecType,\n rotation: quatType = { x: 0, y: 0, z: 0, w: 1 },\n scale: vecType = { x: 1, y: 1, z: 1 },\n rotationOrigin: vecType = { x: 0, y: 0, z: 0 },\n parrentOffset: number = 0,\n ) {\n let targetPosX = rect.x + rect.width / 2\n // Adjust to get the page relative to document instead of viewport\n // This is needed as when you scroll down the page the rect.top moves but we dont want it to so we can offset that by adding scroll\n let targetPosY = rect.y + rect.height / 2 + parrentOffset\n\n if (!this.webview) {\n return\n }\n var entity = this.entity!\n entity.transform.position.x = targetPosX + (offset ? offset.x : 0)\n entity.transform.position.y = targetPosY + (offset ? offset.y : 0)\n entity.transform.position.z = offset ? offset.z : 0\n\n entity.transform.orientation.x = rotation.x\n entity.transform.orientation.y = rotation.y\n entity.transform.orientation.z = rotation.z\n entity.transform.orientation.w = rotation.w\n\n entity.transform.scale.x = scale.x\n entity.transform.scale.y = scale.y\n entity.transform.scale.z = scale.z\n\n await entity.updateTransform()\n\n var webview = this.webview!\n await webview.setResolution(rect.width, rect.height)\n\n await webview.setRotationAnchor(rotationOrigin)\n }\n\n async setZIndex(zIndex: number) {\n let entity = this.entity!\n entity.updateZIndex(zIndex)\n }\n\n async destroy() {\n if (this.initPromise) {\n await this.initPromise\n this.entity?.destroy()\n this.webview?.destroy()\n this.window = null\n }\n }\n}\n","import { createContext } from 'react'\nimport { SpatialWindowManager } from './SpatialWindowManager'\n\nexport const SpatialWindowManagerContext = createContext<\n SpatialWindowManager | undefined | null\n>(null)\n","import { RectType } from '../types'\n\nexport function getInheritedStyleProps(\n computedStyle: CSSStyleDeclaration,\n): any {\n //https://stackoverflow.com/questions/5612302/which-css-properties-are-inherited\n var propNames = [\n 'azimuth',\n 'borderCollapse',\n 'borderSpacing',\n 'captionSide',\n 'color',\n 'cursor',\n 'direction',\n 'elevation',\n 'emptyCells',\n 'fontFamily',\n 'fontSize',\n 'fontStyle',\n 'fontVariant',\n 'fontWeight',\n 'font',\n 'letterSpacing',\n 'lineHeight',\n 'listStyleImage',\n 'listStylePosition',\n 'listStyleType',\n 'listStyle',\n 'orphans',\n 'pitchRange',\n 'pitch',\n 'quotes',\n 'richness',\n 'speakHeader',\n 'speakNumeral',\n 'speakPunctuation',\n 'speak',\n 'speechRate',\n 'stress',\n 'textAlign',\n 'textIndent',\n 'textTransform',\n 'visibility',\n 'voiceFamily',\n 'volume',\n 'whiteSpace',\n 'widows',\n 'wordSpacing',\n // background also need to be synced\n 'background',\n // position also need to be synced\n 'position',\n\n 'width',\n 'height',\n\n 'display',\n ]\n var props = {} as any\n for (var cssName of propNames) {\n if ((computedStyle as any)[cssName]) {\n props[cssName] = (computedStyle as any)[cssName]\n }\n }\n return props\n}\n\nexport function domRect2rectType(from: DOMRect): RectType {\n return {\n x: from.x,\n y: from.y,\n width: from.width,\n height: from.height,\n }\n}\n\nexport function parseTransformOrigin(computedStyle: CSSStyleDeclaration) {\n const transformOriginProperty =\n computedStyle.getPropertyValue('transform-origin')\n const [x, y] = transformOriginProperty.split(' ').map(parseFloat)\n const width = parseFloat(computedStyle.getPropertyValue('width'))\n const height = parseFloat(computedStyle.getPropertyValue('height'))\n\n return {\n x: width > 0 ? x / width : 0.5,\n y: height > 0 ? y / height : 0.5,\n z: 0.5,\n }\n}\n\nfunction parseBorderRadius(borderProperty: string, width: number) {\n if (borderProperty === '') {\n return 0\n }\n if (borderProperty.endsWith('%')) {\n return (width * parseFloat(borderProperty)) / 100\n }\n return parseFloat(borderProperty)\n}\n\nexport function parseCornerRadius(computedStyle: CSSStyleDeclaration) {\n const width = parseFloat(computedStyle.getPropertyValue('width'))\n\n const topLeftPropertyValue = computedStyle.getPropertyValue(\n 'border-top-left-radius',\n )\n const topRightPropertyValue = computedStyle.getPropertyValue(\n 'border-top-right-radius',\n )\n const bottomLeftPropertyValue = computedStyle.getPropertyValue(\n 'border-bottom-left-radius',\n )\n const bottomRightPropertyValue = computedStyle.getPropertyValue(\n 'border-bottom-right-radius',\n )\n\n const cornerRadius = {\n topLeading: parseBorderRadius(topLeftPropertyValue, width),\n bottomLeading: parseBorderRadius(bottomLeftPropertyValue, width),\n topTrailing: parseBorderRadius(topRightPropertyValue, width),\n bottomTrailing: parseBorderRadius(bottomRightPropertyValue, width),\n }\n\n return cornerRadius\n}\n","import { createContext } from 'react'\n\nexport const SpatialDebugNameContext = createContext<string>('')\n","import { WindowContainerOptions } from '@webspatial/core-sdk/'\nimport { getSession } from './utils/getSession'\nexport type { WindowContainerOptions }\nexport const defaultSceneConfig: WindowContainerOptions = {\n defaultSize: {\n width: 900,\n height: 700,\n },\n resizability: 'automatic',\n}\n\nconst CONTEXT_WINDOW_URL = 'webspatial://createWindowContext'\nconst originalOpen = window.open\nexport class XRApp {\n private static instance: XRApp\n static getInstance() {\n if (!XRApp.instance) {\n XRApp.instance = new XRApp()\n }\n return XRApp.instance\n }\n\n handleATag(event: MouseEvent) {\n const targetElement = event.target as HTMLElement\n if (targetElement.tagName === 'A') {\n const link = targetElement as HTMLAnchorElement\n const target = link.target\n const url = link.href\n\n if (target && target !== '_self') {\n event.preventDefault()\n window.open(url, target)\n }\n }\n }\n init() {\n ;(window as any).open = this.open\n\n document.addEventListener('click', this.handleATag)\n }\n deinit() {\n ;(window as any).open = originalOpen\n\n document.removeEventListener('click', this.handleATag)\n }\n private configMap: Record<string, WindowContainerOptions> = {} // name=>config\n private getConfig(name?: string) {\n if (name === undefined || !this.configMap[name]) return undefined\n return this.configMap[name]\n }\n\n async show(window: Window, cfg: WindowContainerOptions) {\n try {\n let session = getSession()!\n await session._createScene(\n 'Plain', // only support Plain for now\n {\n sceneData: {\n method: 'showRoot',\n sceneConfig: cfg,\n // url: url,\n window,\n },\n },\n )\n } catch (error) {\n console.error(error)\n }\n }\n open = (url?: string, target?: string, features?: string) => {\n const newWindow = originalOpen(url, target, features)\n if (url === CONTEXT_WINDOW_URL) return newWindow\n // if target is special\n if (target === '_self' || target === '_parent' || target === '_top') {\n return newWindow\n }\n // should open new scene or focus to\n\n // _webSpatialID is assigned for the new webview\n // timer to check _webSpatialID exist\n let cnt = 2\n let timer = setInterval(async () => {\n cnt -= 1\n if (cnt < 0) {\n clearInterval(timer)\n return\n }\n // native should createRoot if it see the windowID for the first time\n // otherwise should focus to\n if ((newWindow as any)._webSpatialID) {\n clearInterval(timer)\n // fixme:\n let session = getSession()\n if (!session) {\n console.error('no session')\n } else {\n const cfg = this.getConfig(target)\n try {\n await session._createScene(\n 'Plain', // only support Plain for now\n {\n sceneData: {\n method: 'createRoot',\n sceneConfig: cfg,\n url: url,\n window: newWindow!,\n // windowID: (newWindow as any)._webSpatialID,\n // windowContainerID: (newWindow as any)._webSpatialGroupID,\n },\n },\n )\n // remove config after use\n if (typeof target === 'string' && this.configMap[target]) {\n delete this.configMap[target]\n }\n } catch (error) {\n console.error(error)\n }\n }\n }\n }, 0)\n return newWindow\n }\n initScene(\n name: string,\n callback: (pre: WindowContainerOptions) => WindowContainerOptions,\n ) {\n this.configMap[name] = callback({ ...defaultSceneConfig })\n }\n}\n","import { createContext } from 'react'\n\n// SpatialLayerContext is used to mark the spatial layer of the spatial div, which is used to help portal instance find the correct layer standard instance div.\nexport const SpatialLayerContext = createContext(0)\n","import React, { forwardRef, Ref } from 'react'\nimport { SpatialMonitor } from './SpatialMonitor'\n\nconst cachedWithSpatialMonitorType = new Map()\n\nexport function withSpatialMonitor(El: React.ElementType) {\n if (cachedWithSpatialMonitorType.has(El)) {\n return cachedWithSpatialMonitorType.get(El)\n } else {\n const WithSpatialMonitorComponent = forwardRef(\n (givenProps: any, givenRef: Ref<any>) => {\n const {\n El: _,\n\n ...props\n } = givenProps\n\n return <SpatialMonitor El={El} {...props} ref={givenRef} />\n },\n )\n WithSpatialMonitorComponent.displayName = `WithSpatialMonitor(${typeof El === 'string' ? El : El.displayName || El.name})`\n\n cachedWithSpatialMonitorType.set(El, WithSpatialMonitorComponent)\n cachedWithSpatialMonitorType.set(\n cachedWithSpatialMonitorType,\n cachedWithSpatialMonitorType,\n )\n return WithSpatialMonitorComponent\n }\n}\n","import { useRef, useEffect, ForwardedRef, useMemo } from 'react'\nimport { notifyDOMUpdate } from '../notifyUpdateStandInstanceLayout'\n\nexport function useMonitorDomChange(inRef: ForwardedRef<HTMLElement>) {\n const ref = useRef<HTMLElement>(null)\n\n useEffect(() => {\n const observer = new MutationObserver(mutationsList => {\n notifyDOMUpdate(mutationsList)\n })\n\n const config = {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['style', 'class'],\n }\n\n ref.current && observer.observe(ref.current, config)\n\n return () => {\n observer.disconnect()\n }\n }, [])\n\n const proxyRef = useMemo(\n () =>\n new Proxy(ref, {\n set: function (target, key, value) {\n if (key === 'current') {\n if (inRef) {\n if (typeof inRef === 'function') {\n inRef(value)\n } else if (inRef) {\n inRef.current = value\n }\n }\n }\n return Reflect.set(target, key, value)\n },\n }),\n [],\n )\n\n return proxyRef\n}\n","export enum SpatialStyleInfoUpdateEvent {\n standInstanceLayout = 'standInstanceLayout',\n domUpdated = 'domUpdated',\n}\n\n/**\n * External-developers can call this function to sync the standardInstance layout to PortalInstance.\n *\n * Currently: notifyUpdateStandInstanceLayout is called when the document head changed\n * or when the monitored div changed (in both cases spatialDiv's layout may be changed, so we need to update the layout)\n */\nexport function notifyUpdateStandInstanceLayout() {\n document.dispatchEvent(\n new CustomEvent(SpatialStyleInfoUpdateEvent.standInstanceLayout, {\n detail: {},\n }),\n )\n}\n\nexport function notifyDOMUpdate(mutationsList: MutationRecord[]) {\n document.dispatchEvent(\n new CustomEvent(SpatialStyleInfoUpdateEvent.domUpdated, {\n detail: mutationsList,\n }),\n )\n}\n","import { useEffect } from 'react'\nimport { notifyUpdateStandInstanceLayout } from '../notifyUpdateStandInstanceLayout'\n\nexport function useMonitorDocumentHeaderChange() {\n useEffect(() => {\n const observer = new MutationObserver(mutationsList => {\n notifyUpdateStandInstanceLayout()\n })\n\n const config = {\n childList: true,\n subtree: true,\n attributes: true,\n }\n\n observer.observe(document.head, config)\n\n return () => {\n observer.disconnect()\n }\n }, [])\n}\n","import { useMonitorDomChange } from './useMonitorDomChange'\nimport { useMonitorDocumentHeaderChange } from './useMonitorDocumentHeaderChange'\nimport { ElementType, ForwardedRef, forwardRef } from 'react'\n\ntype SpatialMonitorProps = {\n El?: ElementType\n}\n\n/**\n * Component that add MutationObserver to monitor all dom changes including its children.\n * If any dom changes, it will notify all SpatialDiv to render again for the purpose of sync standInstance layout to portalInstance.\n */\nfunction SpatialMonitorBase(\n inProps: SpatialMonitorProps,\n inRef: ForwardedRef<HTMLElement>,\n) {\n const { El = 'div', ...props } = inProps\n const ref = useMonitorDomChange(inRef)\n useMonitorDocumentHeaderChange()\n\n return <El {...props} ref={ref} />\n}\n\nexport const SpatialMonitor = forwardRef(SpatialMonitorBase)\n","import React, { forwardRef, Ref } from 'react'\nimport { primitives } from '../primitives'\nimport { CSSSpatialComponent } from './CSSSpatialComponent'\n\nconst cachedWithCSSSpatialType = new Map()\n\nexport function withCSSSpatial(Component: React.ElementType) {\n if (cachedWithCSSSpatialType.has(Component)) {\n return cachedWithCSSSpatialType.get(Component)\n } else {\n const WithCSSSpatialComponent = forwardRef(\n (givenProps: any, givenRef: Ref<any>) => {\n const {\n component: ignoreComponent,\n className: origClassName = '',\n ...props\n } = givenProps\n const className = 'xr-spatial-default ' + origClassName\n return (\n <CSSSpatialComponent\n component={Component}\n className={className}\n {...props}\n ref={givenRef}\n />\n )\n },\n )\n WithCSSSpatialComponent.displayName = `WithCSSSpatial(${typeof Component === 'string' ? Component : Component.displayName || Component.name})`\n\n cachedWithCSSSpatialType.set(Component, WithCSSSpatialComponent)\n cachedWithCSSSpatialType.set(\n WithCSSSpatialComponent,\n WithCSSSpatialComponent,\n )\n return WithCSSSpatialComponent\n }\n}\n\nexport const CSSSpatialPrimitive: Record<string, typeof CSSSpatialComponent> =\n {}\n;(function createSpatialPrimitive(CSSSpatialPrimitive) {\n primitives.forEach(primitive => {\n CSSSpatialPrimitive[primitive] = withCSSSpatial(primitive)\n })\n})(CSSSpatialPrimitive)\n\nexport const CSSSpatialDiv = CSSSpatialPrimitive.div\n","import {\n CSSProperties,\n forwardRef,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from 'react'\nimport { useSpatialStyle } from './useSpatialStyle'\nimport {\n SpatialReactComponent,\n SpatialReactComponentProps,\n SpatialReactComponentRef,\n} from '../SpatialReactComponent'\nimport { SpatialIsStandardInstanceContext } from '../SpatialReactComponent/SpatialIsStandardInstanceContext'\nimport { getSession } from '../../utils/getSession'\nimport { CSSSpatialDebugNameContext } from './CSSSpatialDebugNameContext'\nimport { useHijackSpatialDivRef } from './useHijackSpatialDivRef'\nimport { InjectClassName } from './injectClassStyle'\nimport { CSSSpatialLayerContext } from './CSSSpatialLayerContext'\nimport {\n CSSSpatialID,\n CSSSpatialRootContext,\n CSSSpatialRootContextObject,\n} from './CSSSpatialRootContext'\n\ninterface CSSSpatialComponentWithUniqueIDProps\n extends SpatialReactComponentProps {\n [CSSSpatialID]: string\n}\n\nfunction renderRootCSSSpatialComponent(\n inProps: SpatialReactComponentProps,\n refIn: SpatialReactComponentRef,\n) {\n const cssSpatialRootContextObject = useMemo(\n () => new CSSSpatialRootContextObject(),\n [],\n )\n\n const {\n style = {},\n className = '',\n children,\n debugName,\n debugShowStandardInstance,\n ...props\n } = inProps\n const { ref, spatialStyle, ready } = useSpatialStyle()\n\n const divRefStyle: CSSProperties = {\n ...style,\n width: 0,\n height: 0,\n padding: 0,\n transition: 'none',\n position: 'absolute',\n }\n\n const spatialDivStyle: CSSProperties = {\n ...style,\n transform: spatialStyle.transformExist ? 'translateZ(0)' : 'none',\n }\n\n const El = inProps.component || 'div'\n\n // hijack SpatialDiv ref\n const spatialDivRef = useHijackSpatialDivRef(refIn, ref)\n\n const divRefClassName = className + ' ' + InjectClassName\n\n return (\n <CSSSpatialRootContext.Provider value={cssSpatialRootContextObject}>\n {ready && (\n <SpatialReactComponent\n style={spatialDivStyle}\n className={className}\n children={children}\n {...props}\n spatialStyle={spatialStyle}\n debugName={debugName}\n debugShowStandardInstance={debugShowStandardInstance}\n ref={spatialDivRef}\n />\n )}\n\n <El\n style={divRefStyle}\n className={divRefClassName}\n {...props}\n ref={ref}\n data-cssparser\n />\n </CSSSpatialRootContext.Provider>\n )\n}\n\nfunction renderInWebEnv(\n props: SpatialReactComponentProps,\n ref: SpatialReactComponentRef,\n) {\n return <SpatialReactComponent {...props} ref={ref} />\n}\n\nfunction renderInStandardInstance(\n cssSpatialRootContextObject: CSSSpatialRootContextObject,\n cssSpatialID: string,\n inProps: SpatialReactComponentProps,\n refIn: SpatialReactComponentRef,\n) {\n const { style: inStyle = {}, ...props } = inProps\n const style: CSSProperties = {\n ...inStyle,\n transform: 'none',\n visibility: 'hidden',\n }\n\n // hijack SpatialDiv ref\n var cssParserRef = useRef<HTMLDivElement | null>(null)\n const spatialDivRef = useHijackSpatialDivRef(refIn, cssParserRef)\n\n useEffect(() => {\n const onDomChangeAction = (dom: HTMLDivElement | null) => {\n cssParserRef.current = dom\n }\n cssSpatialRootContextObject.onDomChange(cssSpatialID, onDomChangeAction)\n\n return () => {\n cssSpatialRootContextObject.offDomChange(cssSpatialID, onDomChangeAction)\n }\n }, [])\n\n return <SpatialReactComponent style={style} {...props} ref={spatialDivRef} />\n}\n\nfunction renderInPortalInstance(\n cssSpatialRootContextObject: CSSSpatialRootContextObject,\n cssSpatialID: string,\n inProps: SpatialReactComponentProps,\n) {\n const {\n style = {},\n className = '',\n children,\n debugName,\n debugShowStandardInstance,\n ...props\n } = inProps\n const { ref, spatialStyle, ready } = useSpatialStyle()\n const divRefStyle: CSSProperties = {\n ...style,\n width: 0,\n height: 0,\n padding: 0,\n transition: 'none',\n position: 'absolute',\n }\n\n const spatialDivStyle: CSSProperties = {\n ...style,\n transform: spatialStyle.transformExist ? 'translateZ(0)' : 'none',\n }\n\n const El = inProps.component || 'div'\n\n const divRefClassName = className + ' ' + InjectClassName\n\n useEffect(() => {\n cssSpatialRootContextObject.setCSSParserRef(cssSpatialID, ref.current)\n }, [ref.current])\n\n return (\n <>\n {ready && (\n <SpatialReactComponent\n style={spatialDivStyle}\n className={className}\n children={children}\n {...props}\n spatialStyle={spatialStyle}\n debugName={debugName}\n debugShowStandardInstance={debugShowStandardInstance}\n />\n )}\n <El\n style={divRefStyle}\n className={divRefClassName}\n {...props}\n ref={ref}\n />\n </>\n )\n}\n\nfunction CSSSpatialComponentBase(\n inProps: CSSSpatialComponentWithUniqueIDProps,\n ref: SpatialReactComponentRef,\n) {\n const { [CSSSpatialID]: cssSpatialID, ...props } = inProps\n const isWebEnv = !getSession()\n if (isWebEnv) {\n return renderInWebEnv(props, ref)\n } else {\n const cssSpatialRootContextObject = useContext(CSSSpatialRootContext)\n if (cssSpatialRootContextObject) {\n const isInStandardInstance = !!useContext(\n SpatialIsStandardInstanceContext,\n )\n if (isInStandardInstance) {\n return renderInStandardInstance(\n cssSpatialRootContextObject,\n cssSpatialID,\n props,\n ref,\n )\n } else {\n return renderInPortalInstance(\n cssSpatialRootContextObject,\n cssSpatialID,\n props,\n )\n }\n } else {\n return renderRootCSSSpatialComponent(props, ref)\n }\n }\n}\n\nconst CSSSpatialComponentBaseWithRef = forwardRef(CSSSpatialComponentBase)\n\nfunction CSSSpatialComponentWithRef(\n inProps: SpatialReactComponentProps,\n ref: SpatialReactComponentRef,\n) {\n const layer = useContext(CSSSpatialLayerContext) + 1\n\n const cssSpatialRootContextObject = useContext(CSSSpatialRootContext)\n const isRootInstance = !cssSpatialRootContextObject\n const isInStandardInstance = !!useContext(SpatialIsStandardInstanceContext)\n const cssSpatialID = useMemo(() => {\n return isRootInstance\n ? layer.toString()\n : cssSpatialRootContextObject.getSpatialID(\n layer,\n isInStandardInstance,\n inProps.debugName,\n )\n }, [])\n\n const props = { ...inProps, [CSSSpatialID]: cssSpatialID }\n\n return (\n <CSSSpatialDebugNameContext.Provider value={inProps.debugName || ''}>\n <CSSSpatialLayerContext.Provider value={layer}>\n <CSSSpatialComponentBaseWithRef {...props} ref={ref} />\n </CSSSpatialLayerContext.Provider>\n </CSSSpatialDebugNameContext.Provider>\n )\n}\n\nexport const CSSSpatialComponent = forwardRef(CSSSpatialComponentWithRef)\n","import { useCallback, useEffect, useRef, useState } from 'react'\nimport { SpatialStyleInfoUpdateEvent } from '../notifyUpdateStandInstanceLayout'\nimport isEqual from 'lodash.isequal'\nimport { Matrix4, Vector3, Quaternion } from './math'\nimport { type BackgroundMaterialType } from '@webspatial/core-sdk'\nimport { SpatialCustomVars } from './const'\n\nfunction parse2dMatrix(transformDataArray: number[]) {\n const [n11, n21, n12, n22, n13, n23] = transformDataArray\n const matrix4 = new Matrix4(\n n11,\n n12,\n 0,\n n13,\n n21,\n n22,\n 0,\n n23,\n 0,\n 0,\n 1,\n 0,\n 0,\n 0,\n 0,\n 1,\n )\n return matrix4\n}\n\nfunction parse3dMatrix(transformDataArray: number[]) {\n const matrix4 = new Matrix4().fromArray(transformDataArray)\n return matrix4\n}\n\nfunction parseTransform(computedStyle: CSSStyleDeclaration) {\n let transform = computedStyle.getPropertyValue('transform')\n const matrixFlagString = 'matrix('\n const idxOfMatrix = transform.indexOf(matrixFlagString)\n if (idxOfMatrix !== -1) {\n const transformDataArray = transform\n .substring(matrixFlagString.length, transform.length - 1)\n .split(',')\n .map(item => parseFloat(item))\n return { transformExist: true, matrix: parse2dMatrix(transformDataArray) }\n } else {\n const matrix3dFlagString = 'matrix3d('\n const idxOfMatrix3d = transform.indexOf(matrix3dFlagString)\n if (idxOfMatrix3d !== -1) {\n const transform3dDataArray = transform\n .substring(matrix3dFlagString.length, transform.length - 1)\n .split(',')\n .map(item => parseFloat(item))\n return {\n transformExist: true,\n matrix: parse3dMatrix(transform3dDataArray),\n }\n } else {\n return { transformExist: false, matrix: new Matrix4() }\n }\n }\n}\n\nfunction parseBack(computedStyle: CSSStyleDeclaration) {\n let backProperty = computedStyle.getPropertyValue(SpatialCustomVars.back)\n let back: number | undefined = undefined\n try {\n back = parseFloat(backProperty)\n } catch (error) {}\n return new Matrix4().makeTranslation(0, 0, back || 0)\n}\n\nfunction parseXRZIndex(computedStyle: CSSStyleDeclaration) {\n let xrZIndexProperty = computedStyle.getPropertyValue(\n SpatialCustomVars.xrZIndex,\n )\n let xrZIndex: number = 0\n try {\n xrZIndex = parseFloat(xrZIndexProperty)\n } catch (error) {}\n return xrZIndex\n}\n\nfunction parseSpatialStyle(node: HTMLElement) {\n const computedStyle = getComputedStyle(node)\n\n // handle back property\n const mat4ForBack = parseBack(computedStyle)\n\n // handle transform properties\n\n const { transformExist, matrix: mat4ForTransform } =\n parseTransform(computedStyle)\n\n const resultMatrix = new Matrix4()\n resultMatrix.multiplyMatrices(mat4ForBack, mat4ForTransform)\n\n const position = new Vector3()\n const quaternion = new Quaternion()\n const scale = new Vector3()\n\n resultMatrix.decompose(position, quaternion, scale)\n\n // parse xrZIndex\n const zIndex = parseXRZIndex(computedStyle)\n\n // parse visibility\n const visible = computedStyle.getPropertyValue('visibility') === 'visible'\n\n // parse backgroundMaterialType\n const backgroundMaterialType: BackgroundMaterialType =\n computedStyle.getPropertyValue(\n SpatialCustomVars.backgroundMaterial,\n ) as BackgroundMaterialType\n\n return {\n position: { x: position.x, y: position.y, z: position.z },\n rotation: {\n x: quaternion.x,\n y: quaternion.y,\n z: quaternion.z,\n w: quaternion.w,\n },\n scale: { x: scale.x, y: scale.y, z: scale.z },\n zIndex,\n material: {\n type: backgroundMaterialType || 'none',\n },\n visible,\n transformExist,\n }\n}\n\nexport function useSpatialStyle() {\n const ref = useRef<HTMLDivElement | null>(null)\n\n const [spatialStyle, setSpatialStyle] = useState({\n position: { x: 0, y: 0, z: 0 },\n rotation: { x: 0, y: 0, z: 0, w: 1 },\n scale: { x: 1, y: 1, z: 1 },\n zIndex: 0,\n material: {\n type: 'none' as BackgroundMaterialType,\n },\n visible: true,\n transformExist: false,\n })\n const [ready, setReady] = useState(false)\n\n const checkSpatialStyleUpdate = useCallback(() => {\n const nextSpatialStyle = parseSpatialStyle(ref.current!)\n if (!isEqual(spatialStyle, nextSpatialStyle)) {\n setSpatialStyle(nextSpatialStyle)\n }\n }, [])\n\n useEffect(() => {\n // first time update\n if (!ref.current) {\n return\n }\n\n const spatialStyle = parseSpatialStyle(ref.current!)\n setSpatialStyle(spatialStyle)\n setReady(true)\n }, [])\n\n useEffect(() => {\n if (!ref.current) {\n return\n }\n\n // sync spatial style when this dom or sub dom change\n const observer = new MutationObserver(mutationsList => {\n checkSpatialStyleUpdate()\n })\n const config = {\n childList: true,\n subtree: true,\n attributes: true,\n // attributeOldValue: true,\n attributeFilter: ['style', 'class'],\n }\n observer.observe(ref.current!, config)\n\n return () => {\n observer.disconnect()\n }\n }, [])\n\n useEffect(() => {\n const headObserver = new MutationObserver(mutations => {\n checkSpatialStyleUpdate()\n })\n headObserver.observe(document.head, { childList: true, subtree: true })\n return () => {\n headObserver.disconnect()\n }\n }, [])\n\n useEffect(() => {\n if (!ref.current) {\n return\n }\n\n // check style property change when some external node changed\n function isDescendant(child: Node, parent: Node) {\n if (child === parent) {\n return true\n }\n let node: Node | null = child\n while (node) {\n if (node === parent) {\n return true\n }\n node = node.parentElement\n }\n return false\n }\n\n const onDomUpdated = (event: Event) => {\n const mutationsList = (event as CustomEvent).detail as MutationRecord[]\n // spatialReactComponentDiv is hardcode currently, maybe refactor later (get from SpatialReactComponent)\n const spatialReactComponentDiv = (ref.current! as HTMLElement)\n .previousElementSibling!\n // ignore the mutation that is in the current ref dom or the previous sibling dom (Like SpatialReactComponent)\n const targets = mutationsList\n .map(m => m.target)\n .filter(\n node =>\n node !== ref.current! &&\n !isDescendant(node, spatialReactComponentDiv),\n )\n if (targets.length > 0) {\n checkSpatialStyleUpdate()\n }\n }\n\n // check style property change when some external style change\n document.addEventListener(\n SpatialStyleInfoUpdateEvent.domUpdated,\n onDomUpdated,\n )\n\n return () => {\n document.removeEventListener(\n SpatialStyleInfoUpdateEvent.domUpdated,\n onDomUpdated,\n )\n }\n }, [])\n\n return { ref, ready, spatialStyle }\n}\n","export { Matrix4 } from 'three/src/math/Matrix4.js'\nexport { Vector3 } from 'three/src/math/Vector3.js'\nexport { Quaternion } from 'three/src/math/Quaternion.js'\n","export const SpatialCustomVars = {\n back: '--xr-back',\n backgroundMaterial: '--xr-background-material',\n xrZIndex: '--xr-z-index',\n}\n\nexport const BackgroundMaterialDefault = 'none'\n","import { createContext } from 'react'\n\nexport const CSSSpatialDebugNameContext = createContext<string>('')\n","import { BackgroundMaterialType } from '@webspatial/core-sdk'\nimport { MutableRefObject, useCallback } from 'react'\nimport { SpatialReactComponentRef } from '../SpatialReactComponent/types'\nimport { SpatialCustomVars } from './const'\nimport { InjectClassName } from './injectClassStyle'\nimport { extractAndRemoveCustomProperties, joinToCSSText } from './utils'\n\nfunction makeOriginalKey(key: string) {\n return `__original_${key}`\n}\n\nexport function useHijackSpatialDivRef(\n refIn: SpatialReactComponentRef,\n cssParserRef: MutableRefObject<HTMLDivElement | null>,\n) {\n const ref = cssParserRef\n const spatialDivRef = useCallback(\n (domElement: HTMLDivElement) => {\n if (domElement && refIn) {\n const domStyle = domElement.style\n const domStyleProxy = new Proxy(domStyle, {\n get(target, prop: string) {\n if (\n typeof target[prop as keyof CSSStyleDeclaration] === 'function'\n ) {\n return function (this: any, ...args: any[]) {\n if (prop === 'setProperty') {\n const [property, value] = args\n if (property === SpatialCustomVars.backgroundMaterial) {\n ref.current?.style.setProperty(\n SpatialCustomVars.backgroundMaterial,\n value as BackgroundMaterialType,\n )\n } else if (property === SpatialCustomVars.back) {\n ref.current?.style.setProperty(\n SpatialCustomVars.back,\n value as string,\n )\n } else if (property === 'transform') {\n ref.current?.style.setProperty(property, value as string)\n return true\n } else if (property === SpatialCustomVars.xrZIndex) {\n ref.current?.style.setProperty(\n SpatialCustomVars.xrZIndex,\n value as string,\n )\n }\n } else if (prop === 'removeProperty') {\n const [property] = args\n if (\n property === SpatialCustomVars.backgroundMaterial ||\n property === SpatialCustomVars.back ||\n property === 'transform' ||\n property === SpatialCustomVars.xrZIndex\n ) {\n ref.current?.style.removeProperty(property)\n }\n } else if (prop === 'getPropertyValue') {\n const [property] = args\n if (property === 'transform') {\n return ref.current?.style[property]\n }\n }\n return (target[prop as keyof CSSStyleDeclaration] as Function)(\n ...args,\n )\n }\n }\n\n if (prop === 'transform') {\n return ref.current?.style[prop]\n }\n\n if (prop === 'visibility') {\n return ref.current?.style.visibility\n }\n\n if (prop === 'cssText') {\n // todo: concat target cssText with ref.current.style's spatialStyle like back/transform/visibility/xrZIndex/backgroundMaterial\n }\n\n return Reflect.get(target, prop)\n },\n set(target, property, value) {\n if (property === SpatialCustomVars.backgroundMaterial) {\n ref.current?.style.setProperty(\n SpatialCustomVars.backgroundMaterial,\n value as BackgroundMaterialType,\n )\n } else if (property === SpatialCustomVars.back) {\n ref.current?.style.setProperty(\n SpatialCustomVars.back,\n value as string,\n )\n } else if (property === SpatialCustomVars.xrZIndex) {\n ref.current?.style.setProperty(\n SpatialCustomVars.xrZIndex,\n value as string,\n )\n } else if (property === 'transform') {\n ref.current?.style.setProperty(property, value as string)\n return true\n } else if (property === 'visibility') {\n ref.current?.style.setProperty(property, value as string)\n return true\n } else if (property === 'cssText') {\n // parse cssText, filter out spatialStyle like back/transform/visibility/xrZIndex/backgroundMaterial\n const toFilteredCSSProperties = [\n 'transform',\n 'visibility',\n SpatialCustomVars.back,\n SpatialCustomVars.backgroundMaterial,\n SpatialCustomVars.xrZIndex,\n ]\n const { extractedValues, filteredCssText } =\n extractAndRemoveCustomProperties(\n value as string,\n toFilteredCSSProperties,\n )\n\n // update cssText for CSSParserDiv\n toFilteredCSSProperties.forEach(key => {\n // update cssText for CSSParserDiv according to extractedValues\n if (extractedValues[key]) {\n ref.current?.style.setProperty(key, extractedValues[key])\n } else {\n ref.current?.style.removeProperty(key)\n }\n })\n\n const appendedCSSText = joinToCSSText({\n transform: 'none',\n visibility: 'hidden',\n })\n\n // set cssText for spatialDiv\n return Reflect.set(\n target,\n property,\n [appendedCSSText, filteredCssText].join(';'),\n )\n }\n return Reflect.set(target, property, value)\n },\n })\n\n // hijack classList\n const domClassList = domElement.classList\n const domClassMethodKeys: Array<\n 'add' | 'remove' | 'toggle' | 'replace'\n > = ['add', 'remove', 'toggle', 'replace']\n domClassMethodKeys.forEach(key => {\n const hiddenKey = makeOriginalKey(key)\n const hiddenKeyExist = (domClassList as any)[hiddenKey] !== undefined\n const originalMethod = hiddenKeyExist\n ? (domClassList as any)[hiddenKey]\n : domClassList[key].bind(domClassList)\n\n ;(domClassList as any)[hiddenKey] = originalMethod\n\n domClassList[key] = function (this: any, ...args: any[]) {\n const result = (originalMethod as Function)(...args)\n if (ref.current) {\n // update CSSParser className\n ref.current.className =\n domElement.className + ' ' + InjectClassName\n }\n return result\n }\n })\n\n const __getComputedStyle = (\n originalGetComputedStyle: any,\n pseudoElt: any,\n ) => {\n return originalGetComputedStyle(domElement, pseudoElt)\n }\n\n const proxyDomElement = new Proxy(domElement, {\n get(target, prop) {\n if (prop === 'style') {\n return domStyleProxy\n }\n\n if (prop === '__isSpatialDiv') {\n return true\n }\n\n if (prop === '__getComputedStyle') {\n return __getComputedStyle\n }\n\n if (typeof target[prop as keyof HTMLElement] === 'function') {\n return function (this: any, ...args: any[]) {\n if ('removeAttribute' === prop) {\n const [property] = args\n if (property === 'style') {\n domStyleProxy.cssText = ''\n return true\n }\n if (property === 'class') {\n proxyDomElement.className = ''\n return true\n }\n }\n return (target[prop as keyof HTMLElement] as Function)(...args)\n }\n }\n\n return Reflect.get(target, prop, target)\n },\n set(target, prop, value) {\n if (ref.current) {\n if (prop === 'className') {\n ref.current.className = value + ' ' + InjectClassName\n }\n if (prop === 'style') {\n domStyleProxy.cssText = joinToCSSText(value)\n return true\n }\n }\n\n return Reflect.set(target, prop, value)\n },\n })\n\n if (typeof refIn === 'function') {\n refIn(proxyDomElement)\n } else {\n refIn.current = proxyDomElement\n }\n } else if (refIn) {\n if (typeof refIn === 'function') {\n refIn(null)\n } else {\n refIn.current = null\n }\n }\n },\n [refIn],\n )\n\n return spatialDivRef\n}\n","import { SpatialCustomVars, BackgroundMaterialDefault } from './const'\n\nexport const InjectClassName = 'xr-css-spatial-default'\n\nfunction injectClassStyle() {\n const style = document.createElement('style')\n style.innerHTML = `\n .${InjectClassName} {\n ${SpatialCustomVars.backgroundMaterial}: ${BackgroundMaterialDefault};\n }\n `\n document.head.prepend(style)\n}\ninjectClassStyle()\n","export function extractAndRemoveCustomProperties(\n cssText: string,\n properties: string[],\n) {\n if (!cssText) {\n return { extractedValues: {}, filteredCssText: '' }\n }\n\n const extractedValues: Record<string, string> = {}\n const rules = cssText.split(';')\n\n const filteredRules = rules.filter(rule => {\n const [key, value] = rule.split(':').map(part => part.trim())\n if (properties.includes(key)) {\n extractedValues[key] = value\n return false\n }\n return true\n })\n\n const filteredCssText = filteredRules.join(';').trim()\n return { extractedValues, filteredCssText }\n}\n\nexport function splitCSSText(cssText: string) {\n const rules = cssText.split(';')\n const filteredRules = rules.filter(rule => rule.trim() !== '')\n return filteredRules\n}\n\nexport function joinToCSSText(cssKV: Record<string, string>) {\n const rules = Object.entries(cssKV).map(([key, value]) => `${key}: ${value}`)\n return rules.join(';')\n}\n","import { createContext } from 'react'\n\n// CSSSpatialLayerContext is used to mark the cssspatial layer of the cssspatial div, which is used to help hijacked ref.current find the correct cssparser div.\nexport const CSSSpatialLayerContext = createContext(0)\n","import { createContext } from 'react'\n\nexport const CSSSpatialID = 'CSSSpatialID'\n\nexport class CSSSpatialRootContextObject {\n prefix = 'css'\n\n domSpatialId: string | null = null\n\n private fns: Record<string, (dom: HTMLDivElement | null) => void> = {}\n // cache dom for each spatialId\n private spatialId2dom: Record<string, HTMLDivElement> = {}\n\n // layer : [standardInstance sequence, portalInstance sequence]\n private layerSequences: Record<number, [number, number]> = {}\n\n public getSpatialID(\n layer: number,\n isInStandardInstance: boolean,\n debugName: string = '',\n ): string {\n if (this.layerSequences[layer] === undefined) {\n this.layerSequences[layer] = [0, 0]\n }\n const idx = isInStandardInstance ? 0 : 1\n const sequenceId = this.layerSequences[layer][idx]\n this.layerSequences[layer][idx] = sequenceId + 1\n const spatialId = `${this.prefix}_${debugName}_${layer}_${sequenceId}`\n\n return spatialId\n }\n\n public onDomChange(\n spatialId: string,\n fn: (dom: HTMLDivElement | null) => void,\n ) {\n this.fns[spatialId] = fn\n }\n\n public offDomChange(\n spatialId: string,\n fn: (dom: HTMLDivElement | null) => void,\n ) {\n delete this.fns[spatialId]\n }\n\n public setCSSParserRef(\n cssSpatialID: string,\n domElement: HTMLDivElement | null,\n ) {\n if (domElement) {\n this.spatialId2dom[cssSpatialID] = domElement\n } else {\n delete this.spatialId2dom[cssSpatialID]\n }\n this.fns[cssSpatialID]?.(domElement)\n }\n}\n\nexport const CSSSpatialRootContext =\n createContext<CSSSpatialRootContextObject | null>(null)\n","import { SpatialHelper } from '@webspatial/core-sdk'\nimport type { SpatialEntity } from '@webspatial/core-sdk'\nimport React, {\n useRef,\n useImperativeHandle,\n forwardRef,\n useEffect,\n} from 'react'\nimport { getSession } from '../utils'\n\nvar runAsync = (fn: any) => {\n return fn()\n}\n\ninterface SpatialViewProps extends React.HTMLAttributes<HTMLDivElement> {\n onViewLoad?: (viewEnt: SpatialEntity) => void\n onViewUnload?: () => void\n}\n\nexport interface SpatialViewRef extends HTMLDivElement {\n getViewEntity: () => Promise<SpatialEntity | null>\n}\n\nconst SpatialViewEl = forwardRef<SpatialViewRef, SpatialViewProps>(\n (props, ref) => {\n const divRef = useRef<HTMLDivElement>(null)\n const spatialEntity = useRef<SpatialEntity | null>(null)\n const activePromise = useRef<Promise<any> | null>(null)\n\n // Add function to get view entity from the spatial view\n useImperativeHandle(ref, () => ({\n ...divRef.current!,\n getViewEntity: async () => {\n if (activePromise.current) {\n await activePromise.current\n }\n return spatialEntity.current!\n },\n }))\n\n if (getSession() == null) {\n return (\n <div ref={divRef} {...props}>\n WebSpatial is not supported in this browser\n </div>\n )\n }\n useEffect(() => {\n activePromise.current = runAsync(async () => {\n if (activePromise.current) {\n await activePromise.current\n }\n let sh = new SpatialHelper(getSession()!)\n let x = await sh.dom.attachSpatialView(divRef.current!)\n spatialEntity.current = x.entity\n\n if (props.onViewLoad) {\n props.onViewLoad(x.entity)\n }\n })\n return () => {\n runAsync(async () => {\n await activePromise.current\n spatialEntity.current?.destroy()\n // Teardown\n if (props.onViewUnload) {\n props.onViewUnload()\n }\n })\n }\n }, [])\n\n // Remove props that cant be used on the div\n const { onViewLoad, onViewUnload, ...divProps } = props\n return <div ref={divRef} {...divProps} />\n },\n)\n\n/**\n * [Experimental] Allows embedding 3D dynamic content within the webpage\n */\nexport const SpatialView = SpatialViewEl\n","import React, {\n CSSProperties,\n forwardRef,\n Children,\n ReactElement,\n useMemo,\n ReactNode,\n useRef,\n useEffect,\n useState,\n} from 'react'\n\nimport { getSession } from '../../utils'\nimport {\n CSSModel3D,\n ModelElementRef,\n ModelEvent,\n ModelDragEvent,\n ModelElement,\n} from '../Model3D'\nexport type * from '../Model3D'\nimport { getAbsoluteURL } from '../Model3D/utils'\n\nimport { ModelViewerElement } from '@google/model-viewer'\n\n{\n // Set a default size for the model tag\n // This is done with css to allow it to be overwritten by className/css/style props\n const styleElement = document.createElement('style')\n styleElement.id = '__custom-class-model-webspatial'\n styleElement.innerHTML = `.__custom-class-model-webspatial { width: 300px; height: 300px; }`\n if (document.getElementById('__custom-class-model-webspatial')) {\n console.warn('__custom-class-model-webspatial already exists')\n }\n document.head.prepend(styleElement)\n}\n\ndeclare global {\n namespace JSX {\n interface IntrinsicElements {\n 'model-viewer': ModelViewerElement | { ref: any }\n }\n }\n}\n\ntype ModelChildren =\n | React.ReactElement<{ type: string; src: string }>\n | [React.ReactElement<{ type: string; src: string }>, React.ReactElement]\n | React.ReactElement<{ type: string; src: string }>[]\n\nexport interface ModelProps {\n // common for config Model3D and ModelViewer\n className?: string\n style?: CSSProperties | undefined\n children: ModelChildren\n onLoad?: (event: ModelEvent) => void\n\n // for config Model3D only\n contentMode?: 'fill' | 'fit'\n resizable?: boolean\n aspectRatio?: number\n onDragStart?: (dragEvent: ModelDragEvent) => void\n onDrag?: (dragEvent: ModelDragEvent) => void\n onDragEnd?: (dragEvent: ModelDragEvent) => void\n\n onTap?: (event: ModelEvent) => void\n onDoubleTap?: (event: ModelEvent) => void\n onLongPress?: (event: ModelEvent) => void\n\n // for config ModelViewer only\n poster?: string\n}\n\nfunction renderInModel3D(\n inProps: Omit<ModelProps, 'children'>,\n ref: ModelElementRef,\n modelUrl: string,\n placeHolder: ReactNode,\n) {\n const { poster, ...props } = inProps\n return (\n <CSSModel3D modelUrl={modelUrl} {...props} ref={ref}>\n {' '}\n {placeHolder}{' '}\n </CSSModel3D>\n )\n}\n\nfunction parseChildren(child: ModelChildren) {\n if (child === undefined) {\n throw new Error('children with <source> required ')\n }\n\n const children = Children.toArray(child)\n\n const sourceElements = children.filter(\n node => (node as ReactElement).type === 'source',\n )\n if (sourceElements.length === 0) {\n throw new Error('children with at least one <source> required ')\n }\n\n const gltfSources = sourceElements.filter(node => {\n const type = (node as ReactElement).props?.type.trim()\n const source = (node as ReactElement).props?.src.trim().toLowerCase()\n const isGLFT = source.endsWith('.gltf')\n const isGLB = source.endsWith('.glb')\n\n return (\n (type.startsWith('model/gltf-binary') && isGLB) ||\n (type.startsWith('model/gltf+json') && isGLFT)\n )\n })\n const usdzSources = sourceElements.filter(node =>\n (node as ReactElement).props?.type.trim().startsWith('model/vnd.usdz+zip'),\n )\n let lastChild = children[children.length - 1]\n const placeHolder =\n sourceElements.indexOf(lastChild) < 0 ? lastChild : undefined\n\n const gltfSourceURL =\n gltfSources.length > 0 ? (gltfSources[0] as ReactElement).props?.src : ''\n const usdzSourceURL =\n usdzSources.length > 0 ? (usdzSources[0] as ReactElement).props?.src : ''\n\n return {\n placeHolder,\n gltfSourceURL: getAbsoluteURL(gltfSourceURL),\n usdzSourceURL: getAbsoluteURL(usdzSourceURL),\n }\n}\n\nfunction ModelBase(inProps: ModelProps, ref: ModelElementRef) {\n const { children, ...props } = inProps\n // Set default dimensions with predefined class\n props.className =\n '__custom-class-model-webspatial ' +\n (props.className ? props.className : '')\n let className = props.className\n\n const { placeHolder, gltfSourceURL, usdzSourceURL } = useMemo(\n () => parseChildren(children),\n [children],\n )\n const isWebEnv = !getSession()\n if (isWebEnv) {\n const [loadFailed, setLoadFailed] = useState(false)\n useEffect(() => {\n if (gltfSourceURL == '') {\n console.warn('Unable to display model, no gltf/glb source provided')\n if (props.onLoad) {\n props.onLoad({\n target: { ready: false, currentSrc: gltfSourceURL } as any,\n })\n }\n setLoadFailed(true)\n }\n }, [])\n\n const myModelViewer = useRef<ModelViewerElement>(null)\n const { style = {}, ...props } = inProps\n\n const isDragging = useRef(false)\n let [modelViewerExists, setModelViewerExists] = useState(false)\n useEffect(() => {\n var modelViewerFound = false\n customElements.whenDefined('model-viewer').then(function () {\n modelViewerFound = true\n setModelViewerExists(modelViewerFound)\n })\n\n // if model-viewer element is not loaded in 500ms, print a warning\n setTimeout(() => {\n if (!modelViewerFound) {\n console.warn(\n 'model-viewer element not loaded yet, if you want to fallback to webGL model loading, you must include the model-viewer library manually in your html file eg. \\n\\n <script type=\"module\" src=\"https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js\"></script>',\n )\n if (props.onLoad) {\n props.onLoad({\n target: { ready: false, currentSrc: gltfSourceURL } as any,\n })\n }\n setLoadFailed(true)\n }\n }, 500)\n }, [])\n\n useEffect(() => {\n if (!modelViewerExists) {\n return\n }\n\n myModelViewer.current!.addEventListener('error', event => {\n if ((event as any).detail.type == 'loadfailure') {\n if (props.onLoad) {\n props.onLoad({\n target: { ready: false, currentSrc: gltfSourceURL } as any,\n })\n }\n setLoadFailed(true)\n }\n })\n\n myModelViewer.current!.addEventListener('load', event => {\n if (props.onLoad) {\n props.onLoad({\n target: { ready: true, currentSrc: gltfSourceURL } as any,\n })\n }\n setLoadFailed(false)\n })\n\n myModelViewer.current!.addEventListener('pointerdown', event => {\n isDragging.current = true\n if (props.onDragStart) {\n props.onDragStart({\n eventType: 'dragstart',\n translation3D: { x: 0, y: 0, z: 0 },\n startLocation3D: { x: 0, y: 0, z: 0 },\n target: (ref as any).current as ModelElement,\n })\n }\n })\n\n myModelViewer.current!.addEventListener('pointermove', event => {\n if (!isDragging.current) {\n return\n }\n if (props.onDrag) {\n props.onDrag({\n eventType: 'drag',\n translation3D: { x: 0, y: 0, z: 0 },\n startLocation3D: { x: 0, y: 0, z: 0 },\n target: (ref as any).current as ModelElement,\n })\n }\n })\n\n myModelViewer.current!.addEventListener('pointerup', event => {\n if (!isDragging.current) {\n return\n }\n isDragging.current = false\n if (props.onDragEnd) {\n props.onDragEnd({\n eventType: 'dragend',\n translation3D: { x: 0, y: 0, z: 0 },\n startLocation3D: { x: 0, y: 0, z: 0 },\n target: (ref as any).current as ModelElement,\n })\n }\n })\n }, [modelViewerExists])\n\n useEffect(() => {\n if (props.contentMode !== undefined && props.contentMode !== 'fit') {\n console.warn(\n \"Model element contentMode != fit isn't supported on 2D screens\",\n )\n }\n if (props.resizable !== undefined && props.resizable !== false) {\n console.warn(\n \"Model element resizable != false isn't supported on 2D screens\",\n )\n }\n if (props.aspectRatio !== undefined && props.aspectRatio !== 1) {\n console.warn(\n \"Model element aspectRatio != 1 isn't supported on 2D screens\",\n )\n }\n }, [props.contentMode, props.resizable, props.aspectRatio])\n\n return (\n <div ref={ref} className={className} style={style}>\n {modelViewerExists ? (\n <>\n <model-viewer\n ref={myModelViewer}\n style={\n {\n display: loadFailed ? 'none' : '',\n width: '100%',\n height: '100%',\n } as any\n }\n src={gltfSourceURL}\n camera-controls\n touch-action=\"pan-y\"\n poster={props.poster}\n ></model-viewer>\n {loadFailed ? <>{placeHolder}</> : <> </>}\n </>\n ) : (\n <>\n {props.poster ? (\n <img\n className={className}\n style={Object.assign(structuredClone(style), {\n objectFit: 'contain',\n })}\n src={props.poster}\n ></img>\n ) : (\n <>{placeHolder}</>\n )}\n </>\n )}\n </div>\n )\n } else {\n return renderInModel3D(props, ref, usdzSourceURL, placeHolder)\n }\n}\n\nexport const Model = forwardRef(ModelBase)\nModel.displayName = 'Model'\n","import { forwardRef, useContext, useMemo } from 'react'\nimport { Model3DProps, ModelElementRef } from './types'\nimport { SpatialLayerContext } from '../SpatialReactComponent/SpatialLayerContext'\nimport { SpatialReactContext } from '../SpatialReactComponent/SpatialReactContext'\nimport { renderModel3DNotInSpatialDiv } from './Model3DNotInSpatialDiv'\nimport { renderModel3DStandardInstance } from './Model3DStandardInstance'\nimport { renderModel3DPortalInstance } from './Model3DPortalInstance'\nimport { SpatialIsStandardInstanceContext } from '../SpatialReactComponent/SpatialIsStandardInstanceContext'\n\nfunction Model3DBase(props: Model3DProps, refIn: ModelElementRef) {\n const parentSpatialReactContextObject = useContext(SpatialReactContext)\n const isInSpatialDiv = !!parentSpatialReactContextObject\n\n if (isInSpatialDiv) {\n const layer = useContext(SpatialLayerContext) + 1\n const isInStandardInstance = !!useContext(SpatialIsStandardInstanceContext)\n const spatialId = useMemo(() => {\n return parentSpatialReactContextObject.getSpatialID(\n layer,\n isInStandardInstance,\n 'Model3D',\n )\n }, [])\n if (isInStandardInstance) {\n return renderModel3DStandardInstance(spatialId, props, refIn)\n } else {\n return renderModel3DPortalInstance(spatialId, props)\n }\n } else {\n return renderModel3DNotInSpatialDiv(props, refIn)\n }\n}\n\nexport const Model3D = forwardRef(Model3DBase)\n\nModel3D.displayName = 'Model3D'\n","import { useRef, useEffect } from 'react'\n\nexport function useDetectLayoutDomUpdated(onDomUpdated: () => void) {\n const ref = useRef<HTMLDivElement>(null)\n\n // detect window resize\n useEffect(() => {\n const handleResize = () => {\n onDomUpdated()\n }\n window.addEventListener('resize', handleResize)\n return () => {\n window.removeEventListener('resize', handleResize)\n }\n }, [])\n\n // detect dom resize\n // Trigger native resize on web resize events\n useEffect(() => {\n if (!ref.current) {\n console.warn('Ref is not attached to the DOM')\n return\n }\n\n let ro = new ResizeObserver(elements => {\n onDomUpdated()\n })\n\n ro.observe(ref.current!)\n return () => {\n ro.disconnect()\n }\n }, [])\n\n // detect dom style and class change\n useEffect(() => {\n if (!ref.current) {\n console.warn('Ref is not attached to the DOM')\n return\n }\n let ro = new MutationObserver(elements => {\n onDomUpdated()\n })\n\n ro.observe(ref.current!, {\n attributeFilter: ['class', 'style'],\n subtree: true,\n attributeOldValue: false,\n })\n return () => {\n ro.disconnect()\n }\n }, [])\n\n return ref\n}\n","import { useRef, useEffect, useState } from 'react'\nimport { Model3DNative } from './Model3DNative'\nimport { SpatialModelDragEvent, SpatialEntity } from '@webspatial/core-sdk'\n\nexport function useModel3DNative(\n modelUrl: string,\n parentEntity: SpatialEntity | undefined,\n eventHandlers: {\n onDragStart?: (dragEvent: SpatialModelDragEvent) => void\n onDrag?: (dragEvent: SpatialModelDragEvent) => void\n onDragEnd?: (dragEvent: SpatialModelDragEvent) => void\n onTap?: () => void\n onDoubleTap?: () => void\n onLongPress?: () => void\n } = {},\n onModel3DNativeReadyCb?: (model3DNative: Model3DNative) => void,\n) {\n let model3DNativeRef = useRef<Model3DNative | null>(null)\n\n const [phase, setPhase] = useState<'loading' | 'success' | 'failure'>(\n 'loading',\n )\n const [failureReason, setFailureReason] = useState('')\n\n useEffect(() => {\n let isDestroyed = false\n\n const model3DContainer = new Model3DNative(parentEntity)\n\n model3DContainer\n .init(\n modelUrl,\n () => {\n setPhase('success')\n },\n (error: string) => {\n setPhase('failure')\n setFailureReason(error)\n },\n )\n .then(() => {\n if (!isDestroyed) {\n model3DNativeRef.current = model3DContainer\n if (onModel3DNativeReadyCb) {\n onModel3DNativeReadyCb(model3DContainer)\n }\n }\n })\n\n return () => {\n isDestroyed = true\n\n model3DContainer.destroy()\n\n model3DNativeRef.current = null\n\n setPhase('loading')\n }\n }, [modelUrl])\n\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.onDragStart = eventHandlers.onDragStart\n }\n }, [model3DNativeRef.current, eventHandlers.onDragStart])\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.onDrag = eventHandlers.onDrag\n }\n }, [model3DNativeRef.current, eventHandlers.onDrag])\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.onDragEnd = eventHandlers.onDragEnd\n }\n })\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.onTap = eventHandlers.onTap\n }\n }, [model3DNativeRef.current, eventHandlers.onTap])\n\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.onDoubleTap = eventHandlers.onDoubleTap\n }\n }, [model3DNativeRef.current, eventHandlers.onDoubleTap])\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.onLongPress = eventHandlers.onLongPress\n }\n }, [model3DNativeRef.current, eventHandlers.onLongPress])\n\n return { model3DNativeRef, phase, failureReason }\n}\n","import { PartialSpatialTransformType, SpatialTransformType } from './types'\n\nexport function PopulatePartialSpatialTransformType(\n spatialTransform: PartialSpatialTransformType = {},\n): SpatialTransformType {\n const {\n position = { x: 0, y: 0, z: 0 },\n rotation = { x: 0, y: 0, z: 0, w: 1 },\n scale = { x: 1, y: 1, z: 1 },\n } = spatialTransform\n const { x: tx = 0, y: ty = 0, z: tz = 0 } = position\n const { x: rx = 0, y: ry = 0, z: rz = 0, w = 1 } = rotation\n const { x: sx = 1, y: sy = 1, z: sz = 1 } = scale\n\n return {\n position: { x: tx, y: ty, z: tz },\n rotation: { x: rx, y: ry, z: rz, w },\n scale: { x: sx, y: sy, z: sz },\n }\n}\n\nexport function getAbsoluteURL(url: string) {\n if (!url) {\n return ''\n }\n if (url.startsWith('http')) {\n return url\n }\n return `${location.origin}${url}`\n}\n","import {\n SpatialModelDragEvent,\n SpatialEntity,\n SpatialModel3DComponent,\n} from '@webspatial/core-sdk'\nimport { getSession } from '../../utils'\nimport { SpatialTransformType } from './types'\nimport { getAbsoluteURL } from './utils'\nimport { parseTransformOrigin } from '../SpatialReactComponent/utils'\nimport { RectType } from '../types'\n\nexport class Model3DNative {\n constructor(parentEntity?: SpatialEntity) {\n this.parentEntity = parentEntity\n }\n\n private parentEntity?: SpatialEntity\n private initPromise?: Promise<any>\n private entity?: SpatialEntity\n private spatialModel3DComponent?: SpatialModel3DComponent\n\n // private modelUrl: string\n\n private isDestroyed = false\n\n private _onDragStart?: (dragEvent: SpatialModelDragEvent) => void\n private _onDrag?: (dragEvent: SpatialModelDragEvent) => void\n private _onDragEnd?: (dragEvent: SpatialModelDragEvent) => void\n\n private _onTap?: () => void\n private _onDoubleTap?: () => void\n private _onLongPress?: () => void\n\n async init(\n modelUrl: string,\n onSuccess: () => void,\n onFailure: (error: string) => void,\n ) {\n if (this.isDestroyed) {\n return\n }\n\n this.initPromise = this.initInternal(modelUrl, onSuccess, onFailure)\n\n return this.initPromise\n }\n\n private async initInternal(\n modelUrl: string,\n onSuccess: () => void,\n onFailure: (error: string) => void,\n ) {\n var session = getSession()\n\n if (!session) {\n return\n }\n\n // Create entity with view component to display the model inside\n const entity = await session.createEntity()\n await entity.setCoordinateSpace('Dom')\n\n const spatialModel3DComponent = await session.createModel3DComponent({\n url: getAbsoluteURL(modelUrl),\n })\n\n await entity.setComponent(spatialModel3DComponent)\n if (this.isDestroyed) {\n return\n }\n if (this.parentEntity) {\n await entity.setParent(this.parentEntity)\n } else {\n // Add entity to the window\n var wc = session.getCurrentWindowComponent()\n var ent = await wc.getEntity()\n await entity.setParent(ent!)\n }\n\n this.entity = entity\n this.spatialModel3DComponent = spatialModel3DComponent\n\n this.spatialModel3DComponent.onSuccess = onSuccess\n this.spatialModel3DComponent.onFailure = onFailure\n this.spatialModel3DComponent.onDragStart = this._onDragStart\n this.spatialModel3DComponent.onDrag = this._onDrag\n this.spatialModel3DComponent.onDragEnd = this._onDragEnd\n this.spatialModel3DComponent.onTap = this._onTap\n this.spatialModel3DComponent.onDoubleTap = this._onDoubleTap\n this.spatialModel3DComponent.onLongPress = this._onLongPress\n }\n\n async setVisible(visible: boolean) {\n if (this.entity) {\n await this.entity.setVisible(visible)\n }\n }\n\n async setContentMode(contentMode: 'fill' | 'fit') {\n if (this.spatialModel3DComponent) {\n await this.spatialModel3DComponent.setContentMode(contentMode)\n }\n }\n\n async setResizable(resizable: boolean) {\n if (this.spatialModel3DComponent) {\n await this.spatialModel3DComponent.setResizable(resizable)\n }\n }\n\n async setAspectRatio(aspectRatio: number) {\n if (this.spatialModel3DComponent) {\n await this.spatialModel3DComponent.setAspectRatio(aspectRatio)\n }\n }\n\n async updateByDom(\n dom: HTMLDivElement,\n options: { spatialTransform: SpatialTransformType },\n ) {\n if (!this.entity || !this.spatialModel3DComponent) {\n return\n }\n\n const computedStyle = getComputedStyle(dom)\n\n const isFixed = computedStyle.position === 'fixed'\n const scrollY = isFixed ? 0 : window.scrollY\n\n const rect = dom.getBoundingClientRect()\n const targetPosX = rect.left + (rect.right - rect.left) / 2\n const targetPosY = rect.bottom + (rect.top - rect.bottom) / 2 + scrollY\n const { spatialTransform } = options\n const { position, rotation, scale } = spatialTransform\n\n const entity = this.entity\n entity.transform.position.x = targetPosX + position.x\n entity.transform.position.y = targetPosY + position.y\n entity.transform.position.z = position.z\n\n entity.transform.orientation.x = rotation.x\n entity.transform.orientation.y = rotation.y\n entity.transform.orientation.z = rotation.z\n entity.transform.orientation.w = rotation.w\n\n entity.transform.scale.x = scale.x\n entity.transform.scale.y = scale.y\n entity.transform.scale.z = scale.z\n\n await entity.updateTransform()\n\n const spatialModel3DComponent = this.spatialModel3DComponent\n await spatialModel3DComponent.setResolution(rect.width, rect.height)\n\n const opacity = parseFloat(computedStyle.getPropertyValue('opacity'))\n await spatialModel3DComponent.setOpacity(opacity)\n\n const anchor = parseTransformOrigin(computedStyle)\n await spatialModel3DComponent.setRotationAnchor(anchor)\n\n await this.setScrollWithParent(!isFixed)\n }\n\n async updateRectAndTransform(\n rect: RectType,\n spatialTransform: SpatialTransformType,\n ) {\n if (!this.entity || !this.spatialModel3DComponent) {\n return\n }\n\n const targetPosX = rect.x + rect.width / 2\n const targetPosY = rect.y + rect.height / 2\n\n const { position, rotation, scale } = spatialTransform\n const entity = this.entity\n entity.transform.position.x = targetPosX + position.x\n entity.transform.position.y = targetPosY + position.y\n entity.transform.position.z = position.z\n entity.transform.orientation.x = rotation.x\n entity.transform.orientation.y = rotation.y\n entity.transform.orientation.z = rotation.z\n entity.transform.orientation.w = rotation.w\n entity.transform.scale.x = scale.x\n entity.transform.scale.y = scale.y\n entity.transform.scale.z = scale.z\n await entity.updateTransform()\n const spatialModel3DComponent = this.spatialModel3DComponent\n await spatialModel3DComponent.setResolution(rect.width, rect.height)\n }\n\n async setRotationAnchor(anchor: { x: number; y: number; z: number }) {\n if (this.spatialModel3DComponent) {\n await this.spatialModel3DComponent.setRotationAnchor(anchor)\n }\n }\n\n async setOpacity(opacity: number) {\n if (this.spatialModel3DComponent) {\n this.spatialModel3DComponent.setOpacity(opacity)\n }\n }\n\n async setScrollWithParent(scrollWithParent: boolean) {\n if (this.spatialModel3DComponent) {\n this.spatialModel3DComponent.setScrollWithParent(scrollWithParent)\n }\n }\n\n async changeParentEntity(parentEntity: SpatialEntity) {\n if (this.parentEntity !== parentEntity) {\n if (this.entity) {\n await this.entity.setParent(parentEntity)\n }\n this.parentEntity = parentEntity\n }\n }\n\n public set onDragStart(\n callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined,\n ) {\n if (this.spatialModel3DComponent) {\n this.spatialModel3DComponent.onDragStart = callback\n }\n this._onDragStart = callback\n }\n\n public set onDrag(\n callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined,\n ) {\n if (this.spatialModel3DComponent) {\n this.spatialModel3DComponent.onDrag = callback\n }\n this._onDrag = callback\n }\n\n public set onDragEnd(\n callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined,\n ) {\n if (this.spatialModel3DComponent) {\n this.spatialModel3DComponent.onDragEnd = callback\n }\n this._onDragEnd = callback\n }\n\n public set onTap(callback: (() => void) | undefined) {\n if (this.spatialModel3DComponent) {\n this.spatialModel3DComponent.onTap = callback\n }\n this._onTap = callback\n }\n\n public set onDoubleTap(callback: (() => void) | undefined) {\n if (this.spatialModel3DComponent) {\n this.spatialModel3DComponent.onDoubleTap = callback\n }\n this._onDoubleTap = callback\n }\n public set onLongPress(callback: (() => void) | undefined) {\n if (this.spatialModel3DComponent) {\n this.spatialModel3DComponent.onLongPress = callback\n }\n this._onLongPress = callback\n }\n\n /**\n * Destroys the current 3D model instance\n * 1. Marks the instance as destroyed\n * 2. Waits for initialization to complete (if in progress)\n * 3. Destroys the spatial entity\n * 4. Cleans up all related references\n */\n async destroy() {\n this.isDestroyed = true\n if (this.initPromise) {\n await this.initPromise\n }\n this.entity?.destroy()\n this.entity = undefined\n this.spatialModel3DComponent = undefined\n this.initPromise = undefined\n }\n}\n","import { SpatialModelDragEvent } from '@webspatial/core-sdk'\n\nimport {\n ModelEvent,\n Model3DProps,\n ModelElement,\n ModelElementRef,\n ModelDragEvent,\n} from './types'\nimport { useDetectLayoutDomUpdated } from './useDetectLayoutDomUpdated'\nimport { useModel3DNative } from './useModel3DNative'\nimport { CSSProperties, useCallback, useEffect, useMemo } from 'react'\nimport { PopulatePartialSpatialTransformType } from './utils'\n\nexport function renderModel3DNotInSpatialDiv(\n props: Model3DProps,\n refIn: ModelElementRef,\n) {\n const {\n className,\n style = {},\n modelUrl,\n visible,\n spatialTransform,\n contentMode = 'fit',\n resizable = true,\n aspectRatio = 0,\n onLoad,\n\n children,\n\n onDragStart,\n onDrag,\n onDragEnd,\n\n onTap,\n onDoubleTap,\n onLongPress,\n } = props\n\n const theSpatialTransform =\n PopulatePartialSpatialTransformType(spatialTransform)\n\n const onDomUpdated = useCallback(() => {\n if (model3DNativeRef.current && layoutInstanceRef.current) {\n const model3DNative = model3DNativeRef.current\n model3DNative.updateByDom(layoutInstanceRef.current, {\n spatialTransform: theSpatialTransform,\n })\n }\n }, [\n theSpatialTransform.position.x,\n theSpatialTransform.position.y,\n theSpatialTransform.position.z,\n theSpatialTransform.rotation.x,\n theSpatialTransform.rotation.y,\n theSpatialTransform.rotation.z,\n theSpatialTransform.rotation.w,\n theSpatialTransform.scale.x,\n theSpatialTransform.scale.y,\n theSpatialTransform.scale.z,\n ])\n\n const onModel3DContainerReadyCb = useCallback(() => {\n if (model3DNativeRef.current && layoutInstanceRef.current) {\n model3DNativeRef.current.updateByDom(layoutInstanceRef.current, {\n spatialTransform: theSpatialTransform,\n })\n }\n }, [\n theSpatialTransform.position.x,\n theSpatialTransform.position.y,\n theSpatialTransform.position.z,\n theSpatialTransform.rotation.x,\n theSpatialTransform.rotation.y,\n theSpatialTransform.rotation.z,\n theSpatialTransform.rotation.w,\n theSpatialTransform.scale.x,\n theSpatialTransform.scale.y,\n theSpatialTransform.scale.z,\n ])\n\n const onDragStartCb = useCallback(\n (spatialDragEvent: SpatialModelDragEvent) => {\n if (onDragStart) {\n const dragEvent: ModelDragEvent = {\n ...spatialDragEvent,\n target: layoutInstanceRef.current! as ModelElement,\n }\n onDragStart(dragEvent)\n }\n },\n [onDragStart],\n )\n\n const onDragCb = useCallback(\n (spatialDragEvent: SpatialModelDragEvent) => {\n if (onDrag) {\n const dragEvent: ModelDragEvent = {\n ...spatialDragEvent,\n target: layoutInstanceRef.current! as ModelElement,\n }\n onDrag(dragEvent)\n }\n },\n [onDrag],\n )\n\n const onDragEndCb = useCallback(\n (spatialDragEvent: SpatialModelDragEvent) => {\n if (onDragEnd) {\n const dragEvent: ModelDragEvent = {\n ...spatialDragEvent,\n target: layoutInstanceRef.current! as ModelElement,\n }\n onDragEnd(dragEvent)\n }\n },\n [onDragEnd],\n )\n\n const onTapCb = useCallback(() => {\n if (onTap) {\n const event: ModelEvent = {\n target: layoutInstanceRef.current! as ModelElement,\n }\n onTap(event)\n }\n }, [onTap])\n\n const onDoubleTapCb = useCallback(() => {\n if (onDoubleTap) {\n const event: ModelEvent = {\n target: layoutInstanceRef.current! as ModelElement,\n }\n onDoubleTap(event)\n }\n }, [onDoubleTap])\n\n const onLongPressCb = useCallback(() => {\n if (onLongPress) {\n const event: ModelEvent = {\n target: layoutInstanceRef.current! as ModelElement,\n }\n onLongPress(event)\n }\n }, [onLongPress])\n\n const layoutInstanceRef = useDetectLayoutDomUpdated(onDomUpdated)\n const { model3DNativeRef, phase, failureReason } = useModel3DNative(\n modelUrl,\n undefined,\n {\n onDragStart: onDragStart ? onDragStartCb : undefined,\n onDrag: onDrag ? onDragCb : undefined,\n onDragEnd: onDragEnd ? onDragEndCb : undefined,\n onTap: onTap ? onTapCb : undefined,\n onDoubleTap: onDoubleTap ? onDoubleTapCb : undefined,\n onLongPress: onLongPress ? onLongPressCb : undefined,\n },\n onModel3DContainerReadyCb,\n )\n\n const onSuccess = useCallback(() => {\n ;(layoutInstanceRef.current! as ModelElement).ready = true\n if (onLoad) {\n onLoad({\n target: layoutInstanceRef.current! as ModelElement,\n })\n }\n }, [onLoad])\n\n const onFailure = useCallback(\n (_: string) => {\n const modelElement = layoutInstanceRef.current! as ModelElement\n modelElement.ready = false\n if (onLoad) {\n onLoad({\n target: layoutInstanceRef.current! as ModelElement,\n })\n }\n },\n [onLoad],\n )\n\n useEffect(() => {\n if (phase === 'failure') {\n onFailure(failureReason)\n } else if (phase === 'success') {\n onSuccess()\n }\n }, [phase])\n\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setVisible(visible)\n }\n }, [model3DNativeRef.current, visible])\n\n useEffect(() => {\n if (model3DNativeRef.current && layoutInstanceRef.current) {\n model3DNativeRef.current.updateByDom(layoutInstanceRef.current, {\n spatialTransform: theSpatialTransform,\n })\n }\n }, [\n theSpatialTransform.position.x,\n theSpatialTransform.position.y,\n theSpatialTransform.position.z,\n theSpatialTransform.rotation.x,\n theSpatialTransform.rotation.y,\n theSpatialTransform.rotation.z,\n theSpatialTransform.rotation.w,\n theSpatialTransform.scale.x,\n theSpatialTransform.scale.y,\n theSpatialTransform.scale.z,\n ])\n\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setContentMode(contentMode)\n }\n }, [model3DNativeRef.current, contentMode])\n\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setResizable(resizable)\n }\n }, [model3DNativeRef.current, resizable])\n\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setAspectRatio(aspectRatio)\n }\n }, [model3DNativeRef.current, aspectRatio])\n\n const layoutDomStyle: CSSProperties = {\n ...style,\n visibility: phase === 'failure' ? 'visible' : 'hidden',\n transform: '',\n }\n\n const proxyRef = useMemo(\n () =>\n new Proxy<typeof layoutInstanceRef>(layoutInstanceRef, {\n get(target, prop, receiver) {\n return Reflect.get(target, prop, receiver)\n },\n set(target, prop, value, receiver) {\n if (prop === 'current') {\n const domElement = value as ModelElement\n\n if (domElement) {\n domElement.ready = false\n domElement.currentSrc = modelUrl\n }\n\n if (refIn) {\n if (typeof refIn === 'function') {\n refIn(domElement)\n } else {\n refIn.current = domElement\n }\n }\n }\n return Reflect.set(target, prop, value, receiver)\n },\n }),\n [layoutInstanceRef, refIn],\n )\n\n useEffect(() => {\n return () => {\n if (layoutInstanceRef.current) {\n const modelElement = layoutInstanceRef.current as ModelElement\n\n modelElement.ready = false\n modelElement.currentSrc = modelUrl\n }\n }\n }, [modelUrl])\n\n return (\n <div className={className} style={layoutDomStyle} ref={proxyRef}>\n {phase === 'failure' && children}\n </div>\n )\n}\n","import { SpatialID } from '../SpatialReactComponent/const'\nimport { Model3DProps, ModelElementRef } from './types'\n\nexport function renderModel3DStandardInstance(\n spatialId: string,\n props: Model3DProps,\n refIn: ModelElementRef,\n) {\n const { className, style } = props\n const extraProps = {\n [SpatialID]: spatialId,\n }\n\n return (\n <div\n data-model3d-spatialid={spatialId}\n className={className}\n style={style}\n ref={refIn}\n {...extraProps}\n />\n )\n}\n","import React, {\n CSSProperties,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n} from 'react'\nimport { Model3DProps, ModelElement, ModelDragEvent, ModelEvent } from './types'\nimport { useSyncDomInfoFromStandardInstance } from './useSyncDomInfoFromStandardInstance'\nimport { useModel3DNative } from './useModel3DNative'\nimport { PopulatePartialSpatialTransformType } from './utils'\nimport { SpatialWindowManagerContext } from '../SpatialReactComponent/SpatialWindowManagerContext'\nimport { type SpatialModelDragEvent } from '@webspatial/core-sdk'\nimport { getSession } from '../../utils'\n\nfunction useModelEvents(\n props: Model3DProps,\n modelRef: React.RefObject<ModelElement>,\n) {\n const {\n onDragStart,\n onDrag,\n onDragEnd,\n\n onTap,\n onDoubleTap,\n onLongPress,\n } = props\n\n const onDragStartCb = useCallback(\n (spatialDragEvent: SpatialModelDragEvent) => {\n if (onDragStart) {\n const dragEvent: ModelDragEvent = {\n ...spatialDragEvent,\n target: modelRef.current! as ModelElement,\n }\n onDragStart(dragEvent)\n }\n },\n [onDragStart],\n )\n\n const onDragCb = useCallback(\n (spatialDragEvent: SpatialModelDragEvent) => {\n if (onDrag) {\n const dragEvent: ModelDragEvent = {\n ...spatialDragEvent,\n target: modelRef.current! as ModelElement,\n }\n onDrag(dragEvent)\n }\n },\n [onDrag],\n )\n\n const onDragEndCb = useCallback(\n (spatialDragEvent: SpatialModelDragEvent) => {\n if (onDragEnd) {\n const dragEvent: ModelDragEvent = {\n ...spatialDragEvent,\n target: modelRef.current! as ModelElement,\n }\n onDragEnd(dragEvent)\n }\n },\n [onDragEnd],\n )\n\n const onTapCb = useCallback(() => {\n if (onTap) {\n const event: ModelEvent = {\n target: modelRef.current! as ModelElement,\n }\n onTap(event)\n }\n }, [onTap])\n\n const onDoubleTapCb = useCallback(() => {\n if (onDoubleTap) {\n const event: ModelEvent = {\n target: modelRef.current! as ModelElement,\n }\n onDoubleTap(event)\n }\n }, [onDoubleTap])\n\n const onLongPressCb = useCallback(() => {\n if (onLongPress) {\n const event: ModelEvent = {\n target: modelRef.current! as ModelElement,\n }\n onLongPress(event)\n }\n }, [onLongPress])\n\n return {\n onDragStart: onDragStartCb,\n onDrag: onDragCb,\n onDragEnd: onDragEndCb,\n onTap: onTapCb,\n onDoubleTap: onDoubleTapCb,\n onLongPress: onLongPressCb,\n }\n}\n\nexport function renderModel3DPortalInstance(\n spatialId: string,\n props: Model3DProps,\n) {\n const {\n style: _,\n modelUrl,\n visible,\n spatialTransform,\n contentMode = 'fit',\n resizable = true,\n aspectRatio = 0,\n onLoad,\n\n children,\n } = props\n\n const theSpatialTransform = useMemo(() => {\n return PopulatePartialSpatialTransformType(spatialTransform)\n }, [spatialTransform])\n\n const {\n modelRef,\n domRect,\n inheritedPortalStyle,\n anchor,\n opacity,\n className,\n } = useSyncDomInfoFromStandardInstance(spatialId)\n\n const parentSpatialWindowManager = useContext(SpatialWindowManagerContext)\n\n const eventHandlers = useModelEvents(\n props,\n modelRef as React.RefObject<ModelElement>,\n )\n\n const { model3DNativeRef, phase, failureReason } = useModel3DNative(\n modelUrl,\n parentSpatialWindowManager!.entity!,\n eventHandlers,\n )\n\n // handle rect and transform\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.updateRectAndTransform(\n domRect,\n theSpatialTransform,\n )\n }\n }, [model3DNativeRef.current, domRect, theSpatialTransform])\n\n // handle anchor\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setRotationAnchor(anchor)\n }\n }, [model3DNativeRef.current, anchor])\n\n // handle visible\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setVisible(visible)\n }\n }, [model3DNativeRef.current, visible])\n\n // handle currentMode\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setContentMode(contentMode)\n }\n }, [model3DNativeRef.current, contentMode])\n\n // handle resizable\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setResizable(resizable)\n }\n }, [model3DNativeRef.current, resizable])\n\n // handle aspectRatio\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setAspectRatio(aspectRatio)\n }\n }, [model3DNativeRef.current, aspectRatio])\n\n // handle opacity\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setOpacity(opacity)\n }\n }, [model3DNativeRef.current, opacity])\n\n const isFixedPosition = inheritedPortalStyle.position == 'fixed'\n\n // handle scrollWithParent Properties\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setScrollWithParent(\n inheritedPortalStyle.position !== 'fixed',\n )\n\n if (isFixedPosition) {\n ;(async function () {\n var wc = await getSession()!.getCurrentWindowComponent()\n var ent = await wc.getEntity()\n model3DNativeRef.current?.changeParentEntity(ent!)\n })()\n }\n }\n }, [model3DNativeRef.current, isFixedPosition])\n\n // handle onLoad using onSuccess/onFailure\n const onSuccess = useCallback(() => {\n ;(modelRef.current! as ModelElement).ready = true\n if (onLoad) {\n onLoad({\n target: modelRef.current! as ModelElement,\n })\n }\n }, [onLoad])\n\n const onFailure = useCallback(\n (_: string) => {\n const modelElement = modelRef.current! as ModelElement\n modelElement.ready = false\n if (onLoad) {\n onLoad({\n target: modelRef.current! as ModelElement,\n })\n }\n },\n [onLoad],\n )\n\n useEffect(() => {\n if (phase === 'failure') {\n onFailure(failureReason)\n } else if (phase === 'success') {\n onSuccess()\n }\n }, [phase])\n\n // handle modelUrl change, need to reset ready/currentSrc\n useEffect(() => {\n return () => {\n const modelElement = modelRef.current! as ModelElement\n if (modelElement) {\n modelElement.ready = false\n modelElement.currentSrc = modelUrl\n }\n }\n }, [modelUrl])\n\n const needRenderPlaceHolder =\n inheritedPortalStyle.position !== 'absolute' &&\n inheritedPortalStyle.position !== 'fixed'\n\n if (!needRenderPlaceHolder && phase !== 'failure') {\n return <></>\n } else {\n const extraStyle: CSSProperties = {\n visibility: 'visible',\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 width: `${domRect.width}px`,\n height: `${domRect.height}px`,\n }\n\n const style: CSSProperties = {\n ...inheritedPortalStyle,\n ...extraStyle,\n }\n\n return (\n <div\n data-model3d-spatialid={spatialId}\n className={className}\n style={style}\n >\n {phase === 'failure' && children}\n </div>\n )\n }\n}\n","import { useRef, useEffect, useState, useContext, CSSProperties } from 'react'\nimport { SpatialReactContext } from '../SpatialReactComponent/SpatialReactContext'\nimport {\n getInheritedStyleProps,\n domRect2rectType,\n parseTransformOrigin,\n} from '../SpatialReactComponent/utils'\n\nexport function useSyncDomInfoFromStandardInstance(spatialId: string) {\n const [domRect, setDomRect] = useState({\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n })\n\n const inheritedPortalStyleRef = useRef<CSSProperties>({})\n\n const anchorRef = useRef({\n x: 0.5,\n y: 0.5,\n z: 0.5,\n })\n\n const opacityRef = useRef(1.0)\n\n const spatialReactContextObject = useContext(SpatialReactContext)\n\n const inheritedPortalClassNameRef = useRef('')\n\n const modelRef = useRef<HTMLDivElement | null>(null)\n\n useEffect(() => {\n const syncDomRect = () => {\n const dom = spatialReactContextObject?.querySpatialDom(spatialId)\n if (!dom) {\n return\n }\n modelRef.current = dom as HTMLDivElement\n\n const computedStyle = getComputedStyle(dom)\n inheritedPortalStyleRef.current = getInheritedStyleProps(computedStyle)\n const stylePosition = inheritedPortalStyleRef.current.position\n const isFixedPosition = stylePosition === 'fixed'\n\n let domRect = dom.getBoundingClientRect()\n let rectType = domRect2rectType(domRect)\n\n if (!isFixedPosition) {\n const parentDom =\n spatialReactContextObject?.queryParentSpatialDom(spatialId)\n if (parentDom) {\n const parentDomRect = parentDom.getBoundingClientRect()\n const parentRectType = domRect2rectType(parentDomRect)\n rectType.x -= parentRectType.x\n rectType.y -= parentRectType.y\n }\n }\n\n const anchor = parseTransformOrigin(computedStyle)\n anchorRef.current = anchor\n\n const opacity = parseFloat(computedStyle.getPropertyValue('opacity'))\n opacityRef.current = opacity\n\n inheritedPortalClassNameRef.current = dom.className\n\n setDomRect(rectType)\n }\n\n spatialReactContextObject?.onDomChange(spatialId, syncDomRect)\n\n return () => {\n spatialReactContextObject?.offDomChange(spatialId)\n }\n }, [])\n\n return {\n modelRef,\n domRect,\n inheritedPortalStyle: inheritedPortalStyleRef.current,\n anchor: anchorRef.current,\n opacity: opacityRef.current,\n className: inheritedPortalClassNameRef.current,\n }\n}\n","import { forwardRef, useContext, useMemo } from 'react'\nimport { CSSModel3DProps, ModelElementRef } from './types'\nimport { SpatialReactContext } from '../SpatialReactComponent/SpatialReactContext'\nimport { SpatialLayerContext } from '../SpatialReactComponent/SpatialLayerContext'\nimport { SpatialIsStandardInstanceContext } from '../SpatialReactComponent/SpatialIsStandardInstanceContext'\nimport { renderCSSModel3DNotInSpatialDiv } from './CSSModel3DNotInSpatialDiv'\nimport { renderCSSModel3DStandardInstance } from './CSSModel3DStandardInstance'\nimport { renderCSSModel3DPortalInstance } from './CSSModel3DPortalInstance'\n\nexport function CSSModel3DBase(props: CSSModel3DProps, refIn: ModelElementRef) {\n const rootSpatialReactContextObject = useContext(SpatialReactContext)\n const isInSpatialDiv = !!rootSpatialReactContextObject\n\n if (isInSpatialDiv) {\n const layer = useContext(SpatialLayerContext) + 1\n const isInStandardInstance = !!useContext(SpatialIsStandardInstanceContext)\n const spatialId = useMemo(() => {\n return rootSpatialReactContextObject.getSubDivSpatialID(\n layer,\n isInStandardInstance,\n 'CSSModel3D',\n )\n }, [])\n if (isInStandardInstance) {\n return renderCSSModel3DStandardInstance(spatialId, props, refIn)\n } else {\n return renderCSSModel3DPortalInstance(spatialId, props)\n }\n } else {\n return renderCSSModel3DNotInSpatialDiv(props, refIn)\n }\n}\n\nexport const CSSModel3D = forwardRef(CSSModel3DBase)\n\nCSSModel3D.displayName = 'CSSModel3D'\n","import { CSSProperties, ForwardedRef } from 'react'\nimport { Model3D } from './Model3D'\nimport { useSpatialStyle } from '../CSSSpatialDiv/useSpatialStyle'\nimport { useHijackSpatialDivRef } from '../CSSSpatialDiv/useHijackSpatialDivRef'\nimport { CSSModel3DProps, ModelElementRef } from './types'\n\nexport function renderCSSModel3DNotInSpatialDiv(\n inProps: CSSModel3DProps,\n refIn: ModelElementRef,\n) {\n const { className, style = {}, ...props } = inProps\n\n const cssParserDomStyle: CSSProperties = {\n ...style,\n width: 0,\n height: 0,\n padding: 0,\n position: 'absolute',\n }\n\n const { ref: cssParserDomRef, spatialStyle, ready } = useSpatialStyle()\n\n // hijack SpatialDiv ref\n const ref = useHijackSpatialDivRef(\n refIn as ForwardedRef<HTMLDivElement>,\n cssParserDomRef,\n ) as ModelElementRef\n\n const spatialTransform = {\n position: spatialStyle.position,\n rotation: spatialStyle.rotation,\n scale: spatialStyle.scale,\n }\n const visible = spatialStyle.visible\n\n const model3DStyle: CSSProperties = {\n ...style,\n transform: spatialStyle.transformExist ? 'translateZ(0)' : 'none',\n }\n return (\n <>\n {ready && (\n <Model3D\n className={className}\n style={model3DStyle}\n ref={ref}\n spatialTransform={spatialTransform}\n visible={visible}\n {...props}\n />\n )}\n <div\n className={className}\n style={cssParserDomStyle}\n ref={cssParserDomRef}\n />\n </>\n )\n}\n","import React, { ForwardedRef, useContext, useEffect, useRef } from 'react'\nimport { CSSModel3DProps, ModelElementRef } from './types'\nimport { useHijackSpatialDivRef } from '../CSSSpatialDiv/useHijackSpatialDivRef'\nimport { Model3D } from './Model3D'\nimport { CSSProperties } from 'react'\nimport { SpatialReactContext } from '../SpatialReactComponent/SpatialReactContext'\n\nexport function renderCSSModel3DStandardInstance(\n spatialId: string,\n inProps: CSSModel3DProps,\n refIn: ModelElementRef,\n) {\n const { style: inStyle = {}, ...props } = inProps\n const style: CSSProperties = {\n ...inStyle,\n transform: 'none',\n visibility: 'hidden',\n }\n\n // hijack SpatialDiv ref\n var cssParserRef = useRef<HTMLDivElement | null>(null)\n const ref = useHijackSpatialDivRef(\n refIn as ForwardedRef<HTMLDivElement>,\n cssParserRef,\n ) as ModelElementRef\n\n const rootSpatialReactContextObject = useContext(SpatialReactContext)!\n\n useEffect(() => {\n const onSubEvent = (dom: HTMLDivElement | null) => {\n cssParserRef.current = dom\n }\n rootSpatialReactContextObject.onSubDivEvent(spatialId, onSubEvent)\n\n return () => {\n rootSpatialReactContextObject.offSubDivEvent(spatialId)\n }\n }, [])\n\n return <Model3D style={style} {...props} ref={ref} visible={true} />\n}\n","import React, { useContext, useEffect } from 'react'\nimport { CSSModel3DProps } from './types'\nimport { Model3D } from './Model3D'\nimport { CSSProperties } from 'react'\nimport { SpatialReactContext } from '../SpatialReactComponent/SpatialReactContext'\nimport { useSpatialStyle } from '../CSSSpatialDiv/useSpatialStyle'\n\nexport function renderCSSModel3DPortalInstance(\n spatialId: string,\n inProps: CSSModel3DProps,\n) {\n const { className, style = {}, ...props } = inProps\n\n const rootSpatialReactContextObject = useContext(SpatialReactContext)!\n\n const { ref, spatialStyle, ready } = useSpatialStyle()\n\n const spatialTransform = {\n position: spatialStyle.position,\n rotation: spatialStyle.rotation,\n scale: spatialStyle.scale,\n }\n const visible = spatialStyle.visible\n\n useEffect(() => {\n rootSpatialReactContextObject.notifySubDivEvent(spatialId, ref.current)\n }, [ref.current])\n\n const cssParserDomStyle: CSSProperties = {\n ...style,\n width: 0,\n height: 0,\n padding: 0,\n position: 'absolute',\n }\n\n const model3DStyle: CSSProperties = {\n ...style,\n transform: spatialStyle.transformExist ? 'translateZ(0)' : 'none',\n }\n\n return (\n <>\n {ready && (\n <Model3D\n className={className}\n style={model3DStyle}\n spatialTransform={spatialTransform}\n visible={visible}\n {...props}\n />\n )}\n <div className={className} style={cssParserDomStyle} ref={ref} />\n </>\n )\n}\n","import type { WindowContainerOptions } from '@webspatial/core-sdk'\n\nexport function initScene(\n name: string,\n callback: (pre: WindowContainerOptions) => WindowContainerOptions,\n) {\n return\n}\n","//@ts-ignore\nimport { getSession } from '@webspatial/react-sdk'\n//@ts-ignore\nimport { defaultSceneConfig, XRApp } from '@webspatial/react-sdk'\n\nexport async function injectSceneHook() {\n if (!window.opener) return\n if ((window as any)._SceneHookOff) return\n\n await getSession()?.setLoading('show')\n // see this flag, we have done create the root scene\n\n function onContentLoaded(callback: any) {\n if (\n document.readyState === 'interactive' ||\n document.readyState === 'complete'\n ) {\n callback()\n } else {\n document.addEventListener('DOMContentLoaded', callback)\n }\n }\n\n onContentLoaded(async () => {\n let cfg = defaultSceneConfig\n if (typeof (window as any).xrCurrentSceneDefaults === 'function') {\n try {\n cfg = await (window as any).xrCurrentSceneDefaults?.()\n } catch (error) {\n console.error(error)\n }\n }\n // fixme: this duration is too short so that hide and show is at racing, so add a little delay to avoid\n await new Promise((resolve, reject) => {\n setTimeout(() => {\n resolve(null)\n }, 1000)\n })\n await getSession()?.setLoading('hide')\n await XRApp.getInstance().show(window, cfg)\n })\n}\n","//@ts-ignore\nimport { parseCornerRadius, getSession, XRApp } from '@webspatial/react-sdk'\nimport { injectSceneHook } from './injectSceneHook'\n\nconst isWebSpatialEnv = getSession() !== null\n\nconst SpatialGlobalCustomVars = {\n backgroundMaterial: '--xr-background-material',\n}\n\n// keep track of current html background material\nlet htmlBackgroundMaterial = ''\nfunction setCurrentWindowStyle(backgroundMaterial: string) {\n if (backgroundMaterial !== htmlBackgroundMaterial) {\n const session = getSession()!\n session.getCurrentWindowComponent().setStyle({\n material: { type: backgroundMaterial as any },\n })\n htmlBackgroundMaterial = backgroundMaterial\n }\n}\n\nfunction checkHtmlBackgroundMaterial() {\n const computedStyle = getComputedStyle(document.documentElement)\n\n const backgroundMaterial = computedStyle.getPropertyValue(\n SpatialGlobalCustomVars.backgroundMaterial,\n )\n\n setCurrentWindowStyle(backgroundMaterial || 'none')\n}\n\n// keep track of current corner radius\nlet htmlCornerRadius = {\n topLeading: 0,\n bottomLeading: 0,\n topTrailing: 0,\n bottomTrailing: 0,\n}\nfunction checkCornerRadius() {\n const computedStyle = getComputedStyle(document.documentElement)\n const cornerRadius = parseCornerRadius(computedStyle)\n setCornerRadius(cornerRadius)\n}\n\nfunction setCornerRadius(cornerRadius: any) {\n if (\n htmlCornerRadius.topLeading !== cornerRadius.topLeading ||\n htmlCornerRadius.bottomLeading !== cornerRadius.bottomLeading ||\n htmlCornerRadius.topTrailing !== cornerRadius.topTrailing ||\n htmlCornerRadius.bottomTrailing !== cornerRadius.bottomTrailing\n ) {\n const session = getSession()!\n if (!session) return\n session.getCurrentWindowComponent().setStyle({\n cornerRadius,\n })\n htmlCornerRadius.topLeading = cornerRadius.topLeading\n htmlCornerRadius.bottomLeading = cornerRadius.bottomLeading\n htmlCornerRadius.topTrailing = cornerRadius.topTrailing\n htmlCornerRadius.bottomTrailing = cornerRadius.bottomTrailing\n }\n}\n\nfunction setOpacity(opacity: number) {\n const session = getSession()!\n if (!session) return\n session.getCurrentWindowComponent().setOpacity(opacity)\n}\n\nfunction checkOpacity() {\n const computedStyle = getComputedStyle(document.documentElement)\n const opacity = parseFloat(computedStyle.getPropertyValue('opacity'))\n setOpacity(opacity)\n}\n\nasync function setHtmlVisible(visible: boolean) {\n const session = getSession()!\n if (!session) return\n const wc = session.getCurrentWindowComponent()\n const ent = await wc.getEntity()\n ent?.setVisible(visible)\n}\n\nfunction checkHtmlVisible() {\n const computedStyle = getComputedStyle(document.documentElement)\n const visibility = computedStyle.getPropertyValue('visibility') !== 'hidden'\n const widthGtZero = parseFloat(computedStyle.getPropertyValue('width')) > 0\n setHtmlVisible(visibility && widthGtZero)\n}\n\nfunction hijackDocumentElementStyle() {\n const rawDocumentStyle = document.documentElement.style\n const styleProxy = new Proxy(rawDocumentStyle, {\n set: function (target, key, value) {\n const ret = Reflect.set(target, key, value)\n\n if (key === SpatialGlobalCustomVars.backgroundMaterial) {\n setCurrentWindowStyle(value)\n }\n\n if (\n key === 'border-radius' ||\n key === 'borderRadius' ||\n key === 'border-top-left-radius' ||\n key === 'borderTopLeftRadius' ||\n key === 'border-top-right-radius' ||\n key === 'borderTopRightRadius' ||\n key === 'border-bottom-left-radius' ||\n key === 'borderBottomLeftRadius' ||\n key === 'border-bottom-right-radius' ||\n key === 'borderBottomRightRadius'\n ) {\n checkCornerRadius()\n }\n\n if (key === 'opacity') {\n checkOpacity()\n }\n\n if (key === 'visibility' || key === 'display') {\n checkHtmlVisible()\n }\n\n return ret\n },\n get: function (target, prop: string) {\n if (typeof target[prop as keyof CSSStyleDeclaration] === 'function') {\n return function (this: any, ...args: any[]) {\n if (prop === 'setProperty') {\n const [property, value] = args\n if (property === SpatialGlobalCustomVars.backgroundMaterial) {\n setCurrentWindowStyle(value)\n }\n } else if (prop === 'removeProperty') {\n const [property] = args\n if (property === SpatialGlobalCustomVars.backgroundMaterial) {\n setCurrentWindowStyle('none')\n }\n }\n return (target[prop as keyof CSSStyleDeclaration] as Function)(\n ...args,\n )\n }\n }\n return Reflect.get(target, prop)\n },\n })\n Object.defineProperty(document.documentElement, 'style', {\n get: function () {\n return styleProxy\n },\n })\n}\n\nfunction monitorExternalStyleChange() {\n const headObserver = new MutationObserver(function (mutationsList) {\n checkCSSProperties()\n })\n\n headObserver.observe(document.head, { childList: true, subtree: true })\n}\n\nfunction checkCSSProperties() {\n checkHtmlBackgroundMaterial()\n checkCornerRadius()\n checkOpacity()\n checkHtmlVisible()\n window.addEventListener('resize', checkHtmlVisible)\n}\n\nfunction hijackGetComputedStyle() {\n const rawFn = window.getComputedStyle.bind(window)\n window.getComputedStyle = (element, pseudoElt) => {\n if ((element as any).__isSpatialDiv) {\n return (element as any).__getComputedStyle(rawFn, pseudoElt)\n }\n return rawFn(element, pseudoElt)\n }\n}\n\nfunction hijackWindowOpen() {\n XRApp.getInstance().init()\n}\n\nfunction monitorHTMLAttributeChange() {\n const observer = new MutationObserver(mutations => {\n mutations.forEach(mutation => {\n if (mutation.type === 'attributes' && mutation.attributeName) {\n checkCSSProperties()\n }\n })\n })\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['style', 'class'],\n })\n}\n\nexport function spatialPolyfill() {\n if (!isWebSpatialEnv) {\n return\n }\n\n injectSceneHook()\n hijackWindowOpen()\n checkCSSProperties()\n hijackGetComputedStyle()\n hijackDocumentElementStyle()\n monitorExternalStyleChange()\n monitorHTMLAttributeChange()\n}\n","export * from './spatial-react-components'\nexport * from './utils'\nexport * from './XRApp'\nexport * from './initScene'\nexport * from './polyfill'\nexport const version = __WEBSPATIAL_REACT_SDK_VERSION__\n"],"mappings":";;;;;;;;;;AAAA,SAAS,cAAAA,mBAAuB;;;ACCzB,IAAM,aAA2B;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA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AA,EACF;AAEA,kBAAgB;AAChB,mBAAiB;AACjB,qBAAmB;AACnB,yBAAuB;AACvB,6BAA2B;AAC3B,6BAA2B;AAC3B,6BAA2B;AAC7B;;;AC/MO,IAAM,UAAU;","names":["forwardRef","forwardRef","useMemo","useContext","createContext","createContext","useRef","useEffect","useState","useContext","useContext","useRef","useEffect","createContext","useContext","useRef","useEffect","createContext","window","jsx","useEffect","useState","useRef","useContext","domRect","spatialWindowManager","createContext","jsx","jsxs","useMemo","useContext","isWebSpatialEnv","forwardRef","jsx","forwardRef","SpatialPrimitive","forwardRef","useRef","useEffect","useMemo","useRef","useEffect","useMemo","useEffect","useEffect","forwardRef","jsx","jsx","forwardRef","forwardRef","forwardRef","useContext","useEffect","useMemo","useRef","useCallback","useEffect","useRef","useState","useRef","useState","useCallback","useEffect","spatialStyle","createContext","useCallback","useCallback","createContext","createContext","jsx","jsxs","useMemo","useRef","useEffect","useContext","forwardRef","jsx","forwardRef","createSpatialPrimitive","CSSSpatialPrimitive","useRef","forwardRef","useEffect","jsx","forwardRef","useRef","useEffect","forwardRef","useMemo","useRef","useEffect","useState","forwardRef","useContext","useMemo","useRef","useEffect","useRef","useEffect","useState","useRef","useState","useEffect","useCallback","useEffect","useMemo","jsx","useCallback","useEffect","useMemo","jsx","useCallback","useContext","useEffect","useMemo","useRef","useEffect","useState","useContext","useState","useRef","useContext","useEffect","domRect","Fragment","jsx","useCallback","useMemo","useContext","useEffect","_","useContext","useMemo","forwardRef","forwardRef","useContext","useMemo","Fragment","jsx","jsxs","useContext","useEffect","useRef","jsx","useRef","useContext","useEffect","useContext","useEffect","Fragment","jsx","jsxs","useContext","useEffect","useContext","useMemo","forwardRef","Fragment","jsx","jsxs","useMemo","useState","useEffect","props","useRef","forwardRef"]}
1
+ {"version":3,"sources":["../../src/spatial-react-components/SpatialPrimitive.tsx","../../src/spatial-react-components/primitives.ts","../../src/spatial-react-components/SpatialReactComponent/SpatialReactComponent.tsx","../../src/noRuntime.ts","../../src/utils/getSession.ts","../../src/utils/debugTool.ts","../../src/spatial-react-components/SpatialReactComponent/StandardInstance.tsx","../../src/spatial-react-components/hooks/useForceUpdate.ts","../../src/spatial-react-components/SpatialReactComponent/SpatialIsStandardInstanceContext.ts","../../src/spatial-react-components/SpatialReactComponent/SpatialReactContext.ts","../../src/spatial-react-components/SpatialReactComponent/const.ts","../../src/spatial-react-components/SpatialReactComponent/PortalInstance.tsx","../../src/spatial-react-components/SpatialReactComponent/usePortalContainer.tsx","../../src/spatial-react-components/SpatialReactComponent/SpatialWindowManager.ts","../../src/spatial-react-components/SpatialReactComponent/SpatialWindowManagerContext.ts","../../src/spatial-react-components/SpatialReactComponent/utils.ts","../../src/spatial-react-components/SpatialReactComponent/SpatialDebugNameContext.ts","../../src/XRApp.ts","../../src/spatial-react-components/SpatialReactComponent/SpatialLayerContext.ts","../../src/spatial-react-components/SpatialMonitor/withSpatialMonitor.tsx","../../src/spatial-react-components/SpatialMonitor/useMonitorDomChange.tsx","../../src/spatial-react-components/notifyUpdateStandInstanceLayout.ts","../../src/spatial-react-components/SpatialMonitor/useMonitorDocumentHeaderChange.tsx","../../src/spatial-react-components/SpatialMonitor/SpatialMonitor.tsx","../../src/spatial-react-components/CSSSpatialDiv/CSSSpatialDiv.tsx","../../src/spatial-react-components/CSSSpatialDiv/CSSSpatialComponent.tsx","../../src/spatial-react-components/CSSSpatialDiv/useSpatialStyle.ts","../../src/spatial-react-components/CSSSpatialDiv/math/index.ts","../../src/spatial-react-components/CSSSpatialDiv/const.ts","../../src/spatial-react-components/CSSSpatialDiv/CSSSpatialDebugNameContext.ts","../../src/spatial-react-components/CSSSpatialDiv/useHijackSpatialDivRef.ts","../../src/spatial-react-components/CSSSpatialDiv/injectClassStyle.ts","../../src/spatial-react-components/CSSSpatialDiv/utils.ts","../../src/spatial-react-components/CSSSpatialDiv/CSSSpatialLayerContext.ts","../../src/spatial-react-components/CSSSpatialDiv/CSSSpatialRootContext.ts","../../src/spatial-react-components/SpatialView.tsx","../../src/spatial-react-components/Model/index.tsx","../../src/spatial-react-components/Model3D/Model3D.tsx","../../src/spatial-react-components/Model3D/useDetectLayoutDomUpdated.ts","../../src/spatial-react-components/Model3D/useModel3DNative.ts","../../src/spatial-react-components/Model3D/utils.ts","../../src/spatial-react-components/Model3D/Model3DNative.ts","../../src/spatial-react-components/Model3D/Model3DNotInSpatialDiv.tsx","../../src/spatial-react-components/Model3D/Model3DStandardInstance.tsx","../../src/spatial-react-components/Model3D/Model3DPortalInstance.tsx","../../src/spatial-react-components/Model3D/useSyncDomInfoFromStandardInstance.ts","../../src/spatial-react-components/Model3D/CSSModel3D.tsx","../../src/spatial-react-components/Model3D/CSSModel3DNotInSpatialDiv.tsx","../../src/spatial-react-components/Model3D/CSSModel3DStandardInstance.tsx","../../src/spatial-react-components/Model3D/CSSModel3DPortalInstance.tsx","../../src/initScene.web.ts","../../src/polyfill/injectSceneHook.ts","../../src/polyfill/spatialPolyfill.ts","../../src/index.ts"],"sourcesContent":["import { forwardRef, Ref } from 'react'\nimport { primitives } from './primitives'\nimport { SpatialReactComponent } from './SpatialReactComponent'\nimport React from 'react'\n\nconst cachedWithSpatialType = new Map()\n\nexport function withSpatial(Component: React.ElementType) {\n if (cachedWithSpatialType.has(Component)) {\n return cachedWithSpatialType.get(Component)\n } else {\n const WithSpatialComponent = forwardRef(\n (givenProps: any, givenRef: Ref<any>) => {\n const { component: ignoreComponent, ...props } = givenProps\n return (\n <SpatialReactComponent\n component={Component}\n {...props}\n ref={givenRef}\n />\n )\n },\n )\n WithSpatialComponent.displayName = `WithSpatial(${typeof Component === 'string' ? Component : Component.displayName || Component.name})`\n\n cachedWithSpatialType.set(Component, WithSpatialComponent)\n cachedWithSpatialType.set(WithSpatialComponent, WithSpatialComponent)\n return WithSpatialComponent\n }\n}\n\nexport const SpatialPrimitive: Record<string, typeof SpatialReactComponent> = {}\n;(function createSpatialPrimitive(SpatialPrimitive) {\n primitives.forEach(primitive => {\n SpatialPrimitive[primitive] = withSpatial(primitive)\n })\n})(SpatialPrimitive)\n\nexport const SpatialDiv = SpatialPrimitive.div\n","export type Primitives = keyof JSX.IntrinsicElements\nexport const primitives: Primitives[] = [\n 'a',\n 'abbr',\n 'address',\n 'area',\n 'article',\n 'aside',\n 'audio',\n 'b',\n 'base',\n 'bdi',\n 'bdo',\n 'big',\n 'blockquote',\n 'body',\n 'br',\n 'button',\n 'canvas',\n 'caption',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'data',\n 'datalist',\n 'dd',\n 'del',\n 'details',\n 'dfn',\n 'dialog',\n 'div',\n 'dl',\n 'dt',\n 'em',\n 'embed',\n 'fieldset',\n 'figcaption',\n 'figure',\n 'footer',\n 'form',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'head',\n 'header',\n 'hgroup',\n 'hr',\n 'html',\n 'i',\n 'iframe',\n 'img',\n 'input',\n 'ins',\n 'kbd',\n 'keygen',\n 'label',\n 'legend',\n 'li',\n 'link',\n 'main',\n 'map',\n 'mark',\n 'menu',\n 'menuitem',\n 'meta',\n 'meter',\n 'nav',\n 'noscript',\n 'object',\n 'ol',\n 'optgroup',\n 'option',\n 'output',\n 'p',\n 'param',\n 'picture',\n 'pre',\n 'progress',\n 'q',\n 'rp',\n 'rt',\n 'ruby',\n 's',\n 'samp',\n 'script',\n 'section',\n 'select',\n 'small',\n 'source',\n 'span',\n 'strong',\n 'style',\n 'sub',\n 'summary',\n 'sup',\n 'table',\n 'tbody',\n 'td',\n 'textarea',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n 'title',\n 'tr',\n 'track',\n 'u',\n 'ul',\n 'var',\n 'video',\n 'wbr',\n // SVG\n 'circle',\n 'clipPath',\n 'defs',\n 'ellipse',\n 'foreignObject',\n 'g',\n 'image',\n 'line',\n 'linearGradient',\n 'mask',\n 'path',\n 'pattern',\n 'polygon',\n 'polyline',\n 'radialGradient',\n 'rect',\n 'stop',\n 'svg',\n 'text',\n 'tspan',\n]\n","import { forwardRef, useMemo, useContext } from 'react'\nimport {\n SpatialReactComponentProps,\n SpatialReactComponentRef,\n SpatialReactComponentWithUniqueIDProps,\n} from './types'\nimport { getSession } from '../../utils'\nimport { StandardInstance } from './StandardInstance'\nimport { PortalInstance } from './PortalInstance'\nimport {\n SpatialReactContext,\n SpatialReactContextObject,\n} from './SpatialReactContext'\nimport { SpatialIsStandardInstanceContext } from './SpatialIsStandardInstanceContext'\nimport { SpatialID } from './const'\nimport { SpatialLayerContext } from './SpatialLayerContext'\nimport { SpatialDebugNameContext } from './SpatialDebugNameContext'\n\nfunction parseProps(inProps: SpatialReactComponentWithUniqueIDProps) {\n const {\n debugShowStandardInstance,\n debugName = '',\n component,\n allowScroll,\n spatialStyle,\n scrollWithParent,\n ...props\n } = inProps\n\n const El = component ? component : 'div'\n\n const componentDesc = { El }\n const spatialDesc = { spatialStyle, allowScroll, scrollWithParent }\n const debugDesc = { debugName, debugShowStandardInstance }\n return { componentDesc, spatialDesc, debugDesc, props }\n}\n\nfunction renderWebReactComponent(\n inProps: SpatialReactComponentWithUniqueIDProps,\n ref: SpatialReactComponentRef,\n) {\n const { componentDesc, props } = parseProps(inProps)\n const { El } = componentDesc\n return <El {...props} ref={ref} />\n}\n\nfunction renderSpatialReactComponent(\n inProps: SpatialReactComponentWithUniqueIDProps,\n ref: SpatialReactComponentRef,\n) {\n const { componentDesc, spatialDesc, debugDesc, props } = parseProps(inProps)\n\n const standardInstanceProps = {\n ...props,\n ...componentDesc,\n debugShowStandardInstance: debugDesc.debugShowStandardInstance,\n }\n\n const portalInstanceProps = {\n ...props,\n ...componentDesc,\n ...spatialDesc,\n }\n\n const spatialReactContextObject = useMemo(\n () => new SpatialReactContextObject(debugDesc.debugName),\n [],\n )\n\n return (\n <SpatialReactContext.Provider value={spatialReactContextObject}>\n <StandardInstance {...standardInstanceProps} ref={ref} />\n <PortalInstance isSubPortal={false} {...portalInstanceProps} />\n </SpatialReactContext.Provider>\n )\n}\n\nfunction renderSubPortalInstance(\n inProps: SpatialReactComponentWithUniqueIDProps,\n) {\n const { componentDesc, spatialDesc, props } = parseProps(inProps)\n const portalInstanceProps = {\n ...props,\n ...componentDesc,\n ...spatialDesc,\n }\n\n return <PortalInstance isSubPortal={true} {...portalInstanceProps} />\n}\n\nfunction SpatialReactComponentRefactor(\n inProps: SpatialReactComponentProps,\n ref: SpatialReactComponentRef,\n) {\n const layer = useContext(SpatialLayerContext) + 1\n\n const parentSpatialReactContextObject = useContext(SpatialReactContext)\n const isRootInstance = !parentSpatialReactContextObject\n const isInStandardInstance = !!useContext(SpatialIsStandardInstanceContext)\n const spatialID = useMemo(() => {\n return isRootInstance\n ? layer.toString()\n : parentSpatialReactContextObject.getSpatialID(\n layer,\n isInStandardInstance,\n inProps.debugName,\n )\n }, [])\n\n const props = { ...inProps, [SpatialID]: spatialID }\n\n const contentInLayer = renderContentInLayer(props, ref)\n return (\n <SpatialDebugNameContext.Provider value={inProps.debugName || ''}>\n <SpatialLayerContext.Provider value={layer}>\n {contentInLayer}\n </SpatialLayerContext.Provider>\n </SpatialDebugNameContext.Provider>\n )\n}\n\nfunction renderContentInLayer(\n inProps: SpatialReactComponentWithUniqueIDProps,\n ref: SpatialReactComponentRef,\n) {\n const isInStandardInstance = useContext(SpatialIsStandardInstanceContext)\n const isWebSpatialEnv = getSession() !== null\n if (isInStandardInstance || !isWebSpatialEnv) {\n return renderWebReactComponent(inProps, ref)\n } else {\n const parentSpatialReactContextObject = useContext(SpatialReactContext)\n if (parentSpatialReactContextObject) {\n return renderSubPortalInstance(inProps)\n } else {\n return renderSpatialReactComponent(inProps, ref)\n }\n }\n}\n\nexport const SpatialReactComponent = forwardRef(SpatialReactComponentRefactor)\n\nSpatialReactComponent.displayName = 'SpatialReactComponent'\n","// Redirect to empty module for treeshaking\nexport default {}\n\nexport const SpatialHelper = {}\n\nexport class Spatial {\n /**\n * Requests a session object from the browser\n * @returns The session or null if not availible in the current browser\n * [TODO] discuss implications of this not being async\n */\n requestSession() {\n return null\n }\n /**\n * @returns true if web spatial is supported by this webpage\n */\n isSupported() {\n return false\n }\n /**\n * Gets the native version, format is \"x.x.x\"\n * @returns native version string\n */\n getNativeVersion() {\n return null\n }\n /**\n * Gets the client version, format is \"x.x.x\"\n * @returns client version string\n */\n getClientVersion() {\n return null\n }\n}\n\nexport const version = undefined // no runtime so this should set undefined\n","import { Spatial, SpatialSession } from '@webspatial/core-sdk'\n// Create the default Spatial session for the app\nlet spatial: Spatial | null = null\nlet _currentSession: SpatialSession | null = null\n/** @hidden */\nexport function getSession() {\n if (!spatial) {\n spatial = new Spatial()\n }\n if (!spatial.isSupported()) {\n return null\n }\n if (_currentSession) {\n return _currentSession\n }\n _currentSession = spatial.requestSession()\n return _currentSession\n}\n\nexport { spatial }\n","import { getSession } from './getSession'\n\nasync function getStat() {\n const statsInfo = await getSession()!._getStats()\n\n return statsInfo\n}\n\nfunction simplifyEntityTree(rootTree: any) {\n const rootEntity = Object.values(rootTree.childEntities)[0]\n\n function traverseTree(node: any, parent: any, callback: any) {\n callback(node, parent)\n\n const childrenNodes = Object.values(node.childEntities)\n if (childrenNodes) {\n childrenNodes.forEach(child => {\n traverseTree(child, node, callback)\n })\n }\n }\n\n let rootNode\n const nodeMap: Record<string, any> = {}\n function visitNode(node: any, parent: any) {\n let newNode = {\n id: node.id,\n name: node.name,\n children: [],\n position: node.position,\n scale: node.scale,\n width: node.components[0].resolutionX,\n height: node.components[0].resolutionY,\n zIndex: node.zIndex,\n visible: node.visible,\n cornerRadius: node.components[0].cornerRadius,\n backgroundMaterial: node.components[0].backgroundMaterial,\n isOpaque: node.components[0].isOpaque,\n isScrollEnabled: node.components[0].isScrollEnabled,\n scrollWithParent: node.components[0].scrollWithParent,\n }\n nodeMap[node.id] = newNode\n\n if (!parent) {\n rootNode = newNode\n } else {\n const parentNode = nodeMap[parent.id]\n parentNode.children.push(newNode)\n }\n }\n\n traverseTree(rootEntity, null, visitNode)\n console.log('rootNode', rootNode)\n return rootNode\n}\n\nasync function inspectRootWindowContainer(simple?: boolean) {\n const rootWindowContainerInfo =\n await getSession()!._inspectRootWindowContainer()\n console.log(rootWindowContainerInfo)\n\n if (simple) {\n return simplifyEntityTree(rootWindowContainerInfo)\n }\n return rootWindowContainerInfo\n}\n\nexport function enableDebugTool() {\n const session = getSession()\n Object.assign(window, {\n session,\n getStat,\n inspectRootWindowContainer,\n })\n}\n","import React, {\n CSSProperties,\n useRef,\n ReactNode,\n useLayoutEffect,\n useEffect,\n useContext,\n forwardRef,\n} from 'react'\nimport { useForceUpdate } from '../hooks/useForceUpdate'\nimport { SpatialIsStandardInstanceContext } from './SpatialIsStandardInstanceContext'\nimport { SpatialReactContext } from './SpatialReactContext'\nimport { SpatialReactComponentRef } from './types'\n\nfunction useDetectDomRectChange() {\n const ref = useRef<HTMLElement>(null)\n\n const forceUpdate = useForceUpdate()\n\n const spatialReactContextObject = useContext(SpatialReactContext)\n\n useLayoutEffect(() => {\n ref.current && spatialReactContextObject?.notifyDomChange(ref.current)\n })\n\n // listen to webview container size change and notifyDomChange\n // document.body.clientWidth may change as page loads.\n // when creating a new scene, clientWidth changes from 0 to some positive value.\n // this cannot be detected by ResizeObserver which only observe the dom element itself\n useEffect(() => {\n if (!ref.current || !spatialReactContextObject) {\n console.warn(\n 'Ref is not attached to the DOM or spatialReactContextObject is not available',\n )\n return\n }\n\n const handleResize = () => {\n forceUpdate()\n }\n\n window.addEventListener('resize', handleResize)\n\n return () => {\n window.removeEventListener('resize', handleResize)\n }\n }, [spatialReactContextObject])\n\n // detect dom resize\n // Trigger native resize on web resize events\n useEffect(() => {\n if (!ref.current) {\n console.warn('Ref is not attached to the DOM')\n return\n }\n\n let ro = new ResizeObserver(elements => {\n forceUpdate()\n })\n\n ro.observe(ref.current!)\n return () => {\n ro.disconnect()\n }\n }, [])\n\n // detect dom style and class change\n useEffect(() => {\n if (!ref.current) {\n console.warn('Ref is not attached to the DOM')\n return\n }\n let ro = new MutationObserver(elements => {\n forceUpdate()\n })\n ro.observe(ref.current!, {\n attributeFilter: ['class', 'style'],\n subtree: true,\n })\n return () => {\n ro.disconnect()\n }\n }, [])\n\n return ref\n}\n\ninterface StandardInstanceProps {\n El: React.ElementType\n children?: ReactNode\n style?: CSSProperties | undefined\n\n // for debug\n debugShowStandardInstance?: boolean\n}\nexport const StandardInstance = forwardRef(function (\n inProps: StandardInstanceProps,\n refIn: SpatialReactComponentRef,\n) {\n const { El, style: inStyle, debugShowStandardInstance, ...props } = inProps\n const extraStyle = {\n visibility: debugShowStandardInstance ? undefined : 'hidden',\n transition: 'none',\n }\n const style = { ...inStyle, ...extraStyle }\n\n var ref = useDetectDomRectChange()\n\n const proxyRef = new Proxy<typeof ref>(ref, {\n get(target, prop, receiver) {\n return Reflect.get(target, prop, receiver)\n },\n set(target, prop, value, receiver) {\n if (prop === 'current') {\n const domElement = value as HTMLDivElement\n if (refIn) {\n if (typeof refIn === 'function') {\n refIn(domElement)\n } else {\n refIn.current = domElement\n }\n }\n }\n return Reflect.set(target, prop, value, receiver)\n },\n })\n\n return (\n <SpatialIsStandardInstanceContext.Provider value={true}>\n <El data-standardinstance ref={proxyRef} style={style} {...props} />\n </SpatialIsStandardInstanceContext.Provider>\n )\n})\n\nStandardInstance.displayName = 'StandardInstance'\n","import { useState } from 'react'\n\nexport function useForceUpdate() {\n const [, setToggle] = useState(false)\n return () => setToggle(toggle => !toggle)\n}\n","import { createContext } from 'react'\n\nexport const SpatialIsStandardInstanceContext = createContext(\n null as null | boolean,\n)\n","import { createContext } from 'react'\nimport { SpatialID } from './const'\n\nexport class SpatialReactContextObject {\n debugName: string\n\n constructor(debugName: string) {\n this.debugName = debugName\n }\n\n dom: HTMLElement | null = null\n domSpatialId: string | null = null\n\n private fns: Record<string, () => void> = {}\n // cache dom for each spatialId\n private spatialId2dom: Record<string, HTMLElement> = {}\n private spatialId2parentSpatialDom: Record<string, HTMLElement> = {}\n\n // layer : [standardInstance sequence, portalInstance sequence]\n private layerSequences: Record<number, [number, number]> = {}\n\n public getSpatialID(\n layer: number,\n isInStandardInstance: boolean,\n debugName: string = '',\n ): string {\n if (this.layerSequences[layer] === undefined) {\n this.layerSequences[layer] = [0, 0]\n }\n const idx = isInStandardInstance ? 0 : 1\n const sequenceId = this.layerSequences[layer][idx]\n this.layerSequences[layer][idx] = sequenceId + 1\n const spatialId = `${debugName}_${layer}_${sequenceId}`\n\n return spatialId\n }\n\n public onDomChange(spatialId: string, fn: () => void) {\n this.fns[spatialId] = fn\n if (this.dom) {\n fn()\n }\n }\n\n public offDomChange(spatialId: string) {\n delete this.fns[spatialId]\n delete this.spatialId2dom[spatialId]\n delete this.spatialId2parentSpatialDom[spatialId]\n }\n\n public notifyDomChange(dom: HTMLElement) {\n this.dom = dom\n this.domSpatialId = dom.getAttribute(SpatialID)\n Object.values(this.fns).forEach(fn => fn())\n }\n\n public querySpatialDom(spatialId: string) {\n if (this.domSpatialId === spatialId) {\n return this.dom\n }\n if (!this.dom) {\n return null\n }\n if (!this.spatialId2dom[spatialId]) {\n const spatialDom = this.dom.querySelector(`[${SpatialID}=\"${spatialId}\"]`)\n\n if (spatialDom) {\n this.spatialId2dom[spatialId] = spatialDom as HTMLElement\n }\n }\n return this.spatialId2dom[spatialId]\n }\n\n public queryParentSpatialDom(spatialId: string) {\n if (this.domSpatialId === spatialId) {\n return null\n }\n\n if (this.spatialId2parentSpatialDom[spatialId]) {\n // early return if already found\n return this.spatialId2parentSpatialDom[spatialId]\n }\n\n let spatialDom = this.querySpatialDom(spatialId)\n if (spatialDom) {\n if (spatialDom === this.dom) return null\n let parentSpatialDom = spatialDom.parentElement as HTMLElement\n while (parentSpatialDom && spatialDom !== this.dom) {\n if (parentSpatialDom.hasAttribute(SpatialID)) {\n break\n } else {\n parentSpatialDom = parentSpatialDom.parentElement as HTMLElement\n }\n }\n\n this.spatialId2parentSpatialDom[spatialId] = parentSpatialDom\n return parentSpatialDom\n }\n return null\n }\n\n // Used for CSSModel3D\n // layer : [standardInstance sequence, portalInstance sequence]\n private subDivLayerSequences: Record<number, [number, number]> = {}\n private subDivEventHandlers: Record<string, (args: any) => void> = {}\n\n public getSubDivSpatialID(\n layer: number,\n isInStandardInstance: boolean,\n prefix: string = '',\n ): string {\n if (this.subDivLayerSequences[layer] === undefined) {\n this.subDivLayerSequences[layer] = [0, 0]\n }\n const idx = isInStandardInstance ? 0 : 1\n const sequenceId = this.subDivLayerSequences[layer][idx]\n this.subDivLayerSequences[layer][idx] = sequenceId + 1\n const spatialId = `${prefix}_${layer}_${sequenceId}`\n\n return spatialId\n }\n\n public onSubDivEvent(\n subSpatialId: string,\n eventHandler: (args: any) => void,\n ) {\n this.subDivEventHandlers[subSpatialId] = eventHandler\n }\n\n public offSubDivEvent(subSpatialId: string) {\n delete this.subDivEventHandlers[subSpatialId]\n }\n public notifySubDivEvent(subSpatialId: string, args: any) {\n const eventHandler = this.subDivEventHandlers[subSpatialId]\n if (eventHandler) {\n eventHandler(args)\n }\n }\n}\n\nexport const SpatialReactContext =\n createContext<SpatialReactContextObject | null>(null)\n","export const SpatialID = 'data-spatial-id'\n","import React, {\n CSSProperties,\n useRef,\n ReactNode,\n useCallback,\n useEffect,\n useState,\n useContext,\n useMemo,\n} from 'react'\nimport { createPortal } from 'react-dom'\nimport { usePortalContainer } from './usePortalContainer'\nimport { SpatialWindowManagerContext } from './SpatialWindowManagerContext'\nimport { SpatialWindowManager } from './SpatialWindowManager'\n\nimport {\n domRect2rectType,\n getInheritedStyleProps,\n parseCornerRadius,\n parseTransformOrigin,\n} from './utils'\nimport { SpatialReactContext } from './SpatialReactContext'\nimport { SpatialID } from './const'\nimport { SpatialDebugNameContext } from './SpatialDebugNameContext'\nimport { CornerRadius } from '@webspatial/core-sdk'\nimport { RectType, vecType } from '../types'\nimport { spatialStyleDef } from './types'\nimport { XRApp } from '../../XRApp'\n\ninterface PortalInstanceProps {\n allowScroll?: boolean\n scrollWithParent?: boolean\n spatialStyle?: Partial<spatialStyleDef>\n\n El: React.ElementType\n children?: ReactNode\n style?: CSSProperties | undefined\n className?: string\n\n isSubPortal: boolean\n\n [SpatialID]: string\n}\n\nfunction renderJSXPortalInstance(\n inProps: Omit<\n PortalInstanceProps,\n 'allowScroll' | 'scrollWithParent' | 'spatialStyle' | 'isSubPortal'\n >,\n\n inheritedPortalStyle: CSSProperties,\n className: string,\n) {\n const { El, style: inStyle = {}, className: _, ...props } = inProps\n const extraStyle = {\n visibility: 'visible',\n position: '',\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 }\n\n const style = {\n ...inStyle,\n ...inheritedPortalStyle,\n ...extraStyle,\n }\n\n return <El style={style} className={className} {...props} />\n}\n\nfunction setOpenWindowStyle(openedWindow: Window) {\n openedWindow!.document.documentElement.style.cssText +=\n document.documentElement.style.cssText\n\n openedWindow!.document.documentElement.style.backgroundColor = 'transparent'\n openedWindow!.document.body.style.margin = '0px'\n}\n\nfunction handleOpenWindowDocumentClick(openedWindow: Window) {\n // Overwrite link href to navigate the parents page\n openedWindow!.document.onclick = function (e) {\n let element = e.target as HTMLElement | null\n let found = false\n\n // Look for <a> element in the clicked elements parents and if found override navigation behavior if needed\n while (!found) {\n if (element && element.tagName == 'A') {\n // When using libraries like react route's <Link> it sets an onclick event, when this happens we should do nothing and let that occur\n\n // if onClick is set for the element, the raw onclick will be noop() trapped so the onclick check is no longer trustable\n // we handle all the scenarios\n XRApp.getInstance().handleATag(e)\n return false // prevent default action and stop event propagation\n }\n if (element && element.parentElement) {\n element = element.parentElement\n } else {\n break\n }\n }\n }\n}\n\nfunction asyncLoadStyleToChildWindow(\n childWindow: WindowProxy,\n n: HTMLLinkElement,\n debugName: string,\n) {\n return new Promise(resolve => {\n // Safari seems to have a bug where\n // ~1/50 loads, if the same url is loaded very quickly in a window and a child window,\n // the second load request never is fired resulting in css not to be applied.\n // Workaround this by making the css stylesheet request unique\n n.href += '?uniqueURL=' + Math.random()\n n.onerror = function () {\n console.error(\n 'Failed to load style link',\n debugName,\n (n as HTMLLinkElement).href,\n )\n resolve(false)\n }\n n.onload = function () {\n resolve(true)\n }\n\n childWindow.document.head.appendChild(n)\n })\n}\n\nasync function syncParentHeadToChild(\n childWindow: WindowProxy,\n debugName: string,\n) {\n const styleLoadedPromises = []\n\n for (let i = 0; i < document.head.children.length; i++) {\n let n = document.head.children[i].cloneNode(true)\n if (\n n.nodeName == 'LINK' &&\n (n as HTMLLinkElement).rel == 'stylesheet' &&\n (n as HTMLLinkElement).href\n ) {\n const promise = asyncLoadStyleToChildWindow(\n childWindow,\n n as HTMLLinkElement,\n debugName,\n )\n styleLoadedPromises.push(promise)\n } else {\n childWindow.document.head.appendChild(n)\n }\n }\n\n if (debugName) {\n childWindow.document.title = debugName\n }\n\n // sync className\n childWindow.document.documentElement.className =\n document.documentElement.className\n\n return Promise.all(styleLoadedPromises)\n}\n\nasync function syncHeaderStyle(openedWindow: Window, debugName: string) {\n // Synchronize head of parent page to this page to ensure styles are in sync\n await syncParentHeadToChild(openedWindow, debugName)\n\n const headObserver = new MutationObserver(mutations => {\n syncParentHeadToChild(openedWindow, debugName)\n })\n\n headObserver.observe(document.head, { childList: true, subtree: true })\n\n return headObserver\n}\n\nfunction syncDefaultSpatialStyle(openedWindow: Window, debugName: string) {\n const styleElement = document.createElement('style')\n styleElement.type = 'text/css'\n styleElement.innerHTML =\n ' .xr-spatial-default { --xr-back: 0.001; --xr-background-material: none } '\n openedWindow.document.head.appendChild(styleElement)\n // openedWindow body's width and height should be set to inline-block to make sure the width and height are correct\n openedWindow.document.body.style.display = 'inline-block'\n openedWindow.document.body.style.minWidth = 'auto'\n openedWindow.document.body.style.minHeight = 'auto'\n openedWindow.document.body.style.maxWidth = 'fit-content'\n openedWindow.document.body.style.minWidth = 'fit-content'\n openedWindow.document.body.style.background = 'transparent'\n}\n\nfunction useSyncSpatialProps(\n spatialWindowManager: SpatialWindowManager | undefined,\n props: Pick<\n PortalInstanceProps,\n 'style' | 'allowScroll' | 'scrollWithParent' | 'spatialStyle'\n >,\n domRect: RectType,\n anchor: vecType,\n cornerRadiusFromStyle: CornerRadius,\n opacity: number,\n stylePosition: string | undefined,\n isSubPortal: boolean,\n) {\n let { allowScroll, scrollWithParent, style, spatialStyle = {} } = props\n let {\n position = { x: 0, y: 0, z: 0 },\n rotation = { x: 0, y: 0, z: 0, w: 1 },\n scale = { x: 1, y: 1, z: 1 },\n material = { type: 'none' },\n cornerRadius = cornerRadiusFromStyle,\n zIndex = 0,\n } = spatialStyle\n\n let styleOverflow = style?.overflow\n\n const visible = useMemo(() => {\n return (\n spatialStyle.visible !== false && domRect.width > 0 && domRect.height > 0\n )\n }, [spatialStyle.visible, domRect.width, domRect.height])\n\n // fill default values for position\n if (position.x === undefined) position.x = 0\n if (position.y === undefined) position.y = 0\n if (position.z === undefined) position.z = 1\n\n // fill default values for scale\n if (scale.x === undefined) scale.x = 1\n if (scale.y === undefined) scale.y = 1\n if (scale.z === undefined) scale.z = 1\n\n // fill cornerRadius Object\n const cornerRadiusObject: CornerRadius = {\n topLeading: 0,\n bottomLeading: 0,\n topTrailing: 0,\n bottomTrailing: 0,\n }\n if (typeof cornerRadius == 'number') {\n cornerRadiusObject.topLeading = cornerRadius\n cornerRadiusObject.bottomLeading = cornerRadius\n cornerRadiusObject.topTrailing = cornerRadius\n cornerRadiusObject.bottomTrailing = cornerRadius\n } else {\n Object.assign(cornerRadiusObject, cornerRadius)\n }\n\n const isFixedPosition = stylePosition == 'fixed'\n useEffect(() => {\n if (spatialWindowManager && spatialWindowManager.webview) {\n spatialWindowManager.updateCSSPosition(isFixedPosition)\n }\n }, [spatialWindowManager, isFixedPosition])\n\n // Sync prop updates\n useEffect(() => {\n if (spatialWindowManager && spatialWindowManager.webview) {\n const webview = spatialWindowManager.webview\n ;(async function () {\n webview.setStyle({\n material: { type: material.type },\n cornerRadius: cornerRadiusObject,\n })\n })()\n }\n }, [\n spatialWindowManager,\n material.type,\n cornerRadiusObject.topLeading,\n cornerRadiusObject.bottomLeading,\n cornerRadiusObject.topTrailing,\n cornerRadiusObject.bottomTrailing,\n ])\n\n useEffect(() => {\n if (spatialWindowManager && spatialWindowManager.webview) {\n const webview = spatialWindowManager.webview\n ;(async function () {\n webview.setScrollEnabled(allowScroll || styleOverflow == 'scroll')\n\n const isFixed = scrollWithParent == false || isFixedPosition\n webview.setScrollWithParent(!isFixed)\n })()\n }\n }, [\n spatialWindowManager,\n allowScroll,\n scrollWithParent,\n isFixedPosition,\n styleOverflow,\n ])\n\n useEffect(() => {\n if (spatialWindowManager && spatialWindowManager.webview) {\n const webview = spatialWindowManager.webview\n ;(async function () {\n webview.setScrollEnabled(allowScroll || styleOverflow == 'scroll')\n\n const isFixed = scrollWithParent == false || stylePosition == 'fixed'\n webview.setScrollWithParent(!isFixed)\n })()\n }\n }, [spatialWindowManager, allowScroll, scrollWithParent, stylePosition])\n\n useEffect(() => {\n if (spatialWindowManager) {\n ;(async function () {\n await spatialWindowManager.resize(\n domRect,\n position as vecType,\n rotation,\n scale as vecType,\n anchor,\n isSubPortal ? 0 : window.scrollY,\n )\n\n spatialWindowManager?.setZIndex(zIndex)\n })()\n }\n }, [\n spatialWindowManager,\n domRect.x,\n domRect.y,\n domRect.width,\n domRect.height,\n position,\n rotation,\n scale,\n anchor,\n zIndex,\n ])\n\n useEffect(() => {\n if (spatialWindowManager && spatialWindowManager.webview) {\n const webview = spatialWindowManager.webview\n webview.setOpacity(opacity)\n }\n }, [spatialWindowManager, opacity])\n\n useEffect(() => {\n if (spatialWindowManager) {\n spatialWindowManager.entity?.setVisible(visible)\n }\n }, [spatialWindowManager, visible])\n\n useEffect(() => {\n // sync viewport\n if (spatialWindowManager?.window && spatialWindowManager.webview) {\n ;(async function () {\n const bodyWidth = document.body.getBoundingClientRect().width\n const viewport = spatialWindowManager.window?.document.querySelector(\n 'meta[name=\"viewport\"]',\n )\n viewport?.setAttribute(\n 'content',\n `width=${bodyWidth}, initial-scale=1.0 user-scalable=no`,\n )\n await spatialWindowManager.webview?.setScrollEdgeInsets({\n top: 0,\n left: 0,\n bottom: 0,\n right: domRect.width - bodyWidth,\n })\n })()\n }\n }, [spatialWindowManager, domRect.width])\n}\n\nfunction useSyncDomRect(spatialId: string) {\n const [domRect, setDomRect] = useState({\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n })\n\n const inheritedPortalStyleRef = useRef<CSSProperties>({})\n\n const anchorRef = useRef({\n x: 0.5,\n y: 0.5,\n z: 0.5,\n })\n\n const cornerRadiusRef = useRef({\n topLeading: 0,\n bottomLeading: 0,\n topTrailing: 0,\n bottomTrailing: 0,\n })\n\n const opacityRef = useRef(1.0)\n\n const spatialReactContextObject = useContext(SpatialReactContext)\n\n const inheritedPortalClassNameRef = useRef('')\n\n useEffect(() => {\n const syncDomRect = () => {\n const dom = spatialReactContextObject?.querySpatialDom(spatialId)\n\n if (!dom) {\n return\n }\n\n const computedStyle = getComputedStyle(dom)\n inheritedPortalStyleRef.current = getInheritedStyleProps(computedStyle)\n\n const stylePosition = inheritedPortalStyleRef.current.position\n const isFixedPosition = stylePosition === 'fixed'\n\n let domRect = dom.getBoundingClientRect()\n let rectType = domRect2rectType(domRect)\n\n if (!isFixedPosition) {\n const parentDom =\n spatialReactContextObject?.queryParentSpatialDom(spatialId)\n if (parentDom) {\n const parentDomRect = parentDom.getBoundingClientRect()\n const parentRectType = domRect2rectType(parentDomRect)\n rectType.x -= parentRectType.x\n rectType.y -= parentRectType.y\n }\n }\n\n const anchor = parseTransformOrigin(computedStyle)\n anchorRef.current = anchor\n\n const cornerRadius = parseCornerRadius(computedStyle)\n cornerRadiusRef.current = cornerRadius\n\n const opacity = parseFloat(computedStyle.getPropertyValue('opacity'))\n opacityRef.current = opacity\n\n inheritedPortalClassNameRef.current = dom.className\n\n setDomRect(rectType)\n }\n\n spatialReactContextObject?.onDomChange(spatialId, syncDomRect)\n\n return () => {\n spatialReactContextObject?.offDomChange(spatialId)\n }\n }, [])\n\n return {\n domRect,\n inheritedPortalStyle: inheritedPortalStyleRef.current,\n anchor: anchorRef.current,\n cornerRadius: cornerRadiusRef.current,\n opacity: opacityRef.current,\n className: inheritedPortalClassNameRef.current,\n }\n}\n\nexport function PortalInstance(inProps: PortalInstanceProps) {\n const { allowScroll, scrollWithParent, spatialStyle, isSubPortal, ...props } =\n inProps\n\n const debugName = useContext(SpatialDebugNameContext)\n\n const onContainerSpawned = useCallback(\n async (spatialWindowManager: SpatialWindowManager) => {\n const openWindow = spatialWindowManager.window!\n setOpenWindowStyle(openWindow)\n handleOpenWindowDocumentClick(openWindow)\n\n syncDefaultSpatialStyle(openWindow, debugName)\n\n const headObserver = await syncHeaderStyle(openWindow, debugName)\n const spawnedResult = {\n headObserver,\n }\n\n spatialWindowManager.setDebugName(debugName)\n\n return spawnedResult\n },\n [],\n )\n\n const onContainerDestroyed = useCallback(\n (spatialWindowManager: SpatialWindowManager, spawnedResult: any) => {\n const { headObserver } = spawnedResult\n headObserver.disconnect()\n },\n [],\n )\n\n const [spatialWindowManager] = usePortalContainer({\n onContainerSpawned,\n onContainerDestroyed,\n })\n\n const spatialId = props[SpatialID]\n\n const {\n domRect,\n inheritedPortalStyle,\n anchor,\n cornerRadius,\n opacity,\n className,\n } = useSyncDomRect(spatialId)\n\n useSyncSpatialProps(\n spatialWindowManager,\n {\n style: props.style,\n allowScroll,\n scrollWithParent,\n spatialStyle,\n },\n domRect,\n anchor,\n cornerRadius,\n opacity,\n inheritedPortalStyle.position,\n isSubPortal,\n )\n\n const JSXPortalInstance = renderJSXPortalInstance(\n props,\n inheritedPortalStyle,\n className,\n )\n\n const needRenderPlaceHolder =\n isSubPortal &&\n inheritedPortalStyle.position !== 'absolute' &&\n inheritedPortalStyle.position !== 'fixed'\n\n const El = props.El\n\n return (\n <SpatialWindowManagerContext.Provider value={spatialWindowManager}>\n {needRenderPlaceHolder && (\n <El\n className={className}\n data-subportal-spatialid={spatialId}\n style={{\n position: 'relative',\n width: `${domRect.width}px`,\n height: `${domRect.height}px`,\n visibility: 'hidden',\n display: inheritedPortalStyle.display,\n }}\n />\n )}\n {spatialWindowManager &&\n spatialWindowManager.window &&\n createPortal(\n JSXPortalInstance,\n spatialWindowManager.window.document.body,\n )}\n </SpatialWindowManagerContext.Provider>\n )\n}\n\nPortalInstance.displayName = 'PortalInstance'\n","import { useContext, useRef, useEffect } from 'react'\nimport { SpatialIsStandardInstanceContext } from './SpatialIsStandardInstanceContext'\nimport { getSession } from '../../utils/getSession'\nimport { SpatialWindowManager } from './SpatialWindowManager'\nimport { SpatialWindowManagerContext } from './SpatialWindowManagerContext'\nimport { useForceUpdate } from '../hooks/useForceUpdate'\n\ntype PortalContainerOption = {\n onContainerSpawned: (\n spatialWindowManager: SpatialWindowManager,\n ) => Promise<any>\n onContainerDestroyed: (\n spatialWindowManager: SpatialWindowManager,\n spawnedResult: any,\n ) => void\n}\n\nexport function usePortalContainer(options: PortalContainerOption) {\n const isStandard = useContext(SpatialIsStandardInstanceContext) // Spatial components render both a standard (hidden) and spatial instance (displayed), this prop lets us know which context we are in\n const parentSpatialWindowManager = useContext(SpatialWindowManagerContext)\n\n const forceUpdate = useForceUpdate()\n\n const spatialWindowManagerRef = useRef<SpatialWindowManager>()\n\n useEffect(() => {\n let isDestroyed = false\n let spawnedResult: any\n\n async function asyncCreatePortalContainer() {\n const session = getSession()!\n // session?.log(\"TREVORX \" + props.debugName + \" \" + (parentSpatialReactComponent !== null ? \"hasParent\" : \"NoParent\"))\n\n // Create spatial window\n let windowMgr = new SpatialWindowManager({\n parentSpatialWindowManager: parentSpatialWindowManager || undefined,\n })\n await windowMgr.initFromWidow()\n\n if (isDestroyed) {\n windowMgr.destroy()\n return\n }\n\n spawnedResult = await options.onContainerSpawned(windowMgr)\n if (isDestroyed) {\n options.onContainerDestroyed(windowMgr, spawnedResult)\n windowMgr.destroy()\n return\n }\n\n spatialWindowManagerRef.current = windowMgr\n forceUpdate()\n }\n\n if (isStandard !== true) {\n asyncCreatePortalContainer()\n }\n\n return () => {\n isDestroyed = true\n const spatialWindowManager = spatialWindowManagerRef.current\n\n if (spatialWindowManager) {\n options.onContainerDestroyed(spatialWindowManager, spawnedResult)\n spatialWindowManager.destroy()\n }\n }\n }, [])\n\n return [spatialWindowManagerRef.current]\n}\n","import { SpatialEntity, SpatialWindowComponent } from '@webspatial/core-sdk'\nimport { getSession } from '../../utils'\nimport { vecType, quatType, RectType } from '../types'\n\n// Manager classes to handle resource creation/deletion\nexport class SpatialWindowManager {\n initPromise?: Promise<any>\n entity?: SpatialEntity\n webview?: SpatialWindowComponent\n window: WindowProxy | null = null\n\n private parentSpatialWindowManager?: SpatialWindowManager\n private isFixedPosition: boolean\n\n constructor(options: {\n parentSpatialWindowManager?: SpatialWindowManager\n isFixedPosition?: boolean\n }) {\n this.isFixedPosition = options.isFixedPosition || false\n this.parentSpatialWindowManager = options.parentSpatialWindowManager\n }\n\n setDebugName(debugName: string) {\n this.entity?._setName(debugName)\n }\n\n private async initInternal(url: string) {\n this.entity = await getSession()!.createEntity()\n this.webview = await getSession()!.createWindowComponent()\n await this.webview.loadURL(url)\n await this.entity.setCoordinateSpace('Dom')\n await this.webview.setScrollWithParent(true)\n await this.webview.setScrollEnabled(false)\n await this.entity.setComponent(this.webview)\n\n var wc = await getSession()!.getCurrentWindowComponent()\n var ent = await wc.getEntity()\n await this.entity.setParent(ent!)\n }\n\n private async initInternalFromWindow() {\n var w = await getSession()!.createWindowContext()\n this.window = w\n this.entity = await getSession()!.createEntity()\n this.webview = await getSession()!.createWindowComponent()\n await this.webview.setFromWindow(w)\n await this.entity.setCoordinateSpace('Dom')\n await this.webview.setScrollWithParent(true)\n await this.webview.setScrollEnabled(false)\n await this.entity.setComponent(this.webview)\n\n this.setEntityParentByCSSPosition(this.isFixedPosition)\n }\n\n async updateCSSPosition(isFixedPosition: boolean) {\n if (this.isFixedPosition === isFixedPosition) {\n return\n } else {\n this.isFixedPosition = isFixedPosition\n }\n return this.setEntityParentByCSSPosition(isFixedPosition)\n }\n\n private async setEntityParentByCSSPosition(isFixedPosition: boolean) {\n if (this.initPromise) {\n await this.initPromise\n if (isFixedPosition || !this.parentSpatialWindowManager) {\n // Add as a child of the current page\n var wc = await getSession()!.getCurrentWindowComponent()\n var ent = await wc.getEntity()\n await this.entity!.setParent(ent!)\n } else {\n const parentSpatialWindowManager = this.parentSpatialWindowManager!\n // Add as a child of the parent\n await parentSpatialWindowManager.initPromise\n this.entity!.setParent(parentSpatialWindowManager.entity!)\n }\n }\n }\n\n async init(url: string) {\n this.initPromise = this.initInternal(url)\n await this.initPromise\n }\n async initFromWidow() {\n this.initPromise = this.initInternalFromWindow()\n await this.initPromise\n }\n async resize(\n rect: RectType,\n offset: vecType,\n rotation: quatType = { x: 0, y: 0, z: 0, w: 1 },\n scale: vecType = { x: 1, y: 1, z: 1 },\n rotationOrigin: vecType = { x: 0, y: 0, z: 0 },\n parrentOffset: number = 0,\n ) {\n let targetPosX = rect.x + rect.width / 2\n // Adjust to get the page relative to document instead of viewport\n // This is needed as when you scroll down the page the rect.top moves but we dont want it to so we can offset that by adding scroll\n let targetPosY = rect.y + rect.height / 2 + parrentOffset\n\n if (!this.webview) {\n return\n }\n var entity = this.entity!\n entity.transform.position.x = targetPosX + (offset ? offset.x : 0)\n entity.transform.position.y = targetPosY + (offset ? offset.y : 0)\n entity.transform.position.z = offset ? offset.z : 0\n\n entity.transform.orientation.x = rotation.x\n entity.transform.orientation.y = rotation.y\n entity.transform.orientation.z = rotation.z\n entity.transform.orientation.w = rotation.w\n\n entity.transform.scale.x = scale.x\n entity.transform.scale.y = scale.y\n entity.transform.scale.z = scale.z\n\n await entity.updateTransform()\n\n var webview = this.webview!\n await webview.setResolution(rect.width, rect.height)\n\n await webview.setRotationAnchor(rotationOrigin)\n }\n\n async setZIndex(zIndex: number) {\n let entity = this.entity!\n entity.updateZIndex(zIndex)\n }\n\n async destroy() {\n if (this.initPromise) {\n await this.initPromise\n this.entity?.destroy()\n this.webview?.destroy()\n this.window = null\n }\n }\n}\n","import { createContext } from 'react'\nimport { SpatialWindowManager } from './SpatialWindowManager'\n\nexport const SpatialWindowManagerContext = createContext<\n SpatialWindowManager | undefined | null\n>(null)\n","import { RectType } from '../types'\n\nexport function getInheritedStyleProps(\n computedStyle: CSSStyleDeclaration,\n): any {\n //https://stackoverflow.com/questions/5612302/which-css-properties-are-inherited\n var propNames = [\n 'azimuth',\n 'borderCollapse',\n 'borderSpacing',\n 'captionSide',\n 'color',\n 'cursor',\n 'direction',\n 'elevation',\n 'emptyCells',\n 'fontFamily',\n 'fontSize',\n 'fontStyle',\n 'fontVariant',\n 'fontWeight',\n 'font',\n 'letterSpacing',\n 'lineHeight',\n 'listStyleImage',\n 'listStylePosition',\n 'listStyleType',\n 'listStyle',\n 'orphans',\n 'pitchRange',\n 'pitch',\n 'quotes',\n 'richness',\n 'speakHeader',\n 'speakNumeral',\n 'speakPunctuation',\n 'speak',\n 'speechRate',\n 'stress',\n 'textAlign',\n 'textIndent',\n 'textTransform',\n 'visibility',\n 'voiceFamily',\n 'volume',\n 'whiteSpace',\n 'widows',\n 'wordSpacing',\n // background also need to be synced\n 'background',\n // position also need to be synced\n 'position',\n\n 'width',\n 'height',\n\n 'display',\n ]\n var props = {} as any\n for (var cssName of propNames) {\n if ((computedStyle as any)[cssName]) {\n props[cssName] = (computedStyle as any)[cssName]\n }\n }\n return props\n}\n\nexport function domRect2rectType(from: DOMRect): RectType {\n return {\n x: from.x,\n y: from.y,\n width: from.width,\n height: from.height,\n }\n}\n\nexport function parseTransformOrigin(computedStyle: CSSStyleDeclaration) {\n const transformOriginProperty =\n computedStyle.getPropertyValue('transform-origin')\n const [x, y] = transformOriginProperty.split(' ').map(parseFloat)\n const width = parseFloat(computedStyle.getPropertyValue('width'))\n const height = parseFloat(computedStyle.getPropertyValue('height'))\n\n return {\n x: width > 0 ? x / width : 0.5,\n y: height > 0 ? y / height : 0.5,\n z: 0.5,\n }\n}\n\nfunction parseBorderRadius(borderProperty: string, width: number) {\n if (borderProperty === '') {\n return 0\n }\n if (borderProperty.endsWith('%')) {\n return (width * parseFloat(borderProperty)) / 100\n }\n return parseFloat(borderProperty)\n}\n\nexport function parseCornerRadius(computedStyle: CSSStyleDeclaration) {\n const width = parseFloat(computedStyle.getPropertyValue('width'))\n\n const topLeftPropertyValue = computedStyle.getPropertyValue(\n 'border-top-left-radius',\n )\n const topRightPropertyValue = computedStyle.getPropertyValue(\n 'border-top-right-radius',\n )\n const bottomLeftPropertyValue = computedStyle.getPropertyValue(\n 'border-bottom-left-radius',\n )\n const bottomRightPropertyValue = computedStyle.getPropertyValue(\n 'border-bottom-right-radius',\n )\n\n const cornerRadius = {\n topLeading: parseBorderRadius(topLeftPropertyValue, width),\n bottomLeading: parseBorderRadius(bottomLeftPropertyValue, width),\n topTrailing: parseBorderRadius(topRightPropertyValue, width),\n bottomTrailing: parseBorderRadius(bottomRightPropertyValue, width),\n }\n\n return cornerRadius\n}\n","import { createContext } from 'react'\n\nexport const SpatialDebugNameContext = createContext<string>('')\n","import { WindowContainerOptions } from '@webspatial/core-sdk/'\nimport { getSession } from './utils/getSession'\nexport type { WindowContainerOptions }\nexport const defaultSceneConfig: WindowContainerOptions = {\n defaultSize: {\n width: 900,\n height: 700,\n },\n resizability: 'automatic',\n}\n\nconst CONTEXT_WINDOW_URL = 'webspatial://createWindowContext'\nconst originalOpen = window.open\nexport class XRApp {\n private static instance: XRApp\n static getInstance() {\n if (!XRApp.instance) {\n XRApp.instance = new XRApp()\n }\n return XRApp.instance\n }\n\n handleATag(event: MouseEvent) {\n const targetElement = event.target as HTMLElement\n if (targetElement.tagName === 'A') {\n const link = targetElement as HTMLAnchorElement\n const target = link.target\n const url = link.href\n\n if (target && target !== '_self') {\n event.preventDefault()\n window.open(url, target)\n }\n }\n }\n init() {\n ;(window as any).open = this.open\n\n document.addEventListener('click', this.handleATag)\n }\n deinit() {\n ;(window as any).open = originalOpen\n\n document.removeEventListener('click', this.handleATag)\n }\n private configMap: Record<string, WindowContainerOptions> = {} // name=>config\n private getConfig(name?: string) {\n if (name === undefined || !this.configMap[name]) return undefined\n return this.configMap[name]\n }\n\n async show(window: Window, cfg: WindowContainerOptions) {\n try {\n let session = getSession()!\n await session._createScene(\n 'Plain', // only support Plain for now\n {\n sceneData: {\n method: 'showRoot',\n sceneConfig: cfg,\n // url: url,\n window,\n },\n },\n )\n } catch (error) {\n console.error(error)\n }\n }\n open = (url?: string, target?: string, features?: string) => {\n const newWindow = originalOpen(url, target, features)\n if (url === CONTEXT_WINDOW_URL) return newWindow\n // if target is special\n if (target === '_self' || target === '_parent' || target === '_top') {\n return newWindow\n }\n // should open new scene or focus to\n\n // _webSpatialID is assigned for the new webview\n // timer to check _webSpatialID exist\n let cnt = 2\n let timer = setInterval(async () => {\n cnt -= 1\n if (cnt < 0) {\n clearInterval(timer)\n return\n }\n // native should createRoot if it see the windowID for the first time\n // otherwise should focus to\n if ((newWindow as any)._webSpatialID) {\n clearInterval(timer)\n // fixme:\n let session = getSession()\n if (!session) {\n console.error('no session')\n } else {\n const cfg = this.getConfig(target)\n try {\n await session._createScene(\n 'Plain', // only support Plain for now\n {\n sceneData: {\n method: 'createRoot',\n sceneConfig: cfg,\n url: url,\n window: newWindow!,\n // windowID: (newWindow as any)._webSpatialID,\n // windowContainerID: (newWindow as any)._webSpatialGroupID,\n },\n },\n )\n // remove config after use\n if (typeof target === 'string' && this.configMap[target]) {\n delete this.configMap[target]\n }\n } catch (error) {\n console.error(error)\n }\n }\n }\n }, 0)\n return newWindow\n }\n initScene(\n name: string,\n callback: (pre: WindowContainerOptions) => WindowContainerOptions,\n ) {\n this.configMap[name] = callback({ ...defaultSceneConfig })\n }\n}\n","import { createContext } from 'react'\n\n// SpatialLayerContext is used to mark the spatial layer of the spatial div, which is used to help portal instance find the correct layer standard instance div.\nexport const SpatialLayerContext = createContext(0)\n","import React, { forwardRef, Ref } from 'react'\nimport { SpatialMonitor } from './SpatialMonitor'\n\nconst cachedWithSpatialMonitorType = new Map()\n\nexport function withSpatialMonitor(El: React.ElementType) {\n if (cachedWithSpatialMonitorType.has(El)) {\n return cachedWithSpatialMonitorType.get(El)\n } else {\n const WithSpatialMonitorComponent = forwardRef(\n (givenProps: any, givenRef: Ref<any>) => {\n const {\n El: _,\n\n ...props\n } = givenProps\n\n return <SpatialMonitor El={El} {...props} ref={givenRef} />\n },\n )\n WithSpatialMonitorComponent.displayName = `WithSpatialMonitor(${typeof El === 'string' ? El : El.displayName || El.name})`\n\n cachedWithSpatialMonitorType.set(El, WithSpatialMonitorComponent)\n cachedWithSpatialMonitorType.set(\n cachedWithSpatialMonitorType,\n cachedWithSpatialMonitorType,\n )\n return WithSpatialMonitorComponent\n }\n}\n","import { useRef, useEffect, ForwardedRef, useMemo } from 'react'\nimport { notifyDOMUpdate } from '../notifyUpdateStandInstanceLayout'\n\nexport function useMonitorDomChange(inRef: ForwardedRef<HTMLElement>) {\n const ref = useRef<HTMLElement>(null)\n\n useEffect(() => {\n const observer = new MutationObserver(mutationsList => {\n notifyDOMUpdate(mutationsList)\n })\n\n const config = {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['style', 'class'],\n }\n\n ref.current && observer.observe(ref.current, config)\n\n return () => {\n observer.disconnect()\n }\n }, [])\n\n const proxyRef = useMemo(\n () =>\n new Proxy(ref, {\n set: function (target, key, value) {\n if (key === 'current') {\n if (inRef) {\n if (typeof inRef === 'function') {\n inRef(value)\n } else if (inRef) {\n inRef.current = value\n }\n }\n }\n return Reflect.set(target, key, value)\n },\n }),\n [],\n )\n\n return proxyRef\n}\n","export enum SpatialStyleInfoUpdateEvent {\n standInstanceLayout = 'standInstanceLayout',\n domUpdated = 'domUpdated',\n}\n\n/**\n * External-developers can call this function to sync the standardInstance layout to PortalInstance.\n *\n * Currently: notifyUpdateStandInstanceLayout is called when the document head changed\n * or when the monitored div changed (in both cases spatialDiv's layout may be changed, so we need to update the layout)\n */\nexport function notifyUpdateStandInstanceLayout() {\n document.dispatchEvent(\n new CustomEvent(SpatialStyleInfoUpdateEvent.standInstanceLayout, {\n detail: {},\n }),\n )\n}\n\nexport function notifyDOMUpdate(mutationsList: MutationRecord[]) {\n document.dispatchEvent(\n new CustomEvent(SpatialStyleInfoUpdateEvent.domUpdated, {\n detail: mutationsList,\n }),\n )\n}\n","import { useEffect } from 'react'\nimport { notifyUpdateStandInstanceLayout } from '../notifyUpdateStandInstanceLayout'\n\nexport function useMonitorDocumentHeaderChange() {\n useEffect(() => {\n const observer = new MutationObserver(mutationsList => {\n notifyUpdateStandInstanceLayout()\n })\n\n const config = {\n childList: true,\n subtree: true,\n attributes: true,\n }\n\n observer.observe(document.head, config)\n\n return () => {\n observer.disconnect()\n }\n }, [])\n}\n","import { useMonitorDomChange } from './useMonitorDomChange'\nimport { useMonitorDocumentHeaderChange } from './useMonitorDocumentHeaderChange'\nimport { ElementType, ForwardedRef, forwardRef } from 'react'\n\ntype SpatialMonitorProps = {\n El?: ElementType\n}\n\n/**\n * Component that add MutationObserver to monitor all dom changes including its children.\n * If any dom changes, it will notify all SpatialDiv to render again for the purpose of sync standInstance layout to portalInstance.\n */\nfunction SpatialMonitorBase(\n inProps: SpatialMonitorProps,\n inRef: ForwardedRef<HTMLElement>,\n) {\n const { El = 'div', ...props } = inProps\n const ref = useMonitorDomChange(inRef)\n useMonitorDocumentHeaderChange()\n\n return <El {...props} ref={ref} />\n}\n\nexport const SpatialMonitor = forwardRef(SpatialMonitorBase)\n","import React, { forwardRef, Ref } from 'react'\nimport { primitives } from '../primitives'\nimport { CSSSpatialComponent } from './CSSSpatialComponent'\n\nconst cachedWithCSSSpatialType = new Map()\n\nexport function withCSSSpatial(Component: React.ElementType) {\n if (cachedWithCSSSpatialType.has(Component)) {\n return cachedWithCSSSpatialType.get(Component)\n } else {\n const WithCSSSpatialComponent = forwardRef(\n (givenProps: any, givenRef: Ref<any>) => {\n const {\n component: ignoreComponent,\n className: origClassName = '',\n ...props\n } = givenProps\n const className = 'xr-spatial-default ' + origClassName\n return (\n <CSSSpatialComponent\n component={Component}\n className={className}\n {...props}\n ref={givenRef}\n />\n )\n },\n )\n WithCSSSpatialComponent.displayName = `WithCSSSpatial(${typeof Component === 'string' ? Component : Component.displayName || Component.name})`\n\n cachedWithCSSSpatialType.set(Component, WithCSSSpatialComponent)\n cachedWithCSSSpatialType.set(\n WithCSSSpatialComponent,\n WithCSSSpatialComponent,\n )\n return WithCSSSpatialComponent\n }\n}\n\nexport const CSSSpatialPrimitive: Record<string, typeof CSSSpatialComponent> =\n {}\n;(function createSpatialPrimitive(CSSSpatialPrimitive) {\n primitives.forEach(primitive => {\n CSSSpatialPrimitive[primitive] = withCSSSpatial(primitive)\n })\n})(CSSSpatialPrimitive)\n\nexport const CSSSpatialDiv = CSSSpatialPrimitive.div\n","import {\n CSSProperties,\n forwardRef,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from 'react'\nimport { useSpatialStyle } from './useSpatialStyle'\nimport {\n SpatialReactComponent,\n SpatialReactComponentProps,\n SpatialReactComponentRef,\n} from '../SpatialReactComponent'\nimport { SpatialIsStandardInstanceContext } from '../SpatialReactComponent/SpatialIsStandardInstanceContext'\nimport { getSession } from '../../utils/getSession'\nimport { CSSSpatialDebugNameContext } from './CSSSpatialDebugNameContext'\nimport { useHijackSpatialDivRef } from './useHijackSpatialDivRef'\nimport { InjectClassName } from './injectClassStyle'\nimport { CSSSpatialLayerContext } from './CSSSpatialLayerContext'\nimport {\n CSSSpatialID,\n CSSSpatialRootContext,\n CSSSpatialRootContextObject,\n} from './CSSSpatialRootContext'\n\ninterface CSSSpatialComponentWithUniqueIDProps\n extends SpatialReactComponentProps {\n [CSSSpatialID]: string\n}\n\nfunction renderRootCSSSpatialComponent(\n inProps: SpatialReactComponentProps,\n refIn: SpatialReactComponentRef,\n) {\n const cssSpatialRootContextObject = useMemo(\n () => new CSSSpatialRootContextObject(),\n [],\n )\n\n const {\n style = {},\n className = '',\n children,\n debugName,\n debugShowStandardInstance,\n ...props\n } = inProps\n const { ref, spatialStyle, ready } = useSpatialStyle()\n\n const divRefStyle: CSSProperties = {\n ...style,\n width: 0,\n height: 0,\n padding: 0,\n transition: 'none',\n position: 'absolute',\n }\n\n const spatialDivStyle: CSSProperties = {\n ...style,\n transform: spatialStyle.transformExist ? 'translateZ(0)' : 'none',\n }\n\n const El = inProps.component || 'div'\n\n // hijack SpatialDiv ref\n const spatialDivRef = useHijackSpatialDivRef(refIn, ref)\n\n const divRefClassName = className + ' ' + InjectClassName\n\n return (\n <CSSSpatialRootContext.Provider value={cssSpatialRootContextObject}>\n {ready && (\n <SpatialReactComponent\n style={spatialDivStyle}\n className={className}\n children={children}\n {...props}\n spatialStyle={spatialStyle}\n debugName={debugName}\n debugShowStandardInstance={debugShowStandardInstance}\n ref={spatialDivRef}\n />\n )}\n\n <El\n style={divRefStyle}\n className={divRefClassName}\n {...props}\n ref={ref}\n data-cssparser\n />\n </CSSSpatialRootContext.Provider>\n )\n}\n\nfunction renderInWebEnv(\n props: SpatialReactComponentProps,\n ref: SpatialReactComponentRef,\n) {\n return <SpatialReactComponent {...props} ref={ref} />\n}\n\nfunction renderInStandardInstance(\n cssSpatialRootContextObject: CSSSpatialRootContextObject,\n cssSpatialID: string,\n inProps: SpatialReactComponentProps,\n refIn: SpatialReactComponentRef,\n) {\n const { style: inStyle = {}, ...props } = inProps\n const style: CSSProperties = {\n ...inStyle,\n transform: 'none',\n visibility: 'hidden',\n }\n\n // hijack SpatialDiv ref\n var cssParserRef = useRef<HTMLDivElement | null>(null)\n const spatialDivRef = useHijackSpatialDivRef(refIn, cssParserRef)\n\n useEffect(() => {\n const onDomChangeAction = (dom: HTMLDivElement | null) => {\n cssParserRef.current = dom\n }\n cssSpatialRootContextObject.onDomChange(cssSpatialID, onDomChangeAction)\n\n return () => {\n cssSpatialRootContextObject.offDomChange(cssSpatialID, onDomChangeAction)\n }\n }, [])\n\n return <SpatialReactComponent style={style} {...props} ref={spatialDivRef} />\n}\n\nfunction renderInPortalInstance(\n cssSpatialRootContextObject: CSSSpatialRootContextObject,\n cssSpatialID: string,\n inProps: SpatialReactComponentProps,\n) {\n const {\n style = {},\n className = '',\n children,\n debugName,\n debugShowStandardInstance,\n ...props\n } = inProps\n const { ref, spatialStyle, ready } = useSpatialStyle()\n const divRefStyle: CSSProperties = {\n ...style,\n width: 0,\n height: 0,\n padding: 0,\n transition: 'none',\n position: 'absolute',\n }\n\n const spatialDivStyle: CSSProperties = {\n ...style,\n transform: spatialStyle.transformExist ? 'translateZ(0)' : 'none',\n }\n\n const El = inProps.component || 'div'\n\n const divRefClassName = className + ' ' + InjectClassName\n\n useEffect(() => {\n cssSpatialRootContextObject.setCSSParserRef(cssSpatialID, ref.current)\n }, [ref.current])\n\n return (\n <>\n {ready && (\n <SpatialReactComponent\n style={spatialDivStyle}\n className={className}\n children={children}\n {...props}\n spatialStyle={spatialStyle}\n debugName={debugName}\n debugShowStandardInstance={debugShowStandardInstance}\n />\n )}\n <El\n style={divRefStyle}\n className={divRefClassName}\n {...props}\n ref={ref}\n />\n </>\n )\n}\n\nfunction CSSSpatialComponentBase(\n inProps: CSSSpatialComponentWithUniqueIDProps,\n ref: SpatialReactComponentRef,\n) {\n const { [CSSSpatialID]: cssSpatialID, ...props } = inProps\n const isWebEnv = !getSession()\n if (isWebEnv) {\n return renderInWebEnv(props, ref)\n } else {\n const cssSpatialRootContextObject = useContext(CSSSpatialRootContext)\n if (cssSpatialRootContextObject) {\n const isInStandardInstance = !!useContext(\n SpatialIsStandardInstanceContext,\n )\n if (isInStandardInstance) {\n return renderInStandardInstance(\n cssSpatialRootContextObject,\n cssSpatialID,\n props,\n ref,\n )\n } else {\n return renderInPortalInstance(\n cssSpatialRootContextObject,\n cssSpatialID,\n props,\n )\n }\n } else {\n return renderRootCSSSpatialComponent(props, ref)\n }\n }\n}\n\nconst CSSSpatialComponentBaseWithRef = forwardRef(CSSSpatialComponentBase)\n\nfunction CSSSpatialComponentWithRef(\n inProps: SpatialReactComponentProps,\n ref: SpatialReactComponentRef,\n) {\n const layer = useContext(CSSSpatialLayerContext) + 1\n\n const cssSpatialRootContextObject = useContext(CSSSpatialRootContext)\n const isRootInstance = !cssSpatialRootContextObject\n const isInStandardInstance = !!useContext(SpatialIsStandardInstanceContext)\n const cssSpatialID = useMemo(() => {\n return isRootInstance\n ? layer.toString()\n : cssSpatialRootContextObject.getSpatialID(\n layer,\n isInStandardInstance,\n inProps.debugName,\n )\n }, [])\n\n const props = { ...inProps, [CSSSpatialID]: cssSpatialID }\n\n return (\n <CSSSpatialDebugNameContext.Provider value={inProps.debugName || ''}>\n <CSSSpatialLayerContext.Provider value={layer}>\n <CSSSpatialComponentBaseWithRef {...props} ref={ref} />\n </CSSSpatialLayerContext.Provider>\n </CSSSpatialDebugNameContext.Provider>\n )\n}\n\nexport const CSSSpatialComponent = forwardRef(CSSSpatialComponentWithRef)\n","import { useCallback, useEffect, useRef, useState } from 'react'\nimport { SpatialStyleInfoUpdateEvent } from '../notifyUpdateStandInstanceLayout'\nimport isEqual from 'lodash.isequal'\nimport { Matrix4, Vector3, Quaternion } from './math'\nimport { type BackgroundMaterialType } from '@webspatial/core-sdk'\nimport { SpatialCustomVars } from './const'\n\nfunction parse2dMatrix(transformDataArray: number[]) {\n const [n11, n21, n12, n22, n13, n23] = transformDataArray\n const matrix4 = new Matrix4(\n n11,\n n12,\n 0,\n n13,\n n21,\n n22,\n 0,\n n23,\n 0,\n 0,\n 1,\n 0,\n 0,\n 0,\n 0,\n 1,\n )\n return matrix4\n}\n\nfunction parse3dMatrix(transformDataArray: number[]) {\n const matrix4 = new Matrix4().fromArray(transformDataArray)\n return matrix4\n}\n\nfunction parseTransform(computedStyle: CSSStyleDeclaration) {\n let transform = computedStyle.getPropertyValue('transform')\n const matrixFlagString = 'matrix('\n const idxOfMatrix = transform.indexOf(matrixFlagString)\n if (idxOfMatrix !== -1) {\n const transformDataArray = transform\n .substring(matrixFlagString.length, transform.length - 1)\n .split(',')\n .map(item => parseFloat(item))\n return { transformExist: true, matrix: parse2dMatrix(transformDataArray) }\n } else {\n const matrix3dFlagString = 'matrix3d('\n const idxOfMatrix3d = transform.indexOf(matrix3dFlagString)\n if (idxOfMatrix3d !== -1) {\n const transform3dDataArray = transform\n .substring(matrix3dFlagString.length, transform.length - 1)\n .split(',')\n .map(item => parseFloat(item))\n return {\n transformExist: true,\n matrix: parse3dMatrix(transform3dDataArray),\n }\n } else {\n return { transformExist: false, matrix: new Matrix4() }\n }\n }\n}\n\nfunction parseBack(computedStyle: CSSStyleDeclaration) {\n let backProperty = computedStyle.getPropertyValue(SpatialCustomVars.back)\n let back: number | undefined = undefined\n try {\n back = parseFloat(backProperty)\n } catch (error) {}\n return new Matrix4().makeTranslation(0, 0, back || 0)\n}\n\nfunction parseXRZIndex(computedStyle: CSSStyleDeclaration) {\n let xrZIndexProperty = computedStyle.getPropertyValue(\n SpatialCustomVars.xrZIndex,\n )\n let xrZIndex: number = 0\n try {\n xrZIndex = parseFloat(xrZIndexProperty)\n } catch (error) {}\n return xrZIndex\n}\n\nfunction parseSpatialStyle(node: HTMLElement) {\n const computedStyle = getComputedStyle(node)\n\n // handle back property\n const mat4ForBack = parseBack(computedStyle)\n\n // handle transform properties\n\n const { transformExist, matrix: mat4ForTransform } =\n parseTransform(computedStyle)\n\n const resultMatrix = new Matrix4()\n resultMatrix.multiplyMatrices(mat4ForBack, mat4ForTransform)\n\n const position = new Vector3()\n const quaternion = new Quaternion()\n const scale = new Vector3()\n\n resultMatrix.decompose(position, quaternion, scale)\n\n // parse xrZIndex\n const zIndex = parseXRZIndex(computedStyle)\n\n // parse visibility\n const visible = computedStyle.getPropertyValue('visibility') === 'visible'\n\n // parse backgroundMaterialType\n const backgroundMaterialType: BackgroundMaterialType =\n computedStyle.getPropertyValue(\n SpatialCustomVars.backgroundMaterial,\n ) as BackgroundMaterialType\n\n return {\n position: { x: position.x, y: position.y, z: position.z },\n rotation: {\n x: quaternion.x,\n y: quaternion.y,\n z: quaternion.z,\n w: quaternion.w,\n },\n scale: { x: scale.x, y: scale.y, z: scale.z },\n zIndex,\n material: {\n type: backgroundMaterialType || 'none',\n },\n visible,\n transformExist,\n }\n}\n\nexport function useSpatialStyle() {\n const ref = useRef<HTMLDivElement | null>(null)\n\n const [spatialStyle, setSpatialStyle] = useState({\n position: { x: 0, y: 0, z: 0 },\n rotation: { x: 0, y: 0, z: 0, w: 1 },\n scale: { x: 1, y: 1, z: 1 },\n zIndex: 0,\n material: {\n type: 'none' as BackgroundMaterialType,\n },\n visible: true,\n transformExist: false,\n })\n const [ready, setReady] = useState(false)\n\n const checkSpatialStyleUpdate = useCallback(() => {\n const nextSpatialStyle = parseSpatialStyle(ref.current!)\n if (!isEqual(spatialStyle, nextSpatialStyle)) {\n setSpatialStyle(nextSpatialStyle)\n }\n }, [])\n\n useEffect(() => {\n // first time update\n if (!ref.current) {\n return\n }\n\n const spatialStyle = parseSpatialStyle(ref.current!)\n setSpatialStyle(spatialStyle)\n setReady(true)\n }, [])\n\n useEffect(() => {\n if (!ref.current) {\n return\n }\n\n // sync spatial style when this dom or sub dom change\n const observer = new MutationObserver(mutationsList => {\n checkSpatialStyleUpdate()\n })\n const config = {\n childList: true,\n subtree: true,\n attributes: true,\n // attributeOldValue: true,\n attributeFilter: ['style', 'class'],\n }\n observer.observe(ref.current!, config)\n\n return () => {\n observer.disconnect()\n }\n }, [])\n\n useEffect(() => {\n const headObserver = new MutationObserver(mutations => {\n checkSpatialStyleUpdate()\n })\n headObserver.observe(document.head, { childList: true, subtree: true })\n return () => {\n headObserver.disconnect()\n }\n }, [])\n\n useEffect(() => {\n if (!ref.current) {\n return\n }\n\n // check style property change when some external node changed\n function isDescendant(child: Node, parent: Node) {\n if (child === parent) {\n return true\n }\n let node: Node | null = child\n while (node) {\n if (node === parent) {\n return true\n }\n node = node.parentElement\n }\n return false\n }\n\n const onDomUpdated = (event: Event) => {\n const mutationsList = (event as CustomEvent).detail as MutationRecord[]\n // spatialReactComponentDiv is hardcode currently, maybe refactor later (get from SpatialReactComponent)\n const spatialReactComponentDiv = (ref.current! as HTMLElement)\n .previousElementSibling!\n // ignore the mutation that is in the current ref dom or the previous sibling dom (Like SpatialReactComponent)\n const targets = mutationsList\n .map(m => m.target)\n .filter(\n node =>\n node !== ref.current! &&\n !isDescendant(node, spatialReactComponentDiv),\n )\n if (targets.length > 0) {\n checkSpatialStyleUpdate()\n }\n }\n\n // check style property change when some external style change\n document.addEventListener(\n SpatialStyleInfoUpdateEvent.domUpdated,\n onDomUpdated,\n )\n\n return () => {\n document.removeEventListener(\n SpatialStyleInfoUpdateEvent.domUpdated,\n onDomUpdated,\n )\n }\n }, [])\n\n return { ref, ready, spatialStyle }\n}\n","export { Matrix4 } from 'three/src/math/Matrix4.js'\nexport { Vector3 } from 'three/src/math/Vector3.js'\nexport { Quaternion } from 'three/src/math/Quaternion.js'\n","export const SpatialCustomVars = {\n back: '--xr-back',\n backgroundMaterial: '--xr-background-material',\n xrZIndex: '--xr-z-index',\n}\n\nexport const BackgroundMaterialDefault = 'none'\n","import { createContext } from 'react'\n\nexport const CSSSpatialDebugNameContext = createContext<string>('')\n","import { BackgroundMaterialType } from '@webspatial/core-sdk'\nimport { MutableRefObject, useCallback } from 'react'\nimport { SpatialReactComponentRef } from '../SpatialReactComponent/types'\nimport { SpatialCustomVars } from './const'\nimport { InjectClassName } from './injectClassStyle'\nimport { extractAndRemoveCustomProperties, joinToCSSText } from './utils'\n\nfunction makeOriginalKey(key: string) {\n return `__original_${key}`\n}\n\nexport function useHijackSpatialDivRef(\n refIn: SpatialReactComponentRef,\n cssParserRef: MutableRefObject<HTMLDivElement | null>,\n) {\n const ref = cssParserRef\n const spatialDivRef = useCallback(\n (domElement: HTMLDivElement) => {\n if (domElement && refIn) {\n const domStyle = domElement.style\n const domStyleProxy = new Proxy(domStyle, {\n get(target, prop: string) {\n if (\n typeof target[prop as keyof CSSStyleDeclaration] === 'function'\n ) {\n return function (this: any, ...args: any[]) {\n if (prop === 'setProperty') {\n const [property, value] = args\n if (property === SpatialCustomVars.backgroundMaterial) {\n ref.current?.style.setProperty(\n SpatialCustomVars.backgroundMaterial,\n value as BackgroundMaterialType,\n )\n } else if (property === SpatialCustomVars.back) {\n ref.current?.style.setProperty(\n SpatialCustomVars.back,\n value as string,\n )\n } else if (property === 'transform') {\n ref.current?.style.setProperty(property, value as string)\n return true\n } else if (property === SpatialCustomVars.xrZIndex) {\n ref.current?.style.setProperty(\n SpatialCustomVars.xrZIndex,\n value as string,\n )\n }\n } else if (prop === 'removeProperty') {\n const [property] = args\n if (\n property === SpatialCustomVars.backgroundMaterial ||\n property === SpatialCustomVars.back ||\n property === 'transform' ||\n property === SpatialCustomVars.xrZIndex\n ) {\n ref.current?.style.removeProperty(property)\n }\n } else if (prop === 'getPropertyValue') {\n const [property] = args\n if (property === 'transform') {\n return ref.current?.style[property]\n }\n }\n return (target[prop as keyof CSSStyleDeclaration] as Function)(\n ...args,\n )\n }\n }\n\n if (prop === 'transform') {\n return ref.current?.style[prop]\n }\n\n if (prop === 'visibility') {\n return ref.current?.style.visibility\n }\n\n if (prop === 'cssText') {\n // todo: concat target cssText with ref.current.style's spatialStyle like back/transform/visibility/xrZIndex/backgroundMaterial\n }\n\n return Reflect.get(target, prop)\n },\n set(target, property, value) {\n if (property === SpatialCustomVars.backgroundMaterial) {\n ref.current?.style.setProperty(\n SpatialCustomVars.backgroundMaterial,\n value as BackgroundMaterialType,\n )\n } else if (property === SpatialCustomVars.back) {\n ref.current?.style.setProperty(\n SpatialCustomVars.back,\n value as string,\n )\n } else if (property === SpatialCustomVars.xrZIndex) {\n ref.current?.style.setProperty(\n SpatialCustomVars.xrZIndex,\n value as string,\n )\n } else if (property === 'transform') {\n ref.current?.style.setProperty(property, value as string)\n return true\n } else if (property === 'visibility') {\n ref.current?.style.setProperty(property, value as string)\n return true\n } else if (property === 'cssText') {\n // parse cssText, filter out spatialStyle like back/transform/visibility/xrZIndex/backgroundMaterial\n const toFilteredCSSProperties = [\n 'transform',\n 'visibility',\n SpatialCustomVars.back,\n SpatialCustomVars.backgroundMaterial,\n SpatialCustomVars.xrZIndex,\n ]\n const { extractedValues, filteredCssText } =\n extractAndRemoveCustomProperties(\n value as string,\n toFilteredCSSProperties,\n )\n\n // update cssText for CSSParserDiv\n toFilteredCSSProperties.forEach(key => {\n // update cssText for CSSParserDiv according to extractedValues\n if (extractedValues[key]) {\n ref.current?.style.setProperty(key, extractedValues[key])\n } else {\n ref.current?.style.removeProperty(key)\n }\n })\n\n const appendedCSSText = joinToCSSText({\n transform: 'none',\n visibility: 'hidden',\n })\n\n // set cssText for spatialDiv\n return Reflect.set(\n target,\n property,\n [appendedCSSText, filteredCssText].join(';'),\n )\n }\n return Reflect.set(target, property, value)\n },\n })\n\n // hijack classList\n const domClassList = domElement.classList\n const domClassMethodKeys: Array<\n 'add' | 'remove' | 'toggle' | 'replace'\n > = ['add', 'remove', 'toggle', 'replace']\n domClassMethodKeys.forEach(key => {\n const hiddenKey = makeOriginalKey(key)\n const hiddenKeyExist = (domClassList as any)[hiddenKey] !== undefined\n const originalMethod = hiddenKeyExist\n ? (domClassList as any)[hiddenKey]\n : domClassList[key].bind(domClassList)\n\n ;(domClassList as any)[hiddenKey] = originalMethod\n\n domClassList[key] = function (this: any, ...args: any[]) {\n const result = (originalMethod as Function)(...args)\n if (ref.current) {\n // update CSSParser className\n ref.current.className =\n domElement.className + ' ' + InjectClassName\n }\n return result\n }\n })\n\n const __getComputedStyle = (\n originalGetComputedStyle: any,\n pseudoElt: any,\n ) => {\n return originalGetComputedStyle(domElement, pseudoElt)\n }\n\n const proxyDomElement = new Proxy(domElement, {\n get(target, prop) {\n if (prop === 'style') {\n return domStyleProxy\n }\n\n if (prop === '__isSpatialDiv') {\n return true\n }\n\n if (prop === '__getComputedStyle') {\n return __getComputedStyle\n }\n\n if (typeof target[prop as keyof HTMLElement] === 'function') {\n return function (this: any, ...args: any[]) {\n if ('removeAttribute' === prop) {\n const [property] = args\n if (property === 'style') {\n domStyleProxy.cssText = ''\n return true\n }\n if (property === 'class') {\n proxyDomElement.className = ''\n return true\n }\n }\n return (target[prop as keyof HTMLElement] as Function)(...args)\n }\n }\n\n return Reflect.get(target, prop, target)\n },\n set(target, prop, value) {\n if (ref.current) {\n if (prop === 'className') {\n ref.current.className = value + ' ' + InjectClassName\n }\n if (prop === 'style') {\n domStyleProxy.cssText = joinToCSSText(value)\n return true\n }\n }\n\n return Reflect.set(target, prop, value)\n },\n })\n\n if (typeof refIn === 'function') {\n refIn(proxyDomElement)\n } else {\n refIn.current = proxyDomElement\n }\n } else if (refIn) {\n if (typeof refIn === 'function') {\n refIn(null)\n } else {\n refIn.current = null\n }\n }\n },\n [refIn],\n )\n\n return spatialDivRef\n}\n","import { SpatialCustomVars, BackgroundMaterialDefault } from './const'\n\nexport const InjectClassName = 'xr-css-spatial-default'\n\nfunction injectClassStyle() {\n const style = document.createElement('style')\n style.innerHTML = `\n .${InjectClassName} {\n ${SpatialCustomVars.backgroundMaterial}: ${BackgroundMaterialDefault};\n }\n `\n document.head.prepend(style)\n}\ninjectClassStyle()\n","export function extractAndRemoveCustomProperties(\n cssText: string,\n properties: string[],\n) {\n if (!cssText) {\n return { extractedValues: {}, filteredCssText: '' }\n }\n\n const extractedValues: Record<string, string> = {}\n const rules = cssText.split(';')\n\n const filteredRules = rules.filter(rule => {\n const [key, value] = rule.split(':').map(part => part.trim())\n if (properties.includes(key)) {\n extractedValues[key] = value\n return false\n }\n return true\n })\n\n const filteredCssText = filteredRules.join(';').trim()\n return { extractedValues, filteredCssText }\n}\n\nexport function splitCSSText(cssText: string) {\n const rules = cssText.split(';')\n const filteredRules = rules.filter(rule => rule.trim() !== '')\n return filteredRules\n}\n\nexport function joinToCSSText(cssKV: Record<string, string>) {\n const rules = Object.entries(cssKV).map(([key, value]) => `${key}: ${value}`)\n return rules.join(';')\n}\n","import { createContext } from 'react'\n\n// CSSSpatialLayerContext is used to mark the cssspatial layer of the cssspatial div, which is used to help hijacked ref.current find the correct cssparser div.\nexport const CSSSpatialLayerContext = createContext(0)\n","import { createContext } from 'react'\n\nexport const CSSSpatialID = 'CSSSpatialID'\n\nexport class CSSSpatialRootContextObject {\n prefix = 'css'\n\n domSpatialId: string | null = null\n\n private fns: Record<string, (dom: HTMLDivElement | null) => void> = {}\n // cache dom for each spatialId\n private spatialId2dom: Record<string, HTMLDivElement> = {}\n\n // layer : [standardInstance sequence, portalInstance sequence]\n private layerSequences: Record<number, [number, number]> = {}\n\n public getSpatialID(\n layer: number,\n isInStandardInstance: boolean,\n debugName: string = '',\n ): string {\n if (this.layerSequences[layer] === undefined) {\n this.layerSequences[layer] = [0, 0]\n }\n const idx = isInStandardInstance ? 0 : 1\n const sequenceId = this.layerSequences[layer][idx]\n this.layerSequences[layer][idx] = sequenceId + 1\n const spatialId = `${this.prefix}_${debugName}_${layer}_${sequenceId}`\n\n return spatialId\n }\n\n public onDomChange(\n spatialId: string,\n fn: (dom: HTMLDivElement | null) => void,\n ) {\n this.fns[spatialId] = fn\n }\n\n public offDomChange(\n spatialId: string,\n fn: (dom: HTMLDivElement | null) => void,\n ) {\n delete this.fns[spatialId]\n }\n\n public setCSSParserRef(\n cssSpatialID: string,\n domElement: HTMLDivElement | null,\n ) {\n if (domElement) {\n this.spatialId2dom[cssSpatialID] = domElement\n } else {\n delete this.spatialId2dom[cssSpatialID]\n }\n this.fns[cssSpatialID]?.(domElement)\n }\n}\n\nexport const CSSSpatialRootContext =\n createContext<CSSSpatialRootContextObject | null>(null)\n","import { SpatialHelper } from '@webspatial/core-sdk'\nimport type { SpatialEntity } from '@webspatial/core-sdk'\nimport React, {\n useRef,\n useImperativeHandle,\n forwardRef,\n useEffect,\n} from 'react'\nimport { getSession } from '../utils'\n\nvar runAsync = (fn: any) => {\n return fn()\n}\n\ninterface SpatialViewProps extends React.HTMLAttributes<HTMLDivElement> {\n onViewLoad?: (viewEnt: SpatialEntity) => void\n onViewUnload?: () => void\n}\n\nexport interface SpatialViewRef extends HTMLDivElement {\n getViewEntity: () => Promise<SpatialEntity | null>\n}\n\nconst SpatialViewEl = forwardRef<SpatialViewRef, SpatialViewProps>(\n (props, ref) => {\n const divRef = useRef<HTMLDivElement>(null)\n const spatialEntity = useRef<SpatialEntity | null>(null)\n const activePromise = useRef<Promise<any> | null>(null)\n\n // Add function to get view entity from the spatial view\n useImperativeHandle(ref, () => ({\n ...divRef.current!,\n getViewEntity: async () => {\n if (activePromise.current) {\n await activePromise.current\n }\n return spatialEntity.current!\n },\n }))\n\n if (getSession() == null) {\n return (\n <div ref={divRef} {...props}>\n WebSpatial is not supported in this browser\n </div>\n )\n }\n useEffect(() => {\n activePromise.current = runAsync(async () => {\n if (activePromise.current) {\n await activePromise.current\n }\n let sh = new SpatialHelper(getSession()!)\n let x = await sh.dom.attachSpatialView(divRef.current!)\n spatialEntity.current = x.entity\n\n if (props.onViewLoad) {\n props.onViewLoad(x.entity)\n }\n })\n return () => {\n runAsync(async () => {\n await activePromise.current\n spatialEntity.current?.destroy()\n // Teardown\n if (props.onViewUnload) {\n props.onViewUnload()\n }\n })\n }\n }, [])\n\n // Remove props that cant be used on the div\n const { onViewLoad, onViewUnload, ...divProps } = props\n return <div ref={divRef} {...divProps} />\n },\n)\n\n/**\n * [Experimental] Allows embedding 3D dynamic content within the webpage\n */\nexport const SpatialView = SpatialViewEl\n","import React, {\n CSSProperties,\n forwardRef,\n Children,\n ReactElement,\n useMemo,\n ReactNode,\n useRef,\n useEffect,\n useState,\n} from 'react'\n\nimport { getSession } from '../../utils'\nimport {\n CSSModel3D,\n ModelElementRef,\n ModelEvent,\n ModelDragEvent,\n ModelElement,\n} from '../Model3D'\nexport type * from '../Model3D'\nimport { getAbsoluteURL } from '../Model3D/utils'\n\nimport { ModelViewerElement } from '@google/model-viewer'\n\n{\n // Set a default size for the model tag\n // This is done with css to allow it to be overwritten by className/css/style props\n const styleElement = document.createElement('style')\n styleElement.id = '__custom-class-model-webspatial'\n styleElement.innerHTML = `.__custom-class-model-webspatial { width: 300px; height: 300px; }`\n if (document.getElementById('__custom-class-model-webspatial')) {\n console.warn('__custom-class-model-webspatial already exists')\n }\n document.head.prepend(styleElement)\n}\n\ndeclare global {\n namespace JSX {\n interface IntrinsicElements {\n 'model-viewer': ModelViewerElement | { ref: any }\n }\n }\n}\n\ntype ModelChildren =\n | React.ReactElement<{ type: string; src: string }>\n | [React.ReactElement<{ type: string; src: string }>, React.ReactElement]\n | React.ReactElement<{ type: string; src: string }>[]\n\nexport interface ModelProps {\n // common for config Model3D and ModelViewer\n className?: string\n style?: CSSProperties | undefined\n children: ModelChildren\n onLoad?: (event: ModelEvent) => void\n\n // for config Model3D only\n contentMode?: 'fill' | 'fit'\n resizable?: boolean\n aspectRatio?: number\n onDragStart?: (dragEvent: ModelDragEvent) => void\n onDrag?: (dragEvent: ModelDragEvent) => void\n onDragEnd?: (dragEvent: ModelDragEvent) => void\n\n onTap?: (event: ModelEvent) => void\n onDoubleTap?: (event: ModelEvent) => void\n onLongPress?: (event: ModelEvent) => void\n\n // for config ModelViewer only\n poster?: string\n}\n\nfunction renderInModel3D(\n inProps: Omit<ModelProps, 'children'>,\n ref: ModelElementRef,\n modelUrl: string,\n placeHolder: ReactNode,\n) {\n const { poster, ...props } = inProps\n return (\n <CSSModel3D modelUrl={modelUrl} {...props} ref={ref}>\n {' '}\n {placeHolder}{' '}\n </CSSModel3D>\n )\n}\n\nfunction parseChildren(child: ModelChildren) {\n if (child === undefined) {\n throw new Error('children with <source> required ')\n }\n\n const children = Children.toArray(child)\n\n const sourceElements = children.filter(\n node => (node as ReactElement).type === 'source',\n )\n if (sourceElements.length === 0) {\n throw new Error('children with at least one <source> required ')\n }\n\n const gltfSources = sourceElements.filter(node => {\n const type = (node as ReactElement).props?.type.trim()\n const source = (node as ReactElement).props?.src.trim().toLowerCase()\n const isGLFT = source.endsWith('.gltf')\n const isGLB = source.endsWith('.glb')\n\n return (\n (type.startsWith('model/gltf-binary') && isGLB) ||\n (type.startsWith('model/gltf+json') && isGLFT)\n )\n })\n const usdzSources = sourceElements.filter(node =>\n (node as ReactElement).props?.type.trim().startsWith('model/vnd.usdz+zip'),\n )\n let lastChild = children[children.length - 1]\n const placeHolder =\n sourceElements.indexOf(lastChild) < 0 ? lastChild : undefined\n\n const gltfSourceURL =\n gltfSources.length > 0 ? (gltfSources[0] as ReactElement).props?.src : ''\n const usdzSourceURL =\n usdzSources.length > 0 ? (usdzSources[0] as ReactElement).props?.src : ''\n\n return {\n placeHolder,\n gltfSourceURL: getAbsoluteURL(gltfSourceURL),\n usdzSourceURL: getAbsoluteURL(usdzSourceURL),\n }\n}\n\nfunction ModelBase(inProps: ModelProps, ref: ModelElementRef) {\n const { children, ...props } = inProps\n // Set default dimensions with predefined class\n props.className =\n '__custom-class-model-webspatial ' +\n (props.className ? props.className : '')\n let className = props.className\n\n const { placeHolder, gltfSourceURL, usdzSourceURL } = useMemo(\n () => parseChildren(children),\n [children],\n )\n const isWebEnv = !getSession()\n if (isWebEnv) {\n const [loadFailed, setLoadFailed] = useState(false)\n useEffect(() => {\n if (gltfSourceURL == '') {\n console.warn('Unable to display model, no gltf/glb source provided')\n if (props.onLoad) {\n props.onLoad({\n target: { ready: false, currentSrc: gltfSourceURL } as any,\n })\n }\n setLoadFailed(true)\n }\n }, [])\n\n const myModelViewer = useRef<ModelViewerElement>(null)\n const { style = {}, ...props } = inProps\n\n const isDragging = useRef(false)\n let [modelViewerExists, setModelViewerExists] = useState(false)\n useEffect(() => {\n var modelViewerFound = false\n customElements.whenDefined('model-viewer').then(function () {\n modelViewerFound = true\n setModelViewerExists(modelViewerFound)\n })\n\n // if model-viewer element is not loaded in 500ms, print a warning\n setTimeout(() => {\n if (!modelViewerFound) {\n console.warn(\n 'model-viewer element not loaded yet, if you want to fallback to webGL model loading, you must include the model-viewer library manually in your html file eg. \\n\\n <script type=\"module\" src=\"https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js\"></script>',\n )\n if (props.onLoad) {\n props.onLoad({\n target: { ready: false, currentSrc: gltfSourceURL } as any,\n })\n }\n setLoadFailed(true)\n }\n }, 500)\n }, [])\n\n useEffect(() => {\n if (!modelViewerExists) {\n return\n }\n\n myModelViewer.current!.addEventListener('error', event => {\n if ((event as any).detail.type == 'loadfailure') {\n if (props.onLoad) {\n props.onLoad({\n target: { ready: false, currentSrc: gltfSourceURL } as any,\n })\n }\n setLoadFailed(true)\n }\n })\n\n myModelViewer.current!.addEventListener('load', event => {\n if (props.onLoad) {\n props.onLoad({\n target: { ready: true, currentSrc: gltfSourceURL } as any,\n })\n }\n setLoadFailed(false)\n })\n\n myModelViewer.current!.addEventListener('pointerdown', event => {\n isDragging.current = true\n if (props.onDragStart) {\n props.onDragStart({\n eventType: 'dragstart',\n translation3D: { x: 0, y: 0, z: 0 },\n startLocation3D: { x: 0, y: 0, z: 0 },\n target: (ref as any).current as ModelElement,\n })\n }\n })\n\n myModelViewer.current!.addEventListener('pointermove', event => {\n if (!isDragging.current) {\n return\n }\n if (props.onDrag) {\n props.onDrag({\n eventType: 'drag',\n translation3D: { x: 0, y: 0, z: 0 },\n startLocation3D: { x: 0, y: 0, z: 0 },\n target: (ref as any).current as ModelElement,\n })\n }\n })\n\n myModelViewer.current!.addEventListener('pointerup', event => {\n if (!isDragging.current) {\n return\n }\n isDragging.current = false\n if (props.onDragEnd) {\n props.onDragEnd({\n eventType: 'dragend',\n translation3D: { x: 0, y: 0, z: 0 },\n startLocation3D: { x: 0, y: 0, z: 0 },\n target: (ref as any).current as ModelElement,\n })\n }\n })\n }, [modelViewerExists])\n\n useEffect(() => {\n if (props.contentMode !== undefined && props.contentMode !== 'fit') {\n console.warn(\n \"Model element contentMode != fit isn't supported on 2D screens\",\n )\n }\n if (props.resizable !== undefined && props.resizable !== false) {\n console.warn(\n \"Model element resizable != false isn't supported on 2D screens\",\n )\n }\n if (props.aspectRatio !== undefined && props.aspectRatio !== 1) {\n console.warn(\n \"Model element aspectRatio != 1 isn't supported on 2D screens\",\n )\n }\n }, [props.contentMode, props.resizable, props.aspectRatio])\n\n return (\n <div ref={ref} className={className} style={style}>\n {modelViewerExists ? (\n <>\n <model-viewer\n ref={myModelViewer}\n style={\n {\n display: loadFailed ? 'none' : '',\n width: '100%',\n height: '100%',\n } as any\n }\n src={gltfSourceURL}\n camera-controls\n touch-action=\"pan-y\"\n poster={props.poster}\n ></model-viewer>\n {loadFailed ? <>{placeHolder}</> : <> </>}\n </>\n ) : (\n <>\n {props.poster ? (\n <img\n className={className}\n style={Object.assign(structuredClone(style), {\n objectFit: 'contain',\n })}\n src={props.poster}\n ></img>\n ) : (\n <>{placeHolder}</>\n )}\n </>\n )}\n </div>\n )\n } else {\n return renderInModel3D(props, ref, usdzSourceURL, placeHolder)\n }\n}\n\nexport const Model = forwardRef(ModelBase)\nModel.displayName = 'Model'\n","import { forwardRef, useContext, useMemo } from 'react'\nimport { Model3DProps, ModelElementRef } from './types'\nimport { SpatialLayerContext } from '../SpatialReactComponent/SpatialLayerContext'\nimport { SpatialReactContext } from '../SpatialReactComponent/SpatialReactContext'\nimport { renderModel3DNotInSpatialDiv } from './Model3DNotInSpatialDiv'\nimport { renderModel3DStandardInstance } from './Model3DStandardInstance'\nimport { renderModel3DPortalInstance } from './Model3DPortalInstance'\nimport { SpatialIsStandardInstanceContext } from '../SpatialReactComponent/SpatialIsStandardInstanceContext'\n\nfunction Model3DBase(props: Model3DProps, refIn: ModelElementRef) {\n const parentSpatialReactContextObject = useContext(SpatialReactContext)\n const isInSpatialDiv = !!parentSpatialReactContextObject\n\n if (isInSpatialDiv) {\n const layer = useContext(SpatialLayerContext) + 1\n const isInStandardInstance = !!useContext(SpatialIsStandardInstanceContext)\n const spatialId = useMemo(() => {\n return parentSpatialReactContextObject.getSpatialID(\n layer,\n isInStandardInstance,\n 'Model3D',\n )\n }, [])\n if (isInStandardInstance) {\n return renderModel3DStandardInstance(spatialId, props, refIn)\n } else {\n return renderModel3DPortalInstance(spatialId, props)\n }\n } else {\n return renderModel3DNotInSpatialDiv(props, refIn)\n }\n}\n\nexport const Model3D = forwardRef(Model3DBase)\n\nModel3D.displayName = 'Model3D'\n","import { useRef, useEffect } from 'react'\n\nexport function useDetectLayoutDomUpdated(onDomUpdated: () => void) {\n const ref = useRef<HTMLDivElement>(null)\n\n // detect window resize\n useEffect(() => {\n const handleResize = () => {\n onDomUpdated()\n }\n window.addEventListener('resize', handleResize)\n return () => {\n window.removeEventListener('resize', handleResize)\n }\n }, [])\n\n // detect dom resize\n // Trigger native resize on web resize events\n useEffect(() => {\n if (!ref.current) {\n console.warn('Ref is not attached to the DOM')\n return\n }\n\n let ro = new ResizeObserver(elements => {\n onDomUpdated()\n })\n\n ro.observe(ref.current!)\n return () => {\n ro.disconnect()\n }\n }, [])\n\n // detect dom style and class change\n useEffect(() => {\n if (!ref.current) {\n console.warn('Ref is not attached to the DOM')\n return\n }\n let ro = new MutationObserver(elements => {\n onDomUpdated()\n })\n\n ro.observe(ref.current!, {\n attributeFilter: ['class', 'style'],\n subtree: true,\n attributeOldValue: false,\n })\n return () => {\n ro.disconnect()\n }\n }, [])\n\n return ref\n}\n","import { useRef, useEffect, useState } from 'react'\nimport { Model3DNative } from './Model3DNative'\nimport { SpatialModelDragEvent, SpatialEntity } from '@webspatial/core-sdk'\n\nexport function useModel3DNative(\n modelUrl: string,\n parentEntity: SpatialEntity | undefined,\n eventHandlers: {\n onDragStart?: (dragEvent: SpatialModelDragEvent) => void\n onDrag?: (dragEvent: SpatialModelDragEvent) => void\n onDragEnd?: (dragEvent: SpatialModelDragEvent) => void\n onTap?: () => void\n onDoubleTap?: () => void\n onLongPress?: () => void\n } = {},\n onModel3DNativeReadyCb?: (model3DNative: Model3DNative) => void,\n) {\n let model3DNativeRef = useRef<Model3DNative | null>(null)\n\n const [phase, setPhase] = useState<'loading' | 'success' | 'failure'>(\n 'loading',\n )\n const [failureReason, setFailureReason] = useState('')\n\n useEffect(() => {\n let isDestroyed = false\n\n const model3DContainer = new Model3DNative(parentEntity)\n\n model3DContainer\n .init(\n modelUrl,\n () => {\n setPhase('success')\n },\n (error: string) => {\n setPhase('failure')\n setFailureReason(error)\n },\n )\n .then(() => {\n if (!isDestroyed) {\n model3DNativeRef.current = model3DContainer\n if (onModel3DNativeReadyCb) {\n onModel3DNativeReadyCb(model3DContainer)\n }\n }\n })\n\n return () => {\n isDestroyed = true\n\n model3DContainer.destroy()\n\n model3DNativeRef.current = null\n\n setPhase('loading')\n }\n }, [modelUrl])\n\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.onDragStart = eventHandlers.onDragStart\n }\n }, [model3DNativeRef.current, eventHandlers.onDragStart])\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.onDrag = eventHandlers.onDrag\n }\n }, [model3DNativeRef.current, eventHandlers.onDrag])\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.onDragEnd = eventHandlers.onDragEnd\n }\n })\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.onTap = eventHandlers.onTap\n }\n }, [model3DNativeRef.current, eventHandlers.onTap])\n\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.onDoubleTap = eventHandlers.onDoubleTap\n }\n }, [model3DNativeRef.current, eventHandlers.onDoubleTap])\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.onLongPress = eventHandlers.onLongPress\n }\n }, [model3DNativeRef.current, eventHandlers.onLongPress])\n\n return { model3DNativeRef, phase, failureReason }\n}\n","import { PartialSpatialTransformType, SpatialTransformType } from './types'\n\nexport function PopulatePartialSpatialTransformType(\n spatialTransform: PartialSpatialTransformType = {},\n): SpatialTransformType {\n const {\n position = { x: 0, y: 0, z: 0 },\n rotation = { x: 0, y: 0, z: 0, w: 1 },\n scale = { x: 1, y: 1, z: 1 },\n } = spatialTransform\n const { x: tx = 0, y: ty = 0, z: tz = 0 } = position\n const { x: rx = 0, y: ry = 0, z: rz = 0, w = 1 } = rotation\n const { x: sx = 1, y: sy = 1, z: sz = 1 } = scale\n\n return {\n position: { x: tx, y: ty, z: tz },\n rotation: { x: rx, y: ry, z: rz, w },\n scale: { x: sx, y: sy, z: sz },\n }\n}\n\nexport function getAbsoluteURL(url: string) {\n if (!url) {\n return ''\n }\n if (url.startsWith('http')) {\n return url\n }\n return `${location.origin}${url}`\n}\n","import {\n SpatialModelDragEvent,\n SpatialEntity,\n SpatialModel3DComponent,\n} from '@webspatial/core-sdk'\nimport { getSession } from '../../utils'\nimport { SpatialTransformType } from './types'\nimport { getAbsoluteURL } from './utils'\nimport { parseTransformOrigin } from '../SpatialReactComponent/utils'\nimport { RectType } from '../types'\n\nexport class Model3DNative {\n constructor(parentEntity?: SpatialEntity) {\n this.parentEntity = parentEntity\n }\n\n private parentEntity?: SpatialEntity\n private initPromise?: Promise<any>\n private entity?: SpatialEntity\n private spatialModel3DComponent?: SpatialModel3DComponent\n\n // private modelUrl: string\n\n private isDestroyed = false\n\n private _onDragStart?: (dragEvent: SpatialModelDragEvent) => void\n private _onDrag?: (dragEvent: SpatialModelDragEvent) => void\n private _onDragEnd?: (dragEvent: SpatialModelDragEvent) => void\n\n private _onTap?: () => void\n private _onDoubleTap?: () => void\n private _onLongPress?: () => void\n\n async init(\n modelUrl: string,\n onSuccess: () => void,\n onFailure: (error: string) => void,\n ) {\n if (this.isDestroyed) {\n return\n }\n\n this.initPromise = this.initInternal(modelUrl, onSuccess, onFailure)\n\n return this.initPromise\n }\n\n private async initInternal(\n modelUrl: string,\n onSuccess: () => void,\n onFailure: (error: string) => void,\n ) {\n var session = getSession()\n\n if (!session) {\n return\n }\n\n // Create entity with view component to display the model inside\n const entity = await session.createEntity()\n await entity.setCoordinateSpace('Dom')\n\n const spatialModel3DComponent = await session.createModel3DComponent({\n url: getAbsoluteURL(modelUrl),\n })\n\n await entity.setComponent(spatialModel3DComponent)\n if (this.isDestroyed) {\n return\n }\n if (this.parentEntity) {\n await entity.setParent(this.parentEntity)\n } else {\n // Add entity to the window\n var wc = session.getCurrentWindowComponent()\n var ent = await wc.getEntity()\n await entity.setParent(ent!)\n }\n\n this.entity = entity\n this.spatialModel3DComponent = spatialModel3DComponent\n\n this.spatialModel3DComponent.onSuccess = onSuccess\n this.spatialModel3DComponent.onFailure = onFailure\n this.spatialModel3DComponent.onDragStart = this._onDragStart\n this.spatialModel3DComponent.onDrag = this._onDrag\n this.spatialModel3DComponent.onDragEnd = this._onDragEnd\n this.spatialModel3DComponent.onTap = this._onTap\n this.spatialModel3DComponent.onDoubleTap = this._onDoubleTap\n this.spatialModel3DComponent.onLongPress = this._onLongPress\n }\n\n async setVisible(visible: boolean) {\n if (this.entity) {\n await this.entity.setVisible(visible)\n }\n }\n\n async setContentMode(contentMode: 'fill' | 'fit') {\n if (this.spatialModel3DComponent) {\n await this.spatialModel3DComponent.setContentMode(contentMode)\n }\n }\n\n async setResizable(resizable: boolean) {\n if (this.spatialModel3DComponent) {\n await this.spatialModel3DComponent.setResizable(resizable)\n }\n }\n\n async setAspectRatio(aspectRatio: number) {\n if (this.spatialModel3DComponent) {\n await this.spatialModel3DComponent.setAspectRatio(aspectRatio)\n }\n }\n\n async updateByDom(\n dom: HTMLDivElement,\n options: { spatialTransform: SpatialTransformType },\n ) {\n if (!this.entity || !this.spatialModel3DComponent) {\n return\n }\n\n const computedStyle = getComputedStyle(dom)\n\n const isFixed = computedStyle.position === 'fixed'\n const scrollY = isFixed ? 0 : window.scrollY\n\n const rect = dom.getBoundingClientRect()\n const targetPosX = rect.left + (rect.right - rect.left) / 2\n const targetPosY = rect.bottom + (rect.top - rect.bottom) / 2 + scrollY\n const { spatialTransform } = options\n const { position, rotation, scale } = spatialTransform\n\n const entity = this.entity\n entity.transform.position.x = targetPosX + position.x\n entity.transform.position.y = targetPosY + position.y\n entity.transform.position.z = position.z\n\n entity.transform.orientation.x = rotation.x\n entity.transform.orientation.y = rotation.y\n entity.transform.orientation.z = rotation.z\n entity.transform.orientation.w = rotation.w\n\n entity.transform.scale.x = scale.x\n entity.transform.scale.y = scale.y\n entity.transform.scale.z = scale.z\n\n await entity.updateTransform()\n\n const spatialModel3DComponent = this.spatialModel3DComponent\n await spatialModel3DComponent.setResolution(rect.width, rect.height)\n\n const opacity = parseFloat(computedStyle.getPropertyValue('opacity'))\n await spatialModel3DComponent.setOpacity(opacity)\n\n const anchor = parseTransformOrigin(computedStyle)\n await spatialModel3DComponent.setRotationAnchor(anchor)\n\n await this.setScrollWithParent(!isFixed)\n }\n\n async updateRectAndTransform(\n rect: RectType,\n spatialTransform: SpatialTransformType,\n ) {\n if (!this.entity || !this.spatialModel3DComponent) {\n return\n }\n\n const targetPosX = rect.x + rect.width / 2\n const targetPosY = rect.y + rect.height / 2\n\n const { position, rotation, scale } = spatialTransform\n const entity = this.entity\n entity.transform.position.x = targetPosX + position.x\n entity.transform.position.y = targetPosY + position.y\n entity.transform.position.z = position.z\n entity.transform.orientation.x = rotation.x\n entity.transform.orientation.y = rotation.y\n entity.transform.orientation.z = rotation.z\n entity.transform.orientation.w = rotation.w\n entity.transform.scale.x = scale.x\n entity.transform.scale.y = scale.y\n entity.transform.scale.z = scale.z\n await entity.updateTransform()\n const spatialModel3DComponent = this.spatialModel3DComponent\n await spatialModel3DComponent.setResolution(rect.width, rect.height)\n }\n\n async setRotationAnchor(anchor: { x: number; y: number; z: number }) {\n if (this.spatialModel3DComponent) {\n await this.spatialModel3DComponent.setRotationAnchor(anchor)\n }\n }\n\n async setOpacity(opacity: number) {\n if (this.spatialModel3DComponent) {\n this.spatialModel3DComponent.setOpacity(opacity)\n }\n }\n\n async setScrollWithParent(scrollWithParent: boolean) {\n if (this.spatialModel3DComponent) {\n this.spatialModel3DComponent.setScrollWithParent(scrollWithParent)\n }\n }\n\n async changeParentEntity(parentEntity: SpatialEntity) {\n if (this.parentEntity !== parentEntity) {\n if (this.entity) {\n await this.entity.setParent(parentEntity)\n }\n this.parentEntity = parentEntity\n }\n }\n\n public set onDragStart(\n callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined,\n ) {\n if (this.spatialModel3DComponent) {\n this.spatialModel3DComponent.onDragStart = callback\n }\n this._onDragStart = callback\n }\n\n public set onDrag(\n callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined,\n ) {\n if (this.spatialModel3DComponent) {\n this.spatialModel3DComponent.onDrag = callback\n }\n this._onDrag = callback\n }\n\n public set onDragEnd(\n callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined,\n ) {\n if (this.spatialModel3DComponent) {\n this.spatialModel3DComponent.onDragEnd = callback\n }\n this._onDragEnd = callback\n }\n\n public set onTap(callback: (() => void) | undefined) {\n if (this.spatialModel3DComponent) {\n this.spatialModel3DComponent.onTap = callback\n }\n this._onTap = callback\n }\n\n public set onDoubleTap(callback: (() => void) | undefined) {\n if (this.spatialModel3DComponent) {\n this.spatialModel3DComponent.onDoubleTap = callback\n }\n this._onDoubleTap = callback\n }\n public set onLongPress(callback: (() => void) | undefined) {\n if (this.spatialModel3DComponent) {\n this.spatialModel3DComponent.onLongPress = callback\n }\n this._onLongPress = callback\n }\n\n /**\n * Destroys the current 3D model instance\n * 1. Marks the instance as destroyed\n * 2. Waits for initialization to complete (if in progress)\n * 3. Destroys the spatial entity\n * 4. Cleans up all related references\n */\n async destroy() {\n this.isDestroyed = true\n if (this.initPromise) {\n await this.initPromise\n }\n this.entity?.destroy()\n this.entity = undefined\n this.spatialModel3DComponent = undefined\n this.initPromise = undefined\n }\n}\n","import { SpatialModelDragEvent } from '@webspatial/core-sdk'\n\nimport {\n ModelEvent,\n Model3DProps,\n ModelElement,\n ModelElementRef,\n ModelDragEvent,\n} from './types'\nimport { useDetectLayoutDomUpdated } from './useDetectLayoutDomUpdated'\nimport { useModel3DNative } from './useModel3DNative'\nimport { CSSProperties, useCallback, useEffect, useMemo } from 'react'\nimport { PopulatePartialSpatialTransformType } from './utils'\n\nexport function renderModel3DNotInSpatialDiv(\n props: Model3DProps,\n refIn: ModelElementRef,\n) {\n const {\n className,\n style = {},\n modelUrl,\n visible,\n spatialTransform,\n contentMode = 'fit',\n resizable = true,\n aspectRatio = 0,\n onLoad,\n\n children,\n\n onDragStart,\n onDrag,\n onDragEnd,\n\n onTap,\n onDoubleTap,\n onLongPress,\n } = props\n\n const theSpatialTransform =\n PopulatePartialSpatialTransformType(spatialTransform)\n\n const onDomUpdated = useCallback(() => {\n if (model3DNativeRef.current && layoutInstanceRef.current) {\n const model3DNative = model3DNativeRef.current\n model3DNative.updateByDom(layoutInstanceRef.current, {\n spatialTransform: theSpatialTransform,\n })\n }\n }, [\n theSpatialTransform.position.x,\n theSpatialTransform.position.y,\n theSpatialTransform.position.z,\n theSpatialTransform.rotation.x,\n theSpatialTransform.rotation.y,\n theSpatialTransform.rotation.z,\n theSpatialTransform.rotation.w,\n theSpatialTransform.scale.x,\n theSpatialTransform.scale.y,\n theSpatialTransform.scale.z,\n ])\n\n const onModel3DContainerReadyCb = useCallback(() => {\n if (model3DNativeRef.current && layoutInstanceRef.current) {\n model3DNativeRef.current.updateByDom(layoutInstanceRef.current, {\n spatialTransform: theSpatialTransform,\n })\n }\n }, [\n theSpatialTransform.position.x,\n theSpatialTransform.position.y,\n theSpatialTransform.position.z,\n theSpatialTransform.rotation.x,\n theSpatialTransform.rotation.y,\n theSpatialTransform.rotation.z,\n theSpatialTransform.rotation.w,\n theSpatialTransform.scale.x,\n theSpatialTransform.scale.y,\n theSpatialTransform.scale.z,\n ])\n\n const onDragStartCb = useCallback(\n (spatialDragEvent: SpatialModelDragEvent) => {\n if (onDragStart) {\n const dragEvent: ModelDragEvent = {\n ...spatialDragEvent,\n target: layoutInstanceRef.current! as ModelElement,\n }\n onDragStart(dragEvent)\n }\n },\n [onDragStart],\n )\n\n const onDragCb = useCallback(\n (spatialDragEvent: SpatialModelDragEvent) => {\n if (onDrag) {\n const dragEvent: ModelDragEvent = {\n ...spatialDragEvent,\n target: layoutInstanceRef.current! as ModelElement,\n }\n onDrag(dragEvent)\n }\n },\n [onDrag],\n )\n\n const onDragEndCb = useCallback(\n (spatialDragEvent: SpatialModelDragEvent) => {\n if (onDragEnd) {\n const dragEvent: ModelDragEvent = {\n ...spatialDragEvent,\n target: layoutInstanceRef.current! as ModelElement,\n }\n onDragEnd(dragEvent)\n }\n },\n [onDragEnd],\n )\n\n const onTapCb = useCallback(() => {\n if (onTap) {\n const event: ModelEvent = {\n target: layoutInstanceRef.current! as ModelElement,\n }\n onTap(event)\n }\n }, [onTap])\n\n const onDoubleTapCb = useCallback(() => {\n if (onDoubleTap) {\n const event: ModelEvent = {\n target: layoutInstanceRef.current! as ModelElement,\n }\n onDoubleTap(event)\n }\n }, [onDoubleTap])\n\n const onLongPressCb = useCallback(() => {\n if (onLongPress) {\n const event: ModelEvent = {\n target: layoutInstanceRef.current! as ModelElement,\n }\n onLongPress(event)\n }\n }, [onLongPress])\n\n const layoutInstanceRef = useDetectLayoutDomUpdated(onDomUpdated)\n const { model3DNativeRef, phase, failureReason } = useModel3DNative(\n modelUrl,\n undefined,\n {\n onDragStart: onDragStart ? onDragStartCb : undefined,\n onDrag: onDrag ? onDragCb : undefined,\n onDragEnd: onDragEnd ? onDragEndCb : undefined,\n onTap: onTap ? onTapCb : undefined,\n onDoubleTap: onDoubleTap ? onDoubleTapCb : undefined,\n onLongPress: onLongPress ? onLongPressCb : undefined,\n },\n onModel3DContainerReadyCb,\n )\n\n const onSuccess = useCallback(() => {\n ;(layoutInstanceRef.current! as ModelElement).ready = true\n if (onLoad) {\n onLoad({\n target: layoutInstanceRef.current! as ModelElement,\n })\n }\n }, [onLoad])\n\n const onFailure = useCallback(\n (_: string) => {\n const modelElement = layoutInstanceRef.current! as ModelElement\n modelElement.ready = false\n if (onLoad) {\n onLoad({\n target: layoutInstanceRef.current! as ModelElement,\n })\n }\n },\n [onLoad],\n )\n\n useEffect(() => {\n if (phase === 'failure') {\n onFailure(failureReason)\n } else if (phase === 'success') {\n onSuccess()\n }\n }, [phase])\n\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setVisible(visible)\n }\n }, [model3DNativeRef.current, visible])\n\n useEffect(() => {\n if (model3DNativeRef.current && layoutInstanceRef.current) {\n model3DNativeRef.current.updateByDom(layoutInstanceRef.current, {\n spatialTransform: theSpatialTransform,\n })\n }\n }, [\n theSpatialTransform.position.x,\n theSpatialTransform.position.y,\n theSpatialTransform.position.z,\n theSpatialTransform.rotation.x,\n theSpatialTransform.rotation.y,\n theSpatialTransform.rotation.z,\n theSpatialTransform.rotation.w,\n theSpatialTransform.scale.x,\n theSpatialTransform.scale.y,\n theSpatialTransform.scale.z,\n ])\n\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setContentMode(contentMode)\n }\n }, [model3DNativeRef.current, contentMode])\n\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setResizable(resizable)\n }\n }, [model3DNativeRef.current, resizable])\n\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setAspectRatio(aspectRatio)\n }\n }, [model3DNativeRef.current, aspectRatio])\n\n const layoutDomStyle: CSSProperties = {\n ...style,\n visibility: phase === 'failure' ? 'visible' : 'hidden',\n transform: '',\n }\n\n const proxyRef = useMemo(\n () =>\n new Proxy<typeof layoutInstanceRef>(layoutInstanceRef, {\n get(target, prop, receiver) {\n return Reflect.get(target, prop, receiver)\n },\n set(target, prop, value, receiver) {\n if (prop === 'current') {\n const domElement = value as ModelElement\n\n if (domElement) {\n domElement.ready = false\n domElement.currentSrc = modelUrl\n }\n\n if (refIn) {\n if (typeof refIn === 'function') {\n refIn(domElement)\n } else {\n refIn.current = domElement\n }\n }\n }\n return Reflect.set(target, prop, value, receiver)\n },\n }),\n [layoutInstanceRef, refIn],\n )\n\n useEffect(() => {\n return () => {\n if (layoutInstanceRef.current) {\n const modelElement = layoutInstanceRef.current as ModelElement\n\n modelElement.ready = false\n modelElement.currentSrc = modelUrl\n }\n }\n }, [modelUrl])\n\n return (\n <div className={className} style={layoutDomStyle} ref={proxyRef}>\n {phase === 'failure' && children}\n </div>\n )\n}\n","import { SpatialID } from '../SpatialReactComponent/const'\nimport { Model3DProps, ModelElementRef } from './types'\n\nexport function renderModel3DStandardInstance(\n spatialId: string,\n props: Model3DProps,\n refIn: ModelElementRef,\n) {\n const { className, style } = props\n const extraProps = {\n [SpatialID]: spatialId,\n }\n\n return (\n <div\n data-model3d-spatialid={spatialId}\n className={className}\n style={style}\n ref={refIn}\n {...extraProps}\n />\n )\n}\n","import React, {\n CSSProperties,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n} from 'react'\nimport { Model3DProps, ModelElement, ModelDragEvent, ModelEvent } from './types'\nimport { useSyncDomInfoFromStandardInstance } from './useSyncDomInfoFromStandardInstance'\nimport { useModel3DNative } from './useModel3DNative'\nimport { PopulatePartialSpatialTransformType } from './utils'\nimport { SpatialWindowManagerContext } from '../SpatialReactComponent/SpatialWindowManagerContext'\nimport { type SpatialModelDragEvent } from '@webspatial/core-sdk'\nimport { getSession } from '../../utils'\n\nfunction useModelEvents(\n props: Model3DProps,\n modelRef: React.RefObject<ModelElement>,\n) {\n const {\n onDragStart,\n onDrag,\n onDragEnd,\n\n onTap,\n onDoubleTap,\n onLongPress,\n } = props\n\n const onDragStartCb = useCallback(\n (spatialDragEvent: SpatialModelDragEvent) => {\n if (onDragStart) {\n const dragEvent: ModelDragEvent = {\n ...spatialDragEvent,\n target: modelRef.current! as ModelElement,\n }\n onDragStart(dragEvent)\n }\n },\n [onDragStart],\n )\n\n const onDragCb = useCallback(\n (spatialDragEvent: SpatialModelDragEvent) => {\n if (onDrag) {\n const dragEvent: ModelDragEvent = {\n ...spatialDragEvent,\n target: modelRef.current! as ModelElement,\n }\n onDrag(dragEvent)\n }\n },\n [onDrag],\n )\n\n const onDragEndCb = useCallback(\n (spatialDragEvent: SpatialModelDragEvent) => {\n if (onDragEnd) {\n const dragEvent: ModelDragEvent = {\n ...spatialDragEvent,\n target: modelRef.current! as ModelElement,\n }\n onDragEnd(dragEvent)\n }\n },\n [onDragEnd],\n )\n\n const onTapCb = useCallback(() => {\n if (onTap) {\n const event: ModelEvent = {\n target: modelRef.current! as ModelElement,\n }\n onTap(event)\n }\n }, [onTap])\n\n const onDoubleTapCb = useCallback(() => {\n if (onDoubleTap) {\n const event: ModelEvent = {\n target: modelRef.current! as ModelElement,\n }\n onDoubleTap(event)\n }\n }, [onDoubleTap])\n\n const onLongPressCb = useCallback(() => {\n if (onLongPress) {\n const event: ModelEvent = {\n target: modelRef.current! as ModelElement,\n }\n onLongPress(event)\n }\n }, [onLongPress])\n\n return {\n onDragStart: onDragStartCb,\n onDrag: onDragCb,\n onDragEnd: onDragEndCb,\n onTap: onTapCb,\n onDoubleTap: onDoubleTapCb,\n onLongPress: onLongPressCb,\n }\n}\n\nexport function renderModel3DPortalInstance(\n spatialId: string,\n props: Model3DProps,\n) {\n const {\n style: _,\n modelUrl,\n visible,\n spatialTransform,\n contentMode = 'fit',\n resizable = true,\n aspectRatio = 0,\n onLoad,\n\n children,\n } = props\n\n const theSpatialTransform = useMemo(() => {\n return PopulatePartialSpatialTransformType(spatialTransform)\n }, [spatialTransform])\n\n const {\n modelRef,\n domRect,\n inheritedPortalStyle,\n anchor,\n opacity,\n className,\n } = useSyncDomInfoFromStandardInstance(spatialId)\n\n const parentSpatialWindowManager = useContext(SpatialWindowManagerContext)\n\n const eventHandlers = useModelEvents(\n props,\n modelRef as React.RefObject<ModelElement>,\n )\n\n const { model3DNativeRef, phase, failureReason } = useModel3DNative(\n modelUrl,\n parentSpatialWindowManager!.entity!,\n eventHandlers,\n )\n\n // handle rect and transform\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.updateRectAndTransform(\n domRect,\n theSpatialTransform,\n )\n }\n }, [model3DNativeRef.current, domRect, theSpatialTransform])\n\n // handle anchor\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setRotationAnchor(anchor)\n }\n }, [model3DNativeRef.current, anchor])\n\n // handle visible\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setVisible(visible)\n }\n }, [model3DNativeRef.current, visible])\n\n // handle currentMode\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setContentMode(contentMode)\n }\n }, [model3DNativeRef.current, contentMode])\n\n // handle resizable\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setResizable(resizable)\n }\n }, [model3DNativeRef.current, resizable])\n\n // handle aspectRatio\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setAspectRatio(aspectRatio)\n }\n }, [model3DNativeRef.current, aspectRatio])\n\n // handle opacity\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setOpacity(opacity)\n }\n }, [model3DNativeRef.current, opacity])\n\n const isFixedPosition = inheritedPortalStyle.position == 'fixed'\n\n // handle scrollWithParent Properties\n useEffect(() => {\n if (model3DNativeRef.current) {\n model3DNativeRef.current.setScrollWithParent(\n inheritedPortalStyle.position !== 'fixed',\n )\n\n if (isFixedPosition) {\n ;(async function () {\n var wc = await getSession()!.getCurrentWindowComponent()\n var ent = await wc.getEntity()\n model3DNativeRef.current?.changeParentEntity(ent!)\n })()\n }\n }\n }, [model3DNativeRef.current, isFixedPosition])\n\n // handle onLoad using onSuccess/onFailure\n const onSuccess = useCallback(() => {\n ;(modelRef.current! as ModelElement).ready = true\n if (onLoad) {\n onLoad({\n target: modelRef.current! as ModelElement,\n })\n }\n }, [onLoad])\n\n const onFailure = useCallback(\n (_: string) => {\n const modelElement = modelRef.current! as ModelElement\n modelElement.ready = false\n if (onLoad) {\n onLoad({\n target: modelRef.current! as ModelElement,\n })\n }\n },\n [onLoad],\n )\n\n useEffect(() => {\n if (phase === 'failure') {\n onFailure(failureReason)\n } else if (phase === 'success') {\n onSuccess()\n }\n }, [phase])\n\n // handle modelUrl change, need to reset ready/currentSrc\n useEffect(() => {\n return () => {\n const modelElement = modelRef.current! as ModelElement\n if (modelElement) {\n modelElement.ready = false\n modelElement.currentSrc = modelUrl\n }\n }\n }, [modelUrl])\n\n const needRenderPlaceHolder =\n inheritedPortalStyle.position !== 'absolute' &&\n inheritedPortalStyle.position !== 'fixed'\n\n if (!needRenderPlaceHolder && phase !== 'failure') {\n return <></>\n } else {\n const extraStyle: CSSProperties = {\n visibility: 'visible',\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 width: `${domRect.width}px`,\n height: `${domRect.height}px`,\n }\n\n const style: CSSProperties = {\n ...inheritedPortalStyle,\n ...extraStyle,\n }\n\n return (\n <div\n data-model3d-spatialid={spatialId}\n className={className}\n style={style}\n >\n {phase === 'failure' && children}\n </div>\n )\n }\n}\n","import { useRef, useEffect, useState, useContext, CSSProperties } from 'react'\nimport { SpatialReactContext } from '../SpatialReactComponent/SpatialReactContext'\nimport {\n getInheritedStyleProps,\n domRect2rectType,\n parseTransformOrigin,\n} from '../SpatialReactComponent/utils'\n\nexport function useSyncDomInfoFromStandardInstance(spatialId: string) {\n const [domRect, setDomRect] = useState({\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n })\n\n const inheritedPortalStyleRef = useRef<CSSProperties>({})\n\n const anchorRef = useRef({\n x: 0.5,\n y: 0.5,\n z: 0.5,\n })\n\n const opacityRef = useRef(1.0)\n\n const spatialReactContextObject = useContext(SpatialReactContext)\n\n const inheritedPortalClassNameRef = useRef('')\n\n const modelRef = useRef<HTMLDivElement | null>(null)\n\n useEffect(() => {\n const syncDomRect = () => {\n const dom = spatialReactContextObject?.querySpatialDom(spatialId)\n if (!dom) {\n return\n }\n modelRef.current = dom as HTMLDivElement\n\n const computedStyle = getComputedStyle(dom)\n inheritedPortalStyleRef.current = getInheritedStyleProps(computedStyle)\n const stylePosition = inheritedPortalStyleRef.current.position\n const isFixedPosition = stylePosition === 'fixed'\n\n let domRect = dom.getBoundingClientRect()\n let rectType = domRect2rectType(domRect)\n\n if (!isFixedPosition) {\n const parentDom =\n spatialReactContextObject?.queryParentSpatialDom(spatialId)\n if (parentDom) {\n const parentDomRect = parentDom.getBoundingClientRect()\n const parentRectType = domRect2rectType(parentDomRect)\n rectType.x -= parentRectType.x\n rectType.y -= parentRectType.y\n }\n }\n\n const anchor = parseTransformOrigin(computedStyle)\n anchorRef.current = anchor\n\n const opacity = parseFloat(computedStyle.getPropertyValue('opacity'))\n opacityRef.current = opacity\n\n inheritedPortalClassNameRef.current = dom.className\n\n setDomRect(rectType)\n }\n\n spatialReactContextObject?.onDomChange(spatialId, syncDomRect)\n\n return () => {\n spatialReactContextObject?.offDomChange(spatialId)\n }\n }, [])\n\n return {\n modelRef,\n domRect,\n inheritedPortalStyle: inheritedPortalStyleRef.current,\n anchor: anchorRef.current,\n opacity: opacityRef.current,\n className: inheritedPortalClassNameRef.current,\n }\n}\n","import { forwardRef, useContext, useMemo } from 'react'\nimport { CSSModel3DProps, ModelElementRef } from './types'\nimport { SpatialReactContext } from '../SpatialReactComponent/SpatialReactContext'\nimport { SpatialLayerContext } from '../SpatialReactComponent/SpatialLayerContext'\nimport { SpatialIsStandardInstanceContext } from '../SpatialReactComponent/SpatialIsStandardInstanceContext'\nimport { renderCSSModel3DNotInSpatialDiv } from './CSSModel3DNotInSpatialDiv'\nimport { renderCSSModel3DStandardInstance } from './CSSModel3DStandardInstance'\nimport { renderCSSModel3DPortalInstance } from './CSSModel3DPortalInstance'\n\nexport function CSSModel3DBase(props: CSSModel3DProps, refIn: ModelElementRef) {\n const rootSpatialReactContextObject = useContext(SpatialReactContext)\n const isInSpatialDiv = !!rootSpatialReactContextObject\n\n if (isInSpatialDiv) {\n const layer = useContext(SpatialLayerContext) + 1\n const isInStandardInstance = !!useContext(SpatialIsStandardInstanceContext)\n const spatialId = useMemo(() => {\n return rootSpatialReactContextObject.getSubDivSpatialID(\n layer,\n isInStandardInstance,\n 'CSSModel3D',\n )\n }, [])\n if (isInStandardInstance) {\n return renderCSSModel3DStandardInstance(spatialId, props, refIn)\n } else {\n return renderCSSModel3DPortalInstance(spatialId, props)\n }\n } else {\n return renderCSSModel3DNotInSpatialDiv(props, refIn)\n }\n}\n\nexport const CSSModel3D = forwardRef(CSSModel3DBase)\n\nCSSModel3D.displayName = 'CSSModel3D'\n","import { CSSProperties, ForwardedRef } from 'react'\nimport { Model3D } from './Model3D'\nimport { useSpatialStyle } from '../CSSSpatialDiv/useSpatialStyle'\nimport { useHijackSpatialDivRef } from '../CSSSpatialDiv/useHijackSpatialDivRef'\nimport { CSSModel3DProps, ModelElementRef } from './types'\n\nexport function renderCSSModel3DNotInSpatialDiv(\n inProps: CSSModel3DProps,\n refIn: ModelElementRef,\n) {\n const { className, style = {}, ...props } = inProps\n\n const cssParserDomStyle: CSSProperties = {\n ...style,\n width: 0,\n height: 0,\n padding: 0,\n position: 'absolute',\n }\n\n const { ref: cssParserDomRef, spatialStyle, ready } = useSpatialStyle()\n\n // hijack SpatialDiv ref\n const ref = useHijackSpatialDivRef(\n refIn as ForwardedRef<HTMLDivElement>,\n cssParserDomRef,\n ) as ModelElementRef\n\n const spatialTransform = {\n position: spatialStyle.position,\n rotation: spatialStyle.rotation,\n scale: spatialStyle.scale,\n }\n const visible = spatialStyle.visible\n\n const model3DStyle: CSSProperties = {\n ...style,\n transform: spatialStyle.transformExist ? 'translateZ(0)' : 'none',\n }\n return (\n <>\n {ready && (\n <Model3D\n className={className}\n style={model3DStyle}\n ref={ref}\n spatialTransform={spatialTransform}\n visible={visible}\n {...props}\n />\n )}\n <div\n className={className}\n style={cssParserDomStyle}\n ref={cssParserDomRef}\n />\n </>\n )\n}\n","import React, { ForwardedRef, useContext, useEffect, useRef } from 'react'\nimport { CSSModel3DProps, ModelElementRef } from './types'\nimport { useHijackSpatialDivRef } from '../CSSSpatialDiv/useHijackSpatialDivRef'\nimport { Model3D } from './Model3D'\nimport { CSSProperties } from 'react'\nimport { SpatialReactContext } from '../SpatialReactComponent/SpatialReactContext'\n\nexport function renderCSSModel3DStandardInstance(\n spatialId: string,\n inProps: CSSModel3DProps,\n refIn: ModelElementRef,\n) {\n const { style: inStyle = {}, ...props } = inProps\n const style: CSSProperties = {\n ...inStyle,\n transform: 'none',\n visibility: 'hidden',\n }\n\n // hijack SpatialDiv ref\n var cssParserRef = useRef<HTMLDivElement | null>(null)\n const ref = useHijackSpatialDivRef(\n refIn as ForwardedRef<HTMLDivElement>,\n cssParserRef,\n ) as ModelElementRef\n\n const rootSpatialReactContextObject = useContext(SpatialReactContext)!\n\n useEffect(() => {\n const onSubEvent = (dom: HTMLDivElement | null) => {\n cssParserRef.current = dom\n }\n rootSpatialReactContextObject.onSubDivEvent(spatialId, onSubEvent)\n\n return () => {\n rootSpatialReactContextObject.offSubDivEvent(spatialId)\n }\n }, [])\n\n return <Model3D style={style} {...props} ref={ref} visible={true} />\n}\n","import React, { useContext, useEffect } from 'react'\nimport { CSSModel3DProps } from './types'\nimport { Model3D } from './Model3D'\nimport { CSSProperties } from 'react'\nimport { SpatialReactContext } from '../SpatialReactComponent/SpatialReactContext'\nimport { useSpatialStyle } from '../CSSSpatialDiv/useSpatialStyle'\n\nexport function renderCSSModel3DPortalInstance(\n spatialId: string,\n inProps: CSSModel3DProps,\n) {\n const { className, style = {}, ...props } = inProps\n\n const rootSpatialReactContextObject = useContext(SpatialReactContext)!\n\n const { ref, spatialStyle, ready } = useSpatialStyle()\n\n const spatialTransform = {\n position: spatialStyle.position,\n rotation: spatialStyle.rotation,\n scale: spatialStyle.scale,\n }\n const visible = spatialStyle.visible\n\n useEffect(() => {\n rootSpatialReactContextObject.notifySubDivEvent(spatialId, ref.current)\n }, [ref.current])\n\n const cssParserDomStyle: CSSProperties = {\n ...style,\n width: 0,\n height: 0,\n padding: 0,\n position: 'absolute',\n }\n\n const model3DStyle: CSSProperties = {\n ...style,\n transform: spatialStyle.transformExist ? 'translateZ(0)' : 'none',\n }\n\n return (\n <>\n {ready && (\n <Model3D\n className={className}\n style={model3DStyle}\n spatialTransform={spatialTransform}\n visible={visible}\n {...props}\n />\n )}\n <div className={className} style={cssParserDomStyle} ref={ref} />\n </>\n )\n}\n","import type { WindowContainerOptions } from '@webspatial/core-sdk'\n\nexport function initScene(\n name: string,\n callback: (pre: WindowContainerOptions) => WindowContainerOptions,\n) {\n return\n}\n","//@ts-ignore\nimport { getSession } from '@webspatial/react-sdk'\n//@ts-ignore\nimport { defaultSceneConfig, XRApp } from '@webspatial/react-sdk'\n\nexport async function injectSceneHook() {\n if (!window.opener) return\n if ((window as any)._SceneHookOff) return\n\n await getSession()?.setLoading('show')\n // see this flag, we have done create the root scene\n\n function onContentLoaded(callback: any) {\n if (\n document.readyState === 'interactive' ||\n document.readyState === 'complete'\n ) {\n callback()\n } else {\n document.addEventListener('DOMContentLoaded', callback)\n }\n }\n\n onContentLoaded(async () => {\n let cfg = defaultSceneConfig\n if (typeof (window as any).xrCurrentSceneDefaults === 'function') {\n try {\n cfg = await (window as any).xrCurrentSceneDefaults?.()\n } catch (error) {\n console.error(error)\n }\n }\n // fixme: this duration is too short so that hide and show is at racing, so add a little delay to avoid\n await new Promise((resolve, reject) => {\n setTimeout(() => {\n resolve(null)\n }, 1000)\n })\n await getSession()?.setLoading('hide')\n await XRApp.getInstance().show(window, cfg)\n })\n}\n","//@ts-ignore\nimport { parseCornerRadius, getSession, XRApp } from '@webspatial/react-sdk'\nimport { injectSceneHook } from './injectSceneHook'\n\nconst isWebSpatialEnv = getSession() !== null\n\nconst SpatialGlobalCustomVars = {\n backgroundMaterial: '--xr-background-material',\n}\n\n// keep track of current html background material\nlet htmlBackgroundMaterial = ''\nfunction setCurrentWindowStyle(backgroundMaterial: string) {\n if (backgroundMaterial !== htmlBackgroundMaterial) {\n const session = getSession()!\n session.getCurrentWindowComponent().setStyle({\n material: { type: backgroundMaterial as any },\n })\n htmlBackgroundMaterial = backgroundMaterial\n }\n}\n\nfunction checkHtmlBackgroundMaterial() {\n const computedStyle = getComputedStyle(document.documentElement)\n\n const backgroundMaterial = computedStyle.getPropertyValue(\n SpatialGlobalCustomVars.backgroundMaterial,\n )\n\n setCurrentWindowStyle(backgroundMaterial || 'none')\n}\n\n// keep track of current corner radius\nlet htmlCornerRadius = {\n topLeading: 0,\n bottomLeading: 0,\n topTrailing: 0,\n bottomTrailing: 0,\n}\nfunction checkCornerRadius() {\n const computedStyle = getComputedStyle(document.documentElement)\n const cornerRadius = parseCornerRadius(computedStyle)\n setCornerRadius(cornerRadius)\n}\n\nfunction setCornerRadius(cornerRadius: any) {\n if (\n htmlCornerRadius.topLeading !== cornerRadius.topLeading ||\n htmlCornerRadius.bottomLeading !== cornerRadius.bottomLeading ||\n htmlCornerRadius.topTrailing !== cornerRadius.topTrailing ||\n htmlCornerRadius.bottomTrailing !== cornerRadius.bottomTrailing\n ) {\n const session = getSession()!\n if (!session) return\n session.getCurrentWindowComponent().setStyle({\n cornerRadius,\n })\n htmlCornerRadius.topLeading = cornerRadius.topLeading\n htmlCornerRadius.bottomLeading = cornerRadius.bottomLeading\n htmlCornerRadius.topTrailing = cornerRadius.topTrailing\n htmlCornerRadius.bottomTrailing = cornerRadius.bottomTrailing\n }\n}\n\nfunction setOpacity(opacity: number) {\n const session = getSession()!\n if (!session) return\n session.getCurrentWindowComponent().setOpacity(opacity)\n}\n\nfunction checkOpacity() {\n const computedStyle = getComputedStyle(document.documentElement)\n const opacity = parseFloat(computedStyle.getPropertyValue('opacity'))\n setOpacity(opacity)\n}\n\nasync function setHtmlVisible(visible: boolean) {\n const session = getSession()!\n if (!session) return\n const wc = session.getCurrentWindowComponent()\n const ent = await wc.getEntity()\n ent?.setVisible(visible)\n}\n\nfunction checkHtmlVisible() {\n const computedStyle = getComputedStyle(document.documentElement)\n const visibility = computedStyle.getPropertyValue('visibility') !== 'hidden'\n const widthGtZero = parseFloat(computedStyle.getPropertyValue('width')) > 0\n setHtmlVisible(visibility && widthGtZero)\n}\n\nfunction hijackDocumentElementStyle() {\n const rawDocumentStyle = document.documentElement.style\n const styleProxy = new Proxy(rawDocumentStyle, {\n set: function (target, key, value) {\n const ret = Reflect.set(target, key, value)\n\n if (key === SpatialGlobalCustomVars.backgroundMaterial) {\n setCurrentWindowStyle(value)\n }\n\n if (\n key === 'border-radius' ||\n key === 'borderRadius' ||\n key === 'border-top-left-radius' ||\n key === 'borderTopLeftRadius' ||\n key === 'border-top-right-radius' ||\n key === 'borderTopRightRadius' ||\n key === 'border-bottom-left-radius' ||\n key === 'borderBottomLeftRadius' ||\n key === 'border-bottom-right-radius' ||\n key === 'borderBottomRightRadius'\n ) {\n checkCornerRadius()\n }\n\n if (key === 'opacity') {\n checkOpacity()\n }\n\n if (key === 'visibility' || key === 'display') {\n checkHtmlVisible()\n }\n\n return ret\n },\n get: function (target, prop: string) {\n if (typeof target[prop as keyof CSSStyleDeclaration] === 'function') {\n return function (this: any, ...args: any[]) {\n if (prop === 'setProperty') {\n const [property, value] = args\n if (property === SpatialGlobalCustomVars.backgroundMaterial) {\n setCurrentWindowStyle(value)\n }\n } else if (prop === 'removeProperty') {\n const [property] = args\n if (property === SpatialGlobalCustomVars.backgroundMaterial) {\n setCurrentWindowStyle('none')\n }\n }\n return (target[prop as keyof CSSStyleDeclaration] as Function)(\n ...args,\n )\n }\n }\n return Reflect.get(target, prop)\n },\n })\n Object.defineProperty(document.documentElement, 'style', {\n get: function () {\n return styleProxy\n },\n })\n}\n\nfunction monitorExternalStyleChange() {\n const headObserver = new MutationObserver(function (mutationsList) {\n checkCSSProperties()\n })\n\n headObserver.observe(document.head, { childList: true, subtree: true })\n}\n\nfunction checkCSSProperties() {\n checkHtmlBackgroundMaterial()\n checkCornerRadius()\n checkOpacity()\n checkHtmlVisible()\n window.addEventListener('resize', checkHtmlVisible)\n}\n\nfunction hijackGetComputedStyle() {\n const rawFn = window.getComputedStyle.bind(window)\n window.getComputedStyle = (element, pseudoElt) => {\n if ((element as any).__isSpatialDiv) {\n return (element as any).__getComputedStyle(rawFn, pseudoElt)\n }\n return rawFn(element, pseudoElt)\n }\n}\n\nfunction hijackWindowOpen() {\n XRApp.getInstance().init()\n}\n\nfunction monitorHTMLAttributeChange() {\n const observer = new MutationObserver(mutations => {\n mutations.forEach(mutation => {\n if (mutation.type === 'attributes' && mutation.attributeName) {\n checkCSSProperties()\n }\n })\n })\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['style', 'class'],\n })\n}\n\nexport function spatialPolyfill() {\n if (!isWebSpatialEnv) {\n return\n }\n\n injectSceneHook()\n hijackWindowOpen()\n checkCSSProperties()\n hijackGetComputedStyle()\n hijackDocumentElementStyle()\n monitorExternalStyleChange()\n monitorHTMLAttributeChange()\n}\n","export * from './spatial-react-components'\nexport * from './utils'\nexport * from './XRApp'\nexport * from './initScene'\nexport * from './polyfill'\nexport const version = __WEBSPATIAL_REACT_SDK_VERSION__\n"],"mappings":";;;;;;;;;;AAAA,SAAS,cAAAA,mBAAuB;;;ACCzB,IAAM,aAA2B;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;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AAe,SAAS,iBAAiB,SAAS;AAAA,IACvD,KAAK,WAAY;AACf,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;AAEA,SAAS,6BAA6B;AACpC,QAAM,eAAe,IAAI,iBAAiB,SAAU,eAAe;AACjE,uBAAmB;AAAA,EACrB,CAAC;AAED,eAAa,QAAQ,SAAS,MAAM,EAAE,WAAW,MAAM,SAAS,KAAK,CAAC;AACxE;AAEA,SAAS,qBAAqB;AAC5B,8BAA4B;AAC5B,oBAAkB;AAClB,eAAa;AACb,mBAAiB;AACjB,SAAO,iBAAiB,UAAU,gBAAgB;AACpD;AAEA,SAAS,yBAAyB;AAChC,QAAM,QAAQ,OAAO,iBAAiB,KAAK,MAAM;AACjD,SAAO,mBAAmB,CAAC,SAAS,cAAc;AAChD,QAAK,QAAgB,gBAAgB;AACnC,aAAQ,QAAgB,mBAAmB,OAAO,SAAS;AAAA,IAC7D;AACA,WAAO,MAAM,SAAS,SAAS;AAAA,EACjC;AACF;AAEA,SAAS,mBAAmB;AAC1B,QAAM,YAAY,EAAE,KAAK;AAC3B;AAEA,SAAS,6BAA6B;AACpC,QAAM,WAAW,IAAI,iBAAiB,eAAa;AACjD,cAAU,QAAQ,cAAY;AAC5B,UAAI,SAAS,SAAS,gBAAgB,SAAS,eAAe;AAC5D,2BAAmB;AAAA,MACrB;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,WAAS,QAAQ,SAAS,iBAAiB;AAAA,IACzC,YAAY;AAAA,IACZ,iBAAiB,CAAC,SAAS,OAAO;AAAA,EACpC,CAAC;AACH;AAEO,SAAS,kBAAkB;AAChC,MAAI,CAAC,iBAAiB;AACpB;AAAA,EACF;AAEA,kBAAgB;AAChB,mBAAiB;AACjB,qBAAmB;AACnB,yBAAuB;AACvB,6BAA2B;AAC3B,6BAA2B;AAC3B,6BAA2B;AAC7B;;;AC/MO,IAAM,UAAU;","names":["forwardRef","forwardRef","useMemo","useContext","createContext","createContext","useRef","useEffect","useState","useContext","useContext","useRef","useEffect","createContext","useContext","useRef","useEffect","createContext","window","jsx","useEffect","useState","useRef","useContext","domRect","spatialWindowManager","createContext","jsx","jsxs","useMemo","useContext","isWebSpatialEnv","forwardRef","jsx","forwardRef","SpatialPrimitive","forwardRef","useRef","useEffect","useMemo","useRef","useEffect","useMemo","useEffect","useEffect","forwardRef","jsx","jsx","forwardRef","forwardRef","forwardRef","useContext","useEffect","useMemo","useRef","useCallback","useEffect","useRef","useState","useRef","useState","useCallback","useEffect","spatialStyle","createContext","useCallback","useCallback","createContext","createContext","jsx","jsxs","useMemo","useRef","useEffect","useContext","forwardRef","jsx","forwardRef","createSpatialPrimitive","CSSSpatialPrimitive","useRef","forwardRef","useEffect","jsx","forwardRef","useRef","useEffect","forwardRef","useMemo","useRef","useEffect","useState","forwardRef","useContext","useMemo","useRef","useEffect","useRef","useEffect","useState","useRef","useState","useEffect","useCallback","useEffect","useMemo","jsx","useCallback","useEffect","useMemo","jsx","useCallback","useContext","useEffect","useMemo","useRef","useEffect","useState","useContext","useState","useRef","useContext","useEffect","domRect","Fragment","jsx","useCallback","useMemo","useContext","useEffect","_","useContext","useMemo","forwardRef","forwardRef","useContext","useMemo","Fragment","jsx","jsxs","useContext","useEffect","useRef","jsx","useRef","useContext","useEffect","useContext","useEffect","Fragment","jsx","jsxs","useContext","useEffect","useContext","useMemo","forwardRef","Fragment","jsx","jsxs","useMemo","useState","useEffect","props","useRef","forwardRef"]}