@themartiancompany/opfs 1.8.11
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/COPYING +674 -0
- package/README.cn.md +301 -0
- package/README.md +241 -0
- package/dist/main.cjs +1840 -0
- package/dist/main.cjs.map +1 -0
- package/dist/main.mjs +1751 -0
- package/dist/main.mjs.map +1 -0
- package/dist/types.d.ts +920 -0
- package/dist/types.d.ts.map +1 -0
- package/docs/README.md +115 -0
- package/docs/classes/SyncMessenger.md +42 -0
- package/docs/functions/appendFile.md +29 -0
- package/docs/functions/appendFileSync.md +26 -0
- package/docs/functions/assertAbsolutePath.md +29 -0
- package/docs/functions/assertFileUrl.md +29 -0
- package/docs/functions/connectSyncAgent.md +25 -0
- package/docs/functions/copy.md +35 -0
- package/docs/functions/copySync.md +30 -0
- package/docs/functions/createFile.md +27 -0
- package/docs/functions/createFileSync.md +25 -0
- package/docs/functions/deleteTemp.md +23 -0
- package/docs/functions/deleteTempSync.md +19 -0
- package/docs/functions/downloadFile.md +58 -0
- package/docs/functions/emptyDir.md +28 -0
- package/docs/functions/emptyDirSync.md +25 -0
- package/docs/functions/exists.md +29 -0
- package/docs/functions/existsSync.md +26 -0
- package/docs/functions/generateTempPath.md +27 -0
- package/docs/functions/getFileDataByHandle.md +27 -0
- package/docs/functions/getSyncMessenger.md +22 -0
- package/docs/functions/isDirectoryHandle.md +27 -0
- package/docs/functions/isFileHandle.md +27 -0
- package/docs/functions/isFileHandleLike.md +27 -0
- package/docs/functions/isOPFSSupported.md +21 -0
- package/docs/functions/isTempPath.md +27 -0
- package/docs/functions/mkTemp.md +28 -0
- package/docs/functions/mkTempSync.md +25 -0
- package/docs/functions/mkdir.md +27 -0
- package/docs/functions/mkdirSync.md +25 -0
- package/docs/functions/move.md +34 -0
- package/docs/functions/moveSync.md +30 -0
- package/docs/functions/pruneTemp.md +28 -0
- package/docs/functions/pruneTempSync.md +25 -0
- package/docs/functions/readBlobFile.md +28 -0
- package/docs/functions/readBlobFileSync.md +25 -0
- package/docs/functions/readDir.md +28 -0
- package/docs/functions/readDirSync.md +26 -0
- package/docs/functions/readFile.md +132 -0
- package/docs/functions/readFileSync.md +70 -0
- package/docs/functions/readJsonFile.md +35 -0
- package/docs/functions/readJsonFileSync.md +31 -0
- package/docs/functions/readTextFile.md +28 -0
- package/docs/functions/readTextFileSync.md +25 -0
- package/docs/functions/remove.md +27 -0
- package/docs/functions/removeSync.md +25 -0
- package/docs/functions/setSyncMessenger.md +26 -0
- package/docs/functions/startSyncAgent.md +21 -0
- package/docs/functions/stat.md +27 -0
- package/docs/functions/statSync.md +25 -0
- package/docs/functions/toFileSystemHandleLike.md +27 -0
- package/docs/functions/unzip.md +32 -0
- package/docs/functions/unzipFromUrl.md +36 -0
- package/docs/functions/unzipSync.md +26 -0
- package/docs/functions/uploadFile.md +33 -0
- package/docs/functions/writeFile.md +32 -0
- package/docs/functions/writeFileSync.md +30 -0
- package/docs/functions/zip.md +65 -0
- package/docs/functions/zipFromUrl.md +63 -0
- package/docs/functions/zipSync.md +55 -0
- package/docs/interfaces/CopyOptions.md +17 -0
- package/docs/interfaces/DownloadFileTempResponse.md +18 -0
- package/docs/interfaces/ErrorLike.md +18 -0
- package/docs/interfaces/ExistsOptions.md +18 -0
- package/docs/interfaces/FileLike.md +21 -0
- package/docs/interfaces/FileSystemFileHandleLike.md +25 -0
- package/docs/interfaces/FileSystemHandleLike.md +22 -0
- package/docs/interfaces/MoveOptions.md +17 -0
- package/docs/interfaces/ReadDirEntry.md +18 -0
- package/docs/interfaces/ReadDirEntrySync.md +18 -0
- package/docs/interfaces/ReadDirOptions.md +17 -0
- package/docs/interfaces/ReadOptions.md +17 -0
- package/docs/interfaces/SyncAgentOptions.md +19 -0
- package/docs/interfaces/TempOptions.md +19 -0
- package/docs/interfaces/UploadRequestInit.md +21 -0
- package/docs/interfaces/WriteOptions.md +19 -0
- package/docs/interfaces/ZipOptions.md +17 -0
- package/docs/type-aliases/FileEncoding.md +15 -0
- package/docs/type-aliases/FsRequestInit.md +15 -0
- package/docs/type-aliases/ReadFileContent.md +15 -0
- package/docs/type-aliases/WriteFileContent.md +15 -0
- package/docs/type-aliases/WriteSyncFileContent.md +16 -0
- package/docs/variables/CURRENT_DIR.md +15 -0
- package/docs/variables/NOT_FOUND_ERROR.md +18 -0
- package/docs/variables/ROOT_DIR.md +15 -0
- package/docs/variables/TMP_DIR.md +15 -0
- package/package.json +141 -0
- package/src/fs/assertions.ts +63 -0
- package/src/fs/constants.ts +63 -0
- package/src/fs/defines.ts +352 -0
- package/src/fs/helpers.ts +338 -0
- package/src/fs/opfs_core.ts +413 -0
- package/src/fs/opfs_download.ts +174 -0
- package/src/fs/opfs_ext.ts +504 -0
- package/src/fs/opfs_tmp.ts +131 -0
- package/src/fs/opfs_unzip.ts +168 -0
- package/src/fs/opfs_upload.ts +126 -0
- package/src/fs/opfs_zip.ts +314 -0
- package/src/fs/support.ts +36 -0
- package/src/fs/utils.ts +176 -0
- package/src/mod.ts +41 -0
- package/src/worker/helpers.ts +168 -0
- package/src/worker/opfs_worker.ts +298 -0
- package/src/worker/opfs_worker_adapter.ts +666 -0
- package/src/worker/shared.ts +400 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[**@themartiancompany/opfs**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@themartiancompany/opfs](../README.md) / pruneTempSync
|
|
6
|
+
|
|
7
|
+
# Function: pruneTempSync()
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
function pruneTempSync(expired): VoidIOResult
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Defined in: worker/opfs\_worker\_adapter.ts:533
|
|
14
|
+
|
|
15
|
+
Sync version of `pruneTemp`.
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
| Parameter | Type |
|
|
20
|
+
| ------ | ------ |
|
|
21
|
+
| `expired` | `Date` |
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
`VoidIOResult`
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[**@themartiancompany/opfs**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@themartiancompany/opfs](../README.md) / readBlobFile
|
|
6
|
+
|
|
7
|
+
# Function: readBlobFile()
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
function readBlobFile(filePath): AsyncIOResult<File>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Defined in: fs/opfs\_ext.ts:446
|
|
14
|
+
|
|
15
|
+
Reads the content of a file at the specified path as a File.
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
| Parameter | Type | Description |
|
|
20
|
+
| ------ | ------ | ------ |
|
|
21
|
+
| `filePath` | `string` | The path of the file to read. |
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
`AsyncIOResult`\<`File`\>
|
|
26
|
+
|
|
27
|
+
A promise that resolves to an `AsyncIOResult`
|
|
28
|
+
containing the file content as a File.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[**@themartiancompany/opfs**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@themartiancompany/opfs](../README.md) / readBlobFileSync
|
|
6
|
+
|
|
7
|
+
# Function: readBlobFileSync()
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
function readBlobFileSync(filePath): IOResult<FileLike>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Defined in: worker/opfs\_worker\_adapter.ts:547
|
|
14
|
+
|
|
15
|
+
Sync version of `readBlobFile`.
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
| Parameter | Type |
|
|
20
|
+
| ------ | ------ |
|
|
21
|
+
| `filePath` | `string` |
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
`IOResult`\<[`FileLike`](../interfaces/FileLike.md)\>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[**@themartiancompany/opfs**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@themartiancompany/opfs](../README.md) / readDir
|
|
6
|
+
|
|
7
|
+
# Function: readDir()
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
function readDir(dirPath, options?): AsyncIOResult<AsyncIterableIterator<ReadDirEntry, any, any>>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Defined in: fs/opfs\_core.ts:104
|
|
14
|
+
|
|
15
|
+
Reads the contents of a directory at the specified path.
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
| Parameter | Type | Description |
|
|
20
|
+
| ------ | ------ | ------ |
|
|
21
|
+
| `dirPath` | `string` | The path of the directory to read. |
|
|
22
|
+
| `options`? | [`ReadDirOptions`](../interfaces/ReadDirOptions.md) | Options of readdir. |
|
|
23
|
+
|
|
24
|
+
## Returns
|
|
25
|
+
|
|
26
|
+
`AsyncIOResult`\<`AsyncIterableIterator`\<[`ReadDirEntry`](../interfaces/ReadDirEntry.md), `any`, `any`\>\>
|
|
27
|
+
|
|
28
|
+
A promise that resolves to an `AsyncIOResult` containing an async iterable iterator over the entries of the directory.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[**@themartiancompany/opfs**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@themartiancompany/opfs](../README.md) / readDirSync
|
|
6
|
+
|
|
7
|
+
# Function: readDirSync()
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
function readDirSync(dirPath, options?): IOResult<ReadDirEntrySync[]>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Defined in: worker/opfs\_worker\_adapter.ts:278
|
|
14
|
+
|
|
15
|
+
Sync version of `readDir`.
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
| Parameter | Type |
|
|
20
|
+
| ------ | ------ |
|
|
21
|
+
| `dirPath` | `string` |
|
|
22
|
+
| `options`? | [`ReadDirOptions`](../interfaces/ReadDirOptions.md) |
|
|
23
|
+
|
|
24
|
+
## Returns
|
|
25
|
+
|
|
26
|
+
`IOResult`\<[`ReadDirEntrySync`](../interfaces/ReadDirEntrySync.md)[]\>
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
[**@themartiancompany/opfs**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@themartiancompany/opfs](../README.md) / readFile
|
|
6
|
+
|
|
7
|
+
# Function: readFile()
|
|
8
|
+
|
|
9
|
+
Reads the content of a file at the specified path with the specified options.
|
|
10
|
+
|
|
11
|
+
## Template
|
|
12
|
+
|
|
13
|
+
The type of the content to read from the file.
|
|
14
|
+
|
|
15
|
+
## Param
|
|
16
|
+
|
|
17
|
+
The path of the file to read.
|
|
18
|
+
|
|
19
|
+
## Param
|
|
20
|
+
|
|
21
|
+
Optional read options.
|
|
22
|
+
|
|
23
|
+
## Call Signature
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
function readFile(filePath, options): AsyncIOResult<File>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Defined in: fs/opfs\_core.ts:162
|
|
30
|
+
|
|
31
|
+
Reads the content of a file at the specified path as a File.
|
|
32
|
+
|
|
33
|
+
### Parameters
|
|
34
|
+
|
|
35
|
+
| Parameter | Type | Description |
|
|
36
|
+
| ------ | ------ | ------ |
|
|
37
|
+
| `filePath` | `string` | The path of the file to read. |
|
|
38
|
+
| `options` | [`ReadOptions`](../interfaces/ReadOptions.md) & \{ `encoding`: `"blob"`; \} | Read options specifying the 'blob' encoding. |
|
|
39
|
+
|
|
40
|
+
### Returns
|
|
41
|
+
|
|
42
|
+
`AsyncIOResult`\<`File`\>
|
|
43
|
+
|
|
44
|
+
A promise that resolves to an `AsyncIOResult` containing the file content.
|
|
45
|
+
|
|
46
|
+
A promise that resolves to an `AsyncIOResult` containing the file content as a File.
|
|
47
|
+
|
|
48
|
+
### Template
|
|
49
|
+
|
|
50
|
+
The type of the content to read from the file.
|
|
51
|
+
|
|
52
|
+
### Param
|
|
53
|
+
|
|
54
|
+
The path of the file to read.
|
|
55
|
+
|
|
56
|
+
### Param
|
|
57
|
+
|
|
58
|
+
Optional read options.
|
|
59
|
+
|
|
60
|
+
## Call Signature
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
function readFile(filePath, options): AsyncIOResult<string>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Defined in: fs/opfs\_core.ts:178
|
|
67
|
+
|
|
68
|
+
Reads the content of a file at the specified path as a string.
|
|
69
|
+
|
|
70
|
+
### Parameters
|
|
71
|
+
|
|
72
|
+
| Parameter | Type | Description |
|
|
73
|
+
| ------ | ------ | ------ |
|
|
74
|
+
| `filePath` | `string` | The path of the file to read. |
|
|
75
|
+
| `options` | [`ReadOptions`](../interfaces/ReadOptions.md) & \{ `encoding`: `"utf8"`; \} | Read options specifying the 'utf8' encoding. |
|
|
76
|
+
|
|
77
|
+
### Returns
|
|
78
|
+
|
|
79
|
+
`AsyncIOResult`\<`string`\>
|
|
80
|
+
|
|
81
|
+
A promise that resolves to an `AsyncIOResult` containing the file content.
|
|
82
|
+
|
|
83
|
+
A promise that resolves to an `AsyncIOResult` containing the file content as a string.
|
|
84
|
+
|
|
85
|
+
### Template
|
|
86
|
+
|
|
87
|
+
The type of the content to read from the file.
|
|
88
|
+
|
|
89
|
+
### Param
|
|
90
|
+
|
|
91
|
+
The path of the file to read.
|
|
92
|
+
|
|
93
|
+
### Param
|
|
94
|
+
|
|
95
|
+
Optional read options.
|
|
96
|
+
|
|
97
|
+
## Call Signature
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
function readFile(filePath, options?): AsyncIOResult<ArrayBuffer>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Defined in: fs/opfs\_core.ts:194
|
|
104
|
+
|
|
105
|
+
Reads the content of a file at the specified path as an ArrayBuffer by default.
|
|
106
|
+
|
|
107
|
+
### Parameters
|
|
108
|
+
|
|
109
|
+
| Parameter | Type | Description |
|
|
110
|
+
| ------ | ------ | ------ |
|
|
111
|
+
| `filePath` | `string` | The path of the file to read. |
|
|
112
|
+
| `options`? | [`ReadOptions`](../interfaces/ReadOptions.md) & \{ `encoding`: `"binary"`; \} | Read options specifying the 'binary' encoding. |
|
|
113
|
+
|
|
114
|
+
### Returns
|
|
115
|
+
|
|
116
|
+
`AsyncIOResult`\<`ArrayBuffer`\>
|
|
117
|
+
|
|
118
|
+
A promise that resolves to an `AsyncIOResult` containing the file content.
|
|
119
|
+
|
|
120
|
+
A promise that resolves to an `AsyncIOResult` containing the file content as an ArrayBuffer.
|
|
121
|
+
|
|
122
|
+
### Template
|
|
123
|
+
|
|
124
|
+
The type of the content to read from the file.
|
|
125
|
+
|
|
126
|
+
### Param
|
|
127
|
+
|
|
128
|
+
The path of the file to read.
|
|
129
|
+
|
|
130
|
+
### Param
|
|
131
|
+
|
|
132
|
+
Optional read options.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
[**@themartiancompany/opfs**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@themartiancompany/opfs](../README.md) / readFileSync
|
|
6
|
+
|
|
7
|
+
# Function: readFileSync()
|
|
8
|
+
|
|
9
|
+
## Call Signature
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
function readFileSync(filePath, options): IOResult<FileLike>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Defined in: worker/opfs\_worker\_adapter.ts:295
|
|
16
|
+
|
|
17
|
+
Sync version of `readFile`.
|
|
18
|
+
|
|
19
|
+
### Parameters
|
|
20
|
+
|
|
21
|
+
| Parameter | Type |
|
|
22
|
+
| ------ | ------ |
|
|
23
|
+
| `filePath` | `string` |
|
|
24
|
+
| `options` | [`ReadOptions`](../interfaces/ReadOptions.md) & \{ `encoding`: `"blob"`; \} |
|
|
25
|
+
|
|
26
|
+
### Returns
|
|
27
|
+
|
|
28
|
+
`IOResult`\<[`FileLike`](../interfaces/FileLike.md)\>
|
|
29
|
+
|
|
30
|
+
## Call Signature
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
function readFileSync(filePath, options): IOResult<string>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Defined in: worker/opfs\_worker\_adapter.ts:305
|
|
37
|
+
|
|
38
|
+
Sync version of `readFile`.
|
|
39
|
+
|
|
40
|
+
### Parameters
|
|
41
|
+
|
|
42
|
+
| Parameter | Type |
|
|
43
|
+
| ------ | ------ |
|
|
44
|
+
| `filePath` | `string` |
|
|
45
|
+
| `options` | [`ReadOptions`](../interfaces/ReadOptions.md) & \{ `encoding`: `"utf8"`; \} |
|
|
46
|
+
|
|
47
|
+
### Returns
|
|
48
|
+
|
|
49
|
+
`IOResult`\<`string`\>
|
|
50
|
+
|
|
51
|
+
## Call Signature
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
function readFileSync(filePath, options?): IOResult<ArrayBuffer>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Defined in: worker/opfs\_worker\_adapter.ts:315
|
|
58
|
+
|
|
59
|
+
Sync version of `readFile`.
|
|
60
|
+
|
|
61
|
+
### Parameters
|
|
62
|
+
|
|
63
|
+
| Parameter | Type |
|
|
64
|
+
| ------ | ------ |
|
|
65
|
+
| `filePath` | `string` |
|
|
66
|
+
| `options`? | [`ReadOptions`](../interfaces/ReadOptions.md) & \{ `encoding`: `"binary"`; \} |
|
|
67
|
+
|
|
68
|
+
### Returns
|
|
69
|
+
|
|
70
|
+
`IOResult`\<`ArrayBuffer`\>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[**@themartiancompany/opfs**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@themartiancompany/opfs](../README.md) / readJsonFile
|
|
6
|
+
|
|
7
|
+
# Function: readJsonFile()
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
function readJsonFile<T>(filePath): AsyncIOResult<T>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Defined in: fs/opfs\_ext.ts:466
|
|
14
|
+
|
|
15
|
+
Reads the content of a file at the specified path as a
|
|
16
|
+
string and returns it as a JSON object.
|
|
17
|
+
|
|
18
|
+
## Type Parameters
|
|
19
|
+
|
|
20
|
+
| Type Parameter |
|
|
21
|
+
| ------ |
|
|
22
|
+
| `T` |
|
|
23
|
+
|
|
24
|
+
## Parameters
|
|
25
|
+
|
|
26
|
+
| Parameter | Type | Description |
|
|
27
|
+
| ------ | ------ | ------ |
|
|
28
|
+
| `filePath` | `string` | The path of the file to read. |
|
|
29
|
+
|
|
30
|
+
## Returns
|
|
31
|
+
|
|
32
|
+
`AsyncIOResult`\<`T`\>
|
|
33
|
+
|
|
34
|
+
A promise that resolves to an `AsyncIOResult`
|
|
35
|
+
containing the file content as a JSON object.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
[**@themartiancompany/opfs**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@themartiancompany/opfs](../README.md) / readJsonFileSync
|
|
6
|
+
|
|
7
|
+
# Function: readJsonFileSync()
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
function readJsonFileSync<T>(filePath): IOResult<T>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Defined in: worker/opfs\_worker\_adapter.ts:562
|
|
14
|
+
|
|
15
|
+
Sync version of `readJsonFile`.
|
|
16
|
+
|
|
17
|
+
## Type Parameters
|
|
18
|
+
|
|
19
|
+
| Type Parameter |
|
|
20
|
+
| ------ |
|
|
21
|
+
| `T` |
|
|
22
|
+
|
|
23
|
+
## Parameters
|
|
24
|
+
|
|
25
|
+
| Parameter | Type |
|
|
26
|
+
| ------ | ------ |
|
|
27
|
+
| `filePath` | `string` |
|
|
28
|
+
|
|
29
|
+
## Returns
|
|
30
|
+
|
|
31
|
+
`IOResult`\<`T`\>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[**@themartiancompany/opfs**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@themartiancompany/opfs](../README.md) / readTextFile
|
|
6
|
+
|
|
7
|
+
# Function: readTextFile()
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
function readTextFile(filePath): AsyncIOResult<string>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Defined in: fs/opfs\_ext.ts:496
|
|
14
|
+
|
|
15
|
+
Reads the content of a file at the specified path as a string.
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
| Parameter | Type | Description |
|
|
20
|
+
| ------ | ------ | ------ |
|
|
21
|
+
| `filePath` | `string` | The path of the file to read. |
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
`AsyncIOResult`\<`string`\>
|
|
26
|
+
|
|
27
|
+
A promise that resolves to an `AsyncIOResult`
|
|
28
|
+
containing the file content as a string.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[**@themartiancompany/opfs**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@themartiancompany/opfs](../README.md) / readTextFileSync
|
|
6
|
+
|
|
7
|
+
# Function: readTextFileSync()
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
function readTextFileSync(filePath): IOResult<string>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Defined in: worker/opfs\_worker\_adapter.ts:587
|
|
14
|
+
|
|
15
|
+
Sync version of `readTextFile`.
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
| Parameter | Type |
|
|
20
|
+
| ------ | ------ |
|
|
21
|
+
| `filePath` | `string` |
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
`IOResult`\<`string`\>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[**@themartiancompany/opfs**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@themartiancompany/opfs](../README.md) / remove
|
|
6
|
+
|
|
7
|
+
# Function: remove()
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
function remove(path): AsyncVoidIOResult
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Defined in: fs/opfs\_core.ts:255
|
|
14
|
+
|
|
15
|
+
Removes a file or directory at the specified path same as `rm -rf`.
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
| Parameter | Type | Description |
|
|
20
|
+
| ------ | ------ | ------ |
|
|
21
|
+
| `path` | `string` | The path of the file or directory to remove. |
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
`AsyncVoidIOResult`
|
|
26
|
+
|
|
27
|
+
A promise that resolves to an `AsyncIOResult` indicating whether the file or directory was successfully removed.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[**@themartiancompany/opfs**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@themartiancompany/opfs](../README.md) / removeSync
|
|
6
|
+
|
|
7
|
+
# Function: removeSync()
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
function removeSync(path): VoidIOResult
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Defined in: worker/opfs\_worker\_adapter.ts:368
|
|
14
|
+
|
|
15
|
+
Sync version of `remove`.
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
| Parameter | Type |
|
|
20
|
+
| ------ | ------ |
|
|
21
|
+
| `path` | `string` |
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
`VoidIOResult`
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[**@themartiancompany/opfs**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@themartiancompany/opfs](../README.md) / setSyncMessenger
|
|
6
|
+
|
|
7
|
+
# Function: setSyncMessenger()
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
function setSyncMessenger(syncMessenger): void
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Defined in: worker/opfs\_worker\_adapter.ts:153
|
|
14
|
+
|
|
15
|
+
Set messenger instance.
|
|
16
|
+
Use this method to share messenger with other environments.
|
|
17
|
+
|
|
18
|
+
## Parameters
|
|
19
|
+
|
|
20
|
+
| Parameter | Type | Description |
|
|
21
|
+
| ------ | ------ | ------ |
|
|
22
|
+
| `syncMessenger` | [`SyncMessenger`](../classes/SyncMessenger.md) | SyncMessenger instance. |
|
|
23
|
+
|
|
24
|
+
## Returns
|
|
25
|
+
|
|
26
|
+
`void`
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[**@themartiancompany/opfs**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@themartiancompany/opfs](../README.md) / startSyncAgent
|
|
6
|
+
|
|
7
|
+
# Function: startSyncAgent()
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
function startSyncAgent(): void
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Defined in: worker/opfs\_worker.ts:111
|
|
14
|
+
|
|
15
|
+
Start worker agent.
|
|
16
|
+
Listens to postMessage from main thread.
|
|
17
|
+
Start runner loop.
|
|
18
|
+
|
|
19
|
+
## Returns
|
|
20
|
+
|
|
21
|
+
`void`
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[**@themartiancompany/opfs**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@themartiancompany/opfs](../README.md) / stat
|
|
6
|
+
|
|
7
|
+
# Function: stat()
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
function stat(path): AsyncIOResult<FileSystemHandle>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Defined in: fs/opfs\_core.ts:316
|
|
14
|
+
|
|
15
|
+
Retrieves the status of a file or directory at the specified path.
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
| Parameter | Type | Description |
|
|
20
|
+
| ------ | ------ | ------ |
|
|
21
|
+
| `path` | `string` | The path of the file or directory to retrieve status for. |
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
`AsyncIOResult`\<`FileSystemHandle`\>
|
|
26
|
+
|
|
27
|
+
A promise that resolves to an `AsyncIOResult` containing the `FileSystemHandle`.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[**@themartiancompany/opfs**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@themartiancompany/opfs](../README.md) / statSync
|
|
6
|
+
|
|
7
|
+
# Function: statSync()
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
function statSync(path): IOResult<FileSystemHandleLike>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Defined in: worker/opfs\_worker\_adapter.ts:382
|
|
14
|
+
|
|
15
|
+
Sync version of `stat`.
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
| Parameter | Type |
|
|
20
|
+
| ------ | ------ |
|
|
21
|
+
| `path` | `string` |
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
`IOResult`\<[`FileSystemHandleLike`](../interfaces/FileSystemHandleLike.md)\>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[**@themartiancompany/opfs**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@themartiancompany/opfs](../README.md) / toFileSystemHandleLike
|
|
6
|
+
|
|
7
|
+
# Function: toFileSystemHandleLike()
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
function toFileSystemHandleLike(handle): Promise<FileSystemHandleLike>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Defined in: fs/utils.ts:81
|
|
14
|
+
|
|
15
|
+
Serialize a `FileSystemHandle` to plain object.
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
| Parameter | Type | Description |
|
|
20
|
+
| ------ | ------ | ------ |
|
|
21
|
+
| `handle` | `FileSystemHandle` | `FileSystemHandle` object. |
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
`Promise`\<[`FileSystemHandleLike`](../interfaces/FileSystemHandleLike.md)\>
|
|
26
|
+
|
|
27
|
+
Serializable version of FileSystemHandle that is FileSystemHandleLike.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
[**@themartiancompany/opfs**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@themartiancompany/opfs](../README.md) / unzip
|
|
6
|
+
|
|
7
|
+
# Function: unzip()
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
function unzip(zipFilePath, targetPath): AsyncVoidIOResult
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Defined in: fs/opfs\_unzip.ts:106
|
|
14
|
+
|
|
15
|
+
Unzip a zip file to a directory.
|
|
16
|
+
Equivalent to `unzip -o <zipFilePath> -d <targetPath>
|
|
17
|
+
|
|
18
|
+
Usees [fflate](https://github.com/101arrowz/fflate) as the unzip backend.
|
|
19
|
+
|
|
20
|
+
## Parameters
|
|
21
|
+
|
|
22
|
+
| Parameter | Type | Description |
|
|
23
|
+
| ------ | ------ | ------ |
|
|
24
|
+
| `zipFilePath` | `string` | Zip file path. |
|
|
25
|
+
| `targetPath` | `string` | The directory to unzip to. |
|
|
26
|
+
|
|
27
|
+
## Returns
|
|
28
|
+
|
|
29
|
+
`AsyncVoidIOResult`
|
|
30
|
+
|
|
31
|
+
A promise that resolves to an `AsyncIOResult`
|
|
32
|
+
indicating whether the zip file was successfully unzipped.
|