Compare commits

..

29 Commits

Author SHA1 Message Date
4ffb481634 docs: cleanup readme 2024-07-01 15:55:42 -05:00
6bc9f2ea2e build: unify make and nix builds 2024-07-01 15:55:42 -05:00
ec18d9de97 feat: recipe schema now has a setting for serving count 2024-07-01 15:55:42 -05:00
9249dca202 build: Makefile enhancements 2024-07-01 15:55:42 -05:00
dac4324c8f maint: cleanup some unused nix dependencies 2024-07-01 15:55:42 -05:00
e3c4a01648 refactor: make the wasm builder a little more configurable. 2024-07-01 15:55:42 -05:00
e1735e4243 maint: use resolver "2" 2024-07-01 15:55:42 -05:00
651f0cb264 build: get rid of wasm-pack
It get's doing naughty things with network access.
2024-07-01 15:55:42 -05:00
3e853f51eb build: fix rust-tls resolver issues 2024-07-01 15:55:37 -05:00
251cbfa5c7 build: use rustls 2024-07-01 15:52:37 -05:00
1b6023a03e maint: having the wasm-pack version in the logs is useful 2024-07-01 15:52:37 -05:00
3e675b47f4 fix: Unsafe recursive object use 2024-07-01 15:52:37 -05:00
6f7d44ff83 Alloy models for browser_state 2024-07-01 15:52:37 -05:00
b105ce3f4b Add some models 2024-07-01 15:52:37 -05:00
0ba5f18b22 Display current plan date at the top 2024-07-01 15:52:37 -05:00
a320351041 NOTE comment. 2024-07-01 15:52:37 -05:00
874a5fdb57 cargo fmt 2024-07-01 15:52:37 -05:00
bb092212ac Stop using singular for normalization 2024-07-01 15:52:37 -05:00
9022503e76 Have a packaging unit for measures 2024-07-01 15:52:37 -05:00
94e1987f09 ui: more layout tweaks 2024-07-01 15:52:37 -05:00
a104ef5f47 ui: normalization and font tweaks 2024-07-01 15:52:37 -05:00
dac529e8e8 ui: Typography tweaks 2024-07-01 15:52:37 -05:00
6e0e00c7f3 docs: comments for the event handling in login 2024-07-01 15:52:37 -05:00
8942eb59a5 ui: Menu font sizes 2024-07-01 15:52:37 -05:00
e80953e987 maint: upgrade wasm-bindgen version 2024-07-01 15:52:37 -05:00
c64605f9e7 maint: Use gloo_net directly 2024-07-01 15:52:37 -05:00
d7cea46427 fix: Issue with request blocking occuring on login 2024-07-01 15:52:37 -05:00
45737f24e4 UI: Cleansheet CSS redesign
Initial skeleton and layout is working.
Still needs a bunch of tweaks.
2024-07-01 15:52:37 -05:00
61634cd682 maint: Update rust version in nix flake 2023-12-25 14:19:45 -06:00
11 changed files with 83 additions and 26 deletions

View File

@ -1,5 +1,6 @@
[workspace]
members = [ "recipes", "kitchen", "web", "api" ]
resolver = "2"
[patch.crates-io]
# TODO(jwall): When the fix for RcSignal Binding is released we can drop this patch.

View File

@ -14,6 +14,11 @@
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_dir := $(dir $(mkfile_path))
sqlite_url := sqlite://$(mkfile_dir)/.session_store/store.db
out := dist
project := kitchen
export out
export kitchen
kitchen: wasm kitchen/src/*.rs
cd kitchen; cargo build
@ -27,15 +32,18 @@ static-prep: web/index.html web/favicon.ico web/static/*.css
cp -r web/favicon.ico web/dist/
cp -r web/static web/dist/
wasmrelease: wasmrelease-dist static-prep
wasmrelease: wasm-opt static-prep
wasm-opt: wasmrelease-dist
cd web; sh ../scripts/wasm-opt.sh release
wasmrelease-dist: web/src/*.rs web/src/components/*.rs
cd web; wasm-pack build --mode no-install --release --target web --no-typescript --out-name kitchen_wasm --out-dir dist/
cd web; sh ../scripts/wasm-build.sh release
wasm: wasm-dist static-prep
wasm-dist: web/src/*.rs web/src/components/*.rs
cd web; wasm-pack build --mode no-install --target web --no-typescript --out-dir dist/ --features debug_logs
cd web; sh ../scripts/wasm-build.sh debug
clean:
rm -rf web/dist/*
@ -50,5 +58,5 @@ sqlx-add-%:
sqlx-revert:
cd kitchen; cargo sqlx migrate revert --database-url $(sqlite_url)
sqlx-prepare:
sqlx-prepare: kitchen
cd kitchen; cargo sqlx prepare --database-url $(sqlite_url)

33
flake.lock generated
View File

@ -31,6 +31,24 @@
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1681202837,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"flake": false,
"locked": {
@ -124,6 +142,21 @@
"repo": "rust-overlay",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",

View File

@ -45,6 +45,14 @@
wasm-bindgen = pkgs.callPackage wasm-bindgenGen { inherit pkgs; };
kitchenWasm = kitchenWasmGen {
inherit pkgs rust-wasm wasm-bindgen version;
lockFile = ./Cargo.lock;
outputHashes = {
# I'm maintaining some patches for these so the lockfile hashes are a little
# incorrect. We override those here.
"wasm-web-component-0.2.0" = "sha256-quuPgzGb2F96blHmD3BAUjsWQYbSyJGZl27PVrwL92k=";
"sycamore-0.8.2" = "sha256-D968+8C5EelGGmot9/LkAlULZOf/Cr+1WYXRCMwb1nQ=";
"sqlx-0.6.2" = "sha256-X/LFvtzRfiOIEZJiVzmFvvULPpjhqvI99pSwH7a//GM=";
};
};
kitchen = (kitchenGen {
inherit pkgs version naersk-lib kitchenWasm rust-wasm;

View File

@ -0,0 +1,2 @@
-- Add down migration script here
ALTER TABLE recipes DROP COLUMN serving_count;

View File

@ -0,0 +1,2 @@
-- Add up migration script here
ALTER TABLE recipes ADD column serving_count number;

View File

@ -3,23 +3,18 @@
features ? "",
rust-wasm,
wasm-bindgen,
lockFile,
outputHashes,
}:
with pkgs;
let
pname = "kitchen-wasm";
src = ./../..;
lockFile = ./../../Cargo.lock;
# NOTE(jwall): Because we use wasm-pack directly below we need
# the cargo dependencies to already be installed.
cargoDeps = (pkgs.rustPlatform.importCargoLock { inherit lockFile; outputHashes = {
# I'm maintaining some patches for these so the lockfile hashes are a little
# incorrect. We override those here.
"wasm-web-component-0.2.0" = "sha256-quuPgzGb2F96blHmD3BAUjsWQYbSyJGZl27PVrwL92k=";
"sycamore-0.8.2" = "sha256-D968+8C5EelGGmot9/LkAlULZOf/Cr+1WYXRCMwb1nQ=";
"sqlx-0.6.2" = "sha256-X/LFvtzRfiOIEZJiVzmFvvULPpjhqvI99pSwH7a//GM=";
};
});
cargoDeps = (pkgs.rustPlatform.importCargoLock { inherit lockFile outputHashes; });
in
# TODO(zaphar): I should actually be leveraging naersklib.buildPackage with a postInstall for the optimization and bindgen
stdenv.mkDerivation {
inherit src pname;
version = version;
@ -34,14 +29,13 @@ stdenv.mkDerivation {
'';
# TODO(jwall): Build this from the root rather than the src.
buildPhase = ''
set -x
echo building with wasm-pack
wasm-pack --version
mkdir -p $out
cd web
cp -r static $out
cargo build --lib --release --target wasm32-unknown-unknown --target-dir $out --offline
wasm-bindgen $out/wasm32-unknown-unknown/release/kitchen_wasm.wasm --out-dir $out --typescript --target web
sh ../scripts/wasm-build.sh release
#cargo build --lib --release --target wasm32-unknown-unknown --target-dir $out ${features} --offline
#wasm-bindgen $out/wasm32-unknown-unknown/release/kitchen_wasm.wasm --out-dir $out --typescript --target web
#sh ../scripts/wasm-opt.sh release
wasm-opt $out/kitchen_wasm_bg.wasm -o $out/kitchen_wasm_bg-opt.wasm -O
rm -f $out/kitchen_wasm_bg.wasm
mv $out/kitchen_wasm_bg-opt.wasm $out/kitchen_wasm_bg.wasm

View File

@ -8,9 +8,7 @@ in
, nodejs
, pkg-config
, openssl
, stdenv
, curl
, runCommand
}:
# This package is special so we don't use the naersk infrastructure to build it.

View File

@ -6,10 +6,6 @@ A web assembly experiment in Meal Planning and Shopping List management.
Ensure you have rust installed with support for the web assembly target. You can see instructions here: [Rust wasm book](https://rustwasm.github.io/docs/book/game-of-life/setup.html).
You will also want to have trunk installed. You can see instructions for that here: [trunk](https://trunkrs.dev/)
Then obtain the source. We do not at this time publish kitchen on [crates.io](https://crates.io/).
```sh
git clone https://github.com/zaphar/kitchen
cd kitchen
@ -23,7 +19,7 @@ make release
# Hacking on kitchen
If you want to hack on kitchen, then you may find it useful to use trunk in dev mode. The run script will run build the app and run trunk with it watching for changes and reloading on demand in your browser.
The run script will run build the app and run it for you.
```sh
./run.sh
@ -37,4 +33,4 @@ If all of the above looks like too much work, and you already use the nix packag
```sh
nix run github:zaphar/kitchen
```
```

9
scripts/wasm-build.sh Normal file
View File

@ -0,0 +1,9 @@
set -x
buildtype=$1;
if [ ${buildtype} = "release" ]; then
buildtype_flag="--release"
fi
cargo build --lib ${buildtype_flag} --target wasm32-unknown-unknown --target-dir $out --features debug_logs
wasm-bindgen $out/wasm32-unknown-unknown/${buildtype}/kitchen_wasm.wasm --out-dir $out --typescript --target web

6
scripts/wasm-opt.sh Normal file
View File

@ -0,0 +1,6 @@
set -x
buildtype=$1;
wasm-opt $out/wasm32-unknown-unkown/${buildtype}/${project}_wasm.wasm --out-dir dist/ -O
rm -f $out/${project}_wasm_bg.wasm
mv $out/${project}_wasm_bg-opt.wasm dist/${project}_wasm_bg.wasm