diff --git a/package-lock.json b/package-lock.json index b1f724c..435445c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,14 +1,15 @@ { "name": "httpgd", - "version": "0.1.4", + "version": "0.1.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "httpgd", - "version": "0.1.4", + "version": "0.1.5", "license": "MIT", "dependencies": { + "@types/ws": "^8.2.0", "isomorphic-ws": "^4.0.1" }, "devDependencies": { @@ -142,12 +143,25 @@ "@types/unist": "*" } }, + "node_modules/@types/node": { + "version": "16.11.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.0.tgz", + "integrity": "sha512-8MLkBIYQMuhRBQzGN9875bYsOhPnf/0rgXGo66S2FemHkhbn9qtsz9ywV1iCG+vbjigE4WUNVvw37Dx+L0qsPg==" + }, "node_modules/@types/unist": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz", "integrity": "sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==", "dev": true }, + "node_modules/@types/ws": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.2.0.tgz", + "integrity": "sha512-cyeefcUCgJlEk+hk2h3N+MqKKsPViQgF5boi9TTHSK+PoR9KWBb/C5ccPcDyAqgsbAYHTwulch725DV84+pSpg==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "4.31.2", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.31.2.tgz", @@ -2162,12 +2176,25 @@ "@types/unist": "*" } }, + "@types/node": { + "version": "16.11.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.0.tgz", + "integrity": "sha512-8MLkBIYQMuhRBQzGN9875bYsOhPnf/0rgXGo66S2FemHkhbn9qtsz9ywV1iCG+vbjigE4WUNVvw37Dx+L0qsPg==" + }, "@types/unist": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz", "integrity": "sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==", "dev": true }, + "@types/ws": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.2.0.tgz", + "integrity": "sha512-cyeefcUCgJlEk+hk2h3N+MqKKsPViQgF5boi9TTHSK+PoR9KWBb/C5ccPcDyAqgsbAYHTwulch725DV84+pSpg==", + "requires": { + "@types/node": "*" + } + }, "@typescript-eslint/eslint-plugin": { "version": "4.31.2", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.31.2.tgz", diff --git a/package.json b/package.json index 785fd3a..eba7f00 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "lib/**/*" ], "dependencies": { + "@types/ws": "^8.2.0", "isomorphic-ws": "^4.0.1" } } diff --git a/src/api.ts b/src/api.ts index ec7d278..c1e0119 100644 --- a/src/api.ts +++ b/src/api.ts @@ -6,7 +6,7 @@ import { HttpgdPlotRequest, HttpgdRemoveRequest } from './types'; -import WebSocket = require('isomorphic-ws'); +import { WebSocket } from 'isomorphic-ws'; const URL_HTTP = 'http://'; const URL_WS = 'ws://'; diff --git a/src/connection.ts b/src/connection.ts index 74d22b3..49098cd 100644 --- a/src/connection.ts +++ b/src/connection.ts @@ -1,7 +1,7 @@ import { HttpgdBackend, HttpgdStateResponse } from './types'; import * as api from './api'; import { StateChangeListener } from './utils'; -import WebSocket = require('isomorphic-ws'); +import { WebSocket } from 'isomorphic-ws'; /** * Connection mode. @@ -108,7 +108,7 @@ export class HttpgdConnection { this.clearWebsocket(); this.socket = api.new_websocket(this.backend); - this.socket.onmessage = (ev) => this.onWsMessage(ev.data); + this.socket.onmessage = (ev) => this.onWsMessage(ev.data.toString()); this.socket.onopen = () => this.onWsOpen(); this.socket.onclose = () => this.onWsClose(); this.socket.onerror = () => this.start(HttpgdConnectionMode.SLOWPOLL); diff --git a/tsconfig.json b/tsconfig.json index 8205908..e25b774 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,8 @@ "module": "commonjs", "declaration": true, "outDir": "./lib", - "strict": true + "strict": true, + "esModuleInterop": true }, "include": [ "src"