@tauri-apps/plugin-fs 2.0.0-alpha.1 → 2.0.0-alpha.3
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/README.md +1 -1
- package/dist-js/index.d.ts +0 -5
- package/dist-js/index.min.js +93 -19
- package/dist-js/index.mjs +14 -15
- package/package.json +2 -2
package/README.md
CHANGED
package/dist-js/index.d.ts
CHANGED
|
@@ -41,11 +41,6 @@
|
|
|
41
41
|
* @module
|
|
42
42
|
*/
|
|
43
43
|
import { BaseDirectory } from "@tauri-apps/api/path";
|
|
44
|
-
declare global {
|
|
45
|
-
interface Window {
|
|
46
|
-
__TAURI_INVOKE__: <T>(cmd: string, args?: unknown) => Promise<T>;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
44
|
interface Permissions {
|
|
50
45
|
/**
|
|
51
46
|
* `true` if these permissions describe a readonly (unwritable) file.
|
package/dist-js/index.min.js
CHANGED
|
@@ -1,8 +1,84 @@
|
|
|
1
|
-
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */
|
|
15
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
19
|
+
var e = new Error(message);
|
|
20
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
21
|
+
};
|
|
2
22
|
|
|
3
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Sends a message to the backend.
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { invoke } from '@tauri-apps/api/primitives';
|
|
28
|
+
* await invoke('login', { user: 'tauri', password: 'poiwe3h4r5ip3yrhtew9ty' });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param cmd The command name.
|
|
32
|
+
* @param args The optional arguments to pass to the command.
|
|
33
|
+
* @param options The request options.
|
|
34
|
+
* @return A promise resolving or rejecting to the backend response.
|
|
35
|
+
*
|
|
36
|
+
* @since 1.0.0
|
|
37
|
+
*/
|
|
38
|
+
async function invoke(cmd, args = {}, options) {
|
|
39
|
+
return window.__TAURI_INTERNALS__.invoke(cmd, args, options);
|
|
40
|
+
}
|
|
4
41
|
|
|
5
|
-
|
|
42
|
+
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
43
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
44
|
+
// SPDX-License-Identifier: MIT
|
|
45
|
+
/**
|
|
46
|
+
* The path module provides utilities for working with file and directory paths.
|
|
47
|
+
*
|
|
48
|
+
* This package is also accessible with `window.__TAURI__.path` when [`build.withGlobalTauri`](https://tauri.app/v1/api/config/#buildconfig.withglobaltauri) in `tauri.conf.json` is set to `true`.
|
|
49
|
+
*
|
|
50
|
+
* It is recommended to allowlist only the APIs you use for optimal bundle size and security.
|
|
51
|
+
* @module
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* @since 2.0.0
|
|
55
|
+
*/
|
|
56
|
+
var BaseDirectory;
|
|
57
|
+
(function (BaseDirectory) {
|
|
58
|
+
BaseDirectory[BaseDirectory["Audio"] = 1] = "Audio";
|
|
59
|
+
BaseDirectory[BaseDirectory["Cache"] = 2] = "Cache";
|
|
60
|
+
BaseDirectory[BaseDirectory["Config"] = 3] = "Config";
|
|
61
|
+
BaseDirectory[BaseDirectory["Data"] = 4] = "Data";
|
|
62
|
+
BaseDirectory[BaseDirectory["LocalData"] = 5] = "LocalData";
|
|
63
|
+
BaseDirectory[BaseDirectory["Document"] = 6] = "Document";
|
|
64
|
+
BaseDirectory[BaseDirectory["Download"] = 7] = "Download";
|
|
65
|
+
BaseDirectory[BaseDirectory["Picture"] = 8] = "Picture";
|
|
66
|
+
BaseDirectory[BaseDirectory["Public"] = 9] = "Public";
|
|
67
|
+
BaseDirectory[BaseDirectory["Video"] = 10] = "Video";
|
|
68
|
+
BaseDirectory[BaseDirectory["Resource"] = 11] = "Resource";
|
|
69
|
+
BaseDirectory[BaseDirectory["Temp"] = 12] = "Temp";
|
|
70
|
+
BaseDirectory[BaseDirectory["AppConfig"] = 13] = "AppConfig";
|
|
71
|
+
BaseDirectory[BaseDirectory["AppData"] = 14] = "AppData";
|
|
72
|
+
BaseDirectory[BaseDirectory["AppLocalData"] = 15] = "AppLocalData";
|
|
73
|
+
BaseDirectory[BaseDirectory["AppCache"] = 16] = "AppCache";
|
|
74
|
+
BaseDirectory[BaseDirectory["AppLog"] = 17] = "AppLog";
|
|
75
|
+
BaseDirectory[BaseDirectory["Desktop"] = 18] = "Desktop";
|
|
76
|
+
BaseDirectory[BaseDirectory["Executable"] = 19] = "Executable";
|
|
77
|
+
BaseDirectory[BaseDirectory["Font"] = 20] = "Font";
|
|
78
|
+
BaseDirectory[BaseDirectory["Home"] = 21] = "Home";
|
|
79
|
+
BaseDirectory[BaseDirectory["Runtime"] = 22] = "Runtime";
|
|
80
|
+
BaseDirectory[BaseDirectory["Template"] = 23] = "Template";
|
|
81
|
+
})(BaseDirectory || (BaseDirectory = {}));
|
|
6
82
|
|
|
7
83
|
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
8
84
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -61,7 +137,7 @@ var q={};g$1(q,{BaseDirectory:()=>t,appCacheDir:()=>p,appConfigDir:()=>s,appData
|
|
|
61
137
|
* @since 2.0.0
|
|
62
138
|
*/
|
|
63
139
|
async function readTextFile(filePath, options = {}) {
|
|
64
|
-
return await
|
|
140
|
+
return await invoke("plugin:fs|read_text_file", {
|
|
65
141
|
path: filePath,
|
|
66
142
|
options,
|
|
67
143
|
});
|
|
@@ -78,7 +154,7 @@ async function readTextFile(filePath, options = {}) {
|
|
|
78
154
|
* @since 2.0.0
|
|
79
155
|
*/
|
|
80
156
|
async function readBinaryFile(filePath, options = {}) {
|
|
81
|
-
const arr = await
|
|
157
|
+
const arr = await invoke("plugin:fs|read_file", {
|
|
82
158
|
path: filePath,
|
|
83
159
|
options,
|
|
84
160
|
});
|
|
@@ -113,7 +189,7 @@ async function writeTextFile(path, contents, options) {
|
|
|
113
189
|
else {
|
|
114
190
|
fileOptions = contents;
|
|
115
191
|
}
|
|
116
|
-
return await
|
|
192
|
+
return await invoke("plugin:fs|write_file", {
|
|
117
193
|
path: file.path,
|
|
118
194
|
contents: Array.from(new TextEncoder().encode(file.contents)),
|
|
119
195
|
options: fileOptions,
|
|
@@ -149,7 +225,7 @@ async function writeBinaryFile(path, contents, options) {
|
|
|
149
225
|
// @ts-expect-error in this case `contents` is always a BinaryFileContents
|
|
150
226
|
file.contents = contents !== null && contents !== void 0 ? contents : [];
|
|
151
227
|
}
|
|
152
|
-
return await
|
|
228
|
+
return await invoke("plugin:fs|write_file", {
|
|
153
229
|
path: file.path,
|
|
154
230
|
contents: Array.from(file.contents instanceof ArrayBuffer
|
|
155
231
|
? new Uint8Array(file.contents)
|
|
@@ -178,7 +254,7 @@ async function writeBinaryFile(path, contents, options) {
|
|
|
178
254
|
* @since 2.0.0
|
|
179
255
|
*/
|
|
180
256
|
async function readDir(dir, options = {}) {
|
|
181
|
-
return await
|
|
257
|
+
return await invoke("plugin:fs|read_dir", {
|
|
182
258
|
path: dir,
|
|
183
259
|
options,
|
|
184
260
|
});
|
|
@@ -199,7 +275,7 @@ async function readDir(dir, options = {}) {
|
|
|
199
275
|
* @since 2.0.0
|
|
200
276
|
*/
|
|
201
277
|
async function createDir(dir, options = {}) {
|
|
202
|
-
return await
|
|
278
|
+
return await invoke("plugin:fs|create_dir", {
|
|
203
279
|
path: dir,
|
|
204
280
|
options,
|
|
205
281
|
});
|
|
@@ -219,7 +295,7 @@ async function createDir(dir, options = {}) {
|
|
|
219
295
|
* @since 2.0.0
|
|
220
296
|
*/
|
|
221
297
|
async function removeDir(dir, options = {}) {
|
|
222
|
-
return await
|
|
298
|
+
return await invoke("plugin:fs|remove_dir", {
|
|
223
299
|
path: dir,
|
|
224
300
|
options,
|
|
225
301
|
});
|
|
@@ -238,7 +314,7 @@ async function removeDir(dir, options = {}) {
|
|
|
238
314
|
* @since 2.0.0
|
|
239
315
|
*/
|
|
240
316
|
async function copyFile(source, destination, options = {}) {
|
|
241
|
-
return await
|
|
317
|
+
return await invoke("plugin:fs|copy_file", {
|
|
242
318
|
source,
|
|
243
319
|
destination,
|
|
244
320
|
options,
|
|
@@ -258,7 +334,7 @@ async function copyFile(source, destination, options = {}) {
|
|
|
258
334
|
* @since 2.0.0
|
|
259
335
|
*/
|
|
260
336
|
async function removeFile(file, options = {}) {
|
|
261
|
-
return await
|
|
337
|
+
return await invoke("plugin:fs|remove_file", {
|
|
262
338
|
path: file,
|
|
263
339
|
options,
|
|
264
340
|
});
|
|
@@ -277,7 +353,7 @@ async function removeFile(file, options = {}) {
|
|
|
277
353
|
* @since 2.0.0
|
|
278
354
|
*/
|
|
279
355
|
async function renameFile(oldPath, newPath, options = {}) {
|
|
280
|
-
return await
|
|
356
|
+
return await invoke("plugin:fs|rename_file", {
|
|
281
357
|
oldPath,
|
|
282
358
|
newPath,
|
|
283
359
|
options,
|
|
@@ -295,7 +371,7 @@ async function renameFile(oldPath, newPath, options = {}) {
|
|
|
295
371
|
* @since 2.0.0
|
|
296
372
|
*/
|
|
297
373
|
async function exists(path) {
|
|
298
|
-
return await
|
|
374
|
+
return await invoke("plugin:fs|exists", { path });
|
|
299
375
|
}
|
|
300
376
|
/**
|
|
301
377
|
* Returns the metadata for the given path.
|
|
@@ -303,11 +379,9 @@ async function exists(path) {
|
|
|
303
379
|
* @since 2.0.0
|
|
304
380
|
*/
|
|
305
381
|
async function metadata(path) {
|
|
306
|
-
return await
|
|
307
|
-
.__TAURI_INVOKE__("plugin:fs|metadata", {
|
|
382
|
+
return await invoke("plugin:fs|metadata", {
|
|
308
383
|
path,
|
|
309
|
-
})
|
|
310
|
-
.then((metadata) => {
|
|
384
|
+
}).then((metadata) => {
|
|
311
385
|
const { accessedAtMs, createdAtMs, modifiedAtMs, ...data } = metadata;
|
|
312
386
|
return {
|
|
313
387
|
accessedAt: new Date(accessedAtMs),
|
|
@@ -318,5 +392,5 @@ async function metadata(path) {
|
|
|
318
392
|
});
|
|
319
393
|
}
|
|
320
394
|
|
|
321
|
-
export {
|
|
395
|
+
export { BaseDirectory, BaseDirectory as Dir, copyFile, createDir, exists, metadata, readBinaryFile, readDir, readTextFile, removeDir, removeFile, renameFile, writeBinaryFile, writeTextFile as writeFile, writeTextFile };
|
|
322
396
|
//# sourceMappingURL=index.min.js.map
|
package/dist-js/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { BaseDirectory, BaseDirectory as Dir } from '@tauri-apps/api/path';
|
|
2
|
+
import { invoke } from '@tauri-apps/api/primitives';
|
|
2
3
|
|
|
3
4
|
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
4
5
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -57,7 +58,7 @@ export { BaseDirectory, BaseDirectory as Dir } from '@tauri-apps/api/path';
|
|
|
57
58
|
* @since 2.0.0
|
|
58
59
|
*/
|
|
59
60
|
async function readTextFile(filePath, options = {}) {
|
|
60
|
-
return await
|
|
61
|
+
return await invoke("plugin:fs|read_text_file", {
|
|
61
62
|
path: filePath,
|
|
62
63
|
options,
|
|
63
64
|
});
|
|
@@ -74,7 +75,7 @@ async function readTextFile(filePath, options = {}) {
|
|
|
74
75
|
* @since 2.0.0
|
|
75
76
|
*/
|
|
76
77
|
async function readBinaryFile(filePath, options = {}) {
|
|
77
|
-
const arr = await
|
|
78
|
+
const arr = await invoke("plugin:fs|read_file", {
|
|
78
79
|
path: filePath,
|
|
79
80
|
options,
|
|
80
81
|
});
|
|
@@ -109,7 +110,7 @@ async function writeTextFile(path, contents, options) {
|
|
|
109
110
|
else {
|
|
110
111
|
fileOptions = contents;
|
|
111
112
|
}
|
|
112
|
-
return await
|
|
113
|
+
return await invoke("plugin:fs|write_file", {
|
|
113
114
|
path: file.path,
|
|
114
115
|
contents: Array.from(new TextEncoder().encode(file.contents)),
|
|
115
116
|
options: fileOptions,
|
|
@@ -145,7 +146,7 @@ async function writeBinaryFile(path, contents, options) {
|
|
|
145
146
|
// @ts-expect-error in this case `contents` is always a BinaryFileContents
|
|
146
147
|
file.contents = contents !== null && contents !== void 0 ? contents : [];
|
|
147
148
|
}
|
|
148
|
-
return await
|
|
149
|
+
return await invoke("plugin:fs|write_file", {
|
|
149
150
|
path: file.path,
|
|
150
151
|
contents: Array.from(file.contents instanceof ArrayBuffer
|
|
151
152
|
? new Uint8Array(file.contents)
|
|
@@ -174,7 +175,7 @@ async function writeBinaryFile(path, contents, options) {
|
|
|
174
175
|
* @since 2.0.0
|
|
175
176
|
*/
|
|
176
177
|
async function readDir(dir, options = {}) {
|
|
177
|
-
return await
|
|
178
|
+
return await invoke("plugin:fs|read_dir", {
|
|
178
179
|
path: dir,
|
|
179
180
|
options,
|
|
180
181
|
});
|
|
@@ -195,7 +196,7 @@ async function readDir(dir, options = {}) {
|
|
|
195
196
|
* @since 2.0.0
|
|
196
197
|
*/
|
|
197
198
|
async function createDir(dir, options = {}) {
|
|
198
|
-
return await
|
|
199
|
+
return await invoke("plugin:fs|create_dir", {
|
|
199
200
|
path: dir,
|
|
200
201
|
options,
|
|
201
202
|
});
|
|
@@ -215,7 +216,7 @@ async function createDir(dir, options = {}) {
|
|
|
215
216
|
* @since 2.0.0
|
|
216
217
|
*/
|
|
217
218
|
async function removeDir(dir, options = {}) {
|
|
218
|
-
return await
|
|
219
|
+
return await invoke("plugin:fs|remove_dir", {
|
|
219
220
|
path: dir,
|
|
220
221
|
options,
|
|
221
222
|
});
|
|
@@ -234,7 +235,7 @@ async function removeDir(dir, options = {}) {
|
|
|
234
235
|
* @since 2.0.0
|
|
235
236
|
*/
|
|
236
237
|
async function copyFile(source, destination, options = {}) {
|
|
237
|
-
return await
|
|
238
|
+
return await invoke("plugin:fs|copy_file", {
|
|
238
239
|
source,
|
|
239
240
|
destination,
|
|
240
241
|
options,
|
|
@@ -254,7 +255,7 @@ async function copyFile(source, destination, options = {}) {
|
|
|
254
255
|
* @since 2.0.0
|
|
255
256
|
*/
|
|
256
257
|
async function removeFile(file, options = {}) {
|
|
257
|
-
return await
|
|
258
|
+
return await invoke("plugin:fs|remove_file", {
|
|
258
259
|
path: file,
|
|
259
260
|
options,
|
|
260
261
|
});
|
|
@@ -273,7 +274,7 @@ async function removeFile(file, options = {}) {
|
|
|
273
274
|
* @since 2.0.0
|
|
274
275
|
*/
|
|
275
276
|
async function renameFile(oldPath, newPath, options = {}) {
|
|
276
|
-
return await
|
|
277
|
+
return await invoke("plugin:fs|rename_file", {
|
|
277
278
|
oldPath,
|
|
278
279
|
newPath,
|
|
279
280
|
options,
|
|
@@ -291,7 +292,7 @@ async function renameFile(oldPath, newPath, options = {}) {
|
|
|
291
292
|
* @since 2.0.0
|
|
292
293
|
*/
|
|
293
294
|
async function exists(path) {
|
|
294
|
-
return await
|
|
295
|
+
return await invoke("plugin:fs|exists", { path });
|
|
295
296
|
}
|
|
296
297
|
/**
|
|
297
298
|
* Returns the metadata for the given path.
|
|
@@ -299,11 +300,9 @@ async function exists(path) {
|
|
|
299
300
|
* @since 2.0.0
|
|
300
301
|
*/
|
|
301
302
|
async function metadata(path) {
|
|
302
|
-
return await
|
|
303
|
-
.__TAURI_INVOKE__("plugin:fs|metadata", {
|
|
303
|
+
return await invoke("plugin:fs|metadata", {
|
|
304
304
|
path,
|
|
305
|
-
})
|
|
306
|
-
.then((metadata) => {
|
|
305
|
+
}).then((metadata) => {
|
|
307
306
|
const { accessedAtMs, createdAtMs, modifiedAtMs, ...data } = metadata;
|
|
308
307
|
return {
|
|
309
308
|
accessedAt: new Date(accessedAtMs),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tauri-apps/plugin-fs",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.3",
|
|
4
4
|
"description": "Access the file system.",
|
|
5
5
|
"license": "MIT or APACHE-2.0",
|
|
6
6
|
"authors": [
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"tslib": "^2.4.1"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@tauri-apps/api": "2.0.0-alpha.
|
|
28
|
+
"@tauri-apps/api": "2.0.0-alpha.11"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "rollup -c"
|