Skip to content

Commit

Permalink
clippy fixes, and some privacy tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Nov 24, 2024
1 parent e0f2997 commit 70898ee
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
23 changes: 11 additions & 12 deletions fastn-resolved-to-js/src/html.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use fastn_resolved_to_js::extensions::{FunctionExt, VariableExt};
use fastn_resolved_to_js::extensions::*;

pub struct HtmlInput {
package: Package,
js: String,
#[expect(unused)]
css_files: Vec<String>,
#[expect(unused)]
js_files: Vec<String>,
doc: dyn fastn_resolved::tdoc::TDoc,
}
Expand Down Expand Up @@ -57,7 +59,7 @@ impl HtmlInput {
}
}

pub fn generate_hash(content: impl AsRef<[u8]>) -> String {
fn generate_hash(content: impl AsRef<[u8]>) -> String {
use sha2::digest::FixedOutput;
use sha2::Digest;
let mut hasher = sha2::Sha256::new();
Expand All @@ -69,15 +71,15 @@ static PRISM_JS_HASH: once_cell::sync::Lazy<String> = once_cell::sync::Lazy::new
format!("prism-{}.js", generate_hash(fastn_js::prism_js().as_str()),)
});

pub fn hashed_prism_js() -> &'static str {
fn hashed_prism_js() -> &'static str {
&PRISM_JS_HASH
}

static MARKDOWN_HASH: once_cell::sync::Lazy<String> = once_cell::sync::Lazy::new(|| {
format!("markdown-{}.js", generate_hash(fastn_js::markdown_js()),)
});

pub fn hashed_markdown_js() -> &'static str {
fn hashed_markdown_js() -> &'static str {
&MARKDOWN_HASH
}

Expand All @@ -88,16 +90,13 @@ static PRISM_CSS_HASH: once_cell::sync::Lazy<String> = once_cell::sync::Lazy::ne
)
});

pub fn hashed_prism_css() -> &'static str {
fn hashed_prism_css() -> &'static str {
&PRISM_CSS_HASH
}

static FTD_JS_HASH: once_cell::sync::OnceCell<String> = once_cell::sync::OnceCell::new();

pub fn hashed_default_ftd_js(
package_name: &str,
doc: &dyn fastn_resolved::tdoc::TDoc,
) -> &'static str {
fn hashed_default_ftd_js(package_name: &str, doc: &dyn fastn_resolved::tdoc::TDoc) -> &'static str {
FTD_JS_HASH.get_or_init(|| {
format!(
"default-{}.js",
Expand All @@ -106,13 +105,13 @@ pub fn hashed_default_ftd_js(
})
}

pub fn all_js_without_test(package_name: &str, doc: &dyn fastn_resolved::tdoc::TDoc) -> String {
fn all_js_without_test(package_name: &str, doc: &dyn fastn_resolved::tdoc::TDoc) -> String {
let all_js = fastn_js::all_js_without_test();
let default_bag_js = fastn_js::to_js(default_bag_into_js_ast(doc).as_slice(), package_name);
format!("{all_js}\n{default_bag_js}")
}

pub fn default_bag_into_js_ast(doc: &dyn fastn_resolved::tdoc::TDoc) -> Vec<fastn_js::Ast> {
fn default_bag_into_js_ast(doc: &dyn fastn_resolved::tdoc::TDoc) -> Vec<fastn_js::Ast> {
let mut ftd_asts = vec![];
let mut export_asts = vec![];
for thing in fastn_builtins::builtins().values() {
Expand Down Expand Up @@ -187,7 +186,7 @@ impl Favicon {
}
}

pub fn available_code_themes() -> String {
fn available_code_themes() -> String {
// TODO Move code from fastn_core::utils::available_code_themes()
"".to_string()
}
15 changes: 7 additions & 8 deletions fastn-resolved-to-js/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
extern crate self as fastn_resolved_to_js;

mod resolver;
pub use resolver::ResolverData;

mod value;
pub use value::Value;

mod element;
use element::Element;

pub mod extensions;
use extensions::*;

mod fastn_type_functions;
mod html;
pub mod utils;
mod value;

use element::Element;
use extensions::*;
pub use html::{Favicon, HtmlInput, Package};
pub use resolver::ResolverData;
pub use value::Value;

pub const CODE_DEFAULT_THEME: &str = "fastn-theme.dark";
pub const REFERENCE: &str = "$";
Expand Down
2 changes: 1 addition & 1 deletion fastn-resolved-to-js/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fn main() {
let c = fastn_resolved::ComponentInvocation {
let _c = fastn_resolved::ComponentInvocation {
id: None,
name: "ftd#text".to_string(),
properties: vec![], // add hello-world caption etc.
Expand Down

0 comments on commit 70898ee

Please sign in to comment.