You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
5.6 KiB
1 lines
5.6 KiB
{"ast":null,"code":"/* global __webpack_dev_server_client__ */\nimport WebSocketClient from \"./clients/WebSocketClient.js\";\nimport { log } from \"./utils/log.js\"; // this WebsocketClient is here as a default fallback, in case the client is not injected\n\n/* eslint-disable camelcase */\n\nvar Client = // eslint-disable-next-line no-nested-ternary\ntypeof __webpack_dev_server_client__ !== \"undefined\" ? typeof __webpack_dev_server_client__.default !== \"undefined\" ? __webpack_dev_server_client__.default : __webpack_dev_server_client__ : WebSocketClient;\n/* eslint-enable camelcase */\n\nvar retries = 0;\nvar maxRetries = 10;\nvar client = null;\n/**\n * @param {string} url\n * @param {{ [handler: string]: (data?: any, params?: any) => any }} handlers\n * @param {number} [reconnect]\n */\n\nvar socket = function initSocket(url, handlers, reconnect) {\n client = new Client(url);\n client.onOpen(function () {\n retries = 0;\n\n if (typeof reconnect !== \"undefined\") {\n maxRetries = reconnect;\n }\n });\n client.onClose(function () {\n if (retries === 0) {\n handlers.close();\n } // Try to reconnect.\n\n\n client = null; // After 10 retries stop trying, to prevent logspam.\n\n if (retries < maxRetries) {\n // Exponentially increase timeout to reconnect.\n // Respectfully copied from the package `got`.\n // eslint-disable-next-line no-restricted-properties\n var retryInMs = 1000 * Math.pow(2, retries) + Math.random() * 100;\n retries += 1;\n log.info(\"Trying to reconnect...\");\n setTimeout(function () {\n socket(url, handlers, reconnect);\n }, retryInMs);\n }\n });\n client.onMessage(\n /**\n * @param {any} data\n */\n function (data) {\n var message = JSON.parse(data);\n\n if (handlers[message.type]) {\n handlers[message.type](message.data, message.params);\n }\n });\n};\n\nexport default socket;","map":{"version":3,"sources":["/tmp/vue-hello/node_modules/webpack-dev-server/client/socket.js"],"names":["WebSocketClient","log","Client","__webpack_dev_server_client__","default","retries","maxRetries","client","socket","initSocket","url","handlers","reconnect","onOpen","onClose","close","retryInMs","Math","pow","random","info","setTimeout","onMessage","data","message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,GAAD,EAAMC,QAAN,EAAgBC,SAAhB,CAAN;AACD,OAFS,EAEPI,SAFO,CAAV;AAGD;AACF,GAnBD;AAoBAT,EAAAA,MAAM,CAACe,SAAP;AACA;AACF;AACA;AACE,YAAUC,IAAV,EAAgB;AACd,QAAIC,OAAO,GAAGC,IAAI,CAACC,KAAL,CAAWH,IAAX,CAAd;;AAEA,QAAIZ,QAAQ,CAACa,OAAO,CAACG,IAAT,CAAZ,EAA4B;AAC1BhB,MAAAA,QAAQ,CAACa,OAAO,CAACG,IAAT,CAAR,CAAuBH,OAAO,CAACD,IAA/B,EAAqCC,OAAO,CAACI,MAA7C;AACD;AACF,GAVD;AAWD,CAxCD;;AA0CA,eAAepB,MAAf","sourcesContent":["/* global __webpack_dev_server_client__ */\nimport WebSocketClient from \"./clients/WebSocketClient.js\";\nimport { log } from \"./utils/log.js\"; // this WebsocketClient is here as a default fallback, in case the client is not injected\n\n/* eslint-disable camelcase */\n\nvar Client = // eslint-disable-next-line no-nested-ternary\ntypeof __webpack_dev_server_client__ !== \"undefined\" ? typeof __webpack_dev_server_client__.default !== \"undefined\" ? __webpack_dev_server_client__.default : __webpack_dev_server_client__ : WebSocketClient;\n/* eslint-enable camelcase */\n\nvar retries = 0;\nvar maxRetries = 10;\nvar client = null;\n/**\n * @param {string} url\n * @param {{ [handler: string]: (data?: any, params?: any) => any }} handlers\n * @param {number} [reconnect]\n */\n\nvar socket = function initSocket(url, handlers, reconnect) {\n client = new Client(url);\n client.onOpen(function () {\n retries = 0;\n\n if (typeof reconnect !== \"undefined\") {\n maxRetries = reconnect;\n }\n });\n client.onClose(function () {\n if (retries === 0) {\n handlers.close();\n } // Try to reconnect.\n\n\n client = null; // After 10 retries stop trying, to prevent logspam.\n\n if (retries < maxRetries) {\n // Exponentially increase timeout to reconnect.\n // Respectfully copied from the package `got`.\n // eslint-disable-next-line no-restricted-properties\n var retryInMs = 1000 * Math.pow(2, retries) + Math.random() * 100;\n retries += 1;\n log.info(\"Trying to reconnect...\");\n setTimeout(function () {\n socket(url, handlers, reconnect);\n }, retryInMs);\n }\n });\n client.onMessage(\n /**\n * @param {any} data\n */\n function (data) {\n var message = JSON.parse(data);\n\n if (handlers[message.type]) {\n handlers[message.type](message.data, message.params);\n }\n });\n};\n\nexport default socket;"]},"metadata":{},"sourceType":"module"} |