File tree 4 files changed +261
-8
lines changed
4 files changed +261
-8
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @ainblockchain/ain-js" ,
3
- "version" : " 1.8 .0" ,
3
+ "version" : " 1.9 .0" ,
4
4
"description" : " " ,
5
5
"main" : " lib/ain.js" ,
6
6
"scripts" : {
13
13
"test_ain_raw" : " jest ain_raw.test.ts" ,
14
14
"test_he" : " jest he.test.ts" ,
15
15
"test_em" : " jest event_manager.test.ts" ,
16
- "docs" : " yarn build && typedoc --plugin @mxssfd/typedoc-theme --theme my-theme --out docs"
16
+ "docs" : " yarn build && typedoc --plugin @mxssfd/typedoc-theme --theme my-theme --out docs" ,
17
+ "postinstall" : " patch-package"
17
18
},
18
19
"engines" : {
19
20
"node" : " >=16"
59
60
"browserify-cipher" : " ^1.0.1" ,
60
61
"eventemitter3" : " ^4.0.0" ,
61
62
"hdkey" : " ^1.1.1" ,
63
+ "is-in-browser" : " ^2.0.0" ,
62
64
"isomorphic-ws" : " ^5.0.0" ,
63
65
"lodash" : " ^4.17.20" ,
64
66
"node-seal" : " ^4.5.7" ,
67
+ "patch-package" : " ^8.0.0" ,
65
68
"pbkdf2" : " ^3.0.17" ,
69
+ "postinstall-postinstall" : " ^2.1.0" ,
66
70
"randombytes" : " ^2.1.0" ,
67
71
"scryptsy" : " ^2.1.0" ,
68
72
"semver" : " ^6.3.0" ,
Original file line number Diff line number Diff line change
1
+ diff --git a/node_modules/isomorphic-ws/index.d.ts b/node_modules/isomorphic-ws/index.d.ts
2
+ index de923a9..7d56cf5 100644
3
+ --- a/node_modules/isomorphic-ws/index.d.ts
4
+ +++ b/node_modules/isomorphic-ws/index.d.ts
5
+ @@ -3,6 +3,9 @@
6
+ // Fix for https://github.com/heineiuo/isomorphic-ws/issues/8
7
+ // If there is still something wrong, welcome issue.
8
+
9
+ - import WebSocket = require('ws')
10
+ + // NOTE(jiyoung): comment out for original reference.
11
+ + // import WebSocket = require('ws')
12
+ + // export = WebSocket
13
+
14
+ - export = WebSocket
15
+ \ No newline at end of file
16
+ + import { WebSocket } from 'ws'
17
+ + export default WebSocket
18
+ \ No newline at end of file
Original file line number Diff line number Diff line change 1
1
import Ain from '../ain' ;
2
- import * as WebSocket from 'isomorphic-ws' ;
2
+ import isBrowser from "is-in-browser" ;
3
+ import WebSocket from 'isomorphic-ws' ;
4
+ import { WebSocket as WebSocketBE } from 'ws' ;
3
5
import {
4
6
EventChannelMessageTypes ,
5
7
EventChannelMessage ,
@@ -21,7 +23,7 @@ export default class EventChannelClient {
21
23
/** The event callback manager object. */
22
24
private readonly _eventCallbackManager : EventCallbackManager ;
23
25
/** The web socket client. */
24
- private _ws ?: WebSocket ;
26
+ private _ws ?: WebSocket | WebSocketBE ;
25
27
/** The blockchain endpoint URL. */
26
28
private _endpointUrl ?: string ;
27
29
/** Whether it's connected or not. */
@@ -86,7 +88,8 @@ export default class EventChannelClient {
86
88
}
87
89
88
90
this . _endpointUrl = url ;
89
- this . _ws = new WebSocket ( url ) ;
91
+ // NOTE(platfowner): Fix WebSocket module import issue (see https://github.com/ainblockchain/ain-js/issues/177).
92
+ this . _ws = isBrowser ? new WebSocket ( url ) : new WebSocketBE ( url ) ;
90
93
// NOTE(platfowner): A custom handshake timeout (see https://github.com/ainblockchain/ain-js/issues/171).
91
94
this . startHandshakeTimer ( DEFAULT_HANDSHAKE_TIMEOUT_MS ) ;
92
95
You can’t perform that action at this time.
0 commit comments