@angular-helpers/browser-web-apis 21.7.0 → 21.9.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.
@@ -3,145 +3,6 @@ import * as i0 from '@angular/core';
3
3
  import { DestroyRef, ElementRef, Signal, InjectionToken, EnvironmentProviders } from '@angular/core';
4
4
  import { CanActivateFn } from '@angular/router';
5
5
 
6
- /**
7
- * Base class for all Browser Web API services.
8
- * Provides common functionality for:
9
- * - Platform detection (browser vs server)
10
- * - Support assertion via Template Method
11
- * - Error creation with cause chaining
12
- * - Structured logging via injectable BROWSER_API_LOGGER token
13
- * - Lifecycle management with destroyRef
14
- *
15
- * Services that also need permission querying should extend
16
- * `PermissionAwareBrowserApiBaseService` instead.
17
- */
18
- declare abstract class BrowserApiBaseService {
19
- protected destroyRef: DestroyRef;
20
- protected platformId: Object;
21
- private readonly logger;
22
- /**
23
- * Abstract method that must be implemented by child services.
24
- * Returns the API name used in log messages and error strings.
25
- */
26
- protected abstract getApiName(): string;
27
- /**
28
- * Check if running in browser environment using Angular's platform detection.
29
- */
30
- protected isBrowserEnvironment(): boolean;
31
- /**
32
- * Check if running in server environment using Angular's platform detection.
33
- */
34
- protected isServerEnvironment(): boolean;
35
- /**
36
- * Template Method: asserts the service can run in the current environment.
37
- * Subclasses must call super.ensureSupported() and then add their own API check.
38
- */
39
- protected ensureSupported(): void;
40
- /**
41
- * Create an error with proper cause chaining.
42
- */
43
- protected createError(message: string, cause?: unknown): Error;
44
- /**
45
- * Log an error through the injected BROWSER_API_LOGGER (default: console).
46
- */
47
- protected logError(message: string, error?: unknown): void;
48
- /**
49
- * Log a warning through the injected BROWSER_API_LOGGER (default: console).
50
- */
51
- protected logWarn(message: string): void;
52
- /**
53
- * Log an informational message through the injected BROWSER_API_LOGGER (default: console).
54
- */
55
- protected logInfo(message: string): void;
56
- static ɵfac: i0.ɵɵFactoryDeclaration<BrowserApiBaseService, never>;
57
- static ɵprov: i0.ɵɵInjectableDeclaration<BrowserApiBaseService>;
58
- }
59
-
60
- type PermissionNameExt = PermissionName | 'clipboard-read' | 'clipboard-write';
61
- interface PermissionRequest {
62
- name: PermissionNameExt;
63
- state: PermissionState;
64
- }
65
- interface BrowserPermissions {
66
- query(descriptor: PermissionDescriptor): Promise<PermissionStatus>;
67
- isSupported(): boolean;
68
- }
69
-
70
- declare class PermissionsService extends BrowserApiBaseService implements BrowserPermissions {
71
- protected getApiName(): string;
72
- query(descriptor: PermissionDescriptor): Promise<PermissionStatus>;
73
- isSupported(): boolean;
74
- static ɵfac: i0.ɵɵFactoryDeclaration<PermissionsService, never>;
75
- static ɵprov: i0.ɵɵInjectableDeclaration<PermissionsService>;
76
- }
77
-
78
- declare class CameraService extends BrowserApiBaseService {
79
- private currentStream;
80
- protected getApiName(): string;
81
- protected ensureSupported(): void;
82
- startCamera(constraints?: MediaStreamConstraints): Promise<MediaStream>;
83
- stopCamera(): void;
84
- switchCamera(deviceId: string, constraints?: MediaStreamConstraints): Promise<MediaStream>;
85
- getCameraCapabilities(deviceId: string): Promise<MediaTrackCapabilities | null>;
86
- getCurrentStream(): MediaStream | null;
87
- isStreaming(): boolean;
88
- getVideoInputDevices(): Promise<MediaDeviceInfo[]>;
89
- getNativeMediaDevices(): MediaDevices;
90
- static ɵfac: i0.ɵɵFactoryDeclaration<CameraService, never>;
91
- static ɵprov: i0.ɵɵInjectableDeclaration<CameraService>;
92
- }
93
-
94
- declare class GeolocationService extends BrowserApiBaseService {
95
- protected getApiName(): string;
96
- protected ensureSupported(): void;
97
- getCurrentPosition(options?: PositionOptions): Promise<GeolocationPosition>;
98
- watchPosition(options?: PositionOptions): Observable<GeolocationPosition>;
99
- clearWatch(watchId: number): void;
100
- getNativeGeolocation(): Geolocation;
101
- static ɵfac: i0.ɵɵFactoryDeclaration<GeolocationService, never>;
102
- static ɵprov: i0.ɵɵInjectableDeclaration<GeolocationService>;
103
- }
104
-
105
- interface DisplayMediaConstraints {
106
- video?: boolean | MediaTrackConstraints;
107
- audio?: boolean | MediaTrackConstraints;
108
- }
109
- declare class MediaDevicesService extends BrowserApiBaseService {
110
- protected getApiName(): string;
111
- protected ensureSupported(): void;
112
- getDevices(): Promise<MediaDeviceInfo[]>;
113
- getUserMedia(constraints?: MediaStreamConstraints): Promise<MediaStream>;
114
- getDisplayMedia(constraints?: DisplayMediaConstraints): Promise<MediaStream>;
115
- watchDeviceChanges(): Observable<MediaDeviceInfo[]>;
116
- getVideoInputDevices(): Promise<MediaDeviceInfo[]>;
117
- getAudioInputDevices(): Promise<MediaDeviceInfo[]>;
118
- getAudioOutputDevices(): Promise<MediaDeviceInfo[]>;
119
- private getDevicesByKind;
120
- private handleMediaError;
121
- getNativeMediaDevices(): MediaDevices;
122
- static ɵfac: i0.ɵɵFactoryDeclaration<MediaDevicesService, never>;
123
- static ɵprov: i0.ɵɵInjectableDeclaration<MediaDevicesService>;
124
- }
125
-
126
- declare class NotificationService extends BrowserApiBaseService {
127
- protected getApiName(): string;
128
- protected ensureSupported(): void;
129
- get permission(): NotificationPermission;
130
- requestNotificationPermission(): Promise<NotificationPermission>;
131
- showNotification(title: string, options?: NotificationOptions): Promise<Notification>;
132
- static ɵfac: i0.ɵɵFactoryDeclaration<NotificationService, never>;
133
- static ɵprov: i0.ɵɵInjectableDeclaration<NotificationService>;
134
- }
135
-
136
- declare class ClipboardService extends BrowserApiBaseService {
137
- protected getApiName(): string;
138
- protected ensureSupported(): void;
139
- writeText(text: string): Promise<void>;
140
- readText(): Promise<string>;
141
- static ɵfac: i0.ɵɵFactoryDeclaration<ClipboardService, never>;
142
- static ɵprov: i0.ɵɵInjectableDeclaration<ClipboardService>;
143
- }
144
-
145
6
  type BrowserCapabilityId = 'permissions' | 'geolocation' | 'clipboard' | 'notification' | 'mediaDevices' | 'camera' | 'webWorker' | 'regexSecurity' | 'webStorage' | 'webShare' | 'battery' | 'webSocket' | 'intersectionObserver' | 'resizeObserver' | 'pageVisibility' | 'broadcastChannel' | 'networkInformation' | 'screenWakeLock' | 'screenOrientation' | 'fullscreen' | 'fileSystemAccess' | 'mediaRecorder' | 'serverSentEvents' | 'vibration' | 'speechSynthesis' | 'mutationObserver' | 'performanceObserver' | 'idleDetector' | 'eyeDropper' | 'barcodeDetector' | 'webAudio' | 'gamepad' | 'webBluetooth' | 'webUsb' | 'webNfc' | 'paymentRequest' | 'credentialManagement';
146
7
  declare class BrowserCapabilityService {
147
8
  getCapabilities(): readonly [{
@@ -296,7 +157,7 @@ declare class BrowserCapabilityService {
296
157
  isSecureContext(): boolean;
297
158
  isSupported(capability: BrowserCapabilityId): boolean;
298
159
  getAllStatuses(): {
299
- id: "camera" | "geolocation" | "permissions" | "clipboard" | "notification" | "mediaDevices" | "webWorker" | "regexSecurity" | "webStorage" | "webShare" | "battery" | "webSocket" | "intersectionObserver" | "resizeObserver" | "pageVisibility" | "broadcastChannel" | "networkInformation" | "screenWakeLock" | "screenOrientation" | "fullscreen" | "fileSystemAccess" | "mediaRecorder" | "serverSentEvents" | "vibration" | "speechSynthesis" | "mutationObserver" | "performanceObserver" | "idleDetector" | "eyeDropper" | "barcodeDetector" | "webAudio" | "gamepad" | "webBluetooth" | "webUsb" | "webNfc" | "paymentRequest" | "credentialManagement";
160
+ id: "permissions" | "geolocation" | "clipboard" | "notification" | "mediaDevices" | "camera" | "webWorker" | "regexSecurity" | "webStorage" | "webShare" | "battery" | "webSocket" | "intersectionObserver" | "resizeObserver" | "pageVisibility" | "broadcastChannel" | "networkInformation" | "screenWakeLock" | "screenOrientation" | "fullscreen" | "fileSystemAccess" | "mediaRecorder" | "serverSentEvents" | "vibration" | "speechSynthesis" | "mutationObserver" | "performanceObserver" | "idleDetector" | "eyeDropper" | "barcodeDetector" | "webAudio" | "gamepad" | "webBluetooth" | "webUsb" | "webNfc" | "paymentRequest" | "credentialManagement";
300
161
  label: "Permissions API" | "Geolocation API" | "Clipboard API" | "Notification API" | "MediaDevices API" | "Camera API" | "Web Worker API" | "Regex Security" | "Web Storage" | "Web Share" | "Battery API" | "WebSocket API" | "Intersection Observer" | "Resize Observer" | "Page Visibility API" | "Broadcast Channel API" | "Network Information API" | "Screen Wake Lock API" | "Screen Orientation API" | "Fullscreen API" | "File System Access API" | "MediaRecorder API" | "Server-Sent Events" | "Vibration API" | "Speech Synthesis API" | "Mutation Observer" | "Performance Observer" | "Idle Detection API" | "EyeDropper API" | "Barcode Detection API" | "Web Audio API" | "Gamepad API" | "Web Bluetooth API" | "WebUSB API" | "Web NFC API" | "Payment Request API" | "Credential Management API";
301
162
  supported: boolean;
302
163
  secureContext: boolean;
@@ -307,7 +168,149 @@ declare class BrowserCapabilityService {
307
168
  static ɵprov: i0.ɵɵInjectableDeclaration<BrowserCapabilityService>;
308
169
  }
309
170
 
310
- interface BatteryInfo {
171
+ /**
172
+ * Base class for all Browser Web API services.
173
+ *
174
+ * ## Support detection contract
175
+ *
176
+ * Services follow ONE pattern (do not invent variants):
177
+ *
178
+ * - `isSupported(): boolean` — public, side-effect free, SSR-safe. Default
179
+ * implementation delegates to {@link BrowserCapabilityService} when the subclass
180
+ * overrides {@link getCapabilityId} (recommended).
181
+ * - `ensureSupported(): void` — internal Template Method. Throws when called outside
182
+ * browser or when the underlying API is missing.
183
+ *
184
+ * ## Error surfacing contract
185
+ *
186
+ * - **Imperative methods** MUST call `ensureSupported()` and throw synchronously.
187
+ * - **Stream-returning methods** MUST guard with `isSupported()` and surface
188
+ * unsupported state as `Observable.error(...)` (NOT throw inline).
189
+ *
190
+ * Services that also need permission querying should extend
191
+ * `PermissionAwareBrowserApiBaseService` instead.
192
+ */
193
+ declare abstract class BrowserApiBaseService {
194
+ protected destroyRef: DestroyRef;
195
+ protected platformId: Object;
196
+ private readonly logger;
197
+ private readonly capabilities;
198
+ /** API name used in log messages and error strings. */
199
+ protected abstract getApiName(): string;
200
+ /**
201
+ * Optional hook for subclasses to delegate feature detection to
202
+ * {@link BrowserCapabilityService}. Returning a capability id removes the need to
203
+ * implement `isSupported()` manually and avoids drift between per-service checks
204
+ * and the centralized capability registry.
205
+ */
206
+ protected getCapabilityId(): BrowserCapabilityId | null;
207
+ /** Public, SSR-safe support check. Override only if you need extra constraints. */
208
+ isSupported(): boolean;
209
+ protected isBrowserEnvironment(): boolean;
210
+ protected isServerEnvironment(): boolean;
211
+ /**
212
+ * Template Method: asserts the service can run in the current environment. Subclasses
213
+ * that need extra checks beyond capability detection MUST call `super.ensureSupported()`
214
+ * first, then add their own check.
215
+ */
216
+ protected ensureSupported(): void;
217
+ protected createError(message: string, cause?: unknown): Error;
218
+ protected logError(message: string, error?: unknown): void;
219
+ protected logWarn(message: string): void;
220
+ protected logInfo(message: string): void;
221
+ static ɵfac: i0.ɵɵFactoryDeclaration<BrowserApiBaseService, never>;
222
+ static ɵprov: i0.ɵɵInjectableDeclaration<BrowserApiBaseService>;
223
+ }
224
+
225
+ type PermissionNameExt = PermissionName | 'clipboard-read' | 'clipboard-write';
226
+ interface PermissionRequest {
227
+ name: PermissionNameExt;
228
+ state: PermissionState;
229
+ }
230
+ interface BrowserPermissions {
231
+ query(descriptor: PermissionDescriptor): Promise<PermissionStatus>;
232
+ isSupported(): boolean;
233
+ }
234
+
235
+ declare class PermissionsService extends BrowserApiBaseService implements BrowserPermissions {
236
+ protected getApiName(): string;
237
+ query(descriptor: PermissionDescriptor): Promise<PermissionStatus>;
238
+ protected getCapabilityId(): BrowserCapabilityId;
239
+ static ɵfac: i0.ɵɵFactoryDeclaration<PermissionsService, never>;
240
+ static ɵprov: i0.ɵɵInjectableDeclaration<PermissionsService>;
241
+ }
242
+
243
+ declare class CameraService extends BrowserApiBaseService {
244
+ private currentStream;
245
+ protected getApiName(): string;
246
+ protected getCapabilityId(): BrowserCapabilityId;
247
+ protected ensureSupported(): void;
248
+ startCamera(constraints?: MediaStreamConstraints): Promise<MediaStream>;
249
+ stopCamera(): void;
250
+ switchCamera(deviceId: string, constraints?: MediaStreamConstraints): Promise<MediaStream>;
251
+ getCameraCapabilities(deviceId: string): Promise<MediaTrackCapabilities | null>;
252
+ getCurrentStream(): MediaStream | null;
253
+ isStreaming(): boolean;
254
+ getVideoInputDevices(): Promise<MediaDeviceInfo[]>;
255
+ getNativeMediaDevices(): MediaDevices;
256
+ static ɵfac: i0.ɵɵFactoryDeclaration<CameraService, never>;
257
+ static ɵprov: i0.ɵɵInjectableDeclaration<CameraService>;
258
+ }
259
+
260
+ declare class GeolocationService extends BrowserApiBaseService {
261
+ protected getApiName(): string;
262
+ protected getCapabilityId(): BrowserCapabilityId;
263
+ getCurrentPosition(options?: PositionOptions): Promise<GeolocationPosition>;
264
+ watchPosition(options?: PositionOptions): Observable<GeolocationPosition>;
265
+ clearWatch(watchId: number): void;
266
+ getNativeGeolocation(): Geolocation;
267
+ static ɵfac: i0.ɵɵFactoryDeclaration<GeolocationService, never>;
268
+ static ɵprov: i0.ɵɵInjectableDeclaration<GeolocationService>;
269
+ }
270
+
271
+ interface DisplayMediaConstraints {
272
+ video?: boolean | MediaTrackConstraints;
273
+ audio?: boolean | MediaTrackConstraints;
274
+ }
275
+ declare class MediaDevicesService extends BrowserApiBaseService {
276
+ protected getApiName(): string;
277
+ protected getCapabilityId(): BrowserCapabilityId;
278
+ protected ensureSupported(): void;
279
+ getDevices(): Promise<MediaDeviceInfo[]>;
280
+ getUserMedia(constraints?: MediaStreamConstraints): Promise<MediaStream>;
281
+ getDisplayMedia(constraints?: DisplayMediaConstraints): Promise<MediaStream>;
282
+ watchDeviceChanges(): Observable<MediaDeviceInfo[]>;
283
+ getVideoInputDevices(): Promise<MediaDeviceInfo[]>;
284
+ getAudioInputDevices(): Promise<MediaDeviceInfo[]>;
285
+ getAudioOutputDevices(): Promise<MediaDeviceInfo[]>;
286
+ private getDevicesByKind;
287
+ private handleMediaError;
288
+ getNativeMediaDevices(): MediaDevices;
289
+ static ɵfac: i0.ɵɵFactoryDeclaration<MediaDevicesService, never>;
290
+ static ɵprov: i0.ɵɵInjectableDeclaration<MediaDevicesService>;
291
+ }
292
+
293
+ declare class NotificationService extends BrowserApiBaseService {
294
+ protected getApiName(): string;
295
+ protected getCapabilityId(): BrowserCapabilityId;
296
+ get permission(): NotificationPermission;
297
+ requestNotificationPermission(): Promise<NotificationPermission>;
298
+ showNotification(title: string, options?: NotificationOptions): Promise<Notification>;
299
+ static ɵfac: i0.ɵɵFactoryDeclaration<NotificationService, never>;
300
+ static ɵprov: i0.ɵɵInjectableDeclaration<NotificationService>;
301
+ }
302
+
303
+ declare class ClipboardService extends BrowserApiBaseService {
304
+ protected getApiName(): string;
305
+ protected getCapabilityId(): BrowserCapabilityId;
306
+ protected ensureSupported(): void;
307
+ writeText(text: string): Promise<void>;
308
+ readText(): Promise<string>;
309
+ static ɵfac: i0.ɵɵFactoryDeclaration<ClipboardService, never>;
310
+ static ɵprov: i0.ɵɵInjectableDeclaration<ClipboardService>;
311
+ }
312
+
313
+ interface BatteryInfo$1 {
311
314
  charging: boolean;
312
315
  chargingTime: number;
313
316
  dischargingTime: number;
@@ -336,10 +339,10 @@ declare global {
336
339
  declare class BatteryService extends BrowserApiBaseService {
337
340
  private batteryManager;
338
341
  protected getApiName(): string;
339
- protected ensureSupported(): void;
340
- initialize(): Promise<BatteryInfo>;
341
- getBatteryInfo(): BatteryInfo;
342
- watchBatteryInfo(): Observable<BatteryInfo>;
342
+ protected getCapabilityId(): BrowserCapabilityId;
343
+ initialize(): Promise<BatteryInfo$1>;
344
+ getBatteryInfo(): BatteryInfo$1;
345
+ watchBatteryInfo(): Observable<BatteryInfo$1>;
343
346
  getNativeBatteryManager(): BatteryManager;
344
347
  isCharging(): boolean;
345
348
  getLevel(): number;
@@ -355,7 +358,7 @@ interface ShareResult {
355
358
  }
356
359
  declare class WebShareService extends BrowserApiBaseService {
357
360
  protected getApiName(): string;
358
- protected ensureSupported(): void;
361
+ protected getCapabilityId(): BrowserCapabilityId;
359
362
  share(data: ShareData): Promise<ShareResult>;
360
363
  canShare(): boolean;
361
364
  canShareFiles(): boolean;
@@ -436,7 +439,7 @@ declare class WebStorageService extends BrowserApiBaseService {
436
439
  readonly session: StorageNamespace;
437
440
  constructor();
438
441
  protected getApiName(): string;
439
- protected ensureSupported(): void;
442
+ protected getCapabilityId(): BrowserCapabilityId;
440
443
  /** Returns true if either local or session storage is usable. */
441
444
  isSupported(): boolean;
442
445
  /** Stream of every storage mutation observed in this tab or other tabs. */
@@ -611,7 +614,7 @@ declare class WebSocketService extends BrowserApiBaseService {
611
614
  /** Legacy single-connection holder used by deprecated `connect()`/`send()` API. */
612
615
  private legacyClient;
613
616
  protected getApiName(): string;
614
- protected ensureSupported(): void;
617
+ protected getCapabilityId(): BrowserCapabilityId;
615
618
  /**
616
619
  * Create a new WebSocket client. The client owns one connection and is the recommended
617
620
  * surface for all interactions (status signal, request/response, reconnect, etc.).
@@ -655,6 +658,8 @@ interface WorkerMessage<T = unknown> {
655
658
  type: string;
656
659
  data: T;
657
660
  timestamp: number;
661
+ /** Set on responses to correlate with a `request()` call. */
662
+ correlationId?: string;
658
663
  }
659
664
  interface WorkerStatus {
660
665
  initialized: boolean;
@@ -663,32 +668,77 @@ interface WorkerStatus {
663
668
  messageCount: number;
664
669
  }
665
670
  interface WorkerTask<T = unknown> {
666
- id: string;
671
+ id?: string;
667
672
  type: string;
668
673
  data: T;
669
674
  transferable?: Transferable[];
670
675
  }
676
+ interface WorkerRequestOptions {
677
+ /** Timeout in milliseconds. Defaults to `30_000`. */
678
+ timeout?: number;
679
+ /** Transferable list forwarded to `postMessage`. */
680
+ transferable?: Transferable[];
681
+ }
682
+ /**
683
+ * Service for creating and managing Web Workers with first-class support for
684
+ * request/response over `postMessage` (id correlation, timeout, transferables).
685
+ *
686
+ * Status is exposed both as a `Signal<WorkerStatus>` (preferred via
687
+ * {@link getStatusSignal}) and as an `Observable<WorkerStatus>` for backward
688
+ * compatibility ({@link createWorker}, {@link getStatus}).
689
+ *
690
+ * The service registers a single `DestroyRef.onDestroy` in its constructor that
691
+ * terminates every registered worker; per-worker handlers do not register their
692
+ * own cleanup callbacks (avoids accumulating callbacks per `setupWorker` call,
693
+ * a previous leak source).
694
+ */
671
695
  declare class WebWorkerService extends BrowserApiBaseService {
672
- private workers;
673
- private workerStatuses;
674
- private workerMessages;
675
- private currentWorkerStatuses;
696
+ private readonly workerLogger;
697
+ private readonly entries;
676
698
  private readonly _cleanup;
677
699
  protected getApiName(): string;
678
- protected ensureSupported(): void;
700
+ protected getCapabilityId(): BrowserCapabilityId;
701
+ /**
702
+ * Create a worker. Idempotent: calling twice with the same name returns the
703
+ * existing entry without recreating the worker.
704
+ *
705
+ * Returns an `Observable<WorkerStatus>` for backward compatibility. Prefer
706
+ * {@link createWorkerSignal} for new code.
707
+ */
679
708
  createWorker(name: string, scriptUrl: string): Observable<WorkerStatus>;
709
+ /**
710
+ * Create a worker (signal-first). Returns the status signal; status is also
711
+ * accessible later via {@link getStatusSignal}.
712
+ */
713
+ createWorkerSignal(name: string, scriptUrl: string): Signal<WorkerStatus>;
680
714
  terminateWorker(name: string): void;
681
715
  terminateAllWorkers(): void;
716
+ /** Send a fire-and-forget message. Use {@link request} when you need a reply. */
682
717
  postMessage(workerName: string, task: WorkerTask): void;
683
- getMessages(workerName: string): Observable<WorkerMessage>;
718
+ /**
719
+ * Send a message and await a correlated response. The worker MUST send back a
720
+ * message containing `correlationId` matching the request id.
721
+ *
722
+ * ```ts
723
+ * const result = await ws.request<{ ok: boolean }>('worker', 'compute', { n: 1 });
724
+ * ```
725
+ */
726
+ request<TRes = unknown, TReq = unknown>(workerName: string, type: string, data: TReq, opts?: WorkerRequestOptions): Promise<TRes>;
727
+ getMessages<T = unknown>(workerName: string): Observable<WorkerMessage<T>>;
728
+ getMessagesByType<T = unknown>(workerName: string, type: string): Observable<WorkerMessage<T>>;
729
+ /** @deprecated Use {@link getStatusSignal}. Kept as Observable for backward compat. */
684
730
  getStatus(workerName: string): Observable<WorkerStatus>;
731
+ getStatusSignal(workerName: string): Signal<WorkerStatus>;
685
732
  getCurrentStatus(workerName: string): WorkerStatus | undefined;
686
733
  getAllStatuses(): Map<string, WorkerStatus>;
687
734
  isWorkerRunning(workerName: string): boolean;
688
- private setupWorker;
689
- private updateWorkerStatus;
690
735
  getNativeWorker(name: string): Worker | undefined;
691
736
  getAllWorkers(): Map<string, Worker>;
737
+ private attachHandlers;
738
+ private rejectPending;
739
+ private bumpMessageCount;
740
+ private ensureEntry;
741
+ private generateId;
692
742
  static ɵfac: i0.ɵɵFactoryDeclaration<WebWorkerService, never>;
693
743
  static ɵprov: i0.ɵɵInjectableDeclaration<WebWorkerService>;
694
744
  }
@@ -700,7 +750,7 @@ interface IntersectionObserverOptions {
700
750
  }
701
751
  declare class IntersectionObserverService extends BrowserApiBaseService {
702
752
  protected getApiName(): string;
703
- isSupported(): boolean;
753
+ protected getCapabilityId(): BrowserCapabilityId;
704
754
  observe(element: Element, options?: IntersectionObserverOptions): Observable<IntersectionObserverEntry[]>;
705
755
  observeVisibility(element: Element, options?: IntersectionObserverOptions): Observable<boolean>;
706
756
  static ɵfac: i0.ɵɵFactoryDeclaration<IntersectionObserverService, never>;
@@ -718,7 +768,7 @@ interface ElementSize {
718
768
  }
719
769
  declare class ResizeObserverService extends BrowserApiBaseService {
720
770
  protected getApiName(): string;
721
- isSupported(): boolean;
771
+ protected getCapabilityId(): BrowserCapabilityId;
722
772
  observe(element: Element, options?: ResizeObserverOptions): Observable<ResizeObserverEntry[]>;
723
773
  observeSize(element: Element, options?: ResizeObserverOptions): Observable<ElementSize>;
724
774
  static ɵfac: i0.ɵɵFactoryDeclaration<ResizeObserverService, never>;
@@ -728,7 +778,7 @@ declare class ResizeObserverService extends BrowserApiBaseService {
728
778
  type VisibilityState = 'visible' | 'hidden' | 'prerender';
729
779
  declare class PageVisibilityService extends BrowserApiBaseService {
730
780
  protected getApiName(): string;
731
- isSupported(): boolean;
781
+ protected getCapabilityId(): BrowserCapabilityId;
732
782
  get isHidden(): boolean;
733
783
  get visibilityState(): VisibilityState;
734
784
  watch(): Observable<VisibilityState>;
@@ -775,7 +825,7 @@ declare abstract class ConnectionRegistryBaseService<T> extends BrowserApiBaseSe
775
825
  declare class BroadcastChannelService extends ConnectionRegistryBaseService<BroadcastChannel> {
776
826
  protected getApiName(): string;
777
827
  protected closeNativeConnection(channel: BroadcastChannel): void;
778
- isSupported(): boolean;
828
+ protected getCapabilityId(): BrowserCapabilityId;
779
829
  private ensureBroadcastChannelSupported;
780
830
  open<T = unknown>(name: string): Observable<T>;
781
831
  post<T = unknown>(name: string, data: T): void;
@@ -799,7 +849,7 @@ interface NetworkInformation {
799
849
  }
800
850
  declare class NetworkInformationService extends BrowserApiBaseService {
801
851
  protected getApiName(): string;
802
- isSupported(): boolean;
852
+ protected getCapabilityId(): BrowserCapabilityId;
803
853
  getSnapshot(): NetworkInformation;
804
854
  watch(): Observable<NetworkInformation>;
805
855
  get isOnline(): boolean;
@@ -816,7 +866,7 @@ interface WakeLockStatus {
816
866
  declare class ScreenWakeLockService extends BrowserApiBaseService {
817
867
  private sentinel;
818
868
  protected getApiName(): string;
819
- isSupported(): boolean;
869
+ protected getCapabilityId(): BrowserCapabilityId;
820
870
  get isActive(): boolean;
821
871
  request(type?: WakeLockType): Promise<WakeLockStatus>;
822
872
  release(): Promise<void>;
@@ -833,7 +883,7 @@ interface OrientationInfo {
833
883
  }
834
884
  declare class ScreenOrientationService extends BrowserApiBaseService {
835
885
  protected getApiName(): string;
836
- isSupported(): boolean;
886
+ protected getCapabilityId(): BrowserCapabilityId;
837
887
  getSnapshot(): OrientationInfo;
838
888
  get isPortrait(): boolean;
839
889
  get isLandscape(): boolean;
@@ -846,6 +896,8 @@ declare class ScreenOrientationService extends BrowserApiBaseService {
846
896
 
847
897
  declare class FullscreenService extends BrowserApiBaseService {
848
898
  protected getApiName(): string;
899
+ protected getCapabilityId(): BrowserCapabilityId;
900
+ /** Override to also check the *enabled* flag (browser may have disabled fullscreen). */
849
901
  isSupported(): boolean;
850
902
  get isFullscreen(): boolean;
851
903
  get fullscreenElement(): Element | null;
@@ -875,6 +927,8 @@ interface FileSaveOptions {
875
927
  }
876
928
  declare class FileSystemAccessService extends BrowserApiBaseService {
877
929
  protected getApiName(): string;
930
+ protected getCapabilityId(): BrowserCapabilityId;
931
+ /** Override to also assert secure context (required by the spec). */
878
932
  isSupported(): boolean;
879
933
  private get win();
880
934
  protected ensureSupported(): void;
@@ -912,7 +966,7 @@ declare class MediaRecorderService extends BrowserApiBaseService {
912
966
  private readonly dataSubject;
913
967
  private readonly stateSubject;
914
968
  protected getApiName(): string;
915
- isSupported(): boolean;
969
+ protected getCapabilityId(): BrowserCapabilityId;
916
970
  get state(): RecordingState;
917
971
  static isTypeSupported(mimeType: string): boolean;
918
972
  watchState(): Observable<RecordingState>;
@@ -940,7 +994,7 @@ interface SSEConfig {
940
994
  declare class ServerSentEventsService extends ConnectionRegistryBaseService<EventSource> {
941
995
  protected getApiName(): string;
942
996
  protected closeNativeConnection(source: EventSource): void;
943
- isSupported(): boolean;
997
+ protected getCapabilityId(): BrowserCapabilityId;
944
998
  private ensureSSESupported;
945
999
  connect<T = unknown>(url: string, config?: SSEConfig): Observable<SSEMessage<T>>;
946
1000
  disconnect(url: string): void;
@@ -961,7 +1015,7 @@ interface VibrationPreset {
961
1015
  declare class VibrationService extends BrowserApiBaseService {
962
1016
  protected getApiName(): string;
963
1017
  readonly presets: VibrationPreset;
964
- isSupported(): boolean;
1018
+ protected getCapabilityId(): BrowserCapabilityId;
965
1019
  vibrate(pattern?: VibrationPattern): boolean;
966
1020
  success(): boolean;
967
1021
  error(): boolean;
@@ -982,7 +1036,7 @@ interface SpeechOptions {
982
1036
  }
983
1037
  declare class SpeechSynthesisService extends BrowserApiBaseService {
984
1038
  protected getApiName(): string;
985
- isSupported(): boolean;
1039
+ protected getCapabilityId(): BrowserCapabilityId;
986
1040
  private ensureSpeechSynthesisSupported;
987
1041
  get state(): SpeechState;
988
1042
  get isPending(): boolean;
@@ -1008,7 +1062,7 @@ interface MutationObserverOptions {
1008
1062
 
1009
1063
  declare class MutationObserverService extends BrowserApiBaseService {
1010
1064
  protected getApiName(): string;
1011
- isSupported(): boolean;
1065
+ protected getCapabilityId(): BrowserCapabilityId;
1012
1066
  observe(target: Node, options?: MutationObserverOptions): Observable<MutationRecord[]>;
1013
1067
  static ɵfac: i0.ɵɵFactoryDeclaration<MutationObserverService, never>;
1014
1068
  static ɵprov: i0.ɵɵInjectableDeclaration<MutationObserverService>;
@@ -1023,7 +1077,7 @@ interface PerformanceObserverConfig {
1023
1077
 
1024
1078
  declare class PerformanceObserverService extends BrowserApiBaseService {
1025
1079
  protected getApiName(): string;
1026
- isSupported(): boolean;
1080
+ protected getCapabilityId(): BrowserCapabilityId;
1027
1081
  observe(config: PerformanceObserverConfig): Observable<PerformanceEntryList>;
1028
1082
  observeByType(type: PerformanceEntryType, buffered?: boolean): Observable<PerformanceEntryList>;
1029
1083
  getSupportedEntryTypes(): PerformanceEntryType[];
@@ -1039,7 +1093,7 @@ interface AudioAnalyserData {
1039
1093
  declare class WebAudioService extends BrowserApiBaseService {
1040
1094
  protected getApiName(): string;
1041
1095
  private context;
1042
- isSupported(): boolean;
1096
+ protected getCapabilityId(): BrowserCapabilityId;
1043
1097
  getContext(): AudioContext;
1044
1098
  resume(): Promise<void>;
1045
1099
  close(): Promise<void>;
@@ -1068,7 +1122,7 @@ interface GamepadState {
1068
1122
 
1069
1123
  declare class GamepadService extends BrowserApiBaseService {
1070
1124
  protected getApiName(): string;
1071
- isSupported(): boolean;
1125
+ protected getCapabilityId(): BrowserCapabilityId;
1072
1126
  getSnapshot(index: number): GamepadState | null;
1073
1127
  getConnectedGamepads(): GamepadState[];
1074
1128
  watchConnections(): Observable<{
@@ -1153,7 +1207,7 @@ interface GeolocationCoordinates {
1153
1207
  heading: number | null;
1154
1208
  speed: number | null;
1155
1209
  }
1156
- interface GeolocationOptions {
1210
+ interface GeolocationOptions$1 {
1157
1211
  enableHighAccuracy?: boolean;
1158
1212
  timeout?: number;
1159
1213
  maximumAge?: number;
@@ -1165,7 +1219,7 @@ interface GeolocationError {
1165
1219
  POSITION_UNAVAILABLE: number;
1166
1220
  TIMEOUT: number;
1167
1221
  }
1168
- interface GeolocationWatchOptions extends GeolocationOptions {
1222
+ interface GeolocationWatchOptions extends GeolocationOptions$1 {
1169
1223
  maximumAge?: number;
1170
1224
  }
1171
1225
 
@@ -1237,6 +1291,62 @@ interface GamepadRef {
1237
1291
  }
1238
1292
  declare function injectGamepad(index: number, intervalMs?: number): GamepadRef;
1239
1293
 
1294
+ interface ClipboardRef {
1295
+ /** Last text successfully read from the clipboard, or `null`. */
1296
+ readonly text: Signal<string | null>;
1297
+ /** Last error message from a read/write attempt, or `null`. */
1298
+ readonly error: Signal<string | null>;
1299
+ /** True when a read/write is in flight. */
1300
+ readonly busy: Signal<boolean>;
1301
+ /** True when the Clipboard API is available in the current environment. */
1302
+ readonly isSupported: Signal<boolean>;
1303
+ writeText(value: string): Promise<boolean>;
1304
+ readText(): Promise<string | null>;
1305
+ }
1306
+ declare function injectClipboard(): ClipboardRef;
1307
+
1308
+ interface GeolocationOptions extends PositionOptions {
1309
+ /** Start watching immediately. Defaults to `false`. */
1310
+ watch?: boolean;
1311
+ }
1312
+ interface GeolocationRef {
1313
+ readonly position: Signal<GeolocationPosition | null>;
1314
+ readonly error: Signal<GeolocationPositionError | null>;
1315
+ readonly watching: Signal<boolean>;
1316
+ readonly isSupported: Signal<boolean>;
1317
+ /** Start watching position. Idempotent — safe to call when already watching. */
1318
+ watch(opts?: PositionOptions): void;
1319
+ /** Stop watching. Idempotent. */
1320
+ stop(): void;
1321
+ /** One-shot read of the current position. */
1322
+ getCurrent(opts?: PositionOptions): Promise<GeolocationPosition>;
1323
+ }
1324
+ declare function injectGeolocation(opts?: GeolocationOptions): GeolocationRef;
1325
+
1326
+ interface BatteryInfo {
1327
+ charging: boolean;
1328
+ level: number;
1329
+ chargingTime: number;
1330
+ dischargingTime: number;
1331
+ }
1332
+ interface BatteryRef {
1333
+ readonly info: Signal<BatteryInfo | null>;
1334
+ readonly error: Signal<string | null>;
1335
+ readonly isSupported: Signal<boolean>;
1336
+ /** Force a one-shot refresh of the battery snapshot. */
1337
+ refresh(): Promise<void>;
1338
+ }
1339
+ declare function injectBattery(): BatteryRef;
1340
+
1341
+ interface WakeLockRef {
1342
+ readonly active: Signal<boolean>;
1343
+ readonly error: Signal<string | null>;
1344
+ readonly isSupported: Signal<boolean>;
1345
+ request(): Promise<boolean>;
1346
+ release(): Promise<void>;
1347
+ }
1348
+ declare function injectWakeLock(): WakeLockRef;
1349
+
1240
1350
  declare class BrowserSupportUtil {
1241
1351
  static isSupported(feature: string): boolean;
1242
1352
  static getUnsupportedFeatures(): string[];
@@ -1357,5 +1467,5 @@ declare function provideBrowserWebApis(config?: BrowserWebApisConfig): Environme
1357
1467
 
1358
1468
  declare const version = "0.1.0";
1359
1469
 
1360
- export { BROWSER_API_LOGGER, BatteryService, BroadcastChannelService, BrowserApiBaseService, BrowserCapabilityService, BrowserSupportUtil, CameraService, ClipboardService, ConnectionRegistryBaseService, FileSystemAccessService, FullscreenService, GamepadService, GeolocationService, IntersectionObserverService, MediaDevicesService, MediaRecorderService, MutationObserverService, NetworkInformationService, NotificationService, PageVisibilityService, PerformanceObserverService, PermissionsService, ResizeObserverService, ScreenOrientationService, ScreenWakeLockService, ServerSentEventsService, SpeechSynthesisService, VibrationService, WebAudioService, WebShareService, WebSocketClient, WebSocketService, WebStorageService, WebWorkerService, permissionGuard as createPermissionGuard, defaultBrowserWebApisConfig, injectGamepad, injectIntersectionObserver, injectMutationObserver, injectNetworkInformation, injectPageVisibility, injectPerformanceObserver, injectResizeObserver, injectScreenOrientation, permissionGuard, provideBattery, provideBroadcastChannel, provideBrowserWebApis, provideCamera, provideClipboard, provideCommunicationApis, provideFileSystemAccess, provideFullscreen, provideGamepad, provideGeolocation, provideIntersectionObserver, provideLocationApis, provideMediaApis, provideMediaDevices, provideMediaRecorder, provideMutationObserver, provideNetworkInformation, provideNotifications, providePageVisibility, providePerformanceObserver, providePermissions, provideResizeObserver, provideScreenOrientation, provideScreenWakeLock, provideServerSentEvents, provideSpeechSynthesis, provideStorageApis, provideVibration, provideWebAudio, provideWebShare, provideWebSocket, provideWebStorage, provideWebWorker, version };
1361
- export type { AudioAnalyserData, AudioContextState, BatteryInfo, BatteryManager, BrowserApiLogger, BrowserCapabilityId, BrowserError, BrowserPermissions, BrowserWebApisConfig, CameraCapabilities, CameraInfo, ConnectionType, EffectiveConnectionType, ElementInput, ElementSize, ErrorCallback, EventHandler, FileOpenOptions, FileSaveOptions, GamepadRef, GamepadState, GeolocationCoordinates, GeolocationError, GeolocationOptions, GeolocationPosition$1 as GeolocationPosition, GeolocationWatchOptions, IntersectionObserverOptions, IntersectionRef, MediaDevice, MediaDeviceKind, MediaDevicesInfo, MediaStreamConstraints$1 as MediaStreamConstraints, MediaTrackConstraints$1 as MediaTrackConstraints, MutationObserverOptions, MutationRef, NetworkInformation, NetworkInformationRef, OrientationInfo, OrientationLockType, OrientationType, PageVisibilityRef, PerformanceEntryType, PerformanceObserverConfig, PerformanceObserverRef, PermissionNameExt, PermissionRequest, RecordingOptions, RecordingResult, RecordingState, ResizeObserverOptions, ResizeRef, SSEConfig, SSEConnectionState, SSEMessage, ScreenOrientationRef, SpeechOptions, SpeechState, StorageEvent, StorageNamespace, StorageOptions, StorageValue, VibrationPattern, VibrationPreset, VisibilityState, WakeLockStatus, WakeLockType, WebSocketClientConfig, WebSocketConfig, WebSocketMessage, WebSocketRequestOptions, WebSocketState, WebSocketStatus, WebSocketStatusV2, WorkerMessage, WorkerStatus, WorkerTask };
1470
+ export { BROWSER_API_LOGGER, BatteryService, BroadcastChannelService, BrowserApiBaseService, BrowserCapabilityService, BrowserSupportUtil, CameraService, ClipboardService, ConnectionRegistryBaseService, FileSystemAccessService, FullscreenService, GamepadService, GeolocationService, IntersectionObserverService, MediaDevicesService, MediaRecorderService, MutationObserverService, NetworkInformationService, NotificationService, PageVisibilityService, PerformanceObserverService, PermissionsService, ResizeObserverService, ScreenOrientationService, ScreenWakeLockService, ServerSentEventsService, SpeechSynthesisService, VibrationService, WebAudioService, WebShareService, WebSocketClient, WebSocketService, WebStorageService, WebWorkerService, permissionGuard as createPermissionGuard, defaultBrowserWebApisConfig, injectBattery, injectClipboard, injectGamepad, injectGeolocation, injectIntersectionObserver, injectMutationObserver, injectNetworkInformation, injectPageVisibility, injectPerformanceObserver, injectResizeObserver, injectScreenOrientation, injectWakeLock, permissionGuard, provideBattery, provideBroadcastChannel, provideBrowserWebApis, provideCamera, provideClipboard, provideCommunicationApis, provideFileSystemAccess, provideFullscreen, provideGamepad, provideGeolocation, provideIntersectionObserver, provideLocationApis, provideMediaApis, provideMediaDevices, provideMediaRecorder, provideMutationObserver, provideNetworkInformation, provideNotifications, providePageVisibility, providePerformanceObserver, providePermissions, provideResizeObserver, provideScreenOrientation, provideScreenWakeLock, provideServerSentEvents, provideSpeechSynthesis, provideStorageApis, provideVibration, provideWebAudio, provideWebShare, provideWebSocket, provideWebStorage, provideWebWorker, version };
1471
+ export type { AudioAnalyserData, AudioContextState, BatteryInfo, BatteryManager, BatteryRef, BrowserApiLogger, BrowserCapabilityId, BrowserError, BrowserPermissions, BrowserWebApisConfig, CameraCapabilities, CameraInfo, ClipboardRef, ConnectionType, EffectiveConnectionType, ElementInput, ElementSize, ErrorCallback, EventHandler, FileOpenOptions, FileSaveOptions, GamepadRef, GamepadState, GeolocationCoordinates, GeolocationError, GeolocationOptions, GeolocationPosition$1 as GeolocationPosition, GeolocationRef, GeolocationWatchOptions, IntersectionObserverOptions, IntersectionRef, MediaDevice, MediaDeviceKind, MediaDevicesInfo, MediaStreamConstraints$1 as MediaStreamConstraints, MediaTrackConstraints$1 as MediaTrackConstraints, MutationObserverOptions, MutationRef, NetworkInformation, NetworkInformationRef, OrientationInfo, OrientationLockType, OrientationType, PageVisibilityRef, PerformanceEntryType, PerformanceObserverConfig, PerformanceObserverRef, PermissionNameExt, PermissionRequest, RecordingOptions, RecordingResult, RecordingState, ResizeObserverOptions, ResizeRef, SSEConfig, SSEConnectionState, SSEMessage, ScreenOrientationRef, SpeechOptions, SpeechState, StorageEvent, StorageNamespace, StorageOptions, StorageValue, VibrationPattern, VibrationPreset, VisibilityState, WakeLockRef, WakeLockStatus, WakeLockType, WebSocketClientConfig, WebSocketConfig, WebSocketMessage, WebSocketRequestOptions, WebSocketState, WebSocketStatus, WebSocketStatusV2, WorkerMessage, WorkerRequestOptions, WorkerStatus, WorkerTask };