@tauri-apps/plugin-fs 2.0.0-beta.1 → 2.0.0-beta.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/dist-js/index.cjs +16 -18
- package/dist-js/index.d.ts +2 -3
- package/dist-js/index.js +16 -18
- package/package.json +2 -2
package/dist-js/index.cjs
CHANGED
|
@@ -98,9 +98,6 @@ function parseFileInfo(r) {
|
|
|
98
98
|
* @since 2.0.0
|
|
99
99
|
*/
|
|
100
100
|
class FileHandle extends core.Resource {
|
|
101
|
-
constructor(rid) {
|
|
102
|
-
super(rid);
|
|
103
|
-
}
|
|
104
101
|
/**
|
|
105
102
|
* Reads up to `p.byteLength` bytes into `p`. It resolves to the number of
|
|
106
103
|
* bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error
|
|
@@ -174,7 +171,7 @@ class FileHandle extends core.Resource {
|
|
|
174
171
|
* @since 2.0.0
|
|
175
172
|
*/
|
|
176
173
|
async seek(offset, whence) {
|
|
177
|
-
return core.invoke("plugin:fs|seek", {
|
|
174
|
+
return await core.invoke("plugin:fs|seek", {
|
|
178
175
|
rid: this.rid,
|
|
179
176
|
offset,
|
|
180
177
|
whence,
|
|
@@ -223,7 +220,7 @@ class FileHandle extends core.Resource {
|
|
|
223
220
|
* @since 2.0.0
|
|
224
221
|
*/
|
|
225
222
|
async truncate(len) {
|
|
226
|
-
|
|
223
|
+
await core.invoke("plugin:fs|ftruncate", {
|
|
227
224
|
rid: this.rid,
|
|
228
225
|
len,
|
|
229
226
|
});
|
|
@@ -249,7 +246,7 @@ class FileHandle extends core.Resource {
|
|
|
249
246
|
* @since 2.0.0
|
|
250
247
|
*/
|
|
251
248
|
async write(data) {
|
|
252
|
-
return core.invoke("plugin:fs|write", {
|
|
249
|
+
return await core.invoke("plugin:fs|write", {
|
|
253
250
|
rid: this.rid,
|
|
254
251
|
data: Array.from(data),
|
|
255
252
|
});
|
|
@@ -318,7 +315,7 @@ async function copyFile(fromPath, toPath, options) {
|
|
|
318
315
|
(toPath instanceof URL && toPath.protocol !== "file:")) {
|
|
319
316
|
throw new TypeError("Must be a file URL.");
|
|
320
317
|
}
|
|
321
|
-
|
|
318
|
+
await core.invoke("plugin:fs|copy_file", {
|
|
322
319
|
fromPath: fromPath instanceof URL ? fromPath.toString() : fromPath,
|
|
323
320
|
toPath: toPath instanceof URL ? toPath.toString() : toPath,
|
|
324
321
|
options,
|
|
@@ -338,7 +335,7 @@ async function mkdir(path, options) {
|
|
|
338
335
|
if (path instanceof URL && path.protocol !== "file:") {
|
|
339
336
|
throw new TypeError("Must be a file URL.");
|
|
340
337
|
}
|
|
341
|
-
|
|
338
|
+
await core.invoke("plugin:fs|mkdir", {
|
|
342
339
|
path: path instanceof URL ? path.toString() : path,
|
|
343
340
|
options,
|
|
344
341
|
});
|
|
@@ -368,7 +365,7 @@ async function readDir(path, options) {
|
|
|
368
365
|
if (path instanceof URL && path.protocol !== "file:") {
|
|
369
366
|
throw new TypeError("Must be a file URL.");
|
|
370
367
|
}
|
|
371
|
-
return core.invoke("plugin:fs|read_dir", {
|
|
368
|
+
return await core.invoke("plugin:fs|read_dir", {
|
|
372
369
|
path: path instanceof URL ? path.toString() : path,
|
|
373
370
|
options,
|
|
374
371
|
});
|
|
@@ -408,7 +405,7 @@ async function readTextFile(path, options) {
|
|
|
408
405
|
if (path instanceof URL && path.protocol !== "file:") {
|
|
409
406
|
throw new TypeError("Must be a file URL.");
|
|
410
407
|
}
|
|
411
|
-
return core.invoke("plugin:fs|read_text_file", {
|
|
408
|
+
return await core.invoke("plugin:fs|read_text_file", {
|
|
412
409
|
path: path instanceof URL ? path.toString() : path,
|
|
413
410
|
options,
|
|
414
411
|
});
|
|
@@ -433,11 +430,11 @@ async function readTextFileLines(path, options) {
|
|
|
433
430
|
throw new TypeError("Must be a file URL.");
|
|
434
431
|
}
|
|
435
432
|
const pathStr = path instanceof URL ? path.toString() : path;
|
|
436
|
-
return Promise.resolve({
|
|
433
|
+
return await Promise.resolve({
|
|
437
434
|
path: pathStr,
|
|
438
435
|
rid: null,
|
|
439
436
|
async next() {
|
|
440
|
-
if (
|
|
437
|
+
if (this.rid == null) {
|
|
441
438
|
this.rid = await core.invoke("plugin:fs|read_text_file_lines", {
|
|
442
439
|
path: pathStr,
|
|
443
440
|
options,
|
|
@@ -448,6 +445,7 @@ async function readTextFileLines(path, options) {
|
|
|
448
445
|
if (done)
|
|
449
446
|
this.rid = null;
|
|
450
447
|
return {
|
|
448
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
451
449
|
value: done ? "" : line,
|
|
452
450
|
done,
|
|
453
451
|
};
|
|
@@ -473,7 +471,7 @@ async function remove(path, options) {
|
|
|
473
471
|
if (path instanceof URL && path.protocol !== "file:") {
|
|
474
472
|
throw new TypeError("Must be a file URL.");
|
|
475
473
|
}
|
|
476
|
-
|
|
474
|
+
await core.invoke("plugin:fs|remove", {
|
|
477
475
|
path: path instanceof URL ? path.toString() : path,
|
|
478
476
|
options,
|
|
479
477
|
});
|
|
@@ -498,7 +496,7 @@ async function rename(oldPath, newPath, options) {
|
|
|
498
496
|
(newPath instanceof URL && newPath.protocol !== "file:")) {
|
|
499
497
|
throw new TypeError("Must be a file URL.");
|
|
500
498
|
}
|
|
501
|
-
|
|
499
|
+
await core.invoke("plugin:fs|rename", {
|
|
502
500
|
oldPath: oldPath instanceof URL ? oldPath.toString() : oldPath,
|
|
503
501
|
newPath: newPath instanceof URL ? newPath.toString() : newPath,
|
|
504
502
|
options,
|
|
@@ -569,7 +567,7 @@ async function truncate(path, len, options) {
|
|
|
569
567
|
if (path instanceof URL && path.protocol !== "file:") {
|
|
570
568
|
throw new TypeError("Must be a file URL.");
|
|
571
569
|
}
|
|
572
|
-
|
|
570
|
+
await core.invoke("plugin:fs|truncate", {
|
|
573
571
|
path: path instanceof URL ? path.toString() : path,
|
|
574
572
|
len,
|
|
575
573
|
options,
|
|
@@ -592,7 +590,7 @@ async function writeFile(path, data, options) {
|
|
|
592
590
|
if (path instanceof URL && path.protocol !== "file:") {
|
|
593
591
|
throw new TypeError("Must be a file URL.");
|
|
594
592
|
}
|
|
595
|
-
|
|
593
|
+
await core.invoke("plugin:fs|write_file", {
|
|
596
594
|
path: path instanceof URL ? path.toString() : path,
|
|
597
595
|
data: Array.from(data),
|
|
598
596
|
options,
|
|
@@ -613,7 +611,7 @@ async function writeTextFile(path, data, options) {
|
|
|
613
611
|
if (path instanceof URL && path.protocol !== "file:") {
|
|
614
612
|
throw new TypeError("Must be a file URL.");
|
|
615
613
|
}
|
|
616
|
-
|
|
614
|
+
await core.invoke("plugin:fs|write_text_file", {
|
|
617
615
|
path: path instanceof URL ? path.toString() : path,
|
|
618
616
|
data,
|
|
619
617
|
options,
|
|
@@ -634,7 +632,7 @@ async function exists(path, options) {
|
|
|
634
632
|
if (path instanceof URL && path.protocol !== "file:") {
|
|
635
633
|
throw new TypeError("Must be a file URL.");
|
|
636
634
|
}
|
|
637
|
-
return core.invoke("plugin:fs|exists", {
|
|
635
|
+
return await core.invoke("plugin:fs|exists", {
|
|
638
636
|
path: path instanceof URL ? path.toString() : path,
|
|
639
637
|
options,
|
|
640
638
|
});
|
package/dist-js/index.d.ts
CHANGED
|
@@ -198,7 +198,6 @@ interface FileInfo {
|
|
|
198
198
|
* @since 2.0.0
|
|
199
199
|
*/
|
|
200
200
|
declare class FileHandle extends Resource {
|
|
201
|
-
constructor(rid: number);
|
|
202
201
|
/**
|
|
203
202
|
* Reads up to `p.byteLength` bytes into `p`. It resolves to the number of
|
|
204
203
|
* bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error
|
|
@@ -737,11 +736,11 @@ interface DebouncedWatchOptions extends WatchOptions {
|
|
|
737
736
|
/**
|
|
738
737
|
* @since 2.0.0
|
|
739
738
|
*/
|
|
740
|
-
|
|
739
|
+
interface WatchEvent {
|
|
741
740
|
type: WatchEventKind;
|
|
742
741
|
paths: string[];
|
|
743
742
|
attrs: unknown;
|
|
744
|
-
}
|
|
743
|
+
}
|
|
745
744
|
/**
|
|
746
745
|
* @since 2.0.0
|
|
747
746
|
*/
|
package/dist-js/index.js
CHANGED
|
@@ -96,9 +96,6 @@ function parseFileInfo(r) {
|
|
|
96
96
|
* @since 2.0.0
|
|
97
97
|
*/
|
|
98
98
|
class FileHandle extends Resource {
|
|
99
|
-
constructor(rid) {
|
|
100
|
-
super(rid);
|
|
101
|
-
}
|
|
102
99
|
/**
|
|
103
100
|
* Reads up to `p.byteLength` bytes into `p`. It resolves to the number of
|
|
104
101
|
* bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error
|
|
@@ -172,7 +169,7 @@ class FileHandle extends Resource {
|
|
|
172
169
|
* @since 2.0.0
|
|
173
170
|
*/
|
|
174
171
|
async seek(offset, whence) {
|
|
175
|
-
return invoke("plugin:fs|seek", {
|
|
172
|
+
return await invoke("plugin:fs|seek", {
|
|
176
173
|
rid: this.rid,
|
|
177
174
|
offset,
|
|
178
175
|
whence,
|
|
@@ -221,7 +218,7 @@ class FileHandle extends Resource {
|
|
|
221
218
|
* @since 2.0.0
|
|
222
219
|
*/
|
|
223
220
|
async truncate(len) {
|
|
224
|
-
|
|
221
|
+
await invoke("plugin:fs|ftruncate", {
|
|
225
222
|
rid: this.rid,
|
|
226
223
|
len,
|
|
227
224
|
});
|
|
@@ -247,7 +244,7 @@ class FileHandle extends Resource {
|
|
|
247
244
|
* @since 2.0.0
|
|
248
245
|
*/
|
|
249
246
|
async write(data) {
|
|
250
|
-
return invoke("plugin:fs|write", {
|
|
247
|
+
return await invoke("plugin:fs|write", {
|
|
251
248
|
rid: this.rid,
|
|
252
249
|
data: Array.from(data),
|
|
253
250
|
});
|
|
@@ -316,7 +313,7 @@ async function copyFile(fromPath, toPath, options) {
|
|
|
316
313
|
(toPath instanceof URL && toPath.protocol !== "file:")) {
|
|
317
314
|
throw new TypeError("Must be a file URL.");
|
|
318
315
|
}
|
|
319
|
-
|
|
316
|
+
await invoke("plugin:fs|copy_file", {
|
|
320
317
|
fromPath: fromPath instanceof URL ? fromPath.toString() : fromPath,
|
|
321
318
|
toPath: toPath instanceof URL ? toPath.toString() : toPath,
|
|
322
319
|
options,
|
|
@@ -336,7 +333,7 @@ async function mkdir(path, options) {
|
|
|
336
333
|
if (path instanceof URL && path.protocol !== "file:") {
|
|
337
334
|
throw new TypeError("Must be a file URL.");
|
|
338
335
|
}
|
|
339
|
-
|
|
336
|
+
await invoke("plugin:fs|mkdir", {
|
|
340
337
|
path: path instanceof URL ? path.toString() : path,
|
|
341
338
|
options,
|
|
342
339
|
});
|
|
@@ -366,7 +363,7 @@ async function readDir(path, options) {
|
|
|
366
363
|
if (path instanceof URL && path.protocol !== "file:") {
|
|
367
364
|
throw new TypeError("Must be a file URL.");
|
|
368
365
|
}
|
|
369
|
-
return invoke("plugin:fs|read_dir", {
|
|
366
|
+
return await invoke("plugin:fs|read_dir", {
|
|
370
367
|
path: path instanceof URL ? path.toString() : path,
|
|
371
368
|
options,
|
|
372
369
|
});
|
|
@@ -406,7 +403,7 @@ async function readTextFile(path, options) {
|
|
|
406
403
|
if (path instanceof URL && path.protocol !== "file:") {
|
|
407
404
|
throw new TypeError("Must be a file URL.");
|
|
408
405
|
}
|
|
409
|
-
return invoke("plugin:fs|read_text_file", {
|
|
406
|
+
return await invoke("plugin:fs|read_text_file", {
|
|
410
407
|
path: path instanceof URL ? path.toString() : path,
|
|
411
408
|
options,
|
|
412
409
|
});
|
|
@@ -431,11 +428,11 @@ async function readTextFileLines(path, options) {
|
|
|
431
428
|
throw new TypeError("Must be a file URL.");
|
|
432
429
|
}
|
|
433
430
|
const pathStr = path instanceof URL ? path.toString() : path;
|
|
434
|
-
return Promise.resolve({
|
|
431
|
+
return await Promise.resolve({
|
|
435
432
|
path: pathStr,
|
|
436
433
|
rid: null,
|
|
437
434
|
async next() {
|
|
438
|
-
if (
|
|
435
|
+
if (this.rid == null) {
|
|
439
436
|
this.rid = await invoke("plugin:fs|read_text_file_lines", {
|
|
440
437
|
path: pathStr,
|
|
441
438
|
options,
|
|
@@ -446,6 +443,7 @@ async function readTextFileLines(path, options) {
|
|
|
446
443
|
if (done)
|
|
447
444
|
this.rid = null;
|
|
448
445
|
return {
|
|
446
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
449
447
|
value: done ? "" : line,
|
|
450
448
|
done,
|
|
451
449
|
};
|
|
@@ -471,7 +469,7 @@ async function remove(path, options) {
|
|
|
471
469
|
if (path instanceof URL && path.protocol !== "file:") {
|
|
472
470
|
throw new TypeError("Must be a file URL.");
|
|
473
471
|
}
|
|
474
|
-
|
|
472
|
+
await invoke("plugin:fs|remove", {
|
|
475
473
|
path: path instanceof URL ? path.toString() : path,
|
|
476
474
|
options,
|
|
477
475
|
});
|
|
@@ -496,7 +494,7 @@ async function rename(oldPath, newPath, options) {
|
|
|
496
494
|
(newPath instanceof URL && newPath.protocol !== "file:")) {
|
|
497
495
|
throw new TypeError("Must be a file URL.");
|
|
498
496
|
}
|
|
499
|
-
|
|
497
|
+
await invoke("plugin:fs|rename", {
|
|
500
498
|
oldPath: oldPath instanceof URL ? oldPath.toString() : oldPath,
|
|
501
499
|
newPath: newPath instanceof URL ? newPath.toString() : newPath,
|
|
502
500
|
options,
|
|
@@ -567,7 +565,7 @@ async function truncate(path, len, options) {
|
|
|
567
565
|
if (path instanceof URL && path.protocol !== "file:") {
|
|
568
566
|
throw new TypeError("Must be a file URL.");
|
|
569
567
|
}
|
|
570
|
-
|
|
568
|
+
await invoke("plugin:fs|truncate", {
|
|
571
569
|
path: path instanceof URL ? path.toString() : path,
|
|
572
570
|
len,
|
|
573
571
|
options,
|
|
@@ -590,7 +588,7 @@ async function writeFile(path, data, options) {
|
|
|
590
588
|
if (path instanceof URL && path.protocol !== "file:") {
|
|
591
589
|
throw new TypeError("Must be a file URL.");
|
|
592
590
|
}
|
|
593
|
-
|
|
591
|
+
await invoke("plugin:fs|write_file", {
|
|
594
592
|
path: path instanceof URL ? path.toString() : path,
|
|
595
593
|
data: Array.from(data),
|
|
596
594
|
options,
|
|
@@ -611,7 +609,7 @@ async function writeTextFile(path, data, options) {
|
|
|
611
609
|
if (path instanceof URL && path.protocol !== "file:") {
|
|
612
610
|
throw new TypeError("Must be a file URL.");
|
|
613
611
|
}
|
|
614
|
-
|
|
612
|
+
await invoke("plugin:fs|write_text_file", {
|
|
615
613
|
path: path instanceof URL ? path.toString() : path,
|
|
616
614
|
data,
|
|
617
615
|
options,
|
|
@@ -632,7 +630,7 @@ async function exists(path, options) {
|
|
|
632
630
|
if (path instanceof URL && path.protocol !== "file:") {
|
|
633
631
|
throw new TypeError("Must be a file URL.");
|
|
634
632
|
}
|
|
635
|
-
return invoke("plugin:fs|exists", {
|
|
633
|
+
return await invoke("plugin:fs|exists", {
|
|
636
634
|
path: path instanceof URL ? path.toString() : path,
|
|
637
635
|
options,
|
|
638
636
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tauri-apps/plugin-fs",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.3",
|
|
4
4
|
"description": "Access the file system.",
|
|
5
5
|
"license": "MIT or APACHE-2.0",
|
|
6
6
|
"authors": [
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"LICENSE"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@tauri-apps/api": "2.0.0-beta.
|
|
24
|
+
"@tauri-apps/api": "2.0.0-beta.11"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "rollup -c"
|