@angular-helpers/browser-web-apis 21.5.0 → 21.7.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/fesm2022/angular-helpers-browser-web-apis-experimental.mjs +478 -0
- package/fesm2022/angular-helpers-browser-web-apis.mjs +671 -816
- package/package.json +5 -1
- package/types/angular-helpers-browser-web-apis-experimental.d.ts +325 -0
- package/types/angular-helpers-browser-web-apis.d.ts +205 -329
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-helpers/browser-web-apis",
|
|
3
|
-
"version": "21.
|
|
3
|
+
"version": "21.7.0",
|
|
4
4
|
"description": "Sistema de servicios Angular para acceso formalizado a Browser Web APIs (cámara, permisos, geolocalización, etc.)",
|
|
5
5
|
"homepage": "https://gaspar1992.github.io/angular-helpers/docs/browser-web-apis",
|
|
6
6
|
"repository": {
|
|
@@ -43,6 +43,10 @@
|
|
|
43
43
|
".": {
|
|
44
44
|
"types": "./types/angular-helpers-browser-web-apis.d.ts",
|
|
45
45
|
"default": "./fesm2022/angular-helpers-browser-web-apis.mjs"
|
|
46
|
+
},
|
|
47
|
+
"./experimental": {
|
|
48
|
+
"types": "./types/angular-helpers-browser-web-apis-experimental.d.ts",
|
|
49
|
+
"default": "./fesm2022/angular-helpers-browser-web-apis-experimental.mjs"
|
|
46
50
|
}
|
|
47
51
|
},
|
|
48
52
|
"dependencies": {
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { BrowserApiBaseService } from '@angular-helpers/browser-web-apis';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { Signal, EnvironmentProviders } from '@angular/core';
|
|
5
|
+
|
|
6
|
+
type UserIdleState = 'active' | 'idle';
|
|
7
|
+
type ScreenIdleState = 'locked' | 'unlocked';
|
|
8
|
+
interface IdleState {
|
|
9
|
+
user: UserIdleState;
|
|
10
|
+
screen: ScreenIdleState;
|
|
11
|
+
}
|
|
12
|
+
interface IdleDetectorOptions {
|
|
13
|
+
threshold?: number;
|
|
14
|
+
}
|
|
15
|
+
declare class IdleDetectorService extends BrowserApiBaseService {
|
|
16
|
+
protected getApiName(): string;
|
|
17
|
+
isSupported(): boolean;
|
|
18
|
+
requestPermission(): Promise<PermissionState>;
|
|
19
|
+
watch(options?: IdleDetectorOptions): Observable<IdleState>;
|
|
20
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<IdleDetectorService, never>;
|
|
21
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<IdleDetectorService>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface ColorSelectionResult {
|
|
25
|
+
sRGBHex: string;
|
|
26
|
+
}
|
|
27
|
+
declare class EyeDropperService extends BrowserApiBaseService {
|
|
28
|
+
protected getApiName(): string;
|
|
29
|
+
isSupported(): boolean;
|
|
30
|
+
open(): Promise<ColorSelectionResult>;
|
|
31
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<EyeDropperService, never>;
|
|
32
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<EyeDropperService>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type BarcodeFormat = 'aztec' | 'code_128' | 'code_39' | 'code_93' | 'codabar' | 'data_matrix' | 'ean_13' | 'ean_8' | 'itf' | 'pdf417' | 'qr_code' | 'upc_a' | 'upc_e' | 'unknown';
|
|
36
|
+
interface DetectedBarcode {
|
|
37
|
+
boundingBox: DOMRectReadOnly;
|
|
38
|
+
cornerPoints: Array<{
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
}>;
|
|
42
|
+
format: BarcodeFormat;
|
|
43
|
+
rawValue: string;
|
|
44
|
+
}
|
|
45
|
+
declare class BarcodeDetectorService extends BrowserApiBaseService {
|
|
46
|
+
protected getApiName(): string;
|
|
47
|
+
isSupported(): boolean;
|
|
48
|
+
getSupportedFormats(): Promise<BarcodeFormat[]>;
|
|
49
|
+
detect(source: ImageBitmapSource, formats?: BarcodeFormat[]): Promise<DetectedBarcode[]>;
|
|
50
|
+
detectStream(video: HTMLVideoElement, options?: {
|
|
51
|
+
formats?: BarcodeFormat[];
|
|
52
|
+
interval?: number;
|
|
53
|
+
}): Observable<DetectedBarcode[]>;
|
|
54
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<BarcodeDetectorService, never>;
|
|
55
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<BarcodeDetectorService>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface BluetoothRequestDeviceOptions {
|
|
59
|
+
filters?: Array<{
|
|
60
|
+
services?: string[];
|
|
61
|
+
name?: string;
|
|
62
|
+
namePrefix?: string;
|
|
63
|
+
}>;
|
|
64
|
+
optionalServices?: string[];
|
|
65
|
+
acceptAllDevices?: boolean;
|
|
66
|
+
}
|
|
67
|
+
interface BluetoothRemoteGATTServer {
|
|
68
|
+
readonly connected: boolean;
|
|
69
|
+
readonly device: BluetoothDeviceRef;
|
|
70
|
+
connect(): Promise<BluetoothRemoteGATTServer>;
|
|
71
|
+
disconnect(): void;
|
|
72
|
+
getPrimaryService(service: string): Promise<BluetoothRemoteGATTService>;
|
|
73
|
+
}
|
|
74
|
+
interface BluetoothRemoteGATTService {
|
|
75
|
+
getCharacteristic(characteristic: string): Promise<BluetoothRemoteGATTCharacteristic>;
|
|
76
|
+
}
|
|
77
|
+
interface BluetoothRemoteGATTCharacteristic extends EventTarget {
|
|
78
|
+
readonly value: DataView | null;
|
|
79
|
+
readValue(): Promise<DataView>;
|
|
80
|
+
writeValue(value: BufferSource): Promise<void>;
|
|
81
|
+
startNotifications(): Promise<BluetoothRemoteGATTCharacteristic>;
|
|
82
|
+
stopNotifications(): Promise<BluetoothRemoteGATTCharacteristic>;
|
|
83
|
+
}
|
|
84
|
+
interface BluetoothDeviceRef extends EventTarget {
|
|
85
|
+
readonly id: string;
|
|
86
|
+
readonly name: string | undefined;
|
|
87
|
+
readonly gatt: BluetoothRemoteGATTServer | undefined;
|
|
88
|
+
}
|
|
89
|
+
interface BluetoothApi {
|
|
90
|
+
requestDevice(options: BluetoothRequestDeviceOptions): Promise<BluetoothDeviceRef>;
|
|
91
|
+
}
|
|
92
|
+
interface UsbDeviceRef {
|
|
93
|
+
readonly vendorId: number;
|
|
94
|
+
readonly productId: number;
|
|
95
|
+
readonly productName: string | undefined;
|
|
96
|
+
readonly manufacturerName: string | undefined;
|
|
97
|
+
readonly serialNumber: string | undefined;
|
|
98
|
+
readonly opened: boolean;
|
|
99
|
+
open(): Promise<void>;
|
|
100
|
+
close(): Promise<void>;
|
|
101
|
+
selectConfiguration(configurationValue: number): Promise<void>;
|
|
102
|
+
claimInterface(interfaceNumber: number): Promise<void>;
|
|
103
|
+
releaseInterface(interfaceNumber: number): Promise<void>;
|
|
104
|
+
transferIn(endpointNumber: number, length: number): Promise<UsbTransferResult>;
|
|
105
|
+
transferOut(endpointNumber: number, data: BufferSource): Promise<UsbTransferResult>;
|
|
106
|
+
}
|
|
107
|
+
interface UsbTransferResult {
|
|
108
|
+
readonly data: DataView | undefined;
|
|
109
|
+
readonly status: 'ok' | 'stall' | 'babble';
|
|
110
|
+
}
|
|
111
|
+
interface UsbApi {
|
|
112
|
+
requestDevice(options: {
|
|
113
|
+
filters: UsbDeviceFilterDef[];
|
|
114
|
+
}): Promise<UsbDeviceRef>;
|
|
115
|
+
getDevices(): Promise<UsbDeviceRef[]>;
|
|
116
|
+
addEventListener(type: string, listener: (event: {
|
|
117
|
+
device: UsbDeviceRef;
|
|
118
|
+
}) => void): void;
|
|
119
|
+
removeEventListener(type: string, listener: (event: {
|
|
120
|
+
device: UsbDeviceRef;
|
|
121
|
+
}) => void): void;
|
|
122
|
+
}
|
|
123
|
+
interface UsbDeviceFilterDef {
|
|
124
|
+
vendorId?: number;
|
|
125
|
+
productId?: number;
|
|
126
|
+
classCode?: number;
|
|
127
|
+
subclassCode?: number;
|
|
128
|
+
protocolCode?: number;
|
|
129
|
+
serialNumber?: string;
|
|
130
|
+
}
|
|
131
|
+
interface NdefMessage {
|
|
132
|
+
records: NdefRecord[];
|
|
133
|
+
}
|
|
134
|
+
interface NdefRecord {
|
|
135
|
+
recordType: string;
|
|
136
|
+
mediaType?: string;
|
|
137
|
+
id?: string;
|
|
138
|
+
data?: DataView;
|
|
139
|
+
encoding?: string;
|
|
140
|
+
lang?: string;
|
|
141
|
+
}
|
|
142
|
+
interface NdefReadingEvent {
|
|
143
|
+
serialNumber: string;
|
|
144
|
+
message: NdefMessage;
|
|
145
|
+
}
|
|
146
|
+
interface NdefWriteOptions {
|
|
147
|
+
overwrite?: boolean;
|
|
148
|
+
signal?: AbortSignal;
|
|
149
|
+
}
|
|
150
|
+
interface NdefScanOptions {
|
|
151
|
+
signal?: AbortSignal;
|
|
152
|
+
}
|
|
153
|
+
interface NdefReaderInstance extends EventTarget {
|
|
154
|
+
scan(options?: NdefScanOptions): Promise<void>;
|
|
155
|
+
write(message: NdefMessage | string, options?: NdefWriteOptions): Promise<void>;
|
|
156
|
+
}
|
|
157
|
+
interface NdefReaderConstructor {
|
|
158
|
+
new (): NdefReaderInstance;
|
|
159
|
+
}
|
|
160
|
+
interface NavigatorWithExperimentalApis extends Navigator {
|
|
161
|
+
bluetooth?: BluetoothApi;
|
|
162
|
+
usb?: UsbApi;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
declare class WebBluetoothService extends BrowserApiBaseService {
|
|
166
|
+
protected getApiName(): string;
|
|
167
|
+
isSupported(): boolean;
|
|
168
|
+
requestDevice(options?: BluetoothRequestDeviceOptions): Promise<BluetoothDeviceRef>;
|
|
169
|
+
getConnectedDevices(): Promise<BluetoothDeviceRef[]>;
|
|
170
|
+
watchConnectionChanges(): Observable<{
|
|
171
|
+
device: BluetoothDeviceRef;
|
|
172
|
+
connected: boolean;
|
|
173
|
+
}>;
|
|
174
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<WebBluetoothService, never>;
|
|
175
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<WebBluetoothService>;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
declare class WebUsbService extends BrowserApiBaseService {
|
|
179
|
+
protected getApiName(): string;
|
|
180
|
+
isSupported(): boolean;
|
|
181
|
+
requestDevice(filters: UsbDeviceFilterDef[]): Promise<UsbDeviceRef>;
|
|
182
|
+
getDevices(): Promise<UsbDeviceRef[]>;
|
|
183
|
+
watchDeviceChanges(): Observable<{
|
|
184
|
+
device: UsbDeviceRef;
|
|
185
|
+
type: 'connect' | 'disconnect';
|
|
186
|
+
}>;
|
|
187
|
+
getDeviceInfo(device: UsbDeviceRef): {
|
|
188
|
+
vendorId: number;
|
|
189
|
+
productId: number;
|
|
190
|
+
productName: string | undefined;
|
|
191
|
+
manufacturerName: string | undefined;
|
|
192
|
+
serialNumber: string | undefined;
|
|
193
|
+
opened: boolean;
|
|
194
|
+
};
|
|
195
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<WebUsbService, never>;
|
|
196
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<WebUsbService>;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
declare class WebNfcService extends BrowserApiBaseService {
|
|
200
|
+
protected getApiName(): string;
|
|
201
|
+
isSupported(): boolean;
|
|
202
|
+
scan(): Observable<NdefReadingEvent>;
|
|
203
|
+
write(message: NdefMessage | string, options?: NdefWriteOptions): Promise<void>;
|
|
204
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<WebNfcService, never>;
|
|
205
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<WebNfcService>;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
interface PaymentMethodConfig {
|
|
209
|
+
supportedMethods: string;
|
|
210
|
+
data?: Record<string, unknown>;
|
|
211
|
+
}
|
|
212
|
+
interface PaymentDetailsInit {
|
|
213
|
+
total: {
|
|
214
|
+
label: string;
|
|
215
|
+
amount: {
|
|
216
|
+
currency: string;
|
|
217
|
+
value: string;
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
displayItems?: Array<{
|
|
221
|
+
label: string;
|
|
222
|
+
amount: {
|
|
223
|
+
currency: string;
|
|
224
|
+
value: string;
|
|
225
|
+
};
|
|
226
|
+
}>;
|
|
227
|
+
}
|
|
228
|
+
interface PaymentOptionsConfig {
|
|
229
|
+
requestPayerName?: boolean;
|
|
230
|
+
requestPayerEmail?: boolean;
|
|
231
|
+
requestPayerPhone?: boolean;
|
|
232
|
+
requestShipping?: boolean;
|
|
233
|
+
}
|
|
234
|
+
interface PaymentResult {
|
|
235
|
+
methodName: string;
|
|
236
|
+
details: Record<string, unknown>;
|
|
237
|
+
payerName: string | null;
|
|
238
|
+
payerEmail: string | null;
|
|
239
|
+
payerPhone: string | null;
|
|
240
|
+
}
|
|
241
|
+
declare class PaymentRequestService extends BrowserApiBaseService {
|
|
242
|
+
protected getApiName(): string;
|
|
243
|
+
isSupported(): boolean;
|
|
244
|
+
canMakePayment(methods: PaymentMethodConfig[], details: PaymentDetailsInit): Promise<boolean>;
|
|
245
|
+
show(methods: PaymentMethodConfig[], details: PaymentDetailsInit, options?: PaymentOptionsConfig): Promise<PaymentResult>;
|
|
246
|
+
abort(methods: PaymentMethodConfig[], details: PaymentDetailsInit): Promise<void>;
|
|
247
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PaymentRequestService, never>;
|
|
248
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<PaymentRequestService>;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
interface PasswordCredentialData {
|
|
252
|
+
id: string;
|
|
253
|
+
password: string;
|
|
254
|
+
name?: string;
|
|
255
|
+
iconURL?: string;
|
|
256
|
+
}
|
|
257
|
+
interface PublicKeyCredentialOptions {
|
|
258
|
+
challenge: BufferSource;
|
|
259
|
+
rp: {
|
|
260
|
+
name: string;
|
|
261
|
+
id?: string;
|
|
262
|
+
};
|
|
263
|
+
user: {
|
|
264
|
+
id: BufferSource;
|
|
265
|
+
name: string;
|
|
266
|
+
displayName: string;
|
|
267
|
+
};
|
|
268
|
+
pubKeyCredParams: Array<{
|
|
269
|
+
type: 'public-key';
|
|
270
|
+
alg: number;
|
|
271
|
+
}>;
|
|
272
|
+
timeout?: number;
|
|
273
|
+
attestation?: AttestationConveyancePreference;
|
|
274
|
+
authenticatorSelection?: AuthenticatorSelectionCriteria;
|
|
275
|
+
}
|
|
276
|
+
interface CredentialResult {
|
|
277
|
+
id: string;
|
|
278
|
+
type: string;
|
|
279
|
+
}
|
|
280
|
+
declare class CredentialManagementService extends BrowserApiBaseService {
|
|
281
|
+
protected getApiName(): string;
|
|
282
|
+
isSupported(): boolean;
|
|
283
|
+
isPublicKeySupported(): boolean;
|
|
284
|
+
get(options?: CredentialRequestOptions): Promise<Credential | null>;
|
|
285
|
+
store(credential: Credential): Promise<void>;
|
|
286
|
+
createPasswordCredential(data: PasswordCredentialData): Promise<Credential>;
|
|
287
|
+
createPublicKeyCredential(options: PublicKeyCredentialOptions): Promise<Credential | null>;
|
|
288
|
+
preventSilentAccess(): Promise<void>;
|
|
289
|
+
isConditionalMediationAvailable(): Promise<boolean>;
|
|
290
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CredentialManagementService, never>;
|
|
291
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<CredentialManagementService>;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
interface IdleDetectorRef {
|
|
295
|
+
readonly state: Signal<IdleState>;
|
|
296
|
+
readonly userState: Signal<UserIdleState>;
|
|
297
|
+
readonly screenState: Signal<ScreenIdleState>;
|
|
298
|
+
readonly isUserIdle: Signal<boolean>;
|
|
299
|
+
readonly isScreenLocked: Signal<boolean>;
|
|
300
|
+
}
|
|
301
|
+
declare function injectIdleDetector(options?: IdleDetectorOptions): IdleDetectorRef;
|
|
302
|
+
|
|
303
|
+
declare function provideIdleDetector(): EnvironmentProviders;
|
|
304
|
+
declare function provideEyeDropper(): EnvironmentProviders;
|
|
305
|
+
declare function provideBarcodeDetector(): EnvironmentProviders;
|
|
306
|
+
declare function provideWebBluetooth(): EnvironmentProviders;
|
|
307
|
+
declare function provideWebUsb(): EnvironmentProviders;
|
|
308
|
+
declare function provideWebNfc(): EnvironmentProviders;
|
|
309
|
+
declare function providePaymentRequest(): EnvironmentProviders;
|
|
310
|
+
declare function provideCredentialManagement(): EnvironmentProviders;
|
|
311
|
+
interface ExperimentalWebApisConfig {
|
|
312
|
+
enableIdleDetector?: boolean;
|
|
313
|
+
enableEyeDropper?: boolean;
|
|
314
|
+
enableBarcodeDetector?: boolean;
|
|
315
|
+
enableWebBluetooth?: boolean;
|
|
316
|
+
enableWebUsb?: boolean;
|
|
317
|
+
enableWebNfc?: boolean;
|
|
318
|
+
enablePaymentRequest?: boolean;
|
|
319
|
+
enableCredentialManagement?: boolean;
|
|
320
|
+
}
|
|
321
|
+
declare const defaultExperimentalWebApisConfig: ExperimentalWebApisConfig;
|
|
322
|
+
declare function provideExperimentalWebApis(config?: ExperimentalWebApisConfig): EnvironmentProviders;
|
|
323
|
+
|
|
324
|
+
export { BarcodeDetectorService, CredentialManagementService, EyeDropperService, IdleDetectorService, PaymentRequestService, WebBluetoothService, WebNfcService, WebUsbService, defaultExperimentalWebApisConfig, injectIdleDetector, provideBarcodeDetector, provideCredentialManagement, provideExperimentalWebApis, provideEyeDropper, provideIdleDetector, providePaymentRequest, provideWebBluetooth, provideWebNfc, provideWebUsb };
|
|
325
|
+
export type { BarcodeFormat, BluetoothApi, BluetoothDeviceRef, BluetoothRemoteGATTCharacteristic, BluetoothRemoteGATTServer, BluetoothRemoteGATTService, BluetoothRequestDeviceOptions, ColorSelectionResult, CredentialResult, DetectedBarcode, ExperimentalWebApisConfig, IdleDetectorOptions, IdleDetectorRef, IdleState, NavigatorWithExperimentalApis, NdefMessage, NdefReaderConstructor, NdefReaderInstance, NdefReadingEvent, NdefRecord, NdefScanOptions, NdefWriteOptions, PasswordCredentialData, PaymentDetailsInit, PaymentMethodConfig, PaymentOptionsConfig, PaymentResult, PublicKeyCredentialOptions, ScreenIdleState, UsbApi, UsbDeviceFilterDef, UsbDeviceRef, UsbTransferResult, UserIdleState };
|