feat(reader): add document mode to the PDF viewer, overhaul PDF viewer, add different modes to CBX viewer (#306)

* feat(reader): add document mode to the PDF viewer, overhaul PDF viewer, add different modes to CBX viewer

* feat(reader): improve reader settings with brightness, emulate book mode, and click-to-paginate options

* feat(reader): add long strip scroll mode and update related settings
This commit is contained in:
brios
2026-04-22 17:26:57 -04:00
committed by Zach Yale
parent a3add5ded9
commit 61b9b53a60
47 changed files with 4458 additions and 874 deletions
@@ -0,0 +1,50 @@
import {Injectable, OnDestroy} from '@angular/core';
@Injectable({providedIn: 'root'})
export class WakeLockService implements OnDestroy {
private wakeLock: WakeLockSentinel | null = null;
private enabled = false;
async enable(): Promise<void> {
if (this.enabled) return;
this.enabled = true;
document.addEventListener('visibilitychange', this.onVisibilityChange);
await this.requestWakeLock();
}
async disable(): Promise<void> {
this.enabled = false;
document.removeEventListener('visibilitychange', this.onVisibilityChange);
await this.releaseWakeLock();
}
ngOnDestroy(): void {
this.disable();
}
private async requestWakeLock(): Promise<void> {
if (!('wakeLock' in navigator)) return;
try {
this.wakeLock = await navigator.wakeLock.request('screen');
this.wakeLock.addEventListener('release', () => {
this.wakeLock = null;
});
} catch {
// Wake lock request failed (e.g., page not visible)
}
}
private async releaseWakeLock(): Promise<void> {
if (this.wakeLock) {
await this.wakeLock.release();
this.wakeLock = null;
}
}
private onVisibilityChange = async (): Promise<void> => {
if (this.enabled && document.visibilityState === 'visible') {
await this.requestWakeLock();
}
};
}