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
6.0 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; // Initialized client is exported so external consumers can utilize the same instance\n// It is mutable to enforce singleton\n// eslint-disable-next-line import/no-mutable-exports\n\nexport var 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,"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","JSON","parse","type","params"],"sources":["/Users/mahdi/Documents/work/programming/barnameNegar/arbaeenWebApp/node_modules/webpack-dev-server/client/socket.js"],"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; // Initialized client is exported so external consumers can utilize the same instance\n// It is mutable to enforce singleton\n// eslint-disable-next-line import/no-mutable-exports\n\nexport var 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;"],"mappings":"AAAA;AACA,OAAOA,eAAP,MAA4B,8BAA5B;AACA,SAASC,GAAT,QAAoB,gBAApB,C,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