mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-14 15:49:31 -07:00
- Attempt pixel-perfect scanline rendering for scaled displays and zoom scenarios - Implement dynamic scanline thickness calculation to prevent sub-pixel rendering issues - Add enhanced kiosk detection via isKioskLike for better fullscreen optimization - Optimize scanlines for specific kiosk resolutions (1024x768, 1023x767) - Add responsive SCSS media queries for different display densities - Include extensive debugging utilities for scanline troubleshooting - Improve noSleep error handling with proper promise rejection handling - Update to modern fullscreen API method names - Add async/await error handling for fullscreen requests - Trigger resize after fullscreen engagement to apply optimal scaling
26 lines
754 B
JavaScript
26 lines
754 B
JavaScript
// track state of nosleep locally to avoid a null case error
|
|
// when nosleep.disable is called without first calling .enable
|
|
|
|
let wakeLock = false;
|
|
|
|
const noSleep = (enable = false) => {
|
|
// get a nosleep controller
|
|
if (!noSleep.controller) noSleep.controller = new NoSleep();
|
|
// don't call anything if the states match
|
|
if (wakeLock === enable) return Promise.resolve(false);
|
|
// store the value
|
|
wakeLock = enable;
|
|
// call the function
|
|
if (enable) {
|
|
return noSleep.controller.enable().catch((error) => {
|
|
// Handle wake lock request failures gracefully
|
|
console.warn('Wake lock request failed:', error.message);
|
|
wakeLock = false;
|
|
return false;
|
|
});
|
|
}
|
|
return Promise.resolve(noSleep.controller.disable());
|
|
};
|
|
|
|
export default noSleep;
|