source: frontend/node_modules/webpack-dev-server/client/clients/SockJSClient.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.5 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 SockJS from "../modules/sockjs-client/index.js";
7import { log } from "../utils/log.js";
8var SockJSClient = /*#__PURE__*/function () {
9 /**
10 * @param {string} url
11 */
12 function SockJSClient(url) {
13 _classCallCheck(this, SockJSClient);
14 // SockJS requires `http` and `https` protocols
15 this.sock = new SockJS(url.replace(/^ws:/i, "http:").replace(/^wss:/i, "https:"));
16 this.sock.onerror =
17 /**
18 * @param {Error} error
19 */
20 function (error) {
21 log.error(error);
22 };
23 }
24
25 /**
26 * @param {(...args: any[]) => void} f
27 */
28 _createClass(SockJSClient, [{
29 key: "onOpen",
30 value: function onOpen(f) {
31 this.sock.onopen = f;
32 }
33
34 /**
35 * @param {(...args: any[]) => void} f
36 */
37 }, {
38 key: "onClose",
39 value: function onClose(f) {
40 this.sock.onclose = f;
41 }
42
43 // call f with the message string as the first argument
44 /**
45 * @param {(...args: any[]) => void} f
46 */
47 }, {
48 key: "onMessage",
49 value: function onMessage(f) {
50 this.sock.onmessage =
51 /**
52 * @param {Error & { data: string }} e
53 */
54 function (e) {
55 f(e.data);
56 };
57 }
58 }]);
59 return SockJSClient;
60}();
61export { SockJSClient as default };
Note: See TracBrowser for help on using the repository browser.