@symbiote-native/file-system 0.1.0
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/LICENSE +21 -0
- package/README.md +262 -0
- package/build/angular/index.d.ts +1 -0
- package/build/angular/index.js +1 -0
- package/build/core/file-system.d.ts +169 -0
- package/build/core/file-system.js +404 -0
- package/build/core/index.d.ts +2 -0
- package/build/core/index.js +2 -0
- package/build/core/native-module.d.ts +32 -0
- package/build/core/native-module.js +2 -0
- package/build/core/types.d.ts +104 -0
- package/build/core/types.js +15 -0
- package/build/next/directory.d.ts +36 -0
- package/build/next/directory.js +59 -0
- package/build/next/file.d.ts +71 -0
- package/build/next/file.js +207 -0
- package/build/next/index.d.ts +5 -0
- package/build/next/index.js +5 -0
- package/build/next/native-module.d.ts +109 -0
- package/build/next/native-module.js +2 -0
- package/build/next/network-tasks.d.ts +118 -0
- package/build/next/network-tasks.js +333 -0
- package/build/next/node-path.d.ts +16 -0
- package/build/next/node-path.js +353 -0
- package/build/next/path-utilities.d.ts +42 -0
- package/build/next/path-utilities.js +110 -0
- package/build/next/paths.d.ts +22 -0
- package/build/next/paths.js +43 -0
- package/build/next/streams.d.ts +25 -0
- package/build/next/streams.js +55 -0
- package/build/next/types.d.ts +152 -0
- package/build/next/types.js +19 -0
- package/build/next/url-utilities.d.ts +3 -0
- package/build/next/url-utilities.js +62 -0
- package/build/next/watcher.d.ts +19 -0
- package/build/next/watcher.js +64 -0
- package/build-ngc/angular/index.d.ts +1 -0
- package/build-ngc/angular/index.js +2 -0
- package/build-ngc/angular/index.js.map +1 -0
- package/build-ngc/next/directory.d.ts +36 -0
- package/build-ngc/next/directory.js +60 -0
- package/build-ngc/next/directory.js.map +1 -0
- package/build-ngc/next/file.d.ts +71 -0
- package/build-ngc/next/file.js +208 -0
- package/build-ngc/next/file.js.map +1 -0
- package/build-ngc/next/index.d.ts +5 -0
- package/build-ngc/next/index.js +6 -0
- package/build-ngc/next/index.js.map +1 -0
- package/build-ngc/next/native-module.d.ts +109 -0
- package/build-ngc/next/native-module.js +3 -0
- package/build-ngc/next/native-module.js.map +1 -0
- package/build-ngc/next/network-tasks.d.ts +118 -0
- package/build-ngc/next/network-tasks.js +334 -0
- package/build-ngc/next/network-tasks.js.map +1 -0
- package/build-ngc/next/node-path.d.ts +16 -0
- package/build-ngc/next/node-path.js +354 -0
- package/build-ngc/next/node-path.js.map +1 -0
- package/build-ngc/next/path-utilities.d.ts +42 -0
- package/build-ngc/next/path-utilities.js +111 -0
- package/build-ngc/next/path-utilities.js.map +1 -0
- package/build-ngc/next/paths.d.ts +22 -0
- package/build-ngc/next/paths.js +44 -0
- package/build-ngc/next/paths.js.map +1 -0
- package/build-ngc/next/streams.d.ts +25 -0
- package/build-ngc/next/streams.js +56 -0
- package/build-ngc/next/streams.js.map +1 -0
- package/build-ngc/next/types.d.ts +152 -0
- package/build-ngc/next/types.js +20 -0
- package/build-ngc/next/types.js.map +1 -0
- package/build-ngc/next/url-utilities.d.ts +3 -0
- package/build-ngc/next/url-utilities.js +63 -0
- package/build-ngc/next/url-utilities.js.map +1 -0
- package/build-ngc/next/watcher.d.ts +19 -0
- package/build-ngc/next/watcher.js +65 -0
- package/build-ngc/next/watcher.js.map +1 -0
- package/native-link.json +17 -0
- package/package.json +154 -0
- package/src/angular/index.ts +1 -0
- package/src/core/file-system.ts +634 -0
- package/src/core/index.ts +2 -0
- package/src/core/native-module.ts +99 -0
- package/src/core/types.ts +135 -0
- package/src/next/directory.ts +83 -0
- package/src/next/file.ts +318 -0
- package/src/next/index.ts +5 -0
- package/src/next/native-module.ts +188 -0
- package/src/next/network-tasks.ts +456 -0
- package/src/next/node-path.ts +362 -0
- package/src/next/path-utilities.ts +144 -0
- package/src/next/paths.ts +52 -0
- package/src/next/streams-ambient.d.ts +34 -0
- package/src/next/streams.ts +81 -0
- package/src/next/types.ts +194 -0
- package/src/next/url-utilities.ts +70 -0
- package/src/next/watcher.ts +106 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 A. Prokopenko
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
# @symbiote-native/file-system
|
|
2
|
+
|
|
3
|
+
A wrapper package for [SymbioteNative](../../README.md) that makes
|
|
4
|
+
[`expo-file-system`](https://github.com/expo/expo/tree/main/packages/expo-file-system) usable
|
|
5
|
+
from **every** adapter — React, Vue, Svelte, Solid, and Angular.
|
|
6
|
+
|
|
7
|
+
**Both of upstream's surfaces are ported, matching upstream's own layout.** The default export is
|
|
8
|
+
the modern, shared-object API — `File`/`Directory`/`Paths` classes built on JSI shared objects
|
|
9
|
+
(`expo-modules-core`'s `SharedObject`), upstream's own default entry as of SDK 54. The legacy,
|
|
10
|
+
function-based API (read/write/copy/move/delete, directory listing, disk-space queries, resumable
|
|
11
|
+
download/upload, Android Storage Access Framework) is available at the `./legacy` subpath,
|
|
12
|
+
reachable in the real upstream package as `expo-file-system/legacy`. See
|
|
13
|
+
[Legacy API (`/legacy`)](#legacy-api-legacy) below.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
**New app:**
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx @symbiote-native/cli new my-app --file-system
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Existing SymbioteNative app:**
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npx @symbiote-native/cli add --file-system
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Either way: installs `@symbiote-native/file-system` and wires the native autolinking automatically — see
|
|
30
|
+
[`@symbiote-native/cli`](../cli).
|
|
31
|
+
|
|
32
|
+
<details>
|
|
33
|
+
<summary>Manual install (no CLI — installing and wiring native autolinking by hand)</summary>
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install @symbiote-native/file-system
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`expo-file-system` and `expo-modules-core` come along as regular dependencies, pinned to exact
|
|
40
|
+
versions — never install them yourself, and never add the `expo` meta-package to your project.
|
|
41
|
+
|
|
42
|
+
## Required one-time step: native autolinking wiring
|
|
43
|
+
|
|
44
|
+
Same one-time step as every other `expo-modules-core` package this project ships — see
|
|
45
|
+
[`@symbiote-native/local-auth`'s README](../local-auth/README.md#required-one-time-step-native-autolinking-wiring)
|
|
46
|
+
and the `symbiote-expo-native-module` project skill.
|
|
47
|
+
|
|
48
|
+
`native-link.json` carries no `Info.plist` keys or `<application>` attributes — upstream's own
|
|
49
|
+
config plugin only sets two OPT-IN keys (`LSSupportsOpeningDocumentsInPlace`,
|
|
50
|
+
`UIFileSharingEnabled`), which an app adds itself only if it wants its Documents directory exposed
|
|
51
|
+
to the Files app; nothing here needs either by default.
|
|
52
|
+
|
|
53
|
+
</details>
|
|
54
|
+
|
|
55
|
+
**Android runtime permissions are NOT added automatically, by the CLI or otherwise** — add
|
|
56
|
+
whichever of these your app actually needs to your own `AndroidManifest.xml`, the same opt-in
|
|
57
|
+
shape [`@symbiote-native/media-library`](../media-library) uses:
|
|
58
|
+
|
|
59
|
+
```xml
|
|
60
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
61
|
+
<!-- only if reading/writing outside your app's own sandboxed directories -->
|
|
62
|
+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
|
63
|
+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`Paths.document`/`Paths.cache` operations and `StorageAccessFramework` (which asks the user to pick
|
|
67
|
+
a directory at runtime, and never touches the two `EXTERNAL_STORAGE` permissions) both work without
|
|
68
|
+
any of these on modern Android — they matter only for direct legacy-path access outside the app
|
|
69
|
+
sandbox.
|
|
70
|
+
|
|
71
|
+
## Shape
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
src/next/ File.ts / Directory.ts / Paths.ts / network-tasks.ts (UploadTask/DownloadTask) /
|
|
75
|
+
watcher.ts (FileSystemWatcher) / path-utilities.ts / streams.ts / types.ts —
|
|
76
|
+
the default, shared-object surface. See "API" below.
|
|
77
|
+
src/core/ file-system.ts (every legacy function + DownloadResumable/UploadTask +
|
|
78
|
+
StorageAccessFramework), native-module.ts, types.ts. See "Legacy API" below.
|
|
79
|
+
src/angular/ @symbiote-native/file-system/angular — export * from '../next'
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`./react`, `./vue`, `./svelte`, and `./solid` are `exports`-map aliases straight onto `src/next/`
|
|
83
|
+
— every class here carries no children/ref/render fields, so there is nothing to split per
|
|
84
|
+
framework. `./angular` stays a physical file/subpath since Angular ships through a separate
|
|
85
|
+
`ngc`/AOT build (`build-ngc/`). `./legacy` is one subpath shared by every adapter, for the same
|
|
86
|
+
reason — plain async functions have no framework-specific shape either.
|
|
87
|
+
|
|
88
|
+
## Use it
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
import { File, Directory, Paths } from '@symbiote-native/file-system';
|
|
92
|
+
|
|
93
|
+
const file = new File(Paths.document, 'notes.txt');
|
|
94
|
+
file.write('hello world');
|
|
95
|
+
const contents = file.text();
|
|
96
|
+
|
|
97
|
+
const dir = new Directory(Paths.document, 'photos');
|
|
98
|
+
dir.create();
|
|
99
|
+
const entries = dir.list();
|
|
100
|
+
|
|
101
|
+
const downloaded = await File.downloadFileAsync(
|
|
102
|
+
'https://example.com/big-file.zip',
|
|
103
|
+
Paths.cache,
|
|
104
|
+
{
|
|
105
|
+
onProgress: ({ bytesWritten, totalBytes }) =>
|
|
106
|
+
console.log(bytesWritten / totalBytes),
|
|
107
|
+
},
|
|
108
|
+
);
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Identical import surface on every adapter — `@symbiote-native/file-system/react`, `/vue`,
|
|
112
|
+
`/svelte`, `/solid`, `/angular` all re-export the same classes.
|
|
113
|
+
|
|
114
|
+
## API
|
|
115
|
+
|
|
116
|
+
### `File`
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
new File(...uris: (string | File | Directory)[])
|
|
120
|
+
static downloadFileAsync(url, destination, options?): Promise<File>
|
|
121
|
+
static pickFileAsync(options?): Promise<IPickSingleFileResult | IPickMultipleFilesResult>
|
|
122
|
+
static createDownloadTask(url, destination, options?): DownloadTask
|
|
123
|
+
|
|
124
|
+
.uri / .exists / .size / .md5 / .type / .lastModified / .creationTime / .parentDirectory /
|
|
125
|
+
.extension / .name
|
|
126
|
+
.write(contents, options?) / .text() / .bytes() / .base64() // + Sync variants
|
|
127
|
+
.create(options?) / .delete() / .copy(dest) / .move(dest) // + Sync variants
|
|
128
|
+
.open(mode) -> IFileSystemHandle
|
|
129
|
+
.readableStream() / .writableStream() / .stream() / .arrayBuffer() / .json() / .formData()
|
|
130
|
+
.slice(start?, end?, contentType?): Blob
|
|
131
|
+
.upload(url, options?): Promise<IFileSystemUploadResult>
|
|
132
|
+
.createUploadTask(url, options?): UploadTask
|
|
133
|
+
.watch(callback, options?): IFileSystemWatchSubscription
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### `Directory`
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
new Directory(...uris: (string | File | Directory)[])
|
|
140
|
+
static pickDirectoryAsync(initialUri?): Promise<Directory>
|
|
141
|
+
|
|
142
|
+
.uri / .exists / .size / .parentDirectory / .name
|
|
143
|
+
.create(options?) / .delete() / .copy(dest) / .move(dest)
|
|
144
|
+
.list(): (File | Directory)[]
|
|
145
|
+
.createFile(name, options?): File
|
|
146
|
+
.createDirectory(name, options?): Directory
|
|
147
|
+
.watch(callback, options?): IFileSystemWatchSubscription
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### `Paths`
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
Paths.cache / Paths.document / Paths.bundle: Directory
|
|
154
|
+
Paths.appleSharedContainers: Record<string, Directory> // ios only
|
|
155
|
+
Paths.totalDiskSpace / Paths.availableDiskSpace: number
|
|
156
|
+
Paths.info(...uris): IPathInfo
|
|
157
|
+
Paths.join / .relative / .isAbsolute / .normalize / .dirname / .basename / .extname / .parse
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### `UploadTask` / `DownloadTask`
|
|
161
|
+
|
|
162
|
+
State machines over a network transfer, both cancellable via `AbortSignal`:
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
new UploadTask(file, url, options?)
|
|
166
|
+
.uploadAsync(): Promise<IFileSystemUploadResult>
|
|
167
|
+
.state: IFileSystemUploadTaskState // idle/active/completed/cancelled/error
|
|
168
|
+
|
|
169
|
+
new DownloadTask(url, destination, options?)
|
|
170
|
+
.downloadAsync(): Promise<File>
|
|
171
|
+
.pause() / .resume()
|
|
172
|
+
.savable(): IFileSystemDownloadPauseState // resume after app restart
|
|
173
|
+
static fromSavable(savable): DownloadTask
|
|
174
|
+
.state: IFileSystemDownloadTaskState // + paused
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Errors
|
|
178
|
+
|
|
179
|
+
No custom JS error-class hierarchy — every native exception surfaces as an ordinary thrown `Error`
|
|
180
|
+
or rejected `Promise`, same as every other native module wrapper in this repo.
|
|
181
|
+
|
|
182
|
+
| Trigger | When |
|
|
183
|
+
| ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
184
|
+
| Constructing a `File`/`Directory` with an invalid/empty path | `validatePath()` throws synchronously in the constructor |
|
|
185
|
+
| Reading/writing through a stale or already-closed handle | `IFileSystemHandle` methods throw |
|
|
186
|
+
| `pickFileAsync`/`pickDirectoryAsync` cancelled by the user | Rejects with an `AbortError` (old-API overload) or resolves `{ canceled: true }` (options-object overload) |
|
|
187
|
+
| `upload()`/`createUploadTask()`/`createDownloadTask()` aborted via `options.signal` | Rejects with an `AbortError` |
|
|
188
|
+
| `.copy()`/`.move()` onto an existing destination without `overwrite: true` | Native `Exception` — destination already exists |
|
|
189
|
+
| Any operation on a path outside the app sandbox without permission | Native `Exception` — permission/sandbox violation |
|
|
190
|
+
|
|
191
|
+
## Legacy API (`/legacy`)
|
|
192
|
+
|
|
193
|
+
Upstream's original function-based surface — plain async functions over `expo-modules-core`
|
|
194
|
+
instead of JSI shared objects. Same install, same autolinking step as above; the native module
|
|
195
|
+
behind it is a **separate** registration (`ExponentFileSystem`, vs. the modern API's
|
|
196
|
+
`FileSystem`) inside the same `expo-file-system` npm dependency — nothing extra to install.
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
import {
|
|
200
|
+
documentDirectory,
|
|
201
|
+
writeAsStringAsync,
|
|
202
|
+
readAsStringAsync,
|
|
203
|
+
downloadAsync,
|
|
204
|
+
createDownloadResumable,
|
|
205
|
+
} from '@symbiote-native/file-system/legacy';
|
|
206
|
+
|
|
207
|
+
const fileUri = `${documentDirectory}notes.txt`;
|
|
208
|
+
await writeAsStringAsync(fileUri, 'hello world');
|
|
209
|
+
const contents = await readAsStringAsync(fileUri);
|
|
210
|
+
|
|
211
|
+
const resumable = createDownloadResumable(
|
|
212
|
+
'https://example.com/big-file.zip',
|
|
213
|
+
`${documentDirectory}big-file.zip`,
|
|
214
|
+
undefined,
|
|
215
|
+
({ totalBytesWritten, totalBytesExpectedToWrite }) => {
|
|
216
|
+
console.log(totalBytesWritten / totalBytesExpectedToWrite);
|
|
217
|
+
},
|
|
218
|
+
);
|
|
219
|
+
await resumable.downloadAsync();
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Legacy API reference
|
|
223
|
+
|
|
224
|
+
```ts
|
|
225
|
+
documentDirectory / cacheDirectory / bundleDirectory: string | null // trailing-slash-normalized
|
|
226
|
+
getInfoAsync(fileUri, options?): Promise<IFileSystemFileInfo>
|
|
227
|
+
readAsStringAsync(fileUri, options?): Promise<string>
|
|
228
|
+
writeAsStringAsync(fileUri, contents, options?): Promise<void>
|
|
229
|
+
getContentUriAsync(fileUri): Promise<string> // android; echoes input on ios
|
|
230
|
+
deleteAsync(fileUri, options?): Promise<void>
|
|
231
|
+
moveAsync(options) / copyAsync(options): Promise<void> // { from, to }
|
|
232
|
+
makeDirectoryAsync(fileUri, options?): Promise<void>
|
|
233
|
+
readDirectoryAsync(fileUri): Promise<string[]>
|
|
234
|
+
getFreeDiskStorageAsync() / getTotalDiskCapacityAsync(): Promise<number> // bytes
|
|
235
|
+
downloadAsync(uri, fileUri, options?): Promise<IFileSystemDownloadResult>
|
|
236
|
+
uploadAsync(url, fileUri, options?): Promise<IFileSystemUploadResult>
|
|
237
|
+
createDownloadResumable(uri, fileUri, options?, callback?, resumeData?): DownloadResumable
|
|
238
|
+
createUploadTask(url, fileUri, options?, callback?): UploadTask
|
|
239
|
+
StorageAccessFramework.{ getUriForDirectoryInRoot, requestDirectoryPermissionsAsync,
|
|
240
|
+
readDirectoryAsync, makeDirectoryAsync, createFileAsync,
|
|
241
|
+
writeAsStringAsync, readAsStringAsync, deleteAsync, moveAsync, copyAsync } // android
|
|
242
|
+
FileSystemSessionType, FileSystemUploadType, FileSystemEncodingType // runtime enums
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
`DownloadResumable` carries `cancelAsync`/`pauseAsync`/`resumeAsync`/`savable()`;
|
|
246
|
+
`UploadTask` carries `cancelAsync`/`uploadAsync`. Both report progress through the `callback`
|
|
247
|
+
passed at construction, driven by a native event subscription keyed on the task's own uuid.
|
|
248
|
+
|
|
249
|
+
Plus every `IFileSystem*` type, ported from upstream's `legacy/FileSystem.types.ts` with this
|
|
250
|
+
repo's `I`-prefix convention for exported types (`ts-js-best-practices`).
|
|
251
|
+
|
|
252
|
+
### Legacy notes
|
|
253
|
+
|
|
254
|
+
- **`StorageAccessFramework` is Android-only** — every function throws `UnavailabilityError` on iOS,
|
|
255
|
+
matching upstream (there is no SAF equivalent on iOS; use the ordinary `document`/`cacheDirectory`
|
|
256
|
+
functions there instead).
|
|
257
|
+
- **`getContentUriAsync` is Android-only** — on iOS it resolves to the input `fileUri` unchanged,
|
|
258
|
+
matching upstream's own platform branch, rather than throwing.
|
|
259
|
+
- **Progress callbacks fire only while a task is subscribed** — `DownloadResumable`/`UploadTask`
|
|
260
|
+
add their native event listener only for the duration of the in-flight call
|
|
261
|
+
(`downloadAsync`/`uploadAsync`/`resumeAsync`), removing it as soon as the promise settles, exactly
|
|
262
|
+
as upstream does.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../next';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../next/index.js';
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { type IFileSystemDeletingOptions, type IFileSystemDownloadOptions, type IFileSystemDownloadPauseState, type IFileSystemDownloadProgressData, type IFileSystemDownloadResult, type IFileSystemFileInfo, type IFileSystemInfoOptions, type IFileSystemMakeDirectoryOptions, type IFileSystemNetworkTaskProgressCallback, type IFileSystemReadingOptions, type IFileSystemRelocatingOptions, type IFileSystemRequestDirectoryPermissionsResult, type IFileSystemUploadOptions, type IFileSystemUploadProgressData, type IFileSystemUploadResult, type IFileSystemWritingOptions } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* `file://` URI pointing to the directory where user documents for this app will be stored.
|
|
4
|
+
* Files stored here will remain until explicitly deleted by the app. Ends with a trailing `/`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const documentDirectory: string | null;
|
|
7
|
+
/**
|
|
8
|
+
* `file://` URI pointing to the directory where temporary files used by this app will be stored.
|
|
9
|
+
* Files stored here may be automatically deleted by the system when low on storage.
|
|
10
|
+
*/
|
|
11
|
+
export declare const cacheDirectory: string | null;
|
|
12
|
+
/**
|
|
13
|
+
* URI to the directory where assets bundled with the application are stored.
|
|
14
|
+
*/
|
|
15
|
+
export declare const bundleDirectory: string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Get metadata information about a file, directory or external content/asset.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getInfoAsync(fileUri: string, options?: IFileSystemInfoOptions): Promise<IFileSystemFileInfo>;
|
|
20
|
+
/**
|
|
21
|
+
* Read the entire contents of a file as a string. Binary is returned in raw format — prepend
|
|
22
|
+
* `data:image/png;base64,` yourself to use it as a data URI.
|
|
23
|
+
*/
|
|
24
|
+
export declare function readAsStringAsync(fileUri: string, options?: IFileSystemReadingOptions): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Takes a `file://` URI and converts it into a `content://` URI so that it can be accessed by
|
|
27
|
+
* other applications outside of the app.
|
|
28
|
+
* @platform android
|
|
29
|
+
*/
|
|
30
|
+
export declare function getContentUriAsync(fileUri: string): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Write the entire contents of a file as a string.
|
|
33
|
+
*/
|
|
34
|
+
export declare function writeAsStringAsync(fileUri: string, contents: string, options?: IFileSystemWritingOptions): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Delete a file or directory. If the URI points to a directory, the directory and all its
|
|
37
|
+
* contents are recursively deleted.
|
|
38
|
+
*/
|
|
39
|
+
export declare function deleteAsync(fileUri: string, options?: IFileSystemDeletingOptions): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Move a file or directory to a new location.
|
|
42
|
+
*/
|
|
43
|
+
export declare function moveAsync(options: IFileSystemRelocatingOptions): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Create a copy of a file or directory. Directories are recursively copied with all of their
|
|
46
|
+
* contents. Also works to copy content shared by other apps into local storage.
|
|
47
|
+
*/
|
|
48
|
+
export declare function copyAsync(options: IFileSystemRelocatingOptions): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Create a new empty directory.
|
|
51
|
+
*/
|
|
52
|
+
export declare function makeDirectoryAsync(fileUri: string, options?: IFileSystemMakeDirectoryOptions): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Enumerate the contents of a directory.
|
|
55
|
+
*/
|
|
56
|
+
export declare function readDirectoryAsync(fileUri: string): Promise<string[]>;
|
|
57
|
+
/**
|
|
58
|
+
* Gets the available internal disk storage size, in bytes.
|
|
59
|
+
*/
|
|
60
|
+
export declare function getFreeDiskStorageAsync(): Promise<number>;
|
|
61
|
+
/**
|
|
62
|
+
* Gets total internal disk storage size, in bytes.
|
|
63
|
+
*/
|
|
64
|
+
export declare function getTotalDiskCapacityAsync(): Promise<number>;
|
|
65
|
+
/**
|
|
66
|
+
* Download the contents at a remote URI to a file in the app's file system. The directory for
|
|
67
|
+
* the local file URI must exist prior to calling this function.
|
|
68
|
+
*/
|
|
69
|
+
export declare function downloadAsync(uri: string, fileUri: string, options?: IFileSystemDownloadOptions): Promise<IFileSystemDownloadResult>;
|
|
70
|
+
/**
|
|
71
|
+
* Upload the contents of the file pointed by `fileUri` to the remote url.
|
|
72
|
+
*/
|
|
73
|
+
export declare function uploadAsync(url: string, fileUri: string, options?: IFileSystemUploadOptions): Promise<IFileSystemUploadResult>;
|
|
74
|
+
/**
|
|
75
|
+
* Create a `DownloadResumable` object which can start, pause, and resume a download of contents
|
|
76
|
+
* at a remote URI to a file in the app's file system.
|
|
77
|
+
*/
|
|
78
|
+
export declare function createDownloadResumable(uri: string, fileUri: string, options?: IFileSystemDownloadOptions, callback?: IFileSystemNetworkTaskProgressCallback<IFileSystemDownloadProgressData>, resumeData?: string): DownloadResumable;
|
|
79
|
+
export declare function createUploadTask(url: string, fileUri: string, options?: IFileSystemUploadOptions, callback?: IFileSystemNetworkTaskProgressCallback<IFileSystemUploadProgressData>): UploadTask;
|
|
80
|
+
export declare abstract class FileSystemCancellableNetworkTask<T extends IFileSystemDownloadProgressData | IFileSystemUploadProgressData> {
|
|
81
|
+
private _uuid;
|
|
82
|
+
protected taskWasCanceled: boolean;
|
|
83
|
+
private subscription?;
|
|
84
|
+
cancelAsync(): Promise<void>;
|
|
85
|
+
protected isTaskCancelled(): boolean;
|
|
86
|
+
protected get uuid(): string;
|
|
87
|
+
protected abstract getEventName(): string;
|
|
88
|
+
protected abstract getCallback(): IFileSystemNetworkTaskProgressCallback<T> | undefined;
|
|
89
|
+
protected addSubscription(): void;
|
|
90
|
+
protected removeSubscription(): void;
|
|
91
|
+
}
|
|
92
|
+
export declare class UploadTask extends FileSystemCancellableNetworkTask<IFileSystemUploadProgressData> {
|
|
93
|
+
private url;
|
|
94
|
+
private fileUri;
|
|
95
|
+
private callback?;
|
|
96
|
+
private options;
|
|
97
|
+
constructor(url: string, fileUri: string, options?: IFileSystemUploadOptions, callback?: IFileSystemNetworkTaskProgressCallback<IFileSystemUploadProgressData> | undefined);
|
|
98
|
+
protected getEventName(): string;
|
|
99
|
+
protected getCallback(): IFileSystemNetworkTaskProgressCallback<IFileSystemUploadProgressData> | undefined;
|
|
100
|
+
uploadAsync(): Promise<IFileSystemUploadResult | undefined | null>;
|
|
101
|
+
}
|
|
102
|
+
export declare class DownloadResumable extends FileSystemCancellableNetworkTask<IFileSystemDownloadProgressData> {
|
|
103
|
+
private url;
|
|
104
|
+
private _fileUri;
|
|
105
|
+
private options;
|
|
106
|
+
private callback?;
|
|
107
|
+
private resumeData?;
|
|
108
|
+
constructor(url: string, _fileUri: string, options?: IFileSystemDownloadOptions, callback?: IFileSystemNetworkTaskProgressCallback<IFileSystemDownloadProgressData> | undefined, resumeData?: string | undefined);
|
|
109
|
+
get fileUri(): string;
|
|
110
|
+
protected getEventName(): string;
|
|
111
|
+
protected getCallback(): IFileSystemNetworkTaskProgressCallback<IFileSystemDownloadProgressData> | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* Download the contents at a remote URI to a file in the app's file system.
|
|
114
|
+
*/
|
|
115
|
+
downloadAsync(): Promise<IFileSystemDownloadResult | undefined>;
|
|
116
|
+
/**
|
|
117
|
+
* Pause the current download operation. `resumeData` is added to the `DownloadResumable`
|
|
118
|
+
* object after a successful pause operation. Returns an object that can be persisted
|
|
119
|
+
* (e.g. via a storage module) for future retrieval.
|
|
120
|
+
*/
|
|
121
|
+
pauseAsync(): Promise<IFileSystemDownloadPauseState>;
|
|
122
|
+
/**
|
|
123
|
+
* Resume a paused download operation.
|
|
124
|
+
*/
|
|
125
|
+
resumeAsync(): Promise<IFileSystemDownloadResult | undefined>;
|
|
126
|
+
/**
|
|
127
|
+
* The object which can be persisted for future retrieval (e.g. via a storage module), and
|
|
128
|
+
* fed back into `createDownloadResumable` after an app restart.
|
|
129
|
+
*/
|
|
130
|
+
savable(): IFileSystemDownloadPauseState;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* `StorageAccessFramework` encapsulates the functions usable with SAF URIs, for accessing
|
|
134
|
+
* user-selected directories outside the app's own storage.
|
|
135
|
+
* @platform android
|
|
136
|
+
*/
|
|
137
|
+
export declare const StorageAccessFramework: {
|
|
138
|
+
/**
|
|
139
|
+
* Gets a SAF URI pointing to a folder in the Android root directory, given the folder name.
|
|
140
|
+
* @platform android
|
|
141
|
+
*/
|
|
142
|
+
getUriForDirectoryInRoot(folderName: string): string;
|
|
143
|
+
/**
|
|
144
|
+
* Allows users to select a specific directory, granting the app access to all of the files and
|
|
145
|
+
* sub-directories within it.
|
|
146
|
+
* @platform android 11+
|
|
147
|
+
*/
|
|
148
|
+
requestDirectoryPermissionsAsync(initialFileUrl?: string | null): Promise<IFileSystemRequestDirectoryPermissionsResult>;
|
|
149
|
+
/**
|
|
150
|
+
* Enumerate the contents of a directory addressed by a SAF URI.
|
|
151
|
+
* @platform android
|
|
152
|
+
*/
|
|
153
|
+
readDirectoryAsync(dirUri: string): Promise<string[]>;
|
|
154
|
+
/**
|
|
155
|
+
* Creates a new empty directory addressed by a SAF URI.
|
|
156
|
+
* @platform android
|
|
157
|
+
*/
|
|
158
|
+
makeDirectoryAsync(parentUri: string, dirName: string): Promise<string>;
|
|
159
|
+
/**
|
|
160
|
+
* Creates a new empty file addressed by a SAF URI.
|
|
161
|
+
* @platform android
|
|
162
|
+
*/
|
|
163
|
+
createFileAsync(parentUri: string, fileName: string, mimeType: string): Promise<string>;
|
|
164
|
+
writeAsStringAsync: typeof writeAsStringAsync;
|
|
165
|
+
readAsStringAsync: typeof readAsStringAsync;
|
|
166
|
+
deleteAsync: typeof deleteAsync;
|
|
167
|
+
moveAsync: typeof moveAsync;
|
|
168
|
+
copyAsync: typeof copyAsync;
|
|
169
|
+
};
|