@ashetm/ng-wake-lock 0.0.0-stage → 20.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DAWOUD Haitham
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,160 @@
1
- # Temporary Holding Version
1
+ # @ashetm/ng-wake-lock
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm version](https://img.shields.io/npm/v/@ashetm/ng-wake-lock.svg)](https://www.npmjs.com/package/@ashetm/ng-wake-lock)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@ashetm/ng-wake-lock.svg)](https://www.npmjs.com/package/@ashetm/ng-wake-lock)
5
+
6
+ ``@ashetm/ng-wake-lock`` keeps the screen on in Angular with the [Screen Wake Lock API](https://developer.mozilla.org/en-US/docs/Web/API/Screen_Wake_Lock_API): a service, an ``inject`` function and a directive, with signals, safe during server-side rendering.
7
+
8
+ Useful for videos, recipes, presentations, maps, video calls, games: any page the user watches without touching it.
9
+
10
+ ## Compatibility Table
11
+
12
+ | Angular Version | @ashetm/ng-wake-lock Version | Support |
13
+ |---------------------|------------------------------|---------|
14
+ | Angular 20.x and + | @ashetm/ng-wake-lock 20.x | ✅ |
15
+
16
+ The version follows the Angular version it starts from: **20.x** supports Angular 20 and above.
17
+
18
+ ## Browser support
19
+
20
+ Chrome and Edge 84+, Safari 16.4+, Firefox 126+ ([caniuse](https://caniuse.com/wake-lock)).
21
+
22
+ * The API only exists in a secure context: **HTTPS**, or ``localhost`` during development.
23
+ * The browser releases the lock when the page is hidden (other tab, minimized window, locked device): see [``reacquireOnVisible``](#providewakelock).
24
+ * A request can fail (battery saver, permission policy, page hidden): the error is in the ``error`` signal, nothing is thrown.
25
+
26
+ Where the API is missing, ``isSupported()`` is ``false`` and requests do nothing.
27
+
28
+ ## Install
29
+
30
+ ```bash
31
+ npm install @ashetm/ng-wake-lock
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ ### The directive
37
+
38
+ ```ts
39
+ import { Component, signal } from '@angular/core';
40
+ import { WakeLockDirective } from '@ashetm/ng-wake-lock';
41
+
42
+ @Component({
43
+ selector: 'app-player',
44
+ imports: [WakeLockDirective],
45
+ template: `
46
+ <!-- the screen stays on while this element is displayed -->
47
+ <video ashetmWakeLock src="movie.mp4"></video>
48
+
49
+ <!-- only while it plays -->
50
+ <video [ashetmWakeLock]="playing()" (play)="playing.set(true)" (pause)="playing.set(false)"></video>
51
+ `
52
+ })
53
+ export class PlayerComponent {
54
+ readonly playing = signal(false);
55
+ }
56
+ ```
57
+
58
+ The lock is released when the input becomes ``false`` or the element is destroyed.
59
+
60
+ ### The signals
61
+
62
+ ```ts
63
+ import { Component } from '@angular/core';
64
+ import { injectWakeLock } from '@ashetm/ng-wake-lock';
65
+
66
+ @Component({
67
+ selector: 'app-recipe',
68
+ template: `
69
+ @if (wakeLock.isSupported()) {
70
+ <button (click)="toggle()">{{ wakeLock.isLocked() ? 'Let the screen sleep' : 'Keep the screen on' }}</button>
71
+ }
72
+ @if (wakeLock.error(); as error) { <p>{{ error.message }}</p> }
73
+ `
74
+ })
75
+ export class RecipeComponent {
76
+
77
+ readonly wakeLock = injectWakeLock();
78
+
79
+ toggle(): void {
80
+ void (this.wakeLock.isLocked() ? this.wakeLock.release() : this.wakeLock.request());
81
+ }
82
+
83
+ }
84
+ ```
85
+
86
+ The request of ``injectWakeLock()`` is released automatically when the component is destroyed.
87
+
88
+ ## API
89
+
90
+ ### provideWakeLock
91
+
92
+ ```ts
93
+ provideWakeLock(config?: WakeLockConfig): EnvironmentProviders
94
+
95
+ interface WakeLockConfig {
96
+ reacquireOnVisible?: boolean; // default true
97
+ }
98
+ ```
99
+
100
+ Optional: without it, the defaults apply.
101
+
102
+ * ``reacquireOnVisible``: request the lock again when the page becomes visible again, if it's still requested (the browser releases it when the page is hidden).
103
+
104
+ ```ts
105
+ bootstrapApplication(AppComponent, {
106
+ providers: [provideWakeLock({ reacquireOnVisible: false })]
107
+ });
108
+ ```
109
+
110
+ ### WakeLockService
111
+
112
+ One lock for the whole application, shared by every caller.
113
+
114
+ | Member | Type | Description |
115
+ |-----------------|-------------------------------|------------------------------------------------------------------------|
116
+ | ``isSupported`` | ``Signal<boolean>`` | whether the browser has the API (``false`` during server-side rendering) |
117
+ | ``isLocked`` | ``Signal<boolean>`` | whether the screen is kept on |
118
+ | ``status`` | ``Signal<WakeLockStatus>`` | ``'unsupported'``, ``'released'``, ``'pending'`` or ``'locked'`` |
119
+ | ``error`` | ``Signal<Error \| null>`` | the error of the last failed request, ``null`` after a successful one |
120
+ | ``request()`` | ``Promise<boolean>`` | asks to keep the screen on; resolves whether it is; never throws |
121
+ | ``release()`` | ``Promise<void>`` | releases one ``request()`` |
122
+
123
+ Requests are counted: each ``request()`` must be matched by a ``release()``, and the lock is released when none is left. A failed request still counts, so that the lock is tried again when the page becomes visible.
124
+
125
+ Prefer ``injectWakeLock()`` or the directive: they count each caller once and release it when it's destroyed.
126
+
127
+ ### injectWakeLock
128
+
129
+ ```ts
130
+ injectWakeLock(options?: { injector?: Injector }): WakeLockRef
131
+ ```
132
+
133
+ The same signals, ``request()`` and ``release()`` as ``WakeLockService``, for one caller:
134
+
135
+ * calling ``request()`` again before ``release()`` counts once
136
+ * its request is released when the caller (component, directive, service) or the given ``injector`` is destroyed
137
+
138
+ Must be called in an injection context, unless an ``injector`` is given.
139
+
140
+ ### WakeLockDirective
141
+
142
+ ```html
143
+ <div ashetmWakeLock></div>
144
+ <div [ashetmWakeLock]="condition"></div>
145
+ <div ashetmWakeLock #lock="ashetmWakeLock">{{ lock.wakeLock.isLocked() }}</div>
146
+ ```
147
+
148
+ | Input | Type | Default | Description |
149
+ |--------------------|-------------|----------|---------------------------------------------|
150
+ | ``ashetmWakeLock`` | ``boolean`` | ``true`` | ``true`` keeps the screen on, ``false`` releases it |
151
+
152
+ Exported as ``ashetmWakeLock``, with its ``wakeLock: WakeLockRef``.
153
+
154
+ ## Server-side rendering
155
+
156
+ Nothing runs on the server: ``isSupported()`` is ``false``, ``status()`` is ``'unsupported'`` and ``request()`` resolves ``false``. The lock is requested once the page runs in the browser.
157
+
158
+ ## Issue
159
+
160
+ LOOKING FOR MAINTAINER OR IF THERE IS AN ISSUE OR ANY IDEA TO ADD. PLEASE CREATE ISSUE IN GITHUB REPOSITORY.
@@ -0,0 +1,238 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, inject, DOCUMENT, signal, computed, DestroyRef, Injectable, assertInInjectionContext, Injector, input, booleanAttribute, effect, Directive, makeEnvironmentProviders } from '@angular/core';
3
+ import { isBrowser } from '@ashetm/platform';
4
+
5
+ /**
6
+ * The browser's `navigator.wakeLock`, or `null` when it's missing (old browser, insecure context, server-side rendering).
7
+ * Internal: replaced by a fake in the specs.
8
+ */
9
+ const WAKE_LOCK_API = new InjectionToken('WAKE_LOCK_API', {
10
+ providedIn: 'root',
11
+ factory: () => isBrowser() && 'wakeLock' in navigator ? navigator.wakeLock : null
12
+ });
13
+
14
+ /**
15
+ * The config given to `provideWakeLock()`, with its defaults
16
+ */
17
+ const WAKE_LOCK_CONFIG = new InjectionToken('WAKE_LOCK_CONFIG', {
18
+ providedIn: 'root',
19
+ factory: () => ({ reacquireOnVisible: true })
20
+ });
21
+
22
+ /**
23
+ * Keeps the screen on with the Screen Wake Lock API.
24
+ *
25
+ * One lock for the whole application: each `request()` must be matched by a `release()`,
26
+ * and the screen can turn off again once every request is released.
27
+ * Does nothing during server-side rendering.
28
+ */
29
+ class WakeLockService {
30
+ #api;
31
+ #config;
32
+ #document;
33
+ #status;
34
+ #error;
35
+ #requests;
36
+ #sentinel;
37
+ #pending;
38
+ constructor() {
39
+ this.#api = inject(WAKE_LOCK_API);
40
+ this.#config = inject(WAKE_LOCK_CONFIG);
41
+ this.#document = inject(DOCUMENT);
42
+ this.#status = signal(this.#api ? 'released' : 'unsupported', ...(ngDevMode ? [{ debugName: "#status" }] : []));
43
+ this.#error = signal(null, ...(ngDevMode ? [{ debugName: "#error" }] : []));
44
+ this.#requests = 0;
45
+ this.#sentinel = null;
46
+ this.#pending = null;
47
+ /**
48
+ * The state of the lock
49
+ */
50
+ this.status = this.#status.asReadonly();
51
+ /**
52
+ * Whether the browser has the Screen Wake Lock API (`false` during server-side rendering)
53
+ */
54
+ this.isSupported = computed(() => this.#status() !== 'unsupported', ...(ngDevMode ? [{ debugName: "isSupported" }] : []));
55
+ /**
56
+ * Whether the screen is kept on
57
+ */
58
+ this.isLocked = computed(() => this.#status() === 'locked', ...(ngDevMode ? [{ debugName: "isLocked" }] : []));
59
+ /**
60
+ * The error of the last failed request, `null` after a successful one
61
+ */
62
+ this.error = this.#error.asReadonly();
63
+ if (!this.#api) {
64
+ return;
65
+ }
66
+ const onVisibilityChange = () => {
67
+ if (this.#document.visibilityState === 'visible' && this.#requests > 0 && this.#config.reacquireOnVisible) {
68
+ void this.#acquire();
69
+ }
70
+ };
71
+ this.#document.addEventListener('visibilitychange', onVisibilityChange);
72
+ inject(DestroyRef).onDestroy(() => {
73
+ this.#document.removeEventListener('visibilitychange', onVisibilityChange);
74
+ this.#requests = 0;
75
+ void this.#releaseSentinel();
76
+ });
77
+ }
78
+ /**
79
+ * Asks to keep the screen on. Never throws: a failure (page hidden, battery saver, permission policy...) is in `error`.
80
+ * The request still counts after a failure: with `reacquireOnVisible`, the lock is tried again when the page becomes visible.
81
+ *
82
+ * @returns whether the screen is now kept on
83
+ */
84
+ request() {
85
+ if (!this.#api) {
86
+ return Promise.resolve(false);
87
+ }
88
+ this.#requests++;
89
+ return this.#acquire();
90
+ }
91
+ /**
92
+ * Releases one `request()`. The lock is released when no request is left.
93
+ */
94
+ async release() {
95
+ if (this.#requests === 0) {
96
+ return;
97
+ }
98
+ this.#requests--;
99
+ if (this.#requests === 0) {
100
+ await this.#releaseSentinel();
101
+ }
102
+ }
103
+ #acquire() {
104
+ if (this.#sentinel) {
105
+ return Promise.resolve(true);
106
+ }
107
+ return this.#pending ??= this.#lock().finally(() => this.#pending = null);
108
+ }
109
+ async #lock() {
110
+ this.#status.set('pending');
111
+ try {
112
+ const sentinel = await this.#api.request('screen');
113
+ if (this.#requests === 0) {
114
+ // released while the request was pending
115
+ await sentinel.release();
116
+ this.#status.set('released');
117
+ return false;
118
+ }
119
+ sentinel.addEventListener('release', () => {
120
+ if (this.#sentinel === sentinel) {
121
+ // released by the browser (page hidden...)
122
+ this.#sentinel = null;
123
+ this.#status.set('released');
124
+ }
125
+ }, { once: true });
126
+ this.#sentinel = sentinel;
127
+ this.#error.set(null);
128
+ this.#status.set('locked');
129
+ return true;
130
+ }
131
+ catch (error) {
132
+ this.#error.set(error instanceof Error ? error : new Error(String(error)));
133
+ this.#status.set('released');
134
+ return false;
135
+ }
136
+ }
137
+ async #releaseSentinel() {
138
+ const sentinel = this.#sentinel;
139
+ this.#sentinel = null;
140
+ if (this.#status() !== 'unsupported' && this.#status() !== 'pending') {
141
+ this.#status.set('released');
142
+ }
143
+ await sentinel?.release();
144
+ }
145
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.34", ngImport: i0, type: WakeLockService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
146
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.34", ngImport: i0, type: WakeLockService, providedIn: 'root' }); }
147
+ }
148
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.34", ngImport: i0, type: WakeLockService, decorators: [{
149
+ type: Injectable,
150
+ args: [{ providedIn: 'root' }]
151
+ }], ctorParameters: () => [] });
152
+
153
+ /**
154
+ * The wake lock of `WakeLockService`, for one caller: its request is counted once,
155
+ * and released automatically when the caller (or the given injector) is destroyed.
156
+ *
157
+ * Must be called in an injection context, unless an `injector` is given.
158
+ */
159
+ function injectWakeLock(options) {
160
+ if (!options?.injector) {
161
+ assertInInjectionContext(injectWakeLock);
162
+ }
163
+ const injector = options?.injector ?? inject(Injector);
164
+ const service = injector.get(WakeLockService);
165
+ let requested = false;
166
+ const release = async () => {
167
+ if (requested) {
168
+ requested = false;
169
+ await service.release();
170
+ }
171
+ };
172
+ injector.get(DestroyRef).onDestroy(() => void release());
173
+ return {
174
+ isSupported: service.isSupported,
175
+ isLocked: service.isLocked,
176
+ status: service.status,
177
+ error: service.error,
178
+ request: () => {
179
+ if (requested) {
180
+ return Promise.resolve(service.isLocked());
181
+ }
182
+ requested = true;
183
+ return service.request();
184
+ },
185
+ release
186
+ };
187
+ }
188
+
189
+ /**
190
+ * Keeps the screen on while the element is displayed and the input is `true` (default).
191
+ *
192
+ * ```html
193
+ * <video ashetmWakeLock></video>
194
+ * <section [ashetmWakeLock]="isPlaying()"></section>
195
+ * ```
196
+ */
197
+ class WakeLockDirective {
198
+ constructor() {
199
+ /**
200
+ * `true` keeps the screen on, `false` releases it
201
+ */
202
+ this.ashetmWakeLock = input(true, ...(ngDevMode ? [{ debugName: "ashetmWakeLock", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
203
+ /**
204
+ * The wake lock of this element, released when the element is destroyed
205
+ */
206
+ this.wakeLock = injectWakeLock();
207
+ effect(() => void (this.ashetmWakeLock() ? this.wakeLock.request() : this.wakeLock.release()));
208
+ }
209
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.34", ngImport: i0, type: WakeLockDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
210
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.34", type: WakeLockDirective, isStandalone: true, selector: "[ashetmWakeLock]", inputs: { ashetmWakeLock: { classPropertyName: "ashetmWakeLock", publicName: "ashetmWakeLock", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["ashetmWakeLock"], ngImport: i0 }); }
211
+ }
212
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.34", ngImport: i0, type: WakeLockDirective, decorators: [{
213
+ type: Directive,
214
+ args: [{
215
+ selector: '[ashetmWakeLock]',
216
+ exportAs: 'ashetmWakeLock'
217
+ }]
218
+ }], ctorParameters: () => [], propDecorators: { ashetmWakeLock: [{ type: i0.Input, args: [{ isSignal: true, alias: "ashetmWakeLock", required: false }] }] } });
219
+
220
+ /**
221
+ * Configures the wake lock. Optional: without it, the defaults apply.
222
+ */
223
+ function provideWakeLock(config = {}) {
224
+ return makeEnvironmentProviders([
225
+ { provide: WAKE_LOCK_CONFIG, useValue: { reacquireOnVisible: true, ...config } }
226
+ ]);
227
+ }
228
+
229
+ /*
230
+ * Public API Surface of wake-lock
231
+ */
232
+
233
+ /**
234
+ * Generated bundle index. Do not edit.
235
+ */
236
+
237
+ export { WAKE_LOCK_CONFIG, WakeLockDirective, WakeLockService, injectWakeLock, provideWakeLock };
238
+ //# sourceMappingURL=ashetm-ng-wake-lock.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ashetm-ng-wake-lock.mjs","sources":["../../../projects/wake-lock/src/lib/wake-lock.api.ts","../../../projects/wake-lock/src/lib/wake-lock.token.ts","../../../projects/wake-lock/src/lib/wake-lock.service.ts","../../../projects/wake-lock/src/lib/wake-lock.inject.ts","../../../projects/wake-lock/src/lib/wake-lock.directive.ts","../../../projects/wake-lock/src/lib/wake-lock.provider.ts","../../../projects/wake-lock/src/public-api.ts","../../../projects/wake-lock/src/ashetm-ng-wake-lock.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport { isBrowser } from '@ashetm/platform';\nimport { Nullable } from '@ashetm/types';\n\n\n/**\n * The browser's `navigator.wakeLock`, or `null` when it's missing (old browser, insecure context, server-side rendering).\n * Internal: replaced by a fake in the specs.\n */\nexport const WAKE_LOCK_API: InjectionToken<Nullable<WakeLock>> = new InjectionToken<Nullable<WakeLock>>('WAKE_LOCK_API', {\n providedIn: 'root',\n factory: () => isBrowser() && 'wakeLock' in navigator ? navigator.wakeLock : null\n});\n","import { InjectionToken } from '@angular/core';\n\nimport { WakeLockConfig } from './wake-lock.type';\n\n\n/**\n * The config given to `provideWakeLock()`, with its defaults\n */\nexport const WAKE_LOCK_CONFIG: InjectionToken<Required<WakeLockConfig>> = new InjectionToken<Required<WakeLockConfig>>('WAKE_LOCK_CONFIG', {\n providedIn: 'root',\n factory: () => ({ reacquireOnVisible: true })\n});\n","import { computed, DestroyRef, DOCUMENT, inject, Injectable, Signal, signal, WritableSignal } from '@angular/core';\nimport { Nullable } from '@ashetm/types';\n\nimport { WAKE_LOCK_API } from './wake-lock.api';\nimport { WAKE_LOCK_CONFIG } from './wake-lock.token';\nimport { WakeLockStatus } from './wake-lock.type';\n\n\n/**\n * Keeps the screen on with the Screen Wake Lock API.\n *\n * One lock for the whole application: each `request()` must be matched by a `release()`,\n * and the screen can turn off again once every request is released.\n * Does nothing during server-side rendering.\n */\n@Injectable({ providedIn: 'root' })\nexport class WakeLockService {\n\n readonly #api: Nullable<WakeLock> = inject(WAKE_LOCK_API);\n readonly #config = inject(WAKE_LOCK_CONFIG);\n readonly #document: Document = inject(DOCUMENT);\n\n readonly #status: WritableSignal<WakeLockStatus> = signal<WakeLockStatus>(this.#api ? 'released' : 'unsupported');\n readonly #error: WritableSignal<Nullable<Error>> = signal<Nullable<Error>>(null);\n\n #requests: number = 0;\n #sentinel: Nullable<WakeLockSentinel> = null;\n #pending: Nullable<Promise<boolean>> = null;\n\n /**\n * The state of the lock\n */\n readonly status: Signal<WakeLockStatus> = this.#status.asReadonly();\n\n /**\n * Whether the browser has the Screen Wake Lock API (`false` during server-side rendering)\n */\n readonly isSupported: Signal<boolean> = computed(() => this.#status() !== 'unsupported');\n\n /**\n * Whether the screen is kept on\n */\n readonly isLocked: Signal<boolean> = computed(() => this.#status() === 'locked');\n\n /**\n * The error of the last failed request, `null` after a successful one\n */\n readonly error: Signal<Nullable<Error>> = this.#error.asReadonly();\n\n constructor() {\n if (!this.#api) {\n return;\n }\n\n const onVisibilityChange: () => void = () => {\n if (this.#document.visibilityState === 'visible' && this.#requests > 0 && this.#config.reacquireOnVisible) {\n void this.#acquire();\n }\n };\n\n this.#document.addEventListener('visibilitychange', onVisibilityChange);\n\n inject(DestroyRef).onDestroy(() => {\n this.#document.removeEventListener('visibilitychange', onVisibilityChange);\n this.#requests = 0;\n void this.#releaseSentinel();\n });\n }\n\n /**\n * Asks to keep the screen on. Never throws: a failure (page hidden, battery saver, permission policy...) is in `error`.\n * The request still counts after a failure: with `reacquireOnVisible`, the lock is tried again when the page becomes visible.\n *\n * @returns whether the screen is now kept on\n */\n request(): Promise<boolean> {\n if (!this.#api) {\n return Promise.resolve(false);\n }\n\n this.#requests++;\n\n return this.#acquire();\n }\n\n /**\n * Releases one `request()`. The lock is released when no request is left.\n */\n async release(): Promise<void> {\n if (this.#requests === 0) {\n return;\n }\n\n this.#requests--;\n\n if (this.#requests === 0) {\n await this.#releaseSentinel();\n }\n }\n\n #acquire(): Promise<boolean> {\n if (this.#sentinel) {\n return Promise.resolve(true);\n }\n\n return this.#pending ??= this.#lock().finally(() => this.#pending = null);\n }\n\n async #lock(): Promise<boolean> {\n this.#status.set('pending');\n\n try {\n const sentinel: WakeLockSentinel = await this.#api!.request('screen');\n\n if (this.#requests === 0) {\n // released while the request was pending\n await sentinel.release();\n this.#status.set('released');\n\n return false;\n }\n\n sentinel.addEventListener('release', () => {\n if (this.#sentinel === sentinel) {\n // released by the browser (page hidden...)\n this.#sentinel = null;\n this.#status.set('released');\n }\n }, { once: true });\n this.#sentinel = sentinel;\n this.#error.set(null);\n this.#status.set('locked');\n\n return true;\n } catch (error: unknown) {\n this.#error.set(error instanceof Error ? error : new Error(String(error)));\n this.#status.set('released');\n\n return false;\n }\n }\n\n async #releaseSentinel(): Promise<void> {\n const sentinel: Nullable<WakeLockSentinel> = this.#sentinel;\n\n this.#sentinel = null;\n\n if (this.#status() !== 'unsupported' && this.#status() !== 'pending') {\n this.#status.set('released');\n }\n\n await sentinel?.release();\n }\n\n}\n","import { assertInInjectionContext, DestroyRef, inject, Injector, Signal } from '@angular/core';\nimport { Nullable } from '@ashetm/types';\n\nimport { WakeLockService } from './wake-lock.service';\nimport { WakeLockStatus } from './wake-lock.type';\n\n\n/**\n * The wake lock for one caller (component, directive, service): see `injectWakeLock()`\n */\nexport interface WakeLockRef {\n readonly isSupported: Signal<boolean>;\n readonly isLocked: Signal<boolean>;\n readonly status: Signal<WakeLockStatus>;\n readonly error: Signal<Nullable<Error>>;\n /**\n * Asks to keep the screen on; calling it again before `release()` counts once\n */\n request(): Promise<boolean>;\n /**\n * Releases this caller's request\n */\n release(): Promise<void>;\n}\n\n/**\n * The wake lock of `WakeLockService`, for one caller: its request is counted once,\n * and released automatically when the caller (or the given injector) is destroyed.\n *\n * Must be called in an injection context, unless an `injector` is given.\n */\nexport function injectWakeLock(options?: { injector?: Injector }): WakeLockRef {\n if (!options?.injector) {\n assertInInjectionContext(injectWakeLock);\n }\n\n const injector: Injector = options?.injector ?? inject(Injector);\n const service: WakeLockService = injector.get(WakeLockService);\n let requested: boolean = false;\n\n const release: () => Promise<void> = async () => {\n if (requested) {\n requested = false;\n await service.release();\n }\n };\n\n injector.get(DestroyRef).onDestroy(() => void release());\n\n return {\n isSupported: service.isSupported,\n isLocked: service.isLocked,\n status: service.status,\n error: service.error,\n request: () => {\n if (requested) {\n return Promise.resolve(service.isLocked());\n }\n requested = true;\n\n return service.request();\n },\n release\n };\n}\n","import { booleanAttribute, Directive, effect, input, InputSignalWithTransform } from '@angular/core';\n\nimport { injectWakeLock, WakeLockRef } from './wake-lock.inject';\n\n\n/**\n * Keeps the screen on while the element is displayed and the input is `true` (default).\n *\n * ```html\n * <video ashetmWakeLock></video>\n * <section [ashetmWakeLock]=\"isPlaying()\"></section>\n * ```\n */\n@Directive({\n selector: '[ashetmWakeLock]',\n exportAs: 'ashetmWakeLock'\n})\nexport class WakeLockDirective {\n\n /**\n * `true` keeps the screen on, `false` releases it\n */\n readonly ashetmWakeLock: InputSignalWithTransform<boolean, unknown> = input<boolean, unknown>(true, { transform: booleanAttribute });\n\n /**\n * The wake lock of this element, released when the element is destroyed\n */\n readonly wakeLock: WakeLockRef = injectWakeLock();\n\n constructor() {\n effect(() => void (this.ashetmWakeLock() ? this.wakeLock.request() : this.wakeLock.release()));\n }\n\n}\n","import { EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';\n\nimport { WAKE_LOCK_CONFIG } from './wake-lock.token';\nimport { WakeLockConfig } from './wake-lock.type';\n\n\n/**\n * Configures the wake lock. Optional: without it, the defaults apply.\n */\nexport function provideWakeLock(config: WakeLockConfig = {}): EnvironmentProviders {\n return makeEnvironmentProviders([\n { provide: WAKE_LOCK_CONFIG, useValue: { reacquireOnVisible: true, ...config } }\n ]);\n}\n","/*\n * Public API Surface of wake-lock\n */\n\nexport * from './lib/wake-lock.directive';\nexport * from './lib/wake-lock.inject';\nexport * from './lib/wake-lock.provider';\nexport * from './lib/wake-lock.service';\nexport * from './lib/wake-lock.token';\nexport * from './lib/wake-lock.type';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAKA;;;AAGG;AACI,MAAM,aAAa,GAAuC,IAAI,cAAc,CAAqB,eAAe,EAAE;AACvH,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,MAAM,SAAS,EAAE,IAAI,UAAU,IAAI,SAAS,GAAG,SAAS,CAAC,QAAQ,GAAG;AAC9E,CAAA,CAAC;;ACPF;;AAEG;MACU,gBAAgB,GAA6C,IAAI,cAAc,CAA2B,kBAAkB,EAAE;AACzI,IAAA,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE;AAC7C,CAAA;;ACHD;;;;;;AAMG;MAEU,eAAe,CAAA;AAEjB,IAAA,IAAI;AACJ,IAAA,OAAO;AACP,IAAA,SAAS;AAET,IAAA,OAAO;AACP,IAAA,MAAM;AAEf,IAAA,SAAS;AACT,IAAA,SAAS;AACT,IAAA,QAAQ;AAsBR,IAAA,WAAA,GAAA;AA/BS,QAAA,IAAA,CAAA,IAAI,GAAuB,MAAM,CAAC,aAAa,CAAC;AAChD,QAAA,IAAA,CAAA,OAAO,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAClC,QAAA,IAAA,CAAA,SAAS,GAAa,MAAM,CAAC,QAAQ,CAAC;AAEtC,QAAA,IAAA,CAAA,OAAO,GAAmC,MAAM,CAAiB,IAAI,CAAC,IAAI,GAAG,UAAU,GAAG,aAAa,mDAAC;AACxG,QAAA,IAAA,CAAA,MAAM,GAAoC,MAAM,CAAkB,IAAI,kDAAC;QAEhF,IAAA,CAAA,SAAS,GAAW,CAAC;QACrB,IAAA,CAAA,SAAS,GAA+B,IAAI;QAC5C,IAAA,CAAA,QAAQ,GAA+B,IAAI;AAE3C;;AAEG;AACM,QAAA,I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OAAO,EAAE,CAAC,CAAC;IAChG;+GAdW,iBAAiB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;mGAAjB,iBAAiB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,kBAAA,EAAA,MAAA,EAAA,EAAA,cAAA,EAAA,EAAA,iBAAA,EAAA,gBAAA,EAAA,UAAA,EAAA,gBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,QAAA,EAAA,CAAA,gBAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;4FAAjB,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAJ7B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,kBAAkB;AAC5B,oBAAA,QAAQ,EAAE;AACX,iBAAA;;;ACVD;;AAEG;AACG,SAAU,eAAe,CAAC,MAAA,GAAyB,EAAE,EAAA;AACzD,IAAA,OAAO,wBAAwB,CAAC;AAC9B,QAAA,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE;AAC/E,KAAA,CAAC;AACJ;;ACbA;;AAEG;;ACFH;;AAEG;;"}
package/index.d.ts ADDED
@@ -0,0 +1,124 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Signal, Injector, InputSignalWithTransform, EnvironmentProviders, InjectionToken } from '@angular/core';
3
+ import { Nullable } from '@ashetm/types';
4
+
5
+ /**
6
+ * Options of `provideWakeLock()`
7
+ */
8
+ interface WakeLockConfig {
9
+ /**
10
+ * Request the lock again when the page becomes visible again, if it's still requested
11
+ * (the browser releases it when the page is hidden). Default `true`.
12
+ */
13
+ reacquireOnVisible?: boolean;
14
+ }
15
+ /**
16
+ * - `unsupported`: no Screen Wake Lock API (old browser, insecure context, server-side rendering)
17
+ * - `released`: no lock held
18
+ * - `pending`: a lock request is in progress
19
+ * - `locked`: the screen stays on
20
+ */
21
+ type WakeLockStatus = 'unsupported' | 'released' | 'pending' | 'locked';
22
+
23
+ /**
24
+ * The wake lock for one caller (component, directive, service): see `injectWakeLock()`
25
+ */
26
+ interface WakeLockRef {
27
+ readonly isSupported: Signal<boolean>;
28
+ readonly isLocked: Signal<boolean>;
29
+ readonly status: Signal<WakeLockStatus>;
30
+ readonly error: Signal<Nullable<Error>>;
31
+ /**
32
+ * Asks to keep the screen on; calling it again before `release()` counts once
33
+ */
34
+ request(): Promise<boolean>;
35
+ /**
36
+ * Releases this caller's request
37
+ */
38
+ release(): Promise<void>;
39
+ }
40
+ /**
41
+ * The wake lock of `WakeLockService`, for one caller: its request is counted once,
42
+ * and released automatically when the caller (or the given injector) is destroyed.
43
+ *
44
+ * Must be called in an injection context, unless an `injector` is given.
45
+ */
46
+ declare function injectWakeLock(options?: {
47
+ injector?: Injector;
48
+ }): WakeLockRef;
49
+
50
+ /**
51
+ * Keeps the screen on while the element is displayed and the input is `true` (default).
52
+ *
53
+ * ```html
54
+ * <video ashetmWakeLock></video>
55
+ * <section [ashetmWakeLock]="isPlaying()"></section>
56
+ * ```
57
+ */
58
+ declare class WakeLockDirective {
59
+ /**
60
+ * `true` keeps the screen on, `false` releases it
61
+ */
62
+ readonly ashetmWakeLock: InputSignalWithTransform<boolean, unknown>;
63
+ /**
64
+ * The wake lock of this element, released when the element is destroyed
65
+ */
66
+ readonly wakeLock: WakeLockRef;
67
+ constructor();
68
+ static ɵfac: i0.ɵɵFactoryDeclaration<WakeLockDirective, never>;
69
+ static ɵdir: i0.ɵɵDirectiveDeclaration<WakeLockDirective, "[ashetmWakeLock]", ["ashetmWakeLock"], { "ashetmWakeLock": { "alias": "ashetmWakeLock"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
70
+ }
71
+
72
+ /**
73
+ * Configures the wake lock. Optional: without it, the defaults apply.
74
+ */
75
+ declare function provideWakeLock(config?: WakeLockConfig): EnvironmentProviders;
76
+
77
+ /**
78
+ * Keeps the screen on with the Screen Wake Lock API.
79
+ *
80
+ * One lock for the whole application: each `request()` must be matched by a `release()`,
81
+ * and the screen can turn off again once every request is released.
82
+ * Does nothing during server-side rendering.
83
+ */
84
+ declare class WakeLockService {
85
+ #private;
86
+ /**
87
+ * The state of the lock
88
+ */
89
+ readonly status: Signal<WakeLockStatus>;
90
+ /**
91
+ * Whether the browser has the Screen Wake Lock API (`false` during server-side rendering)
92
+ */
93
+ readonly isSupported: Signal<boolean>;
94
+ /**
95
+ * Whether the screen is kept on
96
+ */
97
+ readonly isLocked: Signal<boolean>;
98
+ /**
99
+ * The error of the last failed request, `null` after a successful one
100
+ */
101
+ readonly error: Signal<Nullable<Error>>;
102
+ constructor();
103
+ /**
104
+ * Asks to keep the screen on. Never throws: a failure (page hidden, battery saver, permission policy...) is in `error`.
105
+ * The request still counts after a failure: with `reacquireOnVisible`, the lock is tried again when the page becomes visible.
106
+ *
107
+ * @returns whether the screen is now kept on
108
+ */
109
+ request(): Promise<boolean>;
110
+ /**
111
+ * Releases one `request()`. The lock is released when no request is left.
112
+ */
113
+ release(): Promise<void>;
114
+ static ɵfac: i0.ɵɵFactoryDeclaration<WakeLockService, never>;
115
+ static ɵprov: i0.ɵɵInjectableDeclaration<WakeLockService>;
116
+ }
117
+
118
+ /**
119
+ * The config given to `provideWakeLock()`, with its defaults
120
+ */
121
+ declare const WAKE_LOCK_CONFIG: InjectionToken<Required<WakeLockConfig>>;
122
+
123
+ export { WAKE_LOCK_CONFIG, WakeLockDirective, WakeLockService, injectWakeLock, provideWakeLock };
124
+ export type { WakeLockConfig, WakeLockRef, WakeLockStatus };
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "@ashetm/ng-wake-lock",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "20.0.0",
4
+ "description": "Signals, a service and a directive to keep the screen on with the Screen Wake Lock API in Angular.",
5
+ "contributors": [
6
+ {
7
+ "email": "contact@ashetm.com",
8
+ "name": "DAWOUD Haitham",
9
+ "url": "http://ashetm.com"
10
+ }
11
+ ],
12
+ "author": {
13
+ "email": "contact@ashetm.com",
14
+ "name": "DAWOUD Haitham",
15
+ "url": "http://ashetm.com"
16
+ },
17
+ "license": "MIT",
18
+ "keywords": [
19
+ "angular",
20
+ "directive",
21
+ "ng",
22
+ "ng-service",
23
+ "ng-services",
24
+ "ng-wake-lock",
25
+ "screen",
26
+ "screen-wake-lock",
27
+ "signal",
28
+ "signals",
29
+ "ssr",
30
+ "ts",
31
+ "wake-lock",
32
+ "wakelock"
33
+ ],
34
+ "private": false,
35
+ "repository": {
36
+ "url": "https://github.com/AsheTM/ng-services/tree/main/projects/wake-lock"
37
+ },
38
+ "peerDependencies": {
39
+ "@angular/common": ">=20.0.0",
40
+ "@angular/core": ">=20.0.0"
41
+ },
42
+ "dependencies": {
43
+ "@ashetm/platform": "^1.0.1",
44
+ "@ashetm/types": "^1.3.1",
45
+ "tslib": "^2.3.0"
46
+ },
47
+ "sideEffects": false,
48
+ "module": "fesm2022/ashetm-ng-wake-lock.mjs",
49
+ "typings": "index.d.ts",
50
+ "exports": {
51
+ "./package.json": {
52
+ "default": "./package.json"
53
+ },
54
+ ".": {
55
+ "types": "./index.d.ts",
56
+ "default": "./fesm2022/ashetm-ng-wake-lock.mjs"
57
+ }
58
+ }
6
59
  }