-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from oscartbeaumont/custom-plugin-example
custom plugin example
- Loading branch information
Showing
79 changed files
with
1,700 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ pnpm-debug.log* | |
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Ignore everything in this directory | ||
* | ||
# Except this file | ||
!.gitignore | ||
# This is done so that Tauri never complains that '../dist does not exist' |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Ignore everything in this directory | ||
* | ||
# Except this file | ||
!.gitignore | ||
# This is done so that Tauri never complains that '../dist does not exist' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<link rel="icon" type="image/svg+xml" href="/src/assets/logo.svg" /> | ||
<title>Tauri + Solid + Typescript App</title> | ||
</head> | ||
|
||
<body> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root"></div> | ||
|
||
<script src="/src/index.tsx" type="module"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "tauri-specta-example-custom-plugin-app", | ||
"version": "0.0.0", | ||
"description": "", | ||
"scripts": { | ||
"start": "vite", | ||
"dev": "vite", | ||
"build": "vite build", | ||
"serve": "vite preview", | ||
"tauri": "tauri" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"solid-js": "^1.7.8", | ||
"@tauri-apps/api": "^1.4.0", | ||
"tauri-specta-custom-plugin": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.0.2", | ||
"vite": "^4.4.4", | ||
"vite-plugin-solid": "^2.7.0", | ||
"@tauri-apps/cli": "^1.4.0" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
/target/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[package] | ||
name = "tauri-specta-example-custom-plugin-app" | ||
version = "0.0.0" | ||
description = "A Tauri App" | ||
authors = ["you"] | ||
license = "" | ||
repository = "" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[build-dependencies] | ||
tauri-build = { version = "1.4", features = [] } | ||
|
||
[dependencies] | ||
tauri = { version = "1.4", features = ["shell-open"] } | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde_json = "1.0" | ||
tauri-specta-example-custom-plugin = { path = "../../plugin" } | ||
|
||
[features] | ||
# this feature is used for production builds or when `devPath` points to the filesystem | ||
# DO NOT REMOVE!! | ||
custom-protocol = ["tauri/custom-protocol"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
tauri_build::build() | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Prevents additional console window on Windows in release, DO NOT REMOVE!! | ||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] | ||
|
||
fn main() { | ||
tauri::Builder::default() | ||
.plugin(tauri_specta_example_custom_plugin::init()) | ||
.run(tauri::generate_context!()) | ||
.expect("error while running tauri application"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"build": { | ||
"beforeDevCommand": "pnpm dev", | ||
"beforeBuildCommand": "pnpm build", | ||
"devPath": "http://localhost:1420", | ||
"distDir": "../dist", | ||
"withGlobalTauri": false | ||
}, | ||
"package": { | ||
"productName": "app", | ||
"version": "0.0.0" | ||
}, | ||
"tauri": { | ||
"allowlist": { | ||
"all": false, | ||
"shell": { | ||
"all": false, | ||
"open": true | ||
} | ||
}, | ||
"bundle": { | ||
"active": true, | ||
"targets": "all", | ||
"identifier": "com.tauri.dev", | ||
"icon": [ | ||
"icons/32x32.png", | ||
"icons/128x128.png", | ||
"icons/[email protected]", | ||
"icons/icon.icns", | ||
"icons/icon.ico" | ||
] | ||
}, | ||
"security": { | ||
"csp": null | ||
}, | ||
"windows": [ | ||
{ | ||
"fullscreen": false, | ||
"resizable": true, | ||
"title": "app", | ||
"width": 800, | ||
"height": 600 | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Match, Switch, createSignal, onCleanup } from "solid-js"; | ||
import { events, addNumbers } from "tauri-specta-custom-plugin"; | ||
|
||
function App() { | ||
const [latestNumber, setLatestNumber] = createSignal<number | null>(null); | ||
|
||
const [generatedNumber, setGeneratedNumber] = createSignal< | ||
{ type: "loading" } | { type: "loaded"; value: number } | null | ||
>(null); | ||
|
||
events.randomNumber | ||
.listen((e) => setLatestNumber(e.payload)) | ||
.then((unlisten) => onCleanup(unlisten)); | ||
|
||
return ( | ||
<div> | ||
<p>Latest Random Number: {latestNumber()}</p> | ||
<button | ||
disabled={generatedNumber()?.type === "loading"} | ||
onClick={() => { | ||
setGeneratedNumber({ type: "loading" }); | ||
|
||
addNumbers( | ||
Math.floor(Math.random() * 10), | ||
Math.floor(Math.random() * 10) | ||
) | ||
.then((value) => setGeneratedNumber({ type: "loaded", value })) | ||
.catch(() => setGeneratedNumber(null)); | ||
}} | ||
> | ||
Generate Random Number | ||
</button> | ||
<Switch fallback="Generate a number!"> | ||
<Match when={generatedNumber()?.type === "loading"}> | ||
Loading number... | ||
</Match> | ||
<Match | ||
when={(() => { | ||
const n = generatedNumber(); | ||
return n?.type === "loaded" && n.value; | ||
})()} | ||
> | ||
{(value) => value()} | ||
</Match> | ||
</Switch> | ||
</div> | ||
); | ||
} | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* @refresh reload */ | ||
import { render } from "solid-js/web"; | ||
|
||
import App from "./App"; | ||
|
||
render(() => <App />, document.getElementById("root") as HTMLElement); |
Oops, something went wrong.