Skip to content

Commit

Permalink
fix: support SW usage (#23)
Browse files Browse the repository at this point in the history
* fix: support SW usage

* refactor: use globalThis

Co-authored-by: Michael Bumann <hello@michaelbumann.com>

---------

Co-authored-by: Aaron <abarnard@protonmail.com>
Co-authored-by: Michael Bumann <hello@michaelbumann.com>
  • Loading branch information
3 people authored Mar 21, 2023
1 parent 5469c11 commit e910827
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ class LnMessage {
this.connectionStatus$.next('connecting')
this._attemptReconnect = attemptReconnect

this.socket = new (
typeof window === 'undefined' ? (await import('ws')).default : window.WebSocket
)(this.wsUrl)
this.socket = new (typeof globalThis.WebSocket === 'undefined' ? (await import('ws')).default : globalThis.WebSocket)(this.wsUrl)
this.socket.binaryType = 'arraybuffer'

this.socket.onopen = async () => {
Expand Down

0 comments on commit e910827

Please sign in to comment.