@tauri-apps/plugin-fs 2.0.0-beta.3 → 2.0.0-beta.5

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 CHANGED
@@ -76,9 +76,9 @@ function parseFileInfo(r) {
76
76
  isDirectory: r.isDirectory,
77
77
  isSymlink: r.isSymlink,
78
78
  size: r.size,
79
- mtime: r.mtime != null ? new Date(r.mtime) : null,
80
- atime: r.atime != null ? new Date(r.atime) : null,
81
- birthtime: r.birthtime != null ? new Date(r.birthtime) : null,
79
+ mtime: r.mtime !== null ? new Date(r.mtime) : null,
80
+ atime: r.atime !== null ? new Date(r.atime) : null,
81
+ birthtime: r.birthtime !== null ? new Date(r.birthtime) : null,
82
82
  readonly: r.readonly,
83
83
  fileAttributes: r.fileAttributes,
84
84
  dev: r.dev,
@@ -389,7 +389,9 @@ async function readFile(path, options) {
389
389
  path: path instanceof URL ? path.toString() : path,
390
390
  options,
391
391
  });
392
- return Uint8Array.from(arr);
392
+ return arr instanceof ArrayBuffer
393
+ ? new Uint8Array(arr)
394
+ : Uint8Array.from(arr);
393
395
  }
394
396
  /**
395
397
  * Reads and returns the entire contents of a file as UTF-8 string.
@@ -434,7 +436,7 @@ async function readTextFileLines(path, options) {
434
436
  path: pathStr,
435
437
  rid: null,
436
438
  async next() {
437
- if (this.rid == null) {
439
+ if (this.rid === null) {
438
440
  this.rid = await core.invoke("plugin:fs|read_text_file_lines", {
439
441
  path: pathStr,
440
442
  options,
@@ -590,10 +592,11 @@ async function writeFile(path, data, options) {
590
592
  if (path instanceof URL && path.protocol !== "file:") {
591
593
  throw new TypeError("Must be a file URL.");
592
594
  }
593
- await core.invoke("plugin:fs|write_file", {
594
- path: path instanceof URL ? path.toString() : path,
595
- data: Array.from(data),
596
- options,
595
+ await core.invoke("plugin:fs|write_file", data, {
596
+ headers: {
597
+ path: path instanceof URL ? path.toString() : path,
598
+ options: JSON.stringify(options),
599
+ },
597
600
  });
598
601
  }
599
602
  /**
package/dist-js/index.js CHANGED
@@ -74,9 +74,9 @@ function parseFileInfo(r) {
74
74
  isDirectory: r.isDirectory,
75
75
  isSymlink: r.isSymlink,
76
76
  size: r.size,
77
- mtime: r.mtime != null ? new Date(r.mtime) : null,
78
- atime: r.atime != null ? new Date(r.atime) : null,
79
- birthtime: r.birthtime != null ? new Date(r.birthtime) : null,
77
+ mtime: r.mtime !== null ? new Date(r.mtime) : null,
78
+ atime: r.atime !== null ? new Date(r.atime) : null,
79
+ birthtime: r.birthtime !== null ? new Date(r.birthtime) : null,
80
80
  readonly: r.readonly,
81
81
  fileAttributes: r.fileAttributes,
82
82
  dev: r.dev,
@@ -387,7 +387,9 @@ async function readFile(path, options) {
387
387
  path: path instanceof URL ? path.toString() : path,
388
388
  options,
389
389
  });
390
- return Uint8Array.from(arr);
390
+ return arr instanceof ArrayBuffer
391
+ ? new Uint8Array(arr)
392
+ : Uint8Array.from(arr);
391
393
  }
392
394
  /**
393
395
  * Reads and returns the entire contents of a file as UTF-8 string.
@@ -432,7 +434,7 @@ async function readTextFileLines(path, options) {
432
434
  path: pathStr,
433
435
  rid: null,
434
436
  async next() {
435
- if (this.rid == null) {
437
+ if (this.rid === null) {
436
438
  this.rid = await invoke("plugin:fs|read_text_file_lines", {
437
439
  path: pathStr,
438
440
  options,
@@ -588,10 +590,11 @@ async function writeFile(path, data, options) {
588
590
  if (path instanceof URL && path.protocol !== "file:") {
589
591
  throw new TypeError("Must be a file URL.");
590
592
  }
591
- await invoke("plugin:fs|write_file", {
592
- path: path instanceof URL ? path.toString() : path,
593
- data: Array.from(data),
594
- options,
593
+ await invoke("plugin:fs|write_file", data, {
594
+ headers: {
595
+ path: path instanceof URL ? path.toString() : path,
596
+ options: JSON.stringify(options),
597
+ },
595
598
  });
596
599
  }
597
600
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tauri-apps/plugin-fs",
3
- "version": "2.0.0-beta.3",
3
+ "version": "2.0.0-beta.5",
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.11"
24
+ "@tauri-apps/api": "2.0.0-beta.13"
25
25
  },
26
26
  "scripts": {
27
27
  "build": "rollup -c"