├── .gitignore ├── LICENSE ├── README.md ├── docs └── images │ └── threejs-webrtc.gif ├── package-lock.json ├── package.json ├── public ├── index.html └── js │ ├── communications.js │ ├── index.js │ └── libs │ ├── firstPersonControls.js │ └── simplepeer.min.js └── server.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | mydatabase.json -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Aidan Nelson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This [three.js](threejs.org) template allows multiplayer three.js scenes with integrated audio/video capabilities. It uses a node server running socket.io to provide multiplayer functionality as well as WebRTC signaling. 2 | 3 | ![image of multiplayer 3D scene](/docs/images/threejs-webrtc.gif) 4 | 5 | ## Quickstart: 6 | 7 | 1. Download the repository to your computer: 8 | ```bash 9 | $ git clone https://github.com/AidanNelson/threejs-webrtc.git 10 | ``` 11 | 2. Navigate into the local folder and install Node dependencies: 12 | ```bash 13 | $ cd threejs-webrtc 14 | $ npm install 15 | ``` 16 | 3. Start the server: 17 | ```bash 18 | $ npm start 19 | ``` 20 | 4. Navigate to `http://localhost:8080` on your browser. 21 | 22 | ## Technology: 23 | 24 | This space is built using a number of technologies, including: 25 | 26 | * [three.js](https://threejs.org/) provides rendering / 3D environment interaction 27 | * [socket.io](https://socket.io/) provides the three.js multiplayer functionality, and acts as a WebRTC signaling server 28 | * [WebRTC](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API) provides video / audio chat functionality 29 | * [Simple Peer](https://github.com/feross/simple-peer) provides a friendlier API for WebRTC 30 | 31 | ## Credits: 32 | 33 | This template uses code from a number of sources, including: 34 | 35 | * Or Fleisher - [THREE.Multiplayer](https://github.com/juniorxsound/THREE.Multiplayer) server and client setup using socket.io with three.js 36 | * Mikołaj Wargowski - [Simple Chat App](https://github.com/Miczeq22/simple-chat-app) using [WebRTC](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API) with three.js 37 | * Zachary Stenger - [Three.js Video Chat](https://github.com/zacharystenger/three-js-video-chat) using [WebRTC](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API) 38 | -------------------------------------------------------------------------------- /docs/images/threejs-webrtc.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AidanNelson/threejs-webrtc/004bf34acefc2170e61b32d206e5a23677b3faaf/docs/images/threejs-webrtc.gif -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "three.js-webrtc", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "three.js-webrtc", 9 | "version": "1.0.0", 10 | "license": "MIT", 11 | "dependencies": { 12 | "express": "^4.19.2", 13 | "nedb": "^1.8.0", 14 | "socket.io": "^4.7.5" 15 | }, 16 | "devDependencies": { 17 | "nodemon": "^3.1.0" 18 | } 19 | }, 20 | "node_modules/@socket.io/component-emitter": { 21 | "version": "3.1.0", 22 | "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz", 23 | "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==" 24 | }, 25 | "node_modules/@types/cookie": { 26 | "version": "0.4.1", 27 | "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", 28 | "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==" 29 | }, 30 | "node_modules/@types/cors": { 31 | "version": "2.8.17", 32 | "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz", 33 | "integrity": "sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==", 34 | "dependencies": { 35 | "@types/node": "*" 36 | } 37 | }, 38 | "node_modules/@types/node": { 39 | "version": "20.12.6", 40 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.6.tgz", 41 | "integrity": "sha512-3KurE8taB8GCvZBPngVbp0lk5CKi8M9f9k1rsADh0Evdz5SzJ+Q+Hx9uHoFGsLnLnd1xmkDQr2hVhlA0Mn0lKQ==", 42 | "dependencies": { 43 | "undici-types": "~5.26.4" 44 | } 45 | }, 46 | "node_modules/abbrev": { 47 | "version": "1.1.1", 48 | "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", 49 | "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", 50 | "dev": true 51 | }, 52 | "node_modules/accepts": { 53 | "version": "1.3.8", 54 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", 55 | "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", 56 | "dependencies": { 57 | "mime-types": "~2.1.34", 58 | "negotiator": "0.6.3" 59 | }, 60 | "engines": { 61 | "node": ">= 0.6" 62 | } 63 | }, 64 | "node_modules/anymatch": { 65 | "version": "3.1.3", 66 | "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", 67 | "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", 68 | "dev": true, 69 | "dependencies": { 70 | "normalize-path": "^3.0.0", 71 | "picomatch": "^2.0.4" 72 | }, 73 | "engines": { 74 | "node": ">= 8" 75 | } 76 | }, 77 | "node_modules/array-flatten": { 78 | "version": "1.1.1", 79 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", 80 | "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" 81 | }, 82 | "node_modules/async": { 83 | "version": "0.2.10", 84 | "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", 85 | "integrity": "sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ==" 86 | }, 87 | "node_modules/balanced-match": { 88 | "version": "1.0.2", 89 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", 90 | "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", 91 | "dev": true 92 | }, 93 | "node_modules/base64id": { 94 | "version": "2.0.0", 95 | "resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz", 96 | "integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==", 97 | "engines": { 98 | "node": "^4.5.0 || >= 5.9" 99 | } 100 | }, 101 | "node_modules/binary-extensions": { 102 | "version": "2.3.0", 103 | "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", 104 | "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", 105 | "dev": true, 106 | "engines": { 107 | "node": ">=8" 108 | }, 109 | "funding": { 110 | "url": "https://github.com/sponsors/sindresorhus" 111 | } 112 | }, 113 | "node_modules/binary-search-tree": { 114 | "version": "0.2.5", 115 | "resolved": "https://registry.npmjs.org/binary-search-tree/-/binary-search-tree-0.2.5.tgz", 116 | "integrity": "sha512-CvNVKS6iXagL1uGwLagSXz1hzSMezxOuGnFi5FHGKqaTO3nPPWrAbyALUzK640j+xOTVm7lzD9YP8W1f/gvUdw==", 117 | "dependencies": { 118 | "underscore": "~1.4.4" 119 | } 120 | }, 121 | "node_modules/body-parser": { 122 | "version": "1.20.2", 123 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", 124 | "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", 125 | "dependencies": { 126 | "bytes": "3.1.2", 127 | "content-type": "~1.0.5", 128 | "debug": "2.6.9", 129 | "depd": "2.0.0", 130 | "destroy": "1.2.0", 131 | "http-errors": "2.0.0", 132 | "iconv-lite": "0.4.24", 133 | "on-finished": "2.4.1", 134 | "qs": "6.11.0", 135 | "raw-body": "2.5.2", 136 | "type-is": "~1.6.18", 137 | "unpipe": "1.0.0" 138 | }, 139 | "engines": { 140 | "node": ">= 0.8", 141 | "npm": "1.2.8000 || >= 1.4.16" 142 | } 143 | }, 144 | "node_modules/brace-expansion": { 145 | "version": "1.1.11", 146 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 147 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 148 | "dev": true, 149 | "dependencies": { 150 | "balanced-match": "^1.0.0", 151 | "concat-map": "0.0.1" 152 | } 153 | }, 154 | "node_modules/braces": { 155 | "version": "3.0.2", 156 | "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", 157 | "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", 158 | "dev": true, 159 | "dependencies": { 160 | "fill-range": "^7.0.1" 161 | }, 162 | "engines": { 163 | "node": ">=8" 164 | } 165 | }, 166 | "node_modules/bytes": { 167 | "version": "3.1.2", 168 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", 169 | "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", 170 | "engines": { 171 | "node": ">= 0.8" 172 | } 173 | }, 174 | "node_modules/call-bind": { 175 | "version": "1.0.7", 176 | "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", 177 | "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", 178 | "dependencies": { 179 | "es-define-property": "^1.0.0", 180 | "es-errors": "^1.3.0", 181 | "function-bind": "^1.1.2", 182 | "get-intrinsic": "^1.2.4", 183 | "set-function-length": "^1.2.1" 184 | }, 185 | "engines": { 186 | "node": ">= 0.4" 187 | }, 188 | "funding": { 189 | "url": "https://github.com/sponsors/ljharb" 190 | } 191 | }, 192 | "node_modules/chokidar": { 193 | "version": "3.6.0", 194 | "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", 195 | "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", 196 | "dev": true, 197 | "dependencies": { 198 | "anymatch": "~3.1.2", 199 | "braces": "~3.0.2", 200 | "glob-parent": "~5.1.2", 201 | "is-binary-path": "~2.1.0", 202 | "is-glob": "~4.0.1", 203 | "normalize-path": "~3.0.0", 204 | "readdirp": "~3.6.0" 205 | }, 206 | "engines": { 207 | "node": ">= 8.10.0" 208 | }, 209 | "funding": { 210 | "url": "https://paulmillr.com/funding/" 211 | }, 212 | "optionalDependencies": { 213 | "fsevents": "~2.3.2" 214 | } 215 | }, 216 | "node_modules/concat-map": { 217 | "version": "0.0.1", 218 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 219 | "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", 220 | "dev": true 221 | }, 222 | "node_modules/content-disposition": { 223 | "version": "0.5.4", 224 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", 225 | "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", 226 | "dependencies": { 227 | "safe-buffer": "5.2.1" 228 | }, 229 | "engines": { 230 | "node": ">= 0.6" 231 | } 232 | }, 233 | "node_modules/content-type": { 234 | "version": "1.0.5", 235 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", 236 | "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", 237 | "engines": { 238 | "node": ">= 0.6" 239 | } 240 | }, 241 | "node_modules/cookie": { 242 | "version": "0.6.0", 243 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", 244 | "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", 245 | "engines": { 246 | "node": ">= 0.6" 247 | } 248 | }, 249 | "node_modules/cookie-signature": { 250 | "version": "1.0.6", 251 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", 252 | "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" 253 | }, 254 | "node_modules/cors": { 255 | "version": "2.8.5", 256 | "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", 257 | "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", 258 | "dependencies": { 259 | "object-assign": "^4", 260 | "vary": "^1" 261 | }, 262 | "engines": { 263 | "node": ">= 0.10" 264 | } 265 | }, 266 | "node_modules/debug": { 267 | "version": "2.6.9", 268 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 269 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 270 | "dependencies": { 271 | "ms": "2.0.0" 272 | } 273 | }, 274 | "node_modules/define-data-property": { 275 | "version": "1.1.4", 276 | "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", 277 | "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", 278 | "dependencies": { 279 | "es-define-property": "^1.0.0", 280 | "es-errors": "^1.3.0", 281 | "gopd": "^1.0.1" 282 | }, 283 | "engines": { 284 | "node": ">= 0.4" 285 | }, 286 | "funding": { 287 | "url": "https://github.com/sponsors/ljharb" 288 | } 289 | }, 290 | "node_modules/depd": { 291 | "version": "2.0.0", 292 | "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", 293 | "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", 294 | "engines": { 295 | "node": ">= 0.8" 296 | } 297 | }, 298 | "node_modules/destroy": { 299 | "version": "1.2.0", 300 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", 301 | "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", 302 | "engines": { 303 | "node": ">= 0.8", 304 | "npm": "1.2.8000 || >= 1.4.16" 305 | } 306 | }, 307 | "node_modules/ee-first": { 308 | "version": "1.1.1", 309 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", 310 | "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" 311 | }, 312 | "node_modules/encodeurl": { 313 | "version": "1.0.2", 314 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", 315 | "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", 316 | "engines": { 317 | "node": ">= 0.8" 318 | } 319 | }, 320 | "node_modules/engine.io": { 321 | "version": "6.5.4", 322 | "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.5.4.tgz", 323 | "integrity": "sha512-KdVSDKhVKyOi+r5uEabrDLZw2qXStVvCsEB/LN3mw4WFi6Gx50jTyuxYVCwAAC0U46FdnzP/ScKRBTXb/NiEOg==", 324 | "dependencies": { 325 | "@types/cookie": "^0.4.1", 326 | "@types/cors": "^2.8.12", 327 | "@types/node": ">=10.0.0", 328 | "accepts": "~1.3.4", 329 | "base64id": "2.0.0", 330 | "cookie": "~0.4.1", 331 | "cors": "~2.8.5", 332 | "debug": "~4.3.1", 333 | "engine.io-parser": "~5.2.1", 334 | "ws": "~8.11.0" 335 | }, 336 | "engines": { 337 | "node": ">=10.2.0" 338 | } 339 | }, 340 | "node_modules/engine.io-parser": { 341 | "version": "5.2.2", 342 | "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.2.tgz", 343 | "integrity": "sha512-RcyUFKA93/CXH20l4SoVvzZfrSDMOTUS3bWVpTt2FuFP+XYrL8i8oonHP7WInRyVHXh0n/ORtoeiE1os+8qkSw==", 344 | "engines": { 345 | "node": ">=10.0.0" 346 | } 347 | }, 348 | "node_modules/engine.io/node_modules/cookie": { 349 | "version": "0.4.2", 350 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", 351 | "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", 352 | "engines": { 353 | "node": ">= 0.6" 354 | } 355 | }, 356 | "node_modules/engine.io/node_modules/debug": { 357 | "version": "4.3.4", 358 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", 359 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", 360 | "dependencies": { 361 | "ms": "2.1.2" 362 | }, 363 | "engines": { 364 | "node": ">=6.0" 365 | }, 366 | "peerDependenciesMeta": { 367 | "supports-color": { 368 | "optional": true 369 | } 370 | } 371 | }, 372 | "node_modules/engine.io/node_modules/ms": { 373 | "version": "2.1.2", 374 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 375 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" 376 | }, 377 | "node_modules/es-define-property": { 378 | "version": "1.0.0", 379 | "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", 380 | "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", 381 | "dependencies": { 382 | "get-intrinsic": "^1.2.4" 383 | }, 384 | "engines": { 385 | "node": ">= 0.4" 386 | } 387 | }, 388 | "node_modules/es-errors": { 389 | "version": "1.3.0", 390 | "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", 391 | "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", 392 | "engines": { 393 | "node": ">= 0.4" 394 | } 395 | }, 396 | "node_modules/escape-html": { 397 | "version": "1.0.3", 398 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", 399 | "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" 400 | }, 401 | "node_modules/etag": { 402 | "version": "1.8.1", 403 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", 404 | "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", 405 | "engines": { 406 | "node": ">= 0.6" 407 | } 408 | }, 409 | "node_modules/express": { 410 | "version": "4.19.2", 411 | "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", 412 | "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", 413 | "dependencies": { 414 | "accepts": "~1.3.8", 415 | "array-flatten": "1.1.1", 416 | "body-parser": "1.20.2", 417 | "content-disposition": "0.5.4", 418 | "content-type": "~1.0.4", 419 | "cookie": "0.6.0", 420 | "cookie-signature": "1.0.6", 421 | "debug": "2.6.9", 422 | "depd": "2.0.0", 423 | "encodeurl": "~1.0.2", 424 | "escape-html": "~1.0.3", 425 | "etag": "~1.8.1", 426 | "finalhandler": "1.2.0", 427 | "fresh": "0.5.2", 428 | "http-errors": "2.0.0", 429 | "merge-descriptors": "1.0.1", 430 | "methods": "~1.1.2", 431 | "on-finished": "2.4.1", 432 | "parseurl": "~1.3.3", 433 | "path-to-regexp": "0.1.7", 434 | "proxy-addr": "~2.0.7", 435 | "qs": "6.11.0", 436 | "range-parser": "~1.2.1", 437 | "safe-buffer": "5.2.1", 438 | "send": "0.18.0", 439 | "serve-static": "1.15.0", 440 | "setprototypeof": "1.2.0", 441 | "statuses": "2.0.1", 442 | "type-is": "~1.6.18", 443 | "utils-merge": "1.0.1", 444 | "vary": "~1.1.2" 445 | }, 446 | "engines": { 447 | "node": ">= 0.10.0" 448 | } 449 | }, 450 | "node_modules/fill-range": { 451 | "version": "7.0.1", 452 | "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", 453 | "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", 454 | "dev": true, 455 | "dependencies": { 456 | "to-regex-range": "^5.0.1" 457 | }, 458 | "engines": { 459 | "node": ">=8" 460 | } 461 | }, 462 | "node_modules/finalhandler": { 463 | "version": "1.2.0", 464 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", 465 | "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", 466 | "dependencies": { 467 | "debug": "2.6.9", 468 | "encodeurl": "~1.0.2", 469 | "escape-html": "~1.0.3", 470 | "on-finished": "2.4.1", 471 | "parseurl": "~1.3.3", 472 | "statuses": "2.0.1", 473 | "unpipe": "~1.0.0" 474 | }, 475 | "engines": { 476 | "node": ">= 0.8" 477 | } 478 | }, 479 | "node_modules/forwarded": { 480 | "version": "0.2.0", 481 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", 482 | "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", 483 | "engines": { 484 | "node": ">= 0.6" 485 | } 486 | }, 487 | "node_modules/fresh": { 488 | "version": "0.5.2", 489 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", 490 | "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", 491 | "engines": { 492 | "node": ">= 0.6" 493 | } 494 | }, 495 | "node_modules/fsevents": { 496 | "version": "2.3.3", 497 | "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", 498 | "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", 499 | "dev": true, 500 | "hasInstallScript": true, 501 | "optional": true, 502 | "os": [ 503 | "darwin" 504 | ], 505 | "engines": { 506 | "node": "^8.16.0 || ^10.6.0 || >=11.0.0" 507 | } 508 | }, 509 | "node_modules/function-bind": { 510 | "version": "1.1.2", 511 | "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", 512 | "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", 513 | "funding": { 514 | "url": "https://github.com/sponsors/ljharb" 515 | } 516 | }, 517 | "node_modules/get-intrinsic": { 518 | "version": "1.2.4", 519 | "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", 520 | "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", 521 | "dependencies": { 522 | "es-errors": "^1.3.0", 523 | "function-bind": "^1.1.2", 524 | "has-proto": "^1.0.1", 525 | "has-symbols": "^1.0.3", 526 | "hasown": "^2.0.0" 527 | }, 528 | "engines": { 529 | "node": ">= 0.4" 530 | }, 531 | "funding": { 532 | "url": "https://github.com/sponsors/ljharb" 533 | } 534 | }, 535 | "node_modules/glob-parent": { 536 | "version": "5.1.2", 537 | "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", 538 | "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", 539 | "dev": true, 540 | "dependencies": { 541 | "is-glob": "^4.0.1" 542 | }, 543 | "engines": { 544 | "node": ">= 6" 545 | } 546 | }, 547 | "node_modules/gopd": { 548 | "version": "1.0.1", 549 | "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", 550 | "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", 551 | "dependencies": { 552 | "get-intrinsic": "^1.1.3" 553 | }, 554 | "funding": { 555 | "url": "https://github.com/sponsors/ljharb" 556 | } 557 | }, 558 | "node_modules/has-flag": { 559 | "version": "3.0.0", 560 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", 561 | "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", 562 | "dev": true, 563 | "engines": { 564 | "node": ">=4" 565 | } 566 | }, 567 | "node_modules/has-property-descriptors": { 568 | "version": "1.0.2", 569 | "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", 570 | "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", 571 | "dependencies": { 572 | "es-define-property": "^1.0.0" 573 | }, 574 | "funding": { 575 | "url": "https://github.com/sponsors/ljharb" 576 | } 577 | }, 578 | "node_modules/has-proto": { 579 | "version": "1.0.3", 580 | "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", 581 | "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", 582 | "engines": { 583 | "node": ">= 0.4" 584 | }, 585 | "funding": { 586 | "url": "https://github.com/sponsors/ljharb" 587 | } 588 | }, 589 | "node_modules/has-symbols": { 590 | "version": "1.0.3", 591 | "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", 592 | "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", 593 | "engines": { 594 | "node": ">= 0.4" 595 | }, 596 | "funding": { 597 | "url": "https://github.com/sponsors/ljharb" 598 | } 599 | }, 600 | "node_modules/hasown": { 601 | "version": "2.0.2", 602 | "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", 603 | "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", 604 | "dependencies": { 605 | "function-bind": "^1.1.2" 606 | }, 607 | "engines": { 608 | "node": ">= 0.4" 609 | } 610 | }, 611 | "node_modules/http-errors": { 612 | "version": "2.0.0", 613 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", 614 | "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", 615 | "dependencies": { 616 | "depd": "2.0.0", 617 | "inherits": "2.0.4", 618 | "setprototypeof": "1.2.0", 619 | "statuses": "2.0.1", 620 | "toidentifier": "1.0.1" 621 | }, 622 | "engines": { 623 | "node": ">= 0.8" 624 | } 625 | }, 626 | "node_modules/iconv-lite": { 627 | "version": "0.4.24", 628 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", 629 | "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", 630 | "dependencies": { 631 | "safer-buffer": ">= 2.1.2 < 3" 632 | }, 633 | "engines": { 634 | "node": ">=0.10.0" 635 | } 636 | }, 637 | "node_modules/ignore-by-default": { 638 | "version": "1.0.1", 639 | "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", 640 | "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", 641 | "dev": true 642 | }, 643 | "node_modules/immediate": { 644 | "version": "3.0.6", 645 | "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", 646 | "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==" 647 | }, 648 | "node_modules/inherits": { 649 | "version": "2.0.4", 650 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 651 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" 652 | }, 653 | "node_modules/ipaddr.js": { 654 | "version": "1.9.1", 655 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", 656 | "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", 657 | "engines": { 658 | "node": ">= 0.10" 659 | } 660 | }, 661 | "node_modules/is-binary-path": { 662 | "version": "2.1.0", 663 | "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", 664 | "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", 665 | "dev": true, 666 | "dependencies": { 667 | "binary-extensions": "^2.0.0" 668 | }, 669 | "engines": { 670 | "node": ">=8" 671 | } 672 | }, 673 | "node_modules/is-extglob": { 674 | "version": "2.1.1", 675 | "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", 676 | "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", 677 | "dev": true, 678 | "engines": { 679 | "node": ">=0.10.0" 680 | } 681 | }, 682 | "node_modules/is-glob": { 683 | "version": "4.0.3", 684 | "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", 685 | "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", 686 | "dev": true, 687 | "dependencies": { 688 | "is-extglob": "^2.1.1" 689 | }, 690 | "engines": { 691 | "node": ">=0.10.0" 692 | } 693 | }, 694 | "node_modules/is-number": { 695 | "version": "7.0.0", 696 | "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", 697 | "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", 698 | "dev": true, 699 | "engines": { 700 | "node": ">=0.12.0" 701 | } 702 | }, 703 | "node_modules/lie": { 704 | "version": "3.1.1", 705 | "resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz", 706 | "integrity": "sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw==", 707 | "dependencies": { 708 | "immediate": "~3.0.5" 709 | } 710 | }, 711 | "node_modules/localforage": { 712 | "version": "1.10.0", 713 | "resolved": "https://registry.npmjs.org/localforage/-/localforage-1.10.0.tgz", 714 | "integrity": "sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg==", 715 | "dependencies": { 716 | "lie": "3.1.1" 717 | } 718 | }, 719 | "node_modules/lru-cache": { 720 | "version": "6.0.0", 721 | "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", 722 | "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", 723 | "dev": true, 724 | "dependencies": { 725 | "yallist": "^4.0.0" 726 | }, 727 | "engines": { 728 | "node": ">=10" 729 | } 730 | }, 731 | "node_modules/media-typer": { 732 | "version": "0.3.0", 733 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", 734 | "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", 735 | "engines": { 736 | "node": ">= 0.6" 737 | } 738 | }, 739 | "node_modules/merge-descriptors": { 740 | "version": "1.0.1", 741 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", 742 | "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" 743 | }, 744 | "node_modules/methods": { 745 | "version": "1.1.2", 746 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", 747 | "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", 748 | "engines": { 749 | "node": ">= 0.6" 750 | } 751 | }, 752 | "node_modules/mime": { 753 | "version": "1.6.0", 754 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", 755 | "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", 756 | "bin": { 757 | "mime": "cli.js" 758 | }, 759 | "engines": { 760 | "node": ">=4" 761 | } 762 | }, 763 | "node_modules/mime-db": { 764 | "version": "1.52.0", 765 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", 766 | "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", 767 | "engines": { 768 | "node": ">= 0.6" 769 | } 770 | }, 771 | "node_modules/mime-types": { 772 | "version": "2.1.35", 773 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", 774 | "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", 775 | "dependencies": { 776 | "mime-db": "1.52.0" 777 | }, 778 | "engines": { 779 | "node": ">= 0.6" 780 | } 781 | }, 782 | "node_modules/minimatch": { 783 | "version": "3.1.2", 784 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", 785 | "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", 786 | "dev": true, 787 | "dependencies": { 788 | "brace-expansion": "^1.1.7" 789 | }, 790 | "engines": { 791 | "node": "*" 792 | } 793 | }, 794 | "node_modules/minimist": { 795 | "version": "1.2.8", 796 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", 797 | "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", 798 | "funding": { 799 | "url": "https://github.com/sponsors/ljharb" 800 | } 801 | }, 802 | "node_modules/mkdirp": { 803 | "version": "0.5.6", 804 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", 805 | "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", 806 | "dependencies": { 807 | "minimist": "^1.2.6" 808 | }, 809 | "bin": { 810 | "mkdirp": "bin/cmd.js" 811 | } 812 | }, 813 | "node_modules/ms": { 814 | "version": "2.0.0", 815 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 816 | "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" 817 | }, 818 | "node_modules/nedb": { 819 | "version": "1.8.0", 820 | "resolved": "https://registry.npmjs.org/nedb/-/nedb-1.8.0.tgz", 821 | "integrity": "sha512-ip7BJdyb5m+86ZbSb4y10FCCW9g35+U8bDRrZlAfCI6m4dKwEsQ5M52grcDcVK4Vm/vnPlDLywkyo3GliEkb5A==", 822 | "dependencies": { 823 | "async": "0.2.10", 824 | "binary-search-tree": "0.2.5", 825 | "localforage": "^1.3.0", 826 | "mkdirp": "~0.5.1", 827 | "underscore": "~1.4.4" 828 | } 829 | }, 830 | "node_modules/negotiator": { 831 | "version": "0.6.3", 832 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", 833 | "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", 834 | "engines": { 835 | "node": ">= 0.6" 836 | } 837 | }, 838 | "node_modules/nodemon": { 839 | "version": "3.1.0", 840 | "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.0.tgz", 841 | "integrity": "sha512-xqlktYlDMCepBJd43ZQhjWwMw2obW/JRvkrLxq5RCNcuDDX1DbcPT+qT1IlIIdf+DhnWs90JpTMe+Y5KxOchvA==", 842 | "dev": true, 843 | "dependencies": { 844 | "chokidar": "^3.5.2", 845 | "debug": "^4", 846 | "ignore-by-default": "^1.0.1", 847 | "minimatch": "^3.1.2", 848 | "pstree.remy": "^1.1.8", 849 | "semver": "^7.5.3", 850 | "simple-update-notifier": "^2.0.0", 851 | "supports-color": "^5.5.0", 852 | "touch": "^3.1.0", 853 | "undefsafe": "^2.0.5" 854 | }, 855 | "bin": { 856 | "nodemon": "bin/nodemon.js" 857 | }, 858 | "engines": { 859 | "node": ">=10" 860 | }, 861 | "funding": { 862 | "type": "opencollective", 863 | "url": "https://opencollective.com/nodemon" 864 | } 865 | }, 866 | "node_modules/nodemon/node_modules/debug": { 867 | "version": "4.3.4", 868 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", 869 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", 870 | "dev": true, 871 | "dependencies": { 872 | "ms": "2.1.2" 873 | }, 874 | "engines": { 875 | "node": ">=6.0" 876 | }, 877 | "peerDependenciesMeta": { 878 | "supports-color": { 879 | "optional": true 880 | } 881 | } 882 | }, 883 | "node_modules/nodemon/node_modules/ms": { 884 | "version": "2.1.2", 885 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 886 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", 887 | "dev": true 888 | }, 889 | "node_modules/nopt": { 890 | "version": "1.0.10", 891 | "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", 892 | "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==", 893 | "dev": true, 894 | "dependencies": { 895 | "abbrev": "1" 896 | }, 897 | "bin": { 898 | "nopt": "bin/nopt.js" 899 | }, 900 | "engines": { 901 | "node": "*" 902 | } 903 | }, 904 | "node_modules/normalize-path": { 905 | "version": "3.0.0", 906 | "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", 907 | "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", 908 | "dev": true, 909 | "engines": { 910 | "node": ">=0.10.0" 911 | } 912 | }, 913 | "node_modules/object-assign": { 914 | "version": "4.1.1", 915 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 916 | "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", 917 | "engines": { 918 | "node": ">=0.10.0" 919 | } 920 | }, 921 | "node_modules/object-inspect": { 922 | "version": "1.13.1", 923 | "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", 924 | "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", 925 | "funding": { 926 | "url": "https://github.com/sponsors/ljharb" 927 | } 928 | }, 929 | "node_modules/on-finished": { 930 | "version": "2.4.1", 931 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", 932 | "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", 933 | "dependencies": { 934 | "ee-first": "1.1.1" 935 | }, 936 | "engines": { 937 | "node": ">= 0.8" 938 | } 939 | }, 940 | "node_modules/parseurl": { 941 | "version": "1.3.3", 942 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", 943 | "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", 944 | "engines": { 945 | "node": ">= 0.8" 946 | } 947 | }, 948 | "node_modules/path-to-regexp": { 949 | "version": "0.1.7", 950 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", 951 | "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" 952 | }, 953 | "node_modules/picomatch": { 954 | "version": "2.3.1", 955 | "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", 956 | "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", 957 | "dev": true, 958 | "engines": { 959 | "node": ">=8.6" 960 | }, 961 | "funding": { 962 | "url": "https://github.com/sponsors/jonschlinkert" 963 | } 964 | }, 965 | "node_modules/proxy-addr": { 966 | "version": "2.0.7", 967 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", 968 | "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", 969 | "dependencies": { 970 | "forwarded": "0.2.0", 971 | "ipaddr.js": "1.9.1" 972 | }, 973 | "engines": { 974 | "node": ">= 0.10" 975 | } 976 | }, 977 | "node_modules/pstree.remy": { 978 | "version": "1.1.8", 979 | "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", 980 | "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", 981 | "dev": true 982 | }, 983 | "node_modules/qs": { 984 | "version": "6.11.0", 985 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", 986 | "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", 987 | "dependencies": { 988 | "side-channel": "^1.0.4" 989 | }, 990 | "engines": { 991 | "node": ">=0.6" 992 | }, 993 | "funding": { 994 | "url": "https://github.com/sponsors/ljharb" 995 | } 996 | }, 997 | "node_modules/range-parser": { 998 | "version": "1.2.1", 999 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", 1000 | "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", 1001 | "engines": { 1002 | "node": ">= 0.6" 1003 | } 1004 | }, 1005 | "node_modules/raw-body": { 1006 | "version": "2.5.2", 1007 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", 1008 | "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", 1009 | "dependencies": { 1010 | "bytes": "3.1.2", 1011 | "http-errors": "2.0.0", 1012 | "iconv-lite": "0.4.24", 1013 | "unpipe": "1.0.0" 1014 | }, 1015 | "engines": { 1016 | "node": ">= 0.8" 1017 | } 1018 | }, 1019 | "node_modules/readdirp": { 1020 | "version": "3.6.0", 1021 | "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", 1022 | "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", 1023 | "dev": true, 1024 | "dependencies": { 1025 | "picomatch": "^2.2.1" 1026 | }, 1027 | "engines": { 1028 | "node": ">=8.10.0" 1029 | } 1030 | }, 1031 | "node_modules/safe-buffer": { 1032 | "version": "5.2.1", 1033 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", 1034 | "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", 1035 | "funding": [ 1036 | { 1037 | "type": "github", 1038 | "url": "https://github.com/sponsors/feross" 1039 | }, 1040 | { 1041 | "type": "patreon", 1042 | "url": "https://www.patreon.com/feross" 1043 | }, 1044 | { 1045 | "type": "consulting", 1046 | "url": "https://feross.org/support" 1047 | } 1048 | ] 1049 | }, 1050 | "node_modules/safer-buffer": { 1051 | "version": "2.1.2", 1052 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", 1053 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" 1054 | }, 1055 | "node_modules/semver": { 1056 | "version": "7.6.0", 1057 | "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", 1058 | "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", 1059 | "dev": true, 1060 | "dependencies": { 1061 | "lru-cache": "^6.0.0" 1062 | }, 1063 | "bin": { 1064 | "semver": "bin/semver.js" 1065 | }, 1066 | "engines": { 1067 | "node": ">=10" 1068 | } 1069 | }, 1070 | "node_modules/send": { 1071 | "version": "0.18.0", 1072 | "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", 1073 | "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", 1074 | "dependencies": { 1075 | "debug": "2.6.9", 1076 | "depd": "2.0.0", 1077 | "destroy": "1.2.0", 1078 | "encodeurl": "~1.0.2", 1079 | "escape-html": "~1.0.3", 1080 | "etag": "~1.8.1", 1081 | "fresh": "0.5.2", 1082 | "http-errors": "2.0.0", 1083 | "mime": "1.6.0", 1084 | "ms": "2.1.3", 1085 | "on-finished": "2.4.1", 1086 | "range-parser": "~1.2.1", 1087 | "statuses": "2.0.1" 1088 | }, 1089 | "engines": { 1090 | "node": ">= 0.8.0" 1091 | } 1092 | }, 1093 | "node_modules/send/node_modules/ms": { 1094 | "version": "2.1.3", 1095 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", 1096 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" 1097 | }, 1098 | "node_modules/serve-static": { 1099 | "version": "1.15.0", 1100 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", 1101 | "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", 1102 | "dependencies": { 1103 | "encodeurl": "~1.0.2", 1104 | "escape-html": "~1.0.3", 1105 | "parseurl": "~1.3.3", 1106 | "send": "0.18.0" 1107 | }, 1108 | "engines": { 1109 | "node": ">= 0.8.0" 1110 | } 1111 | }, 1112 | "node_modules/set-function-length": { 1113 | "version": "1.2.2", 1114 | "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", 1115 | "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", 1116 | "dependencies": { 1117 | "define-data-property": "^1.1.4", 1118 | "es-errors": "^1.3.0", 1119 | "function-bind": "^1.1.2", 1120 | "get-intrinsic": "^1.2.4", 1121 | "gopd": "^1.0.1", 1122 | "has-property-descriptors": "^1.0.2" 1123 | }, 1124 | "engines": { 1125 | "node": ">= 0.4" 1126 | } 1127 | }, 1128 | "node_modules/setprototypeof": { 1129 | "version": "1.2.0", 1130 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", 1131 | "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" 1132 | }, 1133 | "node_modules/side-channel": { 1134 | "version": "1.0.6", 1135 | "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", 1136 | "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==", 1137 | "dependencies": { 1138 | "call-bind": "^1.0.7", 1139 | "es-errors": "^1.3.0", 1140 | "get-intrinsic": "^1.2.4", 1141 | "object-inspect": "^1.13.1" 1142 | }, 1143 | "engines": { 1144 | "node": ">= 0.4" 1145 | }, 1146 | "funding": { 1147 | "url": "https://github.com/sponsors/ljharb" 1148 | } 1149 | }, 1150 | "node_modules/simple-update-notifier": { 1151 | "version": "2.0.0", 1152 | "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", 1153 | "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", 1154 | "dev": true, 1155 | "dependencies": { 1156 | "semver": "^7.5.3" 1157 | }, 1158 | "engines": { 1159 | "node": ">=10" 1160 | } 1161 | }, 1162 | "node_modules/socket.io": { 1163 | "version": "4.7.5", 1164 | "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.7.5.tgz", 1165 | "integrity": "sha512-DmeAkF6cwM9jSfmp6Dr/5/mfMwb5Z5qRrSXLpo3Fq5SqyU8CMF15jIN4ZhfSwu35ksM1qmHZDQ/DK5XTccSTvA==", 1166 | "dependencies": { 1167 | "accepts": "~1.3.4", 1168 | "base64id": "~2.0.0", 1169 | "cors": "~2.8.5", 1170 | "debug": "~4.3.2", 1171 | "engine.io": "~6.5.2", 1172 | "socket.io-adapter": "~2.5.2", 1173 | "socket.io-parser": "~4.2.4" 1174 | }, 1175 | "engines": { 1176 | "node": ">=10.2.0" 1177 | } 1178 | }, 1179 | "node_modules/socket.io-adapter": { 1180 | "version": "2.5.4", 1181 | "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.4.tgz", 1182 | "integrity": "sha512-wDNHGXGewWAjQPt3pyeYBtpWSq9cLE5UW1ZUPL/2eGK9jtse/FpXib7epSTsz0Q0m+6sg6Y4KtcFTlah1bdOVg==", 1183 | "dependencies": { 1184 | "debug": "~4.3.4", 1185 | "ws": "~8.11.0" 1186 | } 1187 | }, 1188 | "node_modules/socket.io-adapter/node_modules/debug": { 1189 | "version": "4.3.4", 1190 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", 1191 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", 1192 | "dependencies": { 1193 | "ms": "2.1.2" 1194 | }, 1195 | "engines": { 1196 | "node": ">=6.0" 1197 | }, 1198 | "peerDependenciesMeta": { 1199 | "supports-color": { 1200 | "optional": true 1201 | } 1202 | } 1203 | }, 1204 | "node_modules/socket.io-adapter/node_modules/ms": { 1205 | "version": "2.1.2", 1206 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 1207 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" 1208 | }, 1209 | "node_modules/socket.io-parser": { 1210 | "version": "4.2.4", 1211 | "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz", 1212 | "integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==", 1213 | "dependencies": { 1214 | "@socket.io/component-emitter": "~3.1.0", 1215 | "debug": "~4.3.1" 1216 | }, 1217 | "engines": { 1218 | "node": ">=10.0.0" 1219 | } 1220 | }, 1221 | "node_modules/socket.io-parser/node_modules/debug": { 1222 | "version": "4.3.4", 1223 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", 1224 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", 1225 | "dependencies": { 1226 | "ms": "2.1.2" 1227 | }, 1228 | "engines": { 1229 | "node": ">=6.0" 1230 | }, 1231 | "peerDependenciesMeta": { 1232 | "supports-color": { 1233 | "optional": true 1234 | } 1235 | } 1236 | }, 1237 | "node_modules/socket.io-parser/node_modules/ms": { 1238 | "version": "2.1.2", 1239 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 1240 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" 1241 | }, 1242 | "node_modules/socket.io/node_modules/debug": { 1243 | "version": "4.3.3", 1244 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", 1245 | "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", 1246 | "dependencies": { 1247 | "ms": "2.1.2" 1248 | }, 1249 | "engines": { 1250 | "node": ">=6.0" 1251 | }, 1252 | "peerDependenciesMeta": { 1253 | "supports-color": { 1254 | "optional": true 1255 | } 1256 | } 1257 | }, 1258 | "node_modules/socket.io/node_modules/ms": { 1259 | "version": "2.1.2", 1260 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 1261 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" 1262 | }, 1263 | "node_modules/statuses": { 1264 | "version": "2.0.1", 1265 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", 1266 | "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", 1267 | "engines": { 1268 | "node": ">= 0.8" 1269 | } 1270 | }, 1271 | "node_modules/supports-color": { 1272 | "version": "5.5.0", 1273 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", 1274 | "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", 1275 | "dev": true, 1276 | "dependencies": { 1277 | "has-flag": "^3.0.0" 1278 | }, 1279 | "engines": { 1280 | "node": ">=4" 1281 | } 1282 | }, 1283 | "node_modules/to-regex-range": { 1284 | "version": "5.0.1", 1285 | "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", 1286 | "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", 1287 | "dev": true, 1288 | "dependencies": { 1289 | "is-number": "^7.0.0" 1290 | }, 1291 | "engines": { 1292 | "node": ">=8.0" 1293 | } 1294 | }, 1295 | "node_modules/toidentifier": { 1296 | "version": "1.0.1", 1297 | "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", 1298 | "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", 1299 | "engines": { 1300 | "node": ">=0.6" 1301 | } 1302 | }, 1303 | "node_modules/touch": { 1304 | "version": "3.1.0", 1305 | "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", 1306 | "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", 1307 | "dev": true, 1308 | "dependencies": { 1309 | "nopt": "~1.0.10" 1310 | }, 1311 | "bin": { 1312 | "nodetouch": "bin/nodetouch.js" 1313 | } 1314 | }, 1315 | "node_modules/type-is": { 1316 | "version": "1.6.18", 1317 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", 1318 | "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", 1319 | "dependencies": { 1320 | "media-typer": "0.3.0", 1321 | "mime-types": "~2.1.24" 1322 | }, 1323 | "engines": { 1324 | "node": ">= 0.6" 1325 | } 1326 | }, 1327 | "node_modules/undefsafe": { 1328 | "version": "2.0.5", 1329 | "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", 1330 | "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", 1331 | "dev": true 1332 | }, 1333 | "node_modules/underscore": { 1334 | "version": "1.4.4", 1335 | "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.4.4.tgz", 1336 | "integrity": "sha512-ZqGrAgaqqZM7LGRzNjLnw5elevWb5M8LEoDMadxIW3OWbcv72wMMgKdwOKpd5Fqxe8choLD8HN3iSj3TUh/giQ==" 1337 | }, 1338 | "node_modules/undici-types": { 1339 | "version": "5.26.5", 1340 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", 1341 | "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" 1342 | }, 1343 | "node_modules/unpipe": { 1344 | "version": "1.0.0", 1345 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 1346 | "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", 1347 | "engines": { 1348 | "node": ">= 0.8" 1349 | } 1350 | }, 1351 | "node_modules/utils-merge": { 1352 | "version": "1.0.1", 1353 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", 1354 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", 1355 | "engines": { 1356 | "node": ">= 0.4.0" 1357 | } 1358 | }, 1359 | "node_modules/vary": { 1360 | "version": "1.1.2", 1361 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", 1362 | "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", 1363 | "engines": { 1364 | "node": ">= 0.8" 1365 | } 1366 | }, 1367 | "node_modules/ws": { 1368 | "version": "8.11.0", 1369 | "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", 1370 | "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", 1371 | "engines": { 1372 | "node": ">=10.0.0" 1373 | }, 1374 | "peerDependencies": { 1375 | "bufferutil": "^4.0.1", 1376 | "utf-8-validate": "^5.0.2" 1377 | }, 1378 | "peerDependenciesMeta": { 1379 | "bufferutil": { 1380 | "optional": true 1381 | }, 1382 | "utf-8-validate": { 1383 | "optional": true 1384 | } 1385 | } 1386 | }, 1387 | "node_modules/yallist": { 1388 | "version": "4.0.0", 1389 | "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", 1390 | "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", 1391 | "dev": true 1392 | } 1393 | } 1394 | } 1395 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "three.js-webrtc", 3 | "version": "1.0.0", 4 | "description": "Template for using three.js with socket.io and WebRTC", 5 | "main": "server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "nodemon --ignore ./public/ server.js --ignore ./mydatabase.json" 9 | }, 10 | "author": "", 11 | "license": "MIT", 12 | "dependencies": { 13 | "express": "^4.19.2", 14 | "nedb": "^1.8.0", 15 | "socket.io": "^4.7.5" 16 | }, 17 | "devDependencies": { 18 | "nodemon": "^3.1.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | three.js WebRTC template 5 | 6 | 10 | 11 | 12 | 13 | 14 | 22 | 23 | 24 | 29 | 30 | 31 | 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /public/js/communications.js: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * This file exports a class which sets up the Websocket and WebRTC communications for our peer. 4 | * 5 | */ 6 | 7 | export class Communications { 8 | constructor() { 9 | // socket.io 10 | this.socket; 11 | 12 | // array of connected peers 13 | this.peers = {}; 14 | 15 | // Our local media stream (i.e. webcam and microphone stream) 16 | this.localMediaStream = null; 17 | 18 | this.initialize(); 19 | 20 | this.userDefinedCallbacks = { 21 | peerJoined: [], 22 | peerLeft: [], 23 | positions: [], 24 | data: [], 25 | }; 26 | } 27 | 28 | async initialize() { 29 | // first get user media 30 | this.localMediaStream = await this.getLocalMedia(); 31 | 32 | // createLocalVideoElement(); 33 | createPeerDOMElements("local"); 34 | updatePeerDOMElements("local", this.localMediaStream); 35 | 36 | // then initialize socket connection 37 | this.initSocketConnection(); 38 | } 39 | 40 | // add a callback for a given event 41 | on(event, callback) { 42 | console.log(`Setting ${event} callback.`); 43 | this.userDefinedCallbacks[event].push(callback); 44 | } 45 | 46 | sendPosition(position) { 47 | this.socket?.emit("move", position); 48 | } 49 | 50 | sendData(data) { 51 | this.socket?.emit("data", data); 52 | } 53 | 54 | callEventCallback(event, data) { 55 | this.userDefinedCallbacks[event].forEach((callback) => { 56 | callback(data); 57 | }); 58 | } 59 | 60 | async getLocalMedia() { 61 | const videoWidth = 80; 62 | const videoHeight = 60; 63 | const videoFrameRate = 15; 64 | let mediaConstraints = { 65 | audio: true, 66 | video: { 67 | width: videoWidth, 68 | height: videoHeight, 69 | frameRate: videoFrameRate, 70 | }, 71 | }; 72 | 73 | let stream = null; 74 | 75 | try { 76 | stream = await navigator.mediaDevices.getUserMedia(mediaConstraints); 77 | } catch (err) { 78 | console.log("Failed to get user media!"); 79 | console.warn(err); 80 | } 81 | 82 | return stream; 83 | } 84 | 85 | // temporarily pause the outgoing stream 86 | disableOutgoingStream() { 87 | this.localMediaStream.getTracks().forEach((track) => { 88 | track.enabled = false; 89 | }); 90 | } 91 | // enable the outgoing stream 92 | enableOutgoingStream() { 93 | this.localMediaStream.getTracks().forEach((track) => { 94 | track.enabled = true; 95 | }); 96 | } 97 | 98 | initSocketConnection() { 99 | console.log("Initializing socket.io..."); 100 | this.socket = io(); 101 | 102 | this.socket.on("connect", () => { 103 | console.log("My socket ID:", this.socket.id); 104 | }); 105 | 106 | this.socket.on("data", (data) => { 107 | this.callEventCallback("data", data); 108 | }); 109 | 110 | 111 | this.socket.on("introduction", (otherPeerIds) => { 112 | for (let i = 0; i < otherPeerIds.length; i++) { 113 | if (otherPeerIds[i] != this.socket.id) { 114 | let theirId = otherPeerIds[i]; 115 | 116 | console.log("Adding peer with id " + theirId); 117 | this.peers[theirId] = {}; 118 | 119 | let pc = this.createPeerConnection(theirId, true); 120 | this.peers[theirId].peerConnection = pc; 121 | 122 | createPeerDOMElements(theirId); 123 | this.callEventCallback("peerJoined", theirId); 124 | } 125 | } 126 | }); 127 | 128 | // when a new user has entered the server 129 | this.socket.on("peerConnection", (theirId) => { 130 | if (theirId != this.socket.id && !(theirId in this.peers)) { 131 | this.peers[theirId] = {}; 132 | createPeerDOMElements(theirId); 133 | this.callEventCallback("peerJoined", theirId); 134 | } 135 | }); 136 | 137 | this.socket.on("peerDisconnection", (_id) => { 138 | if (_id != this.socket.id) { 139 | this.callEventCallback("peerLeft", _id); 140 | cleanupPeerDomElements(_id); 141 | delete this.peers[_id]; 142 | } 143 | }); 144 | 145 | this.socket.on("signal", (to, from, data) => { 146 | // console.log("Got a signal from the server: ", to, from, data); 147 | 148 | // to should be us 149 | if (to != this.socket.id) { 150 | console.log("Socket IDs don't match"); 151 | } 152 | 153 | // Look for the right simplepeer in our array 154 | let peer = this.peers[from]; 155 | if (peer.peerConnection) { 156 | peer.peerConnection.signal(data); 157 | } else { 158 | console.log("Never found right simplepeer object"); 159 | // Let's create it then, we won't be the "initiator" 160 | // let theirSocketId = from; 161 | let peerConnection = this.createPeerConnection(from, false); 162 | 163 | this.peers[from].peerConnection = peerConnection; 164 | 165 | // Tell the new simplepeer that signal 166 | peerConnection.signal(data); 167 | } 168 | }); 169 | 170 | // Update when one of the users moves in space 171 | this.socket.on("positions", (positions) => { 172 | this.callEventCallback("positions", positions); 173 | }); 174 | } 175 | 176 | // this function sets up a peer connection and corresponding DOM elements for a specific peer 177 | createPeerConnection(theirSocketId, isInitiator = false) { 178 | console.log("Connecting to peer with ID", theirSocketId); 179 | console.log("initiating?", isInitiator); 180 | 181 | let peerConnection = new SimplePeer({ initiator: isInitiator }); 182 | // simplepeer generates signals which need to be sent across socket 183 | peerConnection.on("signal", (data) => { 184 | // console.log('signal'); 185 | this.socket.emit("signal", theirSocketId, this.socket.id, data); 186 | }); 187 | 188 | // When we have a connection, send our stream 189 | peerConnection.on("connect", () => { 190 | // Let's give them our stream 191 | peerConnection.addStream(this.localMediaStream); 192 | console.log("Send our stream"); 193 | }); 194 | 195 | // Stream coming in to us 196 | peerConnection.on("stream", (stream) => { 197 | console.log("Incoming Stream"); 198 | 199 | updatePeerDOMElements(theirSocketId, stream); 200 | }); 201 | 202 | peerConnection.on("close", () => { 203 | console.log("Got close event"); 204 | // Should probably remove from the array of peers 205 | }); 206 | 207 | peerConnection.on("error", (err) => { 208 | console.log(err); 209 | }); 210 | 211 | return peerConnection; 212 | } 213 | } 214 | 215 | // Utilities 🚂 216 | 217 | function createPeerDOMElements(_id) { 218 | const videoElement = document.createElement("video"); 219 | videoElement.id = _id + "_video"; 220 | videoElement.autoplay = true; 221 | videoElement.muted = true; 222 | // videoElement.style = "visibility: hidden;"; 223 | 224 | document.body.appendChild(videoElement); 225 | 226 | let audioEl = document.createElement("audio"); 227 | audioEl.setAttribute("id", _id + "_audio"); 228 | audioEl.controls = "controls"; 229 | audioEl.volume = 0; // initialize at 0 volume. This will be set by 3D scene. 230 | document.body.appendChild(audioEl); 231 | 232 | audioEl.addEventListener("loadeddata", () => { 233 | audioEl.play(); 234 | }); 235 | } 236 | 237 | function updatePeerDOMElements(_id, stream) { 238 | let videoStream = new MediaStream([stream.getVideoTracks()[0]]); 239 | let audioStream = new MediaStream([stream.getAudioTracks()[0]]); 240 | 241 | if (videoStream) { 242 | const videoElement = document.getElementById(_id + "_video"); 243 | videoElement.srcObject = videoStream; 244 | } 245 | if (audioStream) { 246 | let audioEl = document.getElementById(_id + "_audio"); 247 | audioEl.srcObject = audioStream; 248 | } 249 | } 250 | 251 | function cleanupPeerDomElements(_id) { 252 | let videoEl = document.getElementById(_id + "_video"); 253 | if (videoEl != null) { 254 | videoEl.remove(); 255 | } 256 | 257 | let audioEl = document.getElementById(_id + "audio"); 258 | if (audioEl != null) { 259 | audioEl.remove(); 260 | } 261 | } 262 | -------------------------------------------------------------------------------- /public/js/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * This file sets up our web app with 3D scene and communications. 4 | * 5 | */ 6 | 7 | import * as THREE from "three"; 8 | import { Communications } from "./communications.js"; 9 | import { FirstPersonControls } from "./libs/firstPersonControls.js"; 10 | 11 | // lerp value to be used when interpolating positions and rotations 12 | let lerpValue = 0; 13 | 14 | let camera, renderer, scene; 15 | let controls; 16 | let listener; 17 | let communications; 18 | 19 | let frameCount = 0; 20 | let peers = {}; 21 | 22 | function init() { 23 | scene = new THREE.Scene(); 24 | 25 | communications = new Communications(); 26 | 27 | communications.on("peerJoined", (id) => { 28 | addPeer(id); 29 | }); 30 | communications.on("peerLeft", (id) => { 31 | removePeer(id); 32 | }); 33 | communications.on("positions", (positions) => { 34 | updatePeerPositions(positions); 35 | }); 36 | // deal with incoming data 37 | communications.on("data", (msg) => { 38 | console.log("Received message:", msg); 39 | if (msg.type == "box") { 40 | onNewBox(msg); 41 | } 42 | }); 43 | 44 | let width = window.innerWidth; 45 | let height = window.innerHeight * 0.9; 46 | 47 | camera = new THREE.PerspectiveCamera(50, width / height, 0.1, 5000); 48 | camera.position.set(0, 3, 6); 49 | scene.add(camera); 50 | 51 | // create an AudioListener and add it to the camera 52 | listener = new THREE.AudioListener(); 53 | camera.add(listener); 54 | 55 | //THREE WebGL renderer 56 | renderer = new THREE.WebGLRenderer({ 57 | antialiasing: true, 58 | }); 59 | renderer.setClearColor(new THREE.Color("lightblue")); 60 | renderer.setSize(width, height); 61 | 62 | // add controls: 63 | controls = new FirstPersonControls(scene, camera, renderer); 64 | 65 | // add controls for adding boxes on a key press 66 | window.addEventListener("keyup", (ev) => { 67 | if (ev.key === "b") { 68 | addBox(); 69 | } 70 | }); 71 | 72 | //Push the canvas to the DOM 73 | let domElement = document.getElementById("canvas-container"); 74 | domElement.append(renderer.domElement); 75 | 76 | //Setup event listeners for events and handle the states 77 | window.addEventListener("resize", (e) => onWindowResize(e), false); 78 | 79 | // Helpers 80 | scene.add(new THREE.GridHelper(500, 500)); 81 | scene.add(new THREE.AxesHelper(10)); 82 | 83 | addLights(); 84 | 85 | // Start the loop 86 | update(); 87 | } 88 | 89 | init(); 90 | 91 | ////////////////////////////////////////////////////////////////////// 92 | // Lighting 💡 93 | ////////////////////////////////////////////////////////////////////// 94 | 95 | function addLights() { 96 | scene.add(new THREE.AmbientLight(0xffffe6, 0.7)); 97 | } 98 | 99 | ////////////////////////////////////////////////////////////////////// 100 | // Clients 👫 101 | ////////////////////////////////////////////////////////////////////// 102 | 103 | // add a client meshes, a video element and canvas for three.js video texture 104 | function addPeer(id) { 105 | let videoElement = document.getElementById(id + "_video"); 106 | let videoTexture = new THREE.VideoTexture(videoElement); 107 | 108 | let videoMaterial = new THREE.MeshBasicMaterial({ 109 | map: videoTexture, 110 | overdraw: true, 111 | side: THREE.DoubleSide, 112 | }); 113 | let otherMat = new THREE.MeshNormalMaterial(); 114 | 115 | let head = new THREE.Mesh(new THREE.BoxGeometry(1, 1, 1), [ 116 | otherMat, 117 | otherMat, 118 | otherMat, 119 | otherMat, 120 | otherMat, 121 | videoMaterial, 122 | ]); 123 | 124 | // set position of head before adding to parent object 125 | head.position.set(0, 0, 0); 126 | 127 | // https://threejs.org/docs/index.html#api/en/objects/Group 128 | var group = new THREE.Group(); 129 | group.add(head); 130 | 131 | // add group to scene 132 | scene.add(group); 133 | 134 | peers[id] = {}; 135 | peers[id].group = group; 136 | 137 | peers[id].previousPosition = new THREE.Vector3(); 138 | peers[id].previousRotation = new THREE.Quaternion(); 139 | peers[id].desiredPosition = new THREE.Vector3(); 140 | peers[id].desiredRotation = new THREE.Quaternion(); 141 | } 142 | 143 | function removePeer(id) { 144 | scene.remove(peers[id].group); 145 | } 146 | 147 | // overloaded function can deal with new info or not 148 | function updatePeerPositions(positions) { 149 | lerpValue = 0; 150 | for (let id in positions) { 151 | if (!peers[id]) continue; 152 | peers[id].previousPosition.copy(peers[id].group.position); 153 | peers[id].previousRotation.copy(peers[id].group.quaternion); 154 | peers[id].desiredPosition = new THREE.Vector3().fromArray( 155 | positions[id].position 156 | ); 157 | peers[id].desiredRotation = new THREE.Quaternion().fromArray( 158 | positions[id].rotation 159 | ); 160 | } 161 | } 162 | 163 | function interpolatePositions() { 164 | lerpValue += 0.1; // updates are sent roughly every 1/5 second == 10 frames 165 | for (let id in peers) { 166 | if (peers[id].group) { 167 | peers[id].group.position.lerpVectors( 168 | peers[id].previousPosition, 169 | peers[id].desiredPosition, 170 | lerpValue 171 | ); 172 | peers[id].group.quaternion.slerpQuaternions( 173 | peers[id].previousRotation, 174 | peers[id].desiredRotation, 175 | lerpValue 176 | ); 177 | } 178 | } 179 | } 180 | 181 | function updatePeerVolumes() { 182 | for (let id in peers) { 183 | let audioEl = document.getElementById(id + "_audio"); 184 | if (audioEl && peers[id].group) { 185 | let distSquared = camera.position.distanceToSquared( 186 | peers[id].group.position 187 | ); 188 | 189 | if (distSquared > 500) { 190 | audioEl.volume = 0; 191 | } else { 192 | // from lucasio here: https://discourse.threejs.org/t/positionalaudio-setmediastreamsource-with-webrtc-question-not-hearing-any-sound/14301/29 193 | let volume = Math.min(1, 10 / distSquared); 194 | audioEl.volume = volume; 195 | } 196 | } 197 | } 198 | } 199 | 200 | ////////////////////////////////////////////////////////////////////// 201 | // Interaction 🤾‍♀️ 202 | ////////////////////////////////////////////////////////////////////// 203 | 204 | function getPlayerPosition() { 205 | return [ 206 | [camera.position.x, camera.position.y, camera.position.z], 207 | [ 208 | camera.quaternion._x, 209 | camera.quaternion._y, 210 | camera.quaternion._z, 211 | camera.quaternion._w, 212 | ], 213 | ]; 214 | } 215 | 216 | ////////////////////////////////////////////////////////////////////// 217 | // Rendering 🎥 218 | ////////////////////////////////////////////////////////////////////// 219 | 220 | function update() { 221 | requestAnimationFrame(() => update()); 222 | frameCount++; 223 | 224 | if (frameCount % 25 === 0) { 225 | updatePeerVolumes(); 226 | } 227 | 228 | if (frameCount % 10 === 0) { 229 | let position = getPlayerPosition(); 230 | communications.sendPosition(position); 231 | } 232 | 233 | interpolatePositions(); 234 | 235 | controls.update(); 236 | 237 | renderer.render(scene, camera); 238 | } 239 | 240 | ////////////////////////////////////////////////////////////////////// 241 | // Event Handlers 🍽 242 | ////////////////////////////////////////////////////////////////////// 243 | 244 | function onWindowResize(e) { 245 | let width = window.innerWidth; 246 | let height = Math.floor(window.innerHeight * 0.9); 247 | camera.aspect = width / height; 248 | camera.updateProjectionMatrix(); 249 | renderer.setSize(width, height); 250 | } 251 | 252 | function addBox() { 253 | let msg = { 254 | type: "box", 255 | data: { 256 | x: camera.position.x, 257 | y: camera.position.y, 258 | z: camera.position.z, 259 | }, 260 | }; 261 | communications.sendData(msg); 262 | } 263 | 264 | function onNewBox(msg) { 265 | let geo = new THREE.BoxGeometry(1, 1, 1); 266 | let mat = new THREE.MeshBasicMaterial(); 267 | let mesh = new THREE.Mesh(geo, mat); 268 | 269 | let pos = msg.data; 270 | mesh.position.set(pos.x, pos.y, pos.z); 271 | 272 | scene.add(mesh); 273 | } 274 | -------------------------------------------------------------------------------- /public/js/libs/firstPersonControls.js: -------------------------------------------------------------------------------- 1 | // controls implementation from https://github.com/yorb-club/YORB2020 2 | // includes simple collision detection 3 | // just add meshes to layer 3 to have them become collidable! 4 | import * as THREE from "three"; 5 | export class FirstPersonControls { 6 | constructor(scene, camera, renderer) { 7 | this.scene = scene 8 | this.camera = camera 9 | this.renderer = renderer 10 | 11 | this.paused = false 12 | 13 | this.cameraHeight = 1.5 14 | 15 | this.raycaster = new THREE.Raycaster() 16 | 17 | this.setupControls() 18 | this.setupCollisionDetection() 19 | 20 | this.velocity.y = 0 21 | 22 | this.gravity = true; // we'll change this once we click 'Enter' 23 | 24 | // variables for drag controls 25 | this.onPointerDownPointerX = 0 26 | this.onPointerDownPointerY = 0 27 | this.lon = 180 28 | this.lat = 0 29 | this.phi = 0 30 | this.theta = 0; 31 | this.isUserInteracting = false 32 | this.camera.target = new THREE.Vector3(0, 0, 0) 33 | 34 | } 35 | 36 | pause() { 37 | this.paused = true 38 | } 39 | resume() { 40 | this.paused = false 41 | } 42 | 43 | // Set up pointer lock controls and corresponding event listeners 44 | setupControls() { 45 | let jumpSpeed = 12 46 | 47 | this.moveForward = false 48 | this.moveBackward = false 49 | this.moveLeft = false 50 | this.moveRight = false 51 | this.canJump = false 52 | 53 | this.prevTime = performance.now() 54 | this.velocity = new THREE.Vector3() 55 | this.direction = new THREE.Vector3() 56 | 57 | document.addEventListener( 58 | 'keydown', 59 | (event) => { 60 | switch (event.keyCode) { 61 | case 38: // up 62 | case 87: // w 63 | this.moveForward = true 64 | break 65 | 66 | case 37: // left 67 | case 65: // a 68 | this.moveLeft = true 69 | break 70 | 71 | case 40: // down 72 | case 83: // s 73 | this.moveBackward = true 74 | break 75 | 76 | case 39: // right 77 | case 68: // d 78 | this.moveRight = true 79 | break 80 | 81 | case 32: // space 82 | if (this.canJump === true) this.velocity.y = jumpSpeed 83 | this.canJump = false 84 | break 85 | 86 | 87 | } 88 | }, 89 | false 90 | ) 91 | 92 | document.addEventListener( 93 | 'keyup', 94 | (event) => { 95 | switch (event.keyCode) { 96 | case 38: // up 97 | case 87: // w 98 | this.moveForward = false 99 | break 100 | 101 | case 37: // left 102 | case 65: // a 103 | this.moveLeft = false 104 | break 105 | 106 | case 40: // down 107 | case 83: // s 108 | this.moveBackward = false 109 | break 110 | 111 | case 39: // right 112 | case 68: // d 113 | this.moveRight = false 114 | break 115 | 116 | } 117 | }, 118 | false 119 | ) 120 | 121 | 122 | 123 | this.renderer.domElement.addEventListener( 124 | 'mousedown', 125 | (e) => { 126 | this.onDocumentMouseDown(e) 127 | }, 128 | false 129 | ) 130 | this.renderer.domElement.addEventListener( 131 | 'mousemove', 132 | (e) => { 133 | this.onDocumentMouseMove(e) 134 | }, 135 | false 136 | ) 137 | this.renderer.domElement.addEventListener( 138 | 'mouseup', 139 | (e) => { 140 | this.onDocumentMouseUp(e) 141 | }, 142 | false 143 | ) 144 | } 145 | 146 | // clear control state every time we reenter the game 147 | clearControls() { 148 | this.moveForward = false 149 | this.moveBackward = false 150 | this.moveLeft = false 151 | this.moveRight = false 152 | this.canJump = false 153 | this.velocity.x = 0 154 | this.velocity.z = 0 155 | this.velocity.y = 0 156 | } 157 | 158 | update() { 159 | this.detectCollisions() 160 | this.updateControls() 161 | } 162 | 163 | getCollidables() { 164 | let collidableMeshList = [] 165 | this.scene.traverse(function (object) { 166 | if (object.isMesh) { 167 | collidableMeshList.push(object) 168 | } 169 | }) 170 | return collidableMeshList 171 | } 172 | 173 | // update for these controls, which are unfortunately not included in the controls directly... 174 | // see: https://github.com/mrdoob/three.js/issues/5566 175 | updateControls() { 176 | let speed = 100 177 | 178 | var time = performance.now() 179 | var rawDelta = (time - this.prevTime) / 1000 180 | // clamp delta so lower frame rate clients don't end up way far away 181 | let delta = Math.min(rawDelta, 0.1) 182 | 183 | this.velocity.x -= this.velocity.x * 10.0 * delta 184 | this.velocity.z -= this.velocity.z * 10.0 * delta 185 | 186 | this.direction.z = Number(this.moveForward) - Number(this.moveBackward) 187 | this.direction.x = Number(this.moveRight) - Number(this.moveLeft) 188 | this.direction.normalize() // this ensures consistent this.movements in all this.directions 189 | 190 | if (this.moveForward || this.moveBackward) { 191 | this.velocity.z -= this.direction.z * speed * delta 192 | } 193 | 194 | if (this.moveLeft || this.moveRight) { 195 | this.velocity.x -= this.direction.x * speed * delta 196 | } 197 | 198 | // left-right movement 199 | if ((this.velocity.x > 0 && !this.obstacles.left) || (this.velocity.x < 0 && !this.obstacles.right)) { 200 | this.camera.translateX(-this.velocity.x * delta) 201 | } 202 | 203 | // front-back movement 204 | if ((this.velocity.z > 0 && !this.obstacles.backward) || (this.velocity.z < 0 && !this.obstacles.forward)) { 205 | this.camera.position.add(this.getCameraForwardDirAlongXZPlane().multiplyScalar(-this.velocity.z * delta)) 206 | } 207 | 208 | // up-down movement 209 | // origin point from which we cast a ray downwards 210 | // var origin = this.controls.getObject().position.clone() 211 | let origin = this.camera.position.clone() 212 | origin.set(origin.x, origin.y - this.cameraHeight, origin.z) // set origin to floor level 213 | 214 | // set the raycaster to check downward from this point 215 | this.raycaster.set(origin, new THREE.Vector3(0, -1, 0)) 216 | 217 | var intersectionsDown = this.raycaster.intersectObjects(this.getCollidables()) 218 | var onObject = intersectionsDown.length > 0 && intersectionsDown[0].distance < 0.25 219 | // Here we talkin bout gravity... 220 | // this.velocity.y -= 9.8 * 8.0 * delta; // 100.0 = mass 221 | 222 | // For double-jumping! 223 | if (this.camera.position.y > 1.7 && this.gravity) { 224 | // less gravity like when we begin 225 | this.gravity = 2.0 226 | } else if (this.camera.position.y <= 1.7 && this.gravity) { 227 | this.gravity = 8.0 // original value 228 | } 229 | 230 | // If gravity has been activated (like after pressing Enter)... 231 | if (this.gravity) { 232 | // Add gravity 233 | this.velocity.y -= 9.8 * this.gravity * delta // 100.0 = mass 234 | } else { 235 | // Otherwise don't and we stay suspended on the Y axis 236 | this.velocity.y = 0; 237 | } 238 | 239 | if (onObject === true) { 240 | this.velocity.y = Math.max(0, this.velocity.y) 241 | this.canJump = true 242 | } 243 | 244 | this.camera.position.y += this.velocity.y * delta 245 | 246 | if (this.camera.position.y < this.cameraHeight) { 247 | this.velocity.y = 0 248 | this.camera.position.y = this.cameraHeight 249 | this.canJump = true 250 | } 251 | 252 | this.prevTime = time 253 | } 254 | 255 | getCameraForwardDirAlongXZPlane() { 256 | let forwardDir = new THREE.Vector3(0, 0, -1) 257 | // apply the camera's current rotation to that direction vector: 258 | forwardDir.applyQuaternion(this.camera.quaternion) 259 | 260 | let forwardAlongXZPlane = new THREE.Vector3(forwardDir.x, 0, forwardDir.z) 261 | forwardAlongXZPlane.normalize() 262 | 263 | return forwardAlongXZPlane 264 | } 265 | 266 | //==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==// 267 | //==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==//==// 268 | // Collision Detection 🤾‍♀️ 269 | 270 | /* 271 | * setupCollisionDetection() 272 | * 273 | * Description: 274 | * This function sets up collision detection: 275 | * - creates this.collidableMeshList which will be populated by this.loadFloorModel function 276 | * - creates this.obstacles object which will be queried by player controls before performing movement 277 | * - generates arrays of collision detection points, from which we will perform raycasts in this.detectCollisions() 278 | * 279 | */ 280 | setupCollisionDetection() { 281 | this.obstacles = { 282 | forward: false, 283 | backward: false, 284 | right: false, 285 | left: false, 286 | } 287 | } 288 | 289 | /* 290 | * detectCollisions() 291 | * 292 | * based on method shown here: 293 | * https://github.com/stemkoski/stemkoski.github.com/blob/master/Three.js/Collision-Detection.html 294 | * 295 | * Description: 296 | * 1. Creates THREE.Vector3 objects representing the current forward, left, right, backward direction of the character. 297 | * 2. For each side of the cube, 298 | * - uses the collision detection points created in this.setupCollisionDetection() 299 | * - sends a ray out from each point in the direction set up above 300 | * - if any one of the rays hits an object, set this.obstacles.SIDE (i.e. right or left) to true 301 | * 3. Give this.obstacles object to this.controls 302 | * 303 | * To Do: setup helper function to avoid repetitive code 304 | */ 305 | detectCollisions() { 306 | // reset obstacles: 307 | this.obstacles = { 308 | forward: false, 309 | backward: false, 310 | right: false, 311 | left: false, 312 | } 313 | 314 | // TODO only use XZ components of forward DIR in case we are looking up or down while travelling forward 315 | // NOTE: THREE.PlayerControls seems to be backwards (i.e. the 'forward' controls go backwards)... 316 | // Weird, but this function respects those directions for the sake of not having to make conversions 317 | // https://github.com/mrdoob/three.js/issues/1606 318 | var matrix = new THREE.Matrix4() 319 | matrix.extractRotation(this.camera.matrix) 320 | var backwardDir = new THREE.Vector3(0, 0, 1).applyMatrix4(matrix) 321 | var forwardDir = backwardDir.clone().negate() 322 | var rightDir = forwardDir.clone().cross(new THREE.Vector3(0, 1, 0)).normalize() 323 | var leftDir = rightDir.clone().negate() 324 | 325 | // TODO more points around avatar so we can't be inside of walls 326 | // let pt = this.controls.getObject().position.clone() 327 | let pt = this.camera.position.clone() 328 | 329 | this.forwardCollisionDetectionPoints = [pt] 330 | this.backwardCollisionDetectionPoints = [pt] 331 | this.rightCollisionDetectionPoints = [pt] 332 | this.leftCollisionDetectionPoints = [pt] 333 | 334 | // check forward 335 | this.obstacles.forward = this.checkCollisions(this.forwardCollisionDetectionPoints, forwardDir) 336 | this.obstacles.backward = this.checkCollisions(this.backwardCollisionDetectionPoints, backwardDir) 337 | this.obstacles.left = this.checkCollisions(this.leftCollisionDetectionPoints, leftDir) 338 | this.obstacles.right = this.checkCollisions(this.rightCollisionDetectionPoints, rightDir) 339 | } 340 | 341 | checkCollisions(pts, dir) { 342 | // distance at which a collision will be detected and movement stopped (this should be greater than the movement speed per frame...) 343 | var detectCollisionDistance = 1 344 | 345 | for (var i = 0; i < pts.length; i++) { 346 | var pt = pts[i].clone() 347 | 348 | this.raycaster.set(pt, dir) 349 | this.raycaster.layers.set(3) 350 | var collisions = this.raycaster.intersectObjects(this.getCollidables()) 351 | 352 | if (collisions.length > 0 && collisions[0].distance < detectCollisionDistance) { 353 | return true 354 | } 355 | } 356 | return false 357 | } 358 | 359 | onDocumentMouseDown(event) { 360 | this.onPointerDownPointerX = event.clientX 361 | this.onPointerDownPointerY = event.clientY 362 | this.onPointerDownLon = this.lon 363 | this.onPointerDownLat = this.lat 364 | this.isUserInteracting = true 365 | } 366 | 367 | onDocumentMouseMove(event) { 368 | if (this.isUserInteracting) { 369 | this.lon = (this.onPointerDownPointerX - event.clientX) * -0.3 + this.onPointerDownLon 370 | this.lat = (event.clientY - this.onPointerDownPointerY) * -0.3 + this.onPointerDownLat 371 | this.computeCameraOrientation() 372 | } 373 | } 374 | 375 | onDocumentMouseUp(event) { 376 | this.isUserInteracting = false 377 | } 378 | 379 | computeCameraOrientation() { 380 | this.lat = Math.max(-85, Math.min(85, this.lat)) 381 | this.phi = THREE.MathUtils.degToRad(90 - this.lat) 382 | this.theta = THREE.MathUtils.degToRad(this.lon) 383 | this.camera.target.x = 500 * Math.sin(this.phi) * Math.cos(this.theta) 384 | this.camera.target.y = 500 * Math.cos(this.phi) 385 | this.camera.target.z = 500 * Math.sin(this.phi) * Math.sin(this.theta) 386 | this.camera.lookAt(this.camera.target) 387 | } 388 | } -------------------------------------------------------------------------------- /public/js/libs/simplepeer.min.js: -------------------------------------------------------------------------------- 1 | (function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,t.SimplePeer=e()}})(function(){var t=Math.floor,n=Math.abs,r=Math.pow;return function(){function d(s,e,n){function t(o,i){if(!e[o]){if(!s[o]){var l="function"==typeof require&&require;if(!i&&l)return l(o,!0);if(r)return r(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var a=e[o]={exports:{}};s[o][0].call(a.exports,function(e){var r=s[o][1][e];return t(r||e)},a,a.exports,d,s,e,n)}return e[o].exports}for(var r="function"==typeof require&&require,a=0;a>16,l[c++]=255&t>>8,l[c++]=255&t;return 2===s&&(t=u[e.charCodeAt(n)]<<2|u[e.charCodeAt(n+1)]>>4,l[c++]=255&t),1===s&&(t=u[e.charCodeAt(n)]<<10|u[e.charCodeAt(n+1)]<<4|u[e.charCodeAt(n+2)]>>2,l[c++]=255&t>>8,l[c++]=255&t),l}function d(e){return c[63&e>>18]+c[63&e>>12]+c[63&e>>6]+c[63&e]}function s(e,t,n){for(var r,a=[],o=t;ol?l:d+o));return 1===r?(t=e[n-1],a.push(c[t>>2]+c[63&t<<4]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],a.push(c[t>>10]+c[63&t>>4]+c[63&t<<2]+"=")),a.join("")}n.byteLength=function(e){var t=r(e),n=t[0],a=t[1];return 3*(n+a)/4-a},n.toByteArray=o,n.fromByteArray=l;for(var c=[],u=[],p="undefined"==typeof Uint8Array?Array:Uint8Array,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",g=0,_=f.length;g<_;++g)c[g]=f[g],u[f.charCodeAt(g)]=g;u[45]=62,u[95]=63},{}],2:[function(){},{}],3:[function(e,t,n){(function(){(function(){/*! 2 | * The buffer module from node.js, for the browser. 3 | * 4 | * @author Feross Aboukhadijeh 5 | * @license MIT 6 | */'use strict';var t=String.fromCharCode,o=Math.min;function d(e){if(2147483647e)throw new RangeError("The value \""+e+"\" is invalid for option \"size\"")}function u(e,t,n){return c(e),0>=e?d(e):void 0===t?d(e):"string"==typeof n?d(e).fill(t,n):d(e).fill(t)}function p(e){return c(e),d(0>e?0:0|m(e))}function f(e,t){if(("string"!=typeof t||""===t)&&(t="utf8"),!s.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=0|b(e,t),r=d(n),a=r.write(e,t);return a!==n&&(r=r.slice(0,a)),r}function g(e){for(var t=0>e.length?0:0|m(e.length),n=d(t),r=0;rt||e.byteLength=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647 .toString(16)+" bytes");return 0|e}function b(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||K(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError("The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type "+typeof e);var n=e.length,r=2>>1;case"base64":return z(e).length;default:if(a)return r?-1:H(e).length;t=(""+t).toLowerCase(),a=!0;}}function y(e,t,n){var r=!1;if((void 0===t||0>t)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),0>=n)return"";if(n>>>=0,t>>>=0,n<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return P(this,t,n);case"utf8":case"utf-8":return x(this,t,n);case"ascii":return D(this,t,n);case"latin1":case"binary":return I(this,t,n);case"base64":return A(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0;}}function C(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function R(e,t,n,r,a){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):2147483647n&&(n=-2147483648),n=+n,X(n)&&(n=a?0:e.length-1),0>n&&(n=e.length+n),n>=e.length){if(a)return-1;n=e.length-1}else if(0>n)if(a)n=0;else return-1;if("string"==typeof t&&(t=s.from(t,r)),s.isBuffer(t))return 0===t.length?-1:E(e,t,n,r,a);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):E(e,[t],n,r,a);throw new TypeError("val must be string, number or Buffer")}function E(e,t,n,r,a){function o(e,t){return 1===d?e[t]:e.readUInt16BE(t*d)}var d=1,s=e.length,l=t.length;if(void 0!==r&&(r=(r+"").toLowerCase(),"ucs2"===r||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(2>e.length||2>t.length)return-1;d=2,s/=2,l/=2,n/=2}var c;if(a){var u=-1;for(c=n;cs&&(n=s-l),c=n;0<=c;c--){for(var p=!0,f=0;fa&&(r=a)):r=a;var o=t.length;r>o/2&&(r=o/2);for(var d,s=0;sd&&(s=d):2===l?(c=e[a+1],128==(192&c)&&(f=(31&d)<<6|63&c,127f||57343f&&(s=f))):void 0}null===s?(s=65533,l=1):65535>>10),s=56320|1023&s),r.push(s),a+=l}return N(r)}function N(e){var n=e.length;if(n<=4096)return t.apply(String,e);for(var r="",a=0;at)&&(t=0),(!n||0>n||n>r)&&(n=r);for(var a="",o=t;oe)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function F(e,t,n,r,a,o){if(!s.isBuffer(e))throw new TypeError("\"buffer\" argument must be a Buffer instance");if(t>a||te.length)throw new RangeError("Index out of range")}function B(e,t,n,r){if(n+r>e.length)throw new RangeError("Index out of range");if(0>n)throw new RangeError("Index out of range")}function U(e,t,n,r,a){return t=+t,n>>>=0,a||B(e,t,n,4,34028234663852886e22,-34028234663852886e22),J.write(e,t,n,r,23,4),n+4}function j(e,t,n,r,a){return t=+t,n>>>=0,a||B(e,t,n,8,17976931348623157e292,-17976931348623157e292),J.write(e,t,n,r,52,8),n+8}function q(e){if(e=e.split("=")[0],e=e.trim().replace(Q,""),2>e.length)return"";for(;0!=e.length%4;)e+="=";return e}function W(e){return 16>e?"0"+e.toString(16):e.toString(16)}function H(e,t){t=t||1/0;for(var n,r=e.length,a=null,o=[],d=0;dn){if(!a){if(56319n){-1<(t-=3)&&o.push(239,191,189),a=n;continue}n=(a-55296<<10|n-56320)+65536}else a&&-1<(t-=3)&&o.push(239,191,189);if(a=null,128>n){if(0>(t-=1))break;o.push(n)}else if(2048>n){if(0>(t-=2))break;o.push(192|n>>6,128|63&n)}else if(65536>n){if(0>(t-=3))break;o.push(224|n>>12,128|63&n>>6,128|63&n)}else if(1114112>n){if(0>(t-=4))break;o.push(240|n>>18,128|63&n>>12,128|63&n>>6,128|63&n)}else throw new Error("Invalid code point")}return o}function Y(e){for(var t=[],n=0;n(t-=2));++d)n=e.charCodeAt(d),r=n>>8,a=n%256,o.push(a),o.push(r);return o}function z(e){return $.toByteArray(q(e))}function G(e,t,n,r){for(var a=0;a=t.length||a>=e.length);++a)t[a+n]=e[a];return a}function K(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function X(e){return e!==e}var $=e("base64-js"),J=e("ieee754");n.Buffer=s,n.SlowBuffer=function(e){return+e!=e&&(e=0),s.alloc(+e)},n.INSPECT_MAX_BYTES=50;n.kMaxLength=2147483647,s.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(t){return!1}}(),s.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){return s.isBuffer(this)?this.buffer:void 0}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){return s.isBuffer(this)?this.byteOffset:void 0}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&s[Symbol.species]===s&&Object.defineProperty(s,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),s.poolSize=8192,s.from=function(e,t,n){return l(e,t,n)},s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,s.alloc=function(e,t,n){return u(e,t,n)},s.allocUnsafe=function(e){return p(e)},s.allocUnsafeSlow=function(e){return p(e)},s.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==s.prototype},s.compare=function(e,t){if(K(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),K(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError("The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array");if(e===t)return 0;for(var n=e.length,r=t.length,d=0,l=o(n,r);dt&&(e+=" ... "),""},s.prototype.compare=function(e,t,n,r,a){if(K(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw new TypeError("The \"target\" argument must be one of type Buffer or Uint8Array. Received type "+typeof e);if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===a&&(a=this.length),0>t||n>e.length||0>r||a>this.length)throw new RangeError("out of range index");if(r>=a&&t>=n)return 0;if(r>=a)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,a>>>=0,this===e)return 0;for(var d=a-r,l=n-t,c=o(d,l),u=this.slice(r,a),p=e.slice(t,n),f=0;f>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var a=this.length-t;if((void 0===n||n>a)&&(n=a),0n||0>t)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return w(this,e,t,n);case"utf8":case"utf-8":return S(this,e,t,n);case"ascii":return T(this,e,t,n);case"latin1":case"binary":return v(this,e,t,n);case"base64":return k(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0;}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};s.prototype.slice=function(e,t){var n=this.length;e=~~e,t=t===void 0?n:~~t,0>e?(e+=n,0>e&&(e=0)):e>n&&(e=n),0>t?(t+=n,0>t&&(t=0)):t>n&&(t=n),t>>=0,t>>>=0,n||O(e,t,this.length);for(var r=this[e],a=1,o=0;++o>>=0,t>>>=0,n||O(e,t,this.length);for(var r=this[e+--t],a=1;0>>=0,t||O(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||O(e,t,this.length);for(var a=this[e],o=1,d=0;++d=o&&(a-=r(2,8*t)),a},s.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||O(e,t,this.length);for(var a=t,o=1,d=this[e+--a];0=o&&(d-=r(2,8*t)),d},s.prototype.readInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||O(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt16BE=function(e,t){e>>>=0,t||O(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return e>>>=0,t||O(e,4,this.length),J.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||O(e,4,this.length),J.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||O(e,8,this.length),J.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||O(e,8,this.length),J.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,n,a){if(e=+e,t>>>=0,n>>>=0,!a){var o=r(2,8*n)-1;F(this,e,t,n,o,0)}var d=1,s=0;for(this[t]=255&e;++s>>=0,n>>>=0,!a){var o=r(2,8*n)-1;F(this,e,t,n,o,0)}var d=n-1,s=1;for(this[t+d]=255&e;0<=--d&&(s*=256);)this[t+d]=255&e/s;return t+n},s.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},s.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeIntLE=function(e,t,n,a){if(e=+e,t>>>=0,!a){var o=r(2,8*n-1);F(this,e,t,n,o-1,-o)}var d=0,s=1,l=0;for(this[t]=255&e;++de&&0===l&&0!==this[t+d-1]&&(l=1),this[t+d]=255&(e/s>>0)-l;return t+n},s.prototype.writeIntBE=function(e,t,n,a){if(e=+e,t>>>=0,!a){var o=r(2,8*n-1);F(this,e,t,n,o-1,-o)}var d=n-1,s=1,l=0;for(this[t+d]=255&e;0<=--d&&(s*=256);)0>e&&0===l&&0!==this[t+d+1]&&(l=1),this[t+d]=255&(e/s>>0)-l;return t+n},s.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,1,127,-128),0>e&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeFloatLE=function(e,t,n){return U(this,e,t,!0,n)},s.prototype.writeFloatBE=function(e,t,n){return U(this,e,t,!1,n)},s.prototype.writeDoubleLE=function(e,t,n){return j(this,e,t,!0,n)},s.prototype.writeDoubleBE=function(e,t,n){return j(this,e,t,!1,n)},s.prototype.copy=function(e,t,n,r){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),0t)throw new RangeError("targetStart out of bounds");if(0>n||n>=this.length)throw new RangeError("Index out of range");if(0>r)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-ta||"latin1"===r)&&(e=a)}}else"number"==typeof e&&(e&=255);if(0>t||this.length>>=0,n=n===void 0?this.length:n>>>0,e||(e=0);var o;if("number"==typeof e)for(o=t;o{"%%"===e||(r++,"%c"===e&&(a=r))}),e.splice(a,0,n)},n.save=function(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}},n.load=r,n.useColors=function(){return!!("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))||!("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&31<=parseInt(RegExp.$1,10)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},n.storage=function(){try{return localStorage}catch(e){}}(),n.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],n.log=console.debug||console.log||(()=>{}),t.exports=e("./common")(n);const{formatters:o}=t.exports;o.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this)}).call(this,e("_process"))},{"./common":5,_process:12}],5:[function(e,t){t.exports=function(t){function r(e){function t(...e){if(!t.enabled)return;const a=t,o=+new Date,i=o-(n||o);a.diff=i,a.prev=n,a.curr=o,n=o,e[0]=r.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let d=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,n)=>{if("%%"===t)return"%";d++;const o=r.formatters[n];if("function"==typeof o){const n=e[d];t=o.call(a,n),e.splice(d,1),d--}return t}),r.formatArgs.call(a,e);const s=a.log||r.log;s.apply(a,e)}let n,o=null;return t.namespace=e,t.useColors=r.useColors(),t.color=r.selectColor(e),t.extend=a,t.destroy=r.destroy,Object.defineProperty(t,"enabled",{enumerable:!0,configurable:!1,get:()=>null===o?r.enabled(e):o,set:e=>{o=e}}),"function"==typeof r.init&&r.init(t),t}function a(e,t){const n=r(this.namespace+("undefined"==typeof t?":":t)+e);return n.log=this.log,n}function o(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return r.debug=r,r.default=r,r.coerce=function(e){return e instanceof Error?e.stack||e.message:e},r.disable=function(){const e=[...r.names.map(o),...r.skips.map(o).map(e=>"-"+e)].join(",");return r.enable(""),e},r.enable=function(e){r.save(e),r.names=[],r.skips=[];let t;const n=("string"==typeof e?e:"").split(/[\s,]+/),a=n.length;for(t=0;t{r[e]=t[e]}),r.names=[],r.skips=[],r.formatters={},r.selectColor=function(e){let t=0;for(let n=0;nd&&!l.warned){l.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+l.length+" "+(t+" listeners added. Use emitter.setMaxListeners() to increase limit"));c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=l.length,n(c)}return e}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function s(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},a=d.bind(r);return a.listener=n,r.wrapFn=a,a}function l(e,t,n){var r=e._events;if(r===void 0)return[];var a=r[t];return void 0===a?[]:"function"==typeof a?n?[a.listener||a]:[a]:n?f(a):u(a,a.length)}function c(e){var t=this._events;if(t!==void 0){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function u(e,t){for(var n=Array(t),r=0;re||y(e))throw new RangeError("The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received "+e+".");C=e}}),r.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},r.prototype.setMaxListeners=function(e){if("number"!=typeof e||0>e||y(e))throw new RangeError("The value of \"n\" is out of range. It must be a non-negative number. Received "+e+".");return this._maxListeners=e,this},r.prototype.getMaxListeners=function(){return o(this)},r.prototype.emit=function(e){for(var t=[],n=1;no)return this;0===o?n.shift():p(n,o),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},r.prototype.off=r.prototype.removeListener,r.prototype.removeAllListeners=function(e){var t,n,r;if(n=this._events,void 0===n)return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var a,o=Object.keys(n);for(r=0;r */o.read=function(t,n,a,o,l){var c,u,p=8*l-o-1,f=(1<>1,_=-7,h=a?l-1:0,b=a?-1:1,d=t[n+h];for(h+=b,c=d&(1<<-_)-1,d>>=-_,_+=p;0<_;c=256*c+t[n+h],h+=b,_-=8);for(u=c&(1<<-_)-1,c>>=-_,_+=o;0<_;u=256*u+t[n+h],h+=b,_-=8);if(0===c)c=1-g;else{if(c===f)return u?NaN:(d?-1:1)*(1/0);u+=r(2,o),c-=g}return(d?-1:1)*u*r(2,c-o)},o.write=function(a,o,l,u,p,f){var h,b,y,g=Math.LN2,_=Math.log,C=8*f-p-1,R=(1<>1,w=23===p?r(2,-24)-r(2,-77):0,S=u?0:f-1,T=u?1:-1,d=0>o||0===o&&0>1/o?1:0;for(o=n(o),isNaN(o)||o===1/0?(b=isNaN(o)?1:0,h=R):(h=t(_(o)/g),1>o*(y=r(2,-h))&&(h--,y*=2),o+=1<=h+E?w/y:w*r(2,1-E),2<=o*y&&(h++,y/=2),h+E>=R?(b=0,h=R):1<=h+E?(b=(o*y-1)*r(2,p),h+=E):(b=o*r(2,E-1)*r(2,p),h=0));8<=p;a[l+S]=255&b,S+=T,b/=256,p-=8);for(h=h<=1.5*a?"s":"")}var l=24*(60*60000);t.exports=function(e,t){t=t||{};var n=typeof e;if("string"==n&&0 */let n;t.exports="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"==typeof window?e:window):e=>(n||(n=Promise.resolve())).then(e).catch(e=>setTimeout(()=>{throw e},0))}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],14:[function(e,t){(function(n,r){(function(){'use strict';var a=e("safe-buffer").Buffer,o=r.crypto||r.msCrypto;t.exports=o&&o.getRandomValues?function(e,t){if(e>4294967295)throw new RangeError("requested too many random bytes");var r=a.allocUnsafe(e);if(0n?0:+n,t.length)===t}function i(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}function d(e,t,n){return"number"!=typeof n&&(n=0),!(n+t.length>e.length)&&-1!==e.indexOf(t,n)}var s={};r("ERR_INVALID_OPT_VALUE",function(e,t){return"The value \""+t+"\" is invalid for option \""+e+"\""},TypeError),r("ERR_INVALID_ARG_TYPE",function(e,t,n){var r;"string"==typeof t&&o(t,"not ")?(r="must not be",t=t.replace(/^not /,"")):r="must be";var s;if(i(e," argument"))s="The ".concat(e," ").concat(r," ").concat(a(t,"type"));else{var l=d(e,".")?"property":"argument";s="The \"".concat(e,"\" ").concat(l," ").concat(r," ").concat(a(t,"type"))}return s+=". Received type ".concat(typeof n),s},TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"}),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"}),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=s},{}],16:[function(e,t){(function(n){(function(){'use strict';function r(e){return this instanceof r?void(d.call(this,e),s.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",a)))):new r(e)}function a(){this._writableState.ended||n.nextTick(o,this)}function o(e){e.end()}var i=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=r;var d=e("./_stream_readable"),s=e("./_stream_writable");e("inherits")(r,d);for(var l,c=i(s.prototype),u=0;u>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function f(e,t){return 0>=e||0===t.length&&t.ended?0:t.objectMode?1:e===e?(e>t.highWaterMark&&(t.highWaterMark=p(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0)):t.flowing&&t.length?t.buffer.head.data.length:t.length}function g(e,t){if(x("onEofChunk"),!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.sync?_(e):(t.needReadable=!1,!t.emittedReadable&&(t.emittedReadable=!0,h(e)))}}function _(e){var t=e._readableState;x("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(x("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(h,e))}function h(e){var t=e._readableState;x("emitReadable_",t.destroyed,t.length,t.ended),!t.destroyed&&(t.length||t.ended)&&(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,S(e)}function m(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(b,e,t))}function b(e,t){for(;!t.reading&&!t.ended&&(t.length=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n}function v(e){var t=e._readableState;x("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(k,t,e))}function k(e,t){if(x("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var n=t._writableState;(!n||n.autoDestroy&&n.finished)&&t.destroy()}}function L(e,t){for(var n=0,r=e.length;n=t.highWaterMark)||t.ended))return x("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?v(this):_(this),null;if(e=f(e,t),0===e&&t.ended)return 0===t.length&&v(this),null;var a=t.needReadable;x("need readable",a),(0===t.length||t.length-e>>0),n=this.head,r=0;n;)s(n.data,t,r),r+=n.data.length,n=n.next;return t}},{key:"consume",value:function(e,t){var n;return eo.length?o.length:e;if(a+=i===o.length?o:o.slice(0,e),e-=i,0===e){i===o.length?(++r,this.head=t.next?t.next:this.tail=null):(this.head=t,t.data=o.slice(i));break}++r}return this.length-=r,a}},{key:"_getBuffer",value:function(e){var t=u.allocUnsafe(e),r=this.head,a=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var o=r.data,i=e>o.length?o.length:e;if(o.copy(t,t.length-e,0,i),e-=i,0===e){i===o.length?(++a,this.head=r.next?r.next:this.tail=null):(this.head=r,r.data=o.slice(i));break}++a}return this.length-=a,t}},{key:g,value:function(e,t){return f(this,r({},t,{depth:0,customInspect:!1}))}}]),e}()},{buffer:3,util:2}],23:[function(e,t){(function(e){(function(){'use strict';function n(e,t){a(e,t),r(e)}function r(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function a(e,t){e.emit("error",t)}t.exports={destroy:function(t,o){var i=this,d=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return d||s?(o?o(t):t&&(this._writableState?!this._writableState.errorEmitted&&(this._writableState.errorEmitted=!0,e.nextTick(a,this,t)):e.nextTick(a,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!o&&t?i._writableState?i._writableState.errorEmitted?e.nextTick(r,i):(i._writableState.errorEmitted=!0,e.nextTick(n,i,t)):e.nextTick(n,i,t):o?(e.nextTick(r,i),o(t)):e.nextTick(r,i)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit("error",t)}}}).call(this)}).call(this,e("_process"))},{_process:12}],24:[function(e,t){'use strict';function n(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,r=Array(n),a=0;at.length)throw new u("streams");var a,l=t.map(function(e,n){var d=nd){var s=i?o:"highWaterMark";throw new a(s,d)}return t(d)}return e.objectMode?16:16384}}},{"../../../errors":15}],28:[function(e,t){t.exports=e("events").EventEmitter},{events:7}],29:[function(e,t,n){n=t.exports=e("./lib/_stream_readable.js"),n.Stream=n,n.Readable=n,n.Writable=e("./lib/_stream_writable.js"),n.Duplex=e("./lib/_stream_duplex.js"),n.Transform=e("./lib/_stream_transform.js"),n.PassThrough=e("./lib/_stream_passthrough.js"),n.finished=e("./lib/internal/streams/end-of-stream.js"),n.pipeline=e("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":16,"./lib/_stream_passthrough.js":17,"./lib/_stream_readable.js":18,"./lib/_stream_transform.js":19,"./lib/_stream_writable.js":20,"./lib/internal/streams/end-of-stream.js":24,"./lib/internal/streams/pipeline.js":26}],30:[function(e,t,n){function r(e,t){for(var n in e)t[n]=e[n]}function a(e,t,n){return i(e,t,n)}/*! safe-buffer. MIT License. Feross Aboukhadijeh */var o=e("buffer"),i=o.Buffer;i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=o:(r(o,n),n.Buffer=a),a.prototype=Object.create(i.prototype),r(i,a),a.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,n)},a.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=i(e);return void 0===t?r.fill(0):"string"==typeof n?r.fill(t,n):r.fill(t),r},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o.SlowBuffer(e)}},{buffer:3}],31:[function(e,t,n){'use strict';function r(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0;}}function a(e){var t=r(e);if("string"!=typeof t&&(m.isEncoding===b||!b(e)))throw new Error("Unknown encoding: "+e);return t||e}function o(e){this.encoding=a(e);var t;switch(this.encoding){case"utf16le":this.text=u,this.end=p,t=4;break;case"utf8":this.fillLast=c,t=4;break;case"base64":this.text=f,this.end=g,t=3;break;default:return this.write=_,void(this.end=h);}this.lastNeed=0,this.lastTotal=0,this.lastChar=m.allocUnsafe(t)}function d(e){if(127>=e)return 0;return 6==e>>5?2:14==e>>4?3:30==e>>3?4:2==e>>6?-1:-2}function s(e,t,n){var r=t.length-1;if(r=r)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function p(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function f(e,t){var r=(e.length-t)%3;return 0==r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1==r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function g(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function _(e){return e.toString(this.encoding)}function h(e){return e&&e.length?this.write(e):""}var m=e("safe-buffer").Buffer,b=m.isEncoding||function(e){switch(e=""+e,e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1;}};n.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(t=this.fillLast(e),void 0===t)return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n */const a=e("debug")("simple-peer"),o=e("get-browser-rtc"),i=e("randombytes"),d=e("readable-stream"),s=e("queue-microtask"),l=e("err-code"),{Buffer:c}=e("buffer"),u=65536;class p extends d.Duplex{constructor(e){if(e=Object.assign({allowHalfOpen:!1},e),super(e),this._id=i(4).toString("hex").slice(0,7),this._debug("new peer %o",e),this.channelName=e.initiator?e.channelName||i(20).toString("hex"):null,this.initiator=e.initiator||!1,this.channelConfig=e.channelConfig||p.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},p.config,e.config),this.offerOptions=e.offerOptions||{},this.answerOptions=e.answerOptions||{},this.sdpTransform=e.sdpTransform||(e=>e),this.streams=e.streams||(e.stream?[e.stream]:[]),this.trickle=void 0===e.trickle||e.trickle,this.allowHalfTrickle=void 0!==e.allowHalfTrickle&&e.allowHalfTrickle,this.iceCompleteTimeout=e.iceCompleteTimeout||5000,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=e.wrtc&&"object"==typeof e.wrtc?e.wrtc:o(),!this._wrtc)if("undefined"==typeof window)throw l(new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"),"ERR_WEBRTC_SUPPORT");else throw l(new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(e){return void this.destroy(l(e,"ERR_PC_CONSTRUCTOR"))}this._isReactNativeWebrtc="number"==typeof this._pc._peerConnectionId,this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=e=>{this._onIceCandidate(e)},"object"==typeof this._pc.peerIdentity&&this._pc.peerIdentity.catch(e=>{this.destroy(l(e,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=e=>{this._setupData(e)},this.streams&&this.streams.forEach(e=>{this.addStream(e)}),this._pc.ontrack=e=>{this._onTrack(e)},this._debug("initial negotiation"),this._needsNegotiation(),this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&"open"===this._channel.readyState}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(e){if(!this.destroying){if(this.destroyed)throw l(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if("string"==typeof e)try{e=JSON.parse(e)}catch(t){e={}}this._debug("signal()"),e.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),e.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(e.transceiverRequest.kind,e.transceiverRequest.init)),e.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(e.candidate):this._pendingCandidates.push(e.candidate)),e.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(e)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(e=>{this._addIceCandidate(e)}),this._pendingCandidates=[],"offer"===this._pc.remoteDescription.type&&this._createAnswer())}).catch(e=>{this.destroy(l(e,"ERR_SET_REMOTE_DESCRIPTION"))}),e.sdp||e.candidate||e.renegotiate||e.transceiverRequest||this.destroy(l(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(e){const t=new this._wrtc.RTCIceCandidate(e);this._pc.addIceCandidate(t).catch(e=>{!t.address||t.address.endsWith(".local")?r("Ignoring unsupported ICE candidate."):this.destroy(l(e,"ERR_ADD_ICE_CANDIDATE"))})}send(e){if(!this.destroying){if(this.destroyed)throw l(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(e)}}addTransceiver(e,t){if(!this.destroying){if(this.destroyed)throw l(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(e,t),this._needsNegotiation()}catch(e){this.destroy(l(e,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:e,init:t}})}}addStream(e){if(!this.destroying){if(this.destroyed)throw l(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),e.getTracks().forEach(t=>{this.addTrack(t,e)})}}addTrack(e,t){if(this.destroying)return;if(this.destroyed)throw l(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const n=this._senderMap.get(e)||new Map;let r=n.get(t);if(!r)r=this._pc.addTrack(e,t),n.set(t,r),this._senderMap.set(e,n),this._needsNegotiation();else if(r.removed)throw l(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED");else throw l(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(e,t,n){if(this.destroying)return;if(this.destroyed)throw l(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const r=this._senderMap.get(e),a=r?r.get(n):null;if(!a)throw l(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");t&&this._senderMap.set(t,r),null==a.replaceTrack?this.destroy(l(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK")):a.replaceTrack(t)}removeTrack(e,t){if(this.destroying)return;if(this.destroyed)throw l(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const n=this._senderMap.get(e),r=n?n.get(t):null;if(!r)throw l(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{r.removed=!0,this._pc.removeTrack(r)}catch(e){"NS_ERROR_UNEXPECTED"===e.name?this._sendersAwaitingStable.push(r):this.destroy(l(e,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(e){if(!this.destroying){if(this.destroyed)throw l(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),e.getTracks().forEach(t=>{this.removeTrack(t,e)})}}_needsNegotiation(){this._debug("_needsNegotiation"),this._batchedNegotiation||(this._batchedNegotiation=!0,s(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw l(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(e){this._destroy(e,()=>{})}_destroy(e,t){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",e&&(e.message||e)),s(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",e&&(e.message||e)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch(e){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch(e){}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,e&&this.emit("error",e),this.emit("close"),t()}))}_setupData(e){if(!e.channel)return this.destroy(l(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=e.channel,this._channel.binaryType="arraybuffer","number"==typeof this._channel.bufferedAmountLowThreshold&&(this._channel.bufferedAmountLowThreshold=u),this.channelName=this._channel.label,this._channel.onmessage=e=>{this._onChannelMessage(e)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=e=>{const t=e.error instanceof Error?e.error:new Error(`Datachannel error: ${e.message} ${e.filename}:${e.lineno}:${e.colno}`);this.destroy(l(t,"ERR_DATA_CHANNEL"))};let t=!1;this._closingInterval=setInterval(()=>{this._channel&&"closing"===this._channel.readyState?(t&&this._onChannelClose(),t=!0):t=!1},5000)}_read(){}_write(e,t,n){if(this.destroyed)return n(l(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(e)}catch(e){return this.destroy(l(e,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>u?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=n):n(null)}else this._debug("write before connect"),this._chunk=e,this._cb=n}_onFinish(){if(!this.destroyed){const e=()=>{setTimeout(()=>this.destroy(),1e3)};this._connected?e():this.once("connect",e)}}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(e=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(e.sdp=n(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(!this.destroyed){const t=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:t.type,sdp:t.sdp})}};this._pc.setLocalDescription(e).then(()=>{this._debug("createOffer success"),this.destroyed||(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))}).catch(e=>{this.destroy(l(e,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(e=>{this.destroy(l(e,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(e=>{e.mid||!e.sender.track||e.requested||(e.requested=!0,this.addTransceiver(e.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(e=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(e.sdp=n(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(!this.destroyed){const t=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:t.type,sdp:t.sdp}),this.initiator||this._requestMissingTransceivers()}};this._pc.setLocalDescription(e).then(()=>{this.destroyed||(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))}).catch(e=>{this.destroy(l(e,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(e=>{this.destroy(l(e,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||"failed"===this._pc.connectionState&&this.destroy(l(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const e=this._pc.iceConnectionState,t=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",e,t),this.emit("iceStateChange",e,t),("connected"===e||"completed"===e)&&(this._pcReady=!0,this._maybeReady()),"failed"===e&&this.destroy(l(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),"closed"===e&&this.destroy(l(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(e){const t=e=>("[object Array]"===Object.prototype.toString.call(e.values)&&e.values.forEach(t=>{Object.assign(e,t)}),e);0===this._pc.getStats.length||this._isReactNativeWebrtc?this._pc.getStats().then(n=>{const r=[];n.forEach(e=>{r.push(t(e))}),e(null,r)},t=>e(t)):0{if(this.destroyed)return;const r=[];n.result().forEach(e=>{const n={};e.names().forEach(t=>{n[t]=e.stat(t)}),n.id=e.id,n.type=e.type,n.timestamp=e.timestamp,r.push(t(n))}),e(null,r)},t=>e(t)):e(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const e=()=>{this.destroyed||this.getStats((t,n)=>{if(this.destroyed)return;t&&(n=[]);const r={},a={},o={};let i=!1;n.forEach(e=>{("remotecandidate"===e.type||"remote-candidate"===e.type)&&(r[e.id]=e),("localcandidate"===e.type||"local-candidate"===e.type)&&(a[e.id]=e),("candidatepair"===e.type||"candidate-pair"===e.type)&&(o[e.id]=e)});const d=e=>{i=!0;let t=a[e.localCandidateId];t&&(t.ip||t.address)?(this.localAddress=t.ip||t.address,this.localPort=+t.port):t&&t.ipAddress?(this.localAddress=t.ipAddress,this.localPort=+t.portNumber):"string"==typeof e.googLocalAddress&&(t=e.googLocalAddress.split(":"),this.localAddress=t[0],this.localPort=+t[1]),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let n=r[e.remoteCandidateId];n&&(n.ip||n.address)?(this.remoteAddress=n.ip||n.address,this.remotePort=+n.port):n&&n.ipAddress?(this.remoteAddress=n.ipAddress,this.remotePort=+n.portNumber):"string"==typeof e.googRemoteAddress&&(n=e.googRemoteAddress.split(":"),this.remoteAddress=n[0],this.remotePort=+n[1]),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(n.forEach(e=>{"transport"===e.type&&e.selectedCandidatePairId&&d(o[e.selectedCandidatePairId]),("googCandidatePair"===e.type&&"true"===e.googActiveConnection||("candidatepair"===e.type||"candidate-pair"===e.type)&&e.selected)&&d(e)}),!i&&(!Object.keys(o).length||Object.keys(a).length))return void setTimeout(e,100);if(this._connecting=!1,this._connected=!0,this._chunk){try{this.send(this._chunk)}catch(e){return this.destroy(l(e,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug("sent chunk from \"write before connect\"");const e=this._cb;this._cb=null,e(null)}"number"!=typeof this._channel.bufferedAmountLowThreshold&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};e()}_onInterval(){this._cb&&this._channel&&!(this._channel.bufferedAmount>u)&&this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||("stable"===this._pc.signalingState&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(e=>{this._pc.removeTrack(e),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(e){this.destroyed||(e.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):!e.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),e.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(e){if(this.destroyed)return;let t=e.data;t instanceof ArrayBuffer&&(t=c.from(t)),this.push(t)}_onChannelBufferedAmountLow(){if(!this.destroyed&&this._cb){this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const e=this._cb;this._cb=null,e(null)}}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(e){this.destroyed||e.streams.forEach(t=>{this._debug("on track"),this.emit("track",e.track,t),this._remoteTracks.push({track:e.track,stream:t}),this._remoteStreams.some(e=>e.id===t.id)||(this._remoteStreams.push(t),s(()=>{this._debug("on stream"),this.emit("stream",t)}))})}_debug(){const e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],a.apply(null,e)}}p.WEBRTC_SUPPORT=!!o(),p.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},p.channelConfig={},t.exports=p},{buffer:3,debug:4,"err-code":6,"get-browser-rtc":8,"queue-microtask":13,randombytes:14,"readable-stream":29}]},{},[])("/")}); -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * This is the server which runs all Websocket and WebRTC communications for our application. 4 | * 5 | */ 6 | 7 | // Set up an express application to run the server 8 | const express = require("express"); 9 | const app = express(); 10 | 11 | // tell our express application to serve the 'public' folder 12 | app.use(express.static("public")); 13 | 14 | // tell the server to listen on a given port 15 | const port = process.env.PORT || 8080; 16 | const server = app.listen(port); 17 | console.log("Webserver is running on http://localhost:" + port); 18 | 19 | // We will use the socket.io library to manage Websocket connections 20 | const io = require("socket.io")().listen(server); 21 | 22 | // add the database application 'nedb' 23 | const Datastore = require("nedb"); 24 | // create our database and save it to a local file 25 | const db = new Datastore({ filename: "mydatabase.json", autoload: true }); 26 | 27 | // We will use this object to store information about active peers 28 | let peers = {}; 29 | 30 | function main() { 31 | setupSocketServer(); 32 | 33 | // periodically update all peers with their positions 34 | setInterval(function () { 35 | io.sockets.emit("positions", peers); 36 | }, 100); 37 | } 38 | 39 | main(); 40 | 41 | function setupSocketServer() { 42 | // Set up each socket connection 43 | io.on("connection", (socket) => { 44 | console.log( 45 | "Peer joined with ID", 46 | socket.id, 47 | ". There are " + io.engine.clientsCount + " peer(s) connected." 48 | ); 49 | 50 | // add a new peer indexed by their socket id 51 | peers[socket.id] = { 52 | position: [0, 0.5, 0], 53 | rotation: [0, 0, 0, 1], // stored as XYZW values of Quaternion 54 | }; 55 | 56 | // send the new peer a list of all other peers 57 | socket.emit("introduction", Object.keys(peers)); 58 | 59 | // also give the peer all existing peers positions: 60 | socket.emit("userPositions", peers); 61 | 62 | // also give them existing data in the database 63 | db.find({}, (err, docs) => { 64 | if (err) return; 65 | for (let i = 0; i < docs.length; i++) { 66 | let doc = docs[i]; 67 | socket.emit("data", doc); 68 | } 69 | }); 70 | 71 | // tell everyone that a new user connected 72 | io.emit("peerConnection", socket.id); 73 | 74 | // whenever the peer moves, update their movements in the peers object 75 | socket.on("move", (data) => { 76 | if (peers[socket.id]) { 77 | peers[socket.id].position = data[0]; 78 | peers[socket.id].rotation = data[1]; 79 | } 80 | }); 81 | 82 | // setup a generic ping-pong which can be used to share arbitrary info between peers 83 | socket.on("data", (data) => { 84 | // insert data into the database 85 | db.insert(data); 86 | 87 | // then send it to all peers 88 | io.sockets.emit("data", data); 89 | }); 90 | 91 | // Relay simple-peer signals back and forth 92 | socket.on("signal", (to, from, data) => { 93 | if (to in peers) { 94 | io.to(to).emit("signal", to, from, data); 95 | } else { 96 | console.log("Peer not found!"); 97 | } 98 | }); 99 | 100 | // handle disconnections 101 | socket.on("disconnect", () => { 102 | delete peers[socket.id]; 103 | io.sockets.emit("peerDisconnection", socket.id); 104 | console.log( 105 | "Peer " + 106 | socket.id + 107 | " diconnected, there are " + 108 | io.engine.clientsCount + 109 | " peer(s) connected." 110 | ); 111 | }); 112 | }); 113 | } 114 | --------------------------------------------------------------------------------