20 lines
400 B
TypeScript
20 lines
400 B
TypeScript
type UseWindow = Window & typeof globalThis & { chrome?: any }
|
|
|
|
/**
|
|
* Returns the window object
|
|
*
|
|
* @internal
|
|
*/
|
|
export function useWindow(): UseWindow {
|
|
if (typeof window !== 'undefined') {
|
|
return window as UseWindow
|
|
} else {
|
|
return {
|
|
chrome: false,
|
|
addEventListener(..._: Parameters<Window['addEventListener']>) {
|
|
// do nothing
|
|
},
|
|
} as UseWindow
|
|
}
|
|
}
|