@simplysm/capacitor-plugin-usb-storage 13.0.97 → 13.0.98
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 +111 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# @simplysm/capacitor-plugin-usb-storage
|
|
2
|
+
|
|
3
|
+
Capacitor USB Storage Plugin -- read files from USB mass storage devices on Android.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @simplysm/capacitor-plugin-usb-storage
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## API Overview
|
|
12
|
+
|
|
13
|
+
### Types
|
|
14
|
+
|
|
15
|
+
| API | Type | Description |
|
|
16
|
+
|-----|------|-------------|
|
|
17
|
+
| `UsbDeviceInfo` | interface | USB device info (name, manufacturer, product, vendor/product IDs) |
|
|
18
|
+
| `UsbDeviceFilter` | interface | USB device filter by `vendorId` and `productId` |
|
|
19
|
+
| `UsbFileInfo` | interface | File entry info (`name`, `isDirectory`) |
|
|
20
|
+
|
|
21
|
+
### Interfaces
|
|
22
|
+
|
|
23
|
+
| API | Type | Description |
|
|
24
|
+
|-----|------|-------------|
|
|
25
|
+
| `UsbStoragePlugin` | interface | Low-level Capacitor plugin interface for USB storage operations |
|
|
26
|
+
|
|
27
|
+
### Classes
|
|
28
|
+
|
|
29
|
+
| API | Type | Description |
|
|
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
|
+
```
|
|
53
|
+
|
|
54
|
+
## `UsbFileInfo`
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
interface UsbFileInfo {
|
|
58
|
+
name: string;
|
|
59
|
+
isDirectory: boolean;
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## `UsbStoragePlugin`
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
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
|
+
```
|
|
74
|
+
|
|
75
|
+
Low-level Capacitor plugin interface. Use `UsbStorage` static methods instead of calling this directly.
|
|
76
|
+
|
|
77
|
+
## `UsbStorage`
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
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
|
+
```
|
|
88
|
+
|
|
89
|
+
Plugin for interacting with USB storage devices.
|
|
90
|
+
- Android: USB Mass Storage access via libaums library.
|
|
91
|
+
- Browser: IndexedDB-based virtual USB storage emulation.
|
|
92
|
+
|
|
93
|
+
## Usage Examples
|
|
94
|
+
|
|
95
|
+
### List USB devices and read files
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
import { UsbStorage } from "@simplysm/capacitor-plugin-usb-storage";
|
|
99
|
+
|
|
100
|
+
const devices = await UsbStorage.getDevices();
|
|
101
|
+
if (devices.length > 0) {
|
|
102
|
+
const device = devices[0];
|
|
103
|
+
const filter = { vendorId: device.vendorId, productId: device.productId };
|
|
104
|
+
|
|
105
|
+
const granted = await UsbStorage.requestPermissions(filter);
|
|
106
|
+
if (granted) {
|
|
107
|
+
const files = await UsbStorage.readdir(filter, "/");
|
|
108
|
+
const data = await UsbStorage.readFile(filter, "/readme.txt");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
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.98",
|
|
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.98",
|
|
22
|
+
"@simplysm/core-common": "13.0.98"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@capacitor/core": "^7.6.0"
|