@simplysm/capacitor-plugin-file-system 13.0.78 → 13.0.81

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/package.json +6 -5
  2. package/README.md +0 -230
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/capacitor-plugin-file-system",
3
- "version": "13.0.78",
3
+ "version": "13.0.81",
4
4
  "description": "Simplysm Package - Capacitor File System 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.78",
22
- "@simplysm/core-common": "13.0.78"
22
+ "@simplysm/core-browser": "13.0.81",
23
+ "@simplysm/core-common": "13.0.81"
23
24
  },
24
25
  "devDependencies": {
25
- "@capacitor/core": "^7.5.0"
26
+ "@capacitor/core": "^7.6.0"
26
27
  },
27
28
  "peerDependencies": {
28
29
  "@capacitor/core": "^7.4.4"
package/README.md DELETED
@@ -1,230 +0,0 @@
1
- # @simplysm/capacitor-plugin-file-system
2
-
3
- Simplysm Package - Capacitor File System Plugin
4
-
5
- ## Installation
6
-
7
- ```bash
8
- pnpm add @simplysm/capacitor-plugin-file-system
9
- ```
10
-
11
- ## Main Modules
12
-
13
- ### FileSystem
14
-
15
- An abstract class that provides static methods for file system access via the Capacitor plugin bridge.
16
-
17
- - **Android 11+**: Full file system access via `MANAGE_EXTERNAL_STORAGE` permission.
18
- - **Android 10 and below**: `READ_EXTERNAL_STORAGE` / `WRITE_EXTERNAL_STORAGE` permission.
19
- - **Browser**: IndexedDB-based emulation.
20
-
21
- ```typescript
22
- import { FileSystem } from "@simplysm/capacitor-plugin-file-system";
23
- ```
24
-
25
- #### `FileSystem.checkPermissions()`
26
-
27
- Checks whether the required file system permission has been granted.
28
-
29
- ```typescript
30
- static async checkPermissions(): Promise<boolean>
31
- ```
32
-
33
- ```typescript
34
- const granted = await FileSystem.checkPermissions();
35
- if (!granted) {
36
- await FileSystem.requestPermissions();
37
- }
38
- ```
39
-
40
- #### `FileSystem.requestPermissions()`
41
-
42
- Requests the required file system permission.
43
-
44
- - Android 11+: Navigates to the system settings page.
45
- - Android 10 and below: Shows the OS permission dialog.
46
-
47
- ```typescript
48
- static async requestPermissions(): Promise<void>
49
- ```
50
-
51
- ```typescript
52
- await FileSystem.requestPermissions();
53
- ```
54
-
55
- #### `FileSystem.readdir(dirPath)`
56
-
57
- Reads the contents of a directory and returns an array of `FileInfo` objects.
58
-
59
- ```typescript
60
- static async readdir(dirPath: string): Promise<FileInfo[]>
61
- ```
62
-
63
- ```typescript
64
- const entries = await FileSystem.readdir("/storage/emulated/0/Download");
65
- for (const entry of entries) {
66
- console.log(entry.name, entry.isDirectory);
67
- }
68
- ```
69
-
70
- #### `FileSystem.getStoragePath(type)`
71
-
72
- Returns the absolute path for the given storage type.
73
-
74
- ```typescript
75
- static async getStoragePath(type: StorageType): Promise<string>
76
- ```
77
-
78
- | `type` value | Description |
79
- |-------------------|--------------------------------------------------------------------|
80
- | `"external"` | External storage root (`Environment.getExternalStorageDirectory`) |
81
- | `"externalFiles"` | App-specific external files directory |
82
- | `"externalCache"` | App-specific external cache directory |
83
- | `"externalMedia"` | App-specific external media directory |
84
- | `"appData"` | App data directory |
85
- | `"appFiles"` | App files directory |
86
- | `"appCache"` | App cache directory |
87
-
88
- ```typescript
89
- const path = await FileSystem.getStoragePath("external");
90
- console.log(path); // e.g. "/storage/emulated/0"
91
- ```
92
-
93
- #### `FileSystem.getUri(filePath)`
94
-
95
- Returns a `FileProvider` URI for the given file path. Required for sharing files with other apps on Android.
96
-
97
- ```typescript
98
- static async getUri(filePath: string): Promise<string>
99
- ```
100
-
101
- ```typescript
102
- const uri = await FileSystem.getUri("/storage/emulated/0/Download/report.pdf");
103
- console.log(uri); // content://...
104
- ```
105
-
106
- #### `FileSystem.writeFile(filePath, data)`
107
-
108
- Writes data to a file. Accepts a UTF-8 string or a `Bytes` (`Uint8Array`) value. Strings are written with UTF-8 encoding; byte arrays are written with Base64 encoding.
109
-
110
- ```typescript
111
- static async writeFile(filePath: string, data: string | Bytes): Promise<void>
112
- ```
113
-
114
- ```typescript
115
- // Write text
116
- await FileSystem.writeFile("/storage/emulated/0/Download/hello.txt", "Hello, world!");
117
-
118
- // Write binary
119
- const bytes: Uint8Array = new Uint8Array([0x89, 0x50, 0x4e, 0x47]);
120
- await FileSystem.writeFile("/storage/emulated/0/Download/image.png", bytes);
121
- ```
122
-
123
- #### `FileSystem.readFile(filePath)`
124
-
125
- Reads a file. When called without an encoding argument, returns a `Bytes` (`Uint8Array`) value. When called with `"utf8"`, returns a UTF-8 string.
126
-
127
- ```typescript
128
- static async readFile(filePath: string): Promise<Bytes>
129
- static async readFile(filePath: string, encoding: "utf8"): Promise<string>
130
- ```
131
-
132
- ```typescript
133
- // Read as bytes
134
- const bytes = await FileSystem.readFile("/storage/emulated/0/Download/image.png");
135
- console.log(bytes.length);
136
-
137
- // Read as string
138
- const text = await FileSystem.readFile("/storage/emulated/0/Download/hello.txt", "utf8");
139
- console.log(text);
140
- ```
141
-
142
- #### `FileSystem.remove(targetPath)`
143
-
144
- Deletes a file or directory recursively.
145
-
146
- ```typescript
147
- static async remove(targetPath: string): Promise<void>
148
- ```
149
-
150
- ```typescript
151
- await FileSystem.remove("/storage/emulated/0/Download/old-folder");
152
- ```
153
-
154
- #### `FileSystem.mkdir(targetPath)`
155
-
156
- Creates a directory, including any intermediate directories (recursive).
157
-
158
- ```typescript
159
- static async mkdir(targetPath: string): Promise<void>
160
- ```
161
-
162
- ```typescript
163
- await FileSystem.mkdir("/storage/emulated/0/Download/new-folder/sub");
164
- ```
165
-
166
- #### `FileSystem.exists(targetPath)`
167
-
168
- Checks whether a file or directory exists at the given path.
169
-
170
- ```typescript
171
- static async exists(targetPath: string): Promise<boolean>
172
- ```
173
-
174
- ```typescript
175
- const exists = await FileSystem.exists("/storage/emulated/0/Download/report.pdf");
176
- console.log(exists); // true or false
177
- ```
178
-
179
- ## Types
180
-
181
- ### `StorageType`
182
-
183
- Union type representing supported storage location identifiers used with `FileSystem.getStoragePath()`.
184
-
185
- ```typescript
186
- import { type StorageType } from "@simplysm/capacitor-plugin-file-system";
187
-
188
- type StorageType =
189
- | "external"
190
- | "externalFiles"
191
- | "externalCache"
192
- | "externalMedia"
193
- | "appData"
194
- | "appFiles"
195
- | "appCache";
196
- ```
197
-
198
- ### `FileInfo`
199
-
200
- Represents a single entry returned by `FileSystem.readdir()`.
201
-
202
- ```typescript
203
- import { type FileInfo } from "@simplysm/capacitor-plugin-file-system";
204
-
205
- interface FileInfo {
206
- name: string; // File or directory name
207
- isDirectory: boolean; // true if the entry is a directory
208
- }
209
- ```
210
-
211
- ### `FileSystemPlugin`
212
-
213
- The low-level plugin interface registered with Capacitor. Used internally by `FileSystem`. Direct use is not required in most cases.
214
-
215
- ```typescript
216
- import { type FileSystemPlugin } from "@simplysm/capacitor-plugin-file-system";
217
-
218
- interface FileSystemPlugin {
219
- checkPermissions(): Promise<{ granted: boolean }>;
220
- requestPermissions(): Promise<void>;
221
- readdir(options: { path: string }): Promise<{ files: FileInfo[] }>;
222
- getStoragePath(options: { type: StorageType }): Promise<{ path: string }>;
223
- getUri(options: { path: string }): Promise<{ uri: string }>;
224
- writeFile(options: { path: string; data: string; encoding?: "utf8" | "base64" }): Promise<void>;
225
- readFile(options: { path: string; encoding?: "utf8" | "base64" }): Promise<{ data: string }>;
226
- remove(options: { path: string }): Promise<void>;
227
- mkdir(options: { path: string }): Promise<void>;
228
- exists(options: { path: string }): Promise<{ exists: boolean }>;
229
- }
230
- ```