tauri-plugin-device-info-api 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/README.md +154 -53
  2. package/package.json +28 -9
package/README.md CHANGED
@@ -1,8 +1,13 @@
1
1
  # Tauri Plugin device-info
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/tauri-plugin-device-info-api.svg)](https://www.npmjs.com/package/tauri-plugin-device-info-api)
4
+ [![npm downloads](https://img.shields.io/npm/dm/tauri-plugin-device-info-api.svg)](https://www.npmjs.com/package/tauri-plugin-device-info-api)
4
5
  [![Crates.io](https://img.shields.io/crates/v/tauri-plugin-device-info.svg)](https://crates.io/crates/tauri-plugin-device-info)
6
+ [![Crates.io Downloads](https://img.shields.io/crates/d/tauri-plugin-device-info.svg)](https://crates.io/crates/tauri-plugin-device-info)
7
+ [![GitHub stars](https://img.shields.io/github/stars/edisdev/tauri-plugin-device-info?style=social)](https://github.com/edisdev/tauri-plugin-device-info)
8
+ [![GitHub forks](https://img.shields.io/github/forks/edisdev/tauri-plugin-device-info?style=social)](https://github.com/edisdev/tauri-plugin-device-info/fork)
5
9
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
10
+ [![CI](https://github.com/edisdev/tauri-plugin-device-info/actions/workflows/build.yml/badge.svg)](https://github.com/edisdev/tauri-plugin-device-info/actions)
6
11
 
7
12
  A comprehensive Tauri plugin to access device information including Battery, Network, Storage, Display, and System Details.
8
13
 
@@ -26,7 +31,7 @@ A comprehensive Tauri plugin to access device information including Battery, Net
26
31
  ## Platform Support
27
32
 
28
33
  | Platform | Support |
29
- |----------|---------|
34
+ | -------- | ------- |
30
35
  | Windows | ✅ |
31
36
  | macOS | ✅ |
32
37
  | Linux | ✅ |
@@ -45,19 +50,21 @@ yarn tauri add device-info
45
50
 
46
51
  ### Manual Installation
47
52
 
48
- **Cargo.toml:**
53
+ **Cargo.toml:** [![Crates.io](https://img.shields.io/crates/v/tauri-plugin-device-info.svg)](https://crates.io/crates/tauri-plugin-device-info)
54
+
49
55
  ```toml
50
56
  [dependencies]
51
- tauri-plugin-device-info = "0.1.0"
57
+ tauri-plugin-device-info = "1.0" # Check crates.io for latest version
52
58
  # or from git
53
59
  tauri-plugin-device-info = { git = "https://github.com/edisdev/tauri-plugin-device-info" }
54
60
  ```
55
61
 
56
- **package.json:**
62
+ **package.json:** [![npm version](https://img.shields.io/npm/v/tauri-plugin-device-info-api.svg)](https://www.npmjs.com/package/tauri-plugin-device-info-api)
63
+
57
64
  ```json
58
65
  {
59
66
  "dependencies": {
60
- "tauri-plugin-device-info-api": "latest"
67
+ "tauri-plugin-device-info-api": "^1.0.0"
61
68
  }
62
69
  }
63
70
  ```
@@ -67,6 +74,7 @@ tauri-plugin-device-info = { git = "https://github.com/edisdev/tauri-plugin-devi
67
74
  Register the plugin in your Tauri app:
68
75
 
69
76
  **src-tauri/src/lib.rs:**
77
+
70
78
  ```rust
71
79
  fn main() {
72
80
  tauri::Builder::default()
@@ -79,143 +87,236 @@ fn main() {
79
87
  ## Usage
80
88
 
81
89
  ```typescript
82
- import {
83
- getDeviceInfo,
84
- getBatteryInfo,
85
- getNetworkInfo,
86
- getStorageInfo,
87
- getDisplayInfo
88
- } from 'tauri-plugin-device-info-api';
90
+ import {
91
+ getDeviceInfo,
92
+ getBatteryInfo,
93
+ getNetworkInfo,
94
+ getStorageInfo,
95
+ getDisplayInfo,
96
+ } from "tauri-plugin-device-info-api";
89
97
 
90
98
  // Get device information
91
99
  const device = await getDeviceInfo();
92
100
  console.log(device);
101
+ ```
93
102
 
103
+ **Response:**
104
+
105
+ ```json
106
+ {
107
+ "uuid": "550e8400-e29b-41d4-a716-446655440000",
108
+ "manufacturer": "Apple Inc.",
109
+ "model": "MacBookPro16,1",
110
+ "serial": "C02XG2JHJG5H",
111
+ "android_id": null,
112
+ "device_name": "John's MacBook Pro"
113
+ }
114
+ ```
115
+
116
+ ```typescript
94
117
  // Get battery status
95
118
  const battery = await getBatteryInfo();
96
119
  console.log(battery);
120
+ ```
97
121
 
122
+ **Response:**
123
+
124
+ ```json
125
+ {
126
+ "level": 85,
127
+ "isCharging": true,
128
+ "health": "Good"
129
+ }
130
+ ```
131
+
132
+ ```typescript
98
133
  // Get network information
99
134
  const network = await getNetworkInfo();
100
135
  console.log(network);
136
+ ```
137
+
138
+ **Response:**
139
+
140
+ ```json
141
+ {
142
+ "ipAddress": "192.168.x.x",
143
+ "networkType": "wifi",
144
+ "macAddress": "a1:b2:c3:d4:e5:f6"
145
+ }
146
+ ```
101
147
 
148
+ ```typescript
102
149
  // Get storage information
103
150
  const storage = await getStorageInfo();
104
151
  console.log(storage);
152
+ ```
153
+
154
+ **Response:**
105
155
 
156
+ ```json
157
+ {
158
+ "totalSpace": 500107862016,
159
+ "freeSpace": 125026965504,
160
+ "storageType": "SSD"
161
+ }
162
+ ```
163
+
164
+ ```typescript
106
165
  // Get display information
107
166
  const display = await getDisplayInfo();
108
167
  console.log(display);
109
168
  ```
110
169
 
170
+ **Response:**
171
+
172
+ ```json
173
+ {
174
+ "width": 2560,
175
+ "height": 1600,
176
+ "scaleFactor": 2.0,
177
+ "refreshRate": 120
178
+ }
179
+ ```
180
+
111
181
  ## API Reference
112
182
 
113
183
  ### getDeviceInfo()
114
184
 
115
185
  Returns device identification and hardware information.
116
186
 
117
- | Field | Type | Description |
118
- |-------|------|-------------|
119
- | `uuid` | `string?` | Unique device identifier |
120
- | `manufacturer` | `string?` | Device manufacturer (e.g., "Apple Inc.") |
121
- | `model` | `string?` | Device model (e.g., "MacBookPro16,1") |
122
- | `serial` | `string?` | Serial number (restricted on some platforms) |
123
- | `android_id` | `string?` | Android-specific ID (Android only) |
124
- | `device_name` | `string?` | User-assigned device name |
187
+ | Field | Type | Description |
188
+ | -------------- | --------- | -------------------------------------------- |
189
+ | `uuid` | `string?` | Unique device identifier |
190
+ | `manufacturer` | `string?` | Device manufacturer (e.g., "Apple Inc.") |
191
+ | `model` | `string?` | Device model (e.g., "MacBookPro16,1") |
192
+ | `serial` | `string?` | Serial number (restricted on some platforms) |
193
+ | `android_id` | `string?` | Android-specific ID (Android only) |
194
+ | `device_name` | `string?` | User-assigned device name |
125
195
 
126
196
  ### getBatteryInfo()
127
197
 
128
198
  Returns battery status and health information.
129
199
 
130
- | Field | Type | Description |
131
- |-------|------|-------------|
132
- | `level` | `number?` | Battery percentage (0-100) |
200
+ | Field | Type | Description |
201
+ | ------------ | ---------- | ------------------------------ |
202
+ | `level` | `number?` | Battery percentage (0-100) |
133
203
  | `isCharging` | `boolean?` | Whether the device is charging |
134
- | `health` | `string?` | Battery health status |
204
+ | `health` | `string?` | Battery health status |
135
205
 
136
206
  ### getNetworkInfo()
137
207
 
138
208
  Returns network connection details.
139
209
 
140
- | Field | Type | Description |
141
- |-------|------|-------------|
142
- | `ipAddress` | `string?` | Local IP address |
210
+ | Field | Type | Description |
211
+ | ------------- | --------- | ---------------------------------------------------------- |
212
+ | `ipAddress` | `string?` | Local IP address |
143
213
  | `networkType` | `string?` | Connection type: "wifi", "cellular", "ethernet", "unknown" |
144
- | `macAddress` | `string?` | MAC address (unavailable on iOS/Android due to privacy) |
214
+ | `macAddress` | `string?` | MAC address (unavailable on iOS/Android due to privacy) |
145
215
 
146
216
  ### getStorageInfo()
147
217
 
148
218
  Returns storage capacity information.
149
219
 
150
- | Field | Type | Description |
151
- |-------|------|-------------|
152
- | `totalSpace` | `number?` | Total storage in bytes |
153
- | `freeSpace` | `number?` | Available storage in bytes |
220
+ | Field | Type | Description |
221
+ | ------------- | --------- | -------------------------------------- |
222
+ | `totalSpace` | `number?` | Total storage in bytes |
223
+ | `freeSpace` | `number?` | Available storage in bytes |
154
224
  | `storageType` | `string?` | Storage type: "SSD", "HDD", "internal" |
155
225
 
156
226
  ### getDisplayInfo()
157
227
 
158
228
  Returns display/screen information.
159
229
 
160
- | Field | Type | Description |
161
- |-------|------|-------------|
162
- | `width` | `number?` | Screen width in pixels |
163
- | `height` | `number?` | Screen height in pixels |
230
+ | Field | Type | Description |
231
+ | ------------- | --------- | ------------------------------------------- |
232
+ | `width` | `number?` | Screen width in pixels |
233
+ | `height` | `number?` | Screen height in pixels |
164
234
  | `scaleFactor` | `number?` | Display scale factor (e.g., 2.0 for Retina) |
165
- | `refreshRate` | `number?` | Screen refresh rate in Hz |
235
+ | `refreshRate` | `number?` | Screen refresh rate in Hz |
166
236
 
167
237
  ## TypeScript Types
168
238
 
169
239
  All types are exported and can be imported:
170
240
 
171
241
  ```typescript
172
- import type {
173
- DeviceInfoResponse,
174
- BatteryInfo,
175
- NetworkInfo,
176
- StorageInfo,
177
- DisplayInfo
178
- } from 'tauri-plugin-device-info-api';
242
+ import type {
243
+ DeviceInfoResponse,
244
+ BatteryInfo,
245
+ NetworkInfo,
246
+ StorageInfo,
247
+ DisplayInfo,
248
+ } from "tauri-plugin-device-info-api";
179
249
  ```
180
250
 
181
251
  ## Permissions
182
252
 
183
- Add the required permissions in your `capabilities` configuration:
253
+ Add the required permissions in your `capabilities` configuration.
254
+
255
+ **src-tauri/capabilities/default.json:**
256
+
257
+ ```json
258
+ {
259
+ "$schema": "../gen/schemas/desktop-schema.json",
260
+ "identifier": "default",
261
+ "description": "Capability for the main window",
262
+ "windows": ["main"],
263
+ "permissions": ["core:default", "device-info:default"]
264
+ }
265
+ ```
266
+
267
+ ### Available Permissions
268
+
269
+ | Permission | Description |
270
+ | ------------------------------------ | --------------------------------- |
271
+ | `device-info:default` | Enables all device-info commands |
272
+ | `device-info:allow-get-device-info` | Allows getting device information |
273
+ | `device-info:allow-get-battery-info` | Allows getting battery status |
274
+ | `device-info:allow-get-network-info` | Allows getting network details |
275
+ | `device-info:allow-get-storage-info` | Allows getting storage info |
276
+ | `device-info:allow-get-display-info` | Allows getting display info |
277
+
278
+ ### Individual Permissions Example
279
+
280
+ If you want to grant only specific permissions:
184
281
 
185
282
  ```json
186
283
  {
284
+ "$schema": "../gen/schemas/desktop-schema.json",
285
+ "identifier": "default",
286
+ "description": "Capability for the main window",
287
+ "windows": ["main"],
187
288
  "permissions": [
188
- "device-info:default"
289
+ "core:default",
290
+ "device-info:allow-get-battery-info",
291
+ "device-info:allow-get-network-info"
189
292
  ]
190
293
  }
191
294
  ```
192
295
 
193
- Or individually:
194
- - `device-info:allow-get-device-info`
195
- - `device-info:allow-get-battery-info`
196
- - `device-info:allow-get-network-info`
197
- - `device-info:allow-get-storage-info`
198
- - `device-info:allow-get-display-info`
199
-
200
296
  ## Platform-Specific Notes
201
297
 
202
298
  ### iOS
299
+
203
300
  - MAC address is not available due to Apple's privacy restrictions (returns "unavailable")
204
301
  - Serial number uses a persistent Keychain-stored UUID
205
302
 
206
303
  ### Android
304
+
207
305
  - MAC address is restricted on Android 6.0+ (returns "restricted")
208
306
  - Requires no special permissions for basic device info
209
307
 
210
308
  ### macOS
309
+
211
310
  - Uses native CoreGraphics API for accurate refresh rate detection
212
311
  - Full access to all device information
213
312
 
214
313
  ### Windows
314
+
215
315
  - Uses WMI (Windows Management Instrumentation) for device info
216
316
  - Full access to all device information
217
317
 
218
318
  ### Linux
319
+
219
320
  - Display refresh rate requires X11 (xrandr)
220
321
  - Device info read from `/sys/class/dmi/id/`
221
322
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tauri-plugin-device-info-api",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "author": "edisdev<edisdev14@gmail.com>",
5
5
  "description": "A Tauri plugin to access device information.",
6
6
  "license": "MIT",
@@ -8,14 +8,6 @@
8
8
  "type": "git",
9
9
  "url": "https://github.com/edisdev/tauri-plugin-device-info.git"
10
10
  },
11
- "keywords": [
12
- "tauri",
13
- "plugin",
14
- "device-info",
15
- "system",
16
- "mobile",
17
- "desktop"
18
- ],
19
11
  "bugs": {
20
12
  "url": "https://github.com/edisdev/tauri-plugin-device-info/issues"
21
13
  },
@@ -29,6 +21,33 @@
29
21
  "import": "./dist-js/index.js",
30
22
  "require": "./dist-js/index.cjs"
31
23
  },
24
+ "keywords": [
25
+ "tauri",
26
+ "tauri-plugin",
27
+ "tauri-plugin-device-info",
28
+ "tauri-v2",
29
+ "device-info",
30
+ "device",
31
+ "system-info",
32
+ "hardware",
33
+ "battery",
34
+ "battery-status",
35
+ "network",
36
+ "network-info",
37
+ "storage",
38
+ "disk-space",
39
+ "display",
40
+ "screen",
41
+ "cross-platform",
42
+ "desktop",
43
+ "mobile",
44
+ "ios",
45
+ "android",
46
+ "macos",
47
+ "windows",
48
+ "linux",
49
+ "rust"
50
+ ],
32
51
  "files": [
33
52
  "dist-js",
34
53
  "README.md"