Skip to content

Commit

Permalink
Fix isomorphic-ws
Browse files Browse the repository at this point in the history
  • Loading branch information
nx10 committed Oct 16, 2021
1 parent a33d2e9 commit db9c4e3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
31 changes: 29 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"lib/**/*"
],
"dependencies": {
"@types/ws": "^8.2.0",
"isomorphic-ws": "^4.0.1"
}
}
2 changes: 1 addition & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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://';
Expand Down
4 changes: 2 additions & 2 deletions src/connection.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"module": "commonjs",
"declaration": true,
"outDir": "./lib",
"strict": true
"strict": true,
"esModuleInterop": true
},
"include": [
"src"
Expand Down

0 comments on commit db9c4e3

Please sign in to comment.