UNPKG

networked-aframe

Version:

A web framework for building multi-user virtual reality experiences.

120 lines (88 loc) 200 kB
/* * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). * This devtool is neither made for production nor for readable output files. * It uses "eval()" calls to create a separate source file in the browser devtools. * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) * or disable the default devtool with "devtool: false". * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). */ /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ "./node_modules/buffered-interpolation/dist/buffered-interpolation.js": /*!****************************************************************************!*\ !*** ./node_modules/buffered-interpolation/dist/buffered-interpolation.js ***! \****************************************************************************/ /***/ ((module) => { "use strict"; eval("\n\nvar _createClass = function () {\n function defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n }\n return function (Constructor, protoProps, staticProps) {\n if (protoProps) defineProperties(Constructor.prototype, protoProps);\n if (staticProps) defineProperties(Constructor, staticProps);\n return Constructor;\n };\n}();\nfunction _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\n\n/* global THREE */\n\nvar INITIALIZING = 0;\nvar BUFFERING = 1;\nvar PLAYING = 2;\nvar MODE_LERP = 0;\nvar MODE_HERMITE = 1;\nvar vectorPool = [];\nvar quatPool = [];\nvar framePool = [];\nvar getPooledVector = function getPooledVector() {\n return vectorPool.shift() || new THREE.Vector3();\n};\nvar getPooledQuaternion = function getPooledQuaternion() {\n return quatPool.shift() || new THREE.Quaternion();\n};\nvar getPooledFrame = function getPooledFrame() {\n var frame = framePool.pop();\n if (!frame) {\n frame = {\n position: new THREE.Vector3(),\n velocity: new THREE.Vector3(),\n scale: new THREE.Vector3(),\n quaternion: new THREE.Quaternion(),\n time: 0\n };\n }\n return frame;\n};\nvar freeFrame = function freeFrame(f) {\n return framePool.push(f);\n};\nvar InterpolationBuffer = function () {\n function InterpolationBuffer() {\n var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MODE_LERP;\n var bufferTime = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.15;\n _classCallCheck(this, InterpolationBuffer);\n this.state = INITIALIZING;\n this.buffer = [];\n this.bufferTime = bufferTime * 1000;\n this.time = 0;\n this.mode = mode;\n this.originFrame = getPooledFrame();\n this.position = new THREE.Vector3();\n this.quaternion = new THREE.Quaternion();\n this.scale = new THREE.Vector3(1, 1, 1);\n }\n _createClass(InterpolationBuffer, [{\n key: \"hermite\",\n value: function hermite(target, t, p1, p2, v1, v2) {\n var t2 = t * t;\n var t3 = t * t * t;\n var a = 2 * t3 - 3 * t2 + 1;\n var b = -2 * t3 + 3 * t2;\n var c = t3 - 2 * t2 + t;\n var d = t3 - t2;\n target.copy(p1.multiplyScalar(a));\n target.add(p2.multiplyScalar(b));\n target.add(v1.multiplyScalar(c));\n target.add(v2.multiplyScalar(d));\n }\n }, {\n key: \"lerp\",\n value: function lerp(target, v1, v2, alpha) {\n target.lerpVectors(v1, v2, alpha);\n }\n }, {\n key: \"slerp\",\n value: function slerp(target, r1, r2, alpha) {\n target.slerpQuaternions(r1, r2, alpha);\n }\n }, {\n key: \"updateOriginFrameToBufferTail\",\n value: function updateOriginFrameToBufferTail() {\n freeFrame(this.originFrame);\n this.originFrame = this.buffer.shift();\n }\n }, {\n key: \"appendBuffer\",\n value: function appendBuffer(position, velocity, quaternion, scale) {\n var tail = this.buffer.length > 0 ? this.buffer[this.buffer.length - 1] : null;\n // update the last entry in the buffer if this is the same frame\n if (tail && tail.time === this.time) {\n if (position) {\n tail.position.copy(position);\n }\n if (velocity) {\n tail.velocity.copy(velocity);\n }\n if (quaternion) {\n tail.quaternion.copy(quaternion);\n }\n if (scale) {\n tail.scale.copy(scale);\n }\n } else {\n var priorFrame = tail || this.originFrame;\n var newFrame = getPooledFrame();\n newFrame.position.copy(position || priorFrame.position);\n newFrame.velocity.copy(velocity || priorFrame.velocity);\n newFrame.quaternion.copy(quaternion || priorFrame.quaternion);\n newFrame.scale.copy(scale || priorFrame.scale);\n newFrame.time = this.time;\n this.buffer.push(newFrame);\n }\n }\n }, {\n key: \"setTarget\",\n value: function setTarget(position, velocity, quaternion, scale) {\n this.appendBuffer(position, velocity, quaternion, scale);\n }\n }, {\n key: \"setPosition\",\n value: function setPosition(position, velocity) {\n this.appendBuffer(position, velocity, null, null);\n }\n }, {\n key: \"setQuaternion\",\n value: function setQuaternion(quaternion) {\n this.appendBuffer(null, null, quaternion, null);\n }\n }, {\n key: \"setScale\",\n value: function setScale(scale) {\n this.appendBuffer(null, null, null, scale);\n }\n }, {\n key: \"update\",\n value: function update(delta) {\n if (this.state === INITIALIZING) {\n if (this.buffer.length > 0) {\n this.updateOriginFrameToBufferTail();\n this.position.copy(this.originFrame.position);\n this.quaternion.copy(this.originFrame.quaternion);\n this.scale.copy(this.originFrame.scale);\n this.state = BUFFERING;\n }\n }\n if (this.state === BUFFERING) {\n if (this.buffer.length > 0 && this.time > this.bufferTime) {\n this.state = PLAYING;\n }\n }\n if (this.state === PLAYING) {\n var mark = this.time - this.bufferTime;\n //Purge this.buffer of expired frames\n while (this.buffer.length > 0 && mark > this.buffer[0].time) {\n //if this is the last frame in the buffer, just update the time and reuse it\n if (this.buffer.length > 1) {\n this.updateOriginFrameToBufferTail();\n } else {\n this.originFrame.position.copy(this.buffer[0].position);\n this.originFrame.velocity.copy(this.buffer[0].velocity);\n this.originFrame.quaternion.copy(this.buffer[0].quaternion);\n this.originFrame.scale.copy(this.buffer[0].scale);\n this.originFrame.time = this.buffer[0].time;\n this.buffer[0].time = this.time + delta;\n }\n }\n if (this.buffer.length > 0 && this.buffer[0].time > 0) {\n var targetFrame = this.buffer[0];\n var delta_time = targetFrame.time - this.originFrame.time;\n var alpha = (mark - this.originFrame.time) / delta_time;\n if (this.mode === MODE_LERP) {\n this.lerp(this.position, this.originFrame.position, targetFrame.position, alpha);\n } else if (this.mode === MODE_HERMITE) {\n this.hermite(this.position, alpha, this.originFrame.position, targetFrame.position, this.originFrame.velocity.multiplyScalar(delta_time), targetFrame.velocity.multiplyScalar(delta_time));\n }\n this.slerp(this.quaternion, this.originFrame.quaternion, targetFrame.quaternion, alpha);\n this.lerp(this.scale, this.originFrame.scale, targetFrame.scale, alpha);\n }\n }\n if (this.state !== INITIALIZING) {\n this.time += delta;\n }\n }\n }, {\n key: \"getPosition\",\n value: function getPosition() {\n return this.position;\n }\n }, {\n key: \"getQuaternion\",\n value: function getQuaternion() {\n return this.quaternion;\n }\n }, {\n key: \"getScale\",\n value: function getScale() {\n return this.scale;\n }\n }]);\n return InterpolationBuffer;\n}();\nmodule.exports = InterpolationBuffer;\n\n//# sourceURL=webpack://networked-aframe/./node_modules/buffered-interpolation/dist/buffered-interpolation.js?"); /***/ }), /***/ "./src/ChildEntityCache.js": /*!*********************************!*\ !*** ./src/ChildEntityCache.js ***! \*********************************/ /***/ ((module) => { eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nvar ChildEntityCache = /*#__PURE__*/function () {\n function ChildEntityCache() {\n _classCallCheck(this, ChildEntityCache);\n this.dict = {};\n }\n return _createClass(ChildEntityCache, [{\n key: \"addChild\",\n value: function addChild(parentNetworkId, childData) {\n if (!this.hasParent(parentNetworkId)) {\n this.dict[parentNetworkId] = [];\n }\n this.dict[parentNetworkId].push(childData);\n }\n }, {\n key: \"getChildren\",\n value: function getChildren(parentNetworkId) {\n if (!this.hasParent(parentNetworkId)) {\n return [];\n }\n var children = this.dict[parentNetworkId];\n delete this.dict[parentNetworkId];\n return children;\n }\n\n /* Private */\n }, {\n key: \"hasParent\",\n value: function hasParent(parentId) {\n return !!this.dict[parentId];\n }\n }]);\n}();\nmodule.exports = ChildEntityCache;\n\n//# sourceURL=webpack://networked-aframe/./src/ChildEntityCache.js?"); /***/ }), /***/ "./src/DeepEquals.js": /*!***************************!*\ !*** ./src/DeepEquals.js ***! \***************************/ /***/ ((module) => { "use strict"; eval("// Patched version of fast-deep-equal which does not\n// allocate memory via calling Object.keys\n//\n// https://github.com/epoberezkin/fast-deep-equal/blob/master/index.js\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nvar isArray = Array.isArray;\nvar keyList = Object.keys;\nvar hasProp = Object.prototype.hasOwnProperty;\nmodule.exports = function equal(a, b) {\n if (a === b) return true;\n if (a && b && _typeof(a) == 'object' && _typeof(b) == 'object') {\n var arrA = isArray(a),\n arrB = isArray(b),\n i,\n length,\n key;\n if (arrA && arrB) {\n length = a.length;\n if (length != b.length) return false;\n for (i = length; i-- !== 0;) if (!equal(a[i], b[i])) return false;\n return true;\n }\n if (arrA != arrB) return false;\n var dateA = a instanceof Date,\n dateB = b instanceof Date;\n if (dateA != dateB) return false;\n if (dateA && dateB) return a.getTime() == b.getTime();\n var regexpA = a instanceof RegExp,\n regexpB = b instanceof RegExp;\n if (regexpA != regexpB) return false;\n if (regexpA && regexpB) return a.toString() == b.toString();\n var keys = keyList(a);\n length = keys.length;\n if (length !== keyList(b).length) return false;\n for (i = length; i-- !== 0;) if (!hasProp.call(b, keys[i])) return false;\n for (i = length; i-- !== 0;) {\n key = keys[i];\n if (!equal(a[key], b[key])) return false;\n }\n return true;\n }\n return a !== a && b !== b;\n};\n\n//# sourceURL=webpack://networked-aframe/./src/DeepEquals.js?"); /***/ }), /***/ "./src/NafIndex.js": /*!*************************!*\ !*** ./src/NafIndex.js ***! \*************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { eval("var options = __webpack_require__(/*! ./options */ \"./src/options.js\");\nvar utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\nvar NafLogger = __webpack_require__(/*! ./NafLogger */ \"./src/NafLogger.js\");\nvar Schemas = __webpack_require__(/*! ./Schemas */ \"./src/Schemas.js\");\nvar NetworkEntities = __webpack_require__(/*! ./NetworkEntities */ \"./src/NetworkEntities.js\");\nvar NetworkConnection = __webpack_require__(/*! ./NetworkConnection */ \"./src/NetworkConnection.js\");\nvar AdapterFactory = __webpack_require__(/*! ./adapters/AdapterFactory */ \"./src/adapters/AdapterFactory.js\");\nvar naf = {};\nnaf.app = '';\nnaf.room = '';\nnaf.clientId = '';\nnaf.options = options;\nnaf.utils = utils;\nnaf.log = new NafLogger();\nnaf.schemas = new Schemas();\nnaf.version = \"0.14.0\";\nnaf.adapters = new AdapterFactory();\nvar entities = new NetworkEntities();\nvar connection = new NetworkConnection(entities);\nnaf.connection = connection;\nnaf.entities = entities;\nmodule.exports = window.NAF = naf;\n\n//# sourceURL=webpack://networked-aframe/./src/NafIndex.js?"); /***/ }), /***/ "./src/NafInterface.js": /*!*****************************!*\ !*** ./src/NafInterface.js ***! \*****************************/ /***/ ((module) => { eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n/* global NAF */\nvar NafInterface = /*#__PURE__*/function () {\n function NafInterface() {\n _classCallCheck(this, NafInterface);\n }\n return _createClass(NafInterface, [{\n key: \"notImplemented\",\n value: function notImplemented(name) {\n NAF.log.error('Interface method not implemented:', name);\n }\n }]);\n}();\nmodule.exports = NafInterface;\n\n//# sourceURL=webpack://networked-aframe/./src/NafInterface.js?"); /***/ }), /***/ "./src/NafLogger.js": /*!**************************!*\ !*** ./src/NafLogger.js ***! \**************************/ /***/ ((module) => { eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n/*eslint no-console: \"off\" */\nvar NafLogger = /*#__PURE__*/function () {\n function NafLogger() {\n _classCallCheck(this, NafLogger);\n this.debug = false;\n }\n return _createClass(NafLogger, [{\n key: \"setDebug\",\n value: function setDebug(debug) {\n this.debug = debug;\n }\n }, {\n key: \"write\",\n value: function write() {\n if (this.debug) {\n console.log.apply(this, arguments);\n }\n }\n }, {\n key: \"warn\",\n value: function warn() {\n console.warn.apply(this, arguments);\n }\n }, {\n key: \"error\",\n value: function error() {\n console.error.apply(this, arguments);\n }\n }]);\n}();\nmodule.exports = NafLogger;\n\n//# sourceURL=webpack://networked-aframe/./src/NafLogger.js?"); /***/ }), /***/ "./src/NetworkConnection.js": /*!**********************************!*\ !*** ./src/NetworkConnection.js ***! \**********************************/ /***/ ((module) => { eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n/* global NAF */\nvar ReservedDataType = {\n Update: 'u',\n UpdateMulti: 'um',\n Remove: 'r'\n};\nvar NetworkConnection = /*#__PURE__*/function () {\n function NetworkConnection(networkEntities) {\n _classCallCheck(this, NetworkConnection);\n this.entities = networkEntities;\n this.setupDefaultDataSubscriptions();\n this.connectedClients = {};\n this.activeDataChannels = {};\n }\n return _createClass(NetworkConnection, [{\n key: \"setNetworkAdapter\",\n value: function setNetworkAdapter(adapter) {\n this.adapter = adapter;\n }\n }, {\n key: \"setupDefaultDataSubscriptions\",\n value: function setupDefaultDataSubscriptions() {\n this.dataChannelSubs = {};\n this.dataChannelSubs[ReservedDataType.Update] = this.entities.updateEntity.bind(this.entities);\n this.dataChannelSubs[ReservedDataType.UpdateMulti] = this.entities.updateEntityMulti.bind(this.entities);\n this.dataChannelSubs[ReservedDataType.Remove] = this.entities.removeRemoteEntity.bind(this.entities);\n }\n }, {\n key: \"connect\",\n value: function connect(serverUrl, appName, roomName) {\n var enableAudio = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;\n var enableVideo = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;\n NAF.app = appName;\n NAF.room = roomName;\n this.adapter.setServerUrl(serverUrl);\n this.adapter.setApp(appName);\n this.adapter.setRoom(roomName);\n var webrtcOptions = {\n audio: enableAudio,\n video: enableVideo,\n datachannel: true\n };\n this.adapter.setWebRtcOptions(webrtcOptions);\n this.adapter.setServerConnectListeners(this.connectSuccess.bind(this), this.connectFailure.bind(this));\n this.adapter.setDataChannelListeners(this.dataChannelOpen.bind(this), this.dataChannelClosed.bind(this), this.receivedData.bind(this));\n this.adapter.setRoomOccupantListener(this.occupantsReceived.bind(this));\n return this.adapter.connect();\n }\n }, {\n key: \"onConnect\",\n value: function onConnect(callback) {\n this.onConnectCallback = callback;\n if (this.isConnected()) {\n callback();\n } else {\n document.body.addEventListener('connected', callback, false);\n }\n }\n }, {\n key: \"connectSuccess\",\n value: function connectSuccess(clientId) {\n NAF.log.write('Networked-Aframe Client ID:', clientId);\n NAF.clientId = clientId;\n var evt = new CustomEvent('connected', {\n 'detail': {\n clientId: clientId\n }\n });\n document.body.dispatchEvent(evt);\n }\n }, {\n key: \"connectFailure\",\n value: function connectFailure(errorCode, message) {\n NAF.log.error(errorCode, \"failure to connect\");\n }\n }, {\n key: \"occupantsReceived\",\n value: function occupantsReceived(occupantList) {\n var prevConnectedClients = Object.assign({}, this.connectedClients);\n this.connectedClients = occupantList;\n this.checkForDisconnectingClients(prevConnectedClients, occupantList);\n this.checkForConnectingClients(occupantList);\n }\n }, {\n key: \"checkForDisconnectingClients\",\n value: function checkForDisconnectingClients(oldOccupantList, newOccupantList) {\n for (var id in oldOccupantList) {\n var clientFound = newOccupantList[id];\n if (!clientFound) {\n NAF.log.write('Closing stream to', id);\n this.adapter.closeStreamConnection(id);\n }\n }\n }\n\n // Some adapters will handle this internally\n }, {\n key: \"checkForConnectingClients\",\n value: function checkForConnectingClients(occupantList) {\n for (var id in occupantList) {\n var startConnection = this.isNewClient(id) && this.adapter.shouldStartConnectionTo(occupantList[id]);\n if (startConnection) {\n NAF.log.write('Opening datachannel to', id);\n this.adapter.startStreamConnection(id);\n }\n }\n }\n }, {\n key: \"getConnectedClients\",\n value: function getConnectedClients() {\n return this.connectedClients;\n }\n }, {\n key: \"isConnected\",\n value: function isConnected() {\n return !!NAF.clientId;\n }\n }, {\n key: \"isMineAndConnected\",\n value: function isMineAndConnected(clientId) {\n return this.isConnected() && NAF.clientId === clientId;\n }\n }, {\n key: \"isNewClient\",\n value: function isNewClient(clientId) {\n return !this.isConnectedTo(clientId);\n }\n }, {\n key: \"isConnectedTo\",\n value: function isConnectedTo(clientId) {\n return this.adapter.getConnectStatus(clientId) === NAF.adapters.IS_CONNECTED;\n }\n }, {\n key: \"dataChannelOpen\",\n value: function dataChannelOpen(clientId) {\n NAF.log.write('Opened data channel from ' + clientId);\n this.activeDataChannels[clientId] = true;\n this.entities.completeSync(clientId, true);\n var evt = new CustomEvent('clientConnected', {\n detail: {\n clientId: clientId\n }\n });\n document.body.dispatchEvent(evt);\n }\n }, {\n key: \"dataChannelClosed\",\n value: function dataChannelClosed(clientId) {\n NAF.log.write('Closed data channel from ' + clientId);\n this.activeDataChannels[clientId] = false;\n this.entities.removeEntitiesOfClient(clientId);\n var evt = new CustomEvent('clientDisconnected', {\n detail: {\n clientId: clientId\n }\n });\n document.body.dispatchEvent(evt);\n }\n }, {\n key: \"hasActiveDataChannel\",\n value: function hasActiveDataChannel(clientId) {\n return !!this.activeDataChannels[clientId];\n }\n }, {\n key: \"broadcastData\",\n value: function broadcastData(dataType, data) {\n this.adapter.broadcastData(dataType, data);\n }\n }, {\n key: \"broadcastDataGuaranteed\",\n value: function broadcastDataGuaranteed(dataType, data) {\n this.adapter.broadcastDataGuaranteed(dataType, data);\n }\n }, {\n key: \"sendData\",\n value: function sendData(toClientId, dataType, data, guaranteed) {\n if (this.hasActiveDataChannel(toClientId)) {\n if (guaranteed) {\n this.adapter.sendDataGuaranteed(toClientId, dataType, data);\n } else {\n this.adapter.sendData(toClientId, dataType, data);\n }\n } else {\n // console.error(\"NOT-CONNECTED\", \"not connected to \" + toClient);\n }\n }\n }, {\n key: \"sendDataGuaranteed\",\n value: function sendDataGuaranteed(toClientId, dataType, data) {\n this.sendData(toClientId, dataType, data, true);\n }\n }, {\n key: \"subscribeToDataChannel\",\n value: function subscribeToDataChannel(dataType, callback) {\n if (this.isReservedDataType(dataType)) {\n NAF.log.error('NetworkConnection@subscribeToDataChannel: ' + dataType + ' is a reserved dataType. Choose another');\n return;\n }\n this.dataChannelSubs[dataType] = callback;\n }\n }, {\n key: \"unsubscribeToDataChannel\",\n value: function unsubscribeToDataChannel(dataType) {\n if (this.isReservedDataType(dataType)) {\n NAF.log.error('NetworkConnection@unsubscribeToDataChannel: ' + dataType + ' is a reserved dataType. Choose another');\n return;\n }\n delete this.dataChannelSubs[dataType];\n }\n }, {\n key: \"isReservedDataType\",\n value: function isReservedDataType(dataType) {\n return dataType == ReservedDataType.Update || dataType == ReservedDataType.Remove;\n }\n }, {\n key: \"receivedData\",\n value: function receivedData(fromClientId, dataType, data, source) {\n if (this.dataChannelSubs[dataType]) {\n this.dataChannelSubs[dataType](fromClientId, dataType, data, source);\n } else {\n NAF.log.write('NetworkConnection@receivedData: ' + dataType + ' has not been subscribed to yet. Call subscribeToDataChannel()');\n }\n }\n }, {\n key: \"getServerTime\",\n value: function getServerTime() {\n return this.adapter.getServerTime();\n }\n }, {\n key: \"disconnect\",\n value: function disconnect() {\n this.entities.removeRemoteEntities();\n if (this.adapter) {\n this.adapter.disconnect();\n }\n NAF.app = '';\n NAF.room = '';\n NAF.clientId = '';\n this.connectedClients = {};\n this.activeDataChannels = {};\n this.adapter = null;\n this.setupDefaultDataSubscriptions();\n document.body.removeEventListener('connected', this.onConnectCallback);\n }\n }]);\n}();\nmodule.exports = NetworkConnection;\n\n//# sourceURL=webpack://networked-aframe/./src/NetworkConnection.js?"); /***/ }), /***/ "./src/NetworkEntities.js": /*!********************************!*\ !*** ./src/NetworkEntities.js ***! \********************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n/* global NAF */\nvar ChildEntityCache = __webpack_require__(/*! ./ChildEntityCache */ \"./src/ChildEntityCache.js\");\nvar NetworkEntities = /*#__PURE__*/function () {\n function NetworkEntities() {\n _classCallCheck(this, NetworkEntities);\n this.entities = {};\n this.childCache = new ChildEntityCache();\n this.onRemoteEntityCreatedEvent = new Event('remoteEntityCreated');\n this._persistentFirstSyncs = {};\n }\n return _createClass(NetworkEntities, [{\n key: \"registerEntity\",\n value: function registerEntity(networkId, entity) {\n this.entities[networkId] = entity;\n }\n }, {\n key: \"createRemoteEntity\",\n value: function createRemoteEntity(entityData) {\n NAF.log.write('Creating remote entity', entityData);\n var networkId = entityData.networkId;\n var el = NAF.schemas.getCachedTemplate(entityData.template);\n this.initPosition(el, entityData.components);\n this.initRotation(el, entityData.components);\n this.addNetworkComponent(el, entityData);\n this.registerEntity(networkId, el);\n return el;\n }\n }, {\n key: \"initPosition\",\n value: function initPosition(entity, componentData) {\n var hasPosition = componentData['position'];\n if (hasPosition) {\n var position = componentData.position;\n entity.setAttribute('position', position);\n }\n }\n }, {\n key: \"initRotation\",\n value: function initRotation(entity, componentData) {\n var hasRotation = componentData['rotation'];\n if (hasRotation) {\n var rotation = componentData.rotation;\n entity.setAttribute('rotation', rotation);\n }\n }\n }, {\n key: \"addNetworkComponent\",\n value: function addNetworkComponent(entity, entityData) {\n var networkData = {\n template: entityData.template,\n creator: entityData.creator,\n owner: entityData.owner,\n networkId: entityData.networkId,\n persistent: entityData.persistent\n };\n entity.setAttribute('networked', networkData);\n entity.firstUpdateData = entityData;\n }\n }, {\n key: \"updateEntityMulti\",\n value: function updateEntityMulti(client, dataType, entityDatas, source) {\n if (NAF.options.syncSource && source !== NAF.options.syncSource) return;\n for (var i = 0, l = entityDatas.d.length; i < l; i++) {\n this.updateEntity(client, 'u', entityDatas.d[i], source);\n }\n }\n }, {\n key: \"updateEntity\",\n value: function updateEntity(client, dataType, entityData, source) {\n if (NAF.options.syncSource && source !== NAF.options.syncSource) return;\n var networkId = entityData.networkId;\n if (this.hasEntity(networkId)) {\n this.entities[networkId].components.networked.networkUpdate(entityData);\n } else if (entityData.isFirstSync && NAF.connection.activeDataChannels[entityData.owner] !== false) {\n if (NAF.options.firstSyncSource && source !== NAF.options.firstSyncSource) {\n NAF.log.write('Ignoring first sync from disallowed source', source);\n } else {\n if (entityData.persistent) {\n // If we receive a firstSync for a persistent entity that we don't have yet,\n // we assume the scene will create it at some point, so stash the update for later use.\n this._persistentFirstSyncs[networkId] = entityData;\n } else {\n this.receiveFirstUpdateFromEntity(entityData);\n }\n }\n }\n }\n }, {\n key: \"receiveFirstUpdateFromEntity\",\n value: function receiveFirstUpdateFromEntity(entityData) {\n var parent = entityData.parent;\n var networkId = entityData.networkId;\n var parentNotCreatedYet = parent && !this.hasEntity(parent);\n if (parentNotCreatedYet) {\n this.childCache.addChild(parent, entityData);\n } else {\n var remoteEntity = this.createRemoteEntity(entityData);\n this.createAndAppendChildren(networkId, remoteEntity);\n this.addEntityToPage(remoteEntity, parent);\n }\n }\n }, {\n key: \"createAndAppendChildren\",\n value: function createAndAppendChildren(parentId, parentEntity) {\n var children = this.childCache.getChildren(parentId);\n for (var i = 0; i < children.length; i++) {\n var childEntityData = children[i];\n var childId = childEntityData.networkId;\n if (this.hasEntity(childId)) {\n NAF.log.warn('Tried to instantiate entity multiple times', childId, childEntityData, 'Existing entity:', this.getEntity(childId));\n continue;\n }\n var childEntity = this.createRemoteEntity(childEntityData);\n this.createAndAppendChildren(childId, childEntity);\n parentEntity.appendChild(childEntity);\n }\n }\n }, {\n key: \"addEntityToPage\",\n value: function addEntityToPage(entity, parentId) {\n if (this.hasEntity(parentId)) {\n this.addEntityToParent(entity, parentId);\n } else {\n this.addEntityToSceneRoot(entity);\n }\n }\n }, {\n key: \"addEntityToParent\",\n value: function addEntityToParent(entity, parentId) {\n this.entities[parentId].appendChild(entity);\n }\n }, {\n key: \"addEntityToSceneRoot\",\n value: function addEntityToSceneRoot(el) {\n var scene = document.querySelector('a-scene');\n scene.appendChild(el);\n }\n }, {\n key: \"completeSync\",\n value: function completeSync(targetClientId, isFirstSync) {\n for (var id in this.entities) {\n if (this.entities[id]) {\n this.entities[id].components.networked.syncAll(targetClientId, isFirstSync);\n }\n }\n }\n }, {\n key: \"removeRemoteEntity\",\n value: function removeRemoteEntity(toClient, dataType, data, source) {\n if (NAF.options.syncSource && source !== NAF.options.syncSource) return;\n var id = data.networkId;\n return this.removeEntity(id);\n }\n }, {\n key: \"removeEntitiesOfClient\",\n value: function removeEntitiesOfClient(clientId) {\n var removedEntities = [];\n for (var id in this.entities) {\n var entity = this.entities[id];\n var creator = NAF.utils.getCreator(entity);\n var owner = NAF.utils.getNetworkOwner(entity);\n if (creator === clientId || !creator && owner === clientId) {\n var component = this.entities[id].getAttribute(\"networked\");\n if (component && component.persistent) {\n // everyone will attempt to take ownership, someone will win, it does not particularly matter who\n NAF.utils.takeOwnership(entity);\n } else {\n removedEntities.push(this.removeEntity(id));\n }\n }\n }\n return removedEntities;\n }\n }, {\n key: \"removeEntity\",\n value: function removeEntity(id) {\n this.forgetPersistentFirstSync(id);\n if (this.hasEntity(id)) {\n var entity = this.entities[id];\n this.forgetEntity(id);\n entity.parentNode.removeChild(entity);\n return entity;\n } else {\n NAF.log.error(\"Tried to remove entity I don't have.\");\n return null;\n }\n }\n }, {\n key: \"forgetEntity\",\n value: function forgetEntity(id) {\n delete this.entities[id];\n this.forgetPersistentFirstSync(id);\n }\n }, {\n key: \"getPersistentFirstSync\",\n value: function getPersistentFirstSync(id) {\n return this._persistentFirstSyncs[id];\n }\n }, {\n key: \"forgetPersistentFirstSync\",\n value: function forgetPersistentFirstSync(id) {\n delete this._persistentFirstSyncs[id];\n }\n }, {\n key: \"getEntity\",\n value: function getEntity(id) {\n if (this.entities[id]) {\n return this.entities[id];\n }\n return null;\n }\n }, {\n key: \"hasEntity\",\n value: function hasEntity(id) {\n return !!this.entities[id];\n }\n }, {\n key: \"removeRemoteEntities\",\n value: function removeRemoteEntities() {\n this.childCache = new ChildEntityCache();\n for (var id in this.entities) {\n var owner = this.entities[id].getAttribute('networked').owner;\n if (owner != NAF.clientId) {\n this.removeEntity(id);\n }\n }\n }\n }]);\n}();\nmodule.exports = NetworkEntities;\n\n//# sourceURL=webpack://networked-aframe/./src/NetworkEntities.js?"); /***/ }), /***/ "./src/Schemas.js": /*!************************!*\ !*** ./src/Schemas.js ***! \************************/ /***/ ((module) => { eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n/* global NAF */\nvar Schemas = /*#__PURE__*/function () {\n function Schemas() {\n _classCallCheck(this, Schemas);\n this.schemaDict = {};\n this.templateCache = {};\n }\n return _createClass(Schemas, [{\n key: \"createDefaultSchema\",\n value: function createDefaultSchema(name) {\n return {\n template: name,\n components: ['position', 'rotation']\n };\n }\n }, {\n key: \"add\",\n value: function add(schema) {\n if (this.validateSchema(schema)) {\n this.schemaDict[schema.template] = schema;\n var templateEl = document.querySelector(schema.template);\n if (!templateEl) {\n NAF.log.error(\"Template el not found for \".concat(schema.template, \", make sure NAF.schemas.add is called after <a-scene> is defined.\"));\n return;\n }\n if (!this.validateTemplate(schema, templateEl)) {\n return;\n }\n this.templateCache[schema.template] = document.importNode(templateEl.content, true);\n } else {\n NAF.log.error('Schema not valid: ', schema);\n NAF.log.error('See https://github.com/networked-aframe/networked-aframe#syncing-custom-components');\n }\n }\n }, {\n key: \"getCachedTemplate\",\n value: function getCachedTemplate(template) {\n if (!this.templateIsCached(template)) {\n if (this.templateExistsInScene(template)) {\n this.add(this.createDefaultSchema(template));\n } else {\n NAF.log.error(\"Template el for \".concat(template, \" is not in the scene, add the template to <a-assets> and register with NAF.schemas.add.\"));\n }\n }\n return this.templateCache[template].firstElementChild.cloneNode(true);\n }\n }, {\n key: \"templateIsCached\",\n value: function templateIsCached(template) {\n return !!this.templateCache[template];\n }\n }, {\n key: \"getComponents\",\n value: function getComponents(template) {\n var components = ['position', 'rotation'];\n if (this.hasTemplate(template)) {\n components = this.schemaDict[template].components;\n }\n return components;\n }\n }, {\n key: \"hasTemplate\",\n value: function hasTemplate(template) {\n return !!this.schemaDict[template];\n }\n }, {\n key: \"templateExistsInScene\",\n value: function templateExistsInScene(templateSelector) {\n var el = document.querySelector(templateSelector);\n return el && this.isTemplateTag(el);\n }\n }, {\n key: \"validateSchema\",\n value: function validateSchema(schema) {\n return !!(schema['template'] && schema['components']);\n }\n }, {\n key: \"validateTemplate\",\n value: function validateTemplate(schema, el) {\n if (!this.isTemplateTag(el)) {\n NAF.log.error(\"Template for \".concat(schema.template, \" is not a <template> tag. Instead found: \").concat(el.tagName));\n return false;\n } else if (!this.templateHasOneOrZeroChildren(el)) {\n NAF.log.error(\"Template for \".concat(schema.template, \" has more than one child. Templates must have one direct child element, no more. Template found:\"), el);\n return false;\n } else {\n return true;\n }\n }\n }, {\n key: \"isTemplateTag\",\n value: function isTemplateTag(el) {\n return el.tagName.toLowerCase() === 'template';\n }\n }, {\n key: \"templateHasOneOrZeroChildren\",\n value: function templateHasOneOrZeroChildren(el) {\n return el.content.childElementCount < 2;\n }\n }, {\n key: \"remove\",\n value: function remove(template) {\n delete this.schemaDict[template];\n }\n }, {\n key: \"clear\",\n value: function clear() {\n this.schemaDict = {};\n }\n }]);\n}();\nmodule.exports = Schemas;\n\n//# sourceURL=webpack://networked-aframe/./src/Schemas.js?"); /***/ }), /***/ "./src/adapters/AdapterFactory.js": /*!****************************************!*\ !*** ./src/adapters/AdapterFactory.js ***! \****************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nvar WsEasyRtcAdapter = __webpack_require__(/*! ./WsEasyRtcAdapter */ \"./src/adapters/WsEasyRtcAdapter.js\");\nvar EasyRtcAdapter = __webpack_require__(/*! ./EasyRtcAdapter */ \"./src/adapters/EasyRtcAdapter.js\");\nvar WebrtcAdapter = __webpack_require__(/*! ./naf-webrtc-adapter */ \"./src/adapters/naf-webrtc-adapter.js\");\nvar SocketioAdapter = __webpack_require__(/*! ./naf-socketio-adapter */ \"./src/adapters/naf-socketio-adapter.js\");\nvar UWSAdapter = __webpack_require__(/*! ./naf-uws-adapter */ \"./src/adapters/naf-uws-adapter.js\");\nvar AdapterFactory = /*#__PURE__*/function () {\n function AdapterFactory() {\n _classCallCheck(this, AdapterFactory);\n this.adapters = {\n \"wseasyrtc\": WsEasyRtcAdapter,\n \"easyrtc\": EasyRtcAdapter,\n \"socketio\": SocketioAdapter,\n \"webrtc\": WebrtcAdapter,\n \"uws\": UWSAdapter\n };\n this.IS_CONNECTED = AdapterFactory.IS_CONNECTED;\n this.CONNECTING = AdapterFactory.CONNECTING;\n this.NOT_CONNECTED = AdapterFactory.NOT_CONNECTED;\n }\n return _createClass(AdapterFactory, [{\n key: \"register\",\n value: function register(adapterName, AdapterClass) {\n this.adapters[adapterName] = AdapterClass;\n }\n }, {\n key: \"make\",\n value: function make(adapterName) {\n var name = adapterName.toLowerCase();\n if (this.adapters[name]) {\n var AdapterClass = this.adapters[name];\n return new AdapterClass();\n } else {\n throw new Error(\"Adapter: \" + adapterName + \" not registered. Please use NAF.adapters.register() to register this adapter.\");\n }\n }\n }]);\n}();\nAdapterFactory.IS_CONNECTED = \"IS_CONNECTED\";\nAdapterFactory.CONNECTING = \"CONNECTING\";\nAdapterFactory.NOT_CONNECTED = \"NOT_CONNECTED\";\nmodule.exports = AdapterFactory;\n\n//# sourceURL=webpack://networked-aframe/./src/adapters/AdapterFactory.js?"); /***/ }), /***/ "./src/adapters/EasyRtcAdapter.js": /*!****************************************!*\ !*** ./src/adapters/EasyRtcAdapter.js ***! \****************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(r, a) { if (r) { if (\"string\" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }\nfunction _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }\nfunction _iterableToArrayLimit(r, l) { var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t[\"return\"] && (u = t[\"return\"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }\nfunction _arrayWithHoles(r) { if (Array.isArray(r)) ret