source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
"once_cell",
"version_check",
"zerocopy",
[[package]]
name = "anstream"
-version = "0.6.17"
+version = "0.6.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338"
+checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
dependencies = [
"anstyle",
"anstyle-parse",
checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a"
dependencies = [
"addr2line",
- "cfg-if 1.0.0",
+ "cfg-if",
"libc",
"miniz_oxide",
"object",
[[package]]
name = "cc"
-version = "1.1.34"
+version = "1.1.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "67b9470d453346108f93a59222a9a1a5724db32d0a4727b7ab7ace4b4d822dc9"
+checksum = "baee610e9452a8f6f0a1b6194ec09ff9e2d85dea54432acdae41aa0761c95d70"
dependencies = [
"shlex",
]
-[[package]]
-name = "cfg-if"
-version = "0.1.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
-
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
"wasm-bindgen",
]
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
"home",
"windows-sys 0.48.0",
]
"console_error_panic_hook",
"wasm-bindgen",
"web-sys",
- "wee_alloc",
]
[[package]]
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
"libc",
"wasi",
]
[[package]]
name = "hashbrown"
-version = "0.15.0"
+version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb"
+checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3"
[[package]]
name = "hashlink"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9c7c7c8ac16c798734b8a24560c1362120597c40d5e1459f09498f8f6c8f2ba"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
"libc",
"windows",
]
[[package]]
name = "idna"
-version = "0.5.0"
+version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6"
+checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e"
dependencies = [
- "unicode-bidi",
- "unicode-normalization",
+ "idna_adapter",
+ "smallvec",
+ "utf8_iter",
]
[[package]]
-name = "idna"
-version = "1.0.2"
+name = "idna_adapter"
+version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bd69211b9b519e98303c015e21a007e293db403b6c85b9b124e133d25e242cdd"
+checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71"
dependencies = [
"icu_normalizer",
"icu_properties",
- "smallvec",
- "utf8_iter",
]
[[package]]
checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da"
dependencies = [
"equivalent",
- "hashbrown 0.15.0",
+ "hashbrown 0.15.1",
]
[[package]]
"futures-util",
"hostname",
"httpdate",
- "idna 1.0.2",
+ "idna",
"mime",
"nom",
"percent-encoding",
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
"digest",
]
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
-[[package]]
-name = "memory_units"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3"
-
[[package]]
name = "mime"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
"libc",
"redox_syscall",
"smallvec",
checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d"
dependencies = [
"cc",
- "cfg-if 1.0.0",
+ "cfg-if",
"getrandom",
"libc",
"spin",
[[package]]
name = "rustix"
-version = "0.38.38"
+version = "0.38.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a"
+checksum = "375116bee2be9ed569afe2154ea6a99dfdffd257f533f187498c2a8f5feaf4ee"
dependencies = [
"bitflags",
"errno",
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
"cpufeatures",
"digest",
]
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
"cpufeatures",
"digest",
]
checksum = "799c883d55abdb5e98af1a7b3f23b9b6de8ecada0ecac058672d7635eb48ca7b"
dependencies = [
"cc",
- "cfg-if 1.0.0",
+ "cfg-if",
"libc",
"psm",
"windows-sys 0.59.0",
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
"fastrand",
"once_cell",
"rustix",
[[package]]
name = "thiserror"
-version = "1.0.66"
+version = "1.0.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5d171f59dbaa811dbbb1aee1e73db92ec2b122911a48e1390dfe327a821ddede"
+checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
-version = "1.0.66"
+version = "1.0.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b08be0f17bd307950653ce45db00cd31200d82b624b36e181337d9c7d92765b5"
+checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e"
dependencies = [
"proc-macro2",
"quote",
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
"once_cell",
]
[[package]]
name = "url"
-version = "2.5.2"
+version = "2.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c"
+checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada"
dependencies = [
"form_urlencoded",
- "idna 0.5.0",
+ "idna",
"percent-encoding",
]
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
"once_cell",
"wasm-bindgen-macro",
]
"rustls-pki-types",
]
-[[package]]
-name = "wee_alloc"
-version = "0.4.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e"
-dependencies = [
- "cfg-if 0.1.10",
- "libc",
- "memory_units",
- "winapi",
-]
-
[[package]]
name = "whoami"
version = "1.5.2"
## WebAssembly
'frontend' project needs some tools to generate the WebAssembly stuff. Everything is explained here: https://rustwasm.github.io/wasm-bindgen/examples/hello-world.html
+TODO MVC Example:
+ https://github.com/rustwasm/wasm-bindgen/tree/main/examples/todomvc -> https://rustwasm.github.io/wasm-bindgen/exbuild/todomvc/#/
+
+Javascript bundler: https://rspack.dev/
To compile run 'wasm-pack build' in 'frontend' directory
To launch node run 'npm run start' in 'frontend/www' directory
-* How to log error to journalctl or elsewhere + debug log?
-* Try using WASM for all the client logic (test on editing/creating a recipe)
- * Understand the example here:
- * https://github.com/rustwasm/wasm-bindgen/tree/main/examples/todomvc -> https://rustwasm.github.io/wasm-bindgen/exbuild/todomvc/#/
-* Add a level of severity for the message template, use error severity in "impl axum::response::IntoResponse for db::DBError"
* Review the recipe model (SQL)
* Describe the use cases in details.
* Define the UI (mockups).
.service(services::webapi::set_recipe_description)
* Add support to translations into db model.
+[ok] Try using WASM for all the client logic (test on editing/creating a recipe)
+[ok] How to log error to journalctl or elsewhere + debug log?
[ok] Clean the old code + commit
[ok] Reactivate sign up/in/out
[ok] Change all id to i64
# `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size
# compared to the default allocator's ~10K. It is slower than the default
# allocator, however.
-wee_alloc = { version = "0.4", optional = true }
+# wee_alloc = { version = "0.4", optional = true }
# [dev-dependencies]
# wasm-bindgen-test = "0.3"
-wasm-pack build --target web -- --features wee_alloc
+wasm-pack build --target web
cp pkg/frontend.js ../backend/static
cp pkg/frontend_bg.wasm ../backend/static
\ No newline at end of file
{
"scripts": {
- "build": "webpack",
- "serve": "webpack serve"
+ "build": "rspack build",
+ "serve": "rspack serve"
},
"devDependencies": {
+ "@rspack/cli": "^1.0.14",
+ "@rspack/core": "^1.0.14",
"@wasm-tool/wasm-pack-plugin": "1.5.0",
- "html-webpack-plugin": "^5.3.2",
- "text-encoding": "^0.7.0",
- "webpack": "^5.75.0",
- "webpack-cli": "^4.10.0",
- "webpack-dev-server": "^3.11.2"
+ "html-webpack-plugin": "^5.6.0"
}
-}
+}
\ No newline at end of file
--- /dev/null
+const path = require('path');
+const HtmlWebpackPlugin = require('html-webpack-plugin');
+const webpack = require('webpack');
+const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
+
+module.exports = {
+ entry: './index.js',
+ output: {
+ path: path.resolve(__dirname, 'dist'),
+ filename: 'index.js',
+ },
+ plugins: [
+ new HtmlWebpackPlugin(),
+ new WasmPackPlugin({
+ crateDirectory: path.resolve(__dirname, ".")
+ }),
+ ],
+ mode: 'development',
+ experiments: {
+ asyncWebAssembly: true
+ }
+};
\ No newline at end of file
use wasm_bindgen::prelude::*;
use web_sys::Document;
-pub fn edit_recipe(doc: &Document) {}
+pub fn edit_recipe(doc: &Document) {
+ let title_input = doc.get_element_by_id("title_field").unwrap();
+}
use wasm_bindgen::prelude::*;
use web_sys::console;
-// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
-// allocator.
-#[cfg(feature = "wee_alloc")]
-#[global_allocator]
-static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
-
#[wasm_bindgen]
extern "C" {
fn alert(s: &str);
let window = web_sys::window().expect("no global `window` exists");
let document = window.document().expect("should have a document on window");
- //let body = document.body().expect("document should have a body");
+ // let body = document.body().expect("document should have a body");
let location = window.location().pathname()?;
let path: Vec<&str> = location.split('/').skip(1).collect();
console_log!("recipe edit ID: {}", id);
handles::edit_recipe(&document);
-
- let title_input = document.get_element_by_id("title_field").unwrap();
}
_ => (),
}
- //alert(&path);
-
// TEST
// let val = document.create_element("p")?;
// val.set_inner_html("Hello from Rust!");
+# See 'package.json'.
npm run serve
\ No newline at end of file
+++ /dev/null
-const path = require('path');
-const HtmlWebpackPlugin = require('html-webpack-plugin');
-const webpack = require('webpack');
-const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
-
-module.exports = {
- entry: './index.js',
- output: {
- path: path.resolve(__dirname, 'dist'),
- filename: 'index.js',
- },
- plugins: [
- new HtmlWebpackPlugin(),
- new WasmPackPlugin({
- crateDirectory: path.resolve(__dirname, ".")
- }),
- // Have this example work in Edge which doesn't ship `TextEncoder` or
- // `TextDecoder` at this time.
- new webpack.ProvidePlugin({
- TextDecoder: ['text-encoding', 'TextDecoder'],
- TextEncoder: ['text-encoding', 'TextEncoder']
- })
- ],
- mode: 'development',
- experiments: {
- asyncWebAssembly: true
- }
-};
\ No newline at end of file