init Tauri
7
src-tauri/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
|
||||
# Generated by Tauri
|
||||
# will have schema files for capabilities auto-completion
|
||||
/gen/schemas
|
||||
5548
src-tauri/Cargo.lock
generated
Normal file
33
src-tauri/Cargo.toml
Normal file
@@ -0,0 +1,33 @@
|
||||
[package]
|
||||
name = "owlerlay"
|
||||
version = "0.1.0"
|
||||
description = "A Tauri App"
|
||||
authors = ["you"]
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[lib]
|
||||
# The `_lib` suffix may seem redundant but it is necessary
|
||||
# to make the lib name unique and wouldn't conflict with the bin name.
|
||||
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
|
||||
name = "owlerlay_lib"
|
||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2", features = [] }
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "2", features = [] }
|
||||
tauri-plugin-opener = "2"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
axum = "0.8.8"
|
||||
tracing = "0.1.44"
|
||||
tracing-subscriber = "0.3.22"
|
||||
thiserror = "2.0.18"
|
||||
tokio = { version = "1.49.0", features = ["full"] }
|
||||
tower-http = { version = "0.6.8", features = ["fs", "cors"] }
|
||||
minijinja = "2.15.1"
|
||||
toml = "1.0.3"
|
||||
|
||||
3
src-tauri/build.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
}
|
||||
10
src-tauri/capabilities/default.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "default",
|
||||
"description": "Capability for the main window",
|
||||
"windows": ["main"],
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"opener:default"
|
||||
]
|
||||
}
|
||||
BIN
src-tauri/icons/128x128.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
src-tauri/icons/128x128@2x.png
Normal file
|
After Width: | Height: | Size: 6.8 KiB |
BIN
src-tauri/icons/32x32.png
Normal file
|
After Width: | Height: | Size: 974 B |
BIN
src-tauri/icons/Square107x107Logo.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
src-tauri/icons/Square142x142Logo.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
src-tauri/icons/Square150x150Logo.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
src-tauri/icons/Square284x284Logo.png
Normal file
|
After Width: | Height: | Size: 7.6 KiB |
BIN
src-tauri/icons/Square30x30Logo.png
Normal file
|
After Width: | Height: | Size: 903 B |
BIN
src-tauri/icons/Square310x310Logo.png
Normal file
|
After Width: | Height: | Size: 8.4 KiB |
BIN
src-tauri/icons/Square44x44Logo.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
src-tauri/icons/Square71x71Logo.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
src-tauri/icons/Square89x89Logo.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
src-tauri/icons/StoreLogo.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
src-tauri/icons/icon.icns
Normal file
BIN
src-tauri/icons/icon.ico
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
src-tauri/icons/icon.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
0
src-tauri/src/app_state.rs
Normal file
0
src-tauri/src/countdown/commands.rs
Normal file
0
src-tauri/src/countdown/dto.rs
Normal file
0
src-tauri/src/countdown/mod.rs
Normal file
80
src-tauri/src/countdown/model.rs
Normal file
@@ -0,0 +1,80 @@
|
||||
use std::time::{Instant, Duration}
|
||||
|
||||
enum CountdownState{
|
||||
Idle,
|
||||
Running,
|
||||
Paused,
|
||||
Finished
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Countdown {
|
||||
id: uint,
|
||||
label: &str,
|
||||
initial_duration: Duration,
|
||||
remaining_duration_stored: Option<Duration>,
|
||||
state: CountdownState,
|
||||
start_timestamp: Option<Instant>,
|
||||
target_timestamp: Option<Instant>,
|
||||
}
|
||||
|
||||
impl Countdown{
|
||||
|
||||
fn create(&self, id: uint, label: &str, duration: Duration) -> Option<Countdown>{
|
||||
self.id = id;
|
||||
self.label = label;
|
||||
self.initial_duration = duration;
|
||||
self.state = CountdownState::Idle;
|
||||
self.remaining_duration_stored = None;
|
||||
self.start_timestamp = None;
|
||||
self.target_timestamp = None;
|
||||
}
|
||||
|
||||
fn remaining_at(&self, timestamp: Instant) -> Duration{
|
||||
timestamp.saturating_duration_since(target_timestamp)
|
||||
}
|
||||
|
||||
fn remaining(&self) -> Duration{
|
||||
self.remaining_at(Instant::Now())
|
||||
}
|
||||
|
||||
fn is_finished(&self) -> bool {
|
||||
self.state == CountdownState::Finished
|
||||
}
|
||||
|
||||
fn start(&self) -> Result {
|
||||
match self.state{
|
||||
CountdownState::Idle => {
|
||||
start_timestamp = Instant::Now();
|
||||
target_timestamp = start.timestamp.checked_add(self.initial_duration).unwrap();
|
||||
},
|
||||
CountdownState::Paused => {
|
||||
target_timestamp = Instant::Now().checked_add(self.remaining_duration_stored).unwrap();
|
||||
},
|
||||
_ => Err("not startable")
|
||||
}
|
||||
self.remaining_duration_stored = None;
|
||||
self.State = Running;
|
||||
Ok()
|
||||
}
|
||||
|
||||
fn pause(&self) -> Result {
|
||||
match self.state {
|
||||
CountdownState::Running => {
|
||||
self.remaining_duration_stored = Instant::Now().saturating_duration_since(self.target_timestamp);
|
||||
self.state = CountdownState::Paused;
|
||||
Ok()
|
||||
},
|
||||
_ => Err("not pausable")
|
||||
}
|
||||
}
|
||||
|
||||
fn reset(&self) -> Result{
|
||||
self.state = CountdownState::Idle;
|
||||
self.remaining_duration_stored = None;
|
||||
self.start_timestamp = None;
|
||||
self.target_timestamp = None;
|
||||
Ok()
|
||||
}
|
||||
|
||||
}
|
||||
0
src-tauri/src/countdown/service.rs
Normal file
14
src-tauri/src/lib.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
|
||||
#[tauri::command]
|
||||
fn greet(name: &str) -> String {
|
||||
format!("Hello, {}! You've been greeted from Rust!", name)
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.invoke_handler(tauri::generate_handler![greet])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
6
src-tauri/src/main.rs
Normal file
@@ -0,0 +1,6 @@
|
||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
fn main() {
|
||||
owlerlay_lib::run()
|
||||
}
|
||||
0
src-tauri/src/server/mod.rs
Normal file
0
src-tauri/src/server/routes.rs
Normal file
0
src-tauri/src/server/sse.rs
Normal file
36
src-tauri/tauri.conf.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "owlerlay",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.s0wlz.owlerlay",
|
||||
"build": {
|
||||
"beforeDevCommand": "pnpm dev",
|
||||
"devUrl": "http://localhost:1420",
|
||||
"beforeBuildCommand": "pnpm build",
|
||||
"frontendDist": "../dist"
|
||||
},
|
||||
"app": {
|
||||
"withGlobalTauri": true,
|
||||
"windows": [
|
||||
{
|
||||
"title": "owlerlay",
|
||||
"width": 800,
|
||||
"height": 600
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
"csp": null
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
||||