Class: exports

exports(options)

NoSleepApp prevents devices from entering sleep mode. It uses the Wake Lock API, older iOS hacks, or video playback depending on device support.

Constructor

new exports(options)

Parameters:
Name Type Description
options Object Configuration options for NoSleepApp.
Properties
Name Type Attributes Default Description
strategy 'wakeLock' | 'video' | 'legacy' <optional>
'wakeLock' The strategy to use for preventing sleep.
retryInterval number <optional>
10000 Interval to retry enabling Wake Lock if it fails (in milliseconds).
fallbackEnabled boolean <optional>
true Whether to enable fallback mechanisms if Wake Lock is not available.
Source:

Members

_wakeLock :WakeLockSentinel|null

The active Wake Lock instance.
Type:
  • WakeLockSentinel | null
Source:

callback :function

The callback function to execute when the state changes.
Type:
  • function
Source:

enabled :boolean

Indicates whether NoSleepApp is currently enabled.
Type:
  • boolean
Source:

noSleepElement :NoSleepElement

Video element for non-iOS and non-Wake Lock devices.
Type:
  • NoSleepElement
Source:

noSleepTimer :number|null

Timer ID for the iOS hack to prevent sleep.
Type:
  • number | null
Source:

noSleepVideo :HTMLVideoElement

The hidden video element used to prevent sleep.
Type:
  • HTMLVideoElement
Source:

visibilityListener :VisibilityListener|null

Listener for visibility changes to re-enable Wake Lock.
Type:
  • VisibilityListener | null
Source:

exports()

Class to manage a hidden video element that prevents devices from sleeping.

Constructor

new exports()

Source:

Members

_wakeLock :WakeLockSentinel|null

The active Wake Lock instance.
Type:
  • WakeLockSentinel | null
Source:

callback :function

The callback function to execute when the state changes.
Type:
  • function
Source:

enabled :boolean

Indicates whether NoSleepApp is currently enabled.
Type:
  • boolean
Source:

noSleepElement :NoSleepElement

Video element for non-iOS and non-Wake Lock devices.
Type:
  • NoSleepElement
Source:

noSleepTimer :number|null

Timer ID for the iOS hack to prevent sleep.
Type:
  • number | null
Source:

noSleepVideo :HTMLVideoElement

The hidden video element used to prevent sleep.
Type:
  • HTMLVideoElement
Source:

visibilityListener :VisibilityListener|null

Listener for visibility changes to re-enable Wake Lock.
Type:
  • VisibilityListener | null
Source:

exports(callback)

Class to listen for visibility and fullscreen changes in the document. It triggers a callback when the document becomes visible or enters fullscreen mode.

Constructor

new exports(callback)

Parameters:
Name Type Description
callback function The callback function to invoke on visibility or fullscreen changes.
Source:

Members

_wakeLock :WakeLockSentinel|null

The active Wake Lock instance.
Type:
  • WakeLockSentinel | null
Source:

callback :function

The callback function to execute when the state changes.
Type:
  • function
Source:

enabled :boolean

Indicates whether NoSleepApp is currently enabled.
Type:
  • boolean
Source:

noSleepElement :NoSleepElement

Video element for non-iOS and non-Wake Lock devices.
Type:
  • NoSleepElement
Source:

noSleepTimer :number|null

Timer ID for the iOS hack to prevent sleep.
Type:
  • number | null
Source:

noSleepVideo :HTMLVideoElement

The hidden video element used to prevent sleep.
Type:
  • HTMLVideoElement
Source:

visibilityListener :VisibilityListener|null

Listener for visibility changes to re-enable Wake Lock.
Type:
  • VisibilityListener | null
Source: