File tree Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ export default class LNC {
6565 }
6666
6767 private get wasm ( ) {
68- return window [ this . _namespace ] as WasmGlobal ;
68+ return globalThis [ this . _namespace ] as WasmGlobal ;
6969 }
7070
7171 get isReady ( ) {
@@ -195,7 +195,11 @@ export default class LNC {
195195 ) ;
196196
197197 // add an event listener to disconnect if the page is unloaded
198- window . addEventListener ( 'unload' , this . wasm . wasmClientDisconnect ) ;
198+ if ( typeof window !== "undefined" ) {
199+ window . addEventListener ( 'unload' , this . wasm . wasmClientDisconnect ) ;
200+ } else {
201+ log . info ( "No unload event listener added. window is not available" ) ;
202+ }
199203
200204 // repeatedly check if the connection was successful
201205 return new Promise < void > ( ( resolve , reject ) => {
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ export const generateSalt = () => {
66 const validChars =
77 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' ;
88 let array = new Uint8Array ( 32 ) ;
9- window . crypto . getRandomValues ( array ) ;
9+ globalThis . crypto . getRandomValues ( array ) ;
1010 array = array . map ( ( x ) => validChars . charCodeAt ( x % validChars . length ) ) ;
1111 const salt = String . fromCharCode . apply ( null , array as any ) ;
1212 return salt ;
Original file line number Diff line number Diff line change @@ -27,9 +27,9 @@ export class Logger {
2727 // by default, log nothing (assuming prod)
2828 let level = LogLevel . none ;
2929
30- if ( localStorage && localStorage . getItem ( 'debug' ) ) {
30+ if ( globalThis . localStorage && globalThis . localStorage . getItem ( 'debug' ) ) {
3131 // if a 'debug' key is found in localStorage, use the level in storage or 'debug' by default
32- const storageLevel = localStorage . getItem ( 'debug-level' ) || 'debug' ;
32+ const storageLevel = globalThis . localStorage . getItem ( 'debug-level' ) || 'debug' ;
3333 level = LogLevel [ storageLevel as keyof typeof LogLevel ] ;
3434 }
3535
You can’t perform that action at this time.
0 commit comments