@webspatial/core-sdk 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -1
- package/dist/iife/index.d.ts +171 -12
- package/dist/iife/index.global.js +11 -11
- package/dist/iife/index.global.js.map +1 -1
- package/dist/index.d.ts +171 -12
- package/dist/index.js +460 -114
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/JSBCommand.ts +40 -2
- package/src/Spatial.ts +1 -1
- package/src/SpatialSession.ts +4 -2
- package/src/SpatializedElement.ts +10 -10
- package/src/SpatializedElementCreator.ts +5 -2
- package/src/SpatializedStatic3DElement.test.ts +15 -1
- package/src/SpatializedStatic3DElement.ts +167 -8
- package/src/WebMsgCommand.ts +22 -0
- package/src/platform-adapter/index.ts +2 -2
- package/src/platform-adapter/{xr/XRPlatform.ts → pico-os/PicoOSPlatform.ts} +5 -7
- package/src/reality/entity/SpatialEntity.ts +4 -0
- package/src/reality/entity/SpatialModelEntity.ts +6 -0
- package/src/scene-polyfill.manifest.test.ts +402 -0
- package/src/scene-polyfill.test.ts +108 -18
- package/src/scene-polyfill.ts +284 -26
- package/src/types/global.d.ts +8 -0
- package/src/types/types.ts +71 -0
- package/src/utils.ts +21 -0
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ssr-polyfill.ts","../src/platform-adapter/ssr/SSRPlatform.ts","../src/platform-adapter/CommandResultUtils.ts","../src/platform-adapter/puppeteer/PuppeteerPlatform.ts","../src/SpatialWebEvent.ts","../src/platform-adapter/xr/XRPlatform.ts","../src/platform-adapter/android/AndroidPlatform.ts","../src/platform-adapter/vision-os/VisionOSPlatform.ts","../src/platform-adapter/index.ts","../src/utils.ts","../src/JSBCommand.ts","../src/SpatialObject.ts","../src/scene-polyfill.ts","../src/SpatialScene.ts","../src/types/types.ts","../src/SpatializedElementCreator.ts","../src/Spatialized2DElement.ts","../src/SpatializedElement.ts","../src/SpatialWebEventCreator.ts","../src/SpatializedStatic3DElement.ts","../src/SpatializedDynamic3DElement.ts","../src/reality/Attachment.ts","../src/reality/realityCreator.ts","../src/reality/entity/SpatialEntity.ts","../src/reality/entity/SpatialModelEntity.ts","../src/reality/component/SpatialComponent.ts","../src/reality/component/ModelComponent.ts","../src/reality/material/SpatialUnlitMaterial.ts","../src/reality/material/SpatialMaterial.ts","../src/reality/resource/SpatialModelAsset.ts","../src/reality/geometry/SpatialGeometry.ts","../src/reality/geometry/SpatialBoxGeometry.ts","../src/reality/geometry/SpatialSphereGeometry.ts","../src/reality/geometry/SpatialCylinderGeometry.ts","../src/reality/geometry/SpatialPlaneGeometry.ts","../src/reality/geometry/SpatialConeGeometry.ts","../src/SpatialSession.ts","../src/Spatial.ts","../src/physicalMetrics.ts","../src/index.ts","../src/spatial-window-polyfill.ts"],"sourcesContent":["const isSSR = typeof window === 'undefined'\n\nexport const isSSREnv = () => isSSR\n","import {\n CommandResult,\n PlatformAbility,\n WebSpatialProtocolResult,\n} from '../interface'\n\nexport class SSRPlatform implements PlatformAbility {\n callJSB(cmd: string, msg: string): Promise<CommandResult> {\n return Promise.resolve({\n success: true,\n data: undefined,\n errorCode: undefined,\n errorMessage: undefined,\n })\n }\n callWebSpatialProtocol(\n schema: string,\n query?: string,\n target?: string,\n features?: string,\n ): Promise<WebSpatialProtocolResult> {\n return Promise.resolve({\n success: true,\n data: undefined,\n errorCode: undefined,\n errorMessage: undefined,\n })\n }\n callWebSpatialProtocolSync(\n schema: string,\n query?: string,\n target?: string,\n features?: string,\n resultCallback?: (result: CommandResult) => void,\n ): WebSpatialProtocolResult {\n return {\n success: true,\n data: undefined,\n errorCode: undefined,\n errorMessage: undefined,\n }\n }\n}\n","import { CommandResult } from './interface'\n\nexport function CommandResultSuccess(data: any): CommandResult {\n return {\n success: true,\n data,\n errorCode: '',\n errorMessage: '',\n }\n}\n\nexport function CommandResultFailure(\n errorCode: string,\n errorMessage = '',\n): CommandResult {\n return {\n success: false,\n data: undefined,\n errorCode,\n errorMessage,\n }\n}\n","import { PlatformAbility, CommandResult } from '../interface'\nimport {\n CommandResultFailure,\n CommandResultSuccess,\n} from '../CommandResultUtils'\n\n// add window interface for JSB call\ndeclare global {\n interface Window {\n __handleJSBMessage: (message: string) => any\n SpatialId?: string\n }\n\n interface HTMLIFrameElement {\n spatialId?: string\n webSpatialId?: string\n }\n}\n\ntype JSBError = {\n message: string\n}\n\nconsole.log('PuppeteerPlatform')\n\nexport class PuppeteerPlatform implements PlatformAbility {\n // store iframe instance\n private iframeRegistry: Map<string, HTMLIFrameElement> = new Map()\n\n constructor() {}\n\n callJSB(cmd: string, msg: string): Promise<CommandResult> {\n return new Promise(resolve => {\n try {\n // check __handleJSBMessage exist\n if (window.__handleJSBMessage) {\n try {\n console.log(` core-sdk Puppeteer Platform: callJSB: ${cmd}::${msg}`)\n const result = window.__handleJSBMessage(`${cmd}::${msg}`)\n console.log(\n ` core-sdk Puppeteer Platform callJSB result: ${result}`,\n )\n resolve(CommandResultSuccess(result))\n } catch (err) {\n resolve(CommandResultFailure('500', 'JSB execution error'))\n }\n } else {\n // if not exist, return default result\n resolve(CommandResultSuccess('ok'))\n }\n } catch (error: unknown) {\n console.error(\n `PuppeteerPlatform cmd Error: ${cmd}, msg: ${msg} error: ${error}`,\n )\n resolve(CommandResultFailure('500', 'Internal error'))\n }\n })\n }\n\n /**\n * Synchronously create Spatialized2DElement to Puppeteer Runner\n */\n private createSpatializedElementSync(\n spatialId: string,\n webspatialUrl: string,\n ): void {\n try {\n console.log(\n `[Puppeteer Platform] Creating spatialized element sync with id: ${spatialId}, url: ${webspatialUrl}`,\n )\n // directly call Puppeteer Runner method to create element\n const win = window as any\n if (win.__handleJSBMessage) {\n // use simpler format to ensure JSBManager can correctly use our passed spatialId\n const createCommand = {\n id: spatialId,\n url: webspatialUrl,\n }\n win.__handleJSBMessage(\n `CreateSpatialized2DElement::${JSON.stringify(createCommand)}`,\n )\n }\n } catch (error) {\n console.error('Error creating spatialized element sync:', error)\n }\n }\n\n callWebSpatialProtocol(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): Promise<CommandResult> {\n console.log(\n `PuppeteerPlatform: Calling webspatial protocol: webspatial://${command}${query ? `?${query}` : ''}`,\n )\n return new Promise(resolve => {\n try {\n // create complete webspatial URL\n const webspatialUrl = `webspatial://${command}${query ? `?${query}` : ''}`\n // use iframe to create new window\n const { spatialId, iframe, windowProxy } = this.createIframeWindow(\n webspatialUrl,\n target,\n features,\n )\n\n // 对于createSpatialized2DElement命令,同步创建元素\n if (command === 'createSpatialized2DElement') {\n this.createSpatializedElementSync(spatialId, webspatialUrl)\n }\n console.log(\n `[Puppeteer Platform] iframe created with spatialId: ${spatialId}`,\n )\n // store iframe instance\n this.iframeRegistry.set(spatialId, iframe)\n resolve(CommandResultSuccess({ windowProxy, id: spatialId }))\n } catch (error) {\n console.error('Error calling webspatial protocol:', error)\n resolve(\n CommandResultFailure('500', 'Failed to call webspatial protocol'),\n )\n }\n })\n }\n\n callWebSpatialProtocolSync(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): CommandResult {\n try {\n // create complete webspatial URL\n const webspatialUrl = `webspatial://${command}${query ? `?${query}` : ''}`\n console.log(`Calling webspatial protocol sync: ${webspatialUrl}`)\n\n // 使用iframe创建新窗口\n const { spatialId, iframe, windowProxy } = this.createIframeWindow(\n webspatialUrl,\n target,\n features,\n )\n\n // 对于createSpatialized2DElement命令,同步创建元素\n if (command === 'createSpatialized2DElement') {\n this.createSpatializedElementSync(spatialId, webspatialUrl)\n }\n\n // store iframe instance\n this.iframeRegistry.set(spatialId, iframe)\n\n return CommandResultSuccess({ windowProxy, id: spatialId })\n } catch (error) {\n console.error('Error calling webspatial protocol sync:', error)\n return CommandResultFailure(\n '500',\n 'Failed to call webspatial protocol sync',\n )\n }\n }\n\n /**\n * Synchronously create iframe-based window\n */\n private createIframeWindow(url: string, target?: string, features?: string) {\n // create iframe element\n const iframe = document.createElement('iframe')\n\n // set iframe attributes\n iframe.style.border = 'none'\n iframe.style.display = 'none'\n iframe.style.width = '100%'\n iframe.style.height = '100%'\n\n // set iframe id\n const spatialId = this.generateUUID()\n iframe.spatialId = spatialId\n iframe.id = `spatial-iframe-${spatialId}`\n\n // parse features parameter\n const featuresObj = this.parseFeatures(features || '')\n\n // set iframe styles based on features\n if (featuresObj.width) {\n iframe.style.width = featuresObj.width\n }\n if (featuresObj.height) {\n iframe.style.height = featuresObj.height\n }\n if (featuresObj.left) {\n iframe.style.left = featuresObj.left\n iframe.style.position = 'absolute'\n }\n if (featuresObj.top) {\n iframe.style.top = featuresObj.top\n iframe.style.position = 'absolute'\n }\n\n // add iframe to DOM\n document.body.appendChild(iframe)\n\n // create enhanced windowProxy object\n const windowProxy = this.createEnhancedWindowProxy(iframe, url, spatialId)\n\n // set iframe src\n iframe.src = 'about:blank'\n\n console.log(\n `PuppeteerPlatform created iframe window with spatialId: ${spatialId}, URL: ${url}`,\n )\n\n // initialize iframe content\n this.initializeIframeContent(iframe, url, spatialId)\n\n return { spatialId, iframe, windowProxy }\n }\n\n /**\n * create enhanced windowProxy object\n */\n private createEnhancedWindowProxy(\n iframe: HTMLIFrameElement,\n url: string,\n spatialId: string,\n ) {\n // create enhanced windowProxy object\n return {\n // basic properties\n location: {\n href: url,\n toString: () => url,\n reload: () => {\n if (iframe.contentWindow) {\n iframe.contentWindow.location.reload()\n }\n },\n },\n navigator: {\n userAgent: `Mozilla/5.0 (WebKit) SpatialId/${spatialId}`,\n },\n\n // methods\n close: () => {\n console.log(`Closing iframe with spatialId: ${spatialId}`)\n iframe.remove()\n this.iframeRegistry.delete(spatialId)\n },\n\n // document access\n document: iframe.contentDocument || ({} as Document),\n contentWindow: iframe.contentWindow || ({} as Window),\n\n // add message communication method\n postMessage: (message: any, targetOrigin?: string) => {\n if (iframe.contentWindow) {\n iframe.contentWindow.postMessage(message, targetOrigin || '*')\n }\n },\n\n // add event listener method\n addEventListener: (\n type: string,\n listener: EventListenerOrEventListenerObject,\n ) => {\n if (iframe.contentWindow) {\n iframe.contentWindow.addEventListener(type, listener)\n }\n },\n\n removeEventListener: (\n type: string,\n listener: EventListenerOrEventListenerObject,\n ) => {\n if (iframe.contentWindow) {\n iframe.contentWindow.removeEventListener(type, listener)\n }\n },\n\n // execute JavaScript\n executeScript: (code: string): any => {\n if (iframe.contentWindow) {\n try {\n // use type assertion and safer way to execute script\n const win = iframe.contentWindow as any\n return win.eval(code)\n } catch (error) {\n console.error(\n `Error executing script in iframe ${spatialId}:`,\n error,\n )\n return null\n }\n }\n return null\n },\n\n // get iframe reference\n getIframe: () => iframe,\n\n // get spatialId\n getSpatialId: () => spatialId,\n }\n }\n\n /**\n * initialize iframe content\n */\n private initializeIframeContent(\n iframe: HTMLIFrameElement,\n url: string,\n spatialId: string,\n ): void {\n try {\n // wait for iframe to load\n iframe.onload = () => {\n try {\n // set iframe content\n const iframeContent = `\n // inject communication script\n window.webSpatialId = '${spatialId}';\n window.SpatialId = '${spatialId}';\n \n // override window.open to support webspatial protocol\n const originalOpen = window.open;\n window.open = function(url, target, features) {\n if (url && url.startsWith('webspatial://')) {\n // handle webspatial protocol through windowProxy\n const windowProxy = new Proxy({}, {\n get: function(target, prop) {\n if (prop === 'toString') {\n return function() { return url; };\n }\n return undefined;\n }\n });\n return windowProxy;\n }\n return originalOpen.call(window, url, target, features);\n };\n \n // set navigator.userAgent to identify webspatial environment\n Object.defineProperty(navigator, 'userAgent', {\n value: 'WebSpatial/1.0 ' + navigator.userAgent,\n configurable: true\n });\n \n // send loaded message\n window.parent.postMessage({\n type: 'iframe_loaded',\n spatialId: '${spatialId}',\n url: '${url}'\n }, '${window.location.origin}');\n \n // set message handler\n window.addEventListener('message', (event) => {\n if (event.origin !== window.parent.location.origin) return;\n \n const data = event.data;\n if (data && data.type === 'webspatial_command') {\n // handle command from parent window\n console.log('Received command in iframe from parent:', data.command);\n // add command handling logic here\n }\n });\n `\n\n // use document.write instead of eval for security and type compliance\n const doc = iframe.contentDocument\n if (doc) {\n doc.open()\n doc.write(`\n <!DOCTYPE html>\n <html>\n <head>\n <title>Spatial Iframe - ${spatialId}</title>\n <meta charset=\"UTF-8\">\n <style>\n body {\n margin: 0;\n padding: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n </style>\n </head>\n <body>\n <script>${iframeContent}</script>\n </body>\n </html>\n `)\n doc.close()\n }\n } catch (error) {\n console.error('Error initializing iframe content:', error)\n }\n }\n } catch (error) {\n console.error('Error setting up iframe:', error)\n }\n }\n\n /**\n * parse features string to object\n */\n private parseFeatures(features: string): Record<string, string> {\n const result: Record<string, string> = {}\n const pairs = features.split(',')\n\n pairs.forEach(pair => {\n const [key, value] = pair.split('=').map(s => s.trim())\n if (key && value) {\n result[key] = value\n }\n })\n\n return result\n }\n\n /**\n * send message to iframe with specified spatialId\n */\n public sendMessageToIframe(spatialId: string, message: any): boolean {\n const iframe = this.iframeRegistry.get(spatialId)\n if (iframe && iframe.contentWindow) {\n iframe.contentWindow.postMessage(message, window.location.origin)\n return true\n }\n return false\n }\n\n /**\n * get all active iframes\n */\n public getAllActiveIframes(): Array<{\n spatialId: string\n iframe: HTMLIFrameElement\n }> {\n const result: Array<{ spatialId: string; iframe: HTMLIFrameElement }> = []\n\n this.iframeRegistry.forEach((iframe, spatialId) => {\n result.push({ spatialId, iframe })\n })\n\n return result\n }\n\n /**\n * dispose all active iframes\n */\n public dispose(): void {\n // close all iframes\n this.iframeRegistry.forEach((iframe, spatialId) => {\n console.log(`Disposing iframe with spatialId: ${spatialId}`)\n iframe.remove()\n })\n this.iframeRegistry.clear()\n }\n\n // generate UUID function\n private generateUUID(): string {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(\n /[xy]/g,\n function (c) {\n const r = (Math.random() * 16) | 0\n const v = c === 'x' ? r : (r & 0x3) | 0x8\n return v.toString(16).toUpperCase()\n },\n )\n }\n}\n","interface SpatialWebEventData {\n id: string\n data: any\n}\n\nexport class SpatialWebEvent {\n static eventReceiver: Record<string, (data: any) => void> = {}\n static init() {\n // inject __SpatialWebEvent\n window.__SpatialWebEvent = ({ id, data }: SpatialWebEventData) => {\n // console.log('__SpatialWebEvent', id, data)\n SpatialWebEvent.eventReceiver[id]?.(data)\n }\n }\n\n static addEventReceiver(id: string, callback: (data: any) => void) {\n SpatialWebEvent.eventReceiver[id] = callback\n }\n\n static removeEventReceiver(id: string) {\n delete SpatialWebEvent.eventReceiver[id]\n }\n}\n","import { PlatformAbility, CommandResult } from '../interface'\nimport {\n CommandResultFailure,\n CommandResultSuccess,\n} from '../CommandResultUtils'\nimport { SpatialWebEvent } from '../../SpatialWebEvent'\n\ninterface JSBResponse {\n success: boolean\n data: any\n}\ntype JSBError = {\n code: string\n message: string\n}\n\nlet requestId = 0\n\nconst MAX_ID = 100000\n\nfunction nextRequestId() {\n requestId = (requestId + 1) % MAX_ID\n return `rId_${requestId}`\n}\n\nexport class XRPlatform implements PlatformAbility {\n async callJSB(cmd: string, msg: string): Promise<CommandResult> {\n // android JS Bridge interface only support sync invoking\n // in order to implement promise API, register every request by requestId and remove when resolve/reject.\n return new Promise((resolve, reject) => {\n try {\n const rId = nextRequestId()\n\n SpatialWebEvent.addEventReceiver(rId, (result: JSBResponse) => {\n SpatialWebEvent.removeEventReceiver(rId)\n if (result.success) {\n resolve(CommandResultSuccess(result.data))\n } else {\n const { code, message } = result.data as JSBError\n resolve(CommandResultFailure(code, message))\n }\n })\n\n const ans = window.webspatialBridge.postMessage(rId, cmd, msg)\n if (ans !== '') {\n SpatialWebEvent.removeEventReceiver(rId)\n // sync call\n const result = JSON.parse(ans) as JSBResponse\n if (result.success) {\n resolve(CommandResultSuccess(result.data))\n } else {\n const { code, message } = result.data as JSBError\n resolve(CommandResultFailure(code, message))\n }\n }\n } catch (error: unknown) {\n console.error(`XRPlatform cmd: ${cmd}, msg: ${msg} error: ${error}`)\n const { code, message } = error as JSBError\n resolve(CommandResultFailure(code, message))\n }\n })\n }\n\n async callWebSpatialProtocol(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): Promise<CommandResult> {\n // Waiting for request to create spatial div\n return new Promise((resolve, reject) => {\n const createdId = nextRequestId()\n try {\n let windowProxy: any = null\n SpatialWebEvent.addEventReceiver(\n createdId,\n (result: { spatialId: string }) => {\n console.log('createdId', createdId, result.spatialId)\n resolve(\n CommandResultSuccess({\n windowProxy: windowProxy,\n id: result.spatialId,\n }),\n )\n SpatialWebEvent.removeEventReceiver(createdId)\n },\n )\n windowProxy = this.openWindow(\n command,\n query,\n target,\n features,\n ).windowProxy\n windowProxy?.open(`about:blank?rid=${createdId}`, '_self')\n } catch (error: unknown) {\n console.error(`open window error: ${error}`)\n const { code, message } = error as JSBError\n SpatialWebEvent.removeEventReceiver(createdId)\n resolve(CommandResultFailure(code, message))\n }\n })\n }\n\n callWebSpatialProtocolSync(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): CommandResult {\n const { spatialId: id = '', windowProxy } = this.openWindow(\n command,\n query,\n target,\n features,\n )\n\n return CommandResultSuccess({ windowProxy, id })\n }\n\n private openWindow(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ) {\n const windowProxy = window.open(\n `webspatial://${command}?${query || ''}`,\n target,\n features,\n )\n return { spatialId: '', windowProxy }\n }\n}\n","import { PlatformAbility, CommandResult } from '../interface'\nimport {\n CommandResultFailure,\n CommandResultSuccess,\n} from '../CommandResultUtils'\nimport { CheckWebViewCanCreateCommand } from '../../JSBCommand'\nimport { SpatialWebEvent } from '../../SpatialWebEvent'\n\ninterface JSBResponse {\n success: boolean\n data: any\n}\ntype JSBError = {\n code: string\n message: string\n}\n\nlet creatingElementCount = 0\n\nlet requestId = 0\n\nconst MAX_ID = 100000\n\nfunction nextRequestId() {\n requestId = (requestId + 1) % MAX_ID\n return `rId_${requestId}`\n}\n\nexport class AndroidPlatform implements PlatformAbility {\n async callJSB(cmd: string, msg: string): Promise<CommandResult> {\n // android JS Bridge interface only support sync invoking\n // in order to implement promise API, register every request by requestId and remove when resolve/reject.\n return new Promise((resolve, reject) => {\n try {\n const rId = nextRequestId()\n\n SpatialWebEvent.addEventReceiver(rId, (result: JSBResponse) => {\n SpatialWebEvent.removeEventReceiver(rId)\n if (result.success) {\n resolve(CommandResultSuccess(result.data))\n } else {\n const { code, message } = result.data as JSBError\n resolve(CommandResultFailure(code, message))\n }\n })\n\n const ans = window.webspatialBridge.postMessage(rId, cmd, msg)\n if (ans !== '') {\n SpatialWebEvent.removeEventReceiver(rId)\n // sync call\n const result = JSON.parse(ans) as JSBResponse\n if (result.success) {\n resolve(CommandResultSuccess(result.data))\n } else {\n const { code, message } = result.data as JSBError\n resolve(CommandResultFailure(code, message))\n }\n }\n } catch (error: unknown) {\n console.error(\n `AndroidPlatform cmd: ${cmd}, msg: ${msg} error: ${error}`,\n )\n const { code, message } = error as JSBError\n resolve(CommandResultFailure(code, message))\n }\n })\n }\n\n async callWebSpatialProtocol(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): Promise<CommandResult> {\n // Waiting for request to create spatial div\n await new Promise(resolve => setTimeout(resolve, 16 * creatingElementCount))\n // Count the current total number of created spatial div queues\n creatingElementCount++\n // Create a spatial div through JSB polling request\n let canCreate = await new CheckWebViewCanCreateCommand().execute()\n while (!canCreate.data.can) {\n await new Promise(resolve => setTimeout(resolve, 16))\n canCreate = await new CheckWebViewCanCreateCommand().execute()\n }\n // Request successful, call window.open\n const { windowProxy } = this.openWindow(command, query, target, features)\n // Polling waiting for windowProxy to convert into a real window object\n while (!windowProxy?.open) {\n await new Promise(resolve => setTimeout(resolve, 16))\n }\n // Make the page renderable through window.open\n windowProxy?.open('about:blank', '_self')\n // Polling to check if SpatialId injection is successful\n while (!windowProxy?.__SpatialId) {\n await new Promise(resolve => setTimeout(resolve, 16))\n }\n let spatialId = windowProxy?.__SpatialId\n creatingElementCount--\n return Promise.resolve(\n CommandResultSuccess({ windowProxy: windowProxy, id: spatialId }),\n )\n }\n\n callWebSpatialProtocolSync(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): CommandResult {\n const { spatialId: id = '', windowProxy } = this.openWindow(\n command,\n query,\n target,\n features,\n )\n\n return CommandResultSuccess({ windowProxy, id })\n }\n\n private openWindow(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ) {\n const windowProxy = window.open(\n `webspatial://${command}?${query || ''}`,\n target,\n features,\n )\n return { spatialId: '', windowProxy }\n }\n}\n","import { PlatformAbility, CommandResult } from '../interface'\nimport {\n CommandResultFailure,\n CommandResultSuccess,\n} from '../CommandResultUtils'\n\ntype JSBError = {\n message: string\n}\n\nexport class VisionOSPlatform implements PlatformAbility {\n async callJSB(cmd: string, msg: string): Promise<CommandResult> {\n try {\n const result = await window.webkit.messageHandlers.bridge.postMessage(\n `${cmd}::${msg}`,\n )\n return CommandResultSuccess(result)\n } catch (error: unknown) {\n // console.error(`VisionOSPlatform cmd: ${cmd}, msg: ${msg} error: ${error}`)\n const { code, message } = JSON.parse((error as JSBError).message)\n return CommandResultFailure(code, message)\n }\n }\n\n callWebSpatialProtocol(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): Promise<CommandResult> {\n const { spatialId: id, windowProxy } = this.openWindow(\n command,\n query,\n target,\n features,\n )\n return Promise.resolve(\n CommandResultSuccess({ windowProxy: windowProxy, id }),\n )\n }\n\n callWebSpatialProtocolSync(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): CommandResult {\n const { spatialId: id = '', windowProxy } = this.openWindow(\n command,\n query,\n target,\n features,\n )\n\n return CommandResultSuccess({ windowProxy, id })\n }\n\n private openWindow(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ) {\n const windowProxy = window.open(\n `webspatial://${command}?${query || ''}`,\n target,\n features,\n )\n const ua = windowProxy?.navigator.userAgent\n const spatialId = ua?.match(\n /\\b([0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})\\b/gi,\n )?.[0]\n\n return { spatialId, windowProxy }\n }\n}\n","import { isSSREnv } from '../ssr-polyfill'\nimport { PlatformAbility } from './interface'\nimport { SSRPlatform } from './ssr/SSRPlatform'\n\nfunction getWebSpatialVersion(ua: string): number[] | null {\n const match = ua.match(/WebSpatial\\/(\\d+)\\.(\\d+)\\.(\\d+)/)\n if (!match) {\n return null\n }\n return [Number(match[1]), Number(match[2]), Number(match[3])]\n}\n\nfunction isVersionGreater(a: number[] | null, b: number[]): boolean {\n if (!a) {\n return false\n }\n for (let index = 0; index < 3; index += 1) {\n const diff = a[index] - b[index]\n if (diff > 0) {\n return true\n }\n if (diff < 0) {\n return false\n }\n }\n return false\n}\n\nexport function createPlatform(): PlatformAbility {\n if (isSSREnv()) {\n return new SSRPlatform()\n }\n const userAgent = window.navigator.userAgent\n const webSpatialVersion = getWebSpatialVersion(userAgent)\n if (window.navigator.userAgent.includes('Puppeteer')) {\n const PuppeteerPlatform =\n require('./puppeteer/PuppeteerPlatform').PuppeteerPlatform\n return new PuppeteerPlatform()\n } else if (\n userAgent.includes('PicoWebApp') &&\n isVersionGreater(webSpatialVersion, [0, 0, 1])\n ) {\n const XRPlatform = require('./xr/XRPlatform').XRPlatform\n return new XRPlatform()\n } else if (userAgent.includes('Android') || userAgent.includes('Linux')) {\n const AndroidPlatform = require('./android/AndroidPlatform').AndroidPlatform\n return new AndroidPlatform()\n } else {\n const VisionOSPlatform =\n require('./vision-os/VisionOSPlatform').VisionOSPlatform\n return new VisionOSPlatform()\n }\n}\n","import { Vec3 } from './types/types'\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\n/**\n *\n * compose SRT matrix\n * @export\n * @param {Vec3} position meter\n * @param {Vec3} rotation degree\n * @param {Vec3} scale\n * @return {*} {DOMMatrix}\n */\nexport function composeSRT(position: Vec3, rotation: Vec3, scale: Vec3) {\n const { x: px, y: py, z: pz } = position\n const { x: rx, y: ry, z: rz } = rotation\n const { x: sx, y: sy, z: sz } = scale\n\n let m = new DOMMatrix()\n // https://drafts.fxtf.org/geometry/#immutable-transformation-methods\n // as these methods are post-multiplication, the order of transformations is reversed\n // we want SRT = T * R * S\n m = m.translate(px, py, pz)\n m = m.rotate(rx, ry, rz)\n m = m.scale(sx, sy, sz)\n return m\n}\n","import { createPlatform } from './platform-adapter'\nimport { WebSpatialProtocolResult } from './platform-adapter/interface'\nimport { SpatialComponent } from './reality/component/SpatialComponent'\nimport { SpatialEntity } from './reality/entity/SpatialEntity'\nimport { SpatializedDynamic3DElement } from './SpatializedDynamic3DElement'\nimport { SpatializedElement } from './SpatializedElement'\nimport { SpatialObject } from './SpatialObject'\n\nimport {\n Spatialized2DElementProperties,\n SpatializedElementProperties,\n SpatializedStatic3DElementProperties,\n SpatialSceneProperties,\n SpatialSceneCreationOptions,\n SpatialUnlitMaterialOptions,\n SpatialGeometryOptions,\n SpatialGeometryType,\n ModelComponentOptions,\n SpatialEntityProperties,\n ModelAssetOptions,\n SpatialModelEntityCreationOptions,\n SpatialEntityEventType,\n Vec3,\n AttachmentEntityOptions,\n AttachmentEntityUpdateOptions,\n} from './types/types'\nimport { SpatialSceneCreationOptionsInternal } from './types/internal'\nimport { composeSRT } from './utils'\n\nconst platform = createPlatform()\n\nabstract class JSBCommand {\n commandType: string = ''\n protected abstract getParams(): Record<string, any> | undefined\n\n async execute() {\n const param = this.getParams()\n const msg = param ? JSON.stringify(param) : ''\n return platform.callJSB(this.commandType, msg)\n }\n}\n\nexport class UpdateEntityPropertiesCommand extends JSBCommand {\n commandType = 'UpdateEntityProperties'\n\n constructor(\n public entity: SpatialEntity,\n public properties: Partial<SpatialEntityProperties>,\n ) {\n super()\n }\n\n protected getParams() {\n const transform = composeSRT(\n this.properties.position ?? this.entity.position,\n this.properties.rotation ?? this.entity.rotation,\n this.properties.scale ?? this.entity.scale,\n ).toFloat64Array()\n return {\n entityId: this.entity.id,\n transform,\n }\n }\n}\n\nexport class UpdateEntityEventCommand extends JSBCommand {\n commandType = 'UpdateEntityEvent'\n\n constructor(\n public entity: SpatialEntity,\n public type: SpatialEntityEventType,\n public isEnable: boolean,\n ) {\n super()\n }\n\n protected getParams() {\n return {\n type: this.type,\n entityId: this.entity.id,\n isEnable: this.isEnable,\n }\n }\n}\n\n// todo: to be used in SpatialEntity\nexport class UpdateEntityEventsCommand extends JSBCommand {\n // let types:[String:Bool]\n // let entityId:String\n constructor(\n public entity: SpatialEntity,\n public types: Record<SpatialEntityEventType, boolean>,\n ) {\n super()\n }\n\n protected getParams() {\n return {\n entityId: this.entity.id,\n types: this.types,\n }\n }\n}\n\nexport class UpdateSpatialSceneProperties extends JSBCommand {\n properties: Partial<SpatialSceneProperties>\n commandType = 'UpdateSpatialSceneProperties'\n\n constructor(properties: Partial<SpatialSceneProperties>) {\n super()\n this.properties = properties\n }\n\n protected getParams() {\n return this.properties\n }\n}\n\nexport class UpdateSceneConfig extends JSBCommand {\n config: SpatialSceneCreationOptions\n commandType = 'UpdateSceneConfig'\n\n constructor(config: SpatialSceneCreationOptions) {\n super()\n this.config = config\n }\n\n protected getParams(): Record<string, any> | undefined {\n return { config: this.config }\n }\n}\n\nexport class FocusScene extends JSBCommand {\n commandType = 'FocusScene'\n\n constructor(public id: string) {\n super()\n }\n\n protected getParams(): Record<string, any> | undefined {\n return { id: this.id }\n }\n}\n\nexport class GetSpatialSceneState extends JSBCommand {\n commandType = 'GetSpatialSceneState'\n\n constructor() {\n super()\n }\n\n protected getParams(): Record<string, any> | undefined {\n return {}\n }\n}\n\nexport abstract class SpatializedElementCommand extends JSBCommand {\n constructor(readonly spatialObject: SpatialObject) {\n super()\n }\n\n protected getParams() {\n const extraParams = this.getExtraParams()\n return { id: this.spatialObject.id, ...extraParams }\n }\n\n protected abstract getExtraParams(): Record<string, any> | undefined\n}\n\nexport class UpdateSpatialized2DElementProperties extends SpatializedElementCommand {\n properties: Partial<Spatialized2DElementProperties>\n commandType = 'UpdateSpatialized2DElementProperties'\n\n constructor(\n spatialObject: SpatialObject,\n properties: Partial<SpatializedElementProperties>,\n ) {\n super(spatialObject)\n this.properties = properties\n }\n\n protected getExtraParams() {\n return this.properties\n }\n}\n\nexport class UpdateSpatializedDynamic3DElementProperties extends SpatializedElementCommand {\n properties: Partial<Spatialized2DElementProperties>\n commandType = 'UpdateSpatializedDynamic3DElementProperties'\n\n constructor(\n spatialObject: SpatialObject,\n properties: Partial<SpatializedElementProperties>,\n ) {\n super(spatialObject)\n this.properties = properties\n }\n\n protected getExtraParams() {\n return {\n id: this.spatialObject.id,\n ...this.properties,\n }\n }\n}\n\nexport class UpdateUnlitMaterialProperties extends SpatializedElementCommand {\n properties: Partial<SpatialUnlitMaterialOptions>\n commandType = 'UpdateUnlitMaterialProperties'\n\n constructor(\n spatialObject: SpatialObject,\n properties: Partial<SpatialUnlitMaterialOptions>,\n ) {\n super(spatialObject)\n this.properties = properties\n }\n\n protected getExtraParams() {\n return this.properties\n }\n}\n\nexport class UpdateSpatializedElementTransform extends SpatializedElementCommand {\n matrix: DOMMatrix\n commandType = 'UpdateSpatializedElementTransform'\n\n constructor(spatialObject: SpatialObject, matrix: DOMMatrix) {\n super(spatialObject)\n this.matrix = matrix\n }\n\n protected getExtraParams() {\n return { matrix: Array.from(this.matrix.toFloat64Array()) }\n }\n}\n\nexport class UpdateSpatializedStatic3DElementProperties extends SpatializedElementCommand {\n properties: Partial<SpatializedStatic3DElementProperties>\n commandType = 'UpdateSpatializedStatic3DElementProperties'\n\n constructor(\n spatialObject: SpatialObject,\n properties: Partial<SpatializedStatic3DElementProperties>,\n ) {\n super(spatialObject)\n this.properties = properties\n }\n\n protected getExtraParams() {\n return this.properties\n }\n}\n\nexport class AddSpatializedElementToSpatialized2DElement extends SpatializedElementCommand {\n commandType = 'AddSpatializedElementToSpatialized2DElement'\n spatializedElement: SpatializedElement\n\n constructor(\n spatialObject: SpatialObject,\n spatializedElement: SpatializedElement,\n ) {\n super(spatialObject)\n this.spatializedElement = spatializedElement\n }\n\n protected getExtraParams() {\n return { spatializedElementId: this.spatializedElement.id }\n }\n}\n\nexport class AddSpatializedElementToSpatialScene extends JSBCommand {\n commandType = 'AddSpatializedElementToSpatialScene'\n spatializedElement: SpatializedElement\n\n constructor(spatializedElement: SpatializedElement) {\n super()\n this.spatializedElement = spatializedElement\n }\n\n protected getParams() {\n return {\n spatializedElementId: this.spatializedElement.id,\n }\n }\n}\n\nexport class CreateSpatializedStatic3DElementCommand extends JSBCommand {\n commandType = 'CreateSpatializedStatic3DElement'\n\n constructor(readonly modelURL: string) {\n super()\n this.modelURL = modelURL\n }\n\n protected getParams() {\n return { modelURL: this.modelURL }\n }\n}\n\nexport class CreateSpatializedDynamic3DElementCommand extends JSBCommand {\n protected getParams(): Record<string, any> | undefined {\n return { test: true }\n }\n commandType = 'CreateSpatializedDynamic3DElement'\n}\n\nexport class CreateSpatialEntityCommand extends JSBCommand {\n constructor(private name?: string) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return { name: this.name }\n }\n commandType = 'CreateSpatialEntity'\n}\n\nexport class CreateModelComponentCommand extends JSBCommand {\n constructor(private options: ModelComponentOptions) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n let geometryId = this.options.mesh.id\n let materialIds = this.options.materials.map(material => material.id)\n return { geometryId, materialIds }\n }\n commandType = 'CreateModelComponent'\n}\n\nexport class CreateSpatialModelEntityCommand extends JSBCommand {\n constructor(private options: SpatialModelEntityCreationOptions) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return this.options\n }\n commandType = 'CreateSpatialModelEntity'\n}\n\nexport class CreateModelAssetCommand extends JSBCommand {\n constructor(private options: ModelAssetOptions) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return { url: this.options.url }\n }\n commandType = 'CreateModelAsset'\n}\n\nexport class CreateSpatialGeometryCommand extends JSBCommand {\n constructor(\n private type: SpatialGeometryType,\n private options: SpatialGeometryOptions = {},\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return { type: this.type, ...this.options }\n }\n commandType = 'CreateGeometry'\n}\n\nexport class CreateSpatialUnlitMaterialCommand extends JSBCommand {\n constructor(private options: SpatialUnlitMaterialOptions) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return this.options\n }\n commandType = 'CreateUnlitMaterial'\n}\n\nexport class AddComponentToEntityCommand extends JSBCommand {\n constructor(\n public entity: SpatialEntity,\n public comp: SpatialComponent,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n entityId: this.entity.id,\n componentId: this.comp.id,\n }\n }\n commandType = 'AddComponentToEntity'\n}\n\nexport class AddEntityToDynamic3DCommand extends JSBCommand {\n constructor(\n public d3dEle: SpatializedDynamic3DElement,\n public entity: SpatialEntity,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n entityId: this.entity.id,\n dynamic3dId: this.d3dEle.id,\n }\n }\n\n commandType = 'AddEntityToDynamic3D'\n}\n\nexport class AddEntityToEntityCommand extends JSBCommand {\n constructor(\n public parent: SpatialEntity,\n public child: SpatialEntity,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n parentId: this.parent.id,\n childId: this.child.id,\n }\n }\n commandType = 'AddEntityToEntity'\n}\n\nexport class RemoveEntityFromParentCommand extends JSBCommand {\n constructor(public entity: SpatialEntity) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n entityId: this.entity.id,\n }\n }\n commandType = 'RemoveEntityFromParent'\n}\n\nexport class SetParentForEntityCommand extends JSBCommand {\n // childId, parentId\n constructor(\n public childId: string,\n public parentId?: string,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n childId: this.childId,\n parentId: this.parentId,\n }\n }\n commandType = 'SetParentToEntity'\n}\n\nexport class ConvertFromEntityToEntityCommand extends JSBCommand {\n constructor(\n public fromEntityId: string,\n public toEntityId: string,\n public fromPosition: Vec3,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n fromEntityId: this.fromEntityId,\n toEntityId: this.toEntityId,\n position: this.fromPosition,\n }\n }\n commandType = 'ConvertFromEntityToEntity'\n}\n\nexport class ConvertFromEntityToSceneCommand extends JSBCommand {\n constructor(\n public fromEntityId: string,\n public position: Vec3,\n ) {\n super()\n }\n\n protected getParams(): Record<string, any> | undefined {\n return {\n fromEntityId: this.fromEntityId,\n position: this.position,\n }\n }\n\n commandType = 'ConvertFromEntityToScene'\n}\n\nexport class ConvertFromSceneToEntityCommand extends JSBCommand {\n // let entityId: String\n // let position:Vec3\n constructor(\n public entityId: string,\n public position: Vec3,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n entityId: this.entityId,\n position: this.position,\n }\n }\n commandType = 'ConvertFromSceneToEntity'\n}\n\nexport class ConvertCoordinateCommand extends JSBCommand {\n constructor(\n public position: Vec3,\n public fromId: string,\n public toId: string,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n position: this.position,\n fromId: this.fromId,\n toId: this.toId,\n }\n }\n commandType = 'ConvertCoordinate'\n}\n\nexport class CreateTextureResourceCommand extends JSBCommand {\n constructor(private url: string) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n url: this.url,\n }\n }\n commandType = 'CreateTextureResource'\n}\n\nexport class InspectCommand extends JSBCommand {\n commandType = 'Inspect'\n\n constructor(readonly id: string = '') {\n super()\n }\n\n protected getParams() {\n return this.id ? { id: this.id } : { id: '' }\n }\n}\n\nexport class DestroyCommand extends JSBCommand {\n commandType = 'Destroy'\n\n constructor(readonly id: string) {\n super()\n }\n\n protected getParams() {\n return { id: this.id }\n }\n}\n\nexport class CheckWebViewCanCreateCommand extends JSBCommand {\n commandType = 'CheckWebViewCanCreate'\n\n constructor(readonly id: string = '') {\n super()\n }\n\n protected getParams() {\n return { id: this.id }\n }\n}\n\n/* WebSpatial Protocol Begin */\nabstract class WebSpatialProtocolCommand extends JSBCommand {\n target?: string\n features?: string\n\n async execute(): Promise<WebSpatialProtocolResult> {\n const query = this.getQuery()\n return platform.callWebSpatialProtocol(\n this.commandType,\n query,\n this.target,\n this.features,\n )\n }\n\n executeSync(): WebSpatialProtocolResult {\n const query = this.getQuery()\n return platform.callWebSpatialProtocolSync(\n this.commandType,\n query,\n this.target,\n this.features,\n )\n }\n\n private getQuery() {\n let query = undefined\n const params = this.getParams()\n if (params) {\n query = Object.keys(params)\n .map(key => {\n const value = params[key]\n const finalValue =\n typeof value === 'object' ? JSON.stringify(value) : value\n return `${key}=${encodeURIComponent(finalValue)}`\n })\n .join('&')\n }\n\n return query\n }\n}\n\nexport class createSpatialized2DElementCommand extends WebSpatialProtocolCommand {\n commandType = 'createSpatialized2DElement'\n constructor() {\n super()\n }\n protected getParams() {\n return {}\n }\n}\n\nexport class createSpatialSceneCommand extends WebSpatialProtocolCommand {\n commandType = 'createSpatialScene'\n\n constructor(\n private url: string,\n private config: SpatialSceneCreationOptionsInternal | undefined,\n public target?: string,\n public features?: string,\n ) {\n super()\n }\n protected getParams() {\n return {\n url: this.url,\n config: this.config,\n }\n }\n}\n\nexport class CreateAttachmentEntityCommand extends WebSpatialProtocolCommand {\n commandType = 'createAttachment'\n constructor(private options: AttachmentEntityOptions) {\n super()\n }\n protected getParams() {\n return {} // No metadata — just trigger engine/webview creation\n }\n}\n\nexport class InitializeAttachmentCommand extends JSBCommand {\n commandType = 'InitializeAttachment'\n constructor(\n private attachmentId: string,\n private options: AttachmentEntityOptions,\n ) {\n super()\n }\n protected getParams() {\n return {\n id: this.attachmentId,\n parentEntityId: this.options.parentEntityId,\n position: this.options.position ?? [0, 0, 0],\n size: this.options.size,\n ownerViewId: this.options.ownerViewId,\n }\n }\n}\n\nexport class UpdateAttachmentEntityCommand extends JSBCommand {\n commandType = 'UpdateAttachmentEntity'\n constructor(\n private attachmentId: string,\n private options: AttachmentEntityUpdateOptions,\n ) {\n super()\n }\n protected getParams() {\n return {\n id: this.attachmentId,\n ...this.options,\n }\n }\n}\n\n// TODO: Can crypto.randomUUID be used instead including in dev environments without https\nfunction uuid(): string {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {\n const r = (Math.random() * 16) | 0\n return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16)\n })\n}\n\n/* WebSpatial Protocol End */\n","import { DestroyCommand, InspectCommand } from './JSBCommand'\n\n/**\n * @hidden\n * Parent class of spatial objects, should not be used directly\n */\nexport class SpatialObject {\n /** @hidden */\n constructor(\n /** @hidden */\n public readonly id: string,\n ) {}\n\n name?: string\n\n isDestroyed = false\n\n async inspect() {\n const ret = await new InspectCommand(this.id).execute()\n if (ret.success) {\n return ret.data\n }\n throw new Error(ret.errorMessage)\n }\n\n async destroy() {\n if (this.isDestroyed) {\n return\n }\n\n const ret = await new DestroyCommand(this.id).execute()\n if (ret.success) {\n this.onDestroy()\n this.isDestroyed = true\n return ret.data\n } else if (this.isDestroyed) {\n // already destroyed\n return\n }\n\n throw new Error(ret.errorMessage)\n }\n\n // override this method to do some cleanup\n protected onDestroy() {}\n}\n","import { createSpatialSceneCommand, FocusScene } from './JSBCommand'\nimport { SpatialScene } from './SpatialScene'\nimport {\n SpatialSceneCreationOptions,\n SpatialSceneType,\n SpatialSceneState,\n isValidSceneUnit,\n isValidSpatialSceneType,\n isValidWorldScalingType,\n isValidWorldAlignmentType,\n isValidBaseplateVisibilityType,\n} from './types/types'\nimport { SpatialSceneCreationOptionsInternal } from './types/internal'\n\nconst defaultSceneConfig: SpatialSceneCreationOptions = {\n defaultSize: {\n width: 1280,\n height: 720,\n },\n}\n\nconst defaultSceneConfigVolume: SpatialSceneCreationOptions = {\n defaultSize: {\n width: 0.94,\n height: 0.94,\n depth: 0.94,\n },\n}\n\nconst INTERNAL_SCHEMA_PREFIX = 'webspatial://'\n\nclass SceneManager {\n private originalOpen: any\n private static instance: SceneManager\n static getInstance() {\n if (!SceneManager.instance) {\n SceneManager.instance = new SceneManager()\n }\n return SceneManager.instance\n }\n\n init(window: WindowProxy) {\n this.originalOpen = window.open.bind(window)\n ;(window as any).open = this.open\n }\n\n private configMap: Record<string, SpatialSceneCreationOptionsInternal> = {} // name=>config\n private getConfig(name?: string) {\n if (name === undefined || !this.configMap[name]) return undefined\n return this.configMap[name]\n }\n\n // Ensure URL is absolute; only convert when a relative path is provided\n // - Keep external and special schemes untouched (http, https, data, blob, about, file, mailto, etc.)\n // - Handle protocol-relative URLs (//example.com/path)\n // - Resolve relative paths against document.baseURI (respects <base href>)\n private ensureAbsoluteUrl(raw?: string): string | undefined {\n if (!raw) return raw\n // Already has a scheme (includes internal webspatial:// which is handled earlier)\n if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(raw)) {\n return raw\n }\n // Protocol-relative URL\n if (raw.startsWith('//')) {\n return `${window.location.protocol}${raw}`\n }\n // Resolve against base URI\n try {\n return new URL(raw, document.baseURI).toString()\n } catch {\n // Fallback: leave unchanged\n return raw\n }\n }\n\n private open = (url?: string, target?: string, features?: string) => {\n // bypass internal\n if (url?.startsWith(INTERNAL_SCHEMA_PREFIX)) {\n return this.originalOpen(url, target, features)\n }\n\n // Normalize only relative URLs to absolute for platform handling\n url = this.ensureAbsoluteUrl(url)\n\n // if target is special\n if (target === '_self' || target === '_parent' || target === '_top') {\n const newWindow = this.originalOpen(url, target, features)\n return newWindow\n }\n\n const cfg = target ? this.getConfig(target) : undefined\n const cmd = new createSpatialSceneCommand(url!, cfg, target, features)\n const result = cmd.executeSync()\n\n const id = result.data?.id\n\n if (id) {\n // send JSB to focus\n let focusCmd = new FocusScene(id)\n focusCmd.execute()\n }\n\n return result.data?.windowProxy\n }\n initScene(\n name: string,\n callback: (pre: SpatialSceneCreationOptions) => SpatialSceneCreationOptions,\n options?: { type: SpatialSceneType },\n ) {\n const sceneType = options?.type ?? 'window'\n const defaultConfig = getSceneDefaultConfig(sceneType)\n const rawReturnVal = callback({ ...defaultConfig })\n const [formattedConfig, errors] = formatSceneConfig(rawReturnVal, sceneType)\n if (errors.length > 0) {\n console.warn(`initScene ${name} with errors: ${errors.join(', ')}`)\n }\n this.configMap[name] = {\n ...formattedConfig,\n type: sceneType,\n }\n }\n}\n\nfunction pxToMeter(px: number): number {\n return px / 1360\n}\n\nfunction meterToPx(meter: number): number {\n return meter * 1360\n}\n\nfunction formatToNumber(\n str: string | number,\n targetUnit: 'px' | 'm',\n defaultUnit: 'px' | 'm',\n): number {\n if (typeof str === 'number') {\n if (\n (defaultUnit === 'px' && targetUnit === 'px') ||\n (defaultUnit === 'm' && targetUnit === 'm')\n ) {\n return str\n }\n // unit not match target\n if (defaultUnit === 'px' && targetUnit === 'm') {\n return pxToMeter(str)\n } else if (defaultUnit === 'm' && targetUnit === 'px') {\n return meterToPx(str)\n }\n // fallback\n return str\n }\n if (targetUnit === 'm') {\n if (str.endsWith('m')) {\n // 1m\n return Number(str.slice(0, -1))\n } else if (str.endsWith('px')) {\n // 100px\n return pxToMeter(Number(str.slice(0, -2)))\n } else {\n throw new Error('formatToNumber: invalid str')\n }\n } else if (targetUnit === 'px') {\n if (str.endsWith('px')) {\n // 100px\n return Number(str.slice(0, -2))\n } else if (str.endsWith('m')) {\n // 1m\n return meterToPx(Number(str.slice(0, -1)))\n } else {\n throw new Error('formatToNumber: invalid str')\n }\n } else {\n throw new Error('formatToNumber: invalid targetUnit')\n }\n}\n\nexport function formatSceneConfig(\n config: SpatialSceneCreationOptions,\n sceneType: SpatialSceneType,\n): [SpatialSceneCreationOptions, string[]] {\n // defaultSize and resizability's width/height/depth can be 100 or \"100px\" or \"1m\"\n // expect:\n // resizability should format into px\n // defaultSize should format into px if window\n // defaultSize should format into m if volume\n\n const defaultSceneConfig = getSceneDefaultConfig(sceneType)\n\n const errors: string[] = []\n\n const isWindow = sceneType === 'window'\n if (!isValidSpatialSceneType(sceneType)) {\n errors.push(`sceneType`)\n }\n\n // format defaultSize\n if (config.defaultSize) {\n const iterKeys = ['width', 'height', 'depth']\n for (let k of iterKeys) {\n if (!(k in config.defaultSize)) continue\n if (isValidSceneUnit((config.defaultSize as any)[k])) {\n ;(config.defaultSize as any)[k] = formatToNumber(\n (config.defaultSize as any)[k],\n isWindow ? 'px' : 'm',\n isWindow ? 'px' : 'm',\n )\n } else {\n ;(config.defaultSize as any)[k] = (\n defaultSceneConfig.defaultSize as any\n )[k]\n errors.push(`defaultSize.${k}`)\n }\n }\n }\n\n // format resizability\n if (config.resizability) {\n const iterKeys = ['minWidth', 'minHeight', 'maxWidth', 'maxHeight']\n for (let k of iterKeys) {\n if (!(k in config.resizability)) continue\n if (isValidSceneUnit((config.resizability as any)[k])) {\n ;(config.resizability as any)[k] = formatToNumber(\n (config.resizability as any)[k],\n 'px',\n isWindow ? 'px' : 'm',\n )\n } else {\n ;(config.resizability as any)[k] = undefined\n errors.push(`resizability.${k}`)\n }\n }\n }\n\n // check value\n if (config.worldScaling) {\n if (!isValidWorldScalingType(config.worldScaling)) {\n config.worldScaling = 'automatic'\n errors.push('worldScaling')\n }\n }\n\n if (config.worldAlignment) {\n if (!isValidWorldAlignmentType(config.worldAlignment)) {\n config.worldAlignment = 'automatic'\n errors.push('worldAlignment')\n }\n }\n\n if (config.baseplateVisibility) {\n if (!isValidBaseplateVisibilityType(config.baseplateVisibility)) {\n config.baseplateVisibility = 'automatic'\n errors.push('baseplateVisibility')\n }\n }\n\n return [config, errors]\n}\n\nexport function initScene(\n name: string,\n callback: (pre: SpatialSceneCreationOptions) => SpatialSceneCreationOptions,\n options?: { type: SpatialSceneType },\n) {\n return SceneManager.getInstance().initScene(name, callback, options)\n}\n\nexport function hijackWindowOpen(window: WindowProxy) {\n SceneManager.getInstance().init(window)\n}\n\nexport function hijackWindowATag(openedWindow: WindowProxy) {\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\n if (handleATag(e)) {\n return false // prevent default action and stop event propagation\n }\n\n return true\n }\n if (element && element.parentElement) {\n element = element.parentElement\n } else {\n break\n }\n }\n }\n}\n\nfunction 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 return true\n }\n }\n}\n\nfunction getSceneDefaultConfig(sceneType: SpatialSceneType) {\n return sceneType === 'window' ? defaultSceneConfig : defaultSceneConfigVolume\n}\n\nasync function injectScenePolyfill() {\n if (!window.opener) return\n\n const state = await SpatialScene.getInstance().getState()\n\n // only run this in pending state\n if (state !== SpatialSceneState.pending) return\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 provideDefaultSceneConfig = getSceneDefaultConfig(\n window.xrCurrentSceneType ?? 'window',\n )\n let cfg = provideDefaultSceneConfig\n if (typeof window.xrCurrentSceneDefaults === 'function') {\n try {\n cfg = await window.xrCurrentSceneDefaults?.(provideDefaultSceneConfig)\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\n const sceneType = window.xrCurrentSceneType ?? 'window'\n const [formattedConfig, errors] = formatSceneConfig(cfg, sceneType)\n if (errors.length > 0) {\n console.warn(\n `window.xrCurrentSceneDefaults with errors: ${errors.join(', ')}`,\n )\n }\n await SpatialScene.getInstance().updateSceneCreationConfig({\n ...formattedConfig,\n type: sceneType,\n })\n })\n}\n\nexport function injectSceneHook() {\n hijackWindowOpen(window)\n hijackWindowATag(window)\n injectScenePolyfill()\n}\n","import {\n SpatialSceneCreationOptions,\n SpatialSceneProperties,\n Vec3,\n} from './types/types'\nimport { SpatialSceneCreationOptionsInternal } from './types/internal'\nimport {\n AddSpatializedElementToSpatialScene,\n GetSpatialSceneState,\n UpdateSceneConfig,\n UpdateSpatialSceneProperties,\n} from './JSBCommand'\nimport { ConvertCoordinateCommand } from './JSBCommand'\n\nimport { SpatializedElement } from './SpatializedElement'\nimport { SpatialObject } from './SpatialObject'\nimport { SpatialSceneState } from './types/internal'\n\nlet instance: SpatialScene\n\n/**\n * Represents the spatial scene that contains all spatialized elements.\n * This class follows the singleton pattern - only one instance exists per application.\n * The scene manages the overall spatial environment properties and contains all spatial elements.\n */\nexport class SpatialScene extends SpatialObject {\n /**\n * Gets the singleton instance of the SpatialScene.\n * Creates a new instance if one doesn't exist yet.\n * @returns The singleton SpatialScene instance\n */\n static getInstance(): SpatialScene {\n if (!instance) {\n instance = new SpatialScene('')\n }\n return instance\n }\n\n async convertCoordinate(\n position: Vec3,\n fromId: string,\n toId: string,\n ): Promise<Vec3> {\n try {\n const ret = await new ConvertCoordinateCommand(\n position,\n fromId,\n toId,\n ).execute()\n return (ret as any)?.data ?? position\n } catch (error) {\n console.warn('SpatialScene.convertCoordinate error:', error)\n throw error\n }\n }\n\n /**\n * Updates the properties of the spatial scene.\n * This can include background settings, lighting, and other scene-wide properties.\n * @param properties Partial set of properties to update\n * @returns Promise resolving when the update is complete\n */\n async updateSpatialProperties(properties: Partial<SpatialSceneProperties>) {\n return new UpdateSpatialSceneProperties(properties).execute()\n }\n\n /**\n * Adds a spatialized element to the scene.\n * This makes the element visible and interactive in the spatial environment.\n * @param element The SpatializedElement to add to the scene\n * @returns Promise resolving when the element is added\n */\n async addSpatializedElement(element: SpatializedElement) {\n return new AddSpatializedElementToSpatialScene(element).execute()\n }\n\n /**\n * Updates the scene creation configuration.\n * This allows changing scene parameters after initial creation.\n * @param config The new scene creation configuration\n * @returns Promise resolving when the update is complete\n */\n async updateSceneCreationConfig(config: SpatialSceneCreationOptionsInternal) {\n return new UpdateSceneConfig(config).execute()\n }\n\n /**\n * Gets the current state of the spatial scene.\n * This includes information about active elements and scene configuration.\n * @returns Promise resolving to the current SpatialSceneState\n */\n async getState(): Promise<SpatialSceneState> {\n return (await new GetSpatialSceneState().execute()).data.name\n }\n}\n","import type { SpatialEntity } from '..'\nimport { SpatialGeometry } from '../reality/geometry/SpatialGeometry'\nimport { SpatialMaterial } from '../reality/material/SpatialMaterial'\nimport type { SpatializedDynamic3DElement } from '../SpatializedDynamic3DElement'\n\nexport interface Vec3 {\n x: number\n y: number\n z: number\n}\n\nexport type Point3D = Vec3\n\nexport interface Quaternion {\n x: number\n y: number\n z: number\n w: number\n}\n\n/**\n * Material type for SpatialDiv or HTML document.\n *\n * This type defines the background material options for both SpatialDiv elements and HTML documents.\n *\n * - `'none'`: This is the default value.\n * - For HTML documents, the web page window will have the default native background.\n * - For SpatialDiv, the window will have a transparent background.\n * - `'translucent'`: Represents a glass-like material in AVP (Apple Vision Pro).\n * - `'thick'`: Represents a thick material in AVP.\n * - `'regular'`: Represents a regular material in AVP.\n * - `'thin'`: Represents a thin material in AVP.\n * - `'transparent'`: Represents a fully transparent background.\n */\nexport type BackgroundMaterialType =\n | 'none'\n | 'translucent'\n | 'thick'\n | 'regular'\n | 'thin'\n | 'transparent'\n\nexport type CornerRadius = {\n topLeading: number\n bottomLeading: number\n topTrailing: number\n bottomTrailing: number\n}\n\nexport interface SpatialSceneProperties {\n cornerRadius: CornerRadius\n material: BackgroundMaterialType\n opacity: number\n}\n\nexport enum SpatializedElementType {\n Spatialized2DElement,\n SpatializedStatic3DElement,\n SpatializedDynamic3DElement,\n}\n\nexport interface SpatializedElementProperties {\n name: string\n clientX: number\n clientY: number\n width: number\n height: number\n depth: number\n opacity: number\n visible: boolean\n scrollWithParent: boolean\n zIndex: number\n backOffset: number\n rotationAnchor: Point3D\n enableTapGesture: boolean\n enableDragStartGesture: boolean\n enableDragGesture: boolean\n enableDragEndGesture: boolean\n enableRotateGesture: boolean\n enableRotateEndGesture: boolean\n enableMagnifyGesture: boolean\n enableMagnifyEndGesture: boolean\n /**\n * Optional world-space axis for spatial rotate gesture. Omitted or zero vector\n * means unconstrained rotation (platform default).\n */\n rotateConstrainedToAxis?: Vec3\n}\n\nexport interface Spatialized2DElementProperties\n extends SpatializedElementProperties {\n scrollPageEnabled: boolean\n cornerRadius: CornerRadius\n material: BackgroundMaterialType\n scrollEdgeInsetsMarginRight: number\n}\n\nexport interface SpatializedStatic3DElementProperties\n extends SpatializedElementProperties {\n modelURL: string\n modelTransform?: number[]\n}\n\nexport interface SpatialSceneCreationOptions {\n defaultSize?: {\n width: number | string // Initial width of the window\n height: number | string // Initial height of the window\n depth?: number | string // Initial depth of the window, only for volume\n }\n\n resizability?: {\n minWidth?: number | string // Minimum width of the window\n minHeight?: number | string // Minimum height of the window\n maxWidth?: number | string // Maximum width of the window\n maxHeight?: number | string // Maximum height of the window\n }\n worldScaling?: WorldScalingType\n worldAlignment?: WorldAlignmentType\n\n baseplateVisibility?: BaseplateVisibilityType\n}\n\nexport type SpatialEntityEventType =\n | 'spatialtap'\n | 'spatialdragstart'\n | 'spatialdrag'\n | 'spatialdragend'\n | 'spatialrotate'\n | 'spatialrotateend'\n | 'spatialmagnify'\n | 'spatialmagnifyend'\n\nexport const BaseplateVisibilityValues = [\n 'automatic',\n 'visible',\n 'hidden',\n] as const\nexport type BaseplateVisibilityType = (typeof BaseplateVisibilityValues)[number]\n\nexport function isValidBaseplateVisibilityType(type: string): Boolean {\n return BaseplateVisibilityValues.includes(type as BaseplateVisibilityType)\n}\n\nexport const WorldScalingValues = ['automatic', 'dynamic'] as const\nexport type WorldScalingType = (typeof WorldScalingValues)[number]\n\nexport function isValidWorldScalingType(type: string): Boolean {\n return WorldScalingValues.includes(type as WorldScalingType)\n}\n\nexport const WorldAlignmentValues = [\n 'adaptive',\n 'automatic',\n 'gravityAligned',\n] as const\nexport type WorldAlignmentType = (typeof WorldAlignmentValues)[number]\n\nexport function isValidWorldAlignmentType(type: string): Boolean {\n return WorldAlignmentValues.includes(type as WorldAlignmentType)\n}\n\nexport const SpatialSceneValues = ['window', 'volume'] as const\nexport type SpatialSceneType = (typeof SpatialSceneValues)[number]\n\nexport function isValidSpatialSceneType(type: string): Boolean {\n return SpatialSceneValues.includes(type as SpatialSceneType)\n}\n\n/**\n * check px,m and number, number must be >= 0\n *\n * */\nexport function isValidSceneUnit(val: string | number): boolean {\n // only support number or string with unit px or m\n // rpx cm mm not allowed\n if (typeof val === 'number') {\n return val >= 0\n }\n if (typeof val === 'string') {\n if (val.endsWith('px')) {\n // check if number\n if (isNaN(Number(val.slice(0, -2)))) {\n return false\n }\n return Number(val.slice(0, -2)) >= 0\n }\n if (val.endsWith('m')) {\n // check if number\n if (isNaN(Number(val.slice(0, -1)))) {\n return false\n }\n return Number(val.slice(0, -1)) >= 0\n }\n }\n return false\n}\n\nexport interface SpatialEntityProperties {\n position: Vec3\n rotation: Vec3\n scale: Vec3\n}\n\nexport type SpatialGeometryType =\n | 'BoxGeometry'\n | 'PlaneGeometry'\n | 'SphereGeometry'\n | 'CylinderGeometry'\n | 'ConeGeometry'\n\nexport interface SpatialBoxGeometryOptions {\n width?: number\n height?: number\n depth?: number\n cornerRadius?: number\n splitFaces?: boolean\n}\n\nexport interface SpatialPlaneGeometryOptions {\n width?: number\n height?: number\n cornerRadius?: number\n}\n\nexport interface SpatialSphereGeometryOptions {\n radius?: number\n}\n\nexport interface SpatialConeGeometryOptions {\n radius?: number\n height?: number\n}\n\nexport interface SpatialCylinderGeometryOptions {\n radius?: number\n height?: number\n}\n\nexport type SpatialGeometryOptions =\n | SpatialBoxGeometryOptions\n | SpatialPlaneGeometryOptions\n | SpatialSphereGeometryOptions\n | SpatialCylinderGeometryOptions\n | SpatialConeGeometryOptions\n\nexport type SpatialMaterialType = 'unlit'\n\nexport interface SpatialUnlitMaterialOptions {\n color?: string\n textureId?: string\n transparent?: boolean\n opacity?: number\n}\n\nexport interface ModelComponentOptions {\n mesh: SpatialGeometry\n materials: SpatialMaterial[]\n}\n\nexport interface SpatialEntityUserData {\n id?: string\n name?: string\n}\n\nexport interface SpatialModelEntityCreationOptions {\n modelAssetId: string\n name?: string\n}\n\nexport interface ModelAssetOptions {\n url: string\n}\n\nexport enum SpatialSceneState {\n idle = 'idle',\n pending = 'pending',\n willVisible = 'willVisible',\n visible = 'visible',\n fail = 'fail',\n}\n\n/**\n * Translate event, matching similar behavior to https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drag_event\n */\nexport type SpatialModelDragEvent = {\n eventType: 'dragstart' | 'dragend' | 'drag'\n translation3D: Vec3\n startLocation3D: Vec3\n}\n\nexport interface Size {\n width: number\n height: number\n}\n\nexport interface Size3D extends Size {\n depth: number\n}\n\nexport class CubeInfo {\n constructor(\n public size: Size3D,\n public origin: Vec3,\n ) {\n this.size = size\n this.origin = origin\n }\n\n get x() {\n return this.origin.x\n }\n\n get y() {\n return this.origin.y\n }\n\n get z() {\n return this.origin.z\n }\n\n get width() {\n return this.size.width\n }\n\n get height() {\n return this.size.height\n }\n\n get depth() {\n return this.size.depth\n }\n\n get left() {\n return this.x\n }\n\n get top() {\n return this.y\n }\n\n get right() {\n return this.x + this.width\n }\n\n get bottom() {\n return this.y + this.height\n }\n\n get back() {\n return this.z\n }\n\n get front() {\n return this.z + this.depth\n }\n}\n\nexport interface SpatialTapEventDetail {\n location3D: Point3D\n globalLocation3D?: Point3D\n}\n\nexport type SpatialTapEvent = CustomEvent<SpatialTapEventDetail>\n\nexport interface SpatialDragStartEventDetail {\n startLocation3D: Point3D\n globalLocation3D?: Point3D\n}\n\nexport interface SpatialDragEventDetail {\n translation3D: Vec3\n}\n\nexport interface SpatialDragEndEventDetail {}\n\nexport type SpatialDragStartEvent = CustomEvent<SpatialDragStartEventDetail>\n\nexport type SpatialDragEvent = CustomEvent<SpatialDragEventDetail>\n\nexport type SpatialDragEndEvent = CustomEvent<SpatialDragEndEventDetail>\nexport interface SpatialRotateEventDetail {\n quaternion: Quaternion\n}\n\nexport interface SpatialRotateEndEventDetail {}\n\nexport type SpatialRotateEvent = CustomEvent<SpatialRotateEventDetail>\n\nexport type SpatialRotateEndEvent = CustomEvent<SpatialRotateEndEventDetail>\n\nexport interface SpatialMagnifyEventDetail {\n magnification: number\n}\n\nexport interface SpatialMagnifyEndEventDetail {}\n\nexport type SpatialMagnifyEvent = CustomEvent<SpatialMagnifyEventDetail>\n\nexport type SpatialMagnifyEndEvent = CustomEvent<SpatialMagnifyEndEventDetail>\n\nexport type SpatialEntityOrReality = SpatialEntity | SpatializedDynamic3DElement\n\nexport interface AttachmentEntityOptions {\n parentEntityId: string\n position?: [number, number, number]\n size: { width: number; height: number }\n ownerViewId: string\n}\n\nexport interface AttachmentEntityUpdateOptions {\n position?: [number, number, number]\n size?: { width: number; height: number }\n}\n","import {\n createSpatialized2DElementCommand,\n CreateSpatializedDynamic3DElementCommand,\n CreateSpatializedStatic3DElementCommand,\n} from './JSBCommand'\nimport { Spatialized2DElement } from './Spatialized2DElement'\nimport { SpatializedStatic3DElement } from './SpatializedStatic3DElement'\nimport { SpatializedDynamic3DElement } from './SpatializedDynamic3DElement'\n\nexport async function createSpatialized2DElement(): Promise<Spatialized2DElement> {\n const result = await new createSpatialized2DElementCommand().execute()\n if (!result.success) {\n throw new Error('createSpatialized2DElement failed')\n } else {\n const { id, windowProxy } = result.data!\n // set base href to make sure the relative url is correct\n windowProxy.document.head.innerHTML = `<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <base href=\"${document.baseURI}\">`\n return new Spatialized2DElement(id, windowProxy)\n }\n}\n\nexport async function createSpatializedStatic3DElement(\n modelURL: string,\n): Promise<SpatializedStatic3DElement> {\n const result = await new CreateSpatializedStatic3DElementCommand(\n modelURL,\n ).execute()\n if (!result.success) {\n throw new Error('createSpatializedStatic3DElement failed')\n } else {\n const { id } = result.data\n return new SpatializedStatic3DElement(id, modelURL)\n }\n}\n\nexport async function createSpatializedDynamic3DElement(): Promise<SpatializedDynamic3DElement> {\n const result = await new CreateSpatializedDynamic3DElementCommand().execute()\n if (!result.success) {\n throw new Error('createSpatializedDynamic3DElement failed')\n } else {\n const { id } = result.data\n return new SpatializedDynamic3DElement(id)\n }\n}\n","import {\n AddSpatializedElementToSpatialized2DElement,\n UpdateSpatialized2DElementProperties,\n} from './JSBCommand'\nimport { hijackWindowATag } from './scene-polyfill'\nimport { SpatializedElement } from './SpatializedElement'\nimport { Spatialized2DElementProperties } from './types/types'\n\n/**\n * Represents a 2D HTML element that has been spatialized in 3D space.\n * This class handles the integration between 2D web content and the 3D spatial environment,\n * allowing HTML elements to be positioned and interacted with in spatial applications.\n */\nexport class Spatialized2DElement extends SpatializedElement {\n /**\n * Creates a new spatialized 2D element.\n * @param id Unique identifier for this element\n * @param windowProxy Reference to the window object containing the 2D content\n */\n constructor(\n id: string,\n readonly windowProxy: WindowProxy,\n ) {\n super(id)\n // Hijack anchor tag events to handle navigation within the spatial context\n hijackWindowATag(windowProxy)\n }\n\n /**\n * Updates the properties of this 2D element.\n * This can include size, position, background, and other visual properties.\n * @param properties Partial set of properties to update\n * @returns Promise resolving when the update is complete\n */\n async updateProperties(properties: Partial<Spatialized2DElementProperties>) {\n return new UpdateSpatialized2DElementProperties(this, properties).execute()\n }\n\n /**\n * Adds a child spatialized element to this 2D element.\n * This allows for creating hierarchical structures of spatial elements.\n * @param element The child element to add\n * @returns Promise resolving when the element is added\n */\n async addSpatializedElement(element: SpatializedElement) {\n return new AddSpatializedElementToSpatialized2DElement(\n this,\n element,\n ).execute()\n }\n}\n","import { UpdateSpatializedElementTransform } from './JSBCommand'\nimport { WebSpatialProtocolResult } from './platform-adapter/interface'\nimport { SpatialObject } from './SpatialObject'\nimport { SpatialWebEvent } from './SpatialWebEvent'\nimport { createSpatialEvent } from './SpatialWebEventCreator'\nimport {\n CubeInfo,\n SpatialDragEndEvent,\n SpatialDragEvent,\n SpatialDragStartEvent,\n SpatializedElementProperties,\n SpatialMagnifyEndEvent,\n SpatialMagnifyEvent,\n SpatialRotateEndEvent,\n SpatialRotateEvent,\n SpatialTapEvent,\n} from './types/types'\nimport {\n ObjectDestroyMsg,\n SpatialDragEndMsg,\n SpatialDragMsg,\n SpatialDragStartMsg,\n SpatialMagnifyEndMsg,\n SpatialMagnifyMsg,\n SpatialRotateEndMsg,\n SpatialRotateMsg,\n SpatialTapMsg,\n SpatialWebMsgType,\n} from './WebMsgCommand'\n\n/**\n * Abstract base class for all spatialized elements in the WebSpatial environment.\n * Provides common functionality for elements that can exist in 3D space,\n * including transformation handling and gesture event processing.\n */\nexport abstract class SpatializedElement extends SpatialObject {\n /**\n * Creates a new spatialized element with the specified ID.\n * Registers the element to receive spatial events.\n * @param id Unique identifier for this element\n */\n constructor(public readonly id: string) {\n super(id)\n\n SpatialWebEvent.addEventReceiver(id, this.onReceiveEvent.bind(this))\n }\n\n /**\n * Updates the properties of this spatialized element.\n * Must be implemented by derived classes to handle specific property updates.\n * @param properties Partial set of properties to update\n * @returns Promise resolving to the result of the update operation\n */\n abstract updateProperties(\n properties: Partial<SpatializedElementProperties>,\n ): Promise<WebSpatialProtocolResult>\n\n /**\n * Updates the transformation matrix of this element in 3D space.\n * This affects the position, rotation, and scale of the element.\n * @param matrix The new transformation matrix\n * @returns Promise resolving when the transform is updated\n */\n async updateTransform(matrix: DOMMatrix) {\n return new UpdateSpatializedElementTransform(this, matrix).execute()\n }\n\n /**\n * Information about the element's bounding cube.\n * Used for spatial calculations and hit testing.\n */\n private _cubeInfo?: CubeInfo\n\n /**\n * Gets the current cube information for this element.\n * @returns The current CubeInfo or undefined if not set\n */\n get cubeInfo() {\n return this._cubeInfo\n }\n\n /**\n * The current transformation matrix of this element.\n */\n private _transform?: DOMMatrix\n\n /**\n * The inverse of the current transformation matrix.\n * Used for converting world coordinates to local coordinates.\n */\n private _transformInv?: DOMMatrix\n\n /**\n * Gets the current transformation matrix.\n * @returns The current transformation matrix or undefined if not set\n */\n get transform() {\n return this._transform\n }\n\n /**\n * Gets the inverse of the current transformation matrix.\n * @returns The inverse transformation matrix or undefined if not set\n */\n get transformInv() {\n return this._transformInv\n }\n\n /**\n * Processes events received from the WebSpatial environment.\n * Handles various spatial events like transforms, gestures, and interactions.\n * @param data The event data received from the WebSpatial system\n */\n protected onReceiveEvent(\n data:\n | SpatialTapMsg\n | SpatialDragStartMsg\n | SpatialDragMsg\n | SpatialDragEndMsg\n | SpatialRotateMsg\n | SpatialRotateEndMsg\n | ObjectDestroyMsg,\n ) {\n const { type } = data\n if (type === SpatialWebMsgType.objectdestroy) {\n this.isDestroyed = true\n } else if (type === SpatialWebMsgType.spatialtap) {\n // Handle tap gestures\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialtap,\n (data as SpatialTapMsg).detail,\n )\n this._onSpatialTap?.(event)\n } else if (type === SpatialWebMsgType.spatialdragstart) {\n const dragStartEvent = createSpatialEvent(\n SpatialWebMsgType.spatialdragstart,\n (data as SpatialDragStartMsg).detail,\n )\n this._onSpatialDragStart?.(dragStartEvent)\n } else if (type === SpatialWebMsgType.spatialdrag) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialdrag,\n (data as SpatialDragMsg).detail,\n )\n this._onSpatialDrag?.(event)\n } else if (type === SpatialWebMsgType.spatialdragend) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialdragend,\n (data as SpatialDragEndMsg).detail,\n )\n this._onSpatialDragEnd?.(event)\n } else if (type === SpatialWebMsgType.spatialrotate) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialrotate,\n (data as SpatialRotateMsg).detail,\n )\n this._onSpatialRotate?.(event)\n } else if (type === SpatialWebMsgType.spatialrotateend) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialrotateend,\n (data as SpatialRotateEndMsg).detail,\n )\n this._onSpatialRotateEnd?.(event)\n } else if (type === SpatialWebMsgType.spatialmagnify) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialmagnify,\n (data as SpatialMagnifyMsg).detail,\n )\n this._onSpatialMagnify?.(event)\n } else if (type === SpatialWebMsgType.spatialmagnifyend) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialmagnifyend,\n (data as SpatialMagnifyEndMsg).detail,\n )\n this._onSpatialMagnifyEnd?.(event)\n }\n }\n\n private _onSpatialTap?: (event: SpatialTapEvent) => void\n set onSpatialTap(value: (event: SpatialTapEvent) => void | undefined) {\n this._onSpatialTap = value\n this.updateProperties({\n enableTapGesture: value !== undefined,\n })\n }\n\n private _onSpatialDragStart?: (event: SpatialDragStartEvent) => void\n set onSpatialDragStart(\n value: (event: SpatialDragStartEvent) => void | undefined,\n ) {\n this._onSpatialDragStart = value\n this.updateProperties({\n enableDragStartGesture: this._onSpatialDragStart !== undefined,\n })\n }\n\n private _onSpatialDrag?: (event: SpatialDragEvent) => void\n set onSpatialDrag(value: (event: SpatialDragEvent) => void | undefined) {\n this._onSpatialDrag = value\n this.updateProperties({\n enableDragGesture: this._onSpatialDrag !== undefined,\n })\n }\n\n private _onSpatialDragEnd?: (event: SpatialDragEndEvent) => void\n set onSpatialDragEnd(\n value: ((event: SpatialDragEndEvent) => void) | undefined,\n ) {\n this._onSpatialDragEnd = value\n this.updateProperties({\n enableDragEndGesture: value !== undefined,\n })\n }\n\n private _onSpatialRotate?: (event: SpatialRotateEvent) => void\n set onSpatialRotate(\n value: ((event: SpatialRotateEvent) => void) | undefined,\n ) {\n this._onSpatialRotate = value\n this.updateProperties({\n enableRotateGesture: this._onSpatialRotate !== undefined,\n })\n }\n\n private _onSpatialRotateEnd?: (event: SpatialRotateEndEvent) => void\n set onSpatialRotateEnd(\n value: ((event: SpatialRotateEndEvent) => void) | undefined,\n ) {\n this._onSpatialRotateEnd = value\n this.updateProperties({\n enableRotateEndGesture: value !== undefined,\n })\n }\n\n private _onSpatialMagnify?: (event: SpatialMagnifyEvent) => void\n set onSpatialMagnify(\n value: ((event: SpatialMagnifyEvent) => void) | undefined,\n ) {\n this._onSpatialMagnify = value\n this.updateProperties({\n enableMagnifyGesture: value !== undefined,\n })\n }\n\n private _onSpatialMagnifyEnd?: (event: SpatialMagnifyEndEvent) => void\n set onSpatialMagnifyEnd(\n value: ((event: SpatialMagnifyEndEvent) => void) | undefined,\n ) {\n this._onSpatialMagnifyEnd = value\n this.updateProperties({\n enableMagnifyEndGesture: value !== undefined,\n })\n }\n\n /**\n * Cleans up resources when this element is destroyed.\n * Removes event receivers to prevent memory leaks.\n */\n override onDestroy() {\n SpatialWebEvent.removeEventReceiver(this.id)\n }\n}\n","import { SpatialWebMsgType } from './WebMsgCommand'\n\nexport function createSpatialEvent<T>(\n type: SpatialWebMsgType,\n detail: T,\n): CustomEvent<T> {\n return new CustomEvent<T>(type, {\n bubbles: true,\n cancelable: false,\n detail,\n })\n}\n","import { UpdateSpatializedStatic3DElementProperties } from './JSBCommand'\nimport { SpatializedElement } from './SpatializedElement'\nimport { SpatializedStatic3DElementProperties } from './types/types'\nimport { SpatialWebMsgType } from './WebMsgCommand'\n\n/**\n * Represents a static 3D model element in the spatial environment.\n * This class handles loading and displaying pre-built 3D models from URLs,\n * and provides events for load success and failure.\n */\nexport class SpatializedStatic3DElement extends SpatializedElement {\n /**\n * Creates a new spatialized static 3D element with the specified ID and URL.\n * Registers the element to receive spatial events.\n * @param id Unique identifier for this element\n * @param modelURL URL of the 3D model\n */\n constructor(id: string, modelURL: string) {\n super(id)\n this.modelURL = modelURL\n }\n\n /**\n * Promise resolver for the ready state.\n * Used to resolve the ready promise when the model is loaded.\n */\n private _readyResolve?: (success: boolean) => void\n\n /**\n * Caches the last model URL to detect changes.\n * Used to reset the ready promise when the model URL changes.\n */\n private modelURL: string\n\n /**\n * Creates a new promise for tracking the ready state of the model.\n * @returns Promise that resolves when the model is loaded (true) or fails to load (false)\n */\n private createReadyPromise() {\n // If there's an existing promise reject it before it's replaced\n this._readyResolve?.(false)\n return new Promise<boolean>(resolve => {\n this._readyResolve = resolve\n })\n }\n\n /**\n * Promise that resolves when the model is loaded.\n * Resolves to true on successful load, false on failure.\n */\n ready: Promise<boolean> = this.createReadyPromise()\n\n /**\n * Updates the properties of this static 3D element.\n * Handles special case for modelURL changes by resetting the ready promise.\n * @param properties Partial set of properties to update\n * @returns Promise resolving when the update is complete\n */\n async updateProperties(\n properties: Partial<SpatializedStatic3DElementProperties>,\n ) {\n if (properties.modelURL !== undefined) {\n if (this.modelURL !== properties.modelURL) {\n this.modelURL = properties.modelURL\n this.ready = this.createReadyPromise()\n }\n }\n return new UpdateSpatializedStatic3DElementProperties(\n this,\n properties,\n ).execute()\n }\n\n /**\n * Processes events received from the WebSpatial environment.\n * Handles model loading events in addition to base spatial events.\n * @param data The event data received from the WebSpatial system\n */\n override onReceiveEvent(data: { type: SpatialWebMsgType }) {\n if (data.type === SpatialWebMsgType.modelloaded) {\n // Handle successful model loading\n this._onLoadCallback?.()\n this._readyResolve?.(true)\n } else if (data.type === SpatialWebMsgType.modelloadfailed) {\n // Handle model loading failure\n this._onLoadFailureCallback?.()\n this._readyResolve?.(false)\n } else {\n // Handle other spatial events using the base class implementation\n super.onReceiveEvent(data as any)\n }\n }\n\n /**\n * Callback function for successful model loading.\n */\n private _onLoadCallback?: () => void\n\n /**\n * Sets the callback function for successful model loading.\n * @param callback Function to call when the model is loaded successfully\n */\n set onLoadCallback(callback: undefined | (() => void)) {\n this._onLoadCallback = callback\n }\n\n /**\n * Callback function for model loading failure.\n */\n private _onLoadFailureCallback?: undefined | (() => void)\n\n /**\n * Sets the callback function for model loading failure.\n * @param callback Function to call when the model fails to load\n */\n set onLoadFailureCallback(callback: undefined | (() => void)) {\n this._onLoadFailureCallback = callback\n }\n\n updateModelTransform(transform: DOMMatrixReadOnly) {\n const modelTransform = Array.from(transform.toFloat64Array())\n this.updateProperties({ modelTransform })\n }\n}\n","import {\n AddEntityToDynamic3DCommand,\n SetParentForEntityCommand,\n UpdateSpatializedDynamic3DElementProperties,\n} from './JSBCommand'\nimport { SpatialEntity } from './reality'\nimport { SpatializedElement } from './SpatializedElement'\nimport {\n SpatialEntityEventType,\n SpatialEntityOrReality,\n SpatializedElementProperties,\n} from './types/types'\n\nexport class SpatializedDynamic3DElement extends SpatializedElement {\n children: SpatialEntityOrReality[] = []\n events: Record<string, (data: any) => void> = {}\n\n constructor(id: string) {\n super(id)\n }\n\n async addEntity(entity: SpatialEntity) {\n const ans = new SetParentForEntityCommand(entity.id, this.id).execute()\n this.children.push(entity)\n entity.parent = this\n return ans\n }\n\n addEvent(type: SpatialEntityEventType, callback: (data: any) => void) {\n this.events[type] = callback\n }\n\n removeEvent(eventName: SpatialEntityEventType) {\n if (this.events[eventName]) {\n delete this.events[eventName]\n }\n }\n\n dispatchEvent(evt: CustomEvent) {\n this.events[evt.type]?.(evt)\n }\n\n async updateProperties(properties: Partial<SpatializedElementProperties>) {\n return new UpdateSpatializedDynamic3DElementProperties(\n this,\n properties,\n ).execute()\n }\n}\n","import { SpatialObject } from '../SpatialObject'\nimport {\n CreateAttachmentEntityCommand,\n UpdateAttachmentEntityCommand,\n InitializeAttachmentCommand,\n} from '../JSBCommand'\nimport {\n AttachmentEntityOptions,\n AttachmentEntityUpdateOptions,\n} from '../types/types'\n\nexport class Attachment extends SpatialObject {\n constructor(\n id: string,\n private readonly windowProxy: WindowProxy,\n private options: AttachmentEntityOptions,\n ) {\n super(id)\n }\n\n getContainer(): HTMLElement {\n return (this.windowProxy as Window).document.body\n }\n\n getWindowProxy(): WindowProxy {\n return this.windowProxy\n }\n\n async update(options: AttachmentEntityUpdateOptions) {\n if (this.isDestroyed) return\n if (options.position) this.options.position = options.position\n if (options.size) this.options.size = options.size\n return new UpdateAttachmentEntityCommand(this.id, options).execute()\n }\n}\n\nexport async function createAttachmentEntity(\n options: AttachmentEntityOptions,\n): Promise<Attachment> {\n const result = await new CreateAttachmentEntityCommand(options).execute()\n if (!result.success) {\n throw new Error('createAttachmentEntity failed: ' + result?.errorMessage)\n }\n const { id, windowProxy } = result.data!\n await new InitializeAttachmentCommand(id, options).execute()\n return new Attachment(id, windowProxy, options)\n}\n","import {\n CreateModelComponentCommand,\n CreateModelAssetCommand,\n CreateSpatialEntityCommand,\n CreateSpatialGeometryCommand,\n CreateSpatialModelEntityCommand,\n CreateSpatialUnlitMaterialCommand,\n} from '../JSBCommand'\nimport {\n ModelComponentOptions,\n ModelAssetOptions,\n SpatialGeometryOptions,\n SpatialModelEntityCreationOptions,\n SpatialUnlitMaterialOptions,\n SpatialEntityUserData,\n} from '../types/types'\nimport { SpatialEntity, SpatialModelEntity } from './entity'\nimport { ModelComponent } from './component'\nimport { SpatialGeometry } from './geometry'\nimport { SpatialUnlitMaterial } from './material'\nimport { SpatialModelAsset } from './resource'\n\nexport async function createSpatialEntity(\n userData?: SpatialEntityUserData,\n): Promise<SpatialEntity> {\n const result = await new CreateSpatialEntityCommand(userData?.name).execute()\n if (!result.success) {\n throw new Error('createSpatialEntity failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new SpatialEntity(id, userData)\n }\n}\n\nexport async function createSpatialGeometry<T extends SpatialGeometry>(\n ctor: new (...args: any[]) => T,\n options: SpatialGeometryOptions,\n) {\n const result = await new CreateSpatialGeometryCommand(\n (ctor as any).type,\n options,\n ).execute()\n if (!result.success) {\n throw new Error('createSpatialGeometry failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new ctor(id, options) as T\n }\n}\n\nexport async function createSpatialUnlitMaterial(\n options: SpatialUnlitMaterialOptions,\n) {\n const result = await new CreateSpatialUnlitMaterialCommand(options).execute()\n if (!result.success) {\n throw new Error('createSpatialUnlitMaterial failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new SpatialUnlitMaterial(id, options)\n }\n}\n\nexport async function createModelComponent(options: ModelComponentOptions) {\n const result = await new CreateModelComponentCommand(options).execute()\n if (!result.success) {\n throw new Error('createModelComponent failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new ModelComponent(id, options)\n }\n}\n\nexport async function createSpatialModelEntity(\n options: SpatialModelEntityCreationOptions,\n userData?: SpatialEntityUserData,\n) {\n const result = await new CreateSpatialModelEntityCommand(options).execute()\n if (!result.success) {\n throw new Error('createSpatialModelEntity failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new SpatialModelEntity(id, options, userData)\n }\n}\n\nexport async function createModelAsset(options: ModelAssetOptions) {\n const result = await new CreateModelAssetCommand(options).execute()\n if (!result.success) {\n throw new Error('createModelAsset failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new SpatialModelAsset(id, options)\n }\n}\n","import {\n ConvertFromEntityToEntityCommand,\n ConvertFromEntityToSceneCommand,\n ConvertFromSceneToEntityCommand,\n SetParentForEntityCommand,\n} from './../../JSBCommand'\nimport {\n SpatialEntityEventType,\n SpatialEntityOrReality,\n SpatialEntityUserData,\n Vec3,\n} from '../../types/types'\nimport {\n AddComponentToEntityCommand,\n AddEntityToEntityCommand,\n RemoveEntityFromParentCommand,\n UpdateEntityEventCommand,\n UpdateEntityPropertiesCommand,\n} from '../../JSBCommand'\nimport { SpatialObject } from '../../SpatialObject'\nimport { SpatialEntityProperties } from '../../types/types'\nimport { SpatialComponent } from '../component/SpatialComponent'\nimport { SpatialWebEvent } from '../../SpatialWebEvent'\nimport { createSpatialEvent } from '../../SpatialWebEventCreator'\nimport {\n ObjectDestroyMsg,\n SpatialDragEndMsg,\n SpatialDragMsg,\n SpatialDragStartMsg,\n SpatialMagnifyEndMsg,\n SpatialMagnifyMsg,\n SpatialRotateEndMsg,\n SpatialRotateMsg,\n SpatialTapMsg,\n SpatialWebMsgType,\n} from '../../WebMsgCommand'\n\nexport class SpatialEntity extends SpatialObject {\n position: Vec3 = { x: 0, y: 0, z: 0 }\n rotation: Vec3 = { x: 0, y: 0, z: 0 }\n scale: Vec3 = { x: 1, y: 1, z: 1 }\n\n events: Record<string, (data: any) => void> = {}\n children: SpatialEntity[] = []\n parent: SpatialEntityOrReality | null = null\n private _enableInput: boolean = false\n\n get enableInput(): boolean {\n return this._enableInput\n }\n\n set enableInput(value: boolean) {\n // Why enabling only 'spatialtap' makes the entity interactive:\n // - On the native (Swift/RealityKit) side, SpatialEntity.updateGesture(type, isEnable)\n // toggles per-gesture flags. Then enableInteractive = enableTap || enableRotate || enableDrag || enableMagnify.\n // - As soon as any gesture (e.g., 'spatialtap') is enabled, enableInteractive becomes true and\n // InputTargetComponent is attached, making the entity targetable by targetedToAnyEntity().\n // - The view layer forwards hit gestures to the web, so enabling 'spatialtap' is sufficient to\n // make the entity targetable; enable additional gestures only when needed.\n if (this._enableInput === value) return\n this._enableInput = value\n void this.updateEntityEvent('spatialtap', value).catch(err => {\n console.error('enableInput updateEntityEvent failed', 'spatialtap', err)\n // Roll back local flag if the native toggle fails to keep web/native states consistent.\n // Otherwise, the web side would think the entity is interactive while RealityKit is not.\n if (this._enableInput === value) {\n this._enableInput = !value\n }\n })\n }\n constructor(\n id: string,\n public userData?: SpatialEntityUserData,\n ) {\n super(id)\n SpatialWebEvent.addEventReceiver(id, this.onReceiveEvent)\n }\n\n async addComponent(component: SpatialComponent) {\n return new AddComponentToEntityCommand(this, component).execute()\n }\n async setPosition(position: Vec3) {\n return this.updateTransform({ position })\n }\n async setRotation(rotation: Vec3) {\n return this.updateTransform({ rotation })\n }\n async setScale(scale: Vec3) {\n return this.updateTransform({ scale })\n }\n\n async addEntity(ent: SpatialEntity) {\n const ans = await new SetParentForEntityCommand(ent.id, this.id).execute()\n this.children.push(ent)\n ent.parent = this\n return ans\n }\n async removeFromParent() {\n const ans = await new SetParentForEntityCommand(\n this.id,\n undefined,\n ).execute()\n if (this.parent) {\n this.parent.children = this.parent.children.filter(\n child => child.id !== this.id,\n )\n this.parent = null\n }\n return ans\n }\n\n async updateTransform(properties: Partial<SpatialEntityProperties>) {\n this.position = properties.position ?? this.position\n this.rotation = properties.rotation ?? this.rotation\n this.scale = properties.scale ?? this.scale\n return new UpdateEntityPropertiesCommand(this, properties).execute()\n }\n\n async addEvent(type: SpatialEntityEventType, callback: (data: any) => void) {\n if (this.events[type]) {\n // replace if exist\n this.events[type] = callback\n } else {\n try {\n await this.updateEntityEvent(type, true)\n this.events[type] = callback\n } catch (error) {\n console.error('addEvent failed', type)\n }\n }\n }\n\n async removeEvent(eventName: SpatialEntityEventType) {\n if (this.events[eventName]) {\n delete this.events[eventName]\n try {\n await this.updateEntityEvent(eventName, false)\n } catch (error) {\n console.error('removeEvent failed', eventName)\n }\n }\n }\n\n async updateEntityEvent(\n eventName: SpatialEntityEventType,\n isEnable: boolean,\n ) {\n return new UpdateEntityEventCommand(this, eventName, isEnable).execute()\n }\n private onReceiveEvent = (\n data:\n | SpatialTapMsg\n | SpatialDragStartMsg\n | SpatialDragMsg\n | SpatialDragEndMsg\n | SpatialMagnifyMsg\n | SpatialMagnifyEndMsg\n | SpatialRotateMsg\n | SpatialRotateEndMsg\n | ObjectDestroyMsg,\n ) => {\n // console.log('SpatialEntityEvent', data)\n const { type } = data\n if (type === SpatialWebMsgType.objectdestroy) {\n this.isDestroyed = true\n }\n // tap\n else if (type === SpatialWebMsgType.spatialtap) {\n const evt = createSpatialEvent(SpatialWebMsgType.spatialtap, data.detail)\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialdragstart) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialdragstart,\n data.detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialdrag) {\n const evt = createSpatialEvent(SpatialWebMsgType.spatialdrag, data.detail)\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialdragend) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialdragend,\n data.detail,\n )\n this.dispatchEvent(evt)\n }\n // rotate\n else if (type === SpatialWebMsgType.spatialrotate) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialrotate,\n data.detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialrotateend) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialrotateend,\n data.detail,\n )\n this.dispatchEvent(evt)\n }\n // magnify\n else if (type === SpatialWebMsgType.spatialmagnify) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialmagnify,\n data.detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialmagnifyend) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialmagnifyend,\n data.detail,\n )\n this.dispatchEvent(evt)\n }\n }\n\n dispatchEvent(evt: CustomEvent) {\n // Set origin once at the first dispatch in the bubbling chain\n if (!(evt as any).__origin) {\n Object.defineProperty(evt, '__origin', { value: this, enumerable: false })\n }\n this.events[evt.type]?.(evt)\n if (evt.bubbles && !evt.cancelBubble) {\n if (this.parent) {\n this.parent.dispatchEvent(evt)\n }\n }\n }\n\n protected onDestroy(): void {\n SpatialWebEvent.removeEventReceiver(this.id)\n // handle children\n this.children.forEach(child => {\n child.parent = null\n })\n this.children = []\n // handle parent\n if (this.parent) {\n this.parent.children = this.parent.children.filter(\n child => child.id !== this.id,\n )\n this.parent = null\n }\n }\n // onUpdate(properties: SpatialEntityProperties) {\n // this.position = properties.position\n // this.rotation = properties.rotation\n // this.scale = properties.scale\n // }\n async convertFromEntityToEntity(\n fromEntityId: string,\n toEntityId: string,\n position: Vec3,\n ) {\n return new ConvertFromEntityToEntityCommand(\n fromEntityId,\n toEntityId,\n position,\n ).execute()\n }\n\n async convertFromEntityToScene(fromEntityId: string, position: Vec3) {\n return new ConvertFromEntityToSceneCommand(fromEntityId, position).execute()\n }\n async convertFromSceneToEntity(entityId: string, position: Vec3) {\n return new ConvertFromSceneToEntityCommand(entityId, position).execute()\n }\n}\n","import {\n SpatialEntityUserData,\n SpatialModelEntityCreationOptions,\n} from '../../types/types'\nimport { SpatialEntity } from './SpatialEntity'\n\nexport class SpatialModelEntity extends SpatialEntity {\n constructor(\n public id: string,\n public options?: SpatialModelEntityCreationOptions,\n public userData?: SpatialEntityUserData,\n ) {\n super(id, userData)\n }\n}\n","import { SpatialObject } from '../../SpatialObject'\nimport { SpatialWebEvent } from '../../SpatialWebEvent'\nimport { ObjectDestroyMsg, SpatialWebMsgType } from '../../WebMsgCommand'\n\nexport class SpatialComponent extends SpatialObject {\n constructor(id: string) {\n super(id)\n SpatialWebEvent.addEventReceiver(id, this.onReceiveEvent)\n }\n\n private onReceiveEvent = (data: ObjectDestroyMsg) => {\n const { type } = data\n if (type === SpatialWebMsgType.objectdestroy) {\n this.isDestroyed = true\n }\n }\n}\n","import { ModelComponentOptions } from '../../types/types'\nimport { SpatialComponent } from './SpatialComponent'\n\nexport class ModelComponent extends SpatialComponent {\n constructor(\n id: string,\n public options: ModelComponentOptions,\n ) {\n super(id)\n }\n}\n","import { UpdateUnlitMaterialProperties } from '../../JSBCommand'\nimport { SpatialUnlitMaterialOptions } from '../../types/types'\nimport { SpatialMaterial } from './SpatialMaterial'\n\nexport class SpatialUnlitMaterial extends SpatialMaterial {\n constructor(\n public id: string,\n public options: SpatialUnlitMaterialOptions,\n ) {\n super(id, 'unlit')\n }\n\n updateProperties(properties: Partial<SpatialUnlitMaterialOptions>) {\n return new UpdateUnlitMaterialProperties(this, properties).execute()\n }\n}\n","import { SpatialObject } from '../../SpatialObject'\nimport { SpatialMaterialType } from '../../types/types'\n\nexport abstract class SpatialMaterial extends SpatialObject {\n constructor(\n public id: string,\n public type: SpatialMaterialType,\n ) {\n super(id)\n this.type = type\n }\n\n abstract updateProperties(properties: any): void\n}\n","import { SpatialObject } from '../../SpatialObject'\nimport { ModelAssetOptions } from '../../types/types'\n\nexport class SpatialModelAsset extends SpatialObject {\n constructor(\n public id: string,\n public options: ModelAssetOptions,\n ) {\n super(id)\n }\n}\n","import { SpatialObject } from '../../SpatialObject'\nimport { SpatialGeometryOptions, SpatialGeometryType } from '../../types/types'\n\nexport class SpatialGeometry extends SpatialObject {\n static type: SpatialGeometryType\n constructor(\n public id: string,\n public options: SpatialGeometryOptions,\n ) {\n super(id)\n }\n}\n","import {\n SpatialBoxGeometryOptions,\n SpatialGeometryType,\n} from '../../types/types'\nimport { SpatialGeometry } from './SpatialGeometry'\n\nexport class SpatialBoxGeometry extends SpatialGeometry {\n static type: SpatialGeometryType = 'BoxGeometry'\n constructor(\n public id: string,\n public options: SpatialBoxGeometryOptions,\n ) {\n super(id, options)\n }\n}\n","import {\n SpatialGeometryType,\n SpatialSphereGeometryOptions,\n} from '../../types/types'\nimport { SpatialGeometry } from './SpatialGeometry'\n\nexport class SpatialSphereGeometry extends SpatialGeometry {\n static type: SpatialGeometryType = 'SphereGeometry'\n constructor(\n public id: string,\n public options: SpatialSphereGeometryOptions,\n ) {\n super(id, options)\n }\n}\n","import {\n SpatialGeometryType,\n SpatialCylinderGeometryOptions,\n} from '../../types/types'\nimport { SpatialGeometry } from './SpatialGeometry'\n\nexport class SpatialCylinderGeometry extends SpatialGeometry {\n static type: SpatialGeometryType = 'CylinderGeometry'\n constructor(\n public id: string,\n public options: SpatialCylinderGeometryOptions,\n ) {\n super(id, options)\n }\n}\n","import {\n SpatialGeometryType,\n SpatialPlaneGeometryOptions,\n} from '../../types/types'\nimport { SpatialGeometry } from './SpatialGeometry'\n\nexport class SpatialPlaneGeometry extends SpatialGeometry {\n static type: SpatialGeometryType = 'PlaneGeometry'\n constructor(\n public id: string,\n public options: SpatialPlaneGeometryOptions,\n ) {\n super(id, options)\n }\n}\n","import {\n SpatialGeometryType,\n SpatialConeGeometryOptions,\n} from '../../types/types'\nimport { SpatialGeometry } from './SpatialGeometry'\n\nexport class SpatialConeGeometry extends SpatialGeometry {\n static type: SpatialGeometryType = 'ConeGeometry'\n constructor(\n public id: string,\n public options: SpatialConeGeometryOptions,\n ) {\n super(id, options)\n }\n}\n","import { initScene } from './scene-polyfill'\nimport { SpatialScene } from './SpatialScene'\nimport { Spatialized2DElement } from './Spatialized2DElement'\nimport {\n createSpatialized2DElement,\n createSpatializedDynamic3DElement,\n} from './SpatializedElementCreator'\nimport { createSpatializedStatic3DElement } from './SpatializedElementCreator'\nimport { Attachment, createAttachmentEntity } from './reality/Attachment'\nimport { SpatializedStatic3DElement } from './SpatializedStatic3DElement'\nimport {\n ModelComponentOptions,\n ModelAssetOptions,\n SpatialBoxGeometryOptions,\n SpatialConeGeometryOptions,\n SpatialCylinderGeometryOptions,\n SpatialGeometryOptions,\n SpatialModelEntityCreationOptions,\n SpatialPlaneGeometryOptions,\n SpatialSceneCreationOptions,\n SpatialSphereGeometryOptions,\n SpatialUnlitMaterialOptions,\n SpatialEntityUserData,\n AttachmentEntityOptions,\n} from './types/types'\nimport { SpatializedDynamic3DElement } from './SpatializedDynamic3DElement'\nimport { SpatialEntity } from './reality/entity/SpatialEntity'\nimport {\n createModelAsset,\n createModelComponent,\n createSpatialEntity,\n createSpatialGeometry,\n createSpatialModelEntity,\n createSpatialUnlitMaterial,\n} from './reality/realityCreator'\nimport {\n SpatialBoxGeometry,\n SpatialPlaneGeometry,\n SpatialSphereGeometry,\n SpatialConeGeometry,\n SpatialCylinderGeometry,\n} from './reality'\n\n/**\n * Session used to establish a connection to the spatial renderer of the system.\n * All spatial resources must be created through this session object.\n * This class serves as the main factory for creating spatial elements and geometries.\n */\nexport class SpatialSession {\n /**\n * Gets the singleton instance of the spatial scene.\n * The spatial scene is the root container for all spatial elements.\n * @returns The SpatialScene singleton instance\n */\n getSpatialScene(): SpatialScene {\n return SpatialScene.getInstance()\n }\n\n /**\n * Creates a new 2D element that can be spatialized in the 3D environment.\n * 2D elements represent HTML content that can be positioned in 3D space.\n * @returns Promise resolving to a new Spatialized2DElement instance\n */\n createSpatialized2DElement(): Promise<Spatialized2DElement> {\n return createSpatialized2DElement()\n }\n\n /**\n * Creates a new static 3D element with an optional model URL.\n * Static 3D elements represent pre-built 3D models that can be loaded from a URL.\n * @param modelURL Optional URL to the 3D model to load\n * @returns Promise resolving to a new SpatializedStatic3DElement instance\n */\n createSpatializedStatic3DElement(\n modelURL: string,\n ): Promise<SpatializedStatic3DElement> {\n return createSpatializedStatic3DElement(modelURL)\n }\n\n /**\n * Initializes the spatial scene with custom configuration.\n * This is a reference to the initScene function from scene-polyfill.\n */\n initScene = initScene\n\n /**\n * Creates a new dynamic 3D element that can be manipulated at runtime.\n * Dynamic 3D elements allow for programmatic creation and modification of 3D content.\n * @returns Promise resolving to a new SpatializedDynamic3DElement instance\n */\n createSpatializedDynamic3DElement(): Promise<SpatializedDynamic3DElement> {\n return createSpatializedDynamic3DElement()\n }\n\n /**\n * Creates a new spatial entity with an optional name.\n * Entities are the basic building blocks for creating custom 3D content.\n * @param name Optional name for the entity\n * @returns Promise resolving to a new SpatialEntity instance\n */\n createEntity(userData?: SpatialEntityUserData): Promise<SpatialEntity> {\n return createSpatialEntity(userData)\n }\n\n /**\n * Creates a box geometry with optional configuration.\n * @param options Configuration options for the box geometry\n * @returns Promise resolving to a new SpatialBoxGeometry instance\n */\n createBoxGeometry(options: SpatialBoxGeometryOptions = {}) {\n return createSpatialGeometry(SpatialBoxGeometry, options)\n }\n\n /**\n * Creates a plane geometry with optional configuration.\n * @param options Configuration options for the plane geometry\n * @returns Promise resolving to a new SpatialPlaneGeometry instance\n */\n createPlaneGeometry(options: SpatialPlaneGeometryOptions = {}) {\n return createSpatialGeometry(SpatialPlaneGeometry, options)\n }\n\n /**\n * Creates a sphere geometry with optional configuration.\n * @param options Configuration options for the sphere geometry\n * @returns Promise resolving to a new SpatialSphereGeometry instance\n */\n createSphereGeometry(options: SpatialSphereGeometryOptions = {}) {\n return createSpatialGeometry(SpatialSphereGeometry, options)\n }\n\n /**\n * Creates a cone geometry with the specified configuration.\n * @param options Configuration options for the cone geometry\n * @returns Promise resolving to a new SpatialConeGeometry instance\n */\n createConeGeometry(options: SpatialConeGeometryOptions) {\n return createSpatialGeometry(SpatialConeGeometry, options)\n }\n\n /**\n * Creates a cylinder geometry with the specified configuration.\n * @param options Configuration options for the cylinder geometry\n * @returns Promise resolving to a new SpatialCylinderGeometry instance\n */\n createCylinderGeometry(options: SpatialCylinderGeometryOptions) {\n return createSpatialGeometry(SpatialCylinderGeometry, options)\n }\n\n /**\n * Creates a model component with the specified configuration.\n * Model components are used to add 3D model rendering capabilities to entities.\n * @param options Configuration options for the model component\n * @returns Promise resolving to a new ModelComponent instance\n */\n createModelComponent(options: ModelComponentOptions) {\n return createModelComponent(options)\n }\n\n /**\n * Creates an unlit material with the specified configuration.\n * Unlit materials don't respond to lighting in the scene.\n * @param options Configuration options for the unlit material\n * @returns Promise resolving to a new SpatialUnlitMaterial instance\n */\n createUnlitMaterial(options: SpatialUnlitMaterialOptions) {\n return createSpatialUnlitMaterial(options)\n }\n\n /**\n * Creates a model asset with the specified configuration.\n * Model assets represent 3D model resources that can be used by entities.\n * @param options Configuration options for the model asset\n * @returns Promise resolving to a new SpatialModelAsset instance\n */\n createModelAsset(options: ModelAssetOptions) {\n return createModelAsset(options)\n }\n\n /**\n * Creates a spatial model entity with the specified configuration.\n * This is a convenience method for creating an entity with a model component.\n * @param options Configuration options for the spatial model entity\n * @returns Promise resolving to a new SpatialModelEntity instance\n */\n createSpatialModelEntity(\n options: SpatialModelEntityCreationOptions,\n userData?: SpatialEntityUserData,\n ) {\n return createSpatialModelEntity(options, userData)\n }\n\n /**\n * Creates an attachment entity that renders 2D HTML content as a child\n * of a 3D entity in the scene graph.\n * @param options Configuration options including parent entity ID, position, and size\n * @returns Promise resolving to a new Attachment instance\n */\n createAttachmentEntity(\n options: AttachmentEntityOptions,\n ): Promise<Attachment> {\n return createAttachmentEntity(options)\n }\n}\n","import { SpatialSession } from './SpatialSession'\nimport { SpatialWebEvent } from './SpatialWebEvent'\n\n/**\n * Base object designed to be placed on navigator.spatial to mirror navigator.xr for webxr.\n * This is the main entry point for the WebSpatial SDK, providing access to spatial capabilities.\n */\nexport class Spatial {\n private wsAppShellVersionFromUA: string | null | undefined\n\n /**\n * Requests a spatial session object from the browser.\n * This is the primary method to initialize spatial functionality.\n * @returns The SpatialSession instance or null if not available in the current browser\n * [TODO] discuss implications of this not being async\n */\n requestSession() {\n if (this.runInSpatialWeb()) {\n SpatialWebEvent.init()\n return new SpatialSession()\n } else {\n return null\n }\n }\n\n /**\n * Checks if the current page is running in a spatial web environment.\n * This method detects if the application is running in a WebSpatial-compatible browser.\n * @returns True if running in a spatial web environment, false otherwise\n */\n runInSpatialWeb() {\n if (navigator.userAgent.indexOf('WebSpatial/') > 0) {\n return true\n }\n return false\n }\n\n getShellVersionFromUA(): string | null {\n if (this.wsAppShellVersionFromUA !== undefined) {\n return this.wsAppShellVersionFromUA\n }\n if (\n typeof navigator === 'undefined' ||\n typeof navigator.userAgent !== 'string'\n ) {\n this.wsAppShellVersionFromUA = null\n return null\n }\n\n const match = navigator.userAgent.match(\n /WSAppShell\\/(\\d+(?:\\.\\d+){2}(?:[-+][0-9A-Za-z.-]+)*)/,\n )\n this.wsAppShellVersionFromUA = match ? match[1] : '1.3.0'\n return this.wsAppShellVersionFromUA\n }\n\n /** @deprecated\n * Checks if WebSpatial is supported in the current environment.\n * Verifies compatibility between native and client versions.\n * @returns True if web spatial is supported by this webpage\n */\n isSupported() {\n return true\n }\n\n /** @deprecated\n * Gets the native WebSpatial version from the browser environment.\n * The version format follows semantic versioning (x.x.x).\n * @returns Native version string in format \"x.x.x\"\n */\n getNativeVersion() {\n if (window.__WebSpatialData && window.__WebSpatialData.getNativeVersion) {\n return window.__WebSpatialData.getNativeVersion()\n }\n return window.WebSpatailNativeVersion === 'WS_SHELL_VERSION'\n ? this.getClientVersion()\n : window.WebSpatailNativeVersion\n }\n\n /** @deprecated\n * Gets the client SDK version.\n * The version format follows semantic versioning (x.x.x).\n * @returns Client SDK version string in format \"x.x.x\"\n */\n getClientVersion() {\n // @ts-ignore\n return __WEBSPATIAL_CORE_SDK_VERSION__\n }\n}\n","import { SpatialWebEvent } from './SpatialWebEvent'\nexport type PhysicalMetricsValueShape = {\n meterToPtUnscaled: number\n meterToPtScaled: number\n}\n\ntype WorldScalingCompensation = 'unscaled' | 'scaled'\n\ntype ConvertOption = { worldScalingCompensation: WorldScalingCompensation }\n\n// Fallback calibration: 1 meter ≈ 1360 pt for both scaled and unscaled modes.\n// This baseline ensures pointToPhysical(1360) === 1 and physicalToPoint(1) === 1360\n// until native physical metrics are injected into window.__webspatialsdk__.physicalMetrics\n// and a 'WebSpatialPhysicalMetricsUpdate' event updates the snapshot at runtime.\nlet snapshot: PhysicalMetricsValueShape = {\n meterToPtUnscaled: 1360,\n meterToPtScaled: 1360,\n}\n\nfunction getWorldScalingCompensation(options?: ConvertOption) {\n return options?.worldScalingCompensation ?? 'scaled' // default to scaled\n}\n\n/**\n * Converts scene points (pt) to physical meters (m).\n *\n * @param point Points value to convert.\n * @param options Optional conversion options to select world scaling compensation.\n * @returns Physical length in meters.\n */\nexport function pointToPhysical(point: number, options?: ConvertOption) {\n updateValue()\n const compensation = getWorldScalingCompensation(options)\n if (compensation === 'unscaled') {\n return point / snapshot.meterToPtUnscaled\n }\n return point / snapshot.meterToPtScaled\n}\n\n/**\n * Converts physical meters (m) to scene points (pt).\n *\n * @param physical Physical length in meters to convert.\n * @param options Optional conversion options to select world scaling compensation.\n * @returns Points length in the scene.\n */\nexport function physicalToPoint(physical: number, options?: ConvertOption) {\n updateValue()\n const compensation = getWorldScalingCompensation(options)\n if (compensation === 'unscaled') {\n return physical * snapshot.meterToPtUnscaled\n }\n return physical * snapshot.meterToPtScaled\n}\n\nfunction updateValue() {\n // ssr protected\n if (typeof window === 'undefined') return\n const src = window.__webspatialsdk__?.physicalMetrics\n if (!src) return\n const next = {\n meterToPtScaled: src.meterToPtScaled ?? snapshot.meterToPtScaled,\n meterToPtUnscaled: src.meterToPtUnscaled ?? snapshot.meterToPtUnscaled,\n }\n // only update if there is a change\n if (\n next.meterToPtScaled !== snapshot.meterToPtScaled ||\n next.meterToPtUnscaled !== snapshot.meterToPtUnscaled\n ) {\n snapshot = next\n }\n}\n\n/**\n * Returns the current physical metrics used for conversions.\n *\n * @returns The current metrics snapshot `{ meterToPtUnscaled, meterToPtScaled }`.\n */\nexport function getValue(): PhysicalMetricsValueShape {\n updateValue()\n return snapshot\n}\n\n/**\n * Subscribes to physical metrics changes.\n *\n * @param cb Callback invoked when metrics update is detected.\n * @returns Unsubscribe function to remove the listener.\n */\nexport function subscribe(cb: () => void) {\n // ssr protected\n if (typeof window === 'undefined') return () => {}\n const handler = () => {\n cb()\n }\n // receive metrics update from native via SpatialWebEvent, id: \"window\"\n SpatialWebEvent.addEventReceiver('window', handler)\n return () => {\n SpatialWebEvent.removeEventReceiver('window')\n }\n}\n","export { SpatialObject } from './SpatialObject'\nexport { Spatial } from './Spatial'\nexport { SpatialSession } from './SpatialSession'\nexport { SpatialScene } from './SpatialScene'\nexport { SpatializedElement } from './SpatializedElement'\nexport { Spatialized2DElement } from './Spatialized2DElement'\nexport { SpatializedStatic3DElement } from './SpatializedStatic3DElement'\nexport { SpatializedDynamic3DElement } from './SpatializedDynamic3DElement'\nexport * as PhysicalMetrics from './physicalMetrics'\n\nexport * from './reality'\nexport * from './types/types'\nexport * from './types/global.d'\n\n// side effects\nimport { injectSceneHook } from './scene-polyfill'\nimport { isSSREnv } from './ssr-polyfill'\nimport { spatialWindowPolyfill } from './spatial-window-polyfill'\n\nexport { isSSREnv }\n\nif (!isSSREnv() && navigator.userAgent.indexOf('WebSpatial/') > 0) {\n injectSceneHook()\n spatialWindowPolyfill()\n}\n","import { parseCornerRadius } from './utils'\nimport { Spatial } from './Spatial'\nimport { SpatialSession } from './SpatialSession'\nimport { BackgroundMaterialType } from './types/types'\n\nconst spatial = new Spatial()\nlet session: SpatialSession | undefined = undefined\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 session?.getSpatialScene()?.updateSpatialProperties({\n material: backgroundMaterial as BackgroundMaterialType,\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}\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 session?.getSpatialScene()?.updateSpatialProperties({\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 session?.getSpatialScene().updateSpatialProperties({\n opacity,\n })\n}\n\nfunction checkOpacity() {\n const computedStyle = getComputedStyle(document.documentElement)\n const opacity = parseFloat(computedStyle.getPropertyValue('opacity'))\n setOpacity(opacity)\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 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(checkCSSProperties)\n\n headObserver.observe(document.head, { childList: true, subtree: true })\n}\n\nfunction checkCSSProperties() {\n checkHtmlBackgroundMaterial()\n checkCornerRadius()\n checkOpacity()\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 async function spatialWindowPolyfill() {\n if (!spatial.runInSpatialWeb()) {\n return\n }\n\n session = await spatial.requestSession()!\n\n if (document.readyState === 'complete') {\n checkCSSProperties()\n } else {\n window.addEventListener('load', () => {\n checkCSSProperties()\n })\n }\n\n hijackDocumentElementStyle()\n monitorExternalStyleChange()\n monitorHTMLAttributeChange()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAM,OAEO;AAFb;AAAA;AAAA;AAAA,IAAM,QAAQ,OAAO,WAAW;AAEzB,IAAM,WAAW,MAAM;AAAA;AAAA;;;ACF9B,IAMa;AANb;AAAA;AAAA;AAMO,IAAM,cAAN,MAA6C;AAAA,MAClD,QAAQ,KAAa,KAAqC;AACxD,eAAO,QAAQ,QAAQ;AAAA,UACrB,SAAS;AAAA,UACT,MAAM;AAAA,UACN,WAAW;AAAA,UACX,cAAc;AAAA,QAChB,CAAC;AAAA,MACH;AAAA,MACA,uBACE,QACA,OACA,QACA,UACmC;AACnC,eAAO,QAAQ,QAAQ;AAAA,UACrB,SAAS;AAAA,UACT,MAAM;AAAA,UACN,WAAW;AAAA,UACX,cAAc;AAAA,QAChB,CAAC;AAAA,MACH;AAAA,MACA,2BACE,QACA,OACA,QACA,UACA,gBAC0B;AAC1B,eAAO;AAAA,UACL,SAAS;AAAA,UACT,MAAM;AAAA,UACN,WAAW;AAAA,UACX,cAAc;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA;AAAA;;;ACxCO,SAAS,qBAAqB,MAA0B;AAC7D,SAAO;AAAA,IACL,SAAS;AAAA,IACT;AAAA,IACA,WAAW;AAAA,IACX,cAAc;AAAA,EAChB;AACF;AAEO,SAAS,qBACd,WACA,eAAe,IACA;AACf,SAAO;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,IACN;AAAA,I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AC9B;AAAA,EACF;AAEA,YAAU,MAAM,QAAQ,eAAe;AAEvC,MAAI,SAAS,eAAe,YAAY;AACtC,uBAAmB;AAAA,EACrB,OAAO;AACL,WAAO,iBAAiB,QAAQ,MAAM;AACpC,yBAAmB;AAAA,IACrB,CAAC;AAAA,EACH;AAEA,6BAA2B;AAC3B,6BAA2B;AAC3B,6BAA2B;AAC7B;;;ADhKA,IAAI,CAAC,SAAS,KAAK,UAAU,UAAU,QAAQ,aAAa,IAAI,GAAG;AACjE,kBAAgB;AAChB,wBAAsB;AACxB;","names":["nextRequestId","requestId","MAX_ID","PuppeteerPlatform","XRPlatform","AndroidPlatform","VisionOSPlatform","SpatializedElementType","SpatialSceneState","window","defaultSceneConfig"]}
|
|
1
|
+
{"version":3,"sources":["../src/ssr-polyfill.ts","../src/platform-adapter/ssr/SSRPlatform.ts","../src/platform-adapter/CommandResultUtils.ts","../src/platform-adapter/puppeteer/PuppeteerPlatform.ts","../src/SpatialWebEvent.ts","../src/platform-adapter/pico-os/PicoOSPlatform.ts","../src/platform-adapter/android/AndroidPlatform.ts","../src/platform-adapter/vision-os/VisionOSPlatform.ts","../src/platform-adapter/index.ts","../src/utils.ts","../src/JSBCommand.ts","../src/SpatialObject.ts","../src/scene-polyfill.ts","../src/SpatialScene.ts","../src/types/types.ts","../src/physicalMetrics.ts","../src/SpatializedElementCreator.ts","../src/Spatialized2DElement.ts","../src/SpatializedElement.ts","../src/SpatialWebEventCreator.ts","../src/SpatializedStatic3DElement.ts","../src/SpatializedDynamic3DElement.ts","../src/reality/Attachment.ts","../src/reality/realityCreator.ts","../src/reality/entity/SpatialEntity.ts","../src/reality/entity/SpatialModelEntity.ts","../src/reality/component/SpatialComponent.ts","../src/reality/component/ModelComponent.ts","../src/reality/material/SpatialUnlitMaterial.ts","../src/reality/material/SpatialMaterial.ts","../src/reality/resource/SpatialModelAsset.ts","../src/reality/geometry/SpatialGeometry.ts","../src/reality/geometry/SpatialBoxGeometry.ts","../src/reality/geometry/SpatialSphereGeometry.ts","../src/reality/geometry/SpatialCylinderGeometry.ts","../src/reality/geometry/SpatialPlaneGeometry.ts","../src/reality/geometry/SpatialConeGeometry.ts","../src/SpatialSession.ts","../src/Spatial.ts","../src/index.ts","../src/spatial-window-polyfill.ts"],"sourcesContent":["const isSSR = typeof window === 'undefined'\n\nexport const isSSREnv = () => isSSR\n","import {\n CommandResult,\n PlatformAbility,\n WebSpatialProtocolResult,\n} from '../interface'\n\nexport class SSRPlatform implements PlatformAbility {\n callJSB(cmd: string, msg: string): Promise<CommandResult> {\n return Promise.resolve({\n success: true,\n data: undefined,\n errorCode: undefined,\n errorMessage: undefined,\n })\n }\n callWebSpatialProtocol(\n schema: string,\n query?: string,\n target?: string,\n features?: string,\n ): Promise<WebSpatialProtocolResult> {\n return Promise.resolve({\n success: true,\n data: undefined,\n errorCode: undefined,\n errorMessage: undefined,\n })\n }\n callWebSpatialProtocolSync(\n schema: string,\n query?: string,\n target?: string,\n features?: string,\n resultCallback?: (result: CommandResult) => void,\n ): WebSpatialProtocolResult {\n return {\n success: true,\n data: undefined,\n errorCode: undefined,\n errorMessage: undefined,\n }\n }\n}\n","import { CommandResult } from './interface'\n\nexport function CommandResultSuccess(data: any): CommandResult {\n return {\n success: true,\n data,\n errorCode: '',\n errorMessage: '',\n }\n}\n\nexport function CommandResultFailure(\n errorCode: string,\n errorMessage = '',\n): CommandResult {\n return {\n success: false,\n data: undefined,\n errorCode,\n errorMessage,\n }\n}\n","import { PlatformAbility, CommandResult } from '../interface'\nimport {\n CommandResultFailure,\n CommandResultSuccess,\n} from '../CommandResultUtils'\n\n// add window interface for JSB call\ndeclare global {\n interface Window {\n __handleJSBMessage: (message: string) => any\n SpatialId?: string\n }\n\n interface HTMLIFrameElement {\n spatialId?: string\n webSpatialId?: string\n }\n}\n\ntype JSBError = {\n message: string\n}\n\nconsole.log('PuppeteerPlatform')\n\nexport class PuppeteerPlatform implements PlatformAbility {\n // store iframe instance\n private iframeRegistry: Map<string, HTMLIFrameElement> = new Map()\n\n constructor() {}\n\n callJSB(cmd: string, msg: string): Promise<CommandResult> {\n return new Promise(resolve => {\n try {\n // check __handleJSBMessage exist\n if (window.__handleJSBMessage) {\n try {\n console.log(` core-sdk Puppeteer Platform: callJSB: ${cmd}::${msg}`)\n const result = window.__handleJSBMessage(`${cmd}::${msg}`)\n console.log(\n ` core-sdk Puppeteer Platform callJSB result: ${result}`,\n )\n resolve(CommandResultSuccess(result))\n } catch (err) {\n resolve(CommandResultFailure('500', 'JSB execution error'))\n }\n } else {\n // if not exist, return default result\n resolve(CommandResultSuccess('ok'))\n }\n } catch (error: unknown) {\n console.error(\n `PuppeteerPlatform cmd Error: ${cmd}, msg: ${msg} error: ${error}`,\n )\n resolve(CommandResultFailure('500', 'Internal error'))\n }\n })\n }\n\n /**\n * Synchronously create Spatialized2DElement to Puppeteer Runner\n */\n private createSpatializedElementSync(\n spatialId: string,\n webspatialUrl: string,\n ): void {\n try {\n console.log(\n `[Puppeteer Platform] Creating spatialized element sync with id: ${spatialId}, url: ${webspatialUrl}`,\n )\n // directly call Puppeteer Runner method to create element\n const win = window as any\n if (win.__handleJSBMessage) {\n // use simpler format to ensure JSBManager can correctly use our passed spatialId\n const createCommand = {\n id: spatialId,\n url: webspatialUrl,\n }\n win.__handleJSBMessage(\n `CreateSpatialized2DElement::${JSON.stringify(createCommand)}`,\n )\n }\n } catch (error) {\n console.error('Error creating spatialized element sync:', error)\n }\n }\n\n callWebSpatialProtocol(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): Promise<CommandResult> {\n console.log(\n `PuppeteerPlatform: Calling webspatial protocol: webspatial://${command}${query ? `?${query}` : ''}`,\n )\n return new Promise(resolve => {\n try {\n // create complete webspatial URL\n const webspatialUrl = `webspatial://${command}${query ? `?${query}` : ''}`\n // use iframe to create new window\n const { spatialId, iframe, windowProxy } = this.createIframeWindow(\n webspatialUrl,\n target,\n features,\n )\n\n // 对于createSpatialized2DElement命令,同步创建元素\n if (command === 'createSpatialized2DElement') {\n this.createSpatializedElementSync(spatialId, webspatialUrl)\n }\n console.log(\n `[Puppeteer Platform] iframe created with spatialId: ${spatialId}`,\n )\n // store iframe instance\n this.iframeRegistry.set(spatialId, iframe)\n resolve(CommandResultSuccess({ windowProxy, id: spatialId }))\n } catch (error) {\n console.error('Error calling webspatial protocol:', error)\n resolve(\n CommandResultFailure('500', 'Failed to call webspatial protocol'),\n )\n }\n })\n }\n\n callWebSpatialProtocolSync(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): CommandResult {\n try {\n // create complete webspatial URL\n const webspatialUrl = `webspatial://${command}${query ? `?${query}` : ''}`\n console.log(`Calling webspatial protocol sync: ${webspatialUrl}`)\n\n // 使用iframe创建新窗口\n const { spatialId, iframe, windowProxy } = this.createIframeWindow(\n webspatialUrl,\n target,\n features,\n )\n\n // 对于createSpatialized2DElement命令,同步创建元素\n if (command === 'createSpatialized2DElement') {\n this.createSpatializedElementSync(spatialId, webspatialUrl)\n }\n\n // store iframe instance\n this.iframeRegistry.set(spatialId, iframe)\n\n return CommandResultSuccess({ windowProxy, id: spatialId })\n } catch (error) {\n console.error('Error calling webspatial protocol sync:', error)\n return CommandResultFailure(\n '500',\n 'Failed to call webspatial protocol sync',\n )\n }\n }\n\n /**\n * Synchronously create iframe-based window\n */\n private createIframeWindow(url: string, target?: string, features?: string) {\n // create iframe element\n const iframe = document.createElement('iframe')\n\n // set iframe attributes\n iframe.style.border = 'none'\n iframe.style.display = 'none'\n iframe.style.width = '100%'\n iframe.style.height = '100%'\n\n // set iframe id\n const spatialId = this.generateUUID()\n iframe.spatialId = spatialId\n iframe.id = `spatial-iframe-${spatialId}`\n\n // parse features parameter\n const featuresObj = this.parseFeatures(features || '')\n\n // set iframe styles based on features\n if (featuresObj.width) {\n iframe.style.width = featuresObj.width\n }\n if (featuresObj.height) {\n iframe.style.height = featuresObj.height\n }\n if (featuresObj.left) {\n iframe.style.left = featuresObj.left\n iframe.style.position = 'absolute'\n }\n if (featuresObj.top) {\n iframe.style.top = featuresObj.top\n iframe.style.position = 'absolute'\n }\n\n // add iframe to DOM\n document.body.appendChild(iframe)\n\n // create enhanced windowProxy object\n const windowProxy = this.createEnhancedWindowProxy(iframe, url, spatialId)\n\n // set iframe src\n iframe.src = 'about:blank'\n\n console.log(\n `PuppeteerPlatform created iframe window with spatialId: ${spatialId}, URL: ${url}`,\n )\n\n // initialize iframe content\n this.initializeIframeContent(iframe, url, spatialId)\n\n return { spatialId, iframe, windowProxy }\n }\n\n /**\n * create enhanced windowProxy object\n */\n private createEnhancedWindowProxy(\n iframe: HTMLIFrameElement,\n url: string,\n spatialId: string,\n ) {\n // create enhanced windowProxy object\n return {\n // basic properties\n location: {\n href: url,\n toString: () => url,\n reload: () => {\n if (iframe.contentWindow) {\n iframe.contentWindow.location.reload()\n }\n },\n },\n navigator: {\n userAgent: `Mozilla/5.0 (WebKit) SpatialId/${spatialId}`,\n },\n\n // methods\n close: () => {\n console.log(`Closing iframe with spatialId: ${spatialId}`)\n iframe.remove()\n this.iframeRegistry.delete(spatialId)\n },\n\n // document access\n document: iframe.contentDocument || ({} as Document),\n contentWindow: iframe.contentWindow || ({} as Window),\n\n // add message communication method\n postMessage: (message: any, targetOrigin?: string) => {\n if (iframe.contentWindow) {\n iframe.contentWindow.postMessage(message, targetOrigin || '*')\n }\n },\n\n // add event listener method\n addEventListener: (\n type: string,\n listener: EventListenerOrEventListenerObject,\n ) => {\n if (iframe.contentWindow) {\n iframe.contentWindow.addEventListener(type, listener)\n }\n },\n\n removeEventListener: (\n type: string,\n listener: EventListenerOrEventListenerObject,\n ) => {\n if (iframe.contentWindow) {\n iframe.contentWindow.removeEventListener(type, listener)\n }\n },\n\n // execute JavaScript\n executeScript: (code: string): any => {\n if (iframe.contentWindow) {\n try {\n // use type assertion and safer way to execute script\n const win = iframe.contentWindow as any\n return win.eval(code)\n } catch (error) {\n console.error(\n `Error executing script in iframe ${spatialId}:`,\n error,\n )\n return null\n }\n }\n return null\n },\n\n // get iframe reference\n getIframe: () => iframe,\n\n // get spatialId\n getSpatialId: () => spatialId,\n }\n }\n\n /**\n * initialize iframe content\n */\n private initializeIframeContent(\n iframe: HTMLIFrameElement,\n url: string,\n spatialId: string,\n ): void {\n try {\n // wait for iframe to load\n iframe.onload = () => {\n try {\n // set iframe content\n const iframeContent = `\n // inject communication script\n window.webSpatialId = '${spatialId}';\n window.SpatialId = '${spatialId}';\n \n // override window.open to support webspatial protocol\n const originalOpen = window.open;\n window.open = function(url, target, features) {\n if (url && url.startsWith('webspatial://')) {\n // handle webspatial protocol through windowProxy\n const windowProxy = new Proxy({}, {\n get: function(target, prop) {\n if (prop === 'toString') {\n return function() { return url; };\n }\n return undefined;\n }\n });\n return windowProxy;\n }\n return originalOpen.call(window, url, target, features);\n };\n \n // set navigator.userAgent to identify webspatial environment\n Object.defineProperty(navigator, 'userAgent', {\n value: 'WebSpatial/1.0 ' + navigator.userAgent,\n configurable: true\n });\n \n // send loaded message\n window.parent.postMessage({\n type: 'iframe_loaded',\n spatialId: '${spatialId}',\n url: '${url}'\n }, '${window.location.origin}');\n \n // set message handler\n window.addEventListener('message', (event) => {\n if (event.origin !== window.parent.location.origin) return;\n \n const data = event.data;\n if (data && data.type === 'webspatial_command') {\n // handle command from parent window\n console.log('Received command in iframe from parent:', data.command);\n // add command handling logic here\n }\n });\n `\n\n // use document.write instead of eval for security and type compliance\n const doc = iframe.contentDocument\n if (doc) {\n doc.open()\n doc.write(`\n <!DOCTYPE html>\n <html>\n <head>\n <title>Spatial Iframe - ${spatialId}</title>\n <meta charset=\"UTF-8\">\n <style>\n body {\n margin: 0;\n padding: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n </style>\n </head>\n <body>\n <script>${iframeContent}</script>\n </body>\n </html>\n `)\n doc.close()\n }\n } catch (error) {\n console.error('Error initializing iframe content:', error)\n }\n }\n } catch (error) {\n console.error('Error setting up iframe:', error)\n }\n }\n\n /**\n * parse features string to object\n */\n private parseFeatures(features: string): Record<string, string> {\n const result: Record<string, string> = {}\n const pairs = features.split(',')\n\n pairs.forEach(pair => {\n const [key, value] = pair.split('=').map(s => s.trim())\n if (key && value) {\n result[key] = value\n }\n })\n\n return result\n }\n\n /**\n * send message to iframe with specified spatialId\n */\n public sendMessageToIframe(spatialId: string, message: any): boolean {\n const iframe = this.iframeRegistry.get(spatialId)\n if (iframe && iframe.contentWindow) {\n iframe.contentWindow.postMessage(message, window.location.origin)\n return true\n }\n return false\n }\n\n /**\n * get all active iframes\n */\n public getAllActiveIframes(): Array<{\n spatialId: string\n iframe: HTMLIFrameElement\n }> {\n const result: Array<{ spatialId: string; iframe: HTMLIFrameElement }> = []\n\n this.iframeRegistry.forEach((iframe, spatialId) => {\n result.push({ spatialId, iframe })\n })\n\n return result\n }\n\n /**\n * dispose all active iframes\n */\n public dispose(): void {\n // close all iframes\n this.iframeRegistry.forEach((iframe, spatialId) => {\n console.log(`Disposing iframe with spatialId: ${spatialId}`)\n iframe.remove()\n })\n this.iframeRegistry.clear()\n }\n\n // generate UUID function\n private generateUUID(): string {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(\n /[xy]/g,\n function (c) {\n const r = (Math.random() * 16) | 0\n const v = c === 'x' ? r : (r & 0x3) | 0x8\n return v.toString(16).toUpperCase()\n },\n )\n }\n}\n","interface SpatialWebEventData {\n id: string\n data: any\n}\n\nexport class SpatialWebEvent {\n static eventReceiver: Record<string, (data: any) => void> = {}\n static init() {\n // inject __SpatialWebEvent\n window.__SpatialWebEvent = ({ id, data }: SpatialWebEventData) => {\n // console.log('__SpatialWebEvent', id, data)\n SpatialWebEvent.eventReceiver[id]?.(data)\n }\n }\n\n static addEventReceiver(id: string, callback: (data: any) => void) {\n SpatialWebEvent.eventReceiver[id] = callback\n }\n\n static removeEventReceiver(id: string) {\n delete SpatialWebEvent.eventReceiver[id]\n }\n}\n","import { PlatformAbility, CommandResult } from '../interface'\nimport {\n CommandResultFailure,\n CommandResultSuccess,\n} from '../CommandResultUtils'\nimport { SpatialWebEvent } from '../../SpatialWebEvent'\n\ninterface JSBResponse {\n success: boolean\n data: any\n}\ntype JSBError = {\n code: string\n message: string\n}\n\nlet requestId = 0\n\nconst MAX_ID = 100000\n\nfunction nextRequestId() {\n requestId = (requestId + 1) % MAX_ID\n return `rId_${requestId}`\n}\n\n// Only supports Pico OS 6\nexport class PicoOSPlatform implements PlatformAbility {\n async callJSB(cmd: string, msg: string): Promise<CommandResult> {\n // swan JS Bridge interface only support sync invoking\n // in order to implement promise API, register every request by requestId and remove when resolve/reject.\n return new Promise((resolve, reject) => {\n try {\n const rId = nextRequestId()\n\n SpatialWebEvent.addEventReceiver(rId, (result: JSBResponse) => {\n SpatialWebEvent.removeEventReceiver(rId)\n if (result.success) {\n resolve(CommandResultSuccess(result.data))\n } else {\n const { code, message } = result.data as JSBError\n resolve(CommandResultFailure(code, message))\n }\n })\n\n const ans = window.webspatialBridge.postMessage(rId, cmd, msg)\n if (ans !== '') {\n SpatialWebEvent.removeEventReceiver(rId)\n // sync call\n const result = JSON.parse(ans) as JSBResponse\n if (result.success) {\n resolve(CommandResultSuccess(result.data))\n } else {\n const { code, message } = result.data as JSBError\n resolve(CommandResultFailure(code, message))\n }\n }\n } catch (error: unknown) {\n console.error(`SwanPlatform cmd: ${cmd}, msg: ${msg} error: ${error}`)\n const { code, message } = error as JSBError\n resolve(CommandResultFailure(code, message))\n }\n })\n }\n\n async callWebSpatialProtocol(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): Promise<CommandResult> {\n // Waiting for request to create spatial div\n return new Promise((resolve, reject) => {\n const createdId = nextRequestId()\n try {\n let windowProxy: any = null\n SpatialWebEvent.addEventReceiver(\n createdId,\n (result: { spatialId: string }) => {\n resolve(\n CommandResultSuccess({\n windowProxy: windowProxy,\n id: result.spatialId,\n }),\n )\n SpatialWebEvent.removeEventReceiver(createdId)\n },\n )\n windowProxy = this.openWindow(\n command,\n 'rid=' + createdId,\n target,\n features,\n ).windowProxy\n } catch (error: unknown) {\n const { code, message } = error as JSBError\n SpatialWebEvent.removeEventReceiver(createdId)\n resolve(CommandResultFailure(code, message))\n }\n })\n }\n\n callWebSpatialProtocolSync(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): CommandResult {\n const { spatialId: id = '', windowProxy } = this.openWindow(\n command,\n query,\n target,\n features,\n )\n\n return CommandResultSuccess({ windowProxy, id })\n }\n\n private openWindow(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ) {\n const windowProxy = window.open(\n `webspatial://${command}?${query || ''}`,\n target,\n features,\n )\n return { spatialId: '', windowProxy }\n }\n}\n","import { PlatformAbility, CommandResult } from '../interface'\nimport {\n CommandResultFailure,\n CommandResultSuccess,\n} from '../CommandResultUtils'\nimport { CheckWebViewCanCreateCommand } from '../../JSBCommand'\nimport { SpatialWebEvent } from '../../SpatialWebEvent'\n\ninterface JSBResponse {\n success: boolean\n data: any\n}\ntype JSBError = {\n code: string\n message: string\n}\n\nlet creatingElementCount = 0\n\nlet requestId = 0\n\nconst MAX_ID = 100000\n\nfunction nextRequestId() {\n requestId = (requestId + 1) % MAX_ID\n return `rId_${requestId}`\n}\n\nexport class AndroidPlatform implements PlatformAbility {\n async callJSB(cmd: string, msg: string): Promise<CommandResult> {\n // android JS Bridge interface only support sync invoking\n // in order to implement promise API, register every request by requestId and remove when resolve/reject.\n return new Promise((resolve, reject) => {\n try {\n const rId = nextRequestId()\n\n SpatialWebEvent.addEventReceiver(rId, (result: JSBResponse) => {\n SpatialWebEvent.removeEventReceiver(rId)\n if (result.success) {\n resolve(CommandResultSuccess(result.data))\n } else {\n const { code, message } = result.data as JSBError\n resolve(CommandResultFailure(code, message))\n }\n })\n\n const ans = window.webspatialBridge.postMessage(rId, cmd, msg)\n if (ans !== '') {\n SpatialWebEvent.removeEventReceiver(rId)\n // sync call\n const result = JSON.parse(ans) as JSBResponse\n if (result.success) {\n resolve(CommandResultSuccess(result.data))\n } else {\n const { code, message } = result.data as JSBError\n resolve(CommandResultFailure(code, message))\n }\n }\n } catch (error: unknown) {\n console.error(\n `AndroidPlatform cmd: ${cmd}, msg: ${msg} error: ${error}`,\n )\n const { code, message } = error as JSBError\n resolve(CommandResultFailure(code, message))\n }\n })\n }\n\n async callWebSpatialProtocol(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): Promise<CommandResult> {\n // Waiting for request to create spatial div\n await new Promise(resolve => setTimeout(resolve, 16 * creatingElementCount))\n // Count the current total number of created spatial div queues\n creatingElementCount++\n // Create a spatial div through JSB polling request\n let canCreate = await new CheckWebViewCanCreateCommand().execute()\n while (!canCreate.data.can) {\n await new Promise(resolve => setTimeout(resolve, 16))\n canCreate = await new CheckWebViewCanCreateCommand().execute()\n }\n // Request successful, call window.open\n const { windowProxy } = this.openWindow(command, query, target, features)\n // Polling waiting for windowProxy to convert into a real window object\n while (!windowProxy?.open) {\n await new Promise(resolve => setTimeout(resolve, 16))\n }\n // Make the page renderable through window.open\n windowProxy?.open('about:blank', '_self')\n // Polling to check if SpatialId injection is successful\n while (!windowProxy?.__SpatialId) {\n await new Promise(resolve => setTimeout(resolve, 16))\n }\n let spatialId = windowProxy?.__SpatialId\n creatingElementCount--\n return Promise.resolve(\n CommandResultSuccess({ windowProxy: windowProxy, id: spatialId }),\n )\n }\n\n callWebSpatialProtocolSync(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): CommandResult {\n const { spatialId: id = '', windowProxy } = this.openWindow(\n command,\n query,\n target,\n features,\n )\n\n return CommandResultSuccess({ windowProxy, id })\n }\n\n private openWindow(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ) {\n const windowProxy = window.open(\n `webspatial://${command}?${query || ''}`,\n target,\n features,\n )\n return { spatialId: '', windowProxy }\n }\n}\n","import { PlatformAbility, CommandResult } from '../interface'\nimport {\n CommandResultFailure,\n CommandResultSuccess,\n} from '../CommandResultUtils'\n\ntype JSBError = {\n message: string\n}\n\nexport class VisionOSPlatform implements PlatformAbility {\n async callJSB(cmd: string, msg: string): Promise<CommandResult> {\n try {\n const result = await window.webkit.messageHandlers.bridge.postMessage(\n `${cmd}::${msg}`,\n )\n return CommandResultSuccess(result)\n } catch (error: unknown) {\n // console.error(`VisionOSPlatform cmd: ${cmd}, msg: ${msg} error: ${error}`)\n const { code, message } = JSON.parse((error as JSBError).message)\n return CommandResultFailure(code, message)\n }\n }\n\n callWebSpatialProtocol(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): Promise<CommandResult> {\n const { spatialId: id, windowProxy } = this.openWindow(\n command,\n query,\n target,\n features,\n )\n return Promise.resolve(\n CommandResultSuccess({ windowProxy: windowProxy, id }),\n )\n }\n\n callWebSpatialProtocolSync(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): CommandResult {\n const { spatialId: id = '', windowProxy } = this.openWindow(\n command,\n query,\n target,\n features,\n )\n\n return CommandResultSuccess({ windowProxy, id })\n }\n\n private openWindow(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ) {\n const windowProxy = window.open(\n `webspatial://${command}?${query || ''}`,\n target,\n features,\n )\n const ua = windowProxy?.navigator.userAgent\n const spatialId = ua?.match(\n /\\b([0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})\\b/gi,\n )?.[0]\n\n return { spatialId, windowProxy }\n }\n}\n","import { isSSREnv } from '../ssr-polyfill'\nimport { PlatformAbility } from './interface'\nimport { SSRPlatform } from './ssr/SSRPlatform'\n\nfunction getWebSpatialVersion(ua: string): number[] | null {\n const match = ua.match(/WebSpatial\\/(\\d+)\\.(\\d+)\\.(\\d+)/)\n if (!match) {\n return null\n }\n return [Number(match[1]), Number(match[2]), Number(match[3])]\n}\n\nfunction isVersionGreater(a: number[] | null, b: number[]): boolean {\n if (!a) {\n return false\n }\n for (let index = 0; index < 3; index += 1) {\n const diff = a[index] - b[index]\n if (diff > 0) {\n return true\n }\n if (diff < 0) {\n return false\n }\n }\n return false\n}\n\nexport function createPlatform(): PlatformAbility {\n if (isSSREnv()) {\n return new SSRPlatform()\n }\n const userAgent = window.navigator.userAgent\n const webSpatialVersion = getWebSpatialVersion(userAgent)\n if (window.navigator.userAgent.includes('Puppeteer')) {\n const PuppeteerPlatform =\n require('./puppeteer/PuppeteerPlatform').PuppeteerPlatform\n return new PuppeteerPlatform()\n } else if (\n userAgent.includes('PicoWebApp') &&\n isVersionGreater(webSpatialVersion, [0, 0, 1])\n ) {\n const PicoOSPlatform = require('./pico-os/PicoOSPlatform').PicoOSPlatform\n return new PicoOSPlatform()\n } else if (userAgent.includes('Android') || userAgent.includes('Linux')) {\n const AndroidPlatform = require('./android/AndroidPlatform').AndroidPlatform\n return new AndroidPlatform()\n } else {\n const VisionOSPlatform =\n require('./vision-os/VisionOSPlatform').VisionOSPlatform\n return new VisionOSPlatform()\n }\n}\n","import { Vec3 } from './types/types'\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\n/**\n *\n * compose SRT matrix\n * @export\n * @param {Vec3} position meter\n * @param {Vec3} rotation degree\n * @param {Vec3} scale\n * @return {*} {DOMMatrix}\n */\nexport function composeSRT(position: Vec3, rotation: Vec3, scale: Vec3) {\n const { x: px, y: py, z: pz } = position\n const { x: rx, y: ry, z: rz } = rotation\n const { x: sx, y: sy, z: sz } = scale\n\n let m = new DOMMatrix()\n // https://drafts.fxtf.org/geometry/#immutable-transformation-methods\n // as these methods are post-multiplication, the order of transformations is reversed\n // we want SRT = T * R * S\n m = m.translate(px, py, pz)\n m = m.rotate(rx, ry, rz)\n m = m.scale(sx, sy, sz)\n return m\n}\n\n/**\n * Deep-clone a plain JSON-serializable object by value.\n *\n * Notes:\n * - Only use for data composed of primitives, arrays, and plain objects.\n * - Functions, Dates, Maps/Sets, DOM nodes, and circular structures are not supported.\n */\nexport function deepCloneJSON<T>(value: T): T {\n const sc = (globalThis as any).structuredClone as\n | ((v: any) => any)\n | undefined\n if (typeof sc === 'function') {\n try {\n return sc(value)\n } catch {\n // fall through to JSON method\n }\n }\n return JSON.parse(JSON.stringify(value))\n}\n","import { createPlatform } from './platform-adapter'\nimport { WebSpatialProtocolResult } from './platform-adapter/interface'\nimport { SpatialComponent } from './reality/component/SpatialComponent'\nimport { SpatialEntity } from './reality/entity/SpatialEntity'\nimport { SpatialMaterial } from './reality/material/SpatialMaterial'\nimport { SpatializedDynamic3DElement } from './SpatializedDynamic3DElement'\nimport { SpatializedElement } from './SpatializedElement'\nimport { SpatialObject } from './SpatialObject'\n\nimport {\n Spatialized2DElementProperties,\n SpatializedElementProperties,\n SpatializedStatic3DElementProperties,\n SpatialSceneProperties,\n SpatialSceneCreationOptions,\n SpatialUnlitMaterialOptions,\n SpatialGeometryOptions,\n SpatialGeometryType,\n ModelComponentOptions,\n SpatialEntityProperties,\n ModelAssetOptions,\n SpatialModelEntityCreationOptions,\n SpatialEntityEventType,\n Vec3,\n AttachmentEntityOptions,\n AttachmentEntityUpdateOptions,\n ModelSource,\n} from './types/types'\nimport { SpatialSceneCreationOptionsInternal } from './types/internal'\nimport { composeSRT } from './utils'\n\nconst platform = createPlatform()\n\nabstract class JSBCommand {\n commandType: string = ''\n protected abstract getParams(): Record<string, any> | undefined\n\n async execute() {\n const param = this.getParams()\n const msg = param ? JSON.stringify(param) : ''\n return platform.callJSB(this.commandType, msg)\n }\n}\n\nexport class UpdateEntityPropertiesCommand extends JSBCommand {\n commandType = 'UpdateEntityProperties'\n\n constructor(\n public entity: SpatialEntity,\n public properties: Partial<SpatialEntityProperties>,\n ) {\n super()\n }\n\n protected getParams() {\n const transform = composeSRT(\n this.properties.position ?? this.entity.position,\n this.properties.rotation ?? this.entity.rotation,\n this.properties.scale ?? this.entity.scale,\n ).toFloat64Array()\n return {\n entityId: this.entity.id,\n transform,\n }\n }\n}\n\nexport class UpdateEntityEventCommand extends JSBCommand {\n commandType = 'UpdateEntityEvent'\n\n constructor(\n public entity: SpatialEntity,\n public type: SpatialEntityEventType,\n public isEnable: boolean,\n ) {\n super()\n }\n\n protected getParams() {\n return {\n type: this.type,\n entityId: this.entity.id,\n isEnable: this.isEnable,\n }\n }\n}\n\n// todo: to be used in SpatialEntity\nexport class UpdateEntityEventsCommand extends JSBCommand {\n // let types:[String:Bool]\n // let entityId:String\n constructor(\n public entity: SpatialEntity,\n public types: Record<SpatialEntityEventType, boolean>,\n ) {\n super()\n }\n\n protected getParams() {\n return {\n entityId: this.entity.id,\n types: this.types,\n }\n }\n}\n\nexport class UpdateSpatialSceneProperties extends JSBCommand {\n properties: Partial<SpatialSceneProperties>\n commandType = 'UpdateSpatialSceneProperties'\n\n constructor(properties: Partial<SpatialSceneProperties>) {\n super()\n this.properties = properties\n }\n\n protected getParams() {\n return this.properties\n }\n}\n\nexport class UpdateSceneConfig extends JSBCommand {\n config: SpatialSceneCreationOptions\n commandType = 'UpdateSceneConfig'\n\n constructor(config: SpatialSceneCreationOptions) {\n super()\n this.config = config\n }\n\n protected getParams(): Record<string, any> | undefined {\n return { config: this.config }\n }\n}\n\nexport class FocusScene extends JSBCommand {\n commandType = 'FocusScene'\n\n constructor(public id: string) {\n super()\n }\n\n protected getParams(): Record<string, any> | undefined {\n return { id: this.id }\n }\n}\n\nexport class GetSpatialSceneState extends JSBCommand {\n commandType = 'GetSpatialSceneState'\n\n constructor() {\n super()\n }\n\n protected getParams(): Record<string, any> | undefined {\n return {}\n }\n}\n\nexport abstract class SpatializedElementCommand extends JSBCommand {\n constructor(readonly spatialObject: SpatialObject) {\n super()\n }\n\n protected getParams() {\n const extraParams = this.getExtraParams()\n return { id: this.spatialObject.id, ...extraParams }\n }\n\n protected abstract getExtraParams(): Record<string, any> | undefined\n}\n\nexport class UpdateSpatialized2DElementProperties extends SpatializedElementCommand {\n properties: Partial<Spatialized2DElementProperties>\n commandType = 'UpdateSpatialized2DElementProperties'\n\n constructor(\n spatialObject: SpatialObject,\n properties: Partial<SpatializedElementProperties>,\n ) {\n super(spatialObject)\n this.properties = properties\n }\n\n protected getExtraParams() {\n return this.properties\n }\n}\n\nexport class UpdateSpatializedDynamic3DElementProperties extends SpatializedElementCommand {\n properties: Partial<Spatialized2DElementProperties>\n commandType = 'UpdateSpatializedDynamic3DElementProperties'\n\n constructor(\n spatialObject: SpatialObject,\n properties: Partial<SpatializedElementProperties>,\n ) {\n super(spatialObject)\n this.properties = properties\n }\n\n protected getExtraParams() {\n return {\n id: this.spatialObject.id,\n ...this.properties,\n }\n }\n}\n\nexport class UpdateUnlitMaterialProperties extends SpatializedElementCommand {\n properties: Partial<SpatialUnlitMaterialOptions>\n commandType = 'UpdateUnlitMaterialProperties'\n\n constructor(\n spatialObject: SpatialObject,\n properties: Partial<SpatialUnlitMaterialOptions>,\n ) {\n super(spatialObject)\n this.properties = properties\n }\n\n protected getExtraParams() {\n return this.properties\n }\n}\n\nexport class UpdateSpatializedElementTransform extends SpatializedElementCommand {\n matrix: DOMMatrix\n commandType = 'UpdateSpatializedElementTransform'\n\n constructor(spatialObject: SpatialObject, matrix: DOMMatrix) {\n super(spatialObject)\n this.matrix = matrix\n }\n\n protected getExtraParams() {\n return { matrix: Array.from(this.matrix.toFloat64Array()) }\n }\n}\n\nexport class UpdateSpatializedStatic3DElementProperties extends SpatializedElementCommand {\n properties: Partial<SpatializedStatic3DElementProperties>\n commandType = 'UpdateSpatializedStatic3DElementProperties'\n\n constructor(\n spatialObject: SpatialObject,\n properties: Partial<SpatializedStatic3DElementProperties>,\n ) {\n super(spatialObject)\n this.properties = properties\n }\n\n protected getExtraParams() {\n return this.properties\n }\n}\n\nexport class AddSpatializedElementToSpatialized2DElement extends SpatializedElementCommand {\n commandType = 'AddSpatializedElementToSpatialized2DElement'\n spatializedElement: SpatializedElement\n\n constructor(\n spatialObject: SpatialObject,\n spatializedElement: SpatializedElement,\n ) {\n super(spatialObject)\n this.spatializedElement = spatializedElement\n }\n\n protected getExtraParams() {\n return { spatializedElementId: this.spatializedElement.id }\n }\n}\n\nexport class AddSpatializedElementToSpatialScene extends JSBCommand {\n commandType = 'AddSpatializedElementToSpatialScene'\n spatializedElement: SpatializedElement\n\n constructor(spatializedElement: SpatializedElement) {\n super()\n this.spatializedElement = spatializedElement\n }\n\n protected getParams() {\n return {\n spatializedElementId: this.spatializedElement.id,\n }\n }\n}\n\nexport class CreateSpatializedStatic3DElementCommand extends JSBCommand {\n commandType = 'CreateSpatializedStatic3DElement'\n\n constructor(\n readonly modelURL?: string,\n readonly sources?: ModelSource[],\n ) {\n super()\n this.modelURL = modelURL\n this.sources = sources\n }\n\n protected getParams() {\n return { modelURL: this.modelURL, sources: this.sources }\n }\n}\n\nexport class CreateSpatializedDynamic3DElementCommand extends JSBCommand {\n protected getParams(): Record<string, any> | undefined {\n return { test: true }\n }\n commandType = 'CreateSpatializedDynamic3DElement'\n}\n\nexport class CreateSpatialEntityCommand extends JSBCommand {\n constructor(private name?: string) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return { name: this.name }\n }\n commandType = 'CreateSpatialEntity'\n}\n\nexport class CreateModelComponentCommand extends JSBCommand {\n constructor(private options: ModelComponentOptions) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n let geometryId = this.options.mesh.id\n let materialIds = this.options.materials.map(material => material.id)\n return { geometryId, materialIds }\n }\n commandType = 'CreateModelComponent'\n}\n\nexport class CreateSpatialModelEntityCommand extends JSBCommand {\n constructor(private options: SpatialModelEntityCreationOptions) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return this.options\n }\n commandType = 'CreateSpatialModelEntity'\n}\n\nexport class CreateModelAssetCommand extends JSBCommand {\n constructor(private options: ModelAssetOptions) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return { url: this.options.url }\n }\n commandType = 'CreateModelAsset'\n}\n\nexport class CreateSpatialGeometryCommand extends JSBCommand {\n constructor(\n private type: SpatialGeometryType,\n private options: SpatialGeometryOptions = {},\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return { type: this.type, ...this.options }\n }\n commandType = 'CreateGeometry'\n}\n\nexport class CreateSpatialUnlitMaterialCommand extends JSBCommand {\n constructor(private options: SpatialUnlitMaterialOptions) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return this.options\n }\n commandType = 'CreateUnlitMaterial'\n}\n\nexport class AddComponentToEntityCommand extends JSBCommand {\n constructor(\n public entity: SpatialEntity,\n public comp: SpatialComponent,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n entityId: this.entity.id,\n componentId: this.comp.id,\n }\n }\n commandType = 'AddComponentToEntity'\n}\n\nexport class RemoveComponentFromEntityCommand extends JSBCommand {\n constructor(\n public entity: SpatialEntity,\n public comp: SpatialComponent,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n entityId: this.entity.id,\n componentId: this.comp.id,\n }\n }\n commandType = 'RemoveComponentFromEntity'\n}\n\nexport class SetMaterialsOnEntityCommand extends JSBCommand {\n constructor(\n public entityId: string,\n public materials: SpatialMaterial[],\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n entityId: this.entityId,\n materialIds: this.materials.map(m => m.id),\n }\n }\n commandType = 'SetMaterialsOnEntity'\n}\n\nexport class AddEntityToDynamic3DCommand extends JSBCommand {\n constructor(\n public d3dEle: SpatializedDynamic3DElement,\n public entity: SpatialEntity,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n entityId: this.entity.id,\n dynamic3dId: this.d3dEle.id,\n }\n }\n\n commandType = 'AddEntityToDynamic3D'\n}\n\nexport class AddEntityToEntityCommand extends JSBCommand {\n constructor(\n public parent: SpatialEntity,\n public child: SpatialEntity,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n parentId: this.parent.id,\n childId: this.child.id,\n }\n }\n commandType = 'AddEntityToEntity'\n}\n\nexport class RemoveEntityFromParentCommand extends JSBCommand {\n constructor(public entity: SpatialEntity) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n entityId: this.entity.id,\n }\n }\n commandType = 'RemoveEntityFromParent'\n}\n\nexport class SetParentForEntityCommand extends JSBCommand {\n // childId, parentId\n constructor(\n public childId: string,\n public parentId?: string,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n childId: this.childId,\n parentId: this.parentId,\n }\n }\n commandType = 'SetParentToEntity'\n}\n\nexport class ConvertFromEntityToEntityCommand extends JSBCommand {\n constructor(\n public fromEntityId: string,\n public toEntityId: string,\n public fromPosition: Vec3,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n fromEntityId: this.fromEntityId,\n toEntityId: this.toEntityId,\n position: this.fromPosition,\n }\n }\n commandType = 'ConvertFromEntityToEntity'\n}\n\nexport class ConvertFromEntityToSceneCommand extends JSBCommand {\n constructor(\n public fromEntityId: string,\n public position: Vec3,\n ) {\n super()\n }\n\n protected getParams(): Record<string, any> | undefined {\n return {\n fromEntityId: this.fromEntityId,\n position: this.position,\n }\n }\n\n commandType = 'ConvertFromEntityToScene'\n}\n\nexport class ConvertFromSceneToEntityCommand extends JSBCommand {\n // let entityId: String\n // let position:Vec3\n constructor(\n public entityId: string,\n public position: Vec3,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n entityId: this.entityId,\n position: this.position,\n }\n }\n commandType = 'ConvertFromSceneToEntity'\n}\n\nexport class ConvertCoordinateCommand extends JSBCommand {\n constructor(\n public position: Vec3,\n public fromId: string,\n public toId: string,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n position: this.position,\n fromId: this.fromId,\n toId: this.toId,\n }\n }\n commandType = 'ConvertCoordinate'\n}\n\nexport class CreateTextureResourceCommand extends JSBCommand {\n constructor(private url: string) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n url: this.url,\n }\n }\n commandType = 'CreateTextureResource'\n}\n\nexport class InspectCommand extends JSBCommand {\n commandType = 'Inspect'\n\n constructor(readonly id: string = '') {\n super()\n }\n\n protected getParams() {\n return this.id ? { id: this.id } : { id: '' }\n }\n}\n\nexport class DestroyCommand extends JSBCommand {\n commandType = 'Destroy'\n\n constructor(readonly id: string) {\n super()\n }\n\n protected getParams() {\n return { id: this.id }\n }\n}\n\nexport class CheckWebViewCanCreateCommand extends JSBCommand {\n commandType = 'CheckWebViewCanCreate'\n\n constructor(readonly id: string = '') {\n super()\n }\n\n protected getParams() {\n return { id: this.id }\n }\n}\n\n/* WebSpatial Protocol Begin */\nabstract class WebSpatialProtocolCommand extends JSBCommand {\n target?: string\n features?: string\n\n async execute(): Promise<WebSpatialProtocolResult> {\n const query = this.getQuery()\n return platform.callWebSpatialProtocol(\n this.commandType,\n query,\n this.target,\n this.features,\n )\n }\n\n executeSync(): WebSpatialProtocolResult {\n const query = this.getQuery()\n return platform.callWebSpatialProtocolSync(\n this.commandType,\n query,\n this.target,\n this.features,\n )\n }\n\n private getQuery() {\n let query = undefined\n const params = this.getParams()\n if (params) {\n query = Object.keys(params)\n .map(key => {\n const value = params[key]\n const finalValue =\n typeof value === 'object' ? JSON.stringify(value) : value\n return `${key}=${encodeURIComponent(finalValue)}`\n })\n .join('&')\n }\n\n return query\n }\n}\n\nexport class createSpatialized2DElementCommand extends WebSpatialProtocolCommand {\n commandType = 'createSpatialized2DElement'\n constructor() {\n super()\n }\n protected getParams() {\n return {}\n }\n}\n\nexport class createSpatialSceneCommand extends WebSpatialProtocolCommand {\n commandType = 'createSpatialScene'\n\n constructor(\n private url: string,\n private config: SpatialSceneCreationOptionsInternal | undefined,\n public target?: string,\n public features?: string,\n ) {\n super()\n }\n protected getParams() {\n return {\n url: this.url,\n config: this.config,\n }\n }\n}\n\nexport class CreateAttachmentEntityCommand extends WebSpatialProtocolCommand {\n commandType = 'createAttachment'\n constructor(private options: AttachmentEntityOptions) {\n super()\n }\n protected getParams() {\n return {} // No metadata — just trigger engine/webview creation\n }\n}\n\nexport class InitializeAttachmentCommand extends JSBCommand {\n commandType = 'InitializeAttachment'\n constructor(\n private attachmentId: string,\n private options: AttachmentEntityOptions,\n ) {\n super()\n }\n protected getParams() {\n return {\n id: this.attachmentId,\n parentEntityId: this.options.parentEntityId,\n position: this.options.position ?? [0, 0, 0],\n size: this.options.size,\n ownerViewId: this.options.ownerViewId,\n }\n }\n}\n\nexport class UpdateAttachmentEntityCommand extends JSBCommand {\n commandType = 'UpdateAttachmentEntity'\n constructor(\n private attachmentId: string,\n private options: AttachmentEntityUpdateOptions,\n ) {\n super()\n }\n protected getParams() {\n return {\n id: this.attachmentId,\n ...this.options,\n }\n }\n}\n\n// TODO: Can crypto.randomUUID be used instead including in dev environments without https\nfunction uuid(): string {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {\n const r = (Math.random() * 16) | 0\n return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16)\n })\n}\n\n/* WebSpatial Protocol End */\n","import { DestroyCommand, InspectCommand } from './JSBCommand'\n\n/**\n * @hidden\n * Parent class of spatial objects, should not be used directly\n */\nexport class SpatialObject {\n /** @hidden */\n constructor(\n /** @hidden */\n public readonly id: string,\n ) {}\n\n name?: string\n\n isDestroyed = false\n\n async inspect() {\n const ret = await new InspectCommand(this.id).execute()\n if (ret.success) {\n return ret.data\n }\n throw new Error(ret.errorMessage)\n }\n\n async destroy() {\n if (this.isDestroyed) {\n return\n }\n\n const ret = await new DestroyCommand(this.id).execute()\n if (ret.success) {\n this.onDestroy()\n this.isDestroyed = true\n return ret.data\n } else if (this.isDestroyed) {\n // already destroyed\n return\n }\n\n throw new Error(ret.errorMessage)\n }\n\n // override this method to do some cleanup\n protected onDestroy() {}\n}\n","import { createSpatialSceneCommand, FocusScene } from './JSBCommand'\nimport { SpatialScene } from './SpatialScene'\nimport {\n SpatialSceneCreationOptions,\n SpatialSceneType,\n SpatialSceneState,\n isValidSceneUnit,\n isValidSpatialSceneType,\n isValidWorldScalingType,\n isValidWorldAlignmentType,\n isValidBaseplateVisibilityType,\n PWAManifest,\n XRSpatialSceneConfig,\n XRSpatialSceneDefaults,\n} from './types/types'\nimport { SpatialSceneCreationOptionsInternal } from './types/internal'\nimport { deepCloneJSON } from './utils'\nimport { pointToPhysical, physicalToPoint } from './physicalMetrics'\n\nconst defaultSceneConfig: SpatialSceneCreationOptions = {\n defaultSize: {\n width: 1280,\n height: 720,\n },\n}\n\nconst defaultSceneConfigVolume: SpatialSceneCreationOptions = {\n defaultSize: {\n width: '0.94m',\n height: '0.94m',\n depth: '0.94m',\n },\n}\n\nlet xr_window_defaults: SpatialSceneCreationOptions = {\n ...defaultSceneConfig,\n}\nlet xr_volume_defaults: SpatialSceneCreationOptions = {\n ...defaultSceneConfigVolume,\n}\n\nconst INTERNAL_SCHEMA_PREFIX = 'webspatial://'\n\n/**\n * Deep-merge two plain object trees (no arrays, no special classes).\n * - Creates a shallow clone of base, then recursively merges properties from over.\n * - When both sides at a key are plain objects, merges recursively; otherwise, replaces with over.\n * - Ignores arrays (treated as replace).\n * Intended for small configuration objects like manifest overrides.\n */\nfunction deepMergePlain<\n T extends Record<string, any>,\n U extends Record<string, any> | undefined,\n>(base: T, over: U): T & (U extends undefined ? {} : U) {\n if (!over) return { ...(base || {}) } as any\n const out: any = { ...(base || {}) }\n for (const k of Object.keys(over)) {\n const bv = out[k]\n const ov = (over as any)[k]\n if (\n ov &&\n typeof ov === 'object' &&\n !Array.isArray(ov) &&\n bv &&\n typeof bv === 'object' &&\n !Array.isArray(bv)\n ) {\n out[k] = deepMergePlain(bv, ov)\n } else {\n out[k] = ov\n }\n }\n return out\n}\n\n/**\n * Normalize XRSpatialSceneDefaults (manifest shape) into SpatialSceneCreationOptions (runtime shape).\n * - Only remap default_size -> defaultSize when present.\n * - Leaves other keys (resizability, worldScaling, etc.) unchanged.\n * - Units are left as-is; downstream formatting is handled by formatSceneConfig.\n */\nfunction normalizeXRDefaultsToSceneOptions(\n src: XRSpatialSceneDefaults | Record<string, any>,\n): SpatialSceneCreationOptions {\n const out: any = { ...(src || {}) }\n const ds =\n (src as any).defaultSize !== undefined\n ? (src as any).defaultSize\n : (src as any).default_size\n if (ds !== undefined) {\n out.defaultSize = ds\n }\n if ('default_size' in out) {\n delete out.default_size\n }\n return out\n}\n\nclass SceneManager {\n private originalOpen: any\n private static instance: SceneManager\n private manifestReady: Promise<void> | null = null\n static getInstance() {\n if (!SceneManager.instance) {\n SceneManager.instance = new SceneManager()\n }\n return SceneManager.instance\n }\n\n init(window: WindowProxy) {\n this.manifestReady = this.setupManifest()\n this.originalOpen = window.open.bind(window)\n ;(window as any).open = this.open\n }\n\n // Stores the latest formatted config used by the platform (per scene name).\n // This object contains normalized values and is safe for internal consumption.\n private configMap: Record<string, SpatialSceneCreationOptionsInternal> = {}\n // Stores the raw callback return value (per scene name) to feed into the next initScene call as `pre`.\n // We keep this unformatted so developers receive exactly what they last returned.\n private callbackReturnMap: Record<string, SpatialSceneCreationOptions> = {}\n private getConfig(name?: string) {\n if (name === undefined || !this.configMap[name]) return undefined\n return this.configMap[name]\n }\n\n waitManifest(): Promise<void> {\n return this.manifestReady ?? Promise.resolve()\n }\n\n // Ensure URL is absolute; only convert when a relative path is provided\n // - Keep external and special schemes untouched (http, https, data, blob, about, file, mailto, etc.)\n // - Handle protocol-relative URLs (//example.com/path)\n // - Resolve relative paths against document.baseURI (respects <base href>)\n private ensureAbsoluteUrl(raw?: string): string | undefined {\n if (!raw) return raw\n // Already has a scheme (includes internal webspatial:// which is handled earlier)\n if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(raw)) {\n return raw\n }\n // Protocol-relative URL\n if (raw.startsWith('//')) {\n return `${window.location.protocol}${raw}`\n }\n // Resolve against base URI\n try {\n return new URL(raw, document.baseURI).toString()\n } catch {\n // Fallback: leave unchanged\n return raw\n }\n }\n\n private async setupManifest() {\n const manifest = await this.getPWAManifest()\n try {\n const xr = manifest?.xr_spatial_scene\n if (!xr || typeof xr !== 'object') return\n const { overrides, ...topLevel } = xr as XRSpatialSceneConfig\n // Merge top-level defaults with per-scene overrides.\n const windowRaw = deepMergePlain(topLevel, overrides?.window_scene)\n const volumeRaw = deepMergePlain(topLevel, overrides?.volume_scene)\n const windowNext = normalizeXRDefaultsToSceneOptions(windowRaw)\n\n const volumeNext = normalizeXRDefaultsToSceneOptions(volumeRaw)\n if (windowNext && Object.keys(windowNext).length > 0) {\n xr_window_defaults = windowNext\n }\n if (volumeNext && Object.keys(volumeNext).length > 0) {\n xr_volume_defaults = volumeNext\n }\n } catch (error: any) {\n console.warn(\n 'SceneManager.setupManifest failed; using built-in defaults.',\n error?.message || error,\n )\n }\n }\n\n private open = (url?: string, target?: string, features?: string) => {\n // bypass internal\n if (url?.startsWith(INTERNAL_SCHEMA_PREFIX)) {\n if (\n url.includes('createSpatialized2DElement') ||\n url.includes('createAttachment')\n ) {\n const token = //@ts-ignore\n (window.webSpatial || window.__webspatialShell__)?.genToken?.()\n if (token) {\n const command = url.includes('createAttachment')\n ? 'createAttachment'\n : 'createSpatialized2DElement'\n const host = window.location.host\n const protocol = window.location.protocol\n const finalURL = `${protocol}//${host}/${token}/?command=${command}`\n const rid = new URL(url).searchParams.get('rid')\n const final = new URL(finalURL)\n if (rid) final.searchParams.set('rid', rid)\n return this.originalOpen(final.toString(), target, features)\n }\n }\n return this.originalOpen(url, target, features)\n }\n\n // Normalize only relative URLs to absolute for platform handling\n url = this.ensureAbsoluteUrl(url)\n\n // if target is special\n if (target === '_self' || target === '_parent' || target === '_top') {\n const newWindow = this.originalOpen(url, target, features)\n return newWindow\n }\n\n let cfg = target ? this.getConfig(target) : undefined\n\n if (cfg === undefined) {\n // if no config, use default window config\n const preFormatted = deepCloneJSON(getSceneDefaultConfig('window'))\n\n const [ans] = formatSceneConfig(preFormatted, 'window')\n cfg = { ...ans, type: 'window' }\n }\n\n const cmd = new createSpatialSceneCommand(url!, cfg, target, features)\n const result = cmd.executeSync()\n\n const id = result.data?.id\n\n if (id) {\n // send JSB to focus\n let focusCmd = new FocusScene(id)\n focusCmd.execute()\n }\n\n return result.data?.windowProxy\n }\n initScene(\n name: string,\n callback: (pre: SpatialSceneCreationOptions) => SpatialSceneCreationOptions,\n options?: { type: SpatialSceneType },\n ) {\n const sceneType = options?.type ?? 'window'\n const defaultConfigRaw = getSceneDefaultConfig(sceneType)\n const previousOrDefault =\n this.callbackReturnMap[name] ??\n ((): SpatialSceneCreationOptions => {\n // Clone default config to avoid mutating shared defaults during formatting.\n const cloned = deepCloneJSON(defaultConfigRaw)\n return cloned\n })()\n const rawReturnVal = callback(previousOrDefault)\n const sanitizedReturnVal = sanitizeSceneOptionsUnits(\n deepCloneJSON(rawReturnVal),\n )\n const clonedForFormat = deepCloneJSON(sanitizedReturnVal)\n // Merge normalized user return with scene-type defaults before final formatting.\n // This ensures missing fields fall back to the appropriate xr_window_defaults / xr_volume_defaults.\n const baseDefaults = deepCloneJSON(getSceneDefaultConfig(sceneType))\n const mergedForFormat = deepMergePlain(baseDefaults, clonedForFormat)\n\n const [formattedConfig, errors] = formatSceneConfig(\n mergedForFormat,\n sceneType,\n )\n\n if (errors.length > 0) {\n console.warn(`initScene ${name} with errors: ${errors.join(', ')}`)\n }\n this.callbackReturnMap[name] = sanitizedReturnVal\n this.configMap[name] = {\n ...formattedConfig,\n type: sceneType,\n }\n }\n /**\n * Resolve and load a PWA manifest as JSON:\n * 1) Determine href:\n * - Prefer explicit manifestUrl if provided;\n * - Fallback to <link rel=\"manifest\">, preferring the raw attribute over computed href.\n * 2) Normalize href to absolute using ensureAbsoluteUrl (respects <base href>).\n * 3) Handle data URLs inline:\n * - data:...;base64,... → atob then JSON.parse\n * - data:...,... → decodeURIComponent then JSON.parse\n * 4) Fetch with credentials same-origin first; if that fails (e.g., CORS), attempt unauthenticated fetch.\n * 5) Parse as JSON; if response body is text, parse the text as JSON.\n */\n async getPWAManifest(manifestUrl?: string): Promise<PWAManifest | undefined> {\n let href: string | undefined = manifestUrl\n if (!href) {\n const el = document.querySelector(\n 'link[rel=\"manifest\"]',\n ) as HTMLLinkElement | null\n href = el?.getAttribute('href') || el?.href\n }\n if (!href) return\n href = this.ensureAbsoluteUrl(href)\n if (!href) return\n if (href.startsWith('data:')) {\n // Inline data URL manifest: data:[<mediatype>][;base64],<data>\n try {\n const comma = href.indexOf(',')\n if (comma < 0) return\n const meta = href.slice(5, comma)\n const data = href.slice(comma + 1)\n const isBase64 = /;base64/i.test(meta)\n const decoded = isBase64 ? atob(data) : decodeURIComponent(data)\n return JSON.parse(decoded)\n } catch {\n return\n }\n }\n try {\n // Same-origin fetch with credentials first.\n const res = await fetch(href, { credentials: 'same-origin' })\n if (!res.ok) throw new Error(String(res.status))\n try {\n return await res.json()\n } catch {\n const t = await res.text()\n return JSON.parse(t)\n }\n } catch {\n try {\n // Fallback: unauthenticated fetch (may help when same-origin credentials fail due to CORS).\n const res = await fetch(href)\n if (!res.ok) return\n try {\n return await res.json()\n } catch {\n const t = await res.text()\n return JSON.parse(t)\n }\n } catch {\n return\n }\n }\n }\n}\n\nfunction sanitizeSceneOptionsUnits(\n val: SpatialSceneCreationOptions,\n): SpatialSceneCreationOptions {\n if (val?.defaultSize) {\n const keys = ['width', 'height', 'depth'] as const\n for (const k of keys) {\n if (\n k in (val.defaultSize as any) &&\n !isValidSceneUnit((val.defaultSize as any)[k])\n ) {\n delete (val.defaultSize as any)[k]\n }\n }\n }\n if (val?.resizability) {\n const keys = ['minWidth', 'minHeight', 'maxWidth', 'maxHeight'] as const\n for (const k of keys) {\n if (\n k in (val.resizability as any) &&\n !isValidSceneUnit((val.resizability as any)[k])\n ) {\n delete (val.resizability as any)[k]\n }\n }\n }\n return val\n}\n\nfunction pxToMeter(px: number): number {\n return pointToPhysical(px)\n}\n\nfunction meterToPx(meter: number): number {\n return physicalToPoint(meter)\n}\n\nfunction formatToNumber(\n str: string | number,\n targetUnit: 'px' | 'm',\n defaultUnit: 'px' | 'm',\n): number {\n if (typeof str === 'number') {\n if (\n (defaultUnit === 'px' && targetUnit === 'px') ||\n (defaultUnit === 'm' && targetUnit === 'm')\n ) {\n return str\n }\n // unit not match target\n if (defaultUnit === 'px' && targetUnit === 'm') {\n return pxToMeter(str)\n } else if (defaultUnit === 'm' && targetUnit === 'px') {\n return meterToPx(str)\n }\n // fallback\n return str\n }\n if (targetUnit === 'm') {\n if (str.endsWith('m')) {\n // 1m\n return Number(str.slice(0, -1))\n } else if (str.endsWith('px')) {\n // 100px\n return pxToMeter(Number(str.slice(0, -2)))\n } else {\n throw new Error('formatToNumber: invalid str')\n }\n } else if (targetUnit === 'px') {\n if (str.endsWith('px')) {\n // 100px\n return Number(str.slice(0, -2))\n } else if (str.endsWith('m')) {\n // 1m\n return meterToPx(Number(str.slice(0, -1)))\n } else {\n throw new Error('formatToNumber: invalid str')\n }\n } else {\n throw new Error('formatToNumber: invalid targetUnit')\n }\n}\n\nexport function formatSceneConfig(\n config: SpatialSceneCreationOptions,\n sceneType: SpatialSceneType,\n): [SpatialSceneCreationOptions, string[]] {\n // defaultSize and resizability's width/height/depth can be 100 or \"100px\" or \"1m\"\n // expect:\n // resizability should format into px\n // defaultSize should format into px if window\n // defaultSize should format into m if volume\n\n const defaultSceneConfig = getSceneDefaultConfig(sceneType)\n\n const errors: string[] = []\n\n const isWindow = sceneType === 'window'\n if (!isValidSpatialSceneType(sceneType)) {\n errors.push(`sceneType`)\n }\n\n // format defaultSize\n if (config.defaultSize) {\n const iterKeys = ['width', 'height', 'depth']\n for (let k of iterKeys) {\n if (!(k in config.defaultSize)) continue\n if (isValidSceneUnit((config.defaultSize as any)[k])) {\n ;(config.defaultSize as any)[k] = formatToNumber(\n (config.defaultSize as any)[k],\n isWindow ? 'px' : 'm',\n 'px',\n )\n } else {\n // delete invalid unit\n delete (config.defaultSize as any)[k]\n errors.push(`defaultSize.${k}`)\n }\n }\n }\n\n // format resizability\n if (config.resizability) {\n const iterKeys = ['minWidth', 'minHeight', 'maxWidth', 'maxHeight']\n for (let k of iterKeys) {\n if (!(k in config.resizability)) continue\n if (isValidSceneUnit((config.resizability as any)[k])) {\n ;(config.resizability as any)[k] = formatToNumber(\n (config.resizability as any)[k],\n 'px',\n 'px',\n )\n } else {\n // delete invalid unit\n delete (config.resizability as any)[k]\n errors.push(`resizability.${k}`)\n }\n }\n }\n\n // check value\n if (config.worldScaling) {\n if (!isValidWorldScalingType(config.worldScaling)) {\n config.worldScaling = 'automatic'\n errors.push('worldScaling')\n }\n }\n\n if (config.worldAlignment) {\n if (!isValidWorldAlignmentType(config.worldAlignment)) {\n config.worldAlignment = 'automatic'\n errors.push('worldAlignment')\n }\n }\n\n if (config.baseplateVisibility) {\n if (!isValidBaseplateVisibilityType(config.baseplateVisibility)) {\n config.baseplateVisibility = 'automatic'\n errors.push('baseplateVisibility')\n }\n }\n\n return [config, errors]\n}\n\nexport function initScene(\n name: string,\n callback: (pre: SpatialSceneCreationOptions) => SpatialSceneCreationOptions,\n options?: { type: SpatialSceneType },\n) {\n return SceneManager.getInstance().initScene(name, callback, options)\n}\n\nexport function __getSceneConfigSnapshotForTest(\n name: string,\n): SpatialSceneCreationOptionsInternal | undefined {\n const mgr = SceneManager.getInstance() as any\n return mgr?.configMap?.[name]\n}\n\nexport function hijackWindowOpen(window: WindowProxy) {\n SceneManager.getInstance().init(window)\n}\n\nexport function hijackWindowATag(openedWindow: WindowProxy) {\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\n if (handleATag(e)) {\n return false // prevent default action and stop event propagation\n }\n\n return true\n }\n if (element && element.parentElement) {\n element = element.parentElement\n } else {\n break\n }\n }\n }\n}\n\nfunction 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 return true\n }\n }\n}\n\nfunction getSceneDefaultConfig(sceneType: SpatialSceneType) {\n return sceneType === 'window'\n ? xr_window_defaults || defaultSceneConfig\n : xr_volume_defaults || defaultSceneConfigVolume\n}\n\nasync function injectScenePolyfill() {\n if (!window.opener) return\n\n const state = await SpatialScene.getInstance().getState()\n\n // only run this in pending state\n if (state !== SpatialSceneState.pending) return\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 await SceneManager.getInstance().waitManifest()\n const sceneType = window.xrCurrentSceneType ?? 'window'\n const rawDefault = getSceneDefaultConfig(sceneType)\n // Provide a formatted 'pre' to the callback for consistent units and types.\n const pre = deepCloneJSON(rawDefault)\n\n let cfg = pre\n if (typeof window.xrCurrentSceneDefaults === 'function') {\n try {\n cfg = await window.xrCurrentSceneDefaults?.(pre)\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\n // Merge callback return with base defaults to ensure missing fields are filled.\n const mergedCfg = deepMergePlain(deepCloneJSON(rawDefault), cfg)\n const [formattedConfig, errors] = formatSceneConfig(mergedCfg, sceneType)\n if (errors.length > 0) {\n console.warn(\n `window.xrCurrentSceneDefaults with errors: ${errors.join(', ')}`,\n )\n }\n const finalCfg = {\n ...formattedConfig,\n type: sceneType,\n }\n await SpatialScene.getInstance().updateSceneCreationConfig(finalCfg)\n })\n}\n\nexport function injectSceneHook() {\n hijackWindowOpen(window)\n hijackWindowATag(window)\n injectScenePolyfill()\n}\n","import {\n SpatialSceneCreationOptions,\n SpatialSceneProperties,\n Vec3,\n} from './types/types'\nimport { SpatialSceneCreationOptionsInternal } from './types/internal'\nimport {\n AddSpatializedElementToSpatialScene,\n GetSpatialSceneState,\n UpdateSceneConfig,\n UpdateSpatialSceneProperties,\n} from './JSBCommand'\nimport { ConvertCoordinateCommand } from './JSBCommand'\n\nimport { SpatializedElement } from './SpatializedElement'\nimport { SpatialObject } from './SpatialObject'\nimport { SpatialSceneState } from './types/internal'\n\nlet instance: SpatialScene\n\n/**\n * Represents the spatial scene that contains all spatialized elements.\n * This class follows the singleton pattern - only one instance exists per application.\n * The scene manages the overall spatial environment properties and contains all spatial elements.\n */\nexport class SpatialScene extends SpatialObject {\n /**\n * Gets the singleton instance of the SpatialScene.\n * Creates a new instance if one doesn't exist yet.\n * @returns The singleton SpatialScene instance\n */\n static getInstance(): SpatialScene {\n if (!instance) {\n instance = new SpatialScene('')\n }\n return instance\n }\n\n async convertCoordinate(\n position: Vec3,\n fromId: string,\n toId: string,\n ): Promise<Vec3> {\n try {\n const ret = await new ConvertCoordinateCommand(\n position,\n fromId,\n toId,\n ).execute()\n return (ret as any)?.data ?? position\n } catch (error) {\n console.warn('SpatialScene.convertCoordinate error:', error)\n throw error\n }\n }\n\n /**\n * Updates the properties of the spatial scene.\n * This can include background settings, lighting, and other scene-wide properties.\n * @param properties Partial set of properties to update\n * @returns Promise resolving when the update is complete\n */\n async updateSpatialProperties(properties: Partial<SpatialSceneProperties>) {\n return new UpdateSpatialSceneProperties(properties).execute()\n }\n\n /**\n * Adds a spatialized element to the scene.\n * This makes the element visible and interactive in the spatial environment.\n * @param element The SpatializedElement to add to the scene\n * @returns Promise resolving when the element is added\n */\n async addSpatializedElement(element: SpatializedElement) {\n return new AddSpatializedElementToSpatialScene(element).execute()\n }\n\n /**\n * Updates the scene creation configuration.\n * This allows changing scene parameters after initial creation.\n * @param config The new scene creation configuration\n * @returns Promise resolving when the update is complete\n */\n async updateSceneCreationConfig(config: SpatialSceneCreationOptionsInternal) {\n return new UpdateSceneConfig(config).execute()\n }\n\n /**\n * Gets the current state of the spatial scene.\n * This includes information about active elements and scene configuration.\n * @returns Promise resolving to the current SpatialSceneState\n */\n async getState(): Promise<SpatialSceneState> {\n return (await new GetSpatialSceneState().execute()).data.name\n }\n}\n","import type { SpatialEntity } from '..'\nimport { SpatialGeometry } from '../reality/geometry/SpatialGeometry'\nimport { SpatialMaterial } from '../reality/material/SpatialMaterial'\nimport type { SpatializedDynamic3DElement } from '../SpatializedDynamic3DElement'\n\nexport interface Vec3 {\n x: number\n y: number\n z: number\n}\n\nexport type Point3D = Vec3\n\nexport interface Quaternion {\n x: number\n y: number\n z: number\n w: number\n}\n\n/**\n * Material type for SpatialDiv or HTML document.\n *\n * This type defines the background material options for both SpatialDiv elements and HTML documents.\n *\n * - `'none'`: This is the default value.\n * - For HTML documents, the web page window will have the default native background.\n * - For SpatialDiv, the window will have a transparent background.\n * - `'translucent'`: Represents a glass-like material in AVP (Apple Vision Pro).\n * - `'thick'`: Represents a thick material in AVP.\n * - `'regular'`: Represents a regular material in AVP.\n * - `'thin'`: Represents a thin material in AVP.\n * - `'transparent'`: Represents a fully transparent background.\n */\nexport type BackgroundMaterialType =\n | 'none'\n | 'translucent'\n | 'thick'\n | 'regular'\n | 'thin'\n | 'transparent'\n\nexport type CornerRadius = {\n topLeading: number\n bottomLeading: number\n topTrailing: number\n bottomTrailing: number\n}\n\nexport interface SpatialSceneProperties {\n cornerRadius: CornerRadius\n material: BackgroundMaterialType\n opacity: number\n}\n\nexport enum SpatializedElementType {\n Spatialized2DElement,\n SpatializedStatic3DElement,\n SpatializedDynamic3DElement,\n}\n\nexport interface SpatializedElementProperties {\n name: string\n clientX: number\n clientY: number\n width: number\n height: number\n depth: number\n opacity: number\n visible: boolean\n scrollWithParent: boolean\n zIndex: number\n backOffset: number\n rotationAnchor: Point3D\n enableTapGesture: boolean\n enableDragStartGesture: boolean\n enableDragGesture: boolean\n enableDragEndGesture: boolean\n enableRotateGesture: boolean\n enableRotateEndGesture: boolean\n enableMagnifyGesture: boolean\n enableMagnifyEndGesture: boolean\n /**\n * Optional world-space axis for spatial rotate gesture. Omitted or zero vector\n * means unconstrained rotation (platform default).\n */\n rotateConstrainedToAxis?: Vec3\n}\n\nexport interface Spatialized2DElementProperties\n extends SpatializedElementProperties {\n scrollPageEnabled: boolean\n cornerRadius: CornerRadius\n material: BackgroundMaterialType\n scrollEdgeInsetsMarginRight: number\n}\n\nexport interface ModelSource {\n src: string\n type?: string\n}\n\nexport interface SpatializedStatic3DElementProperties\n extends SpatializedElementProperties {\n modelURL: string\n sources?: ModelSource[]\n modelTransform?: number[]\n autoplay?: boolean\n loop?: boolean\n animationPaused?: boolean\n playbackRate?: number\n}\n\nexport interface SpatialSceneCreationOptions {\n defaultSize?: {\n width: number | string // Initial width of the window\n height: number | string // Initial height of the window\n depth?: number | string // Initial depth of the window, only for volume\n }\n\n resizability?: {\n minWidth?: number | string // Minimum width of the window\n minHeight?: number | string // Minimum height of the window\n maxWidth?: number | string // Maximum width of the window\n maxHeight?: number | string // Maximum height of the window\n }\n worldScaling?: WorldScalingType\n worldAlignment?: WorldAlignmentType\n\n baseplateVisibility?: BaseplateVisibilityType\n}\n\nexport type SpatialEntityEventType =\n | 'spatialtap'\n | 'spatialdragstart'\n | 'spatialdrag'\n | 'spatialdragend'\n | 'spatialrotate'\n | 'spatialrotateend'\n | 'spatialmagnify'\n | 'spatialmagnifyend'\n\nexport const BaseplateVisibilityValues = [\n 'automatic',\n 'visible',\n 'hidden',\n] as const\nexport type BaseplateVisibilityType = (typeof BaseplateVisibilityValues)[number]\n\nexport function isValidBaseplateVisibilityType(type: string): Boolean {\n return BaseplateVisibilityValues.includes(type as BaseplateVisibilityType)\n}\n\nexport const WorldScalingValues = ['automatic', 'dynamic'] as const\nexport type WorldScalingType = (typeof WorldScalingValues)[number]\n\nexport function isValidWorldScalingType(type: string): Boolean {\n return WorldScalingValues.includes(type as WorldScalingType)\n}\n\nexport const WorldAlignmentValues = [\n 'adaptive',\n 'automatic',\n 'gravityAligned',\n] as const\nexport type WorldAlignmentType = (typeof WorldAlignmentValues)[number]\n\nexport function isValidWorldAlignmentType(type: string): Boolean {\n return WorldAlignmentValues.includes(type as WorldAlignmentType)\n}\n\nexport const SpatialSceneValues = ['window', 'volume'] as const\nexport type SpatialSceneType = (typeof SpatialSceneValues)[number]\n\nexport function isValidSpatialSceneType(type: string): Boolean {\n return SpatialSceneValues.includes(type as SpatialSceneType)\n}\n\n/**\n * check px,m and number, number must be >= 0\n *\n * */\nexport function isValidSceneUnit(val: string | number): boolean {\n // only support number or string with unit px or m\n // rpx cm mm not allowed\n if (typeof val === 'number') {\n return val >= 0\n }\n if (typeof val === 'string') {\n if (val.endsWith('px')) {\n // check if number\n if (isNaN(Number(val.slice(0, -2)))) {\n return false\n }\n return Number(val.slice(0, -2)) >= 0\n }\n if (val.endsWith('m')) {\n // check if number\n if (isNaN(Number(val.slice(0, -1)))) {\n return false\n }\n return Number(val.slice(0, -1)) >= 0\n }\n }\n return false\n}\n\nexport interface SpatialEntityProperties {\n position: Vec3\n rotation: Vec3\n scale: Vec3\n}\n\nexport type SpatialGeometryType =\n | 'BoxGeometry'\n | 'PlaneGeometry'\n | 'SphereGeometry'\n | 'CylinderGeometry'\n | 'ConeGeometry'\n\nexport interface SpatialBoxGeometryOptions {\n width?: number\n height?: number\n depth?: number\n cornerRadius?: number\n splitFaces?: boolean\n}\n\nexport interface SpatialPlaneGeometryOptions {\n width?: number\n height?: number\n cornerRadius?: number\n}\n\nexport interface SpatialSphereGeometryOptions {\n radius?: number\n}\n\nexport interface SpatialConeGeometryOptions {\n radius?: number\n height?: number\n}\n\nexport interface SpatialCylinderGeometryOptions {\n radius?: number\n height?: number\n}\n\nexport type SpatialGeometryOptions =\n | SpatialBoxGeometryOptions\n | SpatialPlaneGeometryOptions\n | SpatialSphereGeometryOptions\n | SpatialCylinderGeometryOptions\n | SpatialConeGeometryOptions\n\nexport type SpatialMaterialType = 'unlit'\n\nexport interface SpatialUnlitMaterialOptions {\n color?: string\n textureId?: string\n transparent?: boolean\n opacity?: number\n}\n\nexport interface ModelComponentOptions {\n mesh: SpatialGeometry\n materials: SpatialMaterial[]\n}\n\nexport interface SpatialEntityUserData {\n id?: string\n name?: string\n}\n\nexport interface SpatialModelEntityCreationOptions {\n modelAssetId: string\n name?: string\n}\n\nexport interface ModelAssetOptions {\n url: string\n}\n\nexport enum SpatialSceneState {\n idle = 'idle',\n pending = 'pending',\n willVisible = 'willVisible',\n visible = 'visible',\n fail = 'fail',\n}\n\n/**\n * Translate event, matching similar behavior to https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drag_event\n */\nexport type SpatialModelDragEvent = {\n eventType: 'dragstart' | 'dragend' | 'drag'\n translation3D: Vec3\n startLocation3D: Vec3\n}\n\nexport interface Size {\n width: number\n height: number\n}\n\nexport interface Size3D extends Size {\n depth: number\n}\n\nexport class CubeInfo {\n constructor(\n public size: Size3D,\n public origin: Vec3,\n ) {\n this.size = size\n this.origin = origin\n }\n\n get x() {\n return this.origin.x\n }\n\n get y() {\n return this.origin.y\n }\n\n get z() {\n return this.origin.z\n }\n\n get width() {\n return this.size.width\n }\n\n get height() {\n return this.size.height\n }\n\n get depth() {\n return this.size.depth\n }\n\n get left() {\n return this.x\n }\n\n get top() {\n return this.y\n }\n\n get right() {\n return this.x + this.width\n }\n\n get bottom() {\n return this.y + this.height\n }\n\n get back() {\n return this.z\n }\n\n get front() {\n return this.z + this.depth\n }\n}\n\nexport interface SpatialTapEventDetail {\n location3D: Point3D\n globalLocation3D?: Point3D\n}\n\nexport type SpatialTapEvent = CustomEvent<SpatialTapEventDetail>\n\nexport interface SpatialDragStartEventDetail {\n startLocation3D: Point3D\n globalLocation3D?: Point3D\n}\n\nexport interface SpatialDragEventDetail {\n translation3D: Vec3\n}\n\nexport interface SpatialDragEndEventDetail {}\n\nexport type SpatialDragStartEvent = CustomEvent<SpatialDragStartEventDetail>\n\nexport type SpatialDragEvent = CustomEvent<SpatialDragEventDetail>\n\nexport type SpatialDragEndEvent = CustomEvent<SpatialDragEndEventDetail>\nexport interface SpatialRotateEventDetail {\n quaternion: Quaternion\n}\n\nexport interface SpatialRotateEndEventDetail {}\n\nexport type SpatialRotateEvent = CustomEvent<SpatialRotateEventDetail>\n\nexport type SpatialRotateEndEvent = CustomEvent<SpatialRotateEndEventDetail>\n\nexport interface SpatialMagnifyEventDetail {\n magnification: number\n}\n\nexport interface SpatialMagnifyEndEventDetail {}\n\nexport type SpatialMagnifyEvent = CustomEvent<SpatialMagnifyEventDetail>\n\nexport type SpatialMagnifyEndEvent = CustomEvent<SpatialMagnifyEndEventDetail>\n\nexport type SpatialEntityOrReality = SpatialEntity | SpatializedDynamic3DElement\n\nexport interface AttachmentEntityOptions {\n parentEntityId: string\n position?: [number, number, number]\n size: { width: number; height: number }\n ownerViewId: string\n}\n\nexport interface AttachmentEntityUpdateOptions {\n position?: [number, number, number]\n size?: { width: number; height: number }\n}\n\n// manifest\n\nexport type SceneUnitPx = `${number}px`\nexport type SceneUnitM = `${number}m`\nexport type SceneUnit = number | SceneUnitPx | SceneUnitM\n\nexport interface XRSceneSize {\n width: SceneUnit\n height: SceneUnit\n depth?: SceneUnit\n}\n\nexport interface XRSceneResizability {\n minWidth?: SceneUnit\n minHeight?: SceneUnit\n maxWidth?: SceneUnit\n maxHeight?: SceneUnit\n}\n\nexport interface XRMainSceneConfig extends XRSpatialSceneDefaults {\n type?: SpatialSceneType\n}\n\nexport interface XRSpatialSceneDefaults {\n default_size?: XRSceneSize\n resizability?: XRSceneResizability\n worldScaling?: WorldScalingType\n worldAlignment?: WorldAlignmentType\n baseplateVisibility?: BaseplateVisibilityType\n}\n\nexport interface XRSpatialSceneOverrides {\n window_scene?: XRSpatialSceneDefaults\n volume_scene?: XRSpatialSceneDefaults\n}\n\nexport interface XRSpatialSceneConfig extends XRSpatialSceneDefaults {\n overrides?: XRSpatialSceneOverrides\n}\n\nexport interface XRPrdConfig {\n xr_main_scene?: XRMainSceneConfig\n xr_spatial_scene?: XRSpatialSceneConfig\n}\n\nexport interface PWAManifest extends XRPrdConfig {\n name?: string\n short_name?: string\n start_url?: string\n display?: string\n icons?: Array<{\n src: string\n sizes?: string\n type?: string\n purpose?: string\n }>\n id?: string\n scope?: string\n [key: string]: any\n}\n","import { SpatialWebEvent } from './SpatialWebEvent'\nexport type PhysicalMetricsValueShape = {\n meterToPtUnscaled: number\n meterToPtScaled: number\n}\n\ntype WorldScalingCompensation = 'unscaled' | 'scaled'\n\ntype ConvertOption = { worldScalingCompensation: WorldScalingCompensation }\n\n// Fallback calibration: 1 meter ≈ 1360 pt for both scaled and unscaled modes.\n// This baseline ensures pointToPhysical(1360) === 1 and physicalToPoint(1) === 1360\n// until native physical metrics are injected into window.__webspatialsdk__.physicalMetrics\n// and a 'WebSpatialPhysicalMetricsUpdate' event updates the snapshot at runtime.\nlet snapshot: PhysicalMetricsValueShape = {\n meterToPtUnscaled: 1360,\n meterToPtScaled: 1360,\n}\n\nfunction getWorldScalingCompensation(options?: ConvertOption) {\n return options?.worldScalingCompensation ?? 'scaled' // default to scaled\n}\n\n/**\n * Converts scene points (pt) to physical meters (m).\n *\n * @param point Points value to convert.\n * @param options Optional conversion options to select world scaling compensation.\n * @returns Physical length in meters.\n */\nexport function pointToPhysical(point: number, options?: ConvertOption) {\n updateValue()\n const compensation = getWorldScalingCompensation(options)\n if (compensation === 'unscaled') {\n return point / snapshot.meterToPtUnscaled\n }\n return point / snapshot.meterToPtScaled\n}\n\n/**\n * Converts physical meters (m) to scene points (pt).\n *\n * @param physical Physical length in meters to convert.\n * @param options Optional conversion options to select world scaling compensation.\n * @returns Points length in the scene.\n */\nexport function physicalToPoint(physical: number, options?: ConvertOption) {\n updateValue()\n const compensation = getWorldScalingCompensation(options)\n if (compensation === 'unscaled') {\n return physical * snapshot.meterToPtUnscaled\n }\n return physical * snapshot.meterToPtScaled\n}\n\nfunction updateValue() {\n // ssr protected\n if (typeof window === 'undefined') return\n const src = window.__webspatialsdk__?.physicalMetrics\n if (!src) return\n const next = {\n meterToPtScaled: src.meterToPtScaled ?? snapshot.meterToPtScaled,\n meterToPtUnscaled: src.meterToPtUnscaled ?? snapshot.meterToPtUnscaled,\n }\n // only update if there is a change\n if (\n next.meterToPtScaled !== snapshot.meterToPtScaled ||\n next.meterToPtUnscaled !== snapshot.meterToPtUnscaled\n ) {\n snapshot = next\n }\n}\n\n/**\n * Returns the current physical metrics used for conversions.\n *\n * @returns The current metrics snapshot `{ meterToPtUnscaled, meterToPtScaled }`.\n */\nexport function getValue(): PhysicalMetricsValueShape {\n updateValue()\n return snapshot\n}\n\n/**\n * Subscribes to physical metrics changes.\n *\n * @param cb Callback invoked when metrics update is detected.\n * @returns Unsubscribe function to remove the listener.\n */\nexport function subscribe(cb: () => void) {\n // ssr protected\n if (typeof window === 'undefined') return () => {}\n const handler = () => {\n cb()\n }\n // receive metrics update from native via SpatialWebEvent, id: \"window\"\n SpatialWebEvent.addEventReceiver('window', handler)\n return () => {\n SpatialWebEvent.removeEventReceiver('window')\n }\n}\n","import {\n createSpatialized2DElementCommand,\n CreateSpatializedDynamic3DElementCommand,\n CreateSpatializedStatic3DElementCommand,\n} from './JSBCommand'\nimport { Spatialized2DElement } from './Spatialized2DElement'\nimport { SpatializedStatic3DElement } from './SpatializedStatic3DElement'\nimport { SpatializedDynamic3DElement } from './SpatializedDynamic3DElement'\nimport { ModelSource } from './types/types'\n\nexport async function createSpatialized2DElement(): Promise<Spatialized2DElement> {\n const result = await new createSpatialized2DElementCommand().execute()\n if (!result.success) {\n throw new Error('createSpatialized2DElement failed')\n } else {\n const { id, windowProxy } = result.data!\n // set base href to make sure the relative url is correct\n windowProxy.document.head.innerHTML = `<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <base href=\"${document.baseURI}\">`\n return new Spatialized2DElement(id, windowProxy)\n }\n}\n\nexport async function createSpatializedStatic3DElement(\n modelURL?: string,\n sources?: ModelSource[],\n): Promise<SpatializedStatic3DElement> {\n const result = await new CreateSpatializedStatic3DElementCommand(\n modelURL,\n sources,\n ).execute()\n if (!result.success) {\n throw new Error('createSpatializedStatic3DElement failed')\n } else {\n const { id } = result.data\n return new SpatializedStatic3DElement(id, modelURL, sources)\n }\n}\n\nexport async function createSpatializedDynamic3DElement(): Promise<SpatializedDynamic3DElement> {\n const result = await new CreateSpatializedDynamic3DElementCommand().execute()\n if (!result.success) {\n throw new Error('createSpatializedDynamic3DElement failed')\n } else {\n const { id } = result.data\n return new SpatializedDynamic3DElement(id)\n }\n}\n","import {\n AddSpatializedElementToSpatialized2DElement,\n UpdateSpatialized2DElementProperties,\n} from './JSBCommand'\nimport { hijackWindowATag } from './scene-polyfill'\nimport { SpatializedElement } from './SpatializedElement'\nimport { Spatialized2DElementProperties } from './types/types'\n\n/**\n * Represents a 2D HTML element that has been spatialized in 3D space.\n * This class handles the integration between 2D web content and the 3D spatial environment,\n * allowing HTML elements to be positioned and interacted with in spatial applications.\n */\nexport class Spatialized2DElement extends SpatializedElement {\n /**\n * Creates a new spatialized 2D element.\n * @param id Unique identifier for this element\n * @param windowProxy Reference to the window object containing the 2D content\n */\n constructor(\n id: string,\n readonly windowProxy: WindowProxy,\n ) {\n super(id)\n // Hijack anchor tag events to handle navigation within the spatial context\n hijackWindowATag(windowProxy)\n }\n\n /**\n * Updates the properties of this 2D element.\n * This can include size, position, background, and other visual properties.\n * @param properties Partial set of properties to update\n * @returns Promise resolving when the update is complete\n */\n async updateProperties(properties: Partial<Spatialized2DElementProperties>) {\n return new UpdateSpatialized2DElementProperties(this, properties).execute()\n }\n\n /**\n * Adds a child spatialized element to this 2D element.\n * This allows for creating hierarchical structures of spatial elements.\n * @param element The child element to add\n * @returns Promise resolving when the element is added\n */\n async addSpatializedElement(element: SpatializedElement) {\n return new AddSpatializedElementToSpatialized2DElement(\n this,\n element,\n ).execute()\n }\n}\n","import { UpdateSpatializedElementTransform } from './JSBCommand'\nimport { WebSpatialProtocolResult } from './platform-adapter/interface'\nimport { SpatialObject } from './SpatialObject'\nimport { SpatialWebEvent } from './SpatialWebEvent'\nimport { createSpatialEvent } from './SpatialWebEventCreator'\nimport {\n CubeInfo,\n SpatialDragEndEvent,\n SpatialDragEvent,\n SpatialDragStartEvent,\n SpatializedElementProperties,\n SpatialMagnifyEndEvent,\n SpatialMagnifyEvent,\n SpatialRotateEndEvent,\n SpatialRotateEvent,\n SpatialTapEvent,\n} from './types/types'\nimport {\n ObjectDestroyMsg,\n SpatialDragEndMsg,\n SpatialDragMsg,\n SpatialDragStartMsg,\n SpatialMagnifyEndMsg,\n SpatialMagnifyMsg,\n SpatialRotateEndMsg,\n SpatialRotateMsg,\n SpatialTapMsg,\n SpatialWebMsgType,\n} from './WebMsgCommand'\n\n/**\n * Abstract base class for all spatialized elements in the WebSpatial environment.\n * Provides common functionality for elements that can exist in 3D space,\n * including transformation handling and gesture event processing.\n */\nexport abstract class SpatializedElement extends SpatialObject {\n /**\n * Creates a new spatialized element with the specified ID.\n * Registers the element to receive spatial events.\n * @param id Unique identifier for this element\n */\n constructor(public readonly id: string) {\n super(id)\n\n SpatialWebEvent.addEventReceiver(id, this.onReceiveEvent.bind(this))\n }\n\n /**\n * Updates the properties of this spatialized element.\n * Must be implemented by derived classes to handle specific property updates.\n * @param properties Partial set of properties to update\n * @returns Promise resolving to the result of the update operation\n */\n abstract updateProperties(\n properties: Partial<SpatializedElementProperties>,\n ): Promise<WebSpatialProtocolResult>\n\n /**\n * Updates the transformation matrix of this element in 3D space.\n * This affects the position, rotation, and scale of the element.\n * @param matrix The new transformation matrix\n * @returns Promise resolving when the transform is updated\n */\n async updateTransform(matrix: DOMMatrix) {\n return new UpdateSpatializedElementTransform(this, matrix).execute()\n }\n\n /**\n * Information about the element's bounding cube.\n * Used for spatial calculations and hit testing.\n */\n private _cubeInfo?: CubeInfo\n\n /**\n * Gets the current cube information for this element.\n * @returns The current CubeInfo or undefined if not set\n */\n get cubeInfo() {\n return this._cubeInfo\n }\n\n /**\n * The current transformation matrix of this element.\n */\n private _transform?: DOMMatrix\n\n /**\n * The inverse of the current transformation matrix.\n * Used for converting world coordinates to local coordinates.\n */\n private _transformInv?: DOMMatrix\n\n /**\n * Gets the current transformation matrix.\n * @returns The current transformation matrix or undefined if not set\n */\n get transform() {\n return this._transform\n }\n\n /**\n * Gets the inverse of the current transformation matrix.\n * @returns The inverse transformation matrix or undefined if not set\n */\n get transformInv() {\n return this._transformInv\n }\n\n /**\n * Processes events received from the WebSpatial environment.\n * Handles various spatial events like transforms, gestures, and interactions.\n * @param data The event data received from the WebSpatial system\n */\n protected onReceiveEvent(data: ReceiveEventData) {\n const { type } = data\n if (type === SpatialWebMsgType.objectdestroy) {\n this.isDestroyed = true\n } else if (type === SpatialWebMsgType.spatialtap) {\n // Handle tap gestures\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialtap,\n (data as SpatialTapMsg).detail,\n )\n this._onSpatialTap?.(event)\n } else if (type === SpatialWebMsgType.spatialdragstart) {\n const dragStartEvent = createSpatialEvent(\n SpatialWebMsgType.spatialdragstart,\n (data as SpatialDragStartMsg).detail,\n )\n this._onSpatialDragStart?.(dragStartEvent)\n } else if (type === SpatialWebMsgType.spatialdrag) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialdrag,\n (data as SpatialDragMsg).detail,\n )\n this._onSpatialDrag?.(event)\n } else if (type === SpatialWebMsgType.spatialdragend) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialdragend,\n (data as SpatialDragEndMsg).detail,\n )\n this._onSpatialDragEnd?.(event)\n } else if (type === SpatialWebMsgType.spatialrotate) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialrotate,\n (data as SpatialRotateMsg).detail,\n )\n this._onSpatialRotate?.(event)\n } else if (type === SpatialWebMsgType.spatialrotateend) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialrotateend,\n (data as SpatialRotateEndMsg).detail,\n )\n this._onSpatialRotateEnd?.(event)\n } else if (type === SpatialWebMsgType.spatialmagnify) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialmagnify,\n (data as SpatialMagnifyMsg).detail,\n )\n this._onSpatialMagnify?.(event)\n } else if (type === SpatialWebMsgType.spatialmagnifyend) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialmagnifyend,\n (data as SpatialMagnifyEndMsg).detail,\n )\n this._onSpatialMagnifyEnd?.(event)\n }\n }\n\n private _onSpatialTap?: (event: SpatialTapEvent) => void\n set onSpatialTap(value: (event: SpatialTapEvent) => void | undefined) {\n this._onSpatialTap = value\n this.updateProperties({\n enableTapGesture: value !== undefined,\n })\n }\n\n private _onSpatialDragStart?: (event: SpatialDragStartEvent) => void\n set onSpatialDragStart(\n value: (event: SpatialDragStartEvent) => void | undefined,\n ) {\n this._onSpatialDragStart = value\n this.updateProperties({\n enableDragStartGesture: this._onSpatialDragStart !== undefined,\n })\n }\n\n private _onSpatialDrag?: (event: SpatialDragEvent) => void\n set onSpatialDrag(value: (event: SpatialDragEvent) => void | undefined) {\n this._onSpatialDrag = value\n this.updateProperties({\n enableDragGesture: this._onSpatialDrag !== undefined,\n })\n }\n\n private _onSpatialDragEnd?: (event: SpatialDragEndEvent) => void\n set onSpatialDragEnd(\n value: ((event: SpatialDragEndEvent) => void) | undefined,\n ) {\n this._onSpatialDragEnd = value\n this.updateProperties({\n enableDragEndGesture: value !== undefined,\n })\n }\n\n private _onSpatialRotate?: (event: SpatialRotateEvent) => void\n set onSpatialRotate(\n value: ((event: SpatialRotateEvent) => void) | undefined,\n ) {\n this._onSpatialRotate = value\n this.updateProperties({\n enableRotateGesture: this._onSpatialRotate !== undefined,\n })\n }\n\n private _onSpatialRotateEnd?: (event: SpatialRotateEndEvent) => void\n set onSpatialRotateEnd(\n value: ((event: SpatialRotateEndEvent) => void) | undefined,\n ) {\n this._onSpatialRotateEnd = value\n this.updateProperties({\n enableRotateEndGesture: value !== undefined,\n })\n }\n\n private _onSpatialMagnify?: (event: SpatialMagnifyEvent) => void\n set onSpatialMagnify(\n value: ((event: SpatialMagnifyEvent) => void) | undefined,\n ) {\n this._onSpatialMagnify = value\n this.updateProperties({\n enableMagnifyGesture: value !== undefined,\n })\n }\n\n private _onSpatialMagnifyEnd?: (event: SpatialMagnifyEndEvent) => void\n set onSpatialMagnifyEnd(\n value: ((event: SpatialMagnifyEndEvent) => void) | undefined,\n ) {\n this._onSpatialMagnifyEnd = value\n this.updateProperties({\n enableMagnifyEndGesture: value !== undefined,\n })\n }\n\n /**\n * Cleans up resources when this element is destroyed.\n * Removes event receivers to prevent memory leaks.\n */\n override onDestroy() {\n SpatialWebEvent.removeEventReceiver(this.id)\n }\n}\n\nexport type ReceiveEventData =\n | SpatialTapMsg\n | SpatialDragStartMsg\n | SpatialDragMsg\n | SpatialDragEndMsg\n | SpatialRotateMsg\n | SpatialRotateEndMsg\n | ObjectDestroyMsg\n","import { SpatialWebMsgType } from './WebMsgCommand'\n\nexport function createSpatialEvent<T>(\n type: SpatialWebMsgType,\n detail: T,\n): CustomEvent<T> {\n return new CustomEvent<T>(type, {\n bubbles: true,\n cancelable: false,\n detail,\n })\n}\n","import { UpdateSpatializedStatic3DElementProperties } from './JSBCommand'\nimport { ReceiveEventData, SpatializedElement } from './SpatializedElement'\nimport {\n ModelSource,\n SpatializedStatic3DElementProperties,\n} from './types/types'\nimport {\n ModelLoadSuccess,\n ModelLoadFailure,\n SpatialWebMsgType,\n AnimationStateChangeDetail,\n AnimationStateChangeMsg,\n} from './WebMsgCommand'\n\n/**\n * Represents a static 3D model element in the spatial environment.\n * This class handles loading and displaying pre-built 3D models from URLs,\n * and provides events for load success and failure.\n */\nexport class SpatializedStatic3DElement extends SpatializedElement {\n /**\n * Creates a new spatialized static 3D element with the specified ID and URL.\n * Registers the element to receive spatial events.\n * @param id Unique identifier for this element\n * @param modelURL URL of the 3D model\n * @param sources Optional fallback model sources\n */\n constructor(id: string, modelURL?: string, sources?: ModelSource[]) {\n super(id)\n this.modelURL = modelURL\n this.sources = sources\n }\n\n /**\n * Promise resolver for the ready state.\n * Used to resolve the ready promise when the model is loaded.\n */\n private _readyResolve?: (success: boolean) => void\n\n /**\n * Caches the last model URL to detect changes.\n * Used to reset the ready promise when the model URL changes.\n */\n private modelURL?: string\n\n /**\n * Caches the last sources array to detect changes.\n */\n private sources?: ModelSource[]\n\n /**\n * The model URL that was successfully loaded by the native runtime.\n */\n private _currentSrc: string = ''\n\n get currentSrc(): string {\n return this._currentSrc\n }\n\n /**\n * Creates a new promise for tracking the ready state of the model.\n * @returns Promise that resolves when the model is loaded (true) or fails to load (false)\n */\n private createReadyPromise() {\n // If there's an existing promise reject it before it's replaced\n this._readyResolve?.(false)\n return new Promise<boolean>(resolve => {\n this._readyResolve = resolve\n })\n }\n\n /**\n * Promise that resolves when the model is loaded.\n * Resolves to true on successful load, false on failure.\n */\n ready: Promise<boolean> = this.createReadyPromise()\n\n /**\n * Updates the properties of this static 3D element.\n * Handles special case for modelURL changes by resetting the ready promise.\n * @param properties Partial set of properties to update\n * @returns Promise resolving when the update is complete\n */\n async updateProperties(\n properties: Partial<SpatializedStatic3DElementProperties>,\n ) {\n let needsReadyReset = false\n if (properties.modelURL !== undefined) {\n if (this.modelURL !== properties.modelURL) {\n this.modelURL = properties.modelURL\n needsReadyReset = true\n }\n }\n if (properties.sources !== undefined) {\n const prevJson = JSON.stringify(this.sources)\n const nextJson = JSON.stringify(properties.sources)\n if (prevJson !== nextJson) {\n this.sources = properties.sources\n needsReadyReset = true\n }\n }\n if (needsReadyReset) {\n this.ready = this.createReadyPromise()\n }\n if (properties.autoplay !== undefined) {\n this._autoplay = properties.autoplay\n }\n if (properties.loop !== undefined) {\n this._loop = properties.loop\n }\n if (properties.playbackRate !== undefined) {\n this._playbackRate = properties.playbackRate\n }\n return new UpdateSpatializedStatic3DElementProperties(\n this,\n properties,\n ).execute()\n }\n\n /**\n * Total animation duration in seconds, synced from native.\n */\n private _duration: number = 0\n\n /**\n * Returns the total animation duration in seconds.\n */\n get duration(): number {\n return this._duration\n }\n\n /**\n * Playback speed multiplier.\n */\n private _playbackRate: number = 1\n\n /**\n * Returns the current playback rate.\n */\n get playbackRate(): number {\n return this._playbackRate\n }\n\n /**\n * Sets the playback rate and sends it to native.\n */\n set playbackRate(value: number) {\n this.updateProperties({ playbackRate: value })\n }\n\n /**\n * Whether the animation is currently paused.\n */\n private _paused: boolean = true\n\n /**\n * Returns whether the animation is currently paused.\n */\n get paused(): boolean {\n return this._paused\n }\n\n /**\n * Callback for animation state changes.\n */\n private _onAnimationStateChangeCallback?: (\n detail: AnimationStateChangeDetail,\n ) => void\n\n /**\n * Sets the callback for animation state changes.\n */\n set onAnimationStateChangeCallback(\n callback: undefined | ((detail: AnimationStateChangeDetail) => void),\n ) {\n this._onAnimationStateChangeCallback = callback\n }\n\n /**\n * Starts or resumes animation playback.\n * @returns Promise resolving when the command is sent\n */\n async play(): Promise<void> {\n this._paused = false\n await this.updateProperties({ animationPaused: false })\n }\n\n /**\n * Pauses animation playback.\n * @returns Promise resolving when the command is sent\n */\n async pause(): Promise<void> {\n this._paused = true\n await this.updateProperties({ animationPaused: true })\n }\n\n /**\n * Processes events received from the WebSpatial environment.\n * Handles model loading events in addition to base spatial events.\n * @param data The event data received from the WebSpatial system\n */\n override onReceiveEvent(data: Static3DReceiveEventData) {\n if (data.type === SpatialWebMsgType.modelloaded) {\n // On old runtimes (<⍺2.1) detail is not returned so fallback to modelURL\n this._currentSrc = data.detail?.src ?? this.modelURL ?? ''\n // Handle successful model loading\n this._onLoadCallback?.()\n this._readyResolve?.(true)\n } else if (data.type === SpatialWebMsgType.modelloadfailed) {\n // Handle model loading failure\n this._onLoadFailureCallback?.()\n this._readyResolve?.(false)\n } else if (data.type === SpatialWebMsgType.animationstatechange) {\n this._paused = data.detail.paused\n this._duration = data.detail.duration\n this._onAnimationStateChangeCallback?.(data.detail)\n } else {\n // Handle other spatial events using the base class implementation\n super.onReceiveEvent(data)\n }\n }\n\n /**\n * Whether the model should automatically play its first animation on load.\n */\n private _autoplay: boolean = false\n\n /**\n * Returns whether autoplay is enabled for this element.\n */\n get autoplay(): boolean {\n return this._autoplay\n }\n\n /**\n * Whether the model animation should loop continuously.\n */\n private _loop: boolean = false\n\n /**\n * Returns whether loop is enabled for this element.\n */\n get loop(): boolean {\n return this._loop\n }\n\n /**\n * Callback function for successful model loading.\n */\n private _onLoadCallback?: () => void\n\n /**\n * Sets the callback function for successful model loading.\n * @param callback Function to call when the model is loaded successfully\n */\n set onLoadCallback(callback: undefined | (() => void)) {\n this._onLoadCallback = callback\n }\n\n /**\n * Callback function for model loading failure.\n */\n private _onLoadFailureCallback?: undefined | (() => void)\n\n /**\n * Sets the callback function for model loading failure.\n * @param callback Function to call when the model fails to load\n */\n set onLoadFailureCallback(callback: undefined | (() => void)) {\n this._onLoadFailureCallback = callback\n }\n\n updateModelTransform(transform: DOMMatrixReadOnly) {\n const modelTransform = Array.from(transform.toFloat64Array())\n this.updateProperties({ modelTransform })\n }\n}\n\ntype Static3DReceiveEventData =\n | ModelLoadSuccess\n | ModelLoadFailure\n | ReceiveEventData\n | AnimationStateChangeMsg\n","import {\n AddEntityToDynamic3DCommand,\n SetParentForEntityCommand,\n UpdateSpatializedDynamic3DElementProperties,\n} from './JSBCommand'\nimport { SpatialEntity } from './reality'\nimport { SpatializedElement } from './SpatializedElement'\nimport {\n SpatialEntityEventType,\n SpatialEntityOrReality,\n SpatializedElementProperties,\n} from './types/types'\n\nexport class SpatializedDynamic3DElement extends SpatializedElement {\n children: SpatialEntityOrReality[] = []\n events: Record<string, (data: any) => void> = {}\n\n constructor(id: string) {\n super(id)\n }\n\n async addEntity(entity: SpatialEntity) {\n const ans = new SetParentForEntityCommand(entity.id, this.id).execute()\n this.children.push(entity)\n entity.parent = this\n return ans\n }\n\n addEvent(type: SpatialEntityEventType, callback: (data: any) => void) {\n this.events[type] = callback\n }\n\n removeEvent(eventName: SpatialEntityEventType) {\n if (this.events[eventName]) {\n delete this.events[eventName]\n }\n }\n\n dispatchEvent(evt: CustomEvent) {\n this.events[evt.type]?.(evt)\n }\n\n async updateProperties(properties: Partial<SpatializedElementProperties>) {\n return new UpdateSpatializedDynamic3DElementProperties(\n this,\n properties,\n ).execute()\n }\n}\n","import { SpatialObject } from '../SpatialObject'\nimport {\n CreateAttachmentEntityCommand,\n UpdateAttachmentEntityCommand,\n InitializeAttachmentCommand,\n} from '../JSBCommand'\nimport {\n AttachmentEntityOptions,\n AttachmentEntityUpdateOptions,\n} from '../types/types'\n\nexport class Attachment extends SpatialObject {\n constructor(\n id: string,\n private readonly windowProxy: WindowProxy,\n private options: AttachmentEntityOptions,\n ) {\n super(id)\n }\n\n getContainer(): HTMLElement {\n return (this.windowProxy as Window).document.body\n }\n\n getWindowProxy(): WindowProxy {\n return this.windowProxy\n }\n\n async update(options: AttachmentEntityUpdateOptions) {\n if (this.isDestroyed) return\n if (options.position) this.options.position = options.position\n if (options.size) this.options.size = options.size\n return new UpdateAttachmentEntityCommand(this.id, options).execute()\n }\n}\n\nexport async function createAttachmentEntity(\n options: AttachmentEntityOptions,\n): Promise<Attachment> {\n const result = await new CreateAttachmentEntityCommand(options).execute()\n if (!result.success) {\n throw new Error('createAttachmentEntity failed: ' + result?.errorMessage)\n }\n const { id, windowProxy } = result.data!\n await new InitializeAttachmentCommand(id, options).execute()\n return new Attachment(id, windowProxy, options)\n}\n","import {\n CreateModelComponentCommand,\n CreateModelAssetCommand,\n CreateSpatialEntityCommand,\n CreateSpatialGeometryCommand,\n CreateSpatialModelEntityCommand,\n CreateSpatialUnlitMaterialCommand,\n} from '../JSBCommand'\nimport {\n ModelComponentOptions,\n ModelAssetOptions,\n SpatialGeometryOptions,\n SpatialModelEntityCreationOptions,\n SpatialUnlitMaterialOptions,\n SpatialEntityUserData,\n} from '../types/types'\nimport { SpatialEntity, SpatialModelEntity } from './entity'\nimport { ModelComponent } from './component'\nimport { SpatialGeometry } from './geometry'\nimport { SpatialUnlitMaterial } from './material'\nimport { SpatialModelAsset } from './resource'\n\nexport async function createSpatialEntity(\n userData?: SpatialEntityUserData,\n): Promise<SpatialEntity> {\n const result = await new CreateSpatialEntityCommand(userData?.name).execute()\n if (!result.success) {\n throw new Error('createSpatialEntity failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new SpatialEntity(id, userData)\n }\n}\n\nexport async function createSpatialGeometry<T extends SpatialGeometry>(\n ctor: new (...args: any[]) => T,\n options: SpatialGeometryOptions,\n) {\n const result = await new CreateSpatialGeometryCommand(\n (ctor as any).type,\n options,\n ).execute()\n if (!result.success) {\n throw new Error('createSpatialGeometry failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new ctor(id, options) as T\n }\n}\n\nexport async function createSpatialUnlitMaterial(\n options: SpatialUnlitMaterialOptions,\n) {\n const result = await new CreateSpatialUnlitMaterialCommand(options).execute()\n if (!result.success) {\n throw new Error('createSpatialUnlitMaterial failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new SpatialUnlitMaterial(id, options)\n }\n}\n\nexport async function createModelComponent(options: ModelComponentOptions) {\n const result = await new CreateModelComponentCommand(options).execute()\n if (!result.success) {\n throw new Error('createModelComponent failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new ModelComponent(id, options)\n }\n}\n\nexport async function createSpatialModelEntity(\n options: SpatialModelEntityCreationOptions,\n userData?: SpatialEntityUserData,\n) {\n const result = await new CreateSpatialModelEntityCommand(options).execute()\n if (!result.success) {\n throw new Error('createSpatialModelEntity failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new SpatialModelEntity(id, options, userData)\n }\n}\n\nexport async function createModelAsset(options: ModelAssetOptions) {\n const result = await new CreateModelAssetCommand(options).execute()\n if (!result.success) {\n throw new Error('createModelAsset failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new SpatialModelAsset(id, options)\n }\n}\n","import {\n ConvertFromEntityToEntityCommand,\n ConvertFromEntityToSceneCommand,\n ConvertFromSceneToEntityCommand,\n SetParentForEntityCommand,\n} from './../../JSBCommand'\nimport {\n SpatialEntityEventType,\n SpatialEntityOrReality,\n SpatialEntityUserData,\n Vec3,\n} from '../../types/types'\nimport {\n AddComponentToEntityCommand,\n AddEntityToEntityCommand,\n RemoveComponentFromEntityCommand,\n RemoveEntityFromParentCommand,\n UpdateEntityEventCommand,\n UpdateEntityPropertiesCommand,\n} from '../../JSBCommand'\nimport { SpatialObject } from '../../SpatialObject'\nimport { SpatialEntityProperties } from '../../types/types'\nimport { SpatialComponent } from '../component/SpatialComponent'\nimport { SpatialWebEvent } from '../../SpatialWebEvent'\nimport { createSpatialEvent } from '../../SpatialWebEventCreator'\nimport {\n ObjectDestroyMsg,\n SpatialDragEndMsg,\n SpatialDragMsg,\n SpatialDragStartMsg,\n SpatialMagnifyEndMsg,\n SpatialMagnifyMsg,\n SpatialRotateEndMsg,\n SpatialRotateMsg,\n SpatialTapMsg,\n SpatialWebMsgType,\n} from '../../WebMsgCommand'\n\nexport class SpatialEntity extends SpatialObject {\n position: Vec3 = { x: 0, y: 0, z: 0 }\n rotation: Vec3 = { x: 0, y: 0, z: 0 }\n scale: Vec3 = { x: 1, y: 1, z: 1 }\n\n events: Record<string, (data: any) => void> = {}\n children: SpatialEntity[] = []\n parent: SpatialEntityOrReality | null = null\n private _enableInput: boolean = false\n\n get enableInput(): boolean {\n return this._enableInput\n }\n\n set enableInput(value: boolean) {\n // Why enabling only 'spatialtap' makes the entity interactive:\n // - On the native (Swift/RealityKit) side, SpatialEntity.updateGesture(type, isEnable)\n // toggles per-gesture flags. Then enableInteractive = enableTap || enableRotate || enableDrag || enableMagnify.\n // - As soon as any gesture (e.g., 'spatialtap') is enabled, enableInteractive becomes true and\n // InputTargetComponent is attached, making the entity targetable by targetedToAnyEntity().\n // - The view layer forwards hit gestures to the web, so enabling 'spatialtap' is sufficient to\n // make the entity targetable; enable additional gestures only when needed.\n if (this._enableInput === value) return\n this._enableInput = value\n void this.updateEntityEvent('spatialtap', value).catch(err => {\n console.error('enableInput updateEntityEvent failed', 'spatialtap', err)\n // Roll back local flag if the native toggle fails to keep web/native states consistent.\n // Otherwise, the web side would think the entity is interactive while RealityKit is not.\n if (this._enableInput === value) {\n this._enableInput = !value\n }\n })\n }\n constructor(\n id: string,\n public userData?: SpatialEntityUserData,\n ) {\n super(id)\n SpatialWebEvent.addEventReceiver(id, this.onReceiveEvent)\n }\n\n async addComponent(component: SpatialComponent) {\n return new AddComponentToEntityCommand(this, component).execute()\n }\n async removeComponent(component: SpatialComponent) {\n return new RemoveComponentFromEntityCommand(this, component).execute()\n }\n async setPosition(position: Vec3) {\n return this.updateTransform({ position })\n }\n async setRotation(rotation: Vec3) {\n return this.updateTransform({ rotation })\n }\n async setScale(scale: Vec3) {\n return this.updateTransform({ scale })\n }\n\n async addEntity(ent: SpatialEntity) {\n const ans = await new SetParentForEntityCommand(ent.id, this.id).execute()\n this.children.push(ent)\n ent.parent = this\n return ans\n }\n async removeFromParent() {\n const ans = await new SetParentForEntityCommand(\n this.id,\n undefined,\n ).execute()\n if (this.parent) {\n this.parent.children = this.parent.children.filter(\n child => child.id !== this.id,\n )\n this.parent = null\n }\n return ans\n }\n\n async updateTransform(properties: Partial<SpatialEntityProperties>) {\n this.position = properties.position ?? this.position\n this.rotation = properties.rotation ?? this.rotation\n this.scale = properties.scale ?? this.scale\n return new UpdateEntityPropertiesCommand(this, properties).execute()\n }\n\n async addEvent(type: SpatialEntityEventType, callback: (data: any) => void) {\n if (this.events[type]) {\n // replace if exist\n this.events[type] = callback\n } else {\n try {\n await this.updateEntityEvent(type, true)\n this.events[type] = callback\n } catch (error) {\n console.error('addEvent failed', type)\n }\n }\n }\n\n async removeEvent(eventName: SpatialEntityEventType) {\n if (this.events[eventName]) {\n delete this.events[eventName]\n try {\n await this.updateEntityEvent(eventName, false)\n } catch (error) {\n console.error('removeEvent failed', eventName)\n }\n }\n }\n\n async updateEntityEvent(\n eventName: SpatialEntityEventType,\n isEnable: boolean,\n ) {\n return new UpdateEntityEventCommand(this, eventName, isEnable).execute()\n }\n private onReceiveEvent = (\n data:\n | SpatialTapMsg\n | SpatialDragStartMsg\n | SpatialDragMsg\n | SpatialDragEndMsg\n | SpatialMagnifyMsg\n | SpatialMagnifyEndMsg\n | SpatialRotateMsg\n | SpatialRotateEndMsg\n | ObjectDestroyMsg,\n ) => {\n // console.log('SpatialEntityEvent', data)\n const { type } = data\n if (type === SpatialWebMsgType.objectdestroy) {\n this.isDestroyed = true\n }\n // tap\n else if (type === SpatialWebMsgType.spatialtap) {\n const evt = createSpatialEvent(SpatialWebMsgType.spatialtap, data.detail)\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialdragstart) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialdragstart,\n data.detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialdrag) {\n const evt = createSpatialEvent(SpatialWebMsgType.spatialdrag, data.detail)\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialdragend) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialdragend,\n data.detail,\n )\n this.dispatchEvent(evt)\n }\n // rotate\n else if (type === SpatialWebMsgType.spatialrotate) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialrotate,\n data.detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialrotateend) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialrotateend,\n data.detail,\n )\n this.dispatchEvent(evt)\n }\n // magnify\n else if (type === SpatialWebMsgType.spatialmagnify) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialmagnify,\n data.detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialmagnifyend) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialmagnifyend,\n data.detail,\n )\n this.dispatchEvent(evt)\n }\n }\n\n dispatchEvent(evt: CustomEvent) {\n // Set origin once at the first dispatch in the bubbling chain\n if (!(evt as any).__origin) {\n Object.defineProperty(evt, '__origin', { value: this, enumerable: false })\n }\n this.events[evt.type]?.(evt)\n if (evt.bubbles && !evt.cancelBubble) {\n if (this.parent) {\n this.parent.dispatchEvent(evt)\n }\n }\n }\n\n protected onDestroy(): void {\n SpatialWebEvent.removeEventReceiver(this.id)\n // handle children\n this.children.forEach(child => {\n child.parent = null\n })\n this.children = []\n // handle parent\n if (this.parent) {\n this.parent.children = this.parent.children.filter(\n child => child.id !== this.id,\n )\n this.parent = null\n }\n }\n // onUpdate(properties: SpatialEntityProperties) {\n // this.position = properties.position\n // this.rotation = properties.rotation\n // this.scale = properties.scale\n // }\n async convertFromEntityToEntity(\n fromEntityId: string,\n toEntityId: string,\n position: Vec3,\n ) {\n return new ConvertFromEntityToEntityCommand(\n fromEntityId,\n toEntityId,\n position,\n ).execute()\n }\n\n async convertFromEntityToScene(fromEntityId: string, position: Vec3) {\n return new ConvertFromEntityToSceneCommand(fromEntityId, position).execute()\n }\n async convertFromSceneToEntity(entityId: string, position: Vec3) {\n return new ConvertFromSceneToEntityCommand(entityId, position).execute()\n }\n}\n","import {\n SpatialEntityUserData,\n SpatialModelEntityCreationOptions,\n} from '../../types/types'\nimport { SetMaterialsOnEntityCommand } from '../../JSBCommand'\nimport { SpatialMaterial } from '../material/SpatialMaterial'\nimport { SpatialEntity } from './SpatialEntity'\n\nexport class SpatialModelEntity extends SpatialEntity {\n constructor(\n public id: string,\n public options?: SpatialModelEntityCreationOptions,\n public userData?: SpatialEntityUserData,\n ) {\n super(id, userData)\n }\n\n async setMaterials(materials: SpatialMaterial[]) {\n return new SetMaterialsOnEntityCommand(this.id, materials).execute()\n }\n}\n","import { SpatialObject } from '../../SpatialObject'\nimport { SpatialWebEvent } from '../../SpatialWebEvent'\nimport { ObjectDestroyMsg, SpatialWebMsgType } from '../../WebMsgCommand'\n\nexport class SpatialComponent extends SpatialObject {\n constructor(id: string) {\n super(id)\n SpatialWebEvent.addEventReceiver(id, this.onReceiveEvent)\n }\n\n private onReceiveEvent = (data: ObjectDestroyMsg) => {\n const { type } = data\n if (type === SpatialWebMsgType.objectdestroy) {\n this.isDestroyed = true\n }\n }\n}\n","import { ModelComponentOptions } from '../../types/types'\nimport { SpatialComponent } from './SpatialComponent'\n\nexport class ModelComponent extends SpatialComponent {\n constructor(\n id: string,\n public options: ModelComponentOptions,\n ) {\n super(id)\n }\n}\n","import { UpdateUnlitMaterialProperties } from '../../JSBCommand'\nimport { SpatialUnlitMaterialOptions } from '../../types/types'\nimport { SpatialMaterial } from './SpatialMaterial'\n\nexport class SpatialUnlitMaterial extends SpatialMaterial {\n constructor(\n public id: string,\n public options: SpatialUnlitMaterialOptions,\n ) {\n super(id, 'unlit')\n }\n\n updateProperties(properties: Partial<SpatialUnlitMaterialOptions>) {\n return new UpdateUnlitMaterialProperties(this, properties).execute()\n }\n}\n","import { SpatialObject } from '../../SpatialObject'\nimport { SpatialMaterialType } from '../../types/types'\n\nexport abstract class SpatialMaterial extends SpatialObject {\n constructor(\n public id: string,\n public type: SpatialMaterialType,\n ) {\n super(id)\n this.type = type\n }\n\n abstract updateProperties(properties: any): void\n}\n","import { SpatialObject } from '../../SpatialObject'\nimport { ModelAssetOptions } from '../../types/types'\n\nexport class SpatialModelAsset extends SpatialObject {\n constructor(\n public id: string,\n public options: ModelAssetOptions,\n ) {\n super(id)\n }\n}\n","import { SpatialObject } from '../../SpatialObject'\nimport { SpatialGeometryOptions, SpatialGeometryType } from '../../types/types'\n\nexport class SpatialGeometry extends SpatialObject {\n static type: SpatialGeometryType\n constructor(\n public id: string,\n public options: SpatialGeometryOptions,\n ) {\n super(id)\n }\n}\n","import {\n SpatialBoxGeometryOptions,\n SpatialGeometryType,\n} from '../../types/types'\nimport { SpatialGeometry } from './SpatialGeometry'\n\nexport class SpatialBoxGeometry extends SpatialGeometry {\n static type: SpatialGeometryType = 'BoxGeometry'\n constructor(\n public id: string,\n public options: SpatialBoxGeometryOptions,\n ) {\n super(id, options)\n }\n}\n","import {\n SpatialGeometryType,\n SpatialSphereGeometryOptions,\n} from '../../types/types'\nimport { SpatialGeometry } from './SpatialGeometry'\n\nexport class SpatialSphereGeometry extends SpatialGeometry {\n static type: SpatialGeometryType = 'SphereGeometry'\n constructor(\n public id: string,\n public options: SpatialSphereGeometryOptions,\n ) {\n super(id, options)\n }\n}\n","import {\n SpatialGeometryType,\n SpatialCylinderGeometryOptions,\n} from '../../types/types'\nimport { SpatialGeometry } from './SpatialGeometry'\n\nexport class SpatialCylinderGeometry extends SpatialGeometry {\n static type: SpatialGeometryType = 'CylinderGeometry'\n constructor(\n public id: string,\n public options: SpatialCylinderGeometryOptions,\n ) {\n super(id, options)\n }\n}\n","import {\n SpatialGeometryType,\n SpatialPlaneGeometryOptions,\n} from '../../types/types'\nimport { SpatialGeometry } from './SpatialGeometry'\n\nexport class SpatialPlaneGeometry extends SpatialGeometry {\n static type: SpatialGeometryType = 'PlaneGeometry'\n constructor(\n public id: string,\n public options: SpatialPlaneGeometryOptions,\n ) {\n super(id, options)\n }\n}\n","import {\n SpatialGeometryType,\n SpatialConeGeometryOptions,\n} from '../../types/types'\nimport { SpatialGeometry } from './SpatialGeometry'\n\nexport class SpatialConeGeometry extends SpatialGeometry {\n static type: SpatialGeometryType = 'ConeGeometry'\n constructor(\n public id: string,\n public options: SpatialConeGeometryOptions,\n ) {\n super(id, options)\n }\n}\n","import { initScene } from './scene-polyfill'\nimport { SpatialScene } from './SpatialScene'\nimport { Spatialized2DElement } from './Spatialized2DElement'\nimport {\n createSpatialized2DElement,\n createSpatializedDynamic3DElement,\n} from './SpatializedElementCreator'\nimport { createSpatializedStatic3DElement } from './SpatializedElementCreator'\nimport { Attachment, createAttachmentEntity } from './reality/Attachment'\nimport { SpatializedStatic3DElement } from './SpatializedStatic3DElement'\nimport {\n ModelComponentOptions,\n ModelAssetOptions,\n SpatialBoxGeometryOptions,\n SpatialConeGeometryOptions,\n SpatialCylinderGeometryOptions,\n SpatialGeometryOptions,\n SpatialModelEntityCreationOptions,\n SpatialPlaneGeometryOptions,\n SpatialSceneCreationOptions,\n SpatialSphereGeometryOptions,\n SpatialUnlitMaterialOptions,\n SpatialEntityUserData,\n AttachmentEntityOptions,\n ModelSource,\n} from './types/types'\nimport { SpatializedDynamic3DElement } from './SpatializedDynamic3DElement'\nimport { SpatialEntity } from './reality/entity/SpatialEntity'\nimport {\n createModelAsset,\n createModelComponent,\n createSpatialEntity,\n createSpatialGeometry,\n createSpatialModelEntity,\n createSpatialUnlitMaterial,\n} from './reality/realityCreator'\nimport {\n SpatialBoxGeometry,\n SpatialPlaneGeometry,\n SpatialSphereGeometry,\n SpatialConeGeometry,\n SpatialCylinderGeometry,\n} from './reality'\n\n/**\n * Session used to establish a connection to the spatial renderer of the system.\n * All spatial resources must be created through this session object.\n * This class serves as the main factory for creating spatial elements and geometries.\n */\nexport class SpatialSession {\n /**\n * Gets the singleton instance of the spatial scene.\n * The spatial scene is the root container for all spatial elements.\n * @returns The SpatialScene singleton instance\n */\n getSpatialScene(): SpatialScene {\n return SpatialScene.getInstance()\n }\n\n /**\n * Creates a new 2D element that can be spatialized in the 3D environment.\n * 2D elements represent HTML content that can be positioned in 3D space.\n * @returns Promise resolving to a new Spatialized2DElement instance\n */\n createSpatialized2DElement(): Promise<Spatialized2DElement> {\n return createSpatialized2DElement()\n }\n\n /**\n * Creates a new static 3D element with an optional model URL.\n * Static 3D elements represent pre-built 3D models that can be loaded from a URL.\n * @param modelURL Optional URL to the 3D model to load\n * @returns Promise resolving to a new SpatializedStatic3DElement instance\n */\n createSpatializedStatic3DElement(\n modelURL?: string,\n sources?: ModelSource[],\n ): Promise<SpatializedStatic3DElement> {\n return createSpatializedStatic3DElement(modelURL, sources)\n }\n\n /**\n * Initializes the spatial scene with custom configuration.\n * This is a reference to the initScene function from scene-polyfill.\n */\n initScene = initScene\n\n /**\n * Creates a new dynamic 3D element that can be manipulated at runtime.\n * Dynamic 3D elements allow for programmatic creation and modification of 3D content.\n * @returns Promise resolving to a new SpatializedDynamic3DElement instance\n */\n createSpatializedDynamic3DElement(): Promise<SpatializedDynamic3DElement> {\n return createSpatializedDynamic3DElement()\n }\n\n /**\n * Creates a new spatial entity with an optional name.\n * Entities are the basic building blocks for creating custom 3D content.\n * @param name Optional name for the entity\n * @returns Promise resolving to a new SpatialEntity instance\n */\n createEntity(userData?: SpatialEntityUserData): Promise<SpatialEntity> {\n return createSpatialEntity(userData)\n }\n\n /**\n * Creates a box geometry with optional configuration.\n * @param options Configuration options for the box geometry\n * @returns Promise resolving to a new SpatialBoxGeometry instance\n */\n createBoxGeometry(options: SpatialBoxGeometryOptions = {}) {\n return createSpatialGeometry(SpatialBoxGeometry, options)\n }\n\n /**\n * Creates a plane geometry with optional configuration.\n * @param options Configuration options for the plane geometry\n * @returns Promise resolving to a new SpatialPlaneGeometry instance\n */\n createPlaneGeometry(options: SpatialPlaneGeometryOptions = {}) {\n return createSpatialGeometry(SpatialPlaneGeometry, options)\n }\n\n /**\n * Creates a sphere geometry with optional configuration.\n * @param options Configuration options for the sphere geometry\n * @returns Promise resolving to a new SpatialSphereGeometry instance\n */\n createSphereGeometry(options: SpatialSphereGeometryOptions = {}) {\n return createSpatialGeometry(SpatialSphereGeometry, options)\n }\n\n /**\n * Creates a cone geometry with the specified configuration.\n * @param options Configuration options for the cone geometry\n * @returns Promise resolving to a new SpatialConeGeometry instance\n */\n createConeGeometry(options: SpatialConeGeometryOptions) {\n return createSpatialGeometry(SpatialConeGeometry, options)\n }\n\n /**\n * Creates a cylinder geometry with the specified configuration.\n * @param options Configuration options for the cylinder geometry\n * @returns Promise resolving to a new SpatialCylinderGeometry instance\n */\n createCylinderGeometry(options: SpatialCylinderGeometryOptions) {\n return createSpatialGeometry(SpatialCylinderGeometry, options)\n }\n\n /**\n * Creates a model component with the specified configuration.\n * Model components are used to add 3D model rendering capabilities to entities.\n * @param options Configuration options for the model component\n * @returns Promise resolving to a new ModelComponent instance\n */\n createModelComponent(options: ModelComponentOptions) {\n return createModelComponent(options)\n }\n\n /**\n * Creates an unlit material with the specified configuration.\n * Unlit materials don't respond to lighting in the scene.\n * @param options Configuration options for the unlit material\n * @returns Promise resolving to a new SpatialUnlitMaterial instance\n */\n createUnlitMaterial(options: SpatialUnlitMaterialOptions) {\n return createSpatialUnlitMaterial(options)\n }\n\n /**\n * Creates a model asset with the specified configuration.\n * Model assets represent 3D model resources that can be used by entities.\n * @param options Configuration options for the model asset\n * @returns Promise resolving to a new SpatialModelAsset instance\n */\n createModelAsset(options: ModelAssetOptions) {\n return createModelAsset(options)\n }\n\n /**\n * Creates a spatial model entity with the specified configuration.\n * This is a convenience method for creating an entity with a model component.\n * @param options Configuration options for the spatial model entity\n * @returns Promise resolving to a new SpatialModelEntity instance\n */\n createSpatialModelEntity(\n options: SpatialModelEntityCreationOptions,\n userData?: SpatialEntityUserData,\n ) {\n return createSpatialModelEntity(options, userData)\n }\n\n /**\n * Creates an attachment entity that renders 2D HTML content as a child\n * of a 3D entity in the scene graph.\n * @param options Configuration options including parent entity ID, position, and size\n * @returns Promise resolving to a new Attachment instance\n */\n createAttachmentEntity(\n options: AttachmentEntityOptions,\n ): Promise<Attachment> {\n return createAttachmentEntity(options)\n }\n}\n","import { SpatialSession } from './SpatialSession'\nimport { SpatialWebEvent } from './SpatialWebEvent'\n\n/**\n * Base object designed to be placed on navigator.spatial to mirror navigator.xr for webxr.\n * This is the main entry point for the WebSpatial SDK, providing access to spatial capabilities.\n */\nexport class Spatial {\n private wsAppShellVersionFromUA: string | null | undefined\n\n /**\n * Requests a spatial session object from the browser.\n * This is the primary method to initialize spatial functionality.\n * @returns The SpatialSession instance or null if not available in the current browser\n * [TODO] discuss implications of this not being async\n */\n requestSession() {\n if (this.runInSpatialWeb()) {\n SpatialWebEvent.init()\n return new SpatialSession()\n } else {\n return null\n }\n }\n\n /**\n * Checks if the current page is running in a spatial web environment.\n * This method detects if the application is running in a WebSpatial-compatible browser.\n * @returns True if running in a spatial web environment, false otherwise\n */\n runInSpatialWeb() {\n if (navigator.userAgent.indexOf('WebSpatial/') >= 0) {\n return true\n }\n return false\n }\n\n getShellVersionFromUA(): string | null {\n if (this.wsAppShellVersionFromUA !== undefined) {\n return this.wsAppShellVersionFromUA\n }\n if (\n typeof navigator === 'undefined' ||\n typeof navigator.userAgent !== 'string'\n ) {\n this.wsAppShellVersionFromUA = null\n return null\n }\n\n const match = navigator.userAgent.match(\n /WSAppShell\\/(\\d+(?:\\.\\d+){2}(?:[-+][0-9A-Za-z.-]+)*)/,\n )\n this.wsAppShellVersionFromUA = match ? match[1] : '1.3.0'\n return this.wsAppShellVersionFromUA\n }\n\n /** @deprecated\n * Checks if WebSpatial is supported in the current environment.\n * Verifies compatibility between native and client versions.\n * @returns True if web spatial is supported by this webpage\n */\n isSupported() {\n return true\n }\n\n /** @deprecated\n * Gets the native WebSpatial version from the browser environment.\n * The version format follows semantic versioning (x.x.x).\n * @returns Native version string in format \"x.x.x\"\n */\n getNativeVersion() {\n if (window.__WebSpatialData && window.__WebSpatialData.getNativeVersion) {\n return window.__WebSpatialData.getNativeVersion()\n }\n return window.WebSpatailNativeVersion === 'WS_SHELL_VERSION'\n ? this.getClientVersion()\n : window.WebSpatailNativeVersion\n }\n\n /** @deprecated\n * Gets the client SDK version.\n * The version format follows semantic versioning (x.x.x).\n * @returns Client SDK version string in format \"x.x.x\"\n */\n getClientVersion() {\n // @ts-ignore\n return __WEBSPATIAL_CORE_SDK_VERSION__\n }\n}\n","export { SpatialObject } from './SpatialObject'\nexport { Spatial } from './Spatial'\nexport { SpatialSession } from './SpatialSession'\nexport { SpatialScene } from './SpatialScene'\nexport { SpatializedElement } from './SpatializedElement'\nexport { Spatialized2DElement } from './Spatialized2DElement'\nexport { SpatializedStatic3DElement } from './SpatializedStatic3DElement'\nexport { SpatializedDynamic3DElement } from './SpatializedDynamic3DElement'\nexport * as PhysicalMetrics from './physicalMetrics'\n\nexport * from './reality'\nexport * from './types/types'\nexport * from './types/global.d'\n\n// side effects\nimport { injectSceneHook } from './scene-polyfill'\nimport { isSSREnv } from './ssr-polyfill'\nimport { spatialWindowPolyfill } from './spatial-window-polyfill'\n\nexport { isSSREnv }\n\nif (!isSSREnv() && navigator.userAgent.indexOf('WebSpatial/') > 0) {\n injectSceneHook()\n spatialWindowPolyfill()\n}\n","import { parseCornerRadius } from './utils'\nimport { Spatial } from './Spatial'\nimport { SpatialSession } from './SpatialSession'\nimport { BackgroundMaterialType } from './types/types'\n\nconst spatial = new Spatial()\nlet session: SpatialSession | undefined = undefined\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 session?.getSpatialScene()?.updateSpatialProperties({\n material: backgroundMaterial as BackgroundMaterialType,\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}\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 session?.getSpatialScene()?.updateSpatialProperties({\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 session?.getSpatialScene().updateSpatialProperties({\n opacity,\n })\n}\n\nfunction checkOpacity() {\n const computedStyle = getComputedStyle(document.documentElement)\n const opacity = parseFloat(computedStyle.getPropertyValue('opacity'))\n setOpacity(opacity)\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 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(checkCSSProperties)\n\n headObserver.observe(document.head, { childList: true, subtree: true })\n}\n\nfunction checkCSSProperties() {\n checkHtmlBackgroundMaterial()\n checkCornerRadius()\n checkOpacity()\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 async function spatialWindowPolyfill() {\n if (!spatial.runInSpatialWeb()) {\n return\n }\n\n session = await spatial.requestSession()!\n\n if (document.readyState === 'complete') {\n checkCSSProperties()\n } else {\n window.addEventListener('load', () => {\n checkCSSProperties()\n })\n }\n\n hijackDocumentElementStyle()\n monitorExternalStyleChange()\n monitorHTMLAttributeChange()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAM,OAEO;AAFb;AAAA;AAAA;AAAA,IAAM,QAAQ,OAAO,WAAW;AAEzB,IAAM,WAAW,MAAM;AAAA;AAAA;;;ACF9B,IAMa;AANb;AAAA;AAAA;AAMO,IAAM,cAAN,MAA6C;AAAA,MAClD,QAAQ,KAAa,KAAqC;AACxD,eAAO,QAAQ,QAAQ;AAAA,UACrB,SAAS;AAAA,UACT,MAAM;AAAA,UACN,WAAW;AAAA,UACX,cAAc;AAAA,QAChB,CAAC;AAAA,MACH;AAAA,MACA,uBACE,QACA,OACA,QACA,UACmC;AACnC,eAAO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,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;AAEA,eAAsB,wBAAwB;AAC5C,MAAI,CAAC,QAAQ,gBAAgB,GAAG;AAC9B;AAAA,EACF;AAEA,YAAU,MAAM,QAAQ,eAAe;AAEvC,MAAI,SAAS,eAAe,YAAY;AACtC,uBAAmB;AAAA,EACrB,OAAO;AACL,WAAO,iBAAiB,QAAQ,MAAM;AACpC,yBAAmB;AAAA,IACrB,CAAC;AAAA,EACH;AAEA,6BAA2B;AAC3B,6BAA2B;AAC3B,6BAA2B;AAC7B;;;ADhKA,IAAI,CAAC,SAAS,KAAK,UAAU,UAAU,QAAQ,aAAa,IAAI,GAAG;AACjE,kBAAgB;AAChB,wBAAsB;AACxB;","names":["nextRequestId","requestId","MAX_ID","PuppeteerPlatform","PicoOSPlatform","AndroidPlatform","VisionOSPlatform","SpatializedElementType","SpatialSceneState","window","defaultSceneConfig","window"]}
|