@simplysm/capacitor-plugin-usb-storage 13.0.97 → 13.0.99
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/README.md +95 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# @simplysm/capacitor-plugin-usb-storage
|
|
2
|
+
|
|
3
|
+
Simplysm Package - Capacitor USB Storage Plugin. Provides USB Mass Storage device access on Android via the libaums library, with IndexedDB-based browser emulation.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @simplysm/capacitor-plugin-usb-storage
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## API Overview
|
|
12
|
+
|
|
13
|
+
### USB Storage
|
|
14
|
+
|
|
15
|
+
| API | Type | Description |
|
|
16
|
+
|-----|------|-------------|
|
|
17
|
+
| `UsbStorage` | class | USB storage access plugin (static methods) |
|
|
18
|
+
| `UsbStoragePlugin` | interface | Low-level Capacitor plugin interface for USB storage |
|
|
19
|
+
| `UsbDeviceInfo` | interface | USB device information |
|
|
20
|
+
| `UsbDeviceFilter` | interface | USB device filter (vendor/product ID pair) |
|
|
21
|
+
| `UsbFileInfo` | interface | File/directory entry on USB device |
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
### `UsbDeviceInfo`
|
|
26
|
+
|
|
27
|
+
| Field | Type | Description |
|
|
28
|
+
|-------|------|-------------|
|
|
29
|
+
| `deviceName` | `string` | Device name |
|
|
30
|
+
| `manufacturerName` | `string` | Manufacturer name |
|
|
31
|
+
| `productName` | `string` | Product name |
|
|
32
|
+
| `vendorId` | `number` | USB vendor ID |
|
|
33
|
+
| `productId` | `number` | USB product ID |
|
|
34
|
+
|
|
35
|
+
### `UsbDeviceFilter`
|
|
36
|
+
|
|
37
|
+
| Field | Type | Description |
|
|
38
|
+
|-------|------|-------------|
|
|
39
|
+
| `vendorId` | `number` | USB vendor ID |
|
|
40
|
+
| `productId` | `number` | USB product ID |
|
|
41
|
+
|
|
42
|
+
### `UsbFileInfo`
|
|
43
|
+
|
|
44
|
+
| Field | Type | Description |
|
|
45
|
+
|-------|------|-------------|
|
|
46
|
+
| `name` | `string` | File or directory name |
|
|
47
|
+
| `isDirectory` | `boolean` | Whether the entry is a directory |
|
|
48
|
+
|
|
49
|
+
### `UsbStoragePlugin`
|
|
50
|
+
|
|
51
|
+
| Method | Signature | Description |
|
|
52
|
+
|--------|-----------|-------------|
|
|
53
|
+
| `getDevices` | `() => Promise<{ devices: UsbDeviceInfo[] }>` | Get connected USB devices |
|
|
54
|
+
| `requestPermissions` | `(options: UsbDeviceFilter) => Promise<{ granted: boolean }>` | Request USB device permission |
|
|
55
|
+
| `checkPermissions` | `(options: UsbDeviceFilter) => Promise<{ granted: boolean }>` | Check USB device permission |
|
|
56
|
+
| `readdir` | `(options: UsbDeviceFilter & { path: string }) => Promise<{ files: UsbFileInfo[] }>` | Read directory from USB |
|
|
57
|
+
| `readFile` | `(options: UsbDeviceFilter & { path: string }) => Promise<{ data: string \| null }>` | Read file from USB (base64) |
|
|
58
|
+
|
|
59
|
+
### `UsbStorage`
|
|
60
|
+
|
|
61
|
+
Abstract class with static methods for USB Mass Storage access.
|
|
62
|
+
|
|
63
|
+
| Method | Signature | Description |
|
|
64
|
+
|--------|-----------|-------------|
|
|
65
|
+
| `getDevices` | `() => Promise<UsbDeviceInfo[]>` | Get list of connected USB devices |
|
|
66
|
+
| `requestPermissions` | `(filter: UsbDeviceFilter) => Promise<boolean>` | Request USB device access permission |
|
|
67
|
+
| `checkPermissions` | `(filter: UsbDeviceFilter) => Promise<boolean>` | Check USB device access permission |
|
|
68
|
+
| `readdir` | `(filter: UsbDeviceFilter, dirPath: string) => Promise<UsbFileInfo[]>` | Read directory contents from USB device |
|
|
69
|
+
| `readFile` | `(filter: UsbDeviceFilter, filePath: string) => Promise<Bytes \| undefined>` | Read file from USB device |
|
|
70
|
+
|
|
71
|
+
## Usage Examples
|
|
72
|
+
|
|
73
|
+
### List and read from USB device
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { UsbStorage } from "@simplysm/capacitor-plugin-usb-storage";
|
|
77
|
+
|
|
78
|
+
// List connected devices
|
|
79
|
+
const devices = await UsbStorage.getDevices();
|
|
80
|
+
|
|
81
|
+
if (devices.length > 0) {
|
|
82
|
+
const filter = { vendorId: devices[0].vendorId, productId: devices[0].productId };
|
|
83
|
+
|
|
84
|
+
// Request permission
|
|
85
|
+
const granted = await UsbStorage.requestPermissions(filter);
|
|
86
|
+
|
|
87
|
+
if (granted) {
|
|
88
|
+
// Read directory
|
|
89
|
+
const files = await UsbStorage.readdir(filter, "/");
|
|
90
|
+
|
|
91
|
+
// Read a file
|
|
92
|
+
const data = await UsbStorage.readFile(filter, "/document.txt");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/capacitor-plugin-usb-storage",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.99",
|
|
4
4
|
"description": "Simplysm Package - Capacitor USB Storage Plugin",
|
|
5
5
|
"author": "simplysm",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"android"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@simplysm/core-browser": "13.0.
|
|
22
|
-
"@simplysm/core-common": "13.0.
|
|
21
|
+
"@simplysm/core-browser": "13.0.99",
|
|
22
|
+
"@simplysm/core-common": "13.0.99"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@capacitor/core": "^7.6.0"
|