implement file loading
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
AnActualEmerald 2022-09-16 14:17:27 -04:00
parent e4770a8894
commit d213bf787f
Signed by: emerald
GPG Key ID: CC76D6B296CAC8B0
22 changed files with 241 additions and 210 deletions

4
dist/index.html vendored
View File

@ -5,8 +5,8 @@
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri + Svelte + TS</title>
<script type="module" crossorigin src="/assets/index.f473b4a5.js"></script>
<link rel="stylesheet" href="/assets/index.80ecf419.css">
<script type="module" crossorigin src="/assets/index.5494e677.js"></script>
<link rel="stylesheet" href="/assets/index.425121d3.css">
</head>
<body>

View File

@ -11,6 +11,12 @@ pub(crate) struct Archive {
}
impl Archive {
pub(crate) fn open(data: &[u8]) -> Self {
Self {
buffer: data.to_vec(),
}
}
pub(crate) fn new() -> Self {
let mut buffer = vec![];
ZipWriter::new(Cursor::new(&mut buffer));
@ -23,9 +29,11 @@ impl Archive {
pub(crate) fn add_file(&mut self, file_name: &str, data: &[u8]) -> Result<()> {
let mut zip = ZipWriter::new_append(Cursor::new(&mut self.buffer))?;
let options = FileOptions::default().compression_method(zip::CompressionMethod::Bzip2);
let options = FileOptions::default()
.compression_method(zip::CompressionMethod::Bzip2)
.compression_level(Some(9));
zip.start_file(file_name, options)?;
zip.write(data)?;
zip.write_all(data)?;
zip.finish()?;
Ok(())

View File

@ -1,5 +1,9 @@
use anyhow::Result;
use std::{collections::HashMap, fs, path::Path};
use std::{
collections::{hash_map::Keys, HashMap},
fs,
path::Path,
};
use crate::archive::Archive;
@ -11,6 +15,14 @@ pub struct Ray {
}
impl Ray {
pub fn get_meta_keys(&self) -> Keys<String, String> {
self.meta.keys()
}
pub fn get_meta_value(&self, key: &str) -> Option<&String> {
self.meta.get(key)
}
pub fn get_frame(&self, index: usize) -> Option<&Vec<u8>> {
self.frames.get(index)
}
@ -46,4 +58,23 @@ impl Ray {
Ok(())
}
pub fn load(path: impl AsRef<Path>) -> Result<Self> {
let mut ray = Self::default();
let data = fs::read(path.as_ref())?;
let archive = Archive::open(&data);
for i in 0..4 {
if let Ok(buf) = archive.get_file(&i.to_string()) {
ray.set_frame(i as usize, buf);
}
}
if let Ok(buf) = archive.get_file("meta.json") {
let meta: HashMap<String, String> = serde_json::from_slice(&buf)?;
ray.meta = meta;
}
Ok(ray)
}
}

309
src-tauri/Cargo.lock generated
View File

@ -531,7 +531,7 @@ dependencies = [
"core-foundation-sys",
"coreaudio-rs",
"jack",
"jni 0.19.0",
"jni",
"js-sys",
"libc",
"mach",
@ -723,9 +723,9 @@ dependencies = [
[[package]]
name = "digest"
version = "0.10.3"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506"
checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c"
dependencies = [
"block-buffer",
"crypto-common",
@ -812,25 +812,21 @@ version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
[[package]]
name = "embed-resource"
version = "1.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecc24ff8d764818e9ab17963b0593c535f077a513f565e75e4352d758bc4d8c0"
dependencies = [
"cc",
"rustc_version 0.4.0",
"toml",
"vswhom",
"winreg",
]
[[package]]
name = "embed_plist"
version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ef6b89e5b37196644d8796de5268852ff179b44e96276cf4290264843743bb7"
[[package]]
name = "encoding_rs"
version = "0.8.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b"
dependencies = [
"cfg-if",
]
[[package]]
name = "env_logger"
version = "0.9.0"
@ -953,21 +949,6 @@ dependencies = [
"new_debug_unreachable",
]
[[package]]
name = "futures"
version = "0.3.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c"
dependencies = [
"futures-channel",
"futures-core",
"futures-executor",
"futures-io",
"futures-sink",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-channel"
version = "0.3.24"
@ -975,7 +956,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050"
dependencies = [
"futures-core",
"futures-sink",
]
[[package]]
@ -1001,21 +981,6 @@ version = "0.3.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68"
[[package]]
name = "futures-lite"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48"
dependencies = [
"fastrand",
"futures-core",
"futures-io",
"memchr",
"parking",
"pin-project-lite",
"waker-fn",
]
[[package]]
name = "futures-macro"
version = "0.3.24"
@ -1045,13 +1010,9 @@ version = "0.3.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90"
dependencies = [
"futures-channel",
"futures-core",
"futures-io",
"futures-macro",
"futures-sink",
"futures-task",
"memchr",
"pin-project-lite",
"pin-utils",
"slab",
@ -1600,20 +1561,6 @@ dependencies = [
"system-deps 5.0.0",
]
[[package]]
name = "jni"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24967112a1e4301ca5342ea339763613a37592b8a6ce6cf2e4494537c7a42faf"
dependencies = [
"cesu8",
"combine",
"jni-sys",
"log",
"thiserror",
"walkdir",
]
[[package]]
name = "jni"
version = "0.19.0"
@ -1888,7 +1835,7 @@ dependencies = [
"jni-sys",
"ndk-sys 0.4.0",
"num_enum",
"raw-window-handle 0.5.0",
"raw-window-handle",
"thiserror",
]
@ -2088,7 +2035,7 @@ version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27f63c358b4fa0fbcfefd7c8be5cfc39c08ce2389f5325687e7762a48d30a5c1"
dependencies = [
"jni 0.19.0",
"jni",
"ndk 0.6.0",
"ndk-context",
"num-derive",
@ -2142,12 +2089,6 @@ dependencies = [
"system-deps 6.0.2",
]
[[package]]
name = "parking"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72"
[[package]]
name = "parking_lot"
version = "0.12.1"
@ -2178,7 +2119,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d791538a6dcc1e7cb7fe6f6b58aca40e7f79403c45b2bc274008b5e647af1d8"
dependencies = [
"base64ct",
"rand_core 0.6.3",
"rand_core 0.6.4",
"subtle",
]
@ -2516,7 +2457,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"libc",
"rand_chacha 0.3.1",
"rand_core 0.6.3",
"rand_core 0.6.4",
]
[[package]]
@ -2536,7 +2477,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core 0.6.3",
"rand_core 0.6.4",
]
[[package]]
@ -2550,9 +2491,9 @@ dependencies = [
[[package]]
name = "rand_core"
version = "0.6.3"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
"getrandom 0.2.7",
]
@ -2575,15 +2516,6 @@ dependencies = [
"rand_core 0.5.1",
]
[[package]]
name = "raw-window-handle"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b800beb9b6e7d2df1fe337c9e3d04e3af22a124460fb4c30fcc22c9117cefb41"
dependencies = [
"cty",
]
[[package]]
name = "raw-window-handle"
version = "0.5.0"
@ -2686,13 +2618,12 @@ dependencies = [
[[package]]
name = "rfd"
version = "0.9.1"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f121348fd3b9035ed11be1f028e8944263c30641f8c5deacf57a4320782fb402"
checksum = "0149778bd99b6959285b0933288206090c50e2327f47a9c463bfdbf45c8823ea"
dependencies = [
"block",
"dispatch",
"embed-resource",
"glib-sys",
"gobject-sys",
"gtk-sys",
@ -2702,7 +2633,7 @@ dependencies = [
"objc",
"objc-foundation",
"objc_id",
"raw-window-handle 0.4.3",
"raw-window-handle",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
@ -2730,7 +2661,7 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
"semver 1.0.13",
"semver 1.0.14",
]
[[package]]
@ -2809,9 +2740,9 @@ dependencies = [
[[package]]
name = "semver"
version = "1.0.13"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93f6841e709003d68bb2deee8c343572bf446003ec20a583e76f7b15cebf3711"
checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4"
dependencies = [
"serde",
]
@ -2923,9 +2854,9 @@ dependencies = [
[[package]]
name = "sha1"
version = "0.10.4"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "006769ba83e921b3085caa8334186b00cf92b4cb1a6cf4632fbccc8eff5c7549"
checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3"
dependencies = [
"cfg-if",
"cpufeatures",
@ -2934,9 +2865,9 @@ dependencies = [
[[package]]
name = "sha2"
version = "0.10.5"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf9db03534dff993187064c4e0c05a5708d2a9728ace9a8959b77bedf415dac5"
checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0"
dependencies = [
"cfg-if",
"cpufeatures",
@ -3144,9 +3075,9 @@ dependencies = [
[[package]]
name = "tao"
version = "0.12.2"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6fd7725dc1e593e9ecabd9fe49c112a204c8c8694db4182e78b2a5af490b1ae"
checksum = "43336f5d1793543ba96e2a1e75f3a5c7dcd592743be06a0ab3a190f4fcb4b934"
dependencies = [
"bitflags",
"cairo-rs",
@ -3166,7 +3097,7 @@ dependencies = [
"gtk",
"image",
"instant",
"jni 0.19.0",
"jni",
"lazy_static",
"libc",
"log",
@ -3178,12 +3109,12 @@ dependencies = [
"parking_lot",
"paste",
"png 0.17.6",
"raw-window-handle 0.4.3",
"raw-window-handle",
"scopeguard",
"serde",
"unicode-segmentation",
"uuid 1.1.2",
"windows 0.37.0",
"windows 0.39.0",
"windows-implement",
"x11-dl",
]
@ -3201,17 +3132,17 @@ dependencies = [
[[package]]
name = "tauri"
version = "1.0.5"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1a56a8b125069c2682bd31610109b4436c050c74447bee1078217a0325c1add"
checksum = "1613a40b1cdab831ff38f237ffba4d5cf6a00320696e8a92d90608a60e03035b"
dependencies = [
"anyhow",
"cocoa",
"dirs-next",
"embed_plist",
"encoding_rs",
"flate2",
"futures",
"futures-lite",
"futures-util",
"glib",
"glob",
"gtk",
@ -3222,9 +3153,9 @@ dependencies = [
"once_cell",
"percent-encoding",
"rand 0.8.5",
"raw-window-handle 0.4.3",
"raw-window-handle",
"rfd",
"semver 1.0.13",
"semver 1.0.14",
"serde",
"serde_json",
"serde_repr",
@ -3242,20 +3173,20 @@ dependencies = [
"uuid 1.1.2",
"webkit2gtk",
"webview2-com",
"windows 0.37.0",
"windows 0.39.0",
]
[[package]]
name = "tauri-build"
version = "1.0.4"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acafb1c515c5d14234a294461bd43c723639a84891a45f6a250fd3441ad2e8ed"
checksum = "ddf38874b50ef43d84f27031f6bebf5cbe3a329208ec6cbddf3f14f97a3a5be0"
dependencies = [
"anyhow",
"cargo_toml",
"heck 0.4.0",
"json-patch",
"semver 1.0.13",
"semver 1.0.14",
"serde_json",
"tauri-utils",
"winres",
@ -3263,9 +3194,9 @@ dependencies = [
[[package]]
name = "tauri-codegen"
version = "1.0.4"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16d62a3c8790d6cba686cea6e3f7f569d12c662c3274c2d165a4fd33e3871b72"
checksum = "a7a28567222d759b5ebd74ad0d70585b1494475c71f3047e9f41c5e1824c7418"
dependencies = [
"base64",
"brotli",
@ -3275,7 +3206,7 @@ dependencies = [
"png 0.17.6",
"proc-macro2 1.0.43",
"quote 1.0.21",
"semver 1.0.13",
"semver 1.0.14",
"serde",
"serde_json",
"sha2",
@ -3288,9 +3219,9 @@ dependencies = [
[[package]]
name = "tauri-macros"
version = "1.0.4"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7296fa17996629f43081e1c66d554703900187ed900c5bf46f97f0bcfb069278"
checksum = "a005349efa196c7ca5b8bdc46008e2145f09c54e225ba965d31acf6a13f5d68d"
dependencies = [
"heck 0.4.0",
"proc-macro2 1.0.43",
@ -3302,49 +3233,50 @@ dependencies = [
[[package]]
name = "tauri-runtime"
version = "0.10.2"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e4cff3b4d9469727fa2107c4b3d2eda110df1ba45103fb420178e536362fae4"
checksum = "c8c8eff18537f98196c2c93f0d715e9b81a51f5a545e5d3f28f759b4ec7436c4"
dependencies = [
"gtk",
"http",
"http-range",
"infer",
"raw-window-handle 0.4.3",
"rand 0.8.5",
"raw-window-handle",
"serde",
"serde_json",
"tauri-utils",
"thiserror",
"uuid 1.1.2",
"webview2-com",
"windows 0.37.0",
"windows 0.39.0",
]
[[package]]
name = "tauri-runtime-wry"
version = "0.10.2"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fa8c4edaf01d8b556e7172c844b1b4dd3399adcd1a606bd520fc3e65f698546"
checksum = "7cf832dd07842c89e5d563b1402ad7e5d8980b6c8523e6febcc919fb5aeefecb"
dependencies = [
"cocoa",
"gtk",
"percent-encoding",
"rand 0.8.5",
"raw-window-handle 0.4.3",
"raw-window-handle",
"tauri-runtime",
"tauri-utils",
"uuid 1.1.2",
"webkit2gtk",
"webview2-com",
"windows 0.37.0",
"windows 0.39.0",
"wry",
]
[[package]]
name = "tauri-utils"
version = "1.0.3"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12ff4b68d9faeb57c9c727bf58c9c9768d2b67d8e84e62ce6146e7859a2e9c6b"
checksum = "bfb828c364bdc65846b787e3c45887a1fe016a0bfdff26d333cad2c8a6afbcd9"
dependencies = [
"brotli",
"ctor",
@ -3357,14 +3289,14 @@ dependencies = [
"phf 0.10.1",
"proc-macro2 1.0.43",
"quote 1.0.21",
"semver 1.0.13",
"semver 1.0.14",
"serde",
"serde_json",
"serde_with",
"thiserror",
"url",
"walkdir",
"windows 0.37.0",
"windows 0.39.0",
]
[[package]]
@ -3703,32 +3635,6 @@ version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "vswhom"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be979b7f07507105799e854203b470ff7c78a1639e330a58f183b5fea574608b"
dependencies = [
"libc",
"vswhom-sys",
]
[[package]]
name = "vswhom-sys"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22025f6d8eb903ebf920ea6933b70b1e495be37e2cb4099e62c80454aaf57c39"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "waker-fn"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca"
[[package]]
name = "walkdir"
version = "2.3.2"
@ -3877,13 +3783,13 @@ dependencies = [
[[package]]
name = "webview2-com"
version = "0.16.0"
version = "0.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a489a9420acabb3c2ed0434b6f71f6b56b9485ec32665a28dec1ee186d716e0f"
checksum = "b4a769c9f1a64a8734bde70caafac2b96cada12cd4aefa49196b3a386b8b4178"
dependencies = [
"webview2-com-macros",
"webview2-com-sys",
"windows 0.37.0",
"windows 0.39.0",
"windows-implement",
]
@ -3900,16 +3806,17 @@ dependencies = [
[[package]]
name = "webview2-com-sys"
version = "0.16.0"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0258c53ee9adc0a4f8ba1c8c317588f7a58c7048a55b621d469ba75ab3709ca1"
checksum = "aac48ef20ddf657755fdcda8dfed2a7b4fc7e4581acce6fe9b88c3d64f29dee7"
dependencies = [
"regex",
"serde",
"serde_json",
"thiserror",
"windows 0.37.0",
"windows 0.39.0",
"windows-bindgen",
"windows-metadata",
]
[[package]]
@ -3968,7 +3875,6 @@ version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57b543186b344cc61c85b5aab0d2e3adf4e0f99bc076eff9aa5927bcc0b8a647"
dependencies = [
"windows-implement",
"windows_aarch64_msvc 0.37.0",
"windows_i686_gnu 0.37.0",
"windows_i686_msvc 0.37.0",
@ -3977,10 +3883,24 @@ dependencies = [
]
[[package]]
name = "windows-bindgen"
version = "0.37.0"
name = "windows"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bed7be31ade0af08fec9b5343e9edcc005d22b1f11859b8a59b24797f5858e8"
checksum = "f1c4bd0a50ac6020f65184721f758dba47bb9fbc2133df715ec74a237b26794a"
dependencies = [
"windows-implement",
"windows_aarch64_msvc 0.39.0",
"windows_i686_gnu 0.39.0",
"windows_i686_msvc 0.39.0",
"windows_x86_64_gnu 0.39.0",
"windows_x86_64_msvc 0.39.0",
]
[[package]]
name = "windows-bindgen"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68003dbd0e38abc0fb85b939240f4bce37c43a5981d3df37ccbaaa981b47cb41"
dependencies = [
"windows-metadata",
"windows-tokens",
@ -3988,9 +3908,9 @@ dependencies = [
[[package]]
name = "windows-implement"
version = "0.37.0"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67a1062e555f7d9d66fd1130ed4f7c6ec41a47529ee0850cd0e926d95b26bb14"
checksum = "ba01f98f509cb5dc05f4e5fc95e535f78260f15fea8fe1a8abdd08f774f1cee7"
dependencies = [
"syn 1.0.99",
"windows-tokens",
@ -3998,9 +3918,9 @@ dependencies = [
[[package]]
name = "windows-metadata"
version = "0.37.0"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f33f2b90a6664e369c41ab5ff262d06f048fc9685d9bf8a0e99a47750bb0463"
checksum = "9ee5e275231f07c6e240d14f34e1b635bf1faa1c76c57cfd59a5cdb9848e4278"
[[package]]
name = "windows-sys"
@ -4017,9 +3937,9 @@ dependencies = [
[[package]]
name = "windows-tokens"
version = "0.37.0"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3263d25f1170419995b78ff10c06b949e8a986c35c208dc24333c64753a87169"
checksum = "f838de2fe15fe6bac988e74b798f26499a8b21a9d97edec321e79b28d1d7f597"
[[package]]
name = "windows_aarch64_msvc"
@ -4039,6 +3959,12 @@ version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2623277cb2d1c216ba3b578c0f3cf9cdebeddb6e66b1b218bb33596ea7769c3a"
[[package]]
name = "windows_aarch64_msvc"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec7711666096bd4096ffa835238905bb33fb87267910e154b18b44eaabb340f2"
[[package]]
name = "windows_i686_gnu"
version = "0.32.0"
@ -4057,6 +3983,12 @@ version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3925fd0b0b804730d44d4b6278c50f9699703ec49bcd628020f46f4ba07d9e1"
[[package]]
name = "windows_i686_gnu"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "763fc57100a5f7042e3057e7e8d9bdd7860d330070251a73d003563a3bb49e1b"
[[package]]
name = "windows_i686_msvc"
version = "0.32.0"
@ -4075,6 +4007,12 @@ version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce907ac74fe331b524c1298683efbf598bb031bc84d5e274db2083696d07c57c"
[[package]]
name = "windows_i686_msvc"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7bc7cbfe58828921e10a9f446fcaaf649204dcfe6c1ddd712c5eebae6bda1106"
[[package]]
name = "windows_x86_64_gnu"
version = "0.32.0"
@ -4093,6 +4031,12 @@ version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2babfba0828f2e6b32457d5341427dcbb577ceef556273229959ac23a10af33d"
[[package]]
name = "windows_x86_64_gnu"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6868c165637d653ae1e8dc4d82c25d4f97dd6605eaa8d784b5c6e0ab2a252b65"
[[package]]
name = "windows_x86_64_msvc"
version = "0.32.0"
@ -4112,13 +4056,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4dd6dc7df2d84cf7b33822ed5b86318fb1781948e9663bacd047fc9dd52259d"
[[package]]
name = "winreg"
version = "0.10.1"
name = "windows_x86_64_msvc"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"
dependencies = [
"winapi",
]
checksum = "5e4d40883ae9cae962787ca76ba76390ffa29214667a111db9e0a1ad8377e809"
[[package]]
name = "winres"
@ -4131,19 +4072,22 @@ dependencies = [
[[package]]
name = "wry"
version = "0.19.0"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce19dddbd3ce01dc8f14eb6d4c8f914123bf8379aaa838f6da4f981ff7104a3f"
checksum = "ff5c1352b4266fdf92c63479d2f58ab4cd29dc4e78fbc1b62011ed1227926945"
dependencies = [
"base64",
"block",
"cocoa",
"core-graphics",
"crossbeam-channel",
"gdk",
"gio",
"glib",
"gtk",
"html5ever",
"http",
"jni 0.18.0",
"kuchiki",
"libc",
"log",
"objc",
@ -4151,13 +4095,14 @@ dependencies = [
"once_cell",
"serde",
"serde_json",
"sha2",
"tao",
"thiserror",
"url",
"webkit2gtk",
"webkit2gtk-sys",
"webview2-com",
"windows 0.37.0",
"windows 0.39.0",
"windows-implement",
]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 616 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 564 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 820 B

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 892 B

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -36,8 +36,31 @@ pub(crate) async fn open_ray() -> Option<WebRay> {
.add_filter("Rays", &["ray"])
.set_directory(home_dir()?)
.pick_file()?;
let ray = Ray::load(path).ok()?;
let mut frames = [String::new(), String::new(), String::new(), String::new()];
let mut meta = HashMap::new();
None
for i in 0..4 {
println!("Trying frame {}", i);
if let Some(f) = ray.get_frame(i as usize) {
println!("Got frame {}", i);
if f.is_empty() {
println!("Frame {} was empty", i);
continue;
}
let encoded = base64::encode(&f);
frames[i as usize] = format!("{}{}", OBJ_URL, encoded);
}
}
for k in ray.get_meta_keys() {
if let Some(v) = ray.get_meta_value(&k) {
meta.insert(k.clone(), v.clone());
}
}
Some(WebRay { frames, meta })
}
#[derive(Serialize, Deserialize)]

View File

@ -1,8 +1,15 @@
<script lang="ts" context="module">
import { writable } from "svelte/store";
import { writable, type Writable } from "svelte/store";
const transparent = writable(false);
const threshold = writable(0.5);
const threshold: Writable<number> = writable(0.5);
const level = writable(0);
type WebRay = {
frames: Array<string>;
meta: {
threshold: string | undefined;
};
};
</script>
<script lang="ts">
@ -23,7 +30,11 @@
let closeThreshold = 75;
$: {
invoke("set_mic_threshold", { threshold: $threshold }).then();
invoke("set_mic_threshold", { threshold: $threshold as number })
.then()
.catch(async (e) => {
await invoke("log", { msg: `Error setting mic threshold: ${e}` });
});
}
onMount(async () => {
@ -34,8 +45,10 @@
});
monitorTimer = setInterval(async () => {
$level = await invoke("get_audio_level");
await tick();
if (!$transparent) {
$level = await invoke("get_audio_level");
await tick();
}
}, 40);
$threshold = await invoke("get_mic_threshold");
@ -55,12 +68,7 @@
}
fr.map((e) => (e ? e : ""));
const ray = {
frames: [
fr[0].toString(),
fr[1].toString(),
fr[2].toString(),
fr[3].toString(),
],
frames: [fr[0], fr[1], fr[2], fr[3]],
meta: {
threshold: $threshold.toString(),
},
@ -71,6 +79,18 @@
.then()
.catch((e) => invoke("log", { msg: e }).then());
};
const loadRay = async () => {
const ray: WebRay = await invoke("open_ray");
await invoke("log", { msg: `${ray.meta.threshold}` });
for (let i = 0; i < 4; i++) {
await invoke("log", { msg: `Setting frame ${i}` });
$frames[i] = ray.frames[i];
}
if (ray.meta.threshold) {
$threshold = parseFloat(ray.meta.threshold);
}
};
</script>
<div class="container" class:transparent={$transparent}>
@ -90,16 +110,19 @@
</div>
<div transition:fly={{ duration: 200, x: 200, opacity: 100 }} class="audio">
<Bar
progress={$level * 100}
setpoint={$threshold * 100}
withSetpoint
onSetpointChange={async (e) => {
$threshold = e;
}}
--bar-color={active ? "lightgreen" : "blue"}
><img src="mic.svg" alt="microphone" /></Bar
>
{#key $threshold}
<Bar
progress={$level * 100}
setpoint={$threshold * 100}
withSetpoint
onSetpointChange={async (e) => {
$threshold = e;
}}
--bar-color={active ? "lightgreen" : "blue"}
><img src="mic.svg" alt="microphone" /></Bar
>
{/key}
<Bar
withSetpoint
progress={activation}
@ -108,8 +131,9 @@
><img src="mouth.svg" alt="mouth" /></Bar
>
</div>
<button on:click={saveRay}>Save</button>
<button on:click={loadRay}>Load</button>
{/if}
<button on:click={saveRay}>Save</button>
</div>
<svelte:body on:contextmenu|preventDefault />