Skip to content

Commit ba03897

Browse files
committed
scaffold folder plugin (#2732)
1 parent eff1aa0 commit ba03897

File tree

22 files changed

+661
-3
lines changed

22 files changed

+661
-3
lines changed

Cargo.lock

Lines changed: 15 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
@@ -139,6 +139,7 @@ tauri-plugin-deeplink2 = { path = "plugins/deeplink2" }
139139
tauri-plugin-detect = { path = "plugins/detect" }
140140
tauri-plugin-export = { path = "plugins/export" }
141141
tauri-plugin-extensions = { path = "plugins/extensions" }
142+
tauri-plugin-folder = { path = "plugins/folder" }
142143
tauri-plugin-hooks = { path = "plugins/hooks" }
143144
tauri-plugin-icon = { path = "plugins/icon" }
144145
tauri-plugin-importer = { path = "plugins/importer" }

apps/desktop/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@hypr/plugin-deeplink2": "workspace:*",
3838
"@hypr/plugin-detect": "workspace:*",
3939
"@hypr/plugin-export": "workspace:*",
40+
"@hypr/plugin-folder": "workspace:*",
4041
"@hypr/plugin-extensions": "workspace:*",
4142
"@hypr/plugin-hooks": "workspace:*",
4243
"@hypr/plugin-icon": "workspace:*",

apps/desktop/src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ tauri-plugin-detect = { workspace = true }
3636
tauri-plugin-dialog = { workspace = true }
3737
tauri-plugin-export = { workspace = true }
3838
tauri-plugin-extensions = { workspace = true }
39+
tauri-plugin-folder = { workspace = true }
3940
tauri-plugin-fs = { workspace = true }
4041
tauri-plugin-hooks = { workspace = true }
4142
tauri-plugin-http = { workspace = true }

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@
194194
"os:default",
195195
"detect:default",
196196
"export:default",
197+
"folder:default",
197198
"permissions:default",
198199
"settings:default",
199200
"sfx:default",

apps/desktop/src-tauri/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ pub async fn main() {
9595
.plugin(tauri_plugin_deep_link::init())
9696
.plugin(tauri_plugin_deeplink2::init())
9797
.plugin(tauri_plugin_export::init())
98+
.plugin(tauri_plugin_folder::init())
9899
.plugin(tauri_plugin_os::init())
99100
.plugin(tauri_plugin_fs::init())
100101
.plugin(tauri_plugin_path2::init())

plugins/folder/.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/folder/Cargo.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[package]
2+
name = "tauri-plugin-folder"
3+
version = "0.1.0"
4+
authors = ["You"]
5+
edition = "2024"
6+
exclude = ["/js", "/node_modules"]
7+
links = "tauri-plugin-folder"
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 = { workspace = true, features = ["test"] }
19+
tauri-specta = { workspace = true, features = ["derive", "typescript"] }
20+
21+
serde = { workspace = true }
22+
specta = { workspace = true }
23+
24+
thiserror = { workspace = true }

plugins/folder/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/folder/js/bindings.gen.ts

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

0 commit comments

Comments
 (0)