Skip to content

Commit

Permalink
cant solve feature flag issue
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Dec 5, 2024
1 parent 1c5f4c4 commit 9900b67
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 43 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

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

7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ members = [
"fastn-js",
"fastn-lang",
"fastn-package",
"fastn-resolved",
"fastn-runtime",
"fastn-update",
"fastn-utils",
Expand All @@ -20,7 +19,7 @@ members = [
"ftd-ast",
"ftd-p1",
]
exclude = ["fastn-wasm-runtime", "fastn-wasm", "integration-tests/wasm", "v0.5"]
exclude = ["fastn-wasm-runtime", "fastn-wasm", "integration-tests/wasm", "v0.5", "fastn-resolved"]
resolver = "2"

[workspace.package]
Expand Down Expand Up @@ -87,14 +86,14 @@ enum-iterator-derive = "0.6"
fastn-ds.path = "fastn-ds"
fastn-update.path = "fastn-update"
fastn-builtins.path = "fastn-builtins"
fastn-resolved = { path = "fastn-resolved", version = "0.1.0" }
fastn-resolved = { path = "fastn-resolved" }
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"
fastn-runtime = { path = "fastn-runtime", features = ["owned-tdoc"] }
fbt-lib.path = "fbt_lib"
fastn-expr.path = "fastn-expr"
format_num = "0.1"
Expand Down
1 change: 1 addition & 0 deletions fastn-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ url.workspace = true
zip.workspace = true
fastn-expr.workspace = true
fastn-resolved.workspace = true
fastn-runtime.workspace = true

[dev-dependencies]
fbt-lib.workspace = true
Expand Down
19 changes: 16 additions & 3 deletions fastn-core/src/package/package_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,25 @@ pub(crate) async fn read_ftd_(
)
.await
}
fastn_core::FTDEdition::FTD2024 => {
todo!()
}
fastn_core::FTDEdition::FTD2024 => read_ftd_2024(config).await,
}
}

async fn read_ftd_2024(_config: &mut fastn_core::RequestConfig) -> fastn_core::Result<FTDResult> {
Ok(FTDResult::Html(
fastn_runtime::render_2024_document(
// Box::new(&mut config.config.ds),
todo!(),
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: 1 addition & 1 deletion fastn-ds/src/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl fastn_ds::DocumentStore {
}

#[async_trait::async_trait]
impl fastn_compiler::SymbolStore for fastn_ds::DocumentStore {
impl fastn_compiler::SymbolStore for &mut fastn_ds::DocumentStore {
async fn lookup(
&mut self,
arena: &mut fastn_unresolved::Arena,
Expand Down
14 changes: 7 additions & 7 deletions fastn-resolved/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[package]
name = "fastn-resolved"
version = "0.1.1"
authors.workspace = true
edition.workspace = true
description.workspace = true
#authors.workspace = true
edition = "2021"
#description.workspace = true
license = "BSD-3-Clause"
repository.workspace = true
homepage.workspace = true
#repository.workspace = true
#homepage.workspace = true

[features]
owned-tdoc = []

[dependencies]
serde.workspace = true
indexmap.workspace = true
serde = "1"
indexmap = "2"

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

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

[dependencies]
fastn-js.workspace = true
Expand All @@ -22,3 +21,6 @@ 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: 18 additions & 0 deletions fastn-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,3 +443,21 @@ pub(crate) fn external_css_files(
// go through needed_symbols and get the external css files
todo!()
}

pub async fn render_2024_document(
symbols: Box<dyn fastn_compiler::SymbolStore + Send>,
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()
}
4 changes: 4 additions & 0 deletions t/.fastn/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"package": "foo",
"all_packages": {}
}
2 changes: 2 additions & 0 deletions t/FASTN.ftd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- import: fastn
-- fastn.package: foo
1 change: 1 addition & 0 deletions t/index.ftd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- ftd#text: hello world
3 changes: 3 additions & 0 deletions v0.5/Cargo.lock

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

2 changes: 1 addition & 1 deletion v0.5/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ homepage = "https://fastn.com"

arcstr = "1"
async-trait = "0.1"
fastn-compiler = { path = "fastn-compiler" }
fastn-compiler = { path = "fastn-compiler", default-features = false }
fastn-core = { path = "fastn-core" }
fastn-section = { path = "fastn-section" }
fastn-resolved = { path = "../fastn-resolved", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion v0.5/fastn-compiler/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 = []
owned-tdoc = ["fastn-resolved/owned-tdoc"]

[dependencies]
async-trait.workspace = true
Expand Down
26 changes: 2 additions & 24 deletions v0.5/fastn/src/commands/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ impl fastn::commands::Render {
let route = config.resolve(self.path.as_str()).await;
match route {
fastn_core::Route::Document(path, data) => {
let html = render_document(
let html = fastn_runtime::render_2024_document(
Box::new(fastn::Symbols {}),
config.auto_imports.clone(),
path.as_str(),
data,
Expand All @@ -16,26 +17,3 @@ impl fastn::commands::Render {
};
}
}

pub(crate) async fn render_document(
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(
Box::new(fastn::Symbols {}),
&source,
"main",
None,
global_aliases,
)
.await
.unwrap();

let h = fastn_runtime::HtmlData::from_cd(o);
h.to_test_html()
}

0 comments on commit 9900b67

Please sign in to comment.