source: frontend/node_modules/webpack-dev-server/client/clients/WebSocketClient.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.2 KB
Line 
1function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6import { log } from "../utils/log.js";
7var WebSocketClient = /*#__PURE__*/function () {
8 /**
9 * @param {string} url
10 */
11 function WebSocketClient(url) {
12 _classCallCheck(this, WebSocketClient);
13 this.client = new WebSocket(url);
14 this.client.onerror = function (error) {
15 log.error(error);
16 };
17 }
18
19 /**
20 * @param {(...args: any[]) => void} f
21 */
22 _createClass(WebSocketClient, [{
23 key: "onOpen",
24 value: function onOpen(f) {
25 this.client.onopen = f;
26 }
27
28 /**
29 * @param {(...args: any[]) => void} f
30 */
31 }, {
32 key: "onClose",
33 value: function onClose(f) {
34 this.client.onclose = f;
35 }
36
37 // call f with the message string as the first argument
38 /**
39 * @param {(...args: any[]) => void} f
40 */
41 }, {
42 key: "onMessage",
43 value: function onMessage(f) {
44 this.client.onmessage = function (e) {
45 f(e.data);
46 };
47 }
48 }]);
49 return WebSocketClient;
50}();
51export { WebSocketClient as default };
Note: See TracBrowser for help on using the repository browser.