@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
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,920 @@
|
|
|
1
|
+
import { FetchInit, FetchTask } from '@happy-ts/fetch-t';
|
|
2
|
+
export { ABORT_ERROR, TIMEOUT_ERROR } from '@happy-ts/fetch-t';
|
|
3
|
+
import { AsyncVoidIOResult, AsyncIOResult, VoidIOResult, IOResult } from 'happy-rusty';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Asserts that the provided path is an absolute path.
|
|
7
|
+
*
|
|
8
|
+
* @param path - The file path to validate.
|
|
9
|
+
* @throws Will throw an error if the path is not an absolute path.
|
|
10
|
+
*/
|
|
11
|
+
declare function assertAbsolutePath(path: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* Asserts that the provided URL is a valid file URL.
|
|
14
|
+
*
|
|
15
|
+
* @param fileUrl - The file URL to validate.
|
|
16
|
+
* @throws Will throw an error if the URL is not a valid file URL.
|
|
17
|
+
*/
|
|
18
|
+
declare function assertFileUrl(fileUrl: string): void;
|
|
19
|
+
|
|
20
|
+
/** ----------------------------------------------------------------------
|
|
21
|
+
* Copyright ©
|
|
22
|
+
* Jiang Jie
|
|
23
|
+
* 2024, 2025
|
|
24
|
+
* Pellegrino Prevete
|
|
25
|
+
* 2025
|
|
26
|
+
*
|
|
27
|
+
* All rights reserved
|
|
28
|
+
* ----------------------------------------------------------------------
|
|
29
|
+
*
|
|
30
|
+
* This program is free software: you can redistribute it and/or modify
|
|
31
|
+
* it under the terms of the GNU General Public License as published by
|
|
32
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
33
|
+
* (at your option) any later version.
|
|
34
|
+
*
|
|
35
|
+
* This program is distributed in the hope that it will be useful,
|
|
36
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
37
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
38
|
+
* GNU General Public License for more details.
|
|
39
|
+
*
|
|
40
|
+
* You should have received a copy of the GNU General Public License
|
|
41
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A constant representing the error thrown when a
|
|
46
|
+
* file or directory is not found.
|
|
47
|
+
*
|
|
48
|
+
* Name of DOMException.NOT_FOUND_ERR.
|
|
49
|
+
*/
|
|
50
|
+
declare const NOT_FOUND_ERROR: "NotFoundError";
|
|
51
|
+
/**
|
|
52
|
+
* A constant representing the root directory path.
|
|
53
|
+
*/
|
|
54
|
+
declare const ROOT_DIR: "/";
|
|
55
|
+
/**
|
|
56
|
+
* A constant representing the current directory path.
|
|
57
|
+
*/
|
|
58
|
+
declare const CURRENT_DIR: ".";
|
|
59
|
+
/**
|
|
60
|
+
* A constant representing the temporary directory path.
|
|
61
|
+
*/
|
|
62
|
+
declare const TMP_DIR: "/tmp";
|
|
63
|
+
|
|
64
|
+
/** ----------------------------------------------------------------------
|
|
65
|
+
* Copyright ©
|
|
66
|
+
* Jiang Jie
|
|
67
|
+
* 2024, 2025
|
|
68
|
+
* Pellegrino Prevete
|
|
69
|
+
* 2025
|
|
70
|
+
*
|
|
71
|
+
* All rights reserved
|
|
72
|
+
* ----------------------------------------------------------------------
|
|
73
|
+
*
|
|
74
|
+
* This program is free software: you can redistribute it and/or modify
|
|
75
|
+
* it under the terms of the GNU General Public License as published by
|
|
76
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
77
|
+
* (at your option) any later version.
|
|
78
|
+
*
|
|
79
|
+
* This program is distributed in the hope that it will be useful,
|
|
80
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
81
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
82
|
+
* GNU General Public License for more details.
|
|
83
|
+
*
|
|
84
|
+
* You should have received a copy of the GNU General Public License
|
|
85
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Represents the possible content types that can be written to a file.
|
|
90
|
+
*/
|
|
91
|
+
type WriteFileContent = BufferSource | Blob | string;
|
|
92
|
+
/**
|
|
93
|
+
* Represents the possible content types that can be
|
|
94
|
+
* written synchronously to a file.
|
|
95
|
+
*/
|
|
96
|
+
type WriteSyncFileContent = BufferSource | string;
|
|
97
|
+
/**
|
|
98
|
+
* Represents the possible content types that can be read from a file.
|
|
99
|
+
*/
|
|
100
|
+
type ReadFileContent = ArrayBuffer | File | string;
|
|
101
|
+
/**
|
|
102
|
+
* Options for reading files with specified encoding.
|
|
103
|
+
*/
|
|
104
|
+
interface ReadOptions {
|
|
105
|
+
/**
|
|
106
|
+
* The encoding to use for reading the file's content.
|
|
107
|
+
* @defaultValue `'binary'`
|
|
108
|
+
*/
|
|
109
|
+
encoding?: FileEncoding;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Options for writing files, including flags for creation
|
|
113
|
+
* and appending.
|
|
114
|
+
*/
|
|
115
|
+
interface WriteOptions {
|
|
116
|
+
/**
|
|
117
|
+
* Whether to create the file if it does not exist.
|
|
118
|
+
* @defaultValue `true`
|
|
119
|
+
*/
|
|
120
|
+
create?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Whether to append to the file if it already exists.
|
|
123
|
+
* @defaultValue `false`
|
|
124
|
+
*/
|
|
125
|
+
append?: boolean;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Options to determine the existence of a file or directory.
|
|
129
|
+
*/
|
|
130
|
+
interface ExistsOptions {
|
|
131
|
+
/**
|
|
132
|
+
* Whether to check for the existence of a directory.
|
|
133
|
+
* @defaultValue `false`
|
|
134
|
+
*/
|
|
135
|
+
isDirectory?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Whether to check for the existence of a file.
|
|
138
|
+
* @defaultValue `false`
|
|
139
|
+
*/
|
|
140
|
+
isFile?: boolean;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Supported file encodings for reading and writing files.
|
|
144
|
+
*/
|
|
145
|
+
type FileEncoding = 'binary' | 'utf8' | 'blob';
|
|
146
|
+
/**
|
|
147
|
+
* fetch-t options for download and upload.
|
|
148
|
+
*/
|
|
149
|
+
type FsRequestInit = Omit<FetchInit, 'abortable' | 'responseType'>;
|
|
150
|
+
/**
|
|
151
|
+
* fetch-t request options for uploading files.
|
|
152
|
+
*/
|
|
153
|
+
interface UploadRequestInit extends FsRequestInit {
|
|
154
|
+
/**
|
|
155
|
+
* The filename to use when uploading the file.
|
|
156
|
+
*/
|
|
157
|
+
filename?: string;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Options for reading directories.
|
|
161
|
+
*/
|
|
162
|
+
interface ReadDirOptions {
|
|
163
|
+
/**
|
|
164
|
+
* Whether to recursively read the contents of directories.
|
|
165
|
+
*/
|
|
166
|
+
recursive: boolean;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* An entry returned by `readDir`.
|
|
170
|
+
*/
|
|
171
|
+
interface ReadDirEntry {
|
|
172
|
+
/**
|
|
173
|
+
* The relative path of the entry from readDir the path parameter.
|
|
174
|
+
*/
|
|
175
|
+
path: string;
|
|
176
|
+
/**
|
|
177
|
+
* The handle of the entry.
|
|
178
|
+
*/
|
|
179
|
+
handle: FileSystemHandle;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* An entry returned by `readDirSync`.
|
|
183
|
+
*/
|
|
184
|
+
interface ReadDirEntrySync {
|
|
185
|
+
/**
|
|
186
|
+
* The relative path of the entry from readDir the path parameter.
|
|
187
|
+
*/
|
|
188
|
+
path: string;
|
|
189
|
+
/**
|
|
190
|
+
* The handle of the entry.
|
|
191
|
+
*/
|
|
192
|
+
handle: FileSystemHandleLike;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* A handle to a file or directory returned by `statSync`.
|
|
196
|
+
*/
|
|
197
|
+
interface FileSystemHandleLike {
|
|
198
|
+
/**
|
|
199
|
+
* The name of the entry.
|
|
200
|
+
*/
|
|
201
|
+
name: string;
|
|
202
|
+
/**
|
|
203
|
+
* The kind of the entry.
|
|
204
|
+
*/
|
|
205
|
+
kind: FileSystemHandleKind;
|
|
206
|
+
}
|
|
207
|
+
interface FileSystemFileHandleLike extends FileSystemHandleLike {
|
|
208
|
+
/**
|
|
209
|
+
* The type of the file.
|
|
210
|
+
*/
|
|
211
|
+
type: string;
|
|
212
|
+
/**
|
|
213
|
+
* The size of the file.
|
|
214
|
+
*/
|
|
215
|
+
size: number;
|
|
216
|
+
/**
|
|
217
|
+
* The last modified time of the file.
|
|
218
|
+
*/
|
|
219
|
+
lastModified: number;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Serializable version of Error.
|
|
223
|
+
*/
|
|
224
|
+
interface ErrorLike {
|
|
225
|
+
/**
|
|
226
|
+
* The name of the error.
|
|
227
|
+
*/
|
|
228
|
+
name: string;
|
|
229
|
+
/**
|
|
230
|
+
* The message of the error.
|
|
231
|
+
*/
|
|
232
|
+
message: string;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Serializable version of File.
|
|
236
|
+
*/
|
|
237
|
+
interface FileLike {
|
|
238
|
+
/**
|
|
239
|
+
* The name of the file.
|
|
240
|
+
*/
|
|
241
|
+
name: string;
|
|
242
|
+
/**
|
|
243
|
+
* The type of the file.
|
|
244
|
+
*/
|
|
245
|
+
type: string;
|
|
246
|
+
/**
|
|
247
|
+
* The last modified time of the file.
|
|
248
|
+
*/
|
|
249
|
+
lastModified: number;
|
|
250
|
+
/**
|
|
251
|
+
* The size of the file.
|
|
252
|
+
*/
|
|
253
|
+
size: number;
|
|
254
|
+
/**
|
|
255
|
+
* The binary data of the file.
|
|
256
|
+
*/
|
|
257
|
+
data: ArrayBuffer;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Setup options of `connectSyncAgent`.
|
|
261
|
+
*/
|
|
262
|
+
interface SyncAgentOptions {
|
|
263
|
+
/**
|
|
264
|
+
* The worker to communicate with.
|
|
265
|
+
*/
|
|
266
|
+
worker: Worker | URL | string;
|
|
267
|
+
/**
|
|
268
|
+
* The length of the buffer to use for communication.
|
|
269
|
+
*/
|
|
270
|
+
bufferLength?: number;
|
|
271
|
+
/**
|
|
272
|
+
* The timeout for operations.
|
|
273
|
+
*/
|
|
274
|
+
opTimeout?: number;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Options for `zip`.
|
|
278
|
+
*/
|
|
279
|
+
interface ZipOptions {
|
|
280
|
+
/**
|
|
281
|
+
* Whether to preserve the root directory in the zip file.
|
|
282
|
+
* @defaultValue `true`
|
|
283
|
+
*/
|
|
284
|
+
preserveRoot: boolean;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Options for `mkTemp`.
|
|
288
|
+
*/
|
|
289
|
+
interface TempOptions {
|
|
290
|
+
/**
|
|
291
|
+
* Whether to create a directory.
|
|
292
|
+
* eg: `mktemp -d`
|
|
293
|
+
* @defaultValue `false`
|
|
294
|
+
*/
|
|
295
|
+
isDirectory?: boolean;
|
|
296
|
+
/**
|
|
297
|
+
* The basename of the file or directory.
|
|
298
|
+
* eg: `mktemp -t basename.XXX`
|
|
299
|
+
* @defaultValue `tmp`
|
|
300
|
+
*/
|
|
301
|
+
basename?: string;
|
|
302
|
+
/**
|
|
303
|
+
* The extension of the file.
|
|
304
|
+
* eg: `mktemp --suffix .txt`
|
|
305
|
+
*/
|
|
306
|
+
extname?: string;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Options for `copy`.
|
|
310
|
+
*/
|
|
311
|
+
interface CopyOptions {
|
|
312
|
+
/**
|
|
313
|
+
* Whether to overwrite the destination file if it already exists.
|
|
314
|
+
* @defaultValue `true`
|
|
315
|
+
*/
|
|
316
|
+
overwrite?: boolean;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Result of `downloadFile` when the file is saved to a temporary path.
|
|
320
|
+
*/
|
|
321
|
+
interface DownloadFileTempResponse {
|
|
322
|
+
/**
|
|
323
|
+
* The temporary path of the downloaded file to be saved.
|
|
324
|
+
*/
|
|
325
|
+
tempFilePath: string;
|
|
326
|
+
/**
|
|
327
|
+
* The raw response.
|
|
328
|
+
*/
|
|
329
|
+
rawResponse: Response;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Options for `move`.
|
|
333
|
+
*/
|
|
334
|
+
interface MoveOptions {
|
|
335
|
+
/**
|
|
336
|
+
* Whether to overwrite the destination file if it already exists.
|
|
337
|
+
* @defaultValue `true`
|
|
338
|
+
*/
|
|
339
|
+
overwrite?: boolean;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Creates a new file at the specified path same as `touch`.
|
|
344
|
+
*
|
|
345
|
+
* @param filePath - The path of the file to create.
|
|
346
|
+
* @returns A promise that resolves to an `AsyncIOResult` indicating whether the file was successfully created.
|
|
347
|
+
*/
|
|
348
|
+
declare function createFile(filePath: string): AsyncVoidIOResult;
|
|
349
|
+
/**
|
|
350
|
+
* Creates a new directory at the specified path same as `mkdir -p`.
|
|
351
|
+
*
|
|
352
|
+
* @param dirPath - The path where the new directory will be created.
|
|
353
|
+
* @returns A promise that resolves to an `AsyncIOResult` indicating whether the directory was successfully created.
|
|
354
|
+
*/
|
|
355
|
+
declare function mkdir(dirPath: string): AsyncVoidIOResult;
|
|
356
|
+
/**
|
|
357
|
+
* Reads the contents of a directory at the specified path.
|
|
358
|
+
*
|
|
359
|
+
* @param dirPath - The path of the directory to read.
|
|
360
|
+
* @param options - Options of readdir.
|
|
361
|
+
* @returns A promise that resolves to an `AsyncIOResult` containing an async iterable iterator over the entries of the directory.
|
|
362
|
+
*/
|
|
363
|
+
declare function readDir(dirPath: string, options?: ReadDirOptions): AsyncIOResult<AsyncIterableIterator<ReadDirEntry>>;
|
|
364
|
+
/**
|
|
365
|
+
* Reads the content of a file at the specified path as a File.
|
|
366
|
+
*
|
|
367
|
+
* @param filePath - The path of the file to read.
|
|
368
|
+
* @param options - Read options specifying the 'blob' encoding.
|
|
369
|
+
* @returns A promise that resolves to an `AsyncIOResult` containing the file content as a File.
|
|
370
|
+
*/
|
|
371
|
+
declare function readFile(filePath: string, options: ReadOptions & {
|
|
372
|
+
encoding: 'blob';
|
|
373
|
+
}): AsyncIOResult<File>;
|
|
374
|
+
/**
|
|
375
|
+
* Reads the content of a file at the specified path as a string.
|
|
376
|
+
*
|
|
377
|
+
* @param filePath - The path of the file to read.
|
|
378
|
+
* @param options - Read options specifying the 'utf8' encoding.
|
|
379
|
+
* @returns A promise that resolves to an `AsyncIOResult` containing the file content as a string.
|
|
380
|
+
*/
|
|
381
|
+
declare function readFile(filePath: string, options: ReadOptions & {
|
|
382
|
+
encoding: 'utf8';
|
|
383
|
+
}): AsyncIOResult<string>;
|
|
384
|
+
/**
|
|
385
|
+
* Reads the content of a file at the specified path as an ArrayBuffer by default.
|
|
386
|
+
*
|
|
387
|
+
* @param filePath - The path of the file to read.
|
|
388
|
+
* @param options - Read options specifying the 'binary' encoding.
|
|
389
|
+
* @returns A promise that resolves to an `AsyncIOResult` containing the file content as an ArrayBuffer.
|
|
390
|
+
*/
|
|
391
|
+
declare function readFile(filePath: string, options?: ReadOptions & {
|
|
392
|
+
encoding: 'binary';
|
|
393
|
+
}): AsyncIOResult<ArrayBuffer>;
|
|
394
|
+
/**
|
|
395
|
+
* Removes a file or directory at the specified path same as `rm -rf`.
|
|
396
|
+
*
|
|
397
|
+
* @param path - The path of the file or directory to remove.
|
|
398
|
+
* @returns A promise that resolves to an `AsyncIOResult` indicating whether the file or directory was successfully removed.
|
|
399
|
+
*/
|
|
400
|
+
declare function remove(path: string): AsyncVoidIOResult;
|
|
401
|
+
/**
|
|
402
|
+
* Retrieves the status of a file or directory at the specified path.
|
|
403
|
+
*
|
|
404
|
+
* @param path - The path of the file or directory to retrieve status for.
|
|
405
|
+
* @returns A promise that resolves to an `AsyncIOResult` containing the `FileSystemHandle`.
|
|
406
|
+
*/
|
|
407
|
+
declare function stat(path: string): AsyncIOResult<FileSystemHandle>;
|
|
408
|
+
/**
|
|
409
|
+
* Writes content to a file at the specified path.
|
|
410
|
+
*
|
|
411
|
+
* @param filePath - The path of the file to write to.
|
|
412
|
+
* @param contents - The content to write to the file.
|
|
413
|
+
* @param options - Optional write options.
|
|
414
|
+
* @returns A promise that resolves to an `AsyncIOResult` indicating whether the file was successfully written.
|
|
415
|
+
*/
|
|
416
|
+
declare function writeFile(filePath: string, contents: WriteFileContent, options?: WriteOptions): AsyncVoidIOResult;
|
|
417
|
+
|
|
418
|
+
/** ----------------------------------------------------------------------
|
|
419
|
+
* Copyright ©
|
|
420
|
+
* Jiang Jie
|
|
421
|
+
* 2024, 2025
|
|
422
|
+
* Pellegrino Prevete
|
|
423
|
+
* 2025
|
|
424
|
+
*
|
|
425
|
+
* All rights reserved
|
|
426
|
+
* ----------------------------------------------------------------------
|
|
427
|
+
*
|
|
428
|
+
* This program is free software: you can redistribute it and/or modify
|
|
429
|
+
* it under the terms of the GNU General Public License as published by
|
|
430
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
431
|
+
* (at your option) any later version.
|
|
432
|
+
*
|
|
433
|
+
* This program is distributed in the hope that it will be useful,
|
|
434
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
435
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
436
|
+
* GNU General Public License for more details.
|
|
437
|
+
*
|
|
438
|
+
* You should have received a copy of the GNU General Public License
|
|
439
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
440
|
+
*/
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Downloads a file from a URL and saves it to a temporary file.
|
|
444
|
+
* The returned response will contain the temporary file path.
|
|
445
|
+
*
|
|
446
|
+
* @param fileUrl - The URL of the file to download.
|
|
447
|
+
* @param requestInit - Optional request initialization parameters.
|
|
448
|
+
* @returns A task that can be aborted and contains the result of the download.
|
|
449
|
+
*/
|
|
450
|
+
declare function downloadFile(fileUrl: string, requestInit?: FsRequestInit): FetchTask<DownloadFileTempResponse>;
|
|
451
|
+
/**
|
|
452
|
+
* Downloads a file from a URL and saves it to the specified path.
|
|
453
|
+
*
|
|
454
|
+
* @param fileUrl - The URL of the file to download.
|
|
455
|
+
* @param filePath - The path where the downloaded file will be saved.
|
|
456
|
+
* @param requestInit - Optional request initialization parameters.
|
|
457
|
+
* @returns A task that can be aborted and contains the result of the download.
|
|
458
|
+
*/
|
|
459
|
+
declare function downloadFile(fileUrl: string, filePath: string, requestInit?: FsRequestInit): FetchTask<Response>;
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Appends content to a file at the specified path.
|
|
463
|
+
*
|
|
464
|
+
* @param filePath - The path of the file to append to.
|
|
465
|
+
* @param contents - The content to append to the file.
|
|
466
|
+
* @returns A promise that resolves to an `AsyncIOResult`
|
|
467
|
+
* indicating whether the content was successfully appended.
|
|
468
|
+
*/
|
|
469
|
+
declare function appendFile(filePath: string, contents: WriteFileContent): AsyncVoidIOResult;
|
|
470
|
+
/**
|
|
471
|
+
* Copies a file or directory from one location to another same as `cp -r`.
|
|
472
|
+
*
|
|
473
|
+
* Both `srcPath` and `destPath` must both be a file or directory.
|
|
474
|
+
*
|
|
475
|
+
* @param srcPath - The source file/directory path.
|
|
476
|
+
* @param destPath - The destination file/directory path.
|
|
477
|
+
* @param options - The copy options.
|
|
478
|
+
* @returns A promise that resolves to an `AsyncVoidIOResult`
|
|
479
|
+
* indicating whether the file was successfully copied.
|
|
480
|
+
*/
|
|
481
|
+
declare function copy(srcPath: string, destPath: string, options?: CopyOptions): AsyncVoidIOResult;
|
|
482
|
+
/**
|
|
483
|
+
* Empties the contents of a directory at the specified path.
|
|
484
|
+
*
|
|
485
|
+
* @param dirPath - The path of the directory to empty.
|
|
486
|
+
* @returns A promise that resolves to an `AsyncIOResult`
|
|
487
|
+
* indicating whether the directory was successfully emptied.
|
|
488
|
+
*/
|
|
489
|
+
declare function emptyDir(dirPath: string): AsyncVoidIOResult;
|
|
490
|
+
/**
|
|
491
|
+
* Checks whether a file or directory exists at the specified path.
|
|
492
|
+
*
|
|
493
|
+
* @param path - The path of the file or directory to check for existence.
|
|
494
|
+
* @param options - Optional existence options.
|
|
495
|
+
* @returns A promise that resolves to an `AsyncIOResult`
|
|
496
|
+
* indicating whether the file or directory exists.
|
|
497
|
+
*/
|
|
498
|
+
declare function exists(path: string, options?: ExistsOptions): AsyncIOResult<boolean>;
|
|
499
|
+
/**
|
|
500
|
+
* Move a file or directory from an old path to a new path.
|
|
501
|
+
*
|
|
502
|
+
* @param srcPath - The current path of the file or directory.
|
|
503
|
+
* @param destPath - The new path of the file or directory.
|
|
504
|
+
* @param options - Options of move.
|
|
505
|
+
* @returns A promise that resolves to an `AsyncIOResult`
|
|
506
|
+
* indicating whether the file or directory was
|
|
507
|
+
* successfully moved.
|
|
508
|
+
*/
|
|
509
|
+
declare function move(srcPath: string, destPath: string, options?: MoveOptions): AsyncVoidIOResult;
|
|
510
|
+
/**
|
|
511
|
+
* Reads the content of a file at the specified path as a File.
|
|
512
|
+
*
|
|
513
|
+
* @param filePath - The path of the file to read.
|
|
514
|
+
* @returns A promise that resolves to an `AsyncIOResult`
|
|
515
|
+
* containing the file content as a File.
|
|
516
|
+
*/
|
|
517
|
+
declare function readBlobFile(filePath: string): AsyncIOResult<File>;
|
|
518
|
+
/**
|
|
519
|
+
* Reads the content of a file at the specified path as a
|
|
520
|
+
* string and returns it as a JSON object.
|
|
521
|
+
*
|
|
522
|
+
* @param filePath - The path of the file to read.
|
|
523
|
+
* @returns A promise that resolves to an `AsyncIOResult`
|
|
524
|
+
* containing the file content as a JSON object.
|
|
525
|
+
*/
|
|
526
|
+
declare function readJsonFile<T>(filePath: string): AsyncIOResult<T>;
|
|
527
|
+
/**
|
|
528
|
+
* Reads the content of a file at the specified path as a string.
|
|
529
|
+
*
|
|
530
|
+
* @param filePath - The path of the file to read.
|
|
531
|
+
* @returns A promise that resolves to an `AsyncIOResult`
|
|
532
|
+
* containing the file content as a string.
|
|
533
|
+
*/
|
|
534
|
+
declare function readTextFile(filePath: string): AsyncIOResult<string>;
|
|
535
|
+
|
|
536
|
+
/** ----------------------------------------------------------------------
|
|
537
|
+
* Copyright ©
|
|
538
|
+
* Jiang Jie
|
|
539
|
+
* 2024, 2025
|
|
540
|
+
* Pellegrino Prevete
|
|
541
|
+
* 2025
|
|
542
|
+
*
|
|
543
|
+
* All rights reserved
|
|
544
|
+
* ----------------------------------------------------------------------
|
|
545
|
+
*
|
|
546
|
+
* This program is free software: you can redistribute it and/or modify
|
|
547
|
+
* it under the terms of the GNU General Public License as published by
|
|
548
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
549
|
+
* (at your option) any later version.
|
|
550
|
+
*
|
|
551
|
+
* This program is distributed in the hope that it will be useful,
|
|
552
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
553
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
554
|
+
* GNU General Public License for more details.
|
|
555
|
+
*
|
|
556
|
+
* You should have received a copy of the GNU General Public License
|
|
557
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
558
|
+
*/
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Create a temporary file or directory.
|
|
562
|
+
*
|
|
563
|
+
* @param options - Options and flags.
|
|
564
|
+
* @returns A promise that resolves the result of
|
|
565
|
+
* the temporary file or directory path.
|
|
566
|
+
*/
|
|
567
|
+
declare function mkTemp(options?: TempOptions): AsyncIOResult<string>;
|
|
568
|
+
/**
|
|
569
|
+
* Delete the temporary directory and all its contents.
|
|
570
|
+
* @returns A promise that resolves to an `AsyncVoidIOResult`
|
|
571
|
+
* indicating whether the temporary directory was
|
|
572
|
+
* successfully deleted.
|
|
573
|
+
*/
|
|
574
|
+
declare function deleteTemp(): AsyncVoidIOResult;
|
|
575
|
+
/**
|
|
576
|
+
* Prune the temporary directory and delete all expired files.
|
|
577
|
+
* @param expired - The date to determine whether a file is expired.
|
|
578
|
+
* @returns A promise that resolves to an `AsyncVoidIOResult`
|
|
579
|
+
* indicating whether the temporary directory was successfully pruned.
|
|
580
|
+
*/
|
|
581
|
+
declare function pruneTemp(expired: Date): AsyncVoidIOResult;
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Unzip a zip file to a directory.
|
|
585
|
+
* Equivalent to `unzip -o <zipFilePath> -d <targetPath>
|
|
586
|
+
*
|
|
587
|
+
* Usees [fflate](https://github.com/101arrowz/fflate) as the unzip backend.
|
|
588
|
+
* @param zipFilePath - Zip file path.
|
|
589
|
+
* @param targetPath - The directory to unzip to.
|
|
590
|
+
* @returns A promise that resolves to an `AsyncIOResult`
|
|
591
|
+
* indicating whether the zip file was successfully unzipped.
|
|
592
|
+
*/
|
|
593
|
+
declare function unzip(zipFilePath: string, targetPath: string): AsyncVoidIOResult;
|
|
594
|
+
/**
|
|
595
|
+
* Unzip a remote zip file to a directory.
|
|
596
|
+
* Equivalent to `unzip -o <zipFilePath> -d <targetPath>
|
|
597
|
+
*
|
|
598
|
+
* Use [fflate](https://github.com/101arrowz/fflate) as the unzip backend.
|
|
599
|
+
* @param zipFileUrl - Zip file url.
|
|
600
|
+
* @param targetPath - The directory to unzip to.
|
|
601
|
+
* @param requestInit - Optional request initialization parameters.
|
|
602
|
+
* @returns A promise that resolves to an `AsyncIOResult`
|
|
603
|
+
* indicating whether the zip file was successfully unzipped.
|
|
604
|
+
*/
|
|
605
|
+
declare function unzipFromUrl(zipFileUrl: string, targetPath: string, requestInit?: FsRequestInit): AsyncVoidIOResult;
|
|
606
|
+
|
|
607
|
+
/** ----------------------------------------------------------------------
|
|
608
|
+
* Copyright ©
|
|
609
|
+
* Jiang Jie
|
|
610
|
+
* 2024, 2025
|
|
611
|
+
* Pellegrino Prevete
|
|
612
|
+
* 2025
|
|
613
|
+
*
|
|
614
|
+
* All rights reserved
|
|
615
|
+
* ----------------------------------------------------------------------
|
|
616
|
+
*
|
|
617
|
+
* This program is free software: you can redistribute it and/or modify
|
|
618
|
+
* it under the terms of the GNU General Public License as published by
|
|
619
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
620
|
+
* (at your option) any later version.
|
|
621
|
+
*
|
|
622
|
+
* This program is distributed in the hope that it will be useful,
|
|
623
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
624
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
625
|
+
* GNU General Public License for more details.
|
|
626
|
+
*
|
|
627
|
+
* You should have received a copy of the GNU General Public License
|
|
628
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
629
|
+
*/
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Uploads a file from the specified path to a URL.
|
|
633
|
+
*
|
|
634
|
+
* @param filePath - The path of the file to upload.
|
|
635
|
+
* @param fileUrl - The URL where the file will be uploaded.
|
|
636
|
+
* @param requestInit - Optional request initialization parameters.
|
|
637
|
+
* @returns A promise that resolves to an `AsyncIOResult`
|
|
638
|
+
* indicating whether the file was successfully uploaded.
|
|
639
|
+
*/
|
|
640
|
+
declare function uploadFile(filePath: string, fileUrl: string, requestInit?: UploadRequestInit): FetchTask<Response>;
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Zip a file or directory and write to a zip file.
|
|
644
|
+
* Equivalent to `zip -r <zipFilePath> <targetPath>`.
|
|
645
|
+
*
|
|
646
|
+
* Use [fflate](https://github.com/101arrowz/fflate) as the zip backend.
|
|
647
|
+
* @param sourcePath - The path to be zipped.
|
|
648
|
+
* @param zipFilePath - The path to the zip file.
|
|
649
|
+
* @param options - Options of zip.
|
|
650
|
+
* @returns A promise that resolves to an `AsyncIOResult`
|
|
651
|
+
* indicating whether the source was successfully zipped.
|
|
652
|
+
*/
|
|
653
|
+
declare function zip(sourcePath: string, zipFilePath: string, options?: ZipOptions): AsyncVoidIOResult;
|
|
654
|
+
/**
|
|
655
|
+
* Zip a file or directory and return the zip file data.
|
|
656
|
+
* Equivalent to `zip -r <zipFilePath> <targetPath>`.
|
|
657
|
+
*
|
|
658
|
+
* Use [fflate](https://github.com/101arrowz/fflate) as the zip backend.
|
|
659
|
+
* @param sourcePath - The path to be zipped.
|
|
660
|
+
* @param options - Options of zip.
|
|
661
|
+
* @returns A promise that resolves to an `AsyncIOResult` indicating
|
|
662
|
+
* whether the source was successfully zipped.
|
|
663
|
+
*/
|
|
664
|
+
declare function zip(sourcePath: string, options?: ZipOptions): AsyncIOResult<Uint8Array>;
|
|
665
|
+
/**
|
|
666
|
+
* Zip a remote file and write to a zip file.
|
|
667
|
+
*
|
|
668
|
+
* Use [fflate](https://github.com/101arrowz/fflate) as the zip backend.
|
|
669
|
+
* @param sourceUrl - The url to be zipped.
|
|
670
|
+
* @param zipFilePath - The path to the zip file.
|
|
671
|
+
* @param requestInit - Optional request initialization parameters.
|
|
672
|
+
* @returns A promise that resolves to an `AsyncIOResult`
|
|
673
|
+
* indicating whether the source was successfully zipped.
|
|
674
|
+
*/
|
|
675
|
+
declare function zipFromUrl(sourceUrl: string, zipFilePath: string, requestInit?: FsRequestInit): AsyncVoidIOResult;
|
|
676
|
+
/**
|
|
677
|
+
* Zip a remote file and return the zip file data.
|
|
678
|
+
*
|
|
679
|
+
* Use [fflate](https://github.com/101arrowz/fflate) as the zip backend.
|
|
680
|
+
* @param sourceUrl - The url to be zipped.
|
|
681
|
+
* @param requestInit - Optional request initialization parameters.
|
|
682
|
+
* @returns A promise that resolves to an `AsyncIOResult` indicating
|
|
683
|
+
* whether the source was successfully zipped.
|
|
684
|
+
*/
|
|
685
|
+
declare function zipFromUrl(sourceUrl: string, requestInit?: FsRequestInit): AsyncIOResult<Uint8Array>;
|
|
686
|
+
|
|
687
|
+
/** ----------------------------------------------------------------------
|
|
688
|
+
* Copyright ©
|
|
689
|
+
* Jiang Jie
|
|
690
|
+
* 2024, 2025
|
|
691
|
+
* Pellegrino Prevete
|
|
692
|
+
* 2025
|
|
693
|
+
*
|
|
694
|
+
* All rights reserved
|
|
695
|
+
* ----------------------------------------------------------------------
|
|
696
|
+
*
|
|
697
|
+
* This program is free software: you can redistribute it and/or modify
|
|
698
|
+
* it under the terms of the GNU General Public License as published by
|
|
699
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
700
|
+
* (at your option) any later version.
|
|
701
|
+
*
|
|
702
|
+
* This program is distributed in the hope that it will be useful,
|
|
703
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
704
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
705
|
+
* GNU General Public License for more details.
|
|
706
|
+
*
|
|
707
|
+
* You should have received a copy of the GNU General Public License
|
|
708
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
709
|
+
*/
|
|
710
|
+
/**
|
|
711
|
+
* Checks if the Origin Private File System (OPFS) is supported in the current environment.
|
|
712
|
+
*
|
|
713
|
+
* @returns A boolean indicating whether OPFS is supported.
|
|
714
|
+
*/
|
|
715
|
+
declare function isOPFSSupported(): boolean;
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* Generate a temporary path but not create it.
|
|
719
|
+
*
|
|
720
|
+
* @param options - Options and flags.
|
|
721
|
+
* @returns The temporary path.
|
|
722
|
+
*/
|
|
723
|
+
declare function generateTempPath(options?: TempOptions): string;
|
|
724
|
+
/**
|
|
725
|
+
* Check whether the path is a temporary path.
|
|
726
|
+
* @param path - The path to check.
|
|
727
|
+
* @returns `true` if the path is a temporary path otherwise `false`.
|
|
728
|
+
*/
|
|
729
|
+
declare function isTempPath(path: string): boolean;
|
|
730
|
+
/**
|
|
731
|
+
* Serialize a `FileSystemHandle` to plain object.
|
|
732
|
+
* @param handle - `FileSystemHandle` object.
|
|
733
|
+
* @returns Serializable version of FileSystemHandle that is FileSystemHandleLike.
|
|
734
|
+
*/
|
|
735
|
+
declare function toFileSystemHandleLike(handle: FileSystemHandle): Promise<FileSystemHandleLike>;
|
|
736
|
+
/**
|
|
737
|
+
* Whether the handle is a file.
|
|
738
|
+
* @param handle - The handle which is a FileSystemHandle.
|
|
739
|
+
* @returns `true` if the handle is a file, otherwise `false`.
|
|
740
|
+
*/
|
|
741
|
+
declare function isFileHandle(handle: FileSystemHandle): handle is FileSystemFileHandle;
|
|
742
|
+
/**
|
|
743
|
+
* Whether the handle is a directory.
|
|
744
|
+
* @param handle - The handle which is a FileSystemHandle.
|
|
745
|
+
* @returns `true` if the handle is a directory, otherwise `false`.
|
|
746
|
+
*/
|
|
747
|
+
declare function isDirectoryHandle(handle: FileSystemHandle): handle is FileSystemDirectoryHandle;
|
|
748
|
+
/**
|
|
749
|
+
* Whether the handle is a file-like.
|
|
750
|
+
* @param handle - The handle which is a FileSystemHandleLike.
|
|
751
|
+
* @returns `true` if the handle is a file, otherwise `false`.
|
|
752
|
+
*/
|
|
753
|
+
declare function isFileHandleLike(handle: FileSystemHandleLike): handle is FileSystemFileHandleLike;
|
|
754
|
+
/**
|
|
755
|
+
* Gets the data of a file handle.
|
|
756
|
+
* @param handle - The file handle.
|
|
757
|
+
* @returns A promise that resolves to the data of the file.
|
|
758
|
+
*/
|
|
759
|
+
declare function getFileDataByHandle(handle: FileSystemFileHandle): Promise<Uint8Array>;
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* Start worker agent.
|
|
763
|
+
* Listens to postMessage from main thread.
|
|
764
|
+
* Start runner loop.
|
|
765
|
+
*/
|
|
766
|
+
declare function startSyncAgent(): void;
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Inspired by [memfs](https://github.com/streamich/memfs/blob/master/src/fsa-to-node/worker/SyncMessenger.ts).
|
|
770
|
+
*
|
|
771
|
+
* Used both in main thread and worker thread.
|
|
772
|
+
*/
|
|
773
|
+
declare class SyncMessenger {
|
|
774
|
+
readonly i32a: Int32Array;
|
|
775
|
+
readonly u8a: Uint8Array;
|
|
776
|
+
readonly headerLength: number;
|
|
777
|
+
readonly maxDataLength: number;
|
|
778
|
+
constructor(sab: SharedArrayBuffer);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
/** ----------------------------------------------------------------------
|
|
782
|
+
* Copyright ©
|
|
783
|
+
* Jiang Jie
|
|
784
|
+
* 2024, 2025
|
|
785
|
+
* Pellegrino Prevete
|
|
786
|
+
* 2025
|
|
787
|
+
*
|
|
788
|
+
* All rights reserved
|
|
789
|
+
* ----------------------------------------------------------------------
|
|
790
|
+
*
|
|
791
|
+
* This program is free software: you can redistribute it and/or modify
|
|
792
|
+
* it under the terms of the GNU General Public License as published by
|
|
793
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
794
|
+
* (at your option) any later version.
|
|
795
|
+
*
|
|
796
|
+
* This program is distributed in the hope that it will be useful,
|
|
797
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
798
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
799
|
+
* GNU General Public License for more details.
|
|
800
|
+
*
|
|
801
|
+
* You should have received a copy of the GNU General Public License
|
|
802
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
803
|
+
*/
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Communicate with worker.
|
|
807
|
+
* @param options - SyncAgentOptions
|
|
808
|
+
* @returns
|
|
809
|
+
*/
|
|
810
|
+
declare function connectSyncAgent(options: SyncAgentOptions): Promise<void>;
|
|
811
|
+
/**
|
|
812
|
+
* Get messenger instance.
|
|
813
|
+
* Use `setSyncMessenger` to pass the messenger to other environments for sharing.
|
|
814
|
+
*
|
|
815
|
+
* @returns SyncMessenger instance.
|
|
816
|
+
*/
|
|
817
|
+
declare function getSyncMessenger(): SyncMessenger;
|
|
818
|
+
/**
|
|
819
|
+
* Set messenger instance.
|
|
820
|
+
* Use this method to share messenger with other environments.
|
|
821
|
+
*
|
|
822
|
+
* @param syncMessenger - SyncMessenger instance.
|
|
823
|
+
*/
|
|
824
|
+
declare function setSyncMessenger(syncMessenger: SyncMessenger): void;
|
|
825
|
+
/**
|
|
826
|
+
* Sync version of `createFile`.
|
|
827
|
+
*/
|
|
828
|
+
declare function createFileSync(filePath: string): VoidIOResult;
|
|
829
|
+
/**
|
|
830
|
+
* Sync version of `mkdir`.
|
|
831
|
+
*/
|
|
832
|
+
declare function mkdirSync(dirPath: string): VoidIOResult;
|
|
833
|
+
/**
|
|
834
|
+
* Sync version of `move`.
|
|
835
|
+
*/
|
|
836
|
+
declare function moveSync(srcPath: string, destPath: string, options?: MoveOptions): VoidIOResult;
|
|
837
|
+
/**
|
|
838
|
+
* Sync version of `readDir`.
|
|
839
|
+
*/
|
|
840
|
+
declare function readDirSync(dirPath: string, options?: ReadDirOptions): IOResult<ReadDirEntrySync[]>;
|
|
841
|
+
/**
|
|
842
|
+
* Sync version of `readFile`.
|
|
843
|
+
*/
|
|
844
|
+
declare function readFileSync(filePath: string, options: ReadOptions & {
|
|
845
|
+
encoding: 'blob';
|
|
846
|
+
}): IOResult<FileLike>;
|
|
847
|
+
declare function readFileSync(filePath: string, options: ReadOptions & {
|
|
848
|
+
encoding: 'utf8';
|
|
849
|
+
}): IOResult<string>;
|
|
850
|
+
declare function readFileSync(filePath: string, options?: ReadOptions & {
|
|
851
|
+
encoding: 'binary';
|
|
852
|
+
}): IOResult<ArrayBuffer>;
|
|
853
|
+
/**
|
|
854
|
+
* Sync version of `remove`.
|
|
855
|
+
*/
|
|
856
|
+
declare function removeSync(path: string): VoidIOResult;
|
|
857
|
+
/**
|
|
858
|
+
* Sync version of `stat`.
|
|
859
|
+
*/
|
|
860
|
+
declare function statSync(path: string): IOResult<FileSystemHandleLike>;
|
|
861
|
+
/**
|
|
862
|
+
* Sync version of `writeFile`.
|
|
863
|
+
*/
|
|
864
|
+
declare function writeFileSync(filePath: string, contents: WriteSyncFileContent, options?: WriteOptions): VoidIOResult;
|
|
865
|
+
/**
|
|
866
|
+
* Sync version of `appendFile`.
|
|
867
|
+
*/
|
|
868
|
+
declare function appendFileSync(filePath: string, contents: WriteSyncFileContent): VoidIOResult;
|
|
869
|
+
/**
|
|
870
|
+
* Sync version of `copy`.
|
|
871
|
+
*/
|
|
872
|
+
declare function copySync(srcPath: string, destPath: string, options?: CopyOptions): VoidIOResult;
|
|
873
|
+
/**
|
|
874
|
+
* Sync version of `emptyDir`.
|
|
875
|
+
*/
|
|
876
|
+
declare function emptyDirSync(dirPath: string): VoidIOResult;
|
|
877
|
+
/**
|
|
878
|
+
* Sync version of `exists`.
|
|
879
|
+
*/
|
|
880
|
+
declare function existsSync(path: string, options?: ExistsOptions): IOResult<boolean>;
|
|
881
|
+
/**
|
|
882
|
+
* Sync version of `deleteTemp`.
|
|
883
|
+
*/
|
|
884
|
+
declare function deleteTempSync(): VoidIOResult;
|
|
885
|
+
/**
|
|
886
|
+
* Sync version of `mkTemp`.
|
|
887
|
+
*/
|
|
888
|
+
declare function mkTempSync(options?: TempOptions): IOResult<string>;
|
|
889
|
+
/**
|
|
890
|
+
* Sync version of `pruneTemp`.
|
|
891
|
+
*/
|
|
892
|
+
declare function pruneTempSync(expired: Date): VoidIOResult;
|
|
893
|
+
/**
|
|
894
|
+
* Sync version of `readBlobFile`.
|
|
895
|
+
*/
|
|
896
|
+
declare function readBlobFileSync(filePath: string): IOResult<FileLike>;
|
|
897
|
+
/**
|
|
898
|
+
* Sync version of `readJsonFile`.
|
|
899
|
+
*/
|
|
900
|
+
declare function readJsonFileSync<T>(filePath: string): IOResult<T>;
|
|
901
|
+
/**
|
|
902
|
+
* Sync version of `readTextFile`.
|
|
903
|
+
*/
|
|
904
|
+
declare function readTextFileSync(filePath: string): IOResult<string>;
|
|
905
|
+
/**
|
|
906
|
+
* Sync version of `unzip`.
|
|
907
|
+
*/
|
|
908
|
+
declare function unzipSync(zipFilePath: string, targetPath: string): VoidIOResult;
|
|
909
|
+
/**
|
|
910
|
+
* Sync version of `zip`.
|
|
911
|
+
*/
|
|
912
|
+
declare function zipSync(sourcePath: string, zipFilePath: string, options?: ZipOptions): VoidIOResult;
|
|
913
|
+
/**
|
|
914
|
+
* Sync version of `zip`.
|
|
915
|
+
*/
|
|
916
|
+
declare function zipSync(sourcePath: string, options?: ZipOptions): IOResult<Uint8Array>;
|
|
917
|
+
|
|
918
|
+
export { CURRENT_DIR, NOT_FOUND_ERROR, ROOT_DIR, SyncMessenger, TMP_DIR, appendFile, appendFileSync, assertAbsolutePath, assertFileUrl, connectSyncAgent, copy, copySync, createFile, createFileSync, deleteTemp, deleteTempSync, downloadFile, emptyDir, emptyDirSync, exists, existsSync, generateTempPath, getFileDataByHandle, getSyncMessenger, isDirectoryHandle, isFileHandle, isFileHandleLike, isOPFSSupported, isTempPath, mkTemp, mkTempSync, mkdir, mkdirSync, move, moveSync, pruneTemp, pruneTempSync, readBlobFile, readBlobFileSync, readDir, readDirSync, readFile, readFileSync, readJsonFile, readJsonFileSync, readTextFile, readTextFileSync, remove, removeSync, setSyncMessenger, startSyncAgent, stat, statSync, toFileSystemHandleLike, unzip, unzipFromUrl, unzipSync, uploadFile, writeFile, writeFileSync, zip, zipFromUrl, zipSync };
|
|
919
|
+
export type { CopyOptions, DownloadFileTempResponse, ErrorLike, ExistsOptions, FileEncoding, FileLike, FileSystemFileHandleLike, FileSystemHandleLike, FsRequestInit, MoveOptions, ReadDirEntry, ReadDirEntrySync, ReadDirOptions, ReadFileContent, ReadOptions, SyncAgentOptions, TempOptions, UploadRequestInit, WriteFileContent, WriteOptions, WriteSyncFileContent, ZipOptions };
|
|
920
|
+
//# sourceMappingURL=types.d.ts.map
|