@simplysm/capacitor-plugin-usb-storage 13.0.77 → 13.0.80
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/package.json +6 -5
- package/README.md +0 -159
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.80",
|
|
4
4
|
"description": "Simplysm Package - Capacitor USB Storage Plugin",
|
|
5
5
|
"author": "simplysm",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,14 +15,15 @@
|
|
|
15
15
|
"files": [
|
|
16
16
|
"dist",
|
|
17
17
|
"src",
|
|
18
|
-
"android"
|
|
18
|
+
"android",
|
|
19
|
+
"docs"
|
|
19
20
|
],
|
|
20
21
|
"dependencies": {
|
|
21
|
-
"@simplysm/core-browser": "13.0.
|
|
22
|
-
"@simplysm/core-common": "13.0.
|
|
22
|
+
"@simplysm/core-browser": "13.0.80",
|
|
23
|
+
"@simplysm/core-common": "13.0.80"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
|
-
"@capacitor/core": "^7.
|
|
26
|
+
"@capacitor/core": "^7.6.0"
|
|
26
27
|
},
|
|
27
28
|
"peerDependencies": {
|
|
28
29
|
"@capacitor/core": "^7.4.4"
|
package/README.md
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
# @simplysm/capacitor-plugin-usb-storage
|
|
2
|
-
|
|
3
|
-
Simplysm Package - Capacitor USB Storage Plugin
|
|
4
|
-
|
|
5
|
-
Provides access to USB Mass Storage devices from a Capacitor application.
|
|
6
|
-
|
|
7
|
-
- **Android**: USB Mass Storage access via the libaums library.
|
|
8
|
-
- **Browser**: IndexedDB-based virtual USB storage emulation for development.
|
|
9
|
-
|
|
10
|
-
## Installation
|
|
11
|
-
|
|
12
|
-
```bash
|
|
13
|
-
pnpm add @simplysm/capacitor-plugin-usb-storage
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## Main Modules
|
|
17
|
-
|
|
18
|
-
### UsbStorage
|
|
19
|
-
|
|
20
|
-
An abstract class that exposes static methods for interacting with USB storage devices.
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
import { UsbStorage } from "@simplysm/capacitor-plugin-usb-storage";
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
#### `UsbStorage.getDevices()`
|
|
27
|
-
|
|
28
|
-
Returns a list of currently connected USB devices.
|
|
29
|
-
|
|
30
|
-
```typescript
|
|
31
|
-
static async getDevices(): Promise<UsbDeviceInfo[]>
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
```typescript
|
|
35
|
-
const devices = await UsbStorage.getDevices();
|
|
36
|
-
for (const device of devices) {
|
|
37
|
-
console.log(device.productName, device.vendorId, device.productId);
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
#### `UsbStorage.requestPermissions(filter)`
|
|
42
|
-
|
|
43
|
-
Requests access permission for a specific USB device identified by its vendor and product IDs.
|
|
44
|
-
|
|
45
|
-
```typescript
|
|
46
|
-
static async requestPermissions(filter: UsbDeviceFilter): Promise<boolean>
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
```typescript
|
|
50
|
-
const granted = await UsbStorage.requestPermissions({ vendorId: 0x1234, productId: 0x5678 });
|
|
51
|
-
if (granted) {
|
|
52
|
-
console.log("Permission granted");
|
|
53
|
-
}
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
#### `UsbStorage.checkPermissions(filter)`
|
|
57
|
-
|
|
58
|
-
Checks whether access permission for a specific USB device is currently held.
|
|
59
|
-
|
|
60
|
-
```typescript
|
|
61
|
-
static async checkPermissions(filter: UsbDeviceFilter): Promise<boolean>
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
```typescript
|
|
65
|
-
const alreadyGranted = await UsbStorage.checkPermissions({ vendorId: 0x1234, productId: 0x5678 });
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
#### `UsbStorage.readdir(filter, dirPath)`
|
|
69
|
-
|
|
70
|
-
Reads the contents of a directory on the USB storage device.
|
|
71
|
-
|
|
72
|
-
```typescript
|
|
73
|
-
static async readdir(filter: UsbDeviceFilter, dirPath: string): Promise<UsbFileInfo[]>
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
```typescript
|
|
77
|
-
const filter = { vendorId: 0x1234, productId: 0x5678 };
|
|
78
|
-
const entries = await UsbStorage.readdir(filter, "/");
|
|
79
|
-
for (const entry of entries) {
|
|
80
|
-
console.log(entry.name, entry.isDirectory ? "(dir)" : "(file)");
|
|
81
|
-
}
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
#### `UsbStorage.readFile(filter, filePath)`
|
|
85
|
-
|
|
86
|
-
Reads a file from the USB storage device and returns its contents as `Bytes`. Returns `undefined` if the file does not exist.
|
|
87
|
-
|
|
88
|
-
```typescript
|
|
89
|
-
static async readFile(filter: UsbDeviceFilter, filePath: string): Promise<Bytes | undefined>
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
```typescript
|
|
93
|
-
const filter = { vendorId: 0x1234, productId: 0x5678 };
|
|
94
|
-
const bytes = await UsbStorage.readFile(filter, "/data/file.bin");
|
|
95
|
-
if (bytes !== undefined) {
|
|
96
|
-
console.log("File size:", bytes.length);
|
|
97
|
-
}
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
## Types
|
|
101
|
-
|
|
102
|
-
```typescript
|
|
103
|
-
import type {
|
|
104
|
-
UsbDeviceInfo,
|
|
105
|
-
UsbDeviceFilter,
|
|
106
|
-
UsbFileInfo,
|
|
107
|
-
UsbStoragePlugin,
|
|
108
|
-
} from "@simplysm/capacitor-plugin-usb-storage";
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### `UsbDeviceInfo`
|
|
112
|
-
|
|
113
|
-
Describes a connected USB device.
|
|
114
|
-
|
|
115
|
-
```typescript
|
|
116
|
-
interface UsbDeviceInfo {
|
|
117
|
-
deviceName: string;
|
|
118
|
-
manufacturerName: string;
|
|
119
|
-
productName: string;
|
|
120
|
-
vendorId: number;
|
|
121
|
-
productId: number;
|
|
122
|
-
}
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### `UsbDeviceFilter`
|
|
126
|
-
|
|
127
|
-
Identifies a USB device by its vendor and product IDs. Used as a selector in permission and file-system calls.
|
|
128
|
-
|
|
129
|
-
```typescript
|
|
130
|
-
interface UsbDeviceFilter {
|
|
131
|
-
vendorId: number;
|
|
132
|
-
productId: number;
|
|
133
|
-
}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### `UsbFileInfo`
|
|
137
|
-
|
|
138
|
-
Describes a single entry (file or directory) returned by `readdir`.
|
|
139
|
-
|
|
140
|
-
```typescript
|
|
141
|
-
interface UsbFileInfo {
|
|
142
|
-
name: string;
|
|
143
|
-
isDirectory: boolean;
|
|
144
|
-
}
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
### `UsbStoragePlugin`
|
|
148
|
-
|
|
149
|
-
The raw Capacitor plugin interface registered under the `"UsbStorage"` plugin name. Prefer using the `UsbStorage` abstract class instead of calling this interface directly.
|
|
150
|
-
|
|
151
|
-
```typescript
|
|
152
|
-
interface UsbStoragePlugin {
|
|
153
|
-
getDevices(): Promise<{ devices: UsbDeviceInfo[] }>;
|
|
154
|
-
requestPermissions(options: UsbDeviceFilter): Promise<{ granted: boolean }>;
|
|
155
|
-
checkPermissions(options: UsbDeviceFilter): Promise<{ granted: boolean }>;
|
|
156
|
-
readdir(options: UsbDeviceFilter & { path: string }): Promise<{ files: UsbFileInfo[] }>;
|
|
157
|
-
readFile(options: UsbDeviceFilter & { path: string }): Promise<{ data: string | null }>;
|
|
158
|
-
}
|
|
159
|
-
```
|