daydream

A small matrix web client written in rust
git clone git://archive.git.mtrnord.blog/daydream-mx/daydream.git
Log | Files | Refs | README | LICENSE

commit 3e05c4b73be633be2f3cb1e61ff787d826d667f8
parent d4a637ffc65e2bd7153fccee3d5a65c88a891c57
Author: Marcel <mtrnord1@gmail.com>
Date:   Sat, 25 Jul 2020 15:06:13 +0200

Remove bin/ from gitignore

Took 1 minute

Diffstat:
M.gitignore | 1-
Asrc/bin/app.rs | 29+++++++++++++++++++++++++++++
Asrc/bin/native_worker.rs | 18++++++++++++++++++
3 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore @@ -1,6 +1,5 @@ /target **/*.rs.bk -bin/ pkg/ dist/ wasm-pack.log diff --git a/src/bin/app.rs b/src/bin/app.rs @@ -0,0 +1,29 @@ +extern crate console_error_panic_hook; +//extern crate wee_alloc; +use console_error_panic_hook::set_once as set_panic_hook; +use i18n_embed::{language_loader, I18nEmbed, WebLanguageRequester}; +use rust_embed::RustEmbed; + +#[derive(RustEmbed, I18nEmbed)] +#[folder = "i18n/mo"] // path to the compiled localization resources +struct Translations; + +language_loader!(DaydreamLanguageLoader); + +//#[global_allocator] +//static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; + +fn main() { + // If the `console_error_panic_hook` feature is enabled this will set a panic hook, otherwise + // it will do nothing. + set_panic_hook(); + wasm_logger::init(wasm_logger::Config::default()); + + let translations = Translations {}; + let language_loader = DaydreamLanguageLoader::new(); + let requested_languages = WebLanguageRequester::requested_languages(); + + i18n_embed::select(&language_loader, &translations, &requested_languages).unwrap(); + + yew::start_app::<daydream::app::App>(); +} diff --git a/src/bin/native_worker.rs b/src/bin/native_worker.rs @@ -0,0 +1,18 @@ +//====== Running the worker ======/// + +// We need to import the Threaded trait to register the worker +use log::*; +use yew::agent::Threaded; + +/// This gets called by the worker.js entrypoint +/// We need to wrap it in wasm_bindgen so the worker knows the spin the the yew worker instance +fn main() { + wasm_logger::init(wasm_logger::Config::default()); + + // Spawning a yew component without StartApp requires initializing + yew::initialize(); + info!("Worker"); + + // ... registering the worker + daydream::app::matrix::MatrixAgent::register(); +}