@simplysm/capacitor-plugin-usb-storage 13.0.98 → 13.0.100
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 +53 -69
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @simplysm/capacitor-plugin-usb-storage
|
|
2
2
|
|
|
3
|
-
Capacitor USB Storage Plugin
|
|
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
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -10,102 +10,86 @@ npm install @simplysm/capacitor-plugin-usb-storage
|
|
|
10
10
|
|
|
11
11
|
## API Overview
|
|
12
12
|
|
|
13
|
-
###
|
|
13
|
+
### USB Storage
|
|
14
14
|
|
|
15
15
|
| API | Type | Description |
|
|
16
16
|
|-----|------|-------------|
|
|
17
|
-
| `
|
|
18
|
-
| `
|
|
19
|
-
| `
|
|
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 |
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
---
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|-----|------|-------------|
|
|
25
|
-
| `UsbStoragePlugin` | interface | Low-level Capacitor plugin interface for USB storage operations |
|
|
25
|
+
### `UsbDeviceInfo`
|
|
26
26
|
|
|
27
|
-
|
|
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 |
|
|
28
34
|
|
|
29
|
-
|
|
30
|
-
|-----|------|-------------|
|
|
31
|
-
| `UsbStorage` | abstract class | USB mass storage device access |
|
|
32
|
-
|
|
33
|
-
## `UsbDeviceInfo`
|
|
34
|
-
|
|
35
|
-
```typescript
|
|
36
|
-
interface UsbDeviceInfo {
|
|
37
|
-
deviceName: string;
|
|
38
|
-
manufacturerName: string;
|
|
39
|
-
productName: string;
|
|
40
|
-
vendorId: number;
|
|
41
|
-
productId: number;
|
|
42
|
-
}
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## `UsbDeviceFilter`
|
|
46
|
-
|
|
47
|
-
```typescript
|
|
48
|
-
interface UsbDeviceFilter {
|
|
49
|
-
vendorId: number;
|
|
50
|
-
productId: number;
|
|
51
|
-
}
|
|
52
|
-
```
|
|
35
|
+
### `UsbDeviceFilter`
|
|
53
36
|
|
|
54
|
-
|
|
37
|
+
| Field | Type | Description |
|
|
38
|
+
|-------|------|-------------|
|
|
39
|
+
| `vendorId` | `number` | USB vendor ID |
|
|
40
|
+
| `productId` | `number` | USB product ID |
|
|
55
41
|
|
|
56
|
-
|
|
57
|
-
interface UsbFileInfo {
|
|
58
|
-
name: string;
|
|
59
|
-
isDirectory: boolean;
|
|
60
|
-
}
|
|
61
|
-
```
|
|
42
|
+
### `UsbFileInfo`
|
|
62
43
|
|
|
63
|
-
|
|
44
|
+
| Field | Type | Description |
|
|
45
|
+
|-------|------|-------------|
|
|
46
|
+
| `name` | `string` | File or directory name |
|
|
47
|
+
| `isDirectory` | `boolean` | Whether the entry is a directory |
|
|
64
48
|
|
|
65
|
-
|
|
66
|
-
interface UsbStoragePlugin {
|
|
67
|
-
getDevices(): Promise<{ devices: UsbDeviceInfo[] }>;
|
|
68
|
-
requestPermissions(options: UsbDeviceFilter): Promise<{ granted: boolean }>;
|
|
69
|
-
checkPermissions(options: UsbDeviceFilter): Promise<{ granted: boolean }>;
|
|
70
|
-
readdir(options: UsbDeviceFilter & { path: string }): Promise<{ files: UsbFileInfo[] }>;
|
|
71
|
-
readFile(options: UsbDeviceFilter & { path: string }): Promise<{ data: string | null }>;
|
|
72
|
-
}
|
|
73
|
-
```
|
|
49
|
+
### `UsbStoragePlugin`
|
|
74
50
|
|
|
75
|
-
|
|
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) |
|
|
76
58
|
|
|
77
|
-
|
|
59
|
+
### `UsbStorage`
|
|
78
60
|
|
|
79
|
-
|
|
80
|
-
abstract class UsbStorage {
|
|
81
|
-
static async getDevices(): Promise<UsbDeviceInfo[]>;
|
|
82
|
-
static async requestPermissions(filter: UsbDeviceFilter): Promise<boolean>;
|
|
83
|
-
static async checkPermissions(filter: UsbDeviceFilter): Promise<boolean>;
|
|
84
|
-
static async readdir(filter: UsbDeviceFilter, dirPath: string): Promise<UsbFileInfo[]>;
|
|
85
|
-
static async readFile(filter: UsbDeviceFilter, filePath: string): Promise<Bytes | undefined>;
|
|
86
|
-
}
|
|
87
|
-
```
|
|
61
|
+
Abstract class with static methods for USB Mass Storage access.
|
|
88
62
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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 |
|
|
92
70
|
|
|
93
71
|
## Usage Examples
|
|
94
72
|
|
|
95
|
-
### List
|
|
73
|
+
### List and read from USB device
|
|
96
74
|
|
|
97
75
|
```typescript
|
|
98
76
|
import { UsbStorage } from "@simplysm/capacitor-plugin-usb-storage";
|
|
99
77
|
|
|
78
|
+
// List connected devices
|
|
100
79
|
const devices = await UsbStorage.getDevices();
|
|
80
|
+
|
|
101
81
|
if (devices.length > 0) {
|
|
102
|
-
const
|
|
103
|
-
const filter = { vendorId: device.vendorId, productId: device.productId };
|
|
82
|
+
const filter = { vendorId: devices[0].vendorId, productId: devices[0].productId };
|
|
104
83
|
|
|
84
|
+
// Request permission
|
|
105
85
|
const granted = await UsbStorage.requestPermissions(filter);
|
|
86
|
+
|
|
106
87
|
if (granted) {
|
|
88
|
+
// Read directory
|
|
107
89
|
const files = await UsbStorage.readdir(filter, "/");
|
|
108
|
-
|
|
90
|
+
|
|
91
|
+
// Read a file
|
|
92
|
+
const data = await UsbStorage.readFile(filter, "/document.txt");
|
|
109
93
|
}
|
|
110
94
|
}
|
|
111
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.100",
|
|
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.100",
|
|
22
|
+
"@simplysm/core-common": "13.0.100"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@capacitor/core": "^7.6.0"
|