Skip to content

Commit 3c7d257

Browse files
Add tantivy plugin following add-plugin.md guide (#2766)
* Add tantivy plugin following add-plugin.md guide Co-Authored-By: yujonglee <yujonglee.dev@gmail.com> * Fix pnpm-lock.yaml sync for tantivy plugin Co-Authored-By: yujonglee <yujonglee.dev@gmail.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: yujonglee <yujonglee.dev@gmail.com>
1 parent b72a937 commit 3c7d257

File tree

21 files changed

+921
-2
lines changed

21 files changed

+921
-2
lines changed

Cargo.lock

Lines changed: 273 additions & 2 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
@@ -161,6 +161,7 @@ tauri-plugin-settings = { path = "plugins/settings" }
161161
tauri-plugin-sfx = { path = "plugins/sfx" }
162162
tauri-plugin-sidecar2 = { path = "plugins/sidecar2" }
163163
tauri-plugin-store2 = { path = "plugins/store2" }
164+
tauri-plugin-tantivy = { path = "plugins/tantivy" }
164165
tauri-plugin-template = { path = "plugins/template" }
165166
tauri-plugin-tracing = { path = "plugins/tracing" }
166167
tauri-plugin-tray = { path = "plugins/tray" }

apps/desktop/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"@hypr/plugin-overlay": "workspace:*",
5353
"@hypr/plugin-pagefind": "workspace:*",
5454
"@hypr/plugin-path2": "workspace:*",
55+
"@hypr/plugin-tantivy": "workspace:*",
5556
"@hypr/plugin-pdf": "workspace:*",
5657
"@hypr/plugin-permissions": "workspace:*",
5758
"@hypr/plugin-settings": "workspace:*",

apps/desktop/src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ tauri-plugin-sidecar2 = { workspace = true }
6767
tauri-plugin-single-instance = { workspace = true }
6868
tauri-plugin-store = { workspace = true }
6969
tauri-plugin-store2 = { workspace = true }
70+
tauri-plugin-tantivy = { workspace = true }
7071
tauri-plugin-template = { workspace = true }
7172
tauri-plugin-tracing = { workspace = true }
7273
tauri-plugin-tray = { workspace = true }

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@
239239
"overlay:default",
240240
"notify:default",
241241
"pagefind:default",
242+
"tantivy:default",
242243
"shell:allow-open",
243244
{
244245
"identifier": "shell:allow-execute",

plugins/tantivy/.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/tantivy/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-tantivy"
3+
version = "0.1.0"
4+
authors = ["You"]
5+
edition = "2024"
6+
exclude = ["/js", "/node_modules"]
7+
links = "tauri-plugin-tantivy"
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+
tantivy = "0.22"
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/tantivy/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/tantivy/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<null, string>> {
19+
try {
20+
return { status: "ok", data: await TAURI_INVOKE("plugin:tantivy|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/tantivy/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)