Skip to content

Commit

Permalink
v0.5 compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Nov 24, 2024
1 parent 42a46a6 commit 4bb9182
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 533 deletions.
1 change: 1 addition & 0 deletions fastn-resolved/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ owned-tdoc = []

[dependencies]
serde.workspace = true
indexmap.workspace = true

5 changes: 4 additions & 1 deletion fastn-resolved/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,7 @@ impl Definition {
}
}

pub struct CompiledDocument {}
pub struct CompiledDocument {
pub content: Vec<fastn_resolved::ComponentInvocation>,
pub definitions: indexmap::IndexMap<String, fastn_resolved::Definition>,
}
21 changes: 21 additions & 0 deletions fastn-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,3 +422,24 @@ pub fn get_all_asts<'a, T: Iterator<Item = &'a fastn_resolved::Definition>>(
has_rive_components,
}
}

pub(crate) fn external_js_files(
used_definitions: &indexmap::IndexMap<String, &fastn_resolved::Definition>,
) -> Vec<String> {
used_definitions
.values()
.filter_map(|definition| match definition {
fastn_resolved::Definition::WebComponent(web_component) => web_component.js(),
fastn_resolved::Definition::Function(f) => f.js(),
_ => None,
})
.map(ToOwned::to_owned)
.collect()
}

pub(crate) fn external_css_files(
_needed_symbols: &indexmap::IndexMap<String, &fastn_resolved::Definition>,
) -> Vec<String> {
// go through needed_symbols and get the external css files
todo!()
}
6 changes: 1 addition & 5 deletions fastn-runtime/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ fn main() {

let html_str = html.to_test_html();

std::fs::write(
std::path::PathBuf::from("../output.html"),
html_str,
)
.unwrap();
std::fs::write(std::path::PathBuf::from("../output.html"), html_str).unwrap();

// this main should create a HTML file, and store it in current folder as index.html etc.
}
Loading

0 comments on commit 4bb9182

Please sign in to comment.