{"ast":null,"code":"import { Logger } from \"./logger.js\";\nimport { SceneSerializer } from \"./sceneSerializer.js\";\n/**\n * Class used to connect with the reflector zone of the sandbox via the reflector bridge\n * @since 5.0.0\n */\nexport class Reflector {\n /**\n * Constructs a reflector object.\n * @param scene The scene to use\n * @param hostname The hostname of the reflector bridge\n * @param port The port of the reflector bridge\n */\n constructor(scene, hostname, port) {\n this._scene = scene;\n Logger.Log(`[Reflector] Connecting to ws://${hostname}:${port}`);\n this._webSocket = new WebSocket(`ws://${hostname}:${port}`);\n this._webSocket.onmessage = event => {\n const message = event.data;\n if (message.startsWith(Reflector._SERVER_PREFIX)) {\n const serverMessage = message.substring(Reflector._SERVER_PREFIX.length);\n Logger.Log(`[Reflector] Received server message: ${serverMessage.substring(0, 64)}`);\n this._handleServerMessage(serverMessage);\n return;\n } else {\n Logger.Log(`[Reflector] Received client message: ${message.substring(0, 64)}`);\n this._handleClientMessage();\n }\n };\n this._webSocket.onclose = event => {\n Logger.Log(`[Reflector] Disconnected ${event.code} ${event.reason}`);\n };\n }\n /**\n * Closes the reflector connection\n */\n close() {\n this._webSocket.close();\n }\n _handleServerMessage(message) {\n switch (message) {\n case \"connected\":\n {\n SceneSerializer.SerializeAsync(this._scene).then(serialized => {\n this._webSocket.send(`load|${JSON.stringify(serialized)}`);\n });\n break;\n }\n }\n }\n _handleClientMessage() {\n // do nothing\n }\n}\nReflector._SERVER_PREFIX = \"$$\";","map":{"version":3,"names":["Logger","SceneSerializer","Reflector","constructor","scene","hostname","port","_scene","Log","_webSocket","WebSocket","onmessage","event","message","data","startsWith","_SERVER_PREFIX","serverMessage","substring","length","_handleServerMessage","_handleClientMessage","onclose","code","reason","close","SerializeAsync","then","serialized","send","JSON","stringify"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Misc/reflector.js"],"sourcesContent":["import { Logger } from \"./logger.js\";\nimport { SceneSerializer } from \"./sceneSerializer.js\";\n/**\n * Class used to connect with the reflector zone of the sandbox via the reflector bridge\n * @since 5.0.0\n */\nexport class Reflector {\n /**\n * Constructs a reflector object.\n * @param scene The scene to use\n * @param hostname The hostname of the reflector bridge\n * @param port The port of the reflector bridge\n */\n constructor(scene, hostname, port) {\n this._scene = scene;\n Logger.Log(`[Reflector] Connecting to ws://${hostname}:${port}`);\n this._webSocket = new WebSocket(`ws://${hostname}:${port}`);\n this._webSocket.onmessage = (event) => {\n const message = event.data;\n if (message.startsWith(Reflector._SERVER_PREFIX)) {\n const serverMessage = message.substring(Reflector._SERVER_PREFIX.length);\n Logger.Log(`[Reflector] Received server message: ${serverMessage.substring(0, 64)}`);\n this._handleServerMessage(serverMessage);\n return;\n }\n else {\n Logger.Log(`[Reflector] Received client message: ${message.substring(0, 64)}`);\n this._handleClientMessage();\n }\n };\n this._webSocket.onclose = (event) => {\n Logger.Log(`[Reflector] Disconnected ${event.code} ${event.reason}`);\n };\n }\n /**\n * Closes the reflector connection\n */\n close() {\n this._webSocket.close();\n }\n _handleServerMessage(message) {\n switch (message) {\n case \"connected\": {\n SceneSerializer.SerializeAsync(this._scene).then((serialized) => {\n this._webSocket.send(`load|${JSON.stringify(serialized)}`);\n });\n break;\n }\n }\n }\n _handleClientMessage() {\n // do nothing\n }\n}\nReflector._SERVER_PREFIX = \"$$\";\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,aAAa;AACpC,SAASC,eAAe,QAAQ,sBAAsB;AACtD;AACA;AACA;AACA;AACA,OAAO,MAAMC,SAAS,CAAC;EACnB;AACJ;AACA;AACA;AACA;AACA;EACIC,WAAWA,CAACC,KAAK,EAAEC,QAAQ,EAAEC,IAAI,EAAE;IAC/B,IAAI,CAACC,MAAM,GAAGH,KAAK;IACnBJ,MAAM,CAACQ,GAAG,CAAC,kCAAkCH,QAAQ,IAAIC,IAAI,EAAE,CAAC;IAChE,IAAI,CAACG,UAAU,GAAG,IAAIC,SAAS,CAAC,QAAQL,QAAQ,IAAIC,IAAI,EAAE,CAAC;IAC3D,IAAI,CAACG,UAAU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