use-broadcast-ts
Advanced tools
Comparing version 1.6.0 to 1.7.0
@@ -148,3 +148,8 @@ 'use strict'; | ||
var _options$name; | ||
if (typeof window === 'undefined') { | ||
/** | ||
* The broadcast channel is not supported in SSR | ||
*/ | ||
if (typeof window === 'undefined' && | ||
// @ts-expect-error WorkerGlobalScope is not defined in the types | ||
!(typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)) { | ||
console.warn('BroadcastChannel is not supported in this environment. The store will not be shared.'); | ||
@@ -399,3 +404,5 @@ return f(set, get, store); | ||
*/ | ||
window.addEventListener('beforeunload', onClose); | ||
if (typeof window !== 'undefined') { | ||
window.addEventListener('beforeunload', onClose); | ||
} | ||
@@ -402,0 +409,0 @@ /** |
{ | ||
"name": "use-broadcast-ts", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "Use the Broadcast Channel API in React easily with hooks or Zustand, and Typescript!", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -59,3 +59,10 @@ import { StateCreator, StoreMutatorIdentifier } from 'zustand'; | ||
const sharedImpl: SharedImpl = (f, options) => (set, get, store) => { | ||
if (typeof window === 'undefined') { | ||
/** | ||
* The broadcast channel is not supported in SSR | ||
*/ | ||
if ( | ||
typeof window === 'undefined' && | ||
// @ts-expect-error WorkerGlobalScope is not defined in the types | ||
!(typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) | ||
) { | ||
console.warn('BroadcastChannel is not supported in this environment. The store will not be shared.'); | ||
@@ -316,3 +323,5 @@ return f(set, get, store); | ||
*/ | ||
window.addEventListener('beforeunload', onClose); | ||
if (typeof window !== 'undefined') { | ||
window.addEventListener('beforeunload', onClose); | ||
} | ||
@@ -319,0 +328,0 @@ /** |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44823
1362