@capgo/capacitor-device-info 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapgoCapacitorDeviceInfo.podspec +17 -0
- package/LICENSE +373 -0
- package/Package.swift +28 -0
- package/README.md +426 -0
- package/android/build.gradle +59 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/app/capgo/deviceinfo/DeviceInfo.java +765 -0
- package/android/src/main/java/app/capgo/deviceinfo/DeviceInfoPlugin.java +195 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +1285 -0
- package/dist/esm/definitions.d.ts +612 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +29 -0
- package/dist/esm/web.js +182 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +196 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +199 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/DeviceInfoPlugin/DeviceInfo.swift +279 -0
- package/ios/Sources/DeviceInfoPlugin/DeviceInfoPlugin.swift +157 -0
- package/ios/Tests/DeviceInfoPluginTests/DeviceInfoTests.swift +22 -0
- package/package.json +95 -0
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
import type { PluginListenerHandle } from '@capacitor/core';
|
|
2
|
+
/**
|
|
3
|
+
* CPU snapshot for the current device.
|
|
4
|
+
*
|
|
5
|
+
* All frequency values are reported in hertz. `usagePercent` is `null` when a
|
|
6
|
+
* platform needs at least two samples to calculate CPU usage.
|
|
7
|
+
*
|
|
8
|
+
* @since 8.0.0
|
|
9
|
+
*/
|
|
10
|
+
export interface CpuInfo {
|
|
11
|
+
/**
|
|
12
|
+
* Total logical CPU cores visible to the app.
|
|
13
|
+
*
|
|
14
|
+
* @since 8.0.0
|
|
15
|
+
*/
|
|
16
|
+
cores: number;
|
|
17
|
+
/**
|
|
18
|
+
* Logical CPU cores currently active, when the platform exposes it.
|
|
19
|
+
*
|
|
20
|
+
* @since 8.0.0
|
|
21
|
+
*/
|
|
22
|
+
activeCores?: number;
|
|
23
|
+
/**
|
|
24
|
+
* CPU architecture, for example `arm64` or `x86_64`.
|
|
25
|
+
*
|
|
26
|
+
* @since 8.0.0
|
|
27
|
+
*/
|
|
28
|
+
architecture?: string;
|
|
29
|
+
/**
|
|
30
|
+
* CPU or SoC model identifier when available.
|
|
31
|
+
*
|
|
32
|
+
* @since 8.0.0
|
|
33
|
+
*/
|
|
34
|
+
model?: string;
|
|
35
|
+
/**
|
|
36
|
+
* System CPU usage from 0 to 100.
|
|
37
|
+
*
|
|
38
|
+
* @since 8.0.0
|
|
39
|
+
*/
|
|
40
|
+
usagePercent?: number | null;
|
|
41
|
+
/**
|
|
42
|
+
* Highest CPU frequency exposed by the platform.
|
|
43
|
+
*
|
|
44
|
+
* @since 8.0.0
|
|
45
|
+
*/
|
|
46
|
+
maxFrequencyHz?: number;
|
|
47
|
+
/**
|
|
48
|
+
* CPU temperature in Celsius when the platform exposes an onboard thermal sensor.
|
|
49
|
+
*
|
|
50
|
+
* Android reads this as a best-effort value from device thermal zones. iOS does
|
|
51
|
+
* not expose raw CPU temperature through public APIs.
|
|
52
|
+
*
|
|
53
|
+
* @since 8.0.0
|
|
54
|
+
*/
|
|
55
|
+
temperatureCelsius?: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Memory snapshot for the current device and app process.
|
|
59
|
+
*
|
|
60
|
+
* All size values are reported in bytes.
|
|
61
|
+
*
|
|
62
|
+
* @since 8.0.0
|
|
63
|
+
*/
|
|
64
|
+
export interface MemoryInfo {
|
|
65
|
+
/**
|
|
66
|
+
* Total physical memory on the device.
|
|
67
|
+
*
|
|
68
|
+
* @since 8.0.0
|
|
69
|
+
*/
|
|
70
|
+
totalBytes?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Memory available to the system.
|
|
73
|
+
*
|
|
74
|
+
* @since 8.0.0
|
|
75
|
+
*/
|
|
76
|
+
freeBytes?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Memory currently used by the system.
|
|
79
|
+
*
|
|
80
|
+
* @since 8.0.0
|
|
81
|
+
*/
|
|
82
|
+
usedBytes?: number;
|
|
83
|
+
/**
|
|
84
|
+
* Memory usage from 0 to 100.
|
|
85
|
+
*
|
|
86
|
+
* @since 8.0.0
|
|
87
|
+
*/
|
|
88
|
+
usedPercent?: number;
|
|
89
|
+
/**
|
|
90
|
+
* Memory used by the current app process.
|
|
91
|
+
*
|
|
92
|
+
* @since 8.0.0
|
|
93
|
+
*/
|
|
94
|
+
appUsedBytes?: number;
|
|
95
|
+
/**
|
|
96
|
+
* Heap limit visible to the current app process.
|
|
97
|
+
*
|
|
98
|
+
* @since 8.0.0
|
|
99
|
+
*/
|
|
100
|
+
appLimitBytes?: number;
|
|
101
|
+
/**
|
|
102
|
+
* Whether the OS currently reports low-memory pressure.
|
|
103
|
+
*
|
|
104
|
+
* @since 8.0.0
|
|
105
|
+
*/
|
|
106
|
+
lowMemory?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Platform memory pressure label.
|
|
109
|
+
*
|
|
110
|
+
* @since 8.0.0
|
|
111
|
+
*/
|
|
112
|
+
pressure?: 'normal' | 'warning' | 'critical' | 'unknown';
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Storage snapshot for the app data volume.
|
|
116
|
+
*
|
|
117
|
+
* All size values are reported in bytes.
|
|
118
|
+
*
|
|
119
|
+
* @since 8.0.0
|
|
120
|
+
*/
|
|
121
|
+
export interface StorageInfo {
|
|
122
|
+
/**
|
|
123
|
+
* Total bytes on the app data volume.
|
|
124
|
+
*
|
|
125
|
+
* @since 8.0.0
|
|
126
|
+
*/
|
|
127
|
+
totalBytes?: number;
|
|
128
|
+
/**
|
|
129
|
+
* Free bytes on the app data volume.
|
|
130
|
+
*
|
|
131
|
+
* @since 8.0.0
|
|
132
|
+
*/
|
|
133
|
+
freeBytes?: number;
|
|
134
|
+
/**
|
|
135
|
+
* Used bytes on the app data volume.
|
|
136
|
+
*
|
|
137
|
+
* @since 8.0.0
|
|
138
|
+
*/
|
|
139
|
+
usedBytes?: number;
|
|
140
|
+
/**
|
|
141
|
+
* Storage usage from 0 to 100.
|
|
142
|
+
*
|
|
143
|
+
* @since 8.0.0
|
|
144
|
+
*/
|
|
145
|
+
usedPercent?: number;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* GPU snapshot for the primary graphics device.
|
|
149
|
+
*
|
|
150
|
+
* @since 8.0.0
|
|
151
|
+
*/
|
|
152
|
+
export interface GpuInfo {
|
|
153
|
+
/**
|
|
154
|
+
* Graphics API used to query the GPU.
|
|
155
|
+
*
|
|
156
|
+
* @since 8.0.0
|
|
157
|
+
*/
|
|
158
|
+
api?: 'metal' | 'opengl' | 'webgl' | 'unknown';
|
|
159
|
+
/**
|
|
160
|
+
* GPU vendor when available.
|
|
161
|
+
*
|
|
162
|
+
* @since 8.0.0
|
|
163
|
+
*/
|
|
164
|
+
vendor?: string;
|
|
165
|
+
/**
|
|
166
|
+
* GPU renderer or model name when available.
|
|
167
|
+
*
|
|
168
|
+
* @since 8.0.0
|
|
169
|
+
*/
|
|
170
|
+
renderer?: string;
|
|
171
|
+
/**
|
|
172
|
+
* Graphics API version string when available.
|
|
173
|
+
*
|
|
174
|
+
* @since 8.0.0
|
|
175
|
+
*/
|
|
176
|
+
version?: string;
|
|
177
|
+
/**
|
|
178
|
+
* Maximum texture size reported by the graphics API.
|
|
179
|
+
*
|
|
180
|
+
* @since 8.0.0
|
|
181
|
+
*/
|
|
182
|
+
maxTextureSize?: number;
|
|
183
|
+
/**
|
|
184
|
+
* GPU temperature in Celsius when the platform exposes an onboard thermal sensor.
|
|
185
|
+
*
|
|
186
|
+
* Android reads this as a best-effort value from device thermal zones. iOS does
|
|
187
|
+
* not expose raw GPU temperature through public APIs.
|
|
188
|
+
*
|
|
189
|
+
* @since 8.0.0
|
|
190
|
+
*/
|
|
191
|
+
temperatureCelsius?: number;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Thermal state reported by the platform.
|
|
195
|
+
*
|
|
196
|
+
* @since 8.0.0
|
|
197
|
+
*/
|
|
198
|
+
export type ThermalState = 'nominal' | 'fair' | 'serious' | 'critical' | 'unknown';
|
|
199
|
+
/**
|
|
200
|
+
* Description of an onboard hardware sensor exposed by the platform.
|
|
201
|
+
*
|
|
202
|
+
* @since 8.0.0
|
|
203
|
+
*/
|
|
204
|
+
export interface OnboardSensorDescriptor {
|
|
205
|
+
/**
|
|
206
|
+
* Stable sensor type label, for example `pressure`, `ambientTemperature`, or `accelerometer`.
|
|
207
|
+
*
|
|
208
|
+
* @since 8.0.0
|
|
209
|
+
*/
|
|
210
|
+
type: string;
|
|
211
|
+
/**
|
|
212
|
+
* Platform sensor name when available.
|
|
213
|
+
*
|
|
214
|
+
* @since 8.0.0
|
|
215
|
+
*/
|
|
216
|
+
name?: string;
|
|
217
|
+
/**
|
|
218
|
+
* Sensor vendor when available.
|
|
219
|
+
*
|
|
220
|
+
* @since 8.0.0
|
|
221
|
+
*/
|
|
222
|
+
vendor?: string;
|
|
223
|
+
/**
|
|
224
|
+
* Android sensor type id when available.
|
|
225
|
+
*
|
|
226
|
+
* @since 8.0.0
|
|
227
|
+
*/
|
|
228
|
+
platformType?: number;
|
|
229
|
+
/**
|
|
230
|
+
* Maximum sensor range when available.
|
|
231
|
+
*
|
|
232
|
+
* @since 8.0.0
|
|
233
|
+
*/
|
|
234
|
+
maximumRange?: number;
|
|
235
|
+
/**
|
|
236
|
+
* Sensor resolution when available.
|
|
237
|
+
*
|
|
238
|
+
* @since 8.0.0
|
|
239
|
+
*/
|
|
240
|
+
resolution?: number;
|
|
241
|
+
/**
|
|
242
|
+
* Sensor power draw in milliamps when available.
|
|
243
|
+
*
|
|
244
|
+
* @since 8.0.0
|
|
245
|
+
*/
|
|
246
|
+
powerMilliamp?: number;
|
|
247
|
+
/**
|
|
248
|
+
* Minimum sensor delay in microseconds when available.
|
|
249
|
+
*
|
|
250
|
+
* @since 8.0.0
|
|
251
|
+
*/
|
|
252
|
+
minDelayMicroseconds?: number;
|
|
253
|
+
/**
|
|
254
|
+
* Whether this is a wake-up sensor when available.
|
|
255
|
+
*
|
|
256
|
+
* @since 8.0.0
|
|
257
|
+
*/
|
|
258
|
+
wakeUp?: boolean;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Instant onboard sensor reading.
|
|
262
|
+
*
|
|
263
|
+
* @since 8.0.0
|
|
264
|
+
*/
|
|
265
|
+
export interface OnboardSensorReading {
|
|
266
|
+
/**
|
|
267
|
+
* Stable sensor type label.
|
|
268
|
+
*
|
|
269
|
+
* @since 8.0.0
|
|
270
|
+
*/
|
|
271
|
+
type: string;
|
|
272
|
+
/**
|
|
273
|
+
* Human-readable unit, for example `celsius`, `percent`, `hPa`, `lux`, or `cm`.
|
|
274
|
+
*
|
|
275
|
+
* @since 8.0.0
|
|
276
|
+
*/
|
|
277
|
+
unit: string;
|
|
278
|
+
/**
|
|
279
|
+
* Sensor value.
|
|
280
|
+
*
|
|
281
|
+
* @since 8.0.0
|
|
282
|
+
*/
|
|
283
|
+
value: number;
|
|
284
|
+
/**
|
|
285
|
+
* Platform sensor name when available.
|
|
286
|
+
*
|
|
287
|
+
* @since 8.0.0
|
|
288
|
+
*/
|
|
289
|
+
name?: string;
|
|
290
|
+
/**
|
|
291
|
+
* Reading timestamp as Unix epoch milliseconds.
|
|
292
|
+
*
|
|
293
|
+
* @since 8.0.0
|
|
294
|
+
*/
|
|
295
|
+
timestamp?: number;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Onboard sensors snapshot.
|
|
299
|
+
*
|
|
300
|
+
* This only reports hardware sensors exposed by the device or operating system.
|
|
301
|
+
* It does not fetch weather data or any external temperature/humidity source.
|
|
302
|
+
*
|
|
303
|
+
* @since 8.0.0
|
|
304
|
+
*/
|
|
305
|
+
export interface OnboardSensorsInfo {
|
|
306
|
+
/**
|
|
307
|
+
* Sensors available to the app.
|
|
308
|
+
*
|
|
309
|
+
* @since 8.0.0
|
|
310
|
+
*/
|
|
311
|
+
availableSensors?: OnboardSensorDescriptor[];
|
|
312
|
+
/**
|
|
313
|
+
* Instant sensor readings captured for common environmental sensors.
|
|
314
|
+
*
|
|
315
|
+
* @since 8.0.0
|
|
316
|
+
*/
|
|
317
|
+
readings?: OnboardSensorReading[];
|
|
318
|
+
/**
|
|
319
|
+
* Battery temperature in Celsius when available.
|
|
320
|
+
*
|
|
321
|
+
* @since 8.0.0
|
|
322
|
+
*/
|
|
323
|
+
batteryTemperatureCelsius?: number;
|
|
324
|
+
/**
|
|
325
|
+
* Ambient air temperature from an onboard sensor in Celsius when available.
|
|
326
|
+
*
|
|
327
|
+
* @since 8.0.0
|
|
328
|
+
*/
|
|
329
|
+
ambientTemperatureCelsius?: number;
|
|
330
|
+
/**
|
|
331
|
+
* Relative humidity from an onboard sensor as a percentage when available.
|
|
332
|
+
*
|
|
333
|
+
* @since 8.0.0
|
|
334
|
+
*/
|
|
335
|
+
relativeHumidityPercent?: number;
|
|
336
|
+
/**
|
|
337
|
+
* Atmospheric pressure from an onboard barometer in hectopascals when available.
|
|
338
|
+
*
|
|
339
|
+
* @since 8.0.0
|
|
340
|
+
*/
|
|
341
|
+
pressureHpa?: number;
|
|
342
|
+
/**
|
|
343
|
+
* Ambient light from an onboard light sensor in lux when available.
|
|
344
|
+
*
|
|
345
|
+
* @since 8.0.0
|
|
346
|
+
*/
|
|
347
|
+
illuminanceLux?: number;
|
|
348
|
+
/**
|
|
349
|
+
* Proximity distance from an onboard proximity sensor in centimeters when available.
|
|
350
|
+
*
|
|
351
|
+
* @since 8.0.0
|
|
352
|
+
*/
|
|
353
|
+
proximityDistanceCm?: number;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Instant device snapshot returned by {@link DeviceInfoPlugin.getInfo}.
|
|
357
|
+
*
|
|
358
|
+
* @since 8.0.0
|
|
359
|
+
*/
|
|
360
|
+
export interface DeviceInfoSnapshot {
|
|
361
|
+
/**
|
|
362
|
+
* Snapshot timestamp as Unix epoch milliseconds.
|
|
363
|
+
*
|
|
364
|
+
* @since 8.0.0
|
|
365
|
+
*/
|
|
366
|
+
timestamp: number;
|
|
367
|
+
/**
|
|
368
|
+
* Platform implementation that produced the snapshot.
|
|
369
|
+
*
|
|
370
|
+
* @since 8.0.0
|
|
371
|
+
*/
|
|
372
|
+
platform: 'ios' | 'android' | 'web';
|
|
373
|
+
/**
|
|
374
|
+
* CPU information and usage.
|
|
375
|
+
*
|
|
376
|
+
* @since 8.0.0
|
|
377
|
+
*/
|
|
378
|
+
cpu: CpuInfo;
|
|
379
|
+
/**
|
|
380
|
+
* Memory information and usage.
|
|
381
|
+
*
|
|
382
|
+
* @since 8.0.0
|
|
383
|
+
*/
|
|
384
|
+
memory: MemoryInfo;
|
|
385
|
+
/**
|
|
386
|
+
* Storage information and usage.
|
|
387
|
+
*
|
|
388
|
+
* @since 8.0.0
|
|
389
|
+
*/
|
|
390
|
+
storage: StorageInfo;
|
|
391
|
+
/**
|
|
392
|
+
* GPU information when the platform exposes it.
|
|
393
|
+
*
|
|
394
|
+
* @since 8.0.0
|
|
395
|
+
*/
|
|
396
|
+
gpu?: GpuInfo;
|
|
397
|
+
/**
|
|
398
|
+
* Thermal state when the platform exposes it.
|
|
399
|
+
*
|
|
400
|
+
* @since 8.0.0
|
|
401
|
+
*/
|
|
402
|
+
thermalState?: ThermalState;
|
|
403
|
+
/**
|
|
404
|
+
* Low-power mode state when the platform exposes it.
|
|
405
|
+
*
|
|
406
|
+
* @since 8.0.0
|
|
407
|
+
*/
|
|
408
|
+
lowPowerMode?: boolean;
|
|
409
|
+
/**
|
|
410
|
+
* Onboard sensor availability and readings.
|
|
411
|
+
*
|
|
412
|
+
* @since 8.0.0
|
|
413
|
+
*/
|
|
414
|
+
sensors?: OnboardSensorsInfo;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Options used to start periodic device snapshots.
|
|
418
|
+
*
|
|
419
|
+
* @since 8.0.0
|
|
420
|
+
*/
|
|
421
|
+
export interface MonitoringOptions {
|
|
422
|
+
/**
|
|
423
|
+
* Time between samples in milliseconds.
|
|
424
|
+
*
|
|
425
|
+
* Values below 250ms are clamped to 250ms to avoid excessive native work.
|
|
426
|
+
* Defaults to 1000ms.
|
|
427
|
+
*
|
|
428
|
+
* @since 8.0.0
|
|
429
|
+
*/
|
|
430
|
+
intervalMs?: number;
|
|
431
|
+
/**
|
|
432
|
+
* Stop automatically after this duration in milliseconds.
|
|
433
|
+
*
|
|
434
|
+
* @since 8.0.0
|
|
435
|
+
*/
|
|
436
|
+
durationMs?: number;
|
|
437
|
+
/**
|
|
438
|
+
* Stop automatically after this number of emitted samples.
|
|
439
|
+
*
|
|
440
|
+
* @since 8.0.0
|
|
441
|
+
*/
|
|
442
|
+
sampleCount?: number;
|
|
443
|
+
/**
|
|
444
|
+
* Emit one sample immediately when monitoring starts.
|
|
445
|
+
*
|
|
446
|
+
* Defaults to `true`.
|
|
447
|
+
*
|
|
448
|
+
* @since 8.0.0
|
|
449
|
+
*/
|
|
450
|
+
emitImmediately?: boolean;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Result returned when monitoring starts.
|
|
454
|
+
*
|
|
455
|
+
* @since 8.0.0
|
|
456
|
+
*/
|
|
457
|
+
export interface StartMonitoringResult {
|
|
458
|
+
/**
|
|
459
|
+
* Whether monitoring is active.
|
|
460
|
+
*
|
|
461
|
+
* @since 8.0.0
|
|
462
|
+
*/
|
|
463
|
+
monitoring: boolean;
|
|
464
|
+
/**
|
|
465
|
+
* Effective interval in milliseconds.
|
|
466
|
+
*
|
|
467
|
+
* @since 8.0.0
|
|
468
|
+
*/
|
|
469
|
+
intervalMs: number;
|
|
470
|
+
/**
|
|
471
|
+
* Monitoring start timestamp as Unix epoch milliseconds.
|
|
472
|
+
*
|
|
473
|
+
* @since 8.0.0
|
|
474
|
+
*/
|
|
475
|
+
startedAt: number;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Result returned by {@link DeviceInfoPlugin.stopMonitoring}.
|
|
479
|
+
*
|
|
480
|
+
* @since 8.0.0
|
|
481
|
+
*/
|
|
482
|
+
export interface StopMonitoringResult {
|
|
483
|
+
/**
|
|
484
|
+
* Whether monitoring remains active after the stop request.
|
|
485
|
+
*
|
|
486
|
+
* @since 8.0.0
|
|
487
|
+
*/
|
|
488
|
+
monitoring: boolean;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Current monitoring state.
|
|
492
|
+
*
|
|
493
|
+
* @since 8.0.0
|
|
494
|
+
*/
|
|
495
|
+
export interface MonitoringState {
|
|
496
|
+
/**
|
|
497
|
+
* Whether monitoring is active.
|
|
498
|
+
*
|
|
499
|
+
* @since 8.0.0
|
|
500
|
+
*/
|
|
501
|
+
monitoring: boolean;
|
|
502
|
+
/**
|
|
503
|
+
* Effective interval in milliseconds when monitoring is active.
|
|
504
|
+
*
|
|
505
|
+
* @since 8.0.0
|
|
506
|
+
*/
|
|
507
|
+
intervalMs?: number;
|
|
508
|
+
/**
|
|
509
|
+
* Monitoring start timestamp as Unix epoch milliseconds.
|
|
510
|
+
*
|
|
511
|
+
* @since 8.0.0
|
|
512
|
+
*/
|
|
513
|
+
startedAt?: number;
|
|
514
|
+
/**
|
|
515
|
+
* Number of samples emitted by the active monitoring session.
|
|
516
|
+
*
|
|
517
|
+
* @since 8.0.0
|
|
518
|
+
*/
|
|
519
|
+
samplesEmitted?: number;
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Periodic event payload emitted while monitoring is active.
|
|
523
|
+
*
|
|
524
|
+
* @since 8.0.0
|
|
525
|
+
*/
|
|
526
|
+
export interface DeviceInfoUpdate extends DeviceInfoSnapshot {
|
|
527
|
+
/**
|
|
528
|
+
* One-based sample sequence for the active monitoring session.
|
|
529
|
+
*
|
|
530
|
+
* @since 8.0.0
|
|
531
|
+
*/
|
|
532
|
+
sequence: number;
|
|
533
|
+
/**
|
|
534
|
+
* Monitoring start timestamp as Unix epoch milliseconds.
|
|
535
|
+
*
|
|
536
|
+
* @since 8.0.0
|
|
537
|
+
*/
|
|
538
|
+
startedAt: number;
|
|
539
|
+
/**
|
|
540
|
+
* Elapsed milliseconds since monitoring started.
|
|
541
|
+
*
|
|
542
|
+
* @since 8.0.0
|
|
543
|
+
*/
|
|
544
|
+
elapsedMs: number;
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Plugin version payload.
|
|
548
|
+
*
|
|
549
|
+
* @since 8.0.0
|
|
550
|
+
*/
|
|
551
|
+
export interface PluginVersionResult {
|
|
552
|
+
/**
|
|
553
|
+
* Version identifier returned by the platform implementation.
|
|
554
|
+
*
|
|
555
|
+
* @since 8.0.0
|
|
556
|
+
*/
|
|
557
|
+
version: string;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Capacitor plugin contract for reading device CPU, memory, GPU, storage, and onboard sensor metrics.
|
|
561
|
+
*
|
|
562
|
+
* @since 8.0.0
|
|
563
|
+
*/
|
|
564
|
+
export interface DeviceInfoPlugin {
|
|
565
|
+
/**
|
|
566
|
+
* Read one CPU, memory, GPU, storage, thermal, and onboard sensor snapshot.
|
|
567
|
+
*
|
|
568
|
+
* @since 8.0.0
|
|
569
|
+
*/
|
|
570
|
+
getInfo(): Promise<DeviceInfoSnapshot>;
|
|
571
|
+
/**
|
|
572
|
+
* Start periodic device snapshots.
|
|
573
|
+
*
|
|
574
|
+
* Listen to `deviceInfoUpdate` to receive samples. Calling this while monitoring
|
|
575
|
+
* is already active restarts monitoring with the new options.
|
|
576
|
+
*
|
|
577
|
+
* @since 8.0.0
|
|
578
|
+
*/
|
|
579
|
+
startMonitoring(options?: MonitoringOptions): Promise<StartMonitoringResult>;
|
|
580
|
+
/**
|
|
581
|
+
* Stop periodic device snapshots.
|
|
582
|
+
*
|
|
583
|
+
* @since 8.0.0
|
|
584
|
+
*/
|
|
585
|
+
stopMonitoring(): Promise<StopMonitoringResult>;
|
|
586
|
+
/**
|
|
587
|
+
* Return current periodic monitoring state.
|
|
588
|
+
*
|
|
589
|
+
* @since 8.0.0
|
|
590
|
+
*/
|
|
591
|
+
isMonitoring(): Promise<MonitoringState>;
|
|
592
|
+
/**
|
|
593
|
+
* Listen for periodic device snapshots.
|
|
594
|
+
*
|
|
595
|
+
* @param eventName Only the `deviceInfoUpdate` event is supported.
|
|
596
|
+
* @param listenerFunc Callback invoked with each snapshot.
|
|
597
|
+
* @since 8.0.0
|
|
598
|
+
*/
|
|
599
|
+
addListener(eventName: 'deviceInfoUpdate', listenerFunc: (event: DeviceInfoUpdate) => void): Promise<PluginListenerHandle>;
|
|
600
|
+
/**
|
|
601
|
+
* Remove all listeners that have been registered on the plugin.
|
|
602
|
+
*
|
|
603
|
+
* @since 8.0.0
|
|
604
|
+
*/
|
|
605
|
+
removeAllListeners(): Promise<void>;
|
|
606
|
+
/**
|
|
607
|
+
* Get the native Capacitor plugin version.
|
|
608
|
+
*
|
|
609
|
+
* @since 8.0.0
|
|
610
|
+
*/
|
|
611
|
+
getPluginVersion(): Promise<PluginVersionResult>;
|
|
612
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\n/**\n * CPU snapshot for the current device.\n *\n * All frequency values are reported in hertz. `usagePercent` is `null` when a\n * platform needs at least two samples to calculate CPU usage.\n *\n * @since 8.0.0\n */\nexport interface CpuInfo {\n /**\n * Total logical CPU cores visible to the app.\n *\n * @since 8.0.0\n */\n cores: number;\n\n /**\n * Logical CPU cores currently active, when the platform exposes it.\n *\n * @since 8.0.0\n */\n activeCores?: number;\n\n /**\n * CPU architecture, for example `arm64` or `x86_64`.\n *\n * @since 8.0.0\n */\n architecture?: string;\n\n /**\n * CPU or SoC model identifier when available.\n *\n * @since 8.0.0\n */\n model?: string;\n\n /**\n * System CPU usage from 0 to 100.\n *\n * @since 8.0.0\n */\n usagePercent?: number | null;\n\n /**\n * Highest CPU frequency exposed by the platform.\n *\n * @since 8.0.0\n */\n maxFrequencyHz?: number;\n\n /**\n * CPU temperature in Celsius when the platform exposes an onboard thermal sensor.\n *\n * Android reads this as a best-effort value from device thermal zones. iOS does\n * not expose raw CPU temperature through public APIs.\n *\n * @since 8.0.0\n */\n temperatureCelsius?: number;\n}\n\n/**\n * Memory snapshot for the current device and app process.\n *\n * All size values are reported in bytes.\n *\n * @since 8.0.0\n */\nexport interface MemoryInfo {\n /**\n * Total physical memory on the device.\n *\n * @since 8.0.0\n */\n totalBytes?: number;\n\n /**\n * Memory available to the system.\n *\n * @since 8.0.0\n */\n freeBytes?: number;\n\n /**\n * Memory currently used by the system.\n *\n * @since 8.0.0\n */\n usedBytes?: number;\n\n /**\n * Memory usage from 0 to 100.\n *\n * @since 8.0.0\n */\n usedPercent?: number;\n\n /**\n * Memory used by the current app process.\n *\n * @since 8.0.0\n */\n appUsedBytes?: number;\n\n /**\n * Heap limit visible to the current app process.\n *\n * @since 8.0.0\n */\n appLimitBytes?: number;\n\n /**\n * Whether the OS currently reports low-memory pressure.\n *\n * @since 8.0.0\n */\n lowMemory?: boolean;\n\n /**\n * Platform memory pressure label.\n *\n * @since 8.0.0\n */\n pressure?: 'normal' | 'warning' | 'critical' | 'unknown';\n}\n\n/**\n * Storage snapshot for the app data volume.\n *\n * All size values are reported in bytes.\n *\n * @since 8.0.0\n */\nexport interface StorageInfo {\n /**\n * Total bytes on the app data volume.\n *\n * @since 8.0.0\n */\n totalBytes?: number;\n\n /**\n * Free bytes on the app data volume.\n *\n * @since 8.0.0\n */\n freeBytes?: number;\n\n /**\n * Used bytes on the app data volume.\n *\n * @since 8.0.0\n */\n usedBytes?: number;\n\n /**\n * Storage usage from 0 to 100.\n *\n * @since 8.0.0\n */\n usedPercent?: number;\n}\n\n/**\n * GPU snapshot for the primary graphics device.\n *\n * @since 8.0.0\n */\nexport interface GpuInfo {\n /**\n * Graphics API used to query the GPU.\n *\n * @since 8.0.0\n */\n api?: 'metal' | 'opengl' | 'webgl' | 'unknown';\n\n /**\n * GPU vendor when available.\n *\n * @since 8.0.0\n */\n vendor?: string;\n\n /**\n * GPU renderer or model name when available.\n *\n * @since 8.0.0\n */\n renderer?: string;\n\n /**\n * Graphics API version string when available.\n *\n * @since 8.0.0\n */\n version?: string;\n\n /**\n * Maximum texture size reported by the graphics API.\n *\n * @since 8.0.0\n */\n maxTextureSize?: number;\n\n /**\n * GPU temperature in Celsius when the platform exposes an onboard thermal sensor.\n *\n * Android reads this as a best-effort value from device thermal zones. iOS does\n * not expose raw GPU temperature through public APIs.\n *\n * @since 8.0.0\n */\n temperatureCelsius?: number;\n}\n\n/**\n * Thermal state reported by the platform.\n *\n * @since 8.0.0\n */\nexport type ThermalState = 'nominal' | 'fair' | 'serious' | 'critical' | 'unknown';\n\n/**\n * Description of an onboard hardware sensor exposed by the platform.\n *\n * @since 8.0.0\n */\nexport interface OnboardSensorDescriptor {\n /**\n * Stable sensor type label, for example `pressure`, `ambientTemperature`, or `accelerometer`.\n *\n * @since 8.0.0\n */\n type: string;\n\n /**\n * Platform sensor name when available.\n *\n * @since 8.0.0\n */\n name?: string;\n\n /**\n * Sensor vendor when available.\n *\n * @since 8.0.0\n */\n vendor?: string;\n\n /**\n * Android sensor type id when available.\n *\n * @since 8.0.0\n */\n platformType?: number;\n\n /**\n * Maximum sensor range when available.\n *\n * @since 8.0.0\n */\n maximumRange?: number;\n\n /**\n * Sensor resolution when available.\n *\n * @since 8.0.0\n */\n resolution?: number;\n\n /**\n * Sensor power draw in milliamps when available.\n *\n * @since 8.0.0\n */\n powerMilliamp?: number;\n\n /**\n * Minimum sensor delay in microseconds when available.\n *\n * @since 8.0.0\n */\n minDelayMicroseconds?: number;\n\n /**\n * Whether this is a wake-up sensor when available.\n *\n * @since 8.0.0\n */\n wakeUp?: boolean;\n}\n\n/**\n * Instant onboard sensor reading.\n *\n * @since 8.0.0\n */\nexport interface OnboardSensorReading {\n /**\n * Stable sensor type label.\n *\n * @since 8.0.0\n */\n type: string;\n\n /**\n * Human-readable unit, for example `celsius`, `percent`, `hPa`, `lux`, or `cm`.\n *\n * @since 8.0.0\n */\n unit: string;\n\n /**\n * Sensor value.\n *\n * @since 8.0.0\n */\n value: number;\n\n /**\n * Platform sensor name when available.\n *\n * @since 8.0.0\n */\n name?: string;\n\n /**\n * Reading timestamp as Unix epoch milliseconds.\n *\n * @since 8.0.0\n */\n timestamp?: number;\n}\n\n/**\n * Onboard sensors snapshot.\n *\n * This only reports hardware sensors exposed by the device or operating system.\n * It does not fetch weather data or any external temperature/humidity source.\n *\n * @since 8.0.0\n */\nexport interface OnboardSensorsInfo {\n /**\n * Sensors available to the app.\n *\n * @since 8.0.0\n */\n availableSensors?: OnboardSensorDescriptor[];\n\n /**\n * Instant sensor readings captured for common environmental sensors.\n *\n * @since 8.0.0\n */\n readings?: OnboardSensorReading[];\n\n /**\n * Battery temperature in Celsius when available.\n *\n * @since 8.0.0\n */\n batteryTemperatureCelsius?: number;\n\n /**\n * Ambient air temperature from an onboard sensor in Celsius when available.\n *\n * @since 8.0.0\n */\n ambientTemperatureCelsius?: number;\n\n /**\n * Relative humidity from an onboard sensor as a percentage when available.\n *\n * @since 8.0.0\n */\n relativeHumidityPercent?: number;\n\n /**\n * Atmospheric pressure from an onboard barometer in hectopascals when available.\n *\n * @since 8.0.0\n */\n pressureHpa?: number;\n\n /**\n * Ambient light from an onboard light sensor in lux when available.\n *\n * @since 8.0.0\n */\n illuminanceLux?: number;\n\n /**\n * Proximity distance from an onboard proximity sensor in centimeters when available.\n *\n * @since 8.0.0\n */\n proximityDistanceCm?: number;\n}\n\n/**\n * Instant device snapshot returned by {@link DeviceInfoPlugin.getInfo}.\n *\n * @since 8.0.0\n */\nexport interface DeviceInfoSnapshot {\n /**\n * Snapshot timestamp as Unix epoch milliseconds.\n *\n * @since 8.0.0\n */\n timestamp: number;\n\n /**\n * Platform implementation that produced the snapshot.\n *\n * @since 8.0.0\n */\n platform: 'ios' | 'android' | 'web';\n\n /**\n * CPU information and usage.\n *\n * @since 8.0.0\n */\n cpu: CpuInfo;\n\n /**\n * Memory information and usage.\n *\n * @since 8.0.0\n */\n memory: MemoryInfo;\n\n /**\n * Storage information and usage.\n *\n * @since 8.0.0\n */\n storage: StorageInfo;\n\n /**\n * GPU information when the platform exposes it.\n *\n * @since 8.0.0\n */\n gpu?: GpuInfo;\n\n /**\n * Thermal state when the platform exposes it.\n *\n * @since 8.0.0\n */\n thermalState?: ThermalState;\n\n /**\n * Low-power mode state when the platform exposes it.\n *\n * @since 8.0.0\n */\n lowPowerMode?: boolean;\n\n /**\n * Onboard sensor availability and readings.\n *\n * @since 8.0.0\n */\n sensors?: OnboardSensorsInfo;\n}\n\n/**\n * Options used to start periodic device snapshots.\n *\n * @since 8.0.0\n */\nexport interface MonitoringOptions {\n /**\n * Time between samples in milliseconds.\n *\n * Values below 250ms are clamped to 250ms to avoid excessive native work.\n * Defaults to 1000ms.\n *\n * @since 8.0.0\n */\n intervalMs?: number;\n\n /**\n * Stop automatically after this duration in milliseconds.\n *\n * @since 8.0.0\n */\n durationMs?: number;\n\n /**\n * Stop automatically after this number of emitted samples.\n *\n * @since 8.0.0\n */\n sampleCount?: number;\n\n /**\n * Emit one sample immediately when monitoring starts.\n *\n * Defaults to `true`.\n *\n * @since 8.0.0\n */\n emitImmediately?: boolean;\n}\n\n/**\n * Result returned when monitoring starts.\n *\n * @since 8.0.0\n */\nexport interface StartMonitoringResult {\n /**\n * Whether monitoring is active.\n *\n * @since 8.0.0\n */\n monitoring: boolean;\n\n /**\n * Effective interval in milliseconds.\n *\n * @since 8.0.0\n */\n intervalMs: number;\n\n /**\n * Monitoring start timestamp as Unix epoch milliseconds.\n *\n * @since 8.0.0\n */\n startedAt: number;\n}\n\n/**\n * Result returned by {@link DeviceInfoPlugin.stopMonitoring}.\n *\n * @since 8.0.0\n */\nexport interface StopMonitoringResult {\n /**\n * Whether monitoring remains active after the stop request.\n *\n * @since 8.0.0\n */\n monitoring: boolean;\n}\n\n/**\n * Current monitoring state.\n *\n * @since 8.0.0\n */\nexport interface MonitoringState {\n /**\n * Whether monitoring is active.\n *\n * @since 8.0.0\n */\n monitoring: boolean;\n\n /**\n * Effective interval in milliseconds when monitoring is active.\n *\n * @since 8.0.0\n */\n intervalMs?: number;\n\n /**\n * Monitoring start timestamp as Unix epoch milliseconds.\n *\n * @since 8.0.0\n */\n startedAt?: number;\n\n /**\n * Number of samples emitted by the active monitoring session.\n *\n * @since 8.0.0\n */\n samplesEmitted?: number;\n}\n\n/**\n * Periodic event payload emitted while monitoring is active.\n *\n * @since 8.0.0\n */\nexport interface DeviceInfoUpdate extends DeviceInfoSnapshot {\n /**\n * One-based sample sequence for the active monitoring session.\n *\n * @since 8.0.0\n */\n sequence: number;\n\n /**\n * Monitoring start timestamp as Unix epoch milliseconds.\n *\n * @since 8.0.0\n */\n startedAt: number;\n\n /**\n * Elapsed milliseconds since monitoring started.\n *\n * @since 8.0.0\n */\n elapsedMs: number;\n}\n\n/**\n * Plugin version payload.\n *\n * @since 8.0.0\n */\nexport interface PluginVersionResult {\n /**\n * Version identifier returned by the platform implementation.\n *\n * @since 8.0.0\n */\n version: string;\n}\n\n/**\n * Capacitor plugin contract for reading device CPU, memory, GPU, storage, and onboard sensor metrics.\n *\n * @since 8.0.0\n */\nexport interface DeviceInfoPlugin {\n /**\n * Read one CPU, memory, GPU, storage, thermal, and onboard sensor snapshot.\n *\n * @since 8.0.0\n */\n getInfo(): Promise<DeviceInfoSnapshot>;\n\n /**\n * Start periodic device snapshots.\n *\n * Listen to `deviceInfoUpdate` to receive samples. Calling this while monitoring\n * is already active restarts monitoring with the new options.\n *\n * @since 8.0.0\n */\n startMonitoring(options?: MonitoringOptions): Promise<StartMonitoringResult>;\n\n /**\n * Stop periodic device snapshots.\n *\n * @since 8.0.0\n */\n stopMonitoring(): Promise<StopMonitoringResult>;\n\n /**\n * Return current periodic monitoring state.\n *\n * @since 8.0.0\n */\n isMonitoring(): Promise<MonitoringState>;\n\n /**\n * Listen for periodic device snapshots.\n *\n * @param eventName Only the `deviceInfoUpdate` event is supported.\n * @param listenerFunc Callback invoked with each snapshot.\n * @since 8.0.0\n */\n addListener(\n eventName: 'deviceInfoUpdate',\n listenerFunc: (event: DeviceInfoUpdate) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Remove all listeners that have been registered on the plugin.\n *\n * @since 8.0.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Get the native Capacitor plugin version.\n *\n * @since 8.0.0\n */\n getPluginVersion(): Promise<PluginVersionResult>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,UAAU,GAAG,cAAc,CAAmB,YAAY,EAAE;IAChE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;CAC9D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { DeviceInfoPlugin } from './definitions';\n\nconst DeviceInfo = registerPlugin<DeviceInfoPlugin>('DeviceInfo', {\n web: () => import('./web').then((m) => new m.DeviceInfoWeb()),\n});\n\nexport * from './definitions';\nexport { DeviceInfo };\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { PluginListenerHandle } from '@capacitor/core';
|
|
3
|
+
import type { DeviceInfoPlugin, DeviceInfoSnapshot, DeviceInfoUpdate, MonitoringOptions, MonitoringState, PluginVersionResult, StartMonitoringResult, StopMonitoringResult } from './definitions';
|
|
4
|
+
export declare class DeviceInfoWeb extends WebPlugin implements DeviceInfoPlugin {
|
|
5
|
+
private timer;
|
|
6
|
+
private startedAt;
|
|
7
|
+
private intervalMs;
|
|
8
|
+
private samplesEmitted;
|
|
9
|
+
private sampleLimit;
|
|
10
|
+
private stopAt;
|
|
11
|
+
private isEmitting;
|
|
12
|
+
getInfo(): Promise<DeviceInfoSnapshot>;
|
|
13
|
+
startMonitoring(options?: MonitoringOptions): Promise<StartMonitoringResult>;
|
|
14
|
+
stopMonitoring(): Promise<StopMonitoringResult>;
|
|
15
|
+
isMonitoring(): Promise<MonitoringState>;
|
|
16
|
+
addListener(eventName: 'deviceInfoUpdate', listenerFunc: (event: DeviceInfoUpdate) => void): Promise<PluginListenerHandle>;
|
|
17
|
+
removeAllListeners(): Promise<void>;
|
|
18
|
+
getPluginVersion(): Promise<PluginVersionResult>;
|
|
19
|
+
private emitSample;
|
|
20
|
+
private getMemoryInfo;
|
|
21
|
+
private getStorageInfo;
|
|
22
|
+
private getGpuInfo;
|
|
23
|
+
private getOnboardSensorsInfo;
|
|
24
|
+
private shouldStop;
|
|
25
|
+
private normalizeInterval;
|
|
26
|
+
private normalizePositiveInteger;
|
|
27
|
+
private normalizePositiveNumber;
|
|
28
|
+
private toPercent;
|
|
29
|
+
}
|