mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-06-06 13:53:54 +02:00
chore: update to tauri alpha.16, api alpha.9 (#673)
Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
This commit is contained in:
committed by
GitHub
parent
b7c5407cac
commit
5c137365c6
@@ -4,7 +4,7 @@ Access the file system.
|
||||
|
||||
## Install
|
||||
|
||||
_This plugin requires a Rust version of at least **1.65**_
|
||||
_This plugin requires a Rust version of at least **1.70**_
|
||||
|
||||
There are three general methods of installation that we can recommend.
|
||||
|
||||
|
||||
@@ -47,11 +47,7 @@
|
||||
|
||||
import { BaseDirectory } from "@tauri-apps/api/path";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__TAURI_INVOKE__: <T>(cmd: string, args?: unknown) => Promise<T>;
|
||||
}
|
||||
}
|
||||
import { invoke } from "@tauri-apps/api/primitives";
|
||||
|
||||
interface Permissions {
|
||||
/**
|
||||
@@ -231,7 +227,7 @@ async function readTextFile(
|
||||
filePath: string,
|
||||
options: FsOptions = {},
|
||||
): Promise<string> {
|
||||
return await window.__TAURI_INVOKE__("plugin:fs|read_text_file", {
|
||||
return await invoke("plugin:fs|read_text_file", {
|
||||
path: filePath,
|
||||
options,
|
||||
});
|
||||
@@ -252,7 +248,7 @@ async function readBinaryFile(
|
||||
filePath: string,
|
||||
options: FsOptions = {},
|
||||
): Promise<Uint8Array> {
|
||||
const arr = await window.__TAURI_INVOKE__<number[]>("plugin:fs|read_file", {
|
||||
const arr = await invoke<number[]>("plugin:fs|read_file", {
|
||||
path: filePath,
|
||||
options,
|
||||
});
|
||||
@@ -328,7 +324,7 @@ async function writeTextFile(
|
||||
fileOptions = contents;
|
||||
}
|
||||
|
||||
return await window.__TAURI_INVOKE__("plugin:fs|write_file", {
|
||||
return await invoke("plugin:fs|write_file", {
|
||||
path: file.path,
|
||||
contents: Array.from(new TextEncoder().encode(file.contents)),
|
||||
options: fileOptions,
|
||||
@@ -410,7 +406,7 @@ async function writeBinaryFile(
|
||||
file.contents = contents ?? [];
|
||||
}
|
||||
|
||||
return await window.__TAURI_INVOKE__("plugin:fs|write_file", {
|
||||
return await invoke("plugin:fs|write_file", {
|
||||
path: file.path,
|
||||
contents: Array.from(
|
||||
file.contents instanceof ArrayBuffer
|
||||
@@ -445,7 +441,7 @@ async function readDir(
|
||||
dir: string,
|
||||
options: FsDirOptions = {},
|
||||
): Promise<FileEntry[]> {
|
||||
return await window.__TAURI_INVOKE__("plugin:fs|read_dir", {
|
||||
return await invoke("plugin:fs|read_dir", {
|
||||
path: dir,
|
||||
options,
|
||||
});
|
||||
@@ -470,7 +466,7 @@ async function createDir(
|
||||
dir: string,
|
||||
options: FsDirOptions = {},
|
||||
): Promise<void> {
|
||||
return await window.__TAURI_INVOKE__("plugin:fs|create_dir", {
|
||||
return await invoke("plugin:fs|create_dir", {
|
||||
path: dir,
|
||||
options,
|
||||
});
|
||||
@@ -494,7 +490,7 @@ async function removeDir(
|
||||
dir: string,
|
||||
options: FsDirOptions = {},
|
||||
): Promise<void> {
|
||||
return await window.__TAURI_INVOKE__("plugin:fs|remove_dir", {
|
||||
return await invoke("plugin:fs|remove_dir", {
|
||||
path: dir,
|
||||
options,
|
||||
});
|
||||
@@ -518,7 +514,7 @@ async function copyFile(
|
||||
destination: string,
|
||||
options: FsOptions = {},
|
||||
): Promise<void> {
|
||||
return await window.__TAURI_INVOKE__("plugin:fs|copy_file", {
|
||||
return await invoke("plugin:fs|copy_file", {
|
||||
source,
|
||||
destination,
|
||||
options,
|
||||
@@ -542,7 +538,7 @@ async function removeFile(
|
||||
file: string,
|
||||
options: FsOptions = {},
|
||||
): Promise<void> {
|
||||
return await window.__TAURI_INVOKE__("plugin:fs|remove_file", {
|
||||
return await invoke("plugin:fs|remove_file", {
|
||||
path: file,
|
||||
options,
|
||||
});
|
||||
@@ -566,7 +562,7 @@ async function renameFile(
|
||||
newPath: string,
|
||||
options: FsOptions = {},
|
||||
): Promise<void> {
|
||||
return await window.__TAURI_INVOKE__("plugin:fs|rename_file", {
|
||||
return await invoke("plugin:fs|rename_file", {
|
||||
oldPath,
|
||||
newPath,
|
||||
options,
|
||||
@@ -585,7 +581,7 @@ async function renameFile(
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function exists(path: string): Promise<boolean> {
|
||||
return await window.__TAURI_INVOKE__("plugin:fs|exists", { path });
|
||||
return await invoke("plugin:fs|exists", { path });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -594,19 +590,17 @@ async function exists(path: string): Promise<boolean> {
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function metadata(path: string): Promise<Metadata> {
|
||||
return await window
|
||||
.__TAURI_INVOKE__<BackendMetadata>("plugin:fs|metadata", {
|
||||
path,
|
||||
})
|
||||
.then((metadata) => {
|
||||
const { accessedAtMs, createdAtMs, modifiedAtMs, ...data } = metadata;
|
||||
return {
|
||||
accessedAt: new Date(accessedAtMs),
|
||||
createdAt: new Date(createdAtMs),
|
||||
modifiedAt: new Date(modifiedAtMs),
|
||||
...data,
|
||||
};
|
||||
});
|
||||
return await invoke<BackendMetadata>("plugin:fs|metadata", {
|
||||
path,
|
||||
}).then((metadata) => {
|
||||
const { accessedAtMs, createdAtMs, modifiedAtMs, ...data } = metadata;
|
||||
return {
|
||||
accessedAt: new Date(accessedAtMs),
|
||||
createdAt: new Date(createdAtMs),
|
||||
modifiedAt: new Date(modifiedAtMs),
|
||||
...data,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export type {
|
||||
|
||||
@@ -28,6 +28,6 @@
|
||||
"tslib": "^2.4.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "2.0.0-alpha.8"
|
||||
"@tauri-apps/api": "2.0.0-alpha.9"
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user