@angular-helpers/browser-web-apis 21.6.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: "
|
|
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
|
-
|
|
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
|
|
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
|
|
361
|
+
protected getCapabilityId(): BrowserCapabilityId;
|
|
359
362
|
share(data: ShareData): Promise<ShareResult>;
|
|
360
363
|
canShare(): boolean;
|
|
361
364
|
canShareFiles(): boolean;
|
|
@@ -377,53 +380,105 @@ type ErrorCallback = (error: BrowserError) => void;
|
|
|
377
380
|
*/
|
|
378
381
|
type ElementInput = Element | ElementRef<Element> | Signal<Element | ElementRef<Element> | undefined>;
|
|
379
382
|
|
|
383
|
+
interface BrowserApiLogger {
|
|
384
|
+
info(message: string): void;
|
|
385
|
+
warn(message: string): void;
|
|
386
|
+
error(message: string, error?: unknown): void;
|
|
387
|
+
}
|
|
388
|
+
declare const BROWSER_API_LOGGER: InjectionToken<BrowserApiLogger>;
|
|
389
|
+
|
|
380
390
|
interface StorageOptions {
|
|
391
|
+
/** Optional prefix used to namespace keys (e.g. `app:` -> `app:userId`). */
|
|
381
392
|
prefix?: string;
|
|
382
393
|
serialize?: (value: StorageValue) => string;
|
|
383
394
|
deserialize?: (value: string) => StorageValue;
|
|
384
395
|
}
|
|
396
|
+
type StorageArea = 'localStorage' | 'sessionStorage';
|
|
385
397
|
interface StorageEvent {
|
|
386
398
|
key: string | null;
|
|
387
399
|
newValue: StorageValue | null;
|
|
388
400
|
oldValue: StorageValue | null;
|
|
389
|
-
storageArea:
|
|
401
|
+
storageArea: StorageArea;
|
|
390
402
|
}
|
|
403
|
+
interface StorageNamespace {
|
|
404
|
+
readonly area: StorageArea;
|
|
405
|
+
isSupported(): boolean;
|
|
406
|
+
set<T extends StorageValue>(key: string, value: T, opts?: StorageOptions): boolean;
|
|
407
|
+
get<T extends StorageValue>(key: string, defaultValue?: T | null, opts?: StorageOptions): T | null;
|
|
408
|
+
remove(key: string, opts?: StorageOptions): boolean;
|
|
409
|
+
clear(opts?: StorageOptions): boolean;
|
|
410
|
+
size(opts?: StorageOptions): number;
|
|
411
|
+
watch<T extends StorageValue>(key: string, opts?: StorageOptions): Observable<T | null>;
|
|
412
|
+
/** Direct access to the native Storage object. Throws if unsupported. */
|
|
413
|
+
native(): Storage;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Web Storage service with two namespaces (`local`, `session`) sharing one method
|
|
418
|
+
* surface. SecurityError-safe (Safari private mode, sandboxed iframes return defaults
|
|
419
|
+
* instead of throwing).
|
|
420
|
+
*
|
|
421
|
+
* Preferred usage:
|
|
422
|
+
* ```ts
|
|
423
|
+
* const storage = inject(WebStorageService);
|
|
424
|
+
* storage.local.set('user', { id: 1 });
|
|
425
|
+
* const user = storage.local.get<{ id: number }>('user');
|
|
426
|
+
* storage.local.watch<{ id: number }>('user').subscribe(console.log);
|
|
427
|
+
* ```
|
|
428
|
+
*
|
|
429
|
+
* Legacy methods (`setLocalStorage`, `getLocalStorage`, etc.) remain as deprecated
|
|
430
|
+
* wrappers for one minor cycle; removal slated for v22.
|
|
431
|
+
*/
|
|
391
432
|
declare class WebStorageService extends BrowserApiBaseService {
|
|
433
|
+
private readonly storageLogger;
|
|
392
434
|
private storageEvents;
|
|
435
|
+
private readonly eventBus;
|
|
436
|
+
/** Local storage namespace. */
|
|
437
|
+
readonly local: StorageNamespace;
|
|
438
|
+
/** Session storage namespace. */
|
|
439
|
+
readonly session: StorageNamespace;
|
|
393
440
|
constructor();
|
|
394
441
|
protected getApiName(): string;
|
|
395
|
-
protected
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
private
|
|
442
|
+
protected getCapabilityId(): BrowserCapabilityId;
|
|
443
|
+
/** Returns true if either local or session storage is usable. */
|
|
444
|
+
isSupported(): boolean;
|
|
445
|
+
/** Stream of every storage mutation observed in this tab or other tabs. */
|
|
446
|
+
getStorageEvents(): Observable<StorageEvent>;
|
|
447
|
+
private setupCrossTabListener;
|
|
448
|
+
private safeParse;
|
|
449
|
+
/** @deprecated Use `storage.local.set(key, value, opts)`. Removed in v22. */
|
|
401
450
|
setLocalStorage<T extends StorageValue>(key: string, value: T, options?: StorageOptions): boolean;
|
|
451
|
+
/** @deprecated Use `storage.local.get(key, defaultValue, opts)`. Removed in v22. */
|
|
402
452
|
getLocalStorage<T extends StorageValue>(key: string, defaultValue?: T | null, options?: StorageOptions): T | null;
|
|
453
|
+
/** @deprecated Use `storage.local.remove(key, opts)`. Removed in v22. */
|
|
403
454
|
removeLocalStorage(key: string, options?: StorageOptions): boolean;
|
|
455
|
+
/** @deprecated Use `storage.local.clear(opts)`. Removed in v22. */
|
|
404
456
|
clearLocalStorage(options?: StorageOptions): boolean;
|
|
457
|
+
/** @deprecated Use `storage.session.set(key, value, opts)`. Removed in v22. */
|
|
405
458
|
setSessionStorage<T extends StorageValue>(key: string, value: T, options?: StorageOptions): boolean;
|
|
459
|
+
/** @deprecated Use `storage.session.get(key, defaultValue, opts)`. Removed in v22. */
|
|
406
460
|
getSessionStorage<T extends StorageValue>(key: string, defaultValue?: T | null, options?: StorageOptions): T | null;
|
|
461
|
+
/** @deprecated Use `storage.session.remove(key, opts)`. Removed in v22. */
|
|
407
462
|
removeSessionStorage(key: string, options?: StorageOptions): boolean;
|
|
463
|
+
/** @deprecated Use `storage.session.clear(opts)`. Removed in v22. */
|
|
408
464
|
clearSessionStorage(options?: StorageOptions): boolean;
|
|
465
|
+
/** @deprecated Use `storage.local.size(opts)`. Removed in v22. */
|
|
409
466
|
getLocalStorageSize(options?: StorageOptions): number;
|
|
467
|
+
/** @deprecated Use `storage.session.size(opts)`. Removed in v22. */
|
|
410
468
|
getSessionStorageSize(options?: StorageOptions): number;
|
|
411
|
-
|
|
469
|
+
/** @deprecated Use `storage.local.watch<T>(key, opts)`. Removed in v22. */
|
|
412
470
|
watchLocalStorage<T extends StorageValue>(key: string, options?: StorageOptions): Observable<T | null>;
|
|
471
|
+
/** @deprecated Use `storage.session.watch<T>(key, opts)`. Removed in v22. */
|
|
413
472
|
watchSessionStorage<T extends StorageValue>(key: string, options?: StorageOptions): Observable<T | null>;
|
|
473
|
+
/** @deprecated Use `storage.local.native()`. Removed in v22. */
|
|
414
474
|
getNativeLocalStorage(): Storage;
|
|
475
|
+
/** @deprecated Use `storage.session.native()`. Removed in v22. */
|
|
415
476
|
getNativeSessionStorage(): Storage;
|
|
477
|
+
private warnLegacyOnce;
|
|
416
478
|
static ɵfac: i0.ɵɵFactoryDeclaration<WebStorageService, never>;
|
|
417
479
|
static ɵprov: i0.ɵɵInjectableDeclaration<WebStorageService>;
|
|
418
480
|
}
|
|
419
481
|
|
|
420
|
-
interface BrowserApiLogger {
|
|
421
|
-
info(message: string): void;
|
|
422
|
-
warn(message: string): void;
|
|
423
|
-
error(message: string, error?: unknown): void;
|
|
424
|
-
}
|
|
425
|
-
declare const BROWSER_API_LOGGER: InjectionToken<BrowserApiLogger>;
|
|
426
|
-
|
|
427
482
|
/**
|
|
428
483
|
* Configuration for a single WebSocket connection.
|
|
429
484
|
*/
|
|
@@ -559,7 +614,7 @@ declare class WebSocketService extends BrowserApiBaseService {
|
|
|
559
614
|
/** Legacy single-connection holder used by deprecated `connect()`/`send()` API. */
|
|
560
615
|
private legacyClient;
|
|
561
616
|
protected getApiName(): string;
|
|
562
|
-
protected
|
|
617
|
+
protected getCapabilityId(): BrowserCapabilityId;
|
|
563
618
|
/**
|
|
564
619
|
* Create a new WebSocket client. The client owns one connection and is the recommended
|
|
565
620
|
* surface for all interactions (status signal, request/response, reconnect, etc.).
|
|
@@ -603,6 +658,8 @@ interface WorkerMessage<T = unknown> {
|
|
|
603
658
|
type: string;
|
|
604
659
|
data: T;
|
|
605
660
|
timestamp: number;
|
|
661
|
+
/** Set on responses to correlate with a `request()` call. */
|
|
662
|
+
correlationId?: string;
|
|
606
663
|
}
|
|
607
664
|
interface WorkerStatus {
|
|
608
665
|
initialized: boolean;
|
|
@@ -611,32 +668,77 @@ interface WorkerStatus {
|
|
|
611
668
|
messageCount: number;
|
|
612
669
|
}
|
|
613
670
|
interface WorkerTask<T = unknown> {
|
|
614
|
-
id
|
|
671
|
+
id?: string;
|
|
615
672
|
type: string;
|
|
616
673
|
data: T;
|
|
617
674
|
transferable?: Transferable[];
|
|
618
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
|
+
*/
|
|
619
695
|
declare class WebWorkerService extends BrowserApiBaseService {
|
|
620
|
-
private
|
|
621
|
-
private
|
|
622
|
-
private workerMessages;
|
|
623
|
-
private currentWorkerStatuses;
|
|
696
|
+
private readonly workerLogger;
|
|
697
|
+
private readonly entries;
|
|
624
698
|
private readonly _cleanup;
|
|
625
699
|
protected getApiName(): string;
|
|
626
|
-
protected
|
|
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
|
+
*/
|
|
627
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>;
|
|
628
714
|
terminateWorker(name: string): void;
|
|
629
715
|
terminateAllWorkers(): void;
|
|
716
|
+
/** Send a fire-and-forget message. Use {@link request} when you need a reply. */
|
|
630
717
|
postMessage(workerName: string, task: WorkerTask): void;
|
|
631
|
-
|
|
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. */
|
|
632
730
|
getStatus(workerName: string): Observable<WorkerStatus>;
|
|
731
|
+
getStatusSignal(workerName: string): Signal<WorkerStatus>;
|
|
633
732
|
getCurrentStatus(workerName: string): WorkerStatus | undefined;
|
|
634
733
|
getAllStatuses(): Map<string, WorkerStatus>;
|
|
635
734
|
isWorkerRunning(workerName: string): boolean;
|
|
636
|
-
private setupWorker;
|
|
637
|
-
private updateWorkerStatus;
|
|
638
735
|
getNativeWorker(name: string): Worker | undefined;
|
|
639
736
|
getAllWorkers(): Map<string, Worker>;
|
|
737
|
+
private attachHandlers;
|
|
738
|
+
private rejectPending;
|
|
739
|
+
private bumpMessageCount;
|
|
740
|
+
private ensureEntry;
|
|
741
|
+
private generateId;
|
|
640
742
|
static ɵfac: i0.ɵɵFactoryDeclaration<WebWorkerService, never>;
|
|
641
743
|
static ɵprov: i0.ɵɵInjectableDeclaration<WebWorkerService>;
|
|
642
744
|
}
|
|
@@ -648,7 +750,7 @@ interface IntersectionObserverOptions {
|
|
|
648
750
|
}
|
|
649
751
|
declare class IntersectionObserverService extends BrowserApiBaseService {
|
|
650
752
|
protected getApiName(): string;
|
|
651
|
-
|
|
753
|
+
protected getCapabilityId(): BrowserCapabilityId;
|
|
652
754
|
observe(element: Element, options?: IntersectionObserverOptions): Observable<IntersectionObserverEntry[]>;
|
|
653
755
|
observeVisibility(element: Element, options?: IntersectionObserverOptions): Observable<boolean>;
|
|
654
756
|
static ɵfac: i0.ɵɵFactoryDeclaration<IntersectionObserverService, never>;
|
|
@@ -666,7 +768,7 @@ interface ElementSize {
|
|
|
666
768
|
}
|
|
667
769
|
declare class ResizeObserverService extends BrowserApiBaseService {
|
|
668
770
|
protected getApiName(): string;
|
|
669
|
-
|
|
771
|
+
protected getCapabilityId(): BrowserCapabilityId;
|
|
670
772
|
observe(element: Element, options?: ResizeObserverOptions): Observable<ResizeObserverEntry[]>;
|
|
671
773
|
observeSize(element: Element, options?: ResizeObserverOptions): Observable<ElementSize>;
|
|
672
774
|
static ɵfac: i0.ɵɵFactoryDeclaration<ResizeObserverService, never>;
|
|
@@ -676,7 +778,7 @@ declare class ResizeObserverService extends BrowserApiBaseService {
|
|
|
676
778
|
type VisibilityState = 'visible' | 'hidden' | 'prerender';
|
|
677
779
|
declare class PageVisibilityService extends BrowserApiBaseService {
|
|
678
780
|
protected getApiName(): string;
|
|
679
|
-
|
|
781
|
+
protected getCapabilityId(): BrowserCapabilityId;
|
|
680
782
|
get isHidden(): boolean;
|
|
681
783
|
get visibilityState(): VisibilityState;
|
|
682
784
|
watch(): Observable<VisibilityState>;
|
|
@@ -723,7 +825,7 @@ declare abstract class ConnectionRegistryBaseService<T> extends BrowserApiBaseSe
|
|
|
723
825
|
declare class BroadcastChannelService extends ConnectionRegistryBaseService<BroadcastChannel> {
|
|
724
826
|
protected getApiName(): string;
|
|
725
827
|
protected closeNativeConnection(channel: BroadcastChannel): void;
|
|
726
|
-
|
|
828
|
+
protected getCapabilityId(): BrowserCapabilityId;
|
|
727
829
|
private ensureBroadcastChannelSupported;
|
|
728
830
|
open<T = unknown>(name: string): Observable<T>;
|
|
729
831
|
post<T = unknown>(name: string, data: T): void;
|
|
@@ -747,7 +849,7 @@ interface NetworkInformation {
|
|
|
747
849
|
}
|
|
748
850
|
declare class NetworkInformationService extends BrowserApiBaseService {
|
|
749
851
|
protected getApiName(): string;
|
|
750
|
-
|
|
852
|
+
protected getCapabilityId(): BrowserCapabilityId;
|
|
751
853
|
getSnapshot(): NetworkInformation;
|
|
752
854
|
watch(): Observable<NetworkInformation>;
|
|
753
855
|
get isOnline(): boolean;
|
|
@@ -764,7 +866,7 @@ interface WakeLockStatus {
|
|
|
764
866
|
declare class ScreenWakeLockService extends BrowserApiBaseService {
|
|
765
867
|
private sentinel;
|
|
766
868
|
protected getApiName(): string;
|
|
767
|
-
|
|
869
|
+
protected getCapabilityId(): BrowserCapabilityId;
|
|
768
870
|
get isActive(): boolean;
|
|
769
871
|
request(type?: WakeLockType): Promise<WakeLockStatus>;
|
|
770
872
|
release(): Promise<void>;
|
|
@@ -781,7 +883,7 @@ interface OrientationInfo {
|
|
|
781
883
|
}
|
|
782
884
|
declare class ScreenOrientationService extends BrowserApiBaseService {
|
|
783
885
|
protected getApiName(): string;
|
|
784
|
-
|
|
886
|
+
protected getCapabilityId(): BrowserCapabilityId;
|
|
785
887
|
getSnapshot(): OrientationInfo;
|
|
786
888
|
get isPortrait(): boolean;
|
|
787
889
|
get isLandscape(): boolean;
|
|
@@ -794,6 +896,8 @@ declare class ScreenOrientationService extends BrowserApiBaseService {
|
|
|
794
896
|
|
|
795
897
|
declare class FullscreenService extends BrowserApiBaseService {
|
|
796
898
|
protected getApiName(): string;
|
|
899
|
+
protected getCapabilityId(): BrowserCapabilityId;
|
|
900
|
+
/** Override to also check the *enabled* flag (browser may have disabled fullscreen). */
|
|
797
901
|
isSupported(): boolean;
|
|
798
902
|
get isFullscreen(): boolean;
|
|
799
903
|
get fullscreenElement(): Element | null;
|
|
@@ -823,6 +927,8 @@ interface FileSaveOptions {
|
|
|
823
927
|
}
|
|
824
928
|
declare class FileSystemAccessService extends BrowserApiBaseService {
|
|
825
929
|
protected getApiName(): string;
|
|
930
|
+
protected getCapabilityId(): BrowserCapabilityId;
|
|
931
|
+
/** Override to also assert secure context (required by the spec). */
|
|
826
932
|
isSupported(): boolean;
|
|
827
933
|
private get win();
|
|
828
934
|
protected ensureSupported(): void;
|
|
@@ -860,7 +966,7 @@ declare class MediaRecorderService extends BrowserApiBaseService {
|
|
|
860
966
|
private readonly dataSubject;
|
|
861
967
|
private readonly stateSubject;
|
|
862
968
|
protected getApiName(): string;
|
|
863
|
-
|
|
969
|
+
protected getCapabilityId(): BrowserCapabilityId;
|
|
864
970
|
get state(): RecordingState;
|
|
865
971
|
static isTypeSupported(mimeType: string): boolean;
|
|
866
972
|
watchState(): Observable<RecordingState>;
|
|
@@ -888,7 +994,7 @@ interface SSEConfig {
|
|
|
888
994
|
declare class ServerSentEventsService extends ConnectionRegistryBaseService<EventSource> {
|
|
889
995
|
protected getApiName(): string;
|
|
890
996
|
protected closeNativeConnection(source: EventSource): void;
|
|
891
|
-
|
|
997
|
+
protected getCapabilityId(): BrowserCapabilityId;
|
|
892
998
|
private ensureSSESupported;
|
|
893
999
|
connect<T = unknown>(url: string, config?: SSEConfig): Observable<SSEMessage<T>>;
|
|
894
1000
|
disconnect(url: string): void;
|
|
@@ -909,7 +1015,7 @@ interface VibrationPreset {
|
|
|
909
1015
|
declare class VibrationService extends BrowserApiBaseService {
|
|
910
1016
|
protected getApiName(): string;
|
|
911
1017
|
readonly presets: VibrationPreset;
|
|
912
|
-
|
|
1018
|
+
protected getCapabilityId(): BrowserCapabilityId;
|
|
913
1019
|
vibrate(pattern?: VibrationPattern): boolean;
|
|
914
1020
|
success(): boolean;
|
|
915
1021
|
error(): boolean;
|
|
@@ -930,7 +1036,7 @@ interface SpeechOptions {
|
|
|
930
1036
|
}
|
|
931
1037
|
declare class SpeechSynthesisService extends BrowserApiBaseService {
|
|
932
1038
|
protected getApiName(): string;
|
|
933
|
-
|
|
1039
|
+
protected getCapabilityId(): BrowserCapabilityId;
|
|
934
1040
|
private ensureSpeechSynthesisSupported;
|
|
935
1041
|
get state(): SpeechState;
|
|
936
1042
|
get isPending(): boolean;
|
|
@@ -956,7 +1062,7 @@ interface MutationObserverOptions {
|
|
|
956
1062
|
|
|
957
1063
|
declare class MutationObserverService extends BrowserApiBaseService {
|
|
958
1064
|
protected getApiName(): string;
|
|
959
|
-
|
|
1065
|
+
protected getCapabilityId(): BrowserCapabilityId;
|
|
960
1066
|
observe(target: Node, options?: MutationObserverOptions): Observable<MutationRecord[]>;
|
|
961
1067
|
static ɵfac: i0.ɵɵFactoryDeclaration<MutationObserverService, never>;
|
|
962
1068
|
static ɵprov: i0.ɵɵInjectableDeclaration<MutationObserverService>;
|
|
@@ -971,7 +1077,7 @@ interface PerformanceObserverConfig {
|
|
|
971
1077
|
|
|
972
1078
|
declare class PerformanceObserverService extends BrowserApiBaseService {
|
|
973
1079
|
protected getApiName(): string;
|
|
974
|
-
|
|
1080
|
+
protected getCapabilityId(): BrowserCapabilityId;
|
|
975
1081
|
observe(config: PerformanceObserverConfig): Observable<PerformanceEntryList>;
|
|
976
1082
|
observeByType(type: PerformanceEntryType, buffered?: boolean): Observable<PerformanceEntryList>;
|
|
977
1083
|
getSupportedEntryTypes(): PerformanceEntryType[];
|
|
@@ -987,7 +1093,7 @@ interface AudioAnalyserData {
|
|
|
987
1093
|
declare class WebAudioService extends BrowserApiBaseService {
|
|
988
1094
|
protected getApiName(): string;
|
|
989
1095
|
private context;
|
|
990
|
-
|
|
1096
|
+
protected getCapabilityId(): BrowserCapabilityId;
|
|
991
1097
|
getContext(): AudioContext;
|
|
992
1098
|
resume(): Promise<void>;
|
|
993
1099
|
close(): Promise<void>;
|
|
@@ -1016,7 +1122,7 @@ interface GamepadState {
|
|
|
1016
1122
|
|
|
1017
1123
|
declare class GamepadService extends BrowserApiBaseService {
|
|
1018
1124
|
protected getApiName(): string;
|
|
1019
|
-
|
|
1125
|
+
protected getCapabilityId(): BrowserCapabilityId;
|
|
1020
1126
|
getSnapshot(index: number): GamepadState | null;
|
|
1021
1127
|
getConnectedGamepads(): GamepadState[];
|
|
1022
1128
|
watchConnections(): Observable<{
|
|
@@ -1101,7 +1207,7 @@ interface GeolocationCoordinates {
|
|
|
1101
1207
|
heading: number | null;
|
|
1102
1208
|
speed: number | null;
|
|
1103
1209
|
}
|
|
1104
|
-
interface GeolocationOptions {
|
|
1210
|
+
interface GeolocationOptions$1 {
|
|
1105
1211
|
enableHighAccuracy?: boolean;
|
|
1106
1212
|
timeout?: number;
|
|
1107
1213
|
maximumAge?: number;
|
|
@@ -1113,7 +1219,7 @@ interface GeolocationError {
|
|
|
1113
1219
|
POSITION_UNAVAILABLE: number;
|
|
1114
1220
|
TIMEOUT: number;
|
|
1115
1221
|
}
|
|
1116
|
-
interface GeolocationWatchOptions extends GeolocationOptions {
|
|
1222
|
+
interface GeolocationWatchOptions extends GeolocationOptions$1 {
|
|
1117
1223
|
maximumAge?: number;
|
|
1118
1224
|
}
|
|
1119
1225
|
|
|
@@ -1185,6 +1291,62 @@ interface GamepadRef {
|
|
|
1185
1291
|
}
|
|
1186
1292
|
declare function injectGamepad(index: number, intervalMs?: number): GamepadRef;
|
|
1187
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
|
+
|
|
1188
1350
|
declare class BrowserSupportUtil {
|
|
1189
1351
|
static isSupported(feature: string): boolean;
|
|
1190
1352
|
static getUnsupportedFeatures(): string[];
|
|
@@ -1305,5 +1467,5 @@ declare function provideBrowserWebApis(config?: BrowserWebApisConfig): Environme
|
|
|
1305
1467
|
|
|
1306
1468
|
declare const version = "0.1.0";
|
|
1307
1469
|
|
|
1308
|
-
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 };
|
|
1309
|
-
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, 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 };
|