Open source · v1.0.0
@awaketab/wake: the honest wake lock library
An open-source Screen Wake Lock library with seven honest states, a tiny video fallback and denial advice. The maintained NoSleep.js replacement.
Install
terminalnpm install @awaketab/wakemain.jsimport { createWakeLock } from '@awaketab/wake';const lock = createWakeLock();lock.on('change', ({ from, to, reason, advice }) => {pill.textContent = to; // one of the seven stateshint.textContent = advice ?? ''; // e.g. 'iframe_no_allow', 'hidden_document'});start.addEventListener('click', () => lock.request()); // a tap allows the fallbackstop.addEventListener('click', () => lock.release());
Seven honest states
The same states and pill copy as the AwakeTab tool.
StateWhat the pill says
idleWhat the pill says: Ready
requestingWhat the pill says: Starting…
heldWhat the pill says: Screen awake
lostWhat the pill says: Paused — tab hidden
deniedWhat the pill says: Blocked — here's the fix
unsupportedWhat the pill says: Tap to use the fallback
fallbackWhat the pill says: Awake via video fallback
@awaketab/wake vs NoSleep.js
@awaketab/wakeNoSleep.js
Last release@awaketab/wake: Maintained; semverNoSleep.js: 16 December 2020
Native Wake Lock@awaketab/wake: Yes, firstNoSleep.js: Yes (when present)
State reporting@awaketab/wake: Seven states + change events with reason and adviceNoSleep.js:
isEnabled booleanDenial diagnosis@awaketab/wake:
classifyDenial() advice codesNoSleep.js: NoneFallback@awaketab/wake: Inlined 1-frame video, gesture-aware, pauses when hiddenNoSleep.js: Looping video, always on
Size (gzip)@awaketab/wake: ≤ 3.4 KB, fallback includedNoSleep.js: ≈ 3.2 KB
TypeScript · SSR@awaketab/wake: Native · inert on the serverNoSleep.js: Community typings · no
Adapters@awaketab/wake: React, Preact, Vue (< 400 B each)NoSleep.js: No