Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ members = [
"crates/rangular-runtime",
]
exclude = ["demo-leptos", "demo-tauri/src"]
resolver = "2"
resolver = "3"

[workspace.package]
edition = "2021"
edition = "2024"
license = "Apache-2.0"
version = "1.0.2"
authors = ["Interchouette"]
Expand Down
2 changes: 1 addition & 1 deletion crates/rangular-aot/src/emit.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rangular_parser::{builtin_tag_io, classify_bindings, parse, Diagnostic};
use rangular_parser::{Diagnostic, builtin_tag_io, classify_bindings, parse};

use crate::error::{AotIssue, EmitResult, EmitTokens};
use crate::lower::{emit_rust, emit_rust_tokens};
Expand Down
4 changes: 2 additions & 2 deletions crates/rangular-aot/src/glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::cell::RefCell;
use std::rc::Rc;
use std::sync::Arc;

use rangular_expr::{eval_with_pipes, Expr, Host, PipeRegistry, Value};
use rangular_host::{for_implicit_value, EventPayload, LoopScope};
use rangular_expr::{Expr, Host, PipeRegistry, Value, eval_with_pipes};
use rangular_host::{EventPayload, LoopScope, for_implicit_value};
use send_wrapper::SendWrapper;

/// Shared host handle for AOT-generated views.
Expand Down
2 changes: 1 addition & 1 deletion crates/rangular-aot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub use print::tokens_to_rust_source;
pub use rangular_expr;
pub use rangular_host;
pub use rangular_parser;
pub use rangular_parser::{binding_ir, binding_ir_snapshot, IrBinding, IrNode};
pub use rangular_parser::{IrBinding, IrNode, binding_ir, binding_ir_snapshot};

/// Structural binding IR for `source` (shared with runtime parity).
#[must_use]
Expand Down
12 changes: 4 additions & 8 deletions crates/rangular-aot/src/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use proc_macro2::{Literal, Punct, Spacing, TokenStream, TokenTree};
use quote::{format_ident, quote};
use rangular_expr::Expr;
use rangular_parser::{
collect_ng_templates, collect_projection_selects, has_default_projection, select_param_name,
template_outlet_ref, Attr, Element, ForBlock, IfBlock, Node, Projection, Template,
Attr, Element, ForBlock, IfBlock, Node, Projection, Template, collect_ng_templates,
collect_projection_selects, has_default_projection, select_param_name, template_outlet_ref,
};

use crate::error::{AotIssue, EmitResult, EmitTokens};
Expand Down Expand Up @@ -695,16 +695,12 @@ fn event_attr(name: &str, value: &TokenStream) -> TokenStream {
}

const fn sanitize_tag(tag: &str) -> &str {
if tag.is_empty() {
"div"
} else {
tag
}
if tag.is_empty() { "div" } else { tag }
}

#[cfg(test)]
mod coverage_arms {
use super::{lower_one_attr, sanitize_tag, HoistState, Scope};
use super::{HoistState, Scope, lower_one_attr, sanitize_tag};
use rangular_parser::{Attr, Span};

#[test]
Expand Down
23 changes: 13 additions & 10 deletions crates/rangular-aot/tests/host_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::rc::Rc;
use std::sync::Arc;

use rangular_aot::HostCell;
use rangular_expr::{parse, Expr, Host, PipeRegistry, Value};
use rangular_expr::{Expr, Host, PipeRegistry, Value, parse};
use rangular_host::{EventPayload, HostError, LoopScope};

type ValueMap = HashMap<String, Value>;
Expand Down Expand Up @@ -125,10 +125,11 @@ fn host_cell_events_and_value_display_variants() {
cell.emit_dom_event_call("onInput", &handler, "load", String::new());
cell.emit_dom_event_call("onInput", &handler, "focus", "x".into());

assert!(cell
.eval_value(&Expr::Ident("$event".into()))
.as_event()
.is_some());
assert!(
cell.eval_value(&Expr::Ident("$event".into()))
.as_event()
.is_some()
);

let host2 = MapHost::new();
host2.values.borrow_mut().insert(
Expand Down Expand Up @@ -186,11 +187,13 @@ fn host_cell_scoped_bool_none_item_and_event_helpers() {
let cell2 = HostCell::new(seed);
let write = rangular_parser::banana_write_expr(&Expr::Ident("seed".into()));
cell2.emit_dom_event_call("$bananaSet", &write, "click", "1,2".into());
assert!(values
.borrow()
.get("seed")
.and_then(Value::as_event)
.is_some());
assert!(
values
.borrow()
.get("seed")
.and_then(Value::as_event)
.is_some()
);
}

#[test]
Expand Down
12 changes: 7 additions & 5 deletions crates/rangular-aot/tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ fn hostcell_dom_event_passes_dollar_event_to_handler() {
use std::rc::Rc;

use rangular_aot::HostCell;
use rangular_expr::{parse, Host, Value};
use rangular_expr::{Host, Value, parse};
use rangular_host::{EventPayload, HostError};

struct CaptureHost {
Expand Down Expand Up @@ -233,10 +233,12 @@ fn lower_edge_templates() {
"missing_outlet_view",
);
assert!(!unknown.ok());
assert!(unknown
.issues
.iter()
.any(|i| i.message.contains("unknown ngTemplateOutlet")));
assert!(
unknown
.issues
.iter()
.any(|i| i.message.contains("unknown ngTemplateOutlet"))
);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions crates/rangular-css/src/encapsulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ fn strip_comments(css: &str) -> String {
#[cfg(test)]
mod coverage_arms {
use super::{
append_attr, flatten_block, flatten_host, flatten_selector, process_block, take_rule,
ScopeAttrs,
ScopeAttrs, append_attr, flatten_block, flatten_host, flatten_selector, process_block,
take_rule,
};

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/rangular-css/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod encapsulate;
mod error;
mod globals;

pub use encapsulate::{compile_scss, encapsulate, encapsulate_css, ScopeAttrs};
pub use encapsulate::{ScopeAttrs, compile_scss, encapsulate, encapsulate_css};
pub use error::{CssIssue, CssResult};
pub use globals::is_global_selector;

Expand Down
19 changes: 11 additions & 8 deletions crates/rangular-css/tests/encapsulate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rangular_css::{compile_scss, encapsulate, encapsulate_css, ScopeAttrs};
use rangular_css::{ScopeAttrs, compile_scss, encapsulate, encapsulate_css};
use std::path::{Path, PathBuf};

fn fixture_root() -> PathBuf {
Expand Down Expand Up @@ -180,9 +180,10 @@ fn encapsulate_keeps_container_and_has() {
);
assert!(out.ok(), "{:?}", out.issues);
assert!(out.css.contains("@container (max-width: 20rem)"));
assert!(out
.css
.contains(".item-list[_ngcontent-r0]:has(.item-list__implicit)"));
assert!(
out.css
.contains(".item-list[_ngcontent-r0]:has(.item-list__implicit)")
);
assert!(out.css.contains(".item-list__row[_ngcontent-r0]"));
}

Expand Down Expand Up @@ -346,8 +347,10 @@ fn compile_scss_layer_font_and_host_descendants() {

let empty_sel = encapsulate_css(".a,,.b { color: red; }", &scope());
assert!(!empty_sel.ok());
assert!(empty_sel
.issues
.iter()
.any(|i| i.message.contains("empty selector")));
assert!(
empty_sel
.issues
.iter()
.any(|i| i.message.contains("empty selector"))
);
}
2 changes: 1 addition & 1 deletion crates/rangular-expr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod parse_issue;
mod pipe;

pub use ast::{BinOp, Expr, Literal, UnOp};
pub use eval::{eval, eval_with_pipes, EvalError};
pub use eval::{EvalError, eval, eval_with_pipes};
pub use parse::parse;
pub use parse_issue::{IssueSeverity, ParseIssue, ParseResult};
pub use pipe::{PipeFn, PipeRegistry};
Expand Down
42 changes: 25 additions & 17 deletions crates/rangular-expr/tests/eval.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rangular_expr::{eval, parse, BinOp, Expr, Host, Literal, Value};
use rangular_expr::{BinOp, Expr, Host, Literal, Value, eval, parse};
use rangular_host::HostError;

struct Counter;
Expand Down Expand Up @@ -199,38 +199,46 @@ fn parse_error_and_feature_paths() {
assert!(ternary.issues.iter().any(|i| i.message.contains("ternary")));

let bad_ternary = parse("flag ? 1");
assert!(bad_ternary
.issues
.iter()
.any(|i| i.message.contains("expected ':'")));
assert!(
bad_ternary
.issues
.iter()
.any(|i| i.message.contains("expected ':'"))
);

let grouped = parse("(n == 2)");
assert!(grouped.expr.is_some());
assert_eq!(grouped.issues.len(), 0);

let unclosed_paren = parse("(n");
assert!(unclosed_paren
.issues
.iter()
.any(|i| i.message.contains("unclosed")));
assert!(
unclosed_paren
.issues
.iter()
.any(|i| i.message.contains("unclosed"))
);

let call_args = parse("fn(a, b)");
assert!(matches!(call_args.expr, Some(Expr::Call { .. })));

let unclosed_call = parse("fn(a");
assert!(unclosed_call
.issues
.iter()
.any(|i| i.message.contains("unclosed")));
assert!(
unclosed_call
.issues
.iter()
.any(|i| i.message.contains("unclosed"))
);

let escaped = parse(r#""a\"b""#);
assert!(escaped.expr.is_some());

let unclosed_str = parse("'abc");
assert!(unclosed_str
.issues
.iter()
.any(|i| i.message.contains("unclosed string")));
assert!(
unclosed_str
.issues
.iter()
.any(|i| i.message.contains("unclosed string"))
);

let bad_ident = parse("1n");
assert!(bad_ident.expr.is_some() || !bad_ident.issues.is_empty());
Expand Down
2 changes: 1 addition & 1 deletion crates/rangular-host/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod value;

pub use error::HostError;
pub use event::EventPayload;
pub use for_scope::{for_implicit_value, LoopScope};
pub use for_scope::{LoopScope, for_implicit_value};
pub use host::Host;
pub use regex::Regex;
pub use validate::{
Expand Down
2 changes: 1 addition & 1 deletion crates/rangular-host/tests/for_scope.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rangular_host::{for_implicit_value, Value};
use rangular_host::{Value, for_implicit_value};

#[test]
fn for_implicit_index_and_count() {
Expand Down
11 changes: 6 additions & 5 deletions crates/rangular-host/tests/seed_bar.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rangular_expr::{eval, parse, Expr, Host, Value};
use rangular_expr::{Expr, Host, Value, eval, parse};
use rangular_host::HostError;

struct SeedBarHost {
Expand Down Expand Up @@ -87,10 +87,11 @@ fn seed_bar_handlers() {
assert_eq!(host.last_call.as_deref(), Some("onGenerate([])"));

eval(&must_parse("seedChange($event)"), &mut host).unwrap();
assert!(host
.last_call
.as_deref()
.is_some_and(|c| c.starts_with("seedChange(")));
assert!(
host.last_call
.as_deref()
.is_some_and(|c| c.starts_with("seedChange("))
);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions crates/rangular-host/tests/validate.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rangular_host::{
first_error, max_length, max_length_value, min_length, min_length_value, pattern,
pattern_value, required, required_value, show_when_dirty, Regex, Value,
Regex, Value, first_error, max_length, max_length_value, min_length, min_length_value, pattern,
pattern_value, required, required_value, show_when_dirty,
};

#[test]
Expand Down
18 changes: 11 additions & 7 deletions crates/rangular-host/tests/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ fn is_truthy_covers_variants() {
assert!(Value::from(EventPayload::Error).is_truthy());
assert!(Value::from(EventPayload::Load).is_truthy());
assert!(Value::from(EventPayload::Input { value: "a".into() }).is_truthy());
assert!(!Value::from(EventPayload::Input {
value: String::new()
})
.is_truthy());
assert!(
!Value::from(EventPayload::Input {
value: String::new()
})
.is_truthy()
);
assert!(Value::from(EventPayload::Custom(Box::new(Value::Bool(true)))).is_truthy());
assert!(!Value::from(EventPayload::Custom(Box::new(Value::Unit))).is_truthy());
}
Expand Down Expand Up @@ -87,9 +89,11 @@ fn event_payload_labels_and_from_dom() {
);
assert_eq!(EventPayload::Error.demo_label(), "Error");
assert_eq!(EventPayload::Load.demo_label(), "Load");
assert!(EventPayload::Custom(Box::new(Value::Unit))
.demo_label()
.starts_with("Custom("));
assert!(
EventPayload::Custom(Box::new(Value::Unit))
.demo_label()
.starts_with("Custom(")
);
assert_eq!(EventPayload::Click { x: 0, y: 0 }.kind_label(), "click");
assert_eq!(
EventPayload::Input {
Expand Down
4 changes: 2 additions & 2 deletions crates/rangular-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::path::PathBuf;

use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, LitStr};
use syn::{LitStr, parse_macro_input};

#[proc_macro]
pub fn rangular_template(input: TokenStream) -> TokenStream {
Expand Down Expand Up @@ -56,7 +56,7 @@ fn default_fn_name(path: &str) -> String {

#[cfg(test)]
mod tests {
use super::{default_fn_name, TemplateInput};
use super::{TemplateInput, default_fn_name};
use syn::parse_str;

fn resolve_fn_name(input: &TemplateInput) -> String {
Expand Down
2 changes: 1 addition & 1 deletion crates/rangular-parser/src/diag.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::span::{line_col, Span};
use crate::span::{Span, line_col};

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Severity {
Expand Down
Loading