File size: 582 Bytes
5144199
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { isServer } from './utils'

export type IsServerValue = () => boolean

/**
 * Manages environment detection used by TanStack Query internals.
 */
export const environmentManager = (() => {
  let isServerFn: IsServerValue = () => isServer

  return {
    /**
     * Returns whether the current runtime should be treated as a server environment.
     */
    isServer(): boolean {
      return isServerFn()
    },
    /**
     * Overrides the server check globally.
     */
    setIsServer(isServerValue: IsServerValue): void {
      isServerFn = isServerValue
    },
  }
})()