Merge release v0.0.2 (#60)
* update v0.0.1 * update v0.0.1 * add rust cache * rename step * fix test workflow * change to build * add password * move app.jpeg * bump & update name * remove logo * untrack .vscode * remove icon from readme * use npx * rename file and do dom element check * formating * added rust files * generated bindings * rename to ipc * add more examples * move file * new img * refactor * add clippy and tests * imrpove clippy * add semi * enable release profile * refactor * first changeset * version changeset * version app * move version in front of tagname * do not error on local * run after build * use another workflow for clippy
This commit is contained in:

committed by
GitHub

parent
fa8b6cd215
commit
12365282a3
8
.changeset/README.md
Normal file
8
.changeset/README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# Changesets
|
||||
|
||||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
|
||||
with multi-package repos, or single-package repos to help you version and publish your code. You can
|
||||
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
|
||||
|
||||
We have a quick list of common questions to get you started engaging with this project in
|
||||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
|
11
.changeset/config.json
Normal file
11
.changeset/config.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
|
||||
"changelog": "@changesets/cli/changelog",
|
||||
"commit": false,
|
||||
"fixed": [],
|
||||
"linked": [],
|
||||
"access": "restricted",
|
||||
"baseBranch": "dev",
|
||||
"updateInternalDependencies": "patch",
|
||||
"ignore": []
|
||||
}
|
BIN
.github/app.jpeg
vendored
Normal file
BIN
.github/app.jpeg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 102 KiB |
34
.github/workflows/clippy.yml
vendored
Normal file
34
.github/workflows/clippy.yml
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
name: Build and publish
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
publish-tauri:
|
||||
runs-on: 'ubuntu-20.04'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: rui314/setup-mold@v1
|
||||
with:
|
||||
make-default: false
|
||||
|
||||
- name: Install Rust stable
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: install dependencies (ubuntu only)
|
||||
if: matrix.platform == 'ubuntu-20.04'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf
|
||||
|
||||
- name: Clippy & Tests
|
||||
run: |
|
||||
cd src-tauri
|
||||
cargo clippy --all --tests -- -W clippy::nursery -W clippy::pedantic -A clippy::module-name-repetitions -D clippy::unwrap_used
|
||||
cargo test --all
|
2
.github/workflows/publish.yml
vendored
2
.github/workflows/publish.yml
vendored
@@ -74,7 +74,7 @@ jobs:
|
||||
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||
# TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||
with:
|
||||
tagName: __VERSION__v
|
||||
tagName: v__VERSION__
|
||||
releaseName: 'Svelte-Tauri v__VERSION__'
|
||||
releaseBody: 'See the assets to download this version and install.'
|
||||
releaseDraft: false
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@@ -8,4 +8,5 @@ target
|
||||
.eslintcache
|
||||
|
||||
# Nodejs
|
||||
node_modules
|
||||
node_modules
|
||||
.vscode
|
@@ -1,5 +1,8 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
# If not using pnpm, switch to your package manager
|
||||
pnpm exec lint-staged
|
||||
npx lint-staged
|
||||
|
||||
cd src-tauri
|
||||
cargo clippy -- -W clippy::nursery -W clippy::pedantic -A clippy::module-name-repetitions -W clippy::unwrap_used
|
||||
|
7
CHANGELOG.md
Normal file
7
CHANGELOG.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# svelte-tauri
|
||||
|
||||
## 0.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 41ffe7b: First changeset
|
@@ -1,11 +1,9 @@
|
||||
# Svelte/Tauri Template <img src="https://raw.githubusercontent.com/Fractal-Tess/Svelte-Tauri/dev/static/st-1024.png" width="30" align="center" />
|
||||
# Svelte/Tauri Template
|
||||
|
||||
<div align="center">
|
||||
<img src="https://raw.githubusercontent.com/Fractal-Tess/Svelte-Tauri/dev/static/app.jpeg" width="580" style="border-radius:2rem"/>
|
||||
<img src="https://raw.githubusercontent.com/Fractal-Tess/Svelte-Tauri/dev/.github/app.jpeg" width="580" style="border-radius:2rem"/>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
## Overview
|
||||
- Typescript
|
||||
- UI:
|
||||
|
20
package.json
20
package.json
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"name": "svelte-tauri",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.2",
|
||||
"private": true,
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/Fractal-Tess/Svelte-Tauri"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "Vilian Gerdzhikov",
|
||||
"name": "Fractal-Tess",
|
||||
"email": "vgfractal@gmail.com",
|
||||
"url": "https://gist.github.com/Fractal-Tess"
|
||||
},
|
||||
@@ -21,13 +21,15 @@
|
||||
"lint": "eslint .",
|
||||
"check": "svelte-check --tsconfig ./tsconfig.json",
|
||||
"svelte:build": "vite build",
|
||||
"svelte:dev": "vite dev"
|
||||
"svelte:dev": "vite dev",
|
||||
"changeset": "changeset"
|
||||
},
|
||||
"lint-staged": {
|
||||
"src/**/*.{js,ts,svelte}": "eslint --cache --fix",
|
||||
"src/**/*.{js,ts,svelte,css,scss,postcss,md,json}": "prettier --write --ignore-unknown"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@changesets/cli": "^2.26.1",
|
||||
"@fontsource/roboto": "^4.5.8",
|
||||
"@fortawesome/fontawesome-svg-core": "^6.4.0",
|
||||
"@fortawesome/free-brands-svg-icons": "^6.4.0",
|
||||
@@ -38,8 +40,8 @@
|
||||
"@tauri-apps/cli": "^1.3.1",
|
||||
"@tsconfig/svelte": "^4.0.1",
|
||||
"@types/node": "18.15.3",
|
||||
"@typescript-eslint/eslint-plugin": "^5.59.5",
|
||||
"@typescript-eslint/parser": "^5.59.5",
|
||||
"@typescript-eslint/eslint-plugin": "^5.59.6",
|
||||
"@typescript-eslint/parser": "^5.59.6",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"daisyui": "^2.51.6",
|
||||
"eslint": "^8.40.0",
|
||||
@@ -53,7 +55,7 @@
|
||||
"postcss-load-config": "^4.0.1",
|
||||
"prettier": "^2.8.8",
|
||||
"prettier-plugin-svelte": "^2.10.0",
|
||||
"prettier-plugin-tailwindcss": "^0.2.8",
|
||||
"prettier-plugin-tailwindcss": "^0.3.0",
|
||||
"svelte": "^3.59.1",
|
||||
"svelte-check": "^3.3.2",
|
||||
"svelte-fa": "^3.0.3",
|
||||
@@ -61,9 +63,9 @@
|
||||
"svelte-spa-router": "^3.3.0",
|
||||
"tailwindcss": "^3.3.2",
|
||||
"tailwindcss-hero-patterns": "^0.1.2",
|
||||
"tslib": "^2.5.0",
|
||||
"tslib": "^2.5.1",
|
||||
"typescript": "^5.0.4",
|
||||
"vite": "^4.3.5"
|
||||
"vite": "^4.3.7"
|
||||
},
|
||||
"packageManager": "pnpm@8.5.0",
|
||||
"engineStrict": true,
|
||||
|
1443
pnpm-lock.yaml
generated
1443
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
224
src-tauri/Cargo.lock
generated
224
src-tauri/Cargo.lock
generated
@@ -2,6 +2,12 @@
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "Inflector"
|
||||
version = "0.11.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3"
|
||||
|
||||
[[package]]
|
||||
name = "adler"
|
||||
version = "1.0.2"
|
||||
@@ -158,7 +164,7 @@ checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.15",
|
||||
"syn 2.0.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -175,7 +181,7 @@ checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.15",
|
||||
"syn 2.0.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -259,9 +265,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.2.1"
|
||||
version = "2.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24a6904aef64d73cf10ab17ebace7befb918b82164785cb89907993be7f83813"
|
||||
checksum = "6776fc96284a0bb647b615056fc496d1fe1644a7ab01829818a6d91cae888b84"
|
||||
|
||||
[[package]]
|
||||
name = "block"
|
||||
@@ -657,7 +663,7 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"syn 2.0.15",
|
||||
"syn 2.0.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -668,7 +674,7 @@ checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"quote",
|
||||
"syn 2.0.15",
|
||||
"syn 2.0.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -732,6 +738,15 @@ version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b"
|
||||
|
||||
[[package]]
|
||||
name = "document-features"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e493c573fce17f00dcab13b6ac057994f3ce17d1af4dc39bfd482b83c6eb6157"
|
||||
dependencies = [
|
||||
"litrs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dtoa"
|
||||
version = "0.4.8"
|
||||
@@ -753,6 +768,12 @@ version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
|
||||
|
||||
[[package]]
|
||||
name = "embed-resource"
|
||||
version = "2.1.1"
|
||||
@@ -799,7 +820,7 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.15",
|
||||
"syn 2.0.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -974,7 +995,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.15",
|
||||
"syn 2.0.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1470,6 +1491,18 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indoc"
|
||||
version = "1.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306"
|
||||
|
||||
[[package]]
|
||||
name = "indoc"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f2cb48b81b1dc9f39676bf99f5499babfec7cd8fe14307f7b3d747208fb5690"
|
||||
|
||||
[[package]]
|
||||
name = "infer"
|
||||
version = "0.12.0"
|
||||
@@ -1499,6 +1532,15 @@ dependencies = [
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.10.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "0.4.8"
|
||||
@@ -1556,9 +1598,9 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.62"
|
||||
version = "0.3.63"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68c16e1bfd491478ab155fd8b4896b86f9ede344949b641e61501e07c2b8b4d5"
|
||||
checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
@@ -1614,6 +1656,12 @@ version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f"
|
||||
|
||||
[[package]]
|
||||
name = "litrs"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9275e0933cf8bb20f008924c0cb07a0692fe54d8064996520bf998de9eb79aa"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.9"
|
||||
@@ -1987,7 +2035,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.15",
|
||||
"syn 2.0.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2099,6 +2147,12 @@ dependencies = [
|
||||
"windows-sys 0.45.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79"
|
||||
|
||||
[[package]]
|
||||
name = "pathdiff"
|
||||
version = "0.2.1"
|
||||
@@ -2324,9 +2378,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.56"
|
||||
version = "1.0.58"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435"
|
||||
checksum = "fa1fb82fc0c281dd9671101b66b771ebbe1eaf967b96ac8740dcba4b70005ca8"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
@@ -2606,9 +2660,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||
|
||||
[[package]]
|
||||
name = "security-framework"
|
||||
version = "2.8.2"
|
||||
version = "2.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254"
|
||||
checksum = "ca2855b3715770894e67cbfa3df957790aa0c9edc3bf06efa1a84d77fa0839d1"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"core-foundation",
|
||||
@@ -2619,9 +2673,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "security-framework-sys"
|
||||
version = "2.8.0"
|
||||
version = "2.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4"
|
||||
checksum = "f51d0c0d83bec45f16480d0ce0058397a69e48fcdc52d1dc8855fb68acbd31a7"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
@@ -2673,7 +2727,7 @@ checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.15",
|
||||
"syn 2.0.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2695,7 +2749,7 @@ checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.15",
|
||||
"syn 2.0.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2744,7 +2798,7 @@ dependencies = [
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.15",
|
||||
"syn 2.0.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2904,6 +2958,37 @@ dependencies = [
|
||||
"system-deps 5.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "specta"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7230ab99f7b726fa49e350886816dbe5b5b151a5f4158470f92850246d5cae5e"
|
||||
dependencies = [
|
||||
"document-features",
|
||||
"indoc 1.0.9",
|
||||
"once_cell",
|
||||
"paste",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"specta-macros",
|
||||
"tauri",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "specta-macros"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6252ed50d005e1dc2b77ed140f1c230299e0566492470eba40ba34e18cbcfa10"
|
||||
dependencies = [
|
||||
"Inflector",
|
||||
"itertools",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stable_deref_trait"
|
||||
version = "1.2.0"
|
||||
@@ -2980,14 +3065,17 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "svelte-tauri"
|
||||
version = "0.0.1"
|
||||
version = "0.0.2"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"specta",
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
"tauri-plugin-window-state",
|
||||
"tauri-specta",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3003,9 +3091,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.15"
|
||||
version = "2.0.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822"
|
||||
checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -3234,7 +3322,7 @@ version = "0.1.0"
|
||||
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=dev#dce0f02bc571128308c30278cde3233f341e6a50"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"bitflags 2.2.1",
|
||||
"bitflags 2.3.1",
|
||||
"log",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -3283,6 +3371,21 @@ dependencies = [
|
||||
"wry",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-specta"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23419889204476d5a70a04077d4628061a5bb667b18804a4572df2fe6ccb8ba5"
|
||||
dependencies = [
|
||||
"heck 0.4.1",
|
||||
"indoc 2.0.1",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"specta",
|
||||
"tauri",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-utils"
|
||||
version = "1.3.0"
|
||||
@@ -3356,6 +3459,15 @@ dependencies = [
|
||||
"utf-8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thin-slice"
|
||||
version = "0.1.1"
|
||||
@@ -3379,7 +3491,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.15",
|
||||
"syn 2.0.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3495,7 +3607,7 @@ checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.15",
|
||||
"syn 2.0.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3609,9 +3721,9 @@ checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "1.3.2"
|
||||
version = "1.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4dad5567ad0cf5b760e5665964bec1b47dfd077ba8a2544b513f3556d3d239a2"
|
||||
checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2"
|
||||
dependencies = [
|
||||
"getrandom 0.2.9",
|
||||
]
|
||||
@@ -3696,9 +3808,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.85"
|
||||
version = "0.2.86"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b6cb788c4e39112fbe1822277ef6fb3c55cd86b95cb3d3c4c1c9597e4ac74b4"
|
||||
checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"wasm-bindgen-macro",
|
||||
@@ -3706,24 +3818,24 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.85"
|
||||
version = "0.2.86"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "35e522ed4105a9d626d885b35d62501b30d9666283a5c8be12c14a8bdafe7822"
|
||||
checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"log",
|
||||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.15",
|
||||
"syn 2.0.16",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-futures"
|
||||
version = "0.4.35"
|
||||
version = "0.4.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "083abe15c5d88556b77bdf7aef403625be9e327ad37c62c4e4129af740168163"
|
||||
checksum = "2d1985d03709c53167ce907ff394f5316aa22cb4e12761295c5dc57dacb6297e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
@@ -3733,9 +3845,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.85"
|
||||
version = "0.2.86"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "358a79a0cb89d21db8120cbfb91392335913e4890665b1a7981d9e956903b434"
|
||||
checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
@@ -3743,28 +3855,28 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.85"
|
||||
version = "0.2.86"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4783ce29f09b9d93134d41297aded3a712b7b979e9c6f28c32cb88c973a94869"
|
||||
checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.15",
|
||||
"syn 2.0.16",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.85"
|
||||
version = "0.2.86"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a901d592cafaa4d711bc324edfaff879ac700b19c3dfd60058d2b445be2691eb"
|
||||
checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93"
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.62"
|
||||
version = "0.3.63"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "16b5f940c7edfdc6d12126d98c9ef4d1b3d470011c47c76a6581df47ad9ba721"
|
||||
checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
@@ -4260,9 +4372,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zbus"
|
||||
version = "3.13.0"
|
||||
version = "3.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68a7c6d0d40302209909449c60924e537372f00f7ff214724b698a488e3ca43e"
|
||||
checksum = "6c3d77c9966c28321f1907f0b6c5a5561189d1f7311eea6d94180c6be9daab29"
|
||||
dependencies = [
|
||||
"async-broadcast",
|
||||
"async-executor",
|
||||
@@ -4300,9 +4412,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zbus_macros"
|
||||
version = "3.13.0"
|
||||
version = "3.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8aeee0924687157129e1e5b57854492734b49199ee50bb9a5feb5cee10dde284"
|
||||
checksum = "f6e341d12edaff644e539ccbbf7f161601294c9a84ed3d7e015da33155b435af"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
@@ -4326,9 +4438,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zip"
|
||||
version = "0.6.5"
|
||||
version = "0.6.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7e92305c174683d78035cbf1b70e18db6329cc0f1b9cae0a52ca90bf5bfe7125"
|
||||
checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"crc32fast",
|
||||
@@ -4337,9 +4449,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zvariant"
|
||||
version = "3.13.0"
|
||||
version = "3.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5cb36cd95352132911c9c99fdcc1635de5c2c139bd34cbcf6dfb8350ee8ff6a7"
|
||||
checksum = "622cc473f10cef1b0d73b7b34a266be30ebdcfaea40ec297dd8cbda088f9f93c"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"enumflags2",
|
||||
@@ -4351,9 +4463,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zvariant_derive"
|
||||
version = "3.13.0"
|
||||
version = "3.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b34951e1ac64f3a1443fe7181256b9ed6a811a1631917566c3d5ca718d8cf33"
|
||||
checksum = "5d9c1b57352c25b778257c661f3c4744b7cefb7fc09dd46909a153cce7773da2"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
@@ -4364,9 +4476,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zvariant_utils"
|
||||
version = "1.0.0"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53b22993dbc4d128a17a3b6c92f1c63872dd67198537ee728d8b5d7c40640a8b"
|
||||
checksum = "7234f0d811589db492d16893e3f21e8e2fd282e6d01b0cddee310322062cc200"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "svelte-tauri"
|
||||
version = "0.0.1"
|
||||
version = "0.0.2"
|
||||
description = "Svelte-Tauri template starter"
|
||||
authors = ["Fractal-Tess"]
|
||||
license = "MIT"
|
||||
@@ -20,6 +20,9 @@ sha2 = "0.10.6"
|
||||
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
tauri = { version = "1.2.3", features = ["api-all", "devtools", "updater"] }
|
||||
thiserror = "1.0.40"
|
||||
specta = "1.0.4"
|
||||
tauri-specta = { version = "1.0.0", features = ["javascript", "typescript"] }
|
||||
[features]
|
||||
# by default Tauri runs in production mode
|
||||
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
|
||||
@@ -30,7 +33,7 @@ custom-protocol = ["tauri/custom-protocol"]
|
||||
|
||||
|
||||
[profile.release]
|
||||
# panic ='abort'
|
||||
# codegen-units= 1
|
||||
# lto = true
|
||||
# opt-level = 's'
|
||||
panic = 'abort'
|
||||
codegen-units = 1
|
||||
lto = true
|
||||
opt-level = 3
|
||||
|
@@ -1,3 +1,3 @@
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
tauri_build::build();
|
||||
}
|
||||
|
57
src-tauri/src/commands.rs
Normal file
57
src-tauri/src/commands.rs
Normal file
@@ -0,0 +1,57 @@
|
||||
#![allow(clippy::needless_pass_by_value)]
|
||||
// This module shows examples of how to use IPC command handlers that can be invoked from the frontend.
|
||||
use sha2::{Digest, Sha256};
|
||||
use specta::collect_types;
|
||||
use tauri::{Builder, State, Wry};
|
||||
use tauri_specta::ts;
|
||||
|
||||
use crate::state::Store;
|
||||
|
||||
// Exports a function for the tauri app instance to use and register all commands defined as frontend IPC command handlers.
|
||||
pub fn register_command_handlers(builder: Builder<Wry>) -> Builder<Wry> {
|
||||
// Specta generating typed binding interfaces
|
||||
#[cfg(debug_assertions)]
|
||||
ts::export(
|
||||
collect_types![hello_tauri, hash256sum, store_set_key, store_read_key],
|
||||
"../src/lib/ipc.ts",
|
||||
)
|
||||
.expect("unable to generate specta types");
|
||||
|
||||
builder.invoke_handler(tauri::generate_handler![
|
||||
hash256sum,
|
||||
hello_tauri,
|
||||
store_set_key,
|
||||
store_read_key
|
||||
])
|
||||
}
|
||||
|
||||
// An example command
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
fn hello_tauri() -> String {
|
||||
"Hi from Tauri".to_owned()
|
||||
}
|
||||
|
||||
// Another command
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
fn hash256sum(hash_input: String) -> String {
|
||||
let mut hasher = Sha256::new();
|
||||
hasher.update(hash_input.as_bytes());
|
||||
let result = hasher.finalize();
|
||||
format!("{result:X}")
|
||||
}
|
||||
|
||||
// Example command using managed state
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
fn store_set_key(key: String, value: String, store: State<Store>) {
|
||||
store.add_key_val(key, value);
|
||||
}
|
||||
|
||||
// Another example command using managed state
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
fn store_read_key(key: String, store: State<Store>) -> Option<String> {
|
||||
store.read_key(&key)
|
||||
}
|
10
src-tauri/src/error.rs
Normal file
10
src-tauri/src/error.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
#![allow(unused)]
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error("{0}")]
|
||||
Other(String),
|
||||
|
||||
#[error(transparent)]
|
||||
IO(#[from] std::io::Error),
|
||||
}
|
@@ -3,35 +3,31 @@
|
||||
windows_subsystem = "windows"
|
||||
)]
|
||||
|
||||
use sha2::{Digest, Sha256};
|
||||
use tauri::RunEvent;
|
||||
use commands::register_command_handlers;
|
||||
use state::register_managed_state;
|
||||
use tauri::{Builder as TauriBuilder, RunEvent};
|
||||
|
||||
mod commands;
|
||||
mod error;
|
||||
mod prelude;
|
||||
mod state;
|
||||
|
||||
fn main() {
|
||||
let app = tauri::Builder::default()
|
||||
.plugin(tauri_plugin_window_state::Builder::default().build())
|
||||
.invoke_handler(tauri::generate_handler![called_from_js, hash256sum])
|
||||
.build(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
// App builder
|
||||
let app = TauriBuilder::default().plugin(tauri_plugin_window_state::Builder::default().build());
|
||||
|
||||
app.run(|_, e| match e {
|
||||
RunEvent::Ready => {
|
||||
println!("Window is ready");
|
||||
}
|
||||
_ => {}
|
||||
})
|
||||
}
|
||||
// Register app commands
|
||||
let app = register_command_handlers(app);
|
||||
|
||||
#[tauri::command]
|
||||
fn called_from_js() -> String {
|
||||
// The print macro is problematic in release environment (crashes the application if not ran from a terminal)
|
||||
// println!("Returning from tauri");
|
||||
"Hi from Tauri".to_owned()
|
||||
}
|
||||
// Register app managed state
|
||||
let app = register_managed_state(app);
|
||||
|
||||
#[tauri::command]
|
||||
fn hash256sum(hash_input: String) -> String {
|
||||
let mut hasher = Sha256::new();
|
||||
hasher.update(hash_input.as_bytes());
|
||||
let result = hasher.finalize();
|
||||
format!("{:X}", result)
|
||||
// Run the app
|
||||
app.build(tauri::generate_context!())
|
||||
.expect("error while running tauri application")
|
||||
.run(|_, e| {
|
||||
if matches!(e, RunEvent::Ready) {
|
||||
println!("Window is ready");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
6
src-tauri/src/prelude.rs
Normal file
6
src-tauri/src/prelude.rs
Normal file
@@ -0,0 +1,6 @@
|
||||
#![allow(unused)]
|
||||
pub use crate::error::Error;
|
||||
|
||||
pub type Result<T> = core::result::Result<T, Error>;
|
||||
|
||||
pub struct W<T>(pub T);
|
34
src-tauri/src/state.rs
Normal file
34
src-tauri/src/state.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
// This module shows examples of how to use managed custom state.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::string::ToString;
|
||||
use std::sync::Mutex;
|
||||
|
||||
use tauri::{Builder, Wry};
|
||||
|
||||
// Exports a function for the tauri app instance to use and register all commands defined as frontend IPC command handlers.
|
||||
pub fn register_managed_state(builder: Builder<Wry>) -> Builder<Wry> {
|
||||
let store = Store::default();
|
||||
|
||||
builder.manage(store)
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Store {
|
||||
store: Mutex<HashMap<String, String>>,
|
||||
}
|
||||
impl Store {
|
||||
pub fn add_key_val(&self, key: String, val: String) {
|
||||
self.store
|
||||
.lock()
|
||||
.expect("cannot lock store")
|
||||
.insert(key, val);
|
||||
}
|
||||
pub fn read_key(&self, key: &String) -> Option<String> {
|
||||
self.store
|
||||
.lock()
|
||||
.expect("cannot lock store")
|
||||
.get(key)
|
||||
.map(ToString::to_string)
|
||||
}
|
||||
}
|
@@ -8,7 +8,7 @@
|
||||
},
|
||||
"package": {
|
||||
"productName": "svelte-tauri",
|
||||
"version": "0.0.1"
|
||||
"version": "0.0.2"
|
||||
},
|
||||
"tauri": {
|
||||
"allowlist": {
|
||||
|
28
src/lib/ipc.ts
Normal file
28
src/lib/ipc.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually.
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__TAURI_INVOKE__<T>(
|
||||
cmd: string,
|
||||
args?: Record<string, unknown>
|
||||
): Promise<T>;
|
||||
}
|
||||
}
|
||||
|
||||
const invoke = window.__TAURI_INVOKE__;
|
||||
|
||||
export function helloTauri() {
|
||||
return invoke<string>('hello_tauri');
|
||||
}
|
||||
|
||||
export function hash256sum(hashInput: string) {
|
||||
return invoke<string>('hash256sum', { hashInput });
|
||||
}
|
||||
|
||||
export function storeSetKey(key: string, value: string) {
|
||||
return invoke<null>('store_set_key', { key, value });
|
||||
}
|
||||
|
||||
export function storeReadKey(key: string) {
|
||||
return invoke<string | null>('store_read_key', { key });
|
||||
}
|
@@ -26,11 +26,8 @@
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
use:link
|
||||
href="/#call_tauri"
|
||||
class="transition-colors hover:text-secondary">
|
||||
Call Tauri
|
||||
<a use:link href="/#IPC" class="transition-colors hover:text-secondary">
|
||||
IPC
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
@@ -4,7 +4,8 @@
|
||||
import Header from '$layout/BaseHeader.svelte';
|
||||
</script>
|
||||
|
||||
<div class="form-control min-h-screen bg-fixed heropattern-topography-white/10">
|
||||
<div
|
||||
class="form-control min-h-screen bg-fixed heropattern-topography-black/10 dark:heropattern-topography-white/10">
|
||||
<Header />
|
||||
<main class="form-control flex-1" in:fade={{ delay: 300, duration: 1000 }}>
|
||||
<slot />
|
||||
|
@@ -2,12 +2,12 @@
|
||||
import Router from 'svelte-spa-router';
|
||||
|
||||
import Index from '$lib/router/routes/Index.svelte';
|
||||
import CallTauri from '$router/routes/CallTauri.svelte';
|
||||
import IPC from '$lib/router/routes/IPC.svelte';
|
||||
import Versions from '$router/routes/Versions.svelte';
|
||||
|
||||
const routes = {
|
||||
'/': Index,
|
||||
'/#call_tauri': CallTauri,
|
||||
'/#ipc': IPC,
|
||||
'/#versions': Versions
|
||||
};
|
||||
</script>
|
||||
|
@@ -1,47 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { fade } from 'svelte/transition';
|
||||
import { invoke } from '@tauri-apps/api';
|
||||
|
||||
let hashInput = 'Hello world';
|
||||
let hashOutput = '';
|
||||
$: (async () => {
|
||||
hashOutput = await invoke('hash256sum', { hashInput });
|
||||
})();
|
||||
|
||||
let message = '';
|
||||
|
||||
async function callTauri() {
|
||||
message = await invoke('called_from_js');
|
||||
}
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="form-control h-full flex-1 items-center justify-center gap-y-8
|
||||
[&>section]:form-control [&>section]:items-center [&>section]:justify-center [&>section]:gap-y-4">
|
||||
<section class="">
|
||||
<button
|
||||
on:click={callTauri}
|
||||
class="btn-outline btn-primary btn-md btn font-extrabold"
|
||||
>Call Tauri</button>
|
||||
<div class="flex h-20 items-center">
|
||||
{#key message}
|
||||
<p
|
||||
class="whitespace-nowrap border-b-2 border-accent
|
||||
text-2xl"
|
||||
in:fade={{ duration: 300 }}>
|
||||
{message}
|
||||
</p>
|
||||
{/key}
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<label class="input-group flex max-w-max">
|
||||
<span>Hash string</span>
|
||||
<input
|
||||
bind:value={hashInput}
|
||||
type="text"
|
||||
class="input-bordered input-secondary input focus:border-secondary focus:outline-none focus:ring-secondary" />
|
||||
</label>
|
||||
<p class="text-center text-lg">{hashOutput}</p>
|
||||
</section>
|
||||
</div>
|
92
src/lib/router/routes/IPC.svelte
Normal file
92
src/lib/router/routes/IPC.svelte
Normal file
@@ -0,0 +1,92 @@
|
||||
<script lang="ts">
|
||||
import { fade } from 'svelte/transition';
|
||||
import { hash256sum, helloTauri, storeSetKey, storeReadKey } from '$ipc';
|
||||
|
||||
// Or you can also do this if you prefer
|
||||
|
||||
// import * as ipc from '$ipc';
|
||||
// message = await ipc.helloTauri()
|
||||
|
||||
// Calling the hash256 function any time the `hashInput` variable changes
|
||||
let hashInput = 'Hello world';
|
||||
let hashOutput = '';
|
||||
$: (async () => {
|
||||
hashOutput = await hash256sum(hashInput);
|
||||
})();
|
||||
|
||||
// Calling the `helloTauri` when we click the call tauri button
|
||||
let message = '';
|
||||
async function callTauri() {
|
||||
message = await helloTauri();
|
||||
}
|
||||
|
||||
let storeMessage = '';
|
||||
let key = '';
|
||||
let val = '';
|
||||
async function setKeyVal() {
|
||||
await storeSetKey(key, val);
|
||||
storeMessage = `You have set the key '${key}' to be the value of '${val}''`;
|
||||
}
|
||||
|
||||
async function readValFromKey() {
|
||||
const val = await storeReadKey(key);
|
||||
storeMessage = `Using the key '${key}', you have just retrieved the value of '${val}''`;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="form-control h-full flex-1 items-center justify-center gap-y-8
|
||||
[&>section]:form-control [&>section]:items-center [&>section]:justify-center [&>section]:gap-y-4">
|
||||
<section class="">
|
||||
<button
|
||||
on:click={callTauri}
|
||||
class="btn-outline btn-primary btn text-2xl capitalize"
|
||||
>Call Tauri</button>
|
||||
<div class="flex h-20 items-center">
|
||||
{#key message}
|
||||
<p
|
||||
class="whitespace-nowrap border-b-2 border-accent
|
||||
text-2xl"
|
||||
in:fade={{ duration: 300 }}>
|
||||
{message}
|
||||
</p>
|
||||
{/key}
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<label class="input-group flex max-w-max">
|
||||
<span>Hash string</span>
|
||||
<input
|
||||
bind:value={hashInput}
|
||||
type="text"
|
||||
class="input-bordered input-secondary input focus:border-secondary focus:outline-none focus:ring-secondary" />
|
||||
</label>
|
||||
<p class="text-center text-lg">{hashOutput}</p>
|
||||
</section>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<label class="input-group flex max-w-max">
|
||||
<span>Key</span>
|
||||
<input
|
||||
bind:value={key}
|
||||
type="text"
|
||||
class="input-bordered input-secondary input focus:border-secondary focus:outline-none focus:ring-secondary" />
|
||||
</label>
|
||||
<label class="input-group flex max-w-max">
|
||||
<span>Value</span>
|
||||
<input
|
||||
bind:value={val}
|
||||
type="text"
|
||||
class="input-bordered input-secondary input focus:border-secondary focus:outline-none focus:ring-secondary" />
|
||||
</label>
|
||||
|
||||
<button on:click={setKeyVal} class="btn-outline btn-primary btn capitalize"
|
||||
>Set key</button>
|
||||
<button
|
||||
on:click={readValFromKey}
|
||||
class="btn-outline btn-primary btn capitalize">Read key</button>
|
||||
<p class="text-bold font-2xl col-span-full text-center text-primary">
|
||||
{storeMessage}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
10
src/main.ts
10
src/main.ts
@@ -1,8 +1,14 @@
|
||||
import './styles.postcss';
|
||||
import './styles.pcss';
|
||||
import App from './App.svelte';
|
||||
|
||||
const target = document.getElementById('app');
|
||||
if (!target)
|
||||
throw new Error(
|
||||
"The element with id of 'app' wasn't found on the base html file."
|
||||
);
|
||||
|
||||
const app = new App({
|
||||
target: document.getElementById('app'),
|
||||
target,
|
||||
intro: true
|
||||
});
|
||||
|
||||
|
BIN
static/app.jpeg
BIN
static/app.jpeg
Binary file not shown.
Before Width: | Height: | Size: 95 KiB |
Binary file not shown.
Before Width: | Height: | Size: 310 KiB |
@@ -16,6 +16,7 @@
|
||||
"isolatedModules": true,
|
||||
"paths": {
|
||||
"$lib/*": ["src/lib/*"],
|
||||
"$ipc": ["src/lib/ipc.ts"],
|
||||
"$components/*": ["src/lib/components/*"],
|
||||
"$assets/*": ["src/assets/*"],
|
||||
"$router/*": ["src/lib/router/*"],
|
||||
|
@@ -8,6 +8,7 @@ export default defineConfig({
|
||||
resolve: {
|
||||
alias: {
|
||||
$lib: join(__dirname, 'src/lib'),
|
||||
$ipc: join(__dirname, 'src/lib/ipc.ts'),
|
||||
$components: join(__dirname, 'src/lib/components'),
|
||||
$assets: join(__dirname, 'src/assets'),
|
||||
$router: join(__dirname, 'src/lib/router'),
|
||||
|
Reference in New Issue
Block a user