Finish npm exorcism
This commit is contained in:
parent
5ced6ee0bf
commit
918248d3b1
18 changed files with 233 additions and 4503 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -31,3 +31,8 @@ llamafile.git
|
||||||
*/dist/
|
*/dist/
|
||||||
|
|
||||||
.aider*
|
.aider*
|
||||||
|
|
||||||
|
darm_test/style/encr.css
|
||||||
|
darm_test/public/main.*
|
||||||
|
darm_test/public/datastar.*
|
||||||
|
darm_test/public/css/*.css
|
||||||
|
|
4446
Cargo.lock
generated
4446
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -20,7 +20,7 @@ lto = "fat"
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["darm_test", "llama_forge_rs", "llama_proxy_man", "redvault_el_rs"]
|
members = ["darm_test", "llama_proxy_man", "redvault_el_rs"]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
|
|
|
@ -5,6 +5,8 @@ load_cargo_aliases = false
|
||||||
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
|
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
|
||||||
# DB_REPOS
|
# DB_REPOS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[tasks.default]
|
[tasks.default]
|
||||||
alias = "all"
|
alias = "all"
|
||||||
|
|
||||||
|
@ -28,11 +30,11 @@ dependencies = [
|
||||||
|
|
||||||
[tasks.docset]
|
[tasks.docset]
|
||||||
workspace = false
|
workspace = false
|
||||||
dependencies = ["mksitedir", "make-docset", "cp-docset"]
|
dependencies = ["make-docset", "cp-docset"]
|
||||||
|
|
||||||
[tasks.make-docset]
|
[tasks.make-docset]
|
||||||
workspace = false
|
workspace = false
|
||||||
dependencies = ["mksitedir"]
|
dependencies = []
|
||||||
script = "cargo docset --workspace --no-clean --platform-family redvault-ai && sleep 1 && sync"
|
script = "cargo docset --workspace --no-clean --platform-family redvault-ai && sleep 1 && sync"
|
||||||
|
|
||||||
[tasks.cp-docset]
|
[tasks.cp-docset]
|
||||||
|
|
2
darm_test/Makefile.toml
Normal file
2
darm_test/Makefile.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[tasks.pre-build]
|
||||||
|
script = "./scripts/build_css.rs"
|
|
@ -1,6 +1,6 @@
|
||||||
* TODOS (newnewnewest)
|
* TODOS (newnewnewest)
|
||||||
- no npm for css
|
- no npm for css
|
||||||
- finish basic setup with rsass + encro_css + lightningcss
|
- [X] finish basic setup with rsass + encro_css + lightningcss
|
||||||
- encro icons & typography
|
- encro icons & typography
|
||||||
- add encro animate ???
|
- add encro animate ???
|
||||||
- simplify build scripts
|
- simplify build scripts
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
1
darm_test/public/datastar.min.js
vendored
1
darm_test/public/datastar.min.js
vendored
|
@ -1 +0,0 @@
|
||||||
datastar-1-0-0-beta-9-3caff1580ebe0e7c.js
|
|
12
darm_test/public/datastar.min.js
vendored
Normal file
12
darm_test/public/datastar.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
darm_test/public/styles.min.css
vendored
1
darm_test/public/styles.min.css
vendored
File diff suppressed because one or more lines are too long
139
darm_test/scripts/build_css.rs
Executable file
139
darm_test/scripts/build_css.rs
Executable file
|
@ -0,0 +1,139 @@
|
||||||
|
#!/usr/bin/env rust-script
|
||||||
|
//! This is a regular crate doc comment, but it also contains a partial
|
||||||
|
//! Cargo manifest. Note the use of a *fenced* code block, and the
|
||||||
|
//! `cargo` "language".
|
||||||
|
//!
|
||||||
|
//! ```cargo
|
||||||
|
//! [dependencies]
|
||||||
|
//! encre-css = "0.14"
|
||||||
|
//! walkdir = "2"
|
||||||
|
//! grass = { version = "0.13.4", features = ["macro", "nightly"] }
|
||||||
|
//! lightningcss = { version = "1.0.0-alpha.65", features = ["bundler", "browserslist"] }
|
||||||
|
//! anyhow = "1"
|
||||||
|
//! async-compression = { version = "0.4", features = ["tokio", "zstd"] }
|
||||||
|
//! tokio = { version = "1", features = [ "full" ] }
|
||||||
|
//! ```
|
||||||
|
use std::{collections::BTreeSet, fs, path::Path};
|
||||||
|
|
||||||
|
use async_compression::tokio::write::ZstdEncoder;
|
||||||
|
use encre_css::{Config, Scanner};
|
||||||
|
use lightningcss::{
|
||||||
|
bundler::{Bundler, FileProvider},
|
||||||
|
stylesheet::{ParserOptions, PrinterOptions},
|
||||||
|
targets::{Browsers, Targets},
|
||||||
|
};
|
||||||
|
use tokio::io::AsyncWriteExt as _; // for `write_all` and `shutdown`
|
||||||
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() -> anyhow::Result<()> {
|
||||||
|
eprintln!("WEGL CSS 💅 © 2025==========================================");
|
||||||
|
eprintln!("look mum no js/npm");
|
||||||
|
eprintln!("Reading! Step 1/5 🚶 (Walking Dirs)");
|
||||||
|
// Walk through the directory structure
|
||||||
|
let contents = WalkDir::new("./")
|
||||||
|
.into_iter()
|
||||||
|
.filter_map(|e| e.ok())
|
||||||
|
.filter(|e| {
|
||||||
|
e.file_type().is_file()
|
||||||
|
&& e.path()
|
||||||
|
.extension()
|
||||||
|
.map_or(false, |ext| ["rs", "scss"].into_iter().any(|e| e == ext))
|
||||||
|
})
|
||||||
|
.map(|entry| {
|
||||||
|
let path = entry.path();
|
||||||
|
// eprintln!("Processing file: {}", path.display());
|
||||||
|
let content = fs::read_to_string(path).expect("Failed to read");
|
||||||
|
let bx = Box::new(content);
|
||||||
|
let static_ref: &'static str = Box::leak(bx);
|
||||||
|
static_ref
|
||||||
|
});
|
||||||
|
|
||||||
|
let config = {
|
||||||
|
let mut config = Config::default();
|
||||||
|
// FIXME TODO Add moar colors
|
||||||
|
|
||||||
|
config.scanner = Scanner::from_fn(|val| {
|
||||||
|
let mut is_arbitrary = false;
|
||||||
|
|
||||||
|
val.split(|ch| {
|
||||||
|
// Escape all characters in arbitrary values prefixed by a dash (used to avoid
|
||||||
|
// ignoring values in, for example, JS arrays, given that they are defined
|
||||||
|
// using square brackets)
|
||||||
|
match ch {
|
||||||
|
'[' => {
|
||||||
|
is_arbitrary = true;
|
||||||
|
false
|
||||||
|
}
|
||||||
|
']' => {
|
||||||
|
is_arbitrary = false;
|
||||||
|
false
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
ch == ' '
|
||||||
|
|| (!is_arbitrary
|
||||||
|
&& ['.', '\'', '"', '`', '\n'].into_iter().any(|c| c == ch))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect::<BTreeSet<&str>>()
|
||||||
|
});
|
||||||
|
|
||||||
|
// config
|
||||||
|
// .theme
|
||||||
|
// .colors
|
||||||
|
// .add("blue-500", "oklch(.623 .214 259.815)");
|
||||||
|
// config.theme.colors.add("blue", "rgb(.1, .1, .9)");
|
||||||
|
config
|
||||||
|
};
|
||||||
|
|
||||||
|
eprintln!("Building Utilities Step 2/5 ⚙️ (EncrCSS)");
|
||||||
|
let generated = encre_css::generate(contents, &config);
|
||||||
|
tokio::fs::write("./public/css/encr.css", &generated).await?;
|
||||||
|
tokio::fs::write("./style/encr.css", &generated).await?;
|
||||||
|
|
||||||
|
eprintln!("Compiling SCSS Step 3/5 🏗 (Grass Compile)");
|
||||||
|
let compiled = grass::from_path("./style/main.scss", &grass::Options::default())?;
|
||||||
|
tokio::fs::write("./public/css/main.css", compiled.clone()).await?;
|
||||||
|
|
||||||
|
eprintln!("Bundling & Minifying Step 4/5 ⚡️ (Lightning CSS)");
|
||||||
|
let fs: FileProvider = FileProvider::new();
|
||||||
|
let fs: &'static _ = Box::leak(Box::new(fs)); // yolo it's a script, and we need a 'static ref
|
||||||
|
let mut bundler = Bundler::new(fs, None, ParserOptions::default());
|
||||||
|
let stylesheet = bundler.bundle(Path::new("./public/css/main.css"))?;
|
||||||
|
|
||||||
|
// Serialize it to a string.
|
||||||
|
let optimized_opts = PrinterOptions {
|
||||||
|
minify: true,
|
||||||
|
targets: Targets {
|
||||||
|
browsers: Browsers::from_browserslist([
|
||||||
|
"> 0.5%, last 3 versions, Firefox ESR, not dead"
|
||||||
|
])?,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
let res = stylesheet.to_css(Default::default()).unwrap();
|
||||||
|
let opt_res = stylesheet.to_css(optimized_opts).unwrap();
|
||||||
|
|
||||||
|
// println!("{}", res.code);
|
||||||
|
tokio::fs::write("./public/main.css", res.code.clone()).await?;
|
||||||
|
tokio::fs::write("./public/main.min.css", opt_res.code).await?;
|
||||||
|
|
||||||
|
eprintln!("Compressing... Step 5/5 🐁️ (Zstd)");
|
||||||
|
async fn compress(in_data: &[u8]) -> anyhow::Result<Vec<u8>> {
|
||||||
|
let mut encoder = ZstdEncoder::new(Vec::new());
|
||||||
|
encoder.write_all(in_data).await?;
|
||||||
|
encoder.shutdown().await?;
|
||||||
|
Ok(encoder.into_inner())
|
||||||
|
}
|
||||||
|
|
||||||
|
// tokio::fs::write(
|
||||||
|
// "./public/main.min.css.zstd",
|
||||||
|
// compress(res.code.as_bytes()).await?,
|
||||||
|
// )
|
||||||
|
// .await?;
|
||||||
|
|
||||||
|
eprintln!("Done ! =====================================================");
|
||||||
|
Ok(())
|
||||||
|
}
|
|
@ -1,79 +0,0 @@
|
||||||
#!/usr/bin/env rust-script
|
|
||||||
//! This is a regular crate doc comment, but it also contains a partial
|
|
||||||
//! Cargo manifest. Note the use of a *fenced* code block, and the
|
|
||||||
//! `cargo` "language".
|
|
||||||
//!
|
|
||||||
//! ```cargo
|
|
||||||
//! [dependencies]
|
|
||||||
//! encre-css = "0.14"
|
|
||||||
//! walkdir = "2"
|
|
||||||
//! ```
|
|
||||||
|
|
||||||
use std::{
|
|
||||||
collections::BTreeSet,
|
|
||||||
fs::{self, File},
|
|
||||||
io::{self, Write},
|
|
||||||
path::Path,
|
|
||||||
};
|
|
||||||
|
|
||||||
use encre_css::{utils::split_ignore_arbitrary, Config, Scanner};
|
|
||||||
use walkdir::WalkDir;
|
|
||||||
|
|
||||||
fn main() -> io::Result<()> {
|
|
||||||
// Define the source directory to scan
|
|
||||||
let source_dir = "./"; // Change this to your source directory
|
|
||||||
|
|
||||||
eprintln!("Scanning directory: {}", source_dir);
|
|
||||||
|
|
||||||
// Walk through the directory structure
|
|
||||||
let contents = WalkDir::new(source_dir)
|
|
||||||
.into_iter()
|
|
||||||
.filter_map(|e| e.ok())
|
|
||||||
.filter(|e| {
|
|
||||||
e.file_type().is_file()
|
|
||||||
&& e.path()
|
|
||||||
.extension()
|
|
||||||
.map_or(false, |ext| ext == "rs" || ext == "scss")
|
|
||||||
})
|
|
||||||
.map(|entry| {
|
|
||||||
let path = entry.path();
|
|
||||||
eprintln!("Processing file: {}", path.display());
|
|
||||||
let content = fs::read_to_string(path).expect("Failed to read");
|
|
||||||
let bx = Box::new(content);
|
|
||||||
let static_ref: &'static str = Box::leak(bx);
|
|
||||||
static_ref
|
|
||||||
});
|
|
||||||
|
|
||||||
let mut config = Config::default();
|
|
||||||
config.scanner = Scanner::from_fn(|val| {
|
|
||||||
let mut is_arbitrary = false;
|
|
||||||
|
|
||||||
val.split(|ch| {
|
|
||||||
// Escape all characters in arbitrary values prefixed by a dash (used to avoid
|
|
||||||
// ignoring values in, for example, JS arrays, given that they are defined
|
|
||||||
// using square brackets)
|
|
||||||
match ch {
|
|
||||||
'[' => {
|
|
||||||
is_arbitrary = true;
|
|
||||||
false
|
|
||||||
}
|
|
||||||
']' => {
|
|
||||||
is_arbitrary = false;
|
|
||||||
false
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
ch == ' '
|
|
||||||
|| (!is_arbitrary
|
|
||||||
&& (ch == '.' || ch == '\'' || ch == '"' || ch == '`' || ch == '\n'))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect::<BTreeSet<&str>>()
|
|
||||||
});
|
|
||||||
|
|
||||||
let generated = encre_css::generate(contents, &config);
|
|
||||||
|
|
||||||
println!("{generated}");
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
|
@ -11,7 +11,7 @@ pub fn main_page(body: impl Renderable) -> impl Renderable {
|
||||||
meta name="viewport" content="width=device-width, initial-scale=1.0";
|
meta name="viewport" content="width=device-width, initial-scale=1.0";
|
||||||
title { "LLM Chat App" }
|
title { "LLM Chat App" }
|
||||||
script type="module" src="/dist/datastar.min.js" {}
|
script type="module" src="/dist/datastar.min.js" {}
|
||||||
link rel="stylesheet" href="/dist/styles.min.css";
|
link rel="stylesheet" href="/dist/main.min.css";
|
||||||
link rel="icon" href="/dist/favicon.ico";
|
link rel="icon" href="/dist/favicon.ico";
|
||||||
}
|
}
|
||||||
body class="bg-gray-100" {
|
body class="bg-gray-100" {
|
||||||
|
|
|
@ -54,6 +54,8 @@ impl UiController {
|
||||||
|
|
||||||
tokio::time::sleep(Duration::from_millis(250)).await;
|
tokio::time::sleep(Duration::from_millis(250)).await;
|
||||||
|
|
||||||
|
// bg-blue-500
|
||||||
|
// .bg-blue-500
|
||||||
yield MergeFragments::new(maud! { div #llm-1 class="mb-2 animated animated-bounce" { strong { "LLM:" } "This is a mock response."} }.render())
|
yield MergeFragments::new(maud! { div #llm-1 class="mb-2 animated animated-bounce" { strong { "LLM:" } "This is a mock response."} }.render())
|
||||||
.selector("#chat")
|
.selector("#chat")
|
||||||
.merge_mode(FragmentMergeMode::Append)
|
.merge_mode(FragmentMergeMode::Append)
|
||||||
|
@ -75,7 +77,7 @@ impl UiController {
|
||||||
}
|
}
|
||||||
form id="chat-form" {
|
form id="chat-form" {
|
||||||
textarea #user-input .p-2 .m-2 .w-full .rounded-lg .border data-bind-msginput placeholder="Type your message..." {}
|
textarea #user-input .p-2 .m-2 .w-full .rounded-lg .border data-bind-msginput placeholder="Type your message..." {}
|
||||||
button #send-btn class="btn" type="button" data-on-click="@get('/msg')" {
|
button #send-btn .bg-blue-500 .rounded-lg .text-white .p-2 type="button" data-on-click="@get('/msg')" {
|
||||||
"Send"
|
"Send"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,2 @@
|
||||||
// @use '../../node_modules/@unocss/reset/normalize.css';
|
@import url("encr.css");
|
||||||
@use '../../node_modules/@unocss/reset/tailwind-compat.css';
|
// @use "encr";
|
||||||
// @use '../../node_modules/animate.css/animate.min.css';
|
|
||||||
// @use 'uno';
|
|
||||||
@use 'encr';
|
|
||||||
|
|
||||||
.btn {
|
|
||||||
// p-2 text-white bg-blue-500 rounded-lg
|
|
||||||
@extend .p-2, .text-white, .bg-blue-500, .rounded-lg;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue