Skip to content

Commit

Permalink
delinked 0.5 from 0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Dec 6, 2024
1 parent 9238a86 commit 8efa4ac
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 192 deletions.
54 changes: 0 additions & 54 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ fastn-core.path = "fastn-core"
fastn-issues.path = "fastn-issues"
fastn-package.path = "fastn-package"
fastn-utils.path = "fastn-utils"
fastn-compiler = { path = "v0.5/fastn-compiler", features = ["owned-tdoc"] }
fastn-unresolved.path = "v0.5/fastn-unresolved"
fastn-runtime = { path = "fastn-runtime", features = ["owned-tdoc"] }
fbt-lib.path = "fbt_lib"
fastn-expr.path = "fastn-expr"
Expand Down
2 changes: 0 additions & 2 deletions fastn-core/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ pub enum FTDEdition {
FTD2022,
#[default]
FTD2023,
FTD2024,
}

impl FTDEdition {
pub(crate) fn from_string(s: &str) -> fastn_core::Result<FTDEdition> {
match s {
"2022" => Ok(FTDEdition::FTD2022),
"2023" => Ok(FTDEdition::FTD2023),
"2024" => Ok(FTDEdition::FTD2024),
t => {
fastn_core::usage_error(format!("Unknown edition `{}`. Help use `2022` instead", t))
}
Expand Down
15 changes: 0 additions & 15 deletions fastn-core/src/package/package_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,24 +393,9 @@ pub(crate) async fn read_ftd_(
)
.await
}
fastn_core::FTDEdition::FTD2024 => read_ftd_2024(config).await,
}
}

async fn read_ftd_2024(config: &fastn_core::RequestConfig) -> fastn_core::Result<FTDResult> {
Ok(FTDResult::Html(
fastn_runtime::render_2024_document(
&config.config.ds,
Default::default(),
"index.ftd",
serde_json::Value::Null,
false,
)
.await
.into_bytes(),
))
}

#[tracing::instrument(name = "read_ftd_2022", skip_all)]
pub(crate) async fn read_ftd_2022(
config: &mut fastn_core::RequestConfig,
Expand Down
2 changes: 0 additions & 2 deletions fastn-ds/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ homepage.workspace = true

[dependencies]
fastn-utils.workspace = true
fastn-compiler.workspace = true
fastn-unresolved.workspace = true
tokio.workspace = true
thiserror.workspace = true
actix-web.workspace = true
Expand Down
1 change: 0 additions & 1 deletion fastn-ds/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ mod user_data;
mod utils;
pub mod wasm;
pub use user_data::UserDataError;
mod symbols;

pub use create_pool::create_pool;

Expand Down
75 changes: 0 additions & 75 deletions fastn-ds/src/symbols.rs

This file was deleted.

5 changes: 1 addition & 4 deletions fastn-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repository.workspace = true
homepage.workspace = true

[features]
owned-tdoc = ["fastn-resolved/owned-tdoc", "fastn-compiler/owned-tdoc"]
owned-tdoc = ["fastn-resolved/owned-tdoc"]

[dependencies]
fastn-js.workspace = true
Expand All @@ -21,6 +21,3 @@ serde.workspace = true
once_cell.workspace = true
sha2.workspace = true
indexmap.workspace = true
fastn-compiler.workspace = true
fastn-unresolved.workspace = true
serde_json.workspace = true
18 changes: 0 additions & 18 deletions fastn-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,21 +443,3 @@ pub(crate) fn external_css_files(
// go through needed_symbols and get the external css files
todo!()
}

pub async fn render_2024_document(
symbols: dyn fastn_compiler::SymbolStore,
global_aliases: fastn_unresolved::AliasesSimple,
path: &str,
_data: serde_json::Value,
_strict: bool,
) -> String {
let source = std::fs::File::open(path)
.and_then(std::io::read_to_string)
.unwrap();
let o = fastn_compiler::compile(symbols, &source, "main", None, global_aliases)
.await
.unwrap();

let h = fastn_runtime::HtmlData::from_cd(o);
h.to_test_html()
}
3 changes: 0 additions & 3 deletions v0.5/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 11 additions & 13 deletions v0.5/fastn-compiler/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const ITERATION_THRESHOLD: usize = 100;
// exposing: y as x
//
pub(crate) struct Compiler {
symbols: Box<dyn fastn_compiler::SymbolStore>,
pub(crate) definitions_used: std::collections::HashSet<fastn_unresolved::Symbol>,
pub(crate) arena: fastn_unresolved::Arena,
pub(crate) definitions: std::collections::HashMap<String, fastn_unresolved::URD>,
Expand All @@ -20,6 +21,7 @@ pub(crate) struct Compiler {

impl Compiler {
fn new(
symbols: Box<dyn fastn_compiler::SymbolStore>,
source: &str,
package: &str,
module: Option<&str>,
Expand All @@ -37,6 +39,7 @@ impl Compiler {

Self {
arena,
symbols,
definitions: std::collections::HashMap::new(),
modules: std::collections::HashMap::new(),
content,
Expand All @@ -49,11 +52,11 @@ impl Compiler {
async fn fetch_unresolved_symbols(
&mut self,
symbols_to_fetch: &std::collections::HashSet<fastn_unresolved::Symbol>,
symbols: &impl fastn_compiler::SymbolStore,
) {
self.definitions_used
.extend(symbols_to_fetch.iter().cloned());
let definitions = symbols
let definitions = self
.symbols
.lookup(&mut self.arena, &self.global_aliases, symbols_to_fetch)
.await;
for definition in definitions {
Expand Down Expand Up @@ -167,10 +170,7 @@ impl Compiler {
stuck_on_symbols
}

async fn compile(
mut self,
symbols: &impl fastn_compiler::SymbolStore,
) -> Result<fastn_resolved::CompiledDocument, fastn_compiler::Error> {
async fn compile(mut self) -> Result<fastn_resolved::CompiledDocument, fastn_compiler::Error> {
// we only make 10 attempts to resolve the document: we need a warning if we are not able to
// resolve the document in 10 attempts.
let mut unresolvable = std::collections::HashSet::new();
Expand All @@ -184,8 +184,7 @@ impl Compiler {
break;
}
// ever_used.extend(&unresolved_symbols);
self.fetch_unresolved_symbols(&unresolved_symbols, &symbols)
.await;
self.fetch_unresolved_symbols(&unresolved_symbols).await;
// this itself has to happen in a loop. we need a warning if we are not able to resolve all
// symbols in 10 attempts.
let mut r = ResolveSymbolsResult::default();
Expand All @@ -200,8 +199,7 @@ impl Compiler {
break;
}
// ever_used.extend(r.need_more_symbols);
self.fetch_unresolved_symbols(&r.need_more_symbols, &symbols)
.await;
self.fetch_unresolved_symbols(&r.need_more_symbols).await;
iterations += 1;
}

Expand Down Expand Up @@ -245,14 +243,14 @@ impl Compiler {
/// earlier we had strict mode here, but to simplify things, now we let the caller convert non-empty
/// warnings from OK part as error, and discard the generated JS.
pub async fn compile(
symbols: impl fastn_compiler::SymbolStore,
symbols: Box<dyn fastn_compiler::SymbolStore + Send>,
source: &str,
package: &str,
module: Option<&str>,
global_aliases: fastn_unresolved::AliasesSimple,
) -> Result<fastn_resolved::CompiledDocument, fastn_compiler::Error> {
Compiler::new(source, package, module, global_aliases)
.compile(&symbols)
Compiler::new(symbols, source, package, module, global_aliases)
.compile()
.await
}

Expand Down
Loading

0 comments on commit 8efa4ac

Please sign in to comment.