Skip to content

Commit

Permalink
Do not depend on dom
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerlong committed Jan 27, 2025
1 parent 9d2c067 commit 2a10918
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 6 additions & 3 deletions packages/extensions/ws/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,17 @@ class WebSocketExtension extends SdkExtension {
);

// browser only code start
if (typeof window !== "undefined" && window.addEventListener) {
window.addEventListener("offline", () => {
if (
typeof globalThis.window !== "undefined" &&
globalThis.window.addEventListener
) {
globalThis.window.addEventListener("offline", () => {
if (this.pingServerHandle) {
clearTimeout(this.pingServerHandle);
}
this.ws?.close();
});
window.addEventListener("online", () => {
globalThis.window.addEventListener("online", () => {
check();
});
}
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"compilerOptions": {
"esModuleInterop": true,
"lib": ["DOM"],
"declaration": true,
"sourceMap": true
}
Expand Down

0 comments on commit 2a10918

Please sign in to comment.