@wailsnet/plugin-file-system 0.0.0-stage → 0.1.0-alpha.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Wails.Net Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,66 @@
1
+ /**
2
+ * 文件元数据,对应后端 Wails.Net.Plugins.FileSystem.FileStat。
3
+ * 注:与 @wailsnet/runtime 中 FileStat 字段名不同,此处定义本地类型。
4
+ */
5
+ export interface FileStat {
6
+ /** 完整路径。 */
7
+ path: string;
8
+ /** 文件大小(字节)。 */
9
+ size: number;
10
+ /** 是否为目录。 */
11
+ isDirectory: boolean;
12
+ /** 最后修改时间(ISO-8601 UTC 字符串)。 */
13
+ lastModified: string;
14
+ /** 创建时间(ISO-8601 UTC 字符串)。 */
15
+ created: string;
16
+ /** 是否只读。 */
17
+ isReadOnly: boolean;
18
+ }
19
+ /**
20
+ * file-system 插件前端 API(命令前缀 `fs.*`)。
21
+ * 对应后端 Wails.Net.Plugins.FileSystem.FileSystemPlugin 注册的命令。
22
+ * 提供文件读写、目录操作、文件元数据查询等能力,内置路径穿越防护与沙箱限制。
23
+ *
24
+ * 注意:后端同时注册了短名(如 fs.read)和前端 API 名(如 fs.readTextFile),
25
+ * 此处同时暴露两者供调用方按需选择。
26
+ */
27
+ export declare const fileSystem: {
28
+ /** 读取文本文件全部内容。 */
29
+ read: (path: string) => import("@wailsnet/runtime").CancellablePromise<string>;
30
+ /** 写入文本文件(覆盖模式)。 */
31
+ write: (path: string, content: string) => import("@wailsnet/runtime").CancellablePromise<void>;
32
+ /** 检查文件是否存在。 */
33
+ exists: (path: string) => import("@wailsnet/runtime").CancellablePromise<boolean>;
34
+ /** 读取二进制文件,返回 Base64 字符串。 */
35
+ readBinary: (path: string) => import("@wailsnet/runtime").CancellablePromise<string>;
36
+ /** 写入二进制文件(data 为 Base64 字符串,对应后端 byte[])。 */
37
+ writeBinary: (path: string, data: string) => import("@wailsnet/runtime").CancellablePromise<void>;
38
+ /** 读取文本文件全部内容(对应 fs.readTextFile)。 */
39
+ readTextFile: (path: string) => import("@wailsnet/runtime").CancellablePromise<string>;
40
+ /** 写入文本文件(覆盖模式,对应 fs.writeTextFile)。 */
41
+ writeTextFile: (path: string, content: string) => import("@wailsnet/runtime").CancellablePromise<void>;
42
+ /** 读取二进制文件,返回 Base64 字符串(对应 fs.readBinaryFile)。 */
43
+ readBinaryFile: (path: string) => import("@wailsnet/runtime").CancellablePromise<string>;
44
+ /** 写入二进制文件(data 为 Base64 字符串,对应 fs.writeBinaryFile)。 */
45
+ writeBinaryFile: (path: string, data: string) => import("@wailsnet/runtime").CancellablePromise<void>;
46
+ /** 删除文件(对应 fs.delete)。 */
47
+ delete: (path: string) => import("@wailsnet/runtime").CancellablePromise<void>;
48
+ /** 删除文件(对应 fs.remove)。 */
49
+ remove: (path: string) => import("@wailsnet/runtime").CancellablePromise<void>;
50
+ /** 复制文件(覆盖目标)。 */
51
+ copy: (src: string, dest: string) => import("@wailsnet/runtime").CancellablePromise<void>;
52
+ /** 重命名或移动文件。 */
53
+ rename: (src: string, dest: string) => import("@wailsnet/runtime").CancellablePromise<void>;
54
+ /** 获取文件或目录元数据。 */
55
+ stat: (path: string) => import("@wailsnet/runtime").CancellablePromise<FileStat>;
56
+ /** 创建目录(含父目录)。 */
57
+ mkdir: (path: string) => import("@wailsnet/runtime").CancellablePromise<void>;
58
+ /** 删除目录。recursive 为 true 时递归删除子目录和文件。 */
59
+ rmdir: (path: string, recursive: boolean) => import("@wailsnet/runtime").CancellablePromise<void>;
60
+ /** 检查目录是否存在。 */
61
+ existsDir: (path: string) => import("@wailsnet/runtime").CancellablePromise<boolean>;
62
+ /** 列出目录下的所有文件系统条目(文件/目录名数组)。 */
63
+ readDir: (path: string) => import("@wailsnet/runtime").CancellablePromise<string[]>;
64
+ /** 递归列出目录下的所有文件系统条目。 */
65
+ readDirRecursive: (path: string) => import("@wailsnet/runtime").CancellablePromise<string[]>;
66
+ };
package/dist/index.js ADDED
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @wailsnet/plugin-file-system — file-system 插件前端封装。
3
+ * 命令前缀 `fs.*`(M3 runtime 变薄:从 @wailsnet/runtime 迁移至此,按需安装)。
4
+ * @platform windows,linux,macos,android 全平台通用插件。
5
+ */
6
+ import { call } from "@wailsnet/runtime";
7
+ /**
8
+ * file-system 插件前端 API(命令前缀 `fs.*`)。
9
+ * 对应后端 Wails.Net.Plugins.FileSystem.FileSystemPlugin 注册的命令。
10
+ * 提供文件读写、目录操作、文件元数据查询等能力,内置路径穿越防护与沙箱限制。
11
+ *
12
+ * 注意:后端同时注册了短名(如 fs.read)和前端 API 名(如 fs.readTextFile),
13
+ * 此处同时暴露两者供调用方按需选择。
14
+ */
15
+ export const fileSystem = {
16
+ // ===== 短名命令(向后兼容) =====
17
+ /** 读取文本文件全部内容。 */
18
+ read: (path) => call("fs.read", [path]),
19
+ /** 写入文本文件(覆盖模式)。 */
20
+ write: (path, content) => call("fs.write", [path, content]),
21
+ /** 检查文件是否存在。 */
22
+ exists: (path) => call("fs.exists", [path]),
23
+ /** 读取二进制文件,返回 Base64 字符串。 */
24
+ readBinary: (path) => call("fs.readBinary", [path]),
25
+ /** 写入二进制文件(data 为 Base64 字符串,对应后端 byte[])。 */
26
+ writeBinary: (path, data) => call("fs.writeBinary", [path, data]),
27
+ // ===== 前端 API 名命令(与 @wailsnet/runtime/src/api/fs.ts 一致) =====
28
+ /** 读取文本文件全部内容(对应 fs.readTextFile)。 */
29
+ readTextFile: (path) => call("fs.readTextFile", [path]),
30
+ /** 写入文本文件(覆盖模式,对应 fs.writeTextFile)。 */
31
+ writeTextFile: (path, content) => call("fs.writeTextFile", [path, content]),
32
+ /** 读取二进制文件,返回 Base64 字符串(对应 fs.readBinaryFile)。 */
33
+ readBinaryFile: (path) => call("fs.readBinaryFile", [path]),
34
+ /** 写入二进制文件(data 为 Base64 字符串,对应 fs.writeBinaryFile)。 */
35
+ writeBinaryFile: (path, data) => call("fs.writeBinaryFile", [path, data]),
36
+ /** 删除文件(对应 fs.delete)。 */
37
+ delete: (path) => call("fs.delete", [path]),
38
+ /** 删除文件(对应 fs.remove)。 */
39
+ remove: (path) => call("fs.remove", [path]),
40
+ // ===== 其他文件操作 =====
41
+ /** 复制文件(覆盖目标)。 */
42
+ copy: (src, dest) => call("fs.copy", [src, dest]),
43
+ /** 重命名或移动文件。 */
44
+ rename: (src, dest) => call("fs.rename", [src, dest]),
45
+ /** 获取文件或目录元数据。 */
46
+ stat: (path) => call("fs.stat", [path]),
47
+ // ===== 目录操作 =====
48
+ /** 创建目录(含父目录)。 */
49
+ mkdir: (path) => call("fs.mkdir", [path]),
50
+ /** 删除目录。recursive 为 true 时递归删除子目录和文件。 */
51
+ rmdir: (path, recursive) => call("fs.rmdir", [path, recursive]),
52
+ /** 检查目录是否存在。 */
53
+ existsDir: (path) => call("fs.existsDir", [path]),
54
+ /** 列出目录下的所有文件系统条目(文件/目录名数组)。 */
55
+ readDir: (path) => call("fs.readDir", [path]),
56
+ /** 递归列出目录下的所有文件系统条目。 */
57
+ readDirRecursive: (path) => call("fs.readDirRecursive", [path]),
58
+ };
package/package.json CHANGED
@@ -1,6 +1,31 @@
1
1
  {
2
2
  "name": "@wailsnet/plugin-file-system",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0-alpha.1",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ },
12
+ "./package.json": "./package.json"
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "dependencies": {
18
+ "@wailsnet/runtime": "0.1.0-alpha.1"
19
+ },
20
+ "devDependencies": {
21
+ "typescript": "^5.9.3"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public",
25
+ "registry": "https://registry.npmjs.org"
26
+ },
27
+ "scripts": {
28
+ "build": "tsc -p tsconfig.json",
29
+ "typecheck": "tsc --noEmit"
30
+ }
6
31
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.