Skip to content

Commit f3c2639

Browse files
feat: add fs2 plugin wrapping tauri-plugin-fs
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
1 parent b6051ce commit f3c2639

File tree

21 files changed

+665
-0
lines changed

21 files changed

+665
-0
lines changed

Cargo.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ tauri-plugin-deeplink2 = { path = "plugins/deeplink2" }
143143
tauri-plugin-detect = { path = "plugins/detect" }
144144
tauri-plugin-extensions = { path = "plugins/extensions" }
145145
tauri-plugin-fs-sync = { path = "plugins/fs-sync" }
146+
tauri-plugin-fs2 = { path = "plugins/fs2" }
146147
tauri-plugin-hooks = { path = "plugins/hooks" }
147148
tauri-plugin-icon = { path = "plugins/icon" }
148149
tauri-plugin-importer = { path = "plugins/importer" }

apps/desktop/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"@hypr/plugin-detect": "workspace:*",
4747
"@hypr/plugin-extensions": "workspace:*",
4848
"@hypr/plugin-fs-sync": "workspace:*",
49+
"@hypr/plugin-fs2": "workspace:*",
4950
"@hypr/plugin-hooks": "workspace:*",
5051
"@hypr/plugin-icon": "workspace:*",
5152
"@hypr/plugin-importer": "workspace:*",

apps/desktop/src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ tauri-plugin-dialog = { workspace = true }
3838
tauri-plugin-extensions = { workspace = true }
3939
tauri-plugin-fs = { workspace = true }
4040
tauri-plugin-fs-sync = { workspace = true }
41+
tauri-plugin-fs2 = { workspace = true }
4142
tauri-plugin-hooks = { workspace = true }
4243
tauri-plugin-http = { workspace = true }
4344
tauri-plugin-icon = { workspace = true }

apps/desktop/src-tauri/capabilities/default.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@
258258
},
259259
"misc:default",
260260
"fs-sync:default",
261+
"fs2:default",
261262
"os:default",
262263
"detect:default",
263264
"permissions:default",

plugins/fs2/.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/.vs
2+
.DS_Store
3+
.Thumbs.db
4+
*.sublime*
5+
.idea/
6+
debug.log
7+
package-lock.json
8+
.vscode/settings.json
9+
yarn.lock
10+
11+
/.tauri
12+
/target
13+
Cargo.lock
14+
node_modules/
15+
16+
dist-js
17+
dist

plugins/fs2/Cargo.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[package]
2+
name = "tauri-plugin-fs2"
3+
version = "0.1.0"
4+
authors = ["You"]
5+
edition = "2024"
6+
exclude = ["/js", "/node_modules"]
7+
links = "tauri-plugin-fs2"
8+
description = ""
9+
10+
[build-dependencies]
11+
tauri-plugin = { workspace = true, features = ["build"] }
12+
13+
[dev-dependencies]
14+
specta-typescript = { workspace = true }
15+
tokio = { workspace = true, features = ["macros"] }
16+
17+
[dependencies]
18+
tauri-plugin-fs = { workspace = true }
19+
20+
tauri = { workspace = true, features = ["test"] }
21+
tauri-specta = { workspace = true, features = ["derive", "typescript"] }
22+
23+
serde = { workspace = true }
24+
specta = { workspace = true }
25+
26+
thiserror = { workspace = true }

plugins/fs2/build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const COMMANDS: &[&str] = &["ping"];
2+
3+
fn main() {
4+
tauri_plugin::Builder::new(COMMANDS).build();
5+
}

plugins/fs2/js/bindings.gen.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// @ts-nocheck
2+
/** user-defined events **/
3+
/** user-defined constants **/
4+
/** user-defined types **/
5+
/** tauri-specta globals **/
6+
import {
7+
Channel as TAURI_CHANNEL,
8+
invoke as TAURI_INVOKE,
9+
} from "@tauri-apps/api/core";
10+
import * as TAURI_API_EVENT from "@tauri-apps/api/event";
11+
import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow";
12+
13+
// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually.
14+
15+
/** user-defined commands **/
16+
17+
export const commands = {
18+
async ping(): Promise<Result<string, string>> {
19+
try {
20+
return { status: "ok", data: await TAURI_INVOKE("plugin:fs2|ping") };
21+
} catch (e) {
22+
if (e instanceof Error) throw e;
23+
else return { status: "error", error: e as any };
24+
}
25+
},
26+
};
27+
28+
type __EventObj__<T> = {
29+
listen: (
30+
cb: TAURI_API_EVENT.EventCallback<T>,
31+
) => ReturnType<typeof TAURI_API_EVENT.listen<T>>;
32+
once: (
33+
cb: TAURI_API_EVENT.EventCallback<T>,
34+
) => ReturnType<typeof TAURI_API_EVENT.once<T>>;
35+
emit: null extends T
36+
? (payload?: T) => ReturnType<typeof TAURI_API_EVENT.emit>
37+
: (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>;
38+
};
39+
40+
export type Result<T, E> =
41+
| { status: "ok"; data: T }
42+
| { status: "error"; error: E };
43+
44+
function __makeEvents__<T extends Record<string, any>>(
45+
mappings: Record<keyof T, string>,
46+
) {
47+
return new Proxy(
48+
{} as unknown as {
49+
[K in keyof T]: __EventObj__<T[K]> & {
50+
(handle: __WebviewWindow__): __EventObj__<T[K]>;
51+
};
52+
},
53+
{
54+
get: (_, event) => {
55+
const name = mappings[event as keyof T];
56+
57+
return new Proxy((() => {}) as any, {
58+
apply: (_, __, [window]: [__WebviewWindow__]) => ({
59+
listen: (arg: any) => window.listen(name, arg),
60+
once: (arg: any) => window.once(name, arg),
61+
emit: (arg: any) => window.emit(name, arg),
62+
}),
63+
get: (_, command: keyof __EventObj__<any>) => {
64+
switch (command) {
65+
case "listen":
66+
return (arg: any) => TAURI_API_EVENT.listen(name, arg);
67+
case "once":
68+
return (arg: any) => TAURI_API_EVENT.once(name, arg);
69+
case "emit":
70+
return (arg: any) => TAURI_API_EVENT.emit(name, arg);
71+
}
72+
},
73+
});
74+
},
75+
},
76+
);
77+
}

plugins/fs2/js/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./bindings.gen";

0 commit comments

Comments
 (0)