From d46e238fe140b394deff40dad0462e4c457e8cc9 Mon Sep 17 00:00:00 2001 From: Amit Upadhyay Date: Sun, 24 Nov 2024 21:07:49 +0530 Subject: [PATCH] some progress compiling --- Cargo.lock | 5 +- fastn-core/src/package/package_doc.rs | 2 +- fastn-core/src/utils.rs | 4 +- fastn-runtime/src/element.rs | 694 ++++++++++------------ fastn-runtime/src/extensions.rs | 34 +- fastn-runtime/src/fastn_type_functions.rs | 133 ++--- fastn-runtime/src/html.rs | 11 +- fastn-runtime/src/lib.rs | 34 +- fastn-runtime/src/main.rs | 10 +- fastn-runtime/src/utils.rs | 36 +- fastn-runtime/src/value.rs | 66 +- ftd/Cargo.toml | 2 +- ftd/src/executor/main.rs | 2 +- ftd/src/interpreter/things/component.rs | 2 +- ftd/src/js/mod.rs | 12 +- 15 files changed, 485 insertions(+), 562 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6008cc63b..86e5f1519 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1611,11 +1611,12 @@ dependencies = [ name = "fastn-resolved" version = "0.1.1" dependencies = [ + "indexmap", "serde", ] [[package]] -name = "fastn-resolved-to-js" +name = "fastn-runtime" version = "0.1.0" dependencies = [ "fastn-builtins", @@ -1747,7 +1748,7 @@ dependencies = [ "fastn-builtins", "fastn-js", "fastn-resolved", - "fastn-resolved-to-js", + "fastn-runtime", "format_num", "ftd-ast", "ftd-p1", diff --git a/fastn-core/src/package/package_doc.rs b/fastn-core/src/package/package_doc.rs index ba098bbb1..b489b3ce5 100644 --- a/fastn-core/src/package/package_doc.rs +++ b/fastn-core/src/package/package_doc.rs @@ -368,7 +368,7 @@ pub(crate) async fn read_ftd_( test: bool, only_js: bool, preview_session_id: &Option, -) -> fastn_core::Result { +) -> fastn_core::Result { tracing::info!(document = main.id); match config.config.ftd_edition { fastn_core::FTDEdition::FTD2022 => { diff --git a/fastn-core/src/utils.rs b/fastn-core/src/utils.rs index 1088d2d9e..bdaf71727 100644 --- a/fastn-core/src/utils.rs +++ b/fastn-core/src/utils.rs @@ -631,7 +631,7 @@ pub async fn replace_markers_2022( font_style: &str, base_url: &str, session_id: &Option, -) -> String { +) -> fastn_resolved::CompiledDocument { ftd::html::utils::trim_all_lines( s.replace( "__ftd_meta_data__", @@ -731,7 +731,7 @@ pub async fn replace_markers_2023( base_url: &str, config: &fastn_core::Config, session_id: &Option, -) -> String { +) -> fastn_resolved::CompiledDocument { format!( include_str!("../../ftd/ftd-js.html"), fastn_package = get_fastn_package_data(&config.package).as_str(), diff --git a/fastn-runtime/src/element.rs b/fastn-runtime/src/element.rs index 0f9012215..976b7e066 100644 --- a/fastn-runtime/src/element.rs +++ b/fastn-runtime/src/element.rs @@ -2,7 +2,7 @@ #![allow(renamed_and_removed_lints)] #![allow(too_many_arguments)] -use fastn_resolved_to_js::extensions::*; +use fastn_runtime::extensions::*; #[derive(Debug)] pub enum Element { @@ -59,7 +59,7 @@ impl Element { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, should_return: bool, has_rive_components: &mut bool, ) -> Vec { @@ -147,8 +147,8 @@ impl Element { #[derive(Debug)] pub struct CheckBox { - pub enabled: Option, - pub checked: Option, + pub enabled: Option, + pub checked: Option, pub common: Common, } @@ -162,12 +162,12 @@ impl CheckBox { .unwrap(); CheckBox { - enabled: fastn_resolved_to_js::value::get_optional_js_value( + enabled: fastn_runtime::value::get_optional_js_value( "enabled", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - checked: fastn_resolved_to_js::value::get_optional_js_value( + checked: fastn_runtime::value::get_optional_js_value( "checked", component.properties.as_slice(), component_definition.arguments.as_slice(), @@ -185,7 +185,7 @@ impl CheckBox { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &mut fastn_resolved_to_js::ResolverData, + rdata: &mut fastn_runtime::ResolverData, should_return: bool, ) -> Vec { let mut component_statements = vec![]; @@ -229,13 +229,13 @@ impl CheckBox { #[derive(Debug)] pub struct TextInput { - pub placeholder: Option, - pub multiline: Option, - pub max_length: Option, - pub _type: Option, - pub value: Option, - pub default_value: Option, - pub enabled: Option, + pub placeholder: Option, + pub multiline: Option, + pub max_length: Option, + pub _type: Option, + pub value: Option, + pub default_value: Option, + pub enabled: Option, pub common: Common, } @@ -249,37 +249,37 @@ impl TextInput { .unwrap(); TextInput { - placeholder: fastn_resolved_to_js::value::get_optional_js_value( + placeholder: fastn_runtime::value::get_optional_js_value( "placeholder", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - multiline: fastn_resolved_to_js::value::get_optional_js_value( + multiline: fastn_runtime::value::get_optional_js_value( "multiline", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - _type: fastn_resolved_to_js::value::get_optional_js_value( + _type: fastn_runtime::value::get_optional_js_value( "type", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - value: fastn_resolved_to_js::value::get_optional_js_value( + value: fastn_runtime::value::get_optional_js_value( "value", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - default_value: fastn_resolved_to_js::value::get_optional_js_value( + default_value: fastn_runtime::value::get_optional_js_value( "default-value", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - enabled: fastn_resolved_to_js::value::get_optional_js_value( + enabled: fastn_runtime::value::get_optional_js_value( "enabled", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - max_length: fastn_resolved_to_js::value::get_optional_js_value( + max_length: fastn_runtime::value::get_optional_js_value( "max-length", component.properties.as_slice(), component_definition.arguments.as_slice(), @@ -297,7 +297,7 @@ impl TextInput { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &mut fastn_resolved_to_js::ResolverData, + rdata: &mut fastn_runtime::ResolverData, should_return: bool, ) -> Vec { let mut component_statements = vec![]; @@ -392,10 +392,10 @@ impl TextInput { #[derive(Debug)] pub struct Iframe { pub common: Common, - pub src: Option, - pub srcdoc: Option, - pub youtube: Option, - pub loading: Option, + pub src: Option, + pub srcdoc: Option, + pub youtube: Option, + pub loading: Option, } impl Iframe { @@ -413,22 +413,22 @@ impl Iframe { component_definition.arguments.as_slice(), component.events.as_slice(), ), - src: fastn_resolved_to_js::value::get_optional_js_value( + src: fastn_runtime::value::get_optional_js_value( "src", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - srcdoc: fastn_resolved_to_js::value::get_optional_js_value( + srcdoc: fastn_runtime::value::get_optional_js_value( "srcdoc", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - loading: fastn_resolved_to_js::value::get_optional_js_value( + loading: fastn_runtime::value::get_optional_js_value( "loading", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - youtube: fastn_resolved_to_js::value::get_optional_js_value( + youtube: fastn_runtime::value::get_optional_js_value( "youtube", component.properties.as_slice(), component_definition.arguments.as_slice(), @@ -441,7 +441,7 @@ impl Iframe { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &mut fastn_resolved_to_js::ResolverData, + rdata: &mut fastn_runtime::ResolverData, should_return: bool, ) -> Vec { let mut component_statements = vec![]; @@ -510,10 +510,10 @@ impl Iframe { pub struct Code { pub common: Common, pub text_common: TextCommon, - pub code: fastn_resolved_to_js::Value, - pub lang: fastn_resolved_to_js::Value, - pub theme: fastn_resolved_to_js::Value, - pub show_line_number: fastn_resolved_to_js::Value, + pub code: fastn_runtime::Value, + pub lang: fastn_runtime::Value, + pub theme: fastn_runtime::Value, + pub show_line_number: fastn_runtime::Value, } impl Code { @@ -538,28 +538,26 @@ impl Code { component.properties.as_slice(), component_definition.arguments.as_slice(), ), - // code: fastn_resolved_to_js::Value::from_str_value(stylized_code.as_str()), - code: fastn_resolved_to_js::value::get_optional_js_value( + // code: fastn_runtime::Value::from_str_value(stylized_code.as_str()), + code: fastn_runtime::value::get_optional_js_value( "text", component.properties.as_slice(), component_definition.arguments.as_slice(), ) .unwrap(), - lang: fastn_resolved_to_js::value::get_js_value_with_default( + lang: fastn_runtime::value::get_js_value_with_default( "lang", component.properties.as_slice(), component_definition.arguments.as_slice(), - fastn_resolved_to_js::Value::from_str_value("txt"), + fastn_runtime::Value::from_str_value("txt"), ), - theme: fastn_resolved_to_js::value::get_js_value_with_default( + theme: fastn_runtime::value::get_js_value_with_default( "theme", component.properties.as_slice(), component_definition.arguments.as_slice(), - fastn_resolved_to_js::Value::from_str_value( - fastn_resolved_to_js::CODE_DEFAULT_THEME, - ), + fastn_runtime::Value::from_str_value(fastn_runtime::CODE_DEFAULT_THEME), ), - show_line_number: fastn_resolved_to_js::value::get_optional_js_value_with_default( + show_line_number: fastn_runtime::value::get_optional_js_value_with_default( "show-line-number", component.properties.as_slice(), component_definition.arguments.as_slice(), @@ -573,7 +571,7 @@ impl Code { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &mut fastn_resolved_to_js::ResolverData, + rdata: &mut fastn_runtime::ResolverData, should_return: bool, ) -> Vec { let mut component_statements = vec![]; @@ -639,10 +637,10 @@ impl Code { #[derive(Debug)] pub struct Image { - pub src: fastn_resolved_to_js::Value, - pub fit: Option, - pub alt: Option, - pub fetch_priority: Option, + pub src: fastn_runtime::Value, + pub fit: Option, + pub alt: Option, + pub fetch_priority: Option, pub common: Common, } @@ -655,23 +653,23 @@ impl Image { .component() .unwrap(); Image { - src: fastn_resolved_to_js::value::get_optional_js_value( + src: fastn_runtime::value::get_optional_js_value( "src", component.properties.as_slice(), component_definition.arguments.as_slice(), ) .unwrap(), - fit: fastn_resolved_to_js::value::get_optional_js_value( + fit: fastn_runtime::value::get_optional_js_value( "fit", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - fetch_priority: fastn_resolved_to_js::value::get_optional_js_value( + fetch_priority: fastn_runtime::value::get_optional_js_value( "fetch-priority", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - alt: fastn_resolved_to_js::value::get_optional_js_value( + alt: fastn_runtime::value::get_optional_js_value( "alt", component.properties.as_slice(), component_definition.arguments.as_slice(), @@ -689,7 +687,7 @@ impl Image { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &mut fastn_resolved_to_js::ResolverData, + rdata: &mut fastn_runtime::ResolverData, should_return: bool, ) -> Vec { let mut component_statements = vec![]; @@ -750,11 +748,11 @@ impl Image { #[derive(Debug)] pub struct Audio { - pub src: fastn_resolved_to_js::Value, - pub controls: Option, - pub loop_: Option, - pub muted: Option, - pub autoplay: Option, + pub src: fastn_runtime::Value, + pub controls: Option, + pub loop_: Option, + pub muted: Option, + pub autoplay: Option, pub common: Common, } @@ -767,28 +765,28 @@ impl Audio { .component() .unwrap(); Audio { - src: fastn_resolved_to_js::value::get_optional_js_value( + src: fastn_runtime::value::get_optional_js_value( "src", component.properties.as_slice(), component_definition.arguments.as_slice(), ) .unwrap(), - autoplay: fastn_resolved_to_js::value::get_optional_js_value( + autoplay: fastn_runtime::value::get_optional_js_value( "autoplay", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - controls: fastn_resolved_to_js::value::get_optional_js_value( + controls: fastn_runtime::value::get_optional_js_value( "controls", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - loop_: fastn_resolved_to_js::value::get_optional_js_value( + loop_: fastn_runtime::value::get_optional_js_value( "loop", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - muted: fastn_resolved_to_js::value::get_optional_js_value( + muted: fastn_runtime::value::get_optional_js_value( "muted", component.properties.as_slice(), component_definition.arguments.as_slice(), @@ -806,7 +804,7 @@ impl Audio { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &mut fastn_resolved_to_js::ResolverData, + rdata: &mut fastn_runtime::ResolverData, should_return: bool, ) -> Vec { let mut component_statements = vec![]; @@ -876,13 +874,13 @@ impl Audio { } #[derive(Debug)] pub struct Video { - pub src: fastn_resolved_to_js::Value, - pub fit: Option, - pub controls: Option, - pub loop_video: Option, - pub muted: Option, - pub autoplay: Option, - pub poster: Option, + pub src: fastn_runtime::Value, + pub fit: Option, + pub controls: Option, + pub loop_video: Option, + pub muted: Option, + pub autoplay: Option, + pub poster: Option, pub common: Common, } @@ -895,38 +893,38 @@ impl Video { .component() .unwrap(); Video { - src: fastn_resolved_to_js::value::get_optional_js_value( + src: fastn_runtime::value::get_optional_js_value( "src", component.properties.as_slice(), component_definition.arguments.as_slice(), ) .unwrap(), - fit: fastn_resolved_to_js::value::get_optional_js_value( + fit: fastn_runtime::value::get_optional_js_value( "fit", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - autoplay: fastn_resolved_to_js::value::get_optional_js_value( + autoplay: fastn_runtime::value::get_optional_js_value( "autoplay", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - controls: fastn_resolved_to_js::value::get_optional_js_value( + controls: fastn_runtime::value::get_optional_js_value( "controls", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - loop_video: fastn_resolved_to_js::value::get_optional_js_value( + loop_video: fastn_runtime::value::get_optional_js_value( "loop", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - muted: fastn_resolved_to_js::value::get_optional_js_value( + muted: fastn_runtime::value::get_optional_js_value( "muted", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - poster: fastn_resolved_to_js::value::get_optional_js_value( + poster: fastn_runtime::value::get_optional_js_value( "poster", component.properties.as_slice(), component_definition.arguments.as_slice(), @@ -944,7 +942,7 @@ impl Video { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &mut fastn_resolved_to_js::ResolverData, + rdata: &mut fastn_runtime::ResolverData, should_return: bool, ) -> Vec { let mut component_statements = vec![]; @@ -1035,28 +1033,28 @@ impl Video { #[derive(Debug)] pub struct Text { - pub text: fastn_resolved_to_js::Value, + pub text: fastn_runtime::Value, pub common: Common, pub text_common: TextCommon, } #[derive(Debug)] pub struct Integer { - pub value: fastn_resolved_to_js::Value, + pub value: fastn_runtime::Value, pub common: Common, pub text_common: TextCommon, } #[derive(Debug)] pub struct Decimal { - pub value: fastn_resolved_to_js::Value, + pub value: fastn_runtime::Value, pub common: Common, pub text_common: TextCommon, } #[derive(Debug)] pub struct Boolean { - pub value: fastn_resolved_to_js::Value, + pub value: fastn_runtime::Value, pub common: Common, pub text_common: TextCommon, } @@ -1064,23 +1062,23 @@ pub struct Boolean { #[derive(Debug)] pub struct Document { pub container: Container, - pub breakpoint_width: Option, + pub breakpoint_width: Option, pub metadata: DocumentMeta, } #[derive(Debug)] pub struct DocumentMeta { - pub title: Option, - pub favicon: Option, - pub og_title: Option, - pub twitter_title: Option, - pub description: Option, - pub og_description: Option, - pub twitter_description: Option, - pub facebook_domain_verification: Option, - pub og_image: Option, - pub twitter_image: Option, - pub theme_color: Option, + pub title: Option, + pub favicon: Option, + pub og_title: Option, + pub twitter_title: Option, + pub description: Option, + pub og_description: Option, + pub twitter_description: Option, + pub facebook_domain_verification: Option, + pub og_image: Option, + pub twitter_image: Option, + pub theme_color: Option, } #[derive(Debug)] @@ -1092,16 +1090,16 @@ pub struct Column { #[derive(Debug)] pub struct InheritedProperties { - pub colors: Option, - pub types: Option, + pub colors: Option, + pub types: Option, } #[derive(Debug)] pub struct ContainerProperties { - pub spacing: Option, - pub wrap: Option, - pub align_content: Option, - pub backdrop_filter: Option, + pub spacing: Option, + pub wrap: Option, + pub align_content: Option, + pub backdrop_filter: Option, } impl ContainerProperties { @@ -1110,16 +1108,14 @@ impl ContainerProperties { arguments: &[fastn_resolved::Argument], ) -> ContainerProperties { ContainerProperties { - spacing: fastn_resolved_to_js::value::get_optional_js_value( - "spacing", properties, arguments, - ), - wrap: fastn_resolved_to_js::value::get_optional_js_value("wrap", properties, arguments), - align_content: fastn_resolved_to_js::value::get_optional_js_value( + spacing: fastn_runtime::value::get_optional_js_value("spacing", properties, arguments), + wrap: fastn_runtime::value::get_optional_js_value("wrap", properties, arguments), + align_content: fastn_runtime::value::get_optional_js_value( "align-content", properties, arguments, ), - backdrop_filter: fastn_resolved_to_js::value::get_optional_js_value( + backdrop_filter: fastn_runtime::value::get_optional_js_value( "backdrop-filter", properties, arguments, @@ -1131,7 +1127,7 @@ impl ContainerProperties { &self, element_name: &str, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, ) -> Vec { let mut component_statements = vec![]; if let Some(ref wrap) = self.wrap { @@ -1171,7 +1167,7 @@ impl ContainerProperties { #[derive(Debug)] pub struct Container { - pub children: Option, + pub children: Option, pub inherited: InheritedProperties, } @@ -1181,8 +1177,8 @@ impl Container { arguments: &[fastn_resolved::Argument], ) -> Container { Container { - children: fastn_resolved_to_js::utils::get_js_value_from_properties( - fastn_resolved_to_js::utils::get_children_properties_from_properties(properties) + children: fastn_runtime::utils::get_js_value_from_properties( + fastn_runtime::utils::get_children_properties_from_properties(properties) .as_slice(), ), inherited: InheritedProperties::from(properties, arguments), @@ -1192,7 +1188,7 @@ impl Container { pub(crate) fn to_component_statements( &self, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, has_rive_components: &mut bool, should_return: bool, ) -> Vec { @@ -1253,19 +1249,15 @@ impl InheritedProperties { arguments: &[fastn_resolved::Argument], ) -> InheritedProperties { InheritedProperties { - colors: fastn_resolved_to_js::value::get_optional_js_value( - "colors", properties, arguments, - ), - types: fastn_resolved_to_js::value::get_optional_js_value( - "types", properties, arguments, - ), + colors: fastn_runtime::value::get_optional_js_value("colors", properties, arguments), + types: fastn_runtime::value::get_optional_js_value("types", properties, arguments), } } pub(crate) fn get_inherited_variables( &self, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, component_name: &str, ) -> Option { let mut inherited_fields = vec![]; @@ -1308,7 +1300,7 @@ impl Text { .component() .unwrap(); Text { - text: fastn_resolved_to_js::value::get_optional_js_value( + text: fastn_runtime::value::get_optional_js_value( "text", component.properties.as_slice(), component_definition.arguments.as_slice(), @@ -1331,7 +1323,7 @@ impl Text { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &mut fastn_resolved_to_js::ResolverData, + rdata: &mut fastn_runtime::ResolverData, should_return: bool, ) -> Vec { let mut component_statements = vec![]; @@ -1372,7 +1364,7 @@ impl Integer { .component() .unwrap(); Integer { - value: fastn_resolved_to_js::value::get_optional_js_value( + value: fastn_runtime::value::get_optional_js_value( "value", component.properties.as_slice(), component_definition.arguments.as_slice(), @@ -1395,7 +1387,7 @@ impl Integer { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &mut fastn_resolved_to_js::ResolverData, + rdata: &mut fastn_runtime::ResolverData, should_return: bool, ) -> Vec { let mut component_statements = vec![]; @@ -1437,7 +1429,7 @@ impl Decimal { .component() .unwrap(); Decimal { - value: fastn_resolved_to_js::value::get_optional_js_value( + value: fastn_runtime::value::get_optional_js_value( "value", component.properties.as_slice(), component_definition.arguments.as_slice(), @@ -1460,7 +1452,7 @@ impl Decimal { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &mut fastn_resolved_to_js::ResolverData, + rdata: &mut fastn_runtime::ResolverData, should_return: bool, ) -> Vec { let mut component_statements = vec![]; @@ -1502,7 +1494,7 @@ impl Boolean { .component() .unwrap(); Boolean { - value: fastn_resolved_to_js::value::get_optional_js_value( + value: fastn_runtime::value::get_optional_js_value( "value", component.properties.as_slice(), component_definition.arguments.as_slice(), @@ -1525,7 +1517,7 @@ impl Boolean { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &mut fastn_resolved_to_js::ResolverData, + rdata: &mut fastn_runtime::ResolverData, should_return: bool, ) -> Vec { let mut component_statements = vec![]; @@ -1572,7 +1564,7 @@ impl Document { component.properties.as_slice(), component_definition.arguments.as_slice(), ), - breakpoint_width: fastn_resolved_to_js::value::get_optional_js_value( + breakpoint_width: fastn_runtime::value::get_optional_js_value( "breakpoint", component.properties.as_slice(), component_definition.arguments.as_slice(), @@ -1589,7 +1581,7 @@ impl Document { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &mut fastn_resolved_to_js::ResolverData, + rdata: &mut fastn_runtime::ResolverData, should_return: bool, has_rive_components: &mut bool, ) -> Vec { @@ -1635,49 +1627,45 @@ impl DocumentMeta { arguments: &[fastn_resolved::Argument], ) -> DocumentMeta { DocumentMeta { - favicon: fastn_resolved_to_js::value::get_optional_js_value( - "favicon", properties, arguments, - ), - title: fastn_resolved_to_js::value::get_optional_js_value( - "title", properties, arguments, - ), - og_title: fastn_resolved_to_js::value::get_optional_js_value( + favicon: fastn_runtime::value::get_optional_js_value("favicon", properties, arguments), + title: fastn_runtime::value::get_optional_js_value("title", properties, arguments), + og_title: fastn_runtime::value::get_optional_js_value( "og-title", properties, arguments, ), - twitter_title: fastn_resolved_to_js::value::get_optional_js_value( + twitter_title: fastn_runtime::value::get_optional_js_value( "twitter-title", properties, arguments, ), - description: fastn_resolved_to_js::value::get_optional_js_value( + description: fastn_runtime::value::get_optional_js_value( "description", properties, arguments, ), - og_description: fastn_resolved_to_js::value::get_optional_js_value( + og_description: fastn_runtime::value::get_optional_js_value( "og-description", properties, arguments, ), - twitter_description: fastn_resolved_to_js::value::get_optional_js_value( + twitter_description: fastn_runtime::value::get_optional_js_value( "twitter-description", properties, arguments, ), - og_image: fastn_resolved_to_js::value::get_optional_js_value( + og_image: fastn_runtime::value::get_optional_js_value( "og-image", properties, arguments, ), - twitter_image: fastn_resolved_to_js::value::get_optional_js_value( + twitter_image: fastn_runtime::value::get_optional_js_value( "twitter-image", properties, arguments, ), - theme_color: fastn_resolved_to_js::value::get_optional_js_value( + theme_color: fastn_runtime::value::get_optional_js_value( "theme-color", properties, arguments, ), - facebook_domain_verification: fastn_resolved_to_js::value::get_optional_js_value( + facebook_domain_verification: fastn_runtime::value::get_optional_js_value( "facebook-domain-verification", properties, arguments, @@ -1685,8 +1673,8 @@ impl DocumentMeta { } } - pub fn has_self_reference(&self, value: &fastn_resolved_to_js::Value) -> bool { - if let fastn_resolved_to_js::Value::Reference(reference) = value { + pub fn has_self_reference(&self, value: &fastn_runtime::Value) -> bool { + if let fastn_runtime::Value::Reference(reference) = value { return reference.name.starts_with("ftd#document"); } false @@ -1694,12 +1682,12 @@ impl DocumentMeta { pub fn set_property_value_with_self_reference( &self, - value: &fastn_resolved_to_js::Value, + value: &fastn_runtime::Value, value_kind: fastn_js::PropertyKind, - referenced_value: &Option, + referenced_value: &Option, component_statements: &mut Vec, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, element_name: &str, ) { if self.has_self_reference(value) { @@ -1718,7 +1706,7 @@ impl DocumentMeta { pub(crate) fn to_component_statements( &self, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, element_name: &str, ) -> Vec { let mut component_statements = vec![]; @@ -1874,7 +1862,7 @@ impl Column { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &mut fastn_resolved_to_js::ResolverData, + rdata: &mut fastn_runtime::ResolverData, should_return: bool, has_rive_components: &mut bool, ) -> Vec { @@ -1939,7 +1927,7 @@ impl Row { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &mut fastn_resolved_to_js::ResolverData, + rdata: &mut fastn_runtime::ResolverData, should_return: bool, has_rive_components: &mut bool, ) -> Vec { @@ -2002,7 +1990,7 @@ impl ContainerElement { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &mut fastn_resolved_to_js::ResolverData, + rdata: &mut fastn_runtime::ResolverData, should_return: bool, has_rive_components: &mut bool, ) -> Vec { @@ -2065,7 +2053,7 @@ impl Device { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &mut fastn_resolved_to_js::ResolverData, + rdata: &mut fastn_runtime::ResolverData, should_return: bool, has_rive_components: &mut bool, ) -> Vec { @@ -2107,14 +2095,14 @@ impl Device { #[derive(Debug)] pub struct TextCommon { - pub text_transform: Option, - pub text_indent: Option, - pub text_align: Option, - pub line_clamp: Option, - pub style: Option, - pub display: Option, - pub link_color: Option, - pub text_shadow: Option, + pub text_transform: Option, + pub text_indent: Option, + pub text_align: Option, + pub line_clamp: Option, + pub style: Option, + pub display: Option, + pub link_color: Option, + pub text_shadow: Option, } impl TextCommon { @@ -2123,38 +2111,34 @@ impl TextCommon { arguments: &[fastn_resolved::Argument], ) -> TextCommon { TextCommon { - text_transform: fastn_resolved_to_js::value::get_optional_js_value( + text_transform: fastn_runtime::value::get_optional_js_value( "text-transform", properties, arguments, ), - text_indent: fastn_resolved_to_js::value::get_optional_js_value( + text_indent: fastn_runtime::value::get_optional_js_value( "text-indent", properties, arguments, ), - text_align: fastn_resolved_to_js::value::get_optional_js_value( + text_align: fastn_runtime::value::get_optional_js_value( "text-align", properties, arguments, ), - line_clamp: fastn_resolved_to_js::value::get_optional_js_value( + line_clamp: fastn_runtime::value::get_optional_js_value( "line-clamp", properties, arguments, ), - style: fastn_resolved_to_js::value::get_optional_js_value( - "style", properties, arguments, - ), - display: fastn_resolved_to_js::value::get_optional_js_value( - "display", properties, arguments, - ), - link_color: fastn_resolved_to_js::value::get_optional_js_value( + style: fastn_runtime::value::get_optional_js_value("style", properties, arguments), + display: fastn_runtime::value::get_optional_js_value("display", properties, arguments), + link_color: fastn_runtime::value::get_optional_js_value( "link-color", properties, arguments, ), - text_shadow: fastn_resolved_to_js::value::get_optional_js_value( + text_shadow: fastn_runtime::value::get_optional_js_value( "text-shadow", properties, arguments, @@ -2166,7 +2150,7 @@ impl TextCommon { &self, element_name: &str, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, ) -> Vec { let mut component_statements = vec![]; if let Some(ref transform) = self.text_transform { @@ -2236,12 +2220,12 @@ impl TextCommon { #[derive(Debug)] #[allow(dead_code)] pub struct Rive { - pub src: fastn_resolved_to_js::Value, - pub canvas_width: Option, - pub canvas_height: Option, - pub state_machines: fastn_resolved_to_js::Value, - pub autoplay: fastn_resolved_to_js::Value, - pub artboard: Option, + pub src: fastn_runtime::Value, + pub canvas_width: Option, + pub canvas_height: Option, + pub state_machines: fastn_runtime::Value, + pub autoplay: fastn_runtime::Value, + pub artboard: Option, pub common: Common, } @@ -2255,35 +2239,35 @@ impl Rive { .unwrap(); Rive { - src: fastn_resolved_to_js::value::get_optional_js_value( + src: fastn_runtime::value::get_optional_js_value( "src", component.properties.as_slice(), component_definition.arguments.as_slice(), ) .unwrap(), - canvas_width: fastn_resolved_to_js::value::get_optional_js_value( + canvas_width: fastn_runtime::value::get_optional_js_value( "canvas-width", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - canvas_height: fastn_resolved_to_js::value::get_optional_js_value( + canvas_height: fastn_runtime::value::get_optional_js_value( "canvas-height", component.properties.as_slice(), component_definition.arguments.as_slice(), ), - state_machines: fastn_resolved_to_js::value::get_optional_js_value_with_default( + state_machines: fastn_runtime::value::get_optional_js_value_with_default( "state-machine", component.properties.as_slice(), component_definition.arguments.as_slice(), ) .unwrap(), - autoplay: fastn_resolved_to_js::value::get_optional_js_value_with_default( + autoplay: fastn_runtime::value::get_optional_js_value_with_default( "autoplay", component.properties.as_slice(), component_definition.arguments.as_slice(), ) .unwrap(), - artboard: fastn_resolved_to_js::value::get_optional_js_value( + artboard: fastn_runtime::value::get_optional_js_value( "artboard", component.properties.as_slice(), component_definition.arguments.as_slice(), @@ -2301,7 +2285,7 @@ impl Rive { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &mut fastn_resolved_to_js::ResolverData, + rdata: &mut fastn_runtime::ResolverData, should_return: bool, ) -> Vec { let mut component_statements = vec![]; @@ -2323,7 +2307,7 @@ impl Rive { ) }); - let rive_events = fastn_resolved_to_js::utils::get_rive_event( + let rive_events = fastn_runtime::utils::get_rive_event( self.common.events.as_slice(), doc, rdata, @@ -2380,79 +2364,79 @@ impl Rive { #[derive(Debug)] pub struct Common { - pub id: Option, - pub region: Option, - pub download: Option, - pub link: Option, - pub link_rel: Option, - pub open_in_new_tab: Option, - pub align_self: Option, - pub width: Option, - pub height: Option, - pub padding: Option, - pub padding_horizontal: Option, - pub padding_vertical: Option, - pub padding_left: Option, - pub padding_right: Option, - pub padding_top: Option, - pub padding_bottom: Option, - pub margin: Option, - pub margin_horizontal: Option, - pub margin_vertical: Option, - pub margin_left: Option, - pub margin_right: Option, - pub margin_top: Option, - pub margin_bottom: Option, - pub border_width: Option, - pub border_top_width: Option, - pub border_bottom_width: Option, - pub border_left_width: Option, - pub border_right_width: Option, - pub border_radius: Option, - pub border_top_left_radius: Option, - pub border_top_right_radius: Option, - pub border_bottom_left_radius: Option, - pub border_bottom_right_radius: Option, - pub border_style: Option, - pub border_style_vertical: Option, - pub border_style_horizontal: Option, - pub border_left_style: Option, - pub border_right_style: Option, - pub border_top_style: Option, - pub border_bottom_style: Option, - pub border_color: Option, - pub border_left_color: Option, - pub border_right_color: Option, - pub border_top_color: Option, - pub border_bottom_color: Option, - pub color: Option, - pub background: Option, - pub role: Option, - pub z_index: Option, - pub sticky: Option, - pub top: Option, - pub bottom: Option, - pub left: Option, - pub right: Option, - pub overflow: Option, - pub overflow_x: Option, - pub overflow_y: Option, - pub opacity: Option, - pub cursor: Option, - pub resize: Option, - pub max_height: Option, - pub max_width: Option, - pub min_height: Option, - pub min_width: Option, - pub whitespace: Option, - pub classes: Option, - pub anchor: Option, - pub shadow: Option, - pub css: Option, - pub js: Option, + pub id: Option, + pub region: Option, + pub download: Option, + pub link: Option, + pub link_rel: Option, + pub open_in_new_tab: Option, + pub align_self: Option, + pub width: Option, + pub height: Option, + pub padding: Option, + pub padding_horizontal: Option, + pub padding_vertical: Option, + pub padding_left: Option, + pub padding_right: Option, + pub padding_top: Option, + pub padding_bottom: Option, + pub margin: Option, + pub margin_horizontal: Option, + pub margin_vertical: Option, + pub margin_left: Option, + pub margin_right: Option, + pub margin_top: Option, + pub margin_bottom: Option, + pub border_width: Option, + pub border_top_width: Option, + pub border_bottom_width: Option, + pub border_left_width: Option, + pub border_right_width: Option, + pub border_radius: Option, + pub border_top_left_radius: Option, + pub border_top_right_radius: Option, + pub border_bottom_left_radius: Option, + pub border_bottom_right_radius: Option, + pub border_style: Option, + pub border_style_vertical: Option, + pub border_style_horizontal: Option, + pub border_left_style: Option, + pub border_right_style: Option, + pub border_top_style: Option, + pub border_bottom_style: Option, + pub border_color: Option, + pub border_left_color: Option, + pub border_right_color: Option, + pub border_top_color: Option, + pub border_bottom_color: Option, + pub color: Option, + pub background: Option, + pub role: Option, + pub z_index: Option, + pub sticky: Option, + pub top: Option, + pub bottom: Option, + pub left: Option, + pub right: Option, + pub overflow: Option, + pub overflow_x: Option, + pub overflow_y: Option, + pub opacity: Option, + pub cursor: Option, + pub resize: Option, + pub max_height: Option, + pub max_width: Option, + pub min_height: Option, + pub min_width: Option, + pub whitespace: Option, + pub classes: Option, + pub anchor: Option, + pub shadow: Option, + pub css: Option, + pub js: Option, pub events: Vec, - pub selectable: Option, - pub mask: Option, + pub selectable: Option, + pub mask: Option, } impl Common { @@ -2462,296 +2446,262 @@ impl Common { events: &[fastn_resolved::Event], ) -> Common { Common { - id: fastn_resolved_to_js::value::get_optional_js_value("id", properties, arguments), - download: fastn_resolved_to_js::value::get_optional_js_value( + id: fastn_runtime::value::get_optional_js_value("id", properties, arguments), + download: fastn_runtime::value::get_optional_js_value( "download", properties, arguments, ), - css: fastn_resolved_to_js::value::get_optional_js_value("css", properties, arguments), - js: fastn_resolved_to_js::value::get_optional_js_value("js", properties, arguments), - region: fastn_resolved_to_js::value::get_optional_js_value( - "region", properties, arguments, - ), - link: fastn_resolved_to_js::value::get_optional_js_value("link", properties, arguments), - link_rel: fastn_resolved_to_js::value::get_optional_js_value( - "rel", properties, arguments, - ), - open_in_new_tab: fastn_resolved_to_js::value::get_optional_js_value( + css: fastn_runtime::value::get_optional_js_value("css", properties, arguments), + js: fastn_runtime::value::get_optional_js_value("js", properties, arguments), + region: fastn_runtime::value::get_optional_js_value("region", properties, arguments), + link: fastn_runtime::value::get_optional_js_value("link", properties, arguments), + link_rel: fastn_runtime::value::get_optional_js_value("rel", properties, arguments), + open_in_new_tab: fastn_runtime::value::get_optional_js_value( "open-in-new-tab", properties, arguments, ), - anchor: fastn_resolved_to_js::value::get_optional_js_value( - "anchor", properties, arguments, - ), - classes: fastn_resolved_to_js::value::get_optional_js_value( - "classes", properties, arguments, - ), - align_self: fastn_resolved_to_js::value::get_optional_js_value( + anchor: fastn_runtime::value::get_optional_js_value("anchor", properties, arguments), + classes: fastn_runtime::value::get_optional_js_value("classes", properties, arguments), + align_self: fastn_runtime::value::get_optional_js_value( "align-self", properties, arguments, ), - width: fastn_resolved_to_js::value::get_optional_js_value( - "width", properties, arguments, - ), - height: fastn_resolved_to_js::value::get_optional_js_value( - "height", properties, arguments, - ), - padding: fastn_resolved_to_js::value::get_optional_js_value( - "padding", properties, arguments, - ), - padding_horizontal: fastn_resolved_to_js::value::get_optional_js_value( + width: fastn_runtime::value::get_optional_js_value("width", properties, arguments), + height: fastn_runtime::value::get_optional_js_value("height", properties, arguments), + padding: fastn_runtime::value::get_optional_js_value("padding", properties, arguments), + padding_horizontal: fastn_runtime::value::get_optional_js_value( "padding-horizontal", properties, arguments, ), - padding_vertical: fastn_resolved_to_js::value::get_optional_js_value( + padding_vertical: fastn_runtime::value::get_optional_js_value( "padding-vertical", properties, arguments, ), - padding_left: fastn_resolved_to_js::value::get_optional_js_value( + padding_left: fastn_runtime::value::get_optional_js_value( "padding-left", properties, arguments, ), - padding_right: fastn_resolved_to_js::value::get_optional_js_value( + padding_right: fastn_runtime::value::get_optional_js_value( "padding-right", properties, arguments, ), - padding_top: fastn_resolved_to_js::value::get_optional_js_value( + padding_top: fastn_runtime::value::get_optional_js_value( "padding-top", properties, arguments, ), - padding_bottom: fastn_resolved_to_js::value::get_optional_js_value( + padding_bottom: fastn_runtime::value::get_optional_js_value( "padding-bottom", properties, arguments, ), - margin: fastn_resolved_to_js::value::get_optional_js_value( - "margin", properties, arguments, - ), - margin_horizontal: fastn_resolved_to_js::value::get_optional_js_value( + margin: fastn_runtime::value::get_optional_js_value("margin", properties, arguments), + margin_horizontal: fastn_runtime::value::get_optional_js_value( "margin-horizontal", properties, arguments, ), - margin_vertical: fastn_resolved_to_js::value::get_optional_js_value( + margin_vertical: fastn_runtime::value::get_optional_js_value( "margin-vertical", properties, arguments, ), - margin_left: fastn_resolved_to_js::value::get_optional_js_value( + margin_left: fastn_runtime::value::get_optional_js_value( "margin-left", properties, arguments, ), - margin_right: fastn_resolved_to_js::value::get_optional_js_value( + margin_right: fastn_runtime::value::get_optional_js_value( "margin-right", properties, arguments, ), - margin_top: fastn_resolved_to_js::value::get_optional_js_value( + margin_top: fastn_runtime::value::get_optional_js_value( "margin-top", properties, arguments, ), - margin_bottom: fastn_resolved_to_js::value::get_optional_js_value( + margin_bottom: fastn_runtime::value::get_optional_js_value( "margin-bottom", properties, arguments, ), - border_width: fastn_resolved_to_js::value::get_optional_js_value( + border_width: fastn_runtime::value::get_optional_js_value( "border-width", properties, arguments, ), - border_top_width: fastn_resolved_to_js::value::get_optional_js_value( + border_top_width: fastn_runtime::value::get_optional_js_value( "border-top-width", properties, arguments, ), - border_bottom_width: fastn_resolved_to_js::value::get_optional_js_value( + border_bottom_width: fastn_runtime::value::get_optional_js_value( "border-bottom-width", properties, arguments, ), - border_left_width: fastn_resolved_to_js::value::get_optional_js_value( + border_left_width: fastn_runtime::value::get_optional_js_value( "border-left-width", properties, arguments, ), - border_right_width: fastn_resolved_to_js::value::get_optional_js_value( + border_right_width: fastn_runtime::value::get_optional_js_value( "border-right-width", properties, arguments, ), - border_radius: fastn_resolved_to_js::value::get_optional_js_value( + border_radius: fastn_runtime::value::get_optional_js_value( "border-radius", properties, arguments, ), - border_top_left_radius: fastn_resolved_to_js::value::get_optional_js_value( + border_top_left_radius: fastn_runtime::value::get_optional_js_value( "border-top-left-radius", properties, arguments, ), - border_top_right_radius: fastn_resolved_to_js::value::get_optional_js_value( + border_top_right_radius: fastn_runtime::value::get_optional_js_value( "border-top-right-radius", properties, arguments, ), - border_bottom_left_radius: fastn_resolved_to_js::value::get_optional_js_value( + border_bottom_left_radius: fastn_runtime::value::get_optional_js_value( "border-bottom-left-radius", properties, arguments, ), - border_bottom_right_radius: fastn_resolved_to_js::value::get_optional_js_value( + border_bottom_right_radius: fastn_runtime::value::get_optional_js_value( "border-bottom-right-radius", properties, arguments, ), - border_style: fastn_resolved_to_js::value::get_optional_js_value( + border_style: fastn_runtime::value::get_optional_js_value( "border-style", properties, arguments, ), - border_style_vertical: fastn_resolved_to_js::value::get_optional_js_value( + border_style_vertical: fastn_runtime::value::get_optional_js_value( "border-style-vertical", properties, arguments, ), - border_style_horizontal: fastn_resolved_to_js::value::get_optional_js_value( + border_style_horizontal: fastn_runtime::value::get_optional_js_value( "border-style-horizontal", properties, arguments, ), - border_left_style: fastn_resolved_to_js::value::get_optional_js_value( + border_left_style: fastn_runtime::value::get_optional_js_value( "border-style-left", properties, arguments, ), - border_right_style: fastn_resolved_to_js::value::get_optional_js_value( + border_right_style: fastn_runtime::value::get_optional_js_value( "border-style-right", properties, arguments, ), - border_top_style: fastn_resolved_to_js::value::get_optional_js_value( + border_top_style: fastn_runtime::value::get_optional_js_value( "border-style-top", properties, arguments, ), - border_bottom_style: fastn_resolved_to_js::value::get_optional_js_value( + border_bottom_style: fastn_runtime::value::get_optional_js_value( "border-style-bottom", properties, arguments, ), - border_color: fastn_resolved_to_js::value::get_optional_js_value( + border_color: fastn_runtime::value::get_optional_js_value( "border-color", properties, arguments, ), - border_left_color: fastn_resolved_to_js::value::get_optional_js_value( + border_left_color: fastn_runtime::value::get_optional_js_value( "border-left-color", properties, arguments, ), - border_right_color: fastn_resolved_to_js::value::get_optional_js_value( + border_right_color: fastn_runtime::value::get_optional_js_value( "border-right-color", properties, arguments, ), - border_top_color: fastn_resolved_to_js::value::get_optional_js_value( + border_top_color: fastn_runtime::value::get_optional_js_value( "border-top-color", properties, arguments, ), - border_bottom_color: fastn_resolved_to_js::value::get_optional_js_value( + border_bottom_color: fastn_runtime::value::get_optional_js_value( "border-bottom-color", properties, arguments, ), - color: fastn_resolved_to_js::value::get_optional_js_value( - "color", properties, arguments, - ), - background: fastn_resolved_to_js::value::get_optional_js_value( + color: fastn_runtime::value::get_optional_js_value("color", properties, arguments), + background: fastn_runtime::value::get_optional_js_value( "background", properties, arguments, ), - role: fastn_resolved_to_js::value::get_optional_js_value("role", properties, arguments), - z_index: fastn_resolved_to_js::value::get_optional_js_value( - "z-index", properties, arguments, - ), - sticky: fastn_resolved_to_js::value::get_optional_js_value( - "sticky", properties, arguments, - ), - top: fastn_resolved_to_js::value::get_optional_js_value("top", properties, arguments), - bottom: fastn_resolved_to_js::value::get_optional_js_value( - "bottom", properties, arguments, - ), - left: fastn_resolved_to_js::value::get_optional_js_value("left", properties, arguments), - right: fastn_resolved_to_js::value::get_optional_js_value( - "right", properties, arguments, - ), - overflow: fastn_resolved_to_js::value::get_optional_js_value( + role: fastn_runtime::value::get_optional_js_value("role", properties, arguments), + z_index: fastn_runtime::value::get_optional_js_value("z-index", properties, arguments), + sticky: fastn_runtime::value::get_optional_js_value("sticky", properties, arguments), + top: fastn_runtime::value::get_optional_js_value("top", properties, arguments), + bottom: fastn_runtime::value::get_optional_js_value("bottom", properties, arguments), + left: fastn_runtime::value::get_optional_js_value("left", properties, arguments), + right: fastn_runtime::value::get_optional_js_value("right", properties, arguments), + overflow: fastn_runtime::value::get_optional_js_value( "overflow", properties, arguments, ), - overflow_x: fastn_resolved_to_js::value::get_optional_js_value( + overflow_x: fastn_runtime::value::get_optional_js_value( "overflow-x", properties, arguments, ), - overflow_y: fastn_resolved_to_js::value::get_optional_js_value( + overflow_y: fastn_runtime::value::get_optional_js_value( "overflow-y", properties, arguments, ), - opacity: fastn_resolved_to_js::value::get_optional_js_value( - "opacity", properties, arguments, - ), - cursor: fastn_resolved_to_js::value::get_optional_js_value( - "cursor", properties, arguments, - ), - resize: fastn_resolved_to_js::value::get_optional_js_value( - "resize", properties, arguments, - ), - max_height: fastn_resolved_to_js::value::get_optional_js_value( + opacity: fastn_runtime::value::get_optional_js_value("opacity", properties, arguments), + cursor: fastn_runtime::value::get_optional_js_value("cursor", properties, arguments), + resize: fastn_runtime::value::get_optional_js_value("resize", properties, arguments), + max_height: fastn_runtime::value::get_optional_js_value( "max-height", properties, arguments, ), - max_width: fastn_resolved_to_js::value::get_optional_js_value( + max_width: fastn_runtime::value::get_optional_js_value( "max-width", properties, arguments, ), - min_height: fastn_resolved_to_js::value::get_optional_js_value( + min_height: fastn_runtime::value::get_optional_js_value( "min-height", properties, arguments, ), - min_width: fastn_resolved_to_js::value::get_optional_js_value( + min_width: fastn_runtime::value::get_optional_js_value( "min-width", properties, arguments, ), - whitespace: fastn_resolved_to_js::value::get_optional_js_value( + whitespace: fastn_runtime::value::get_optional_js_value( "white-space", properties, arguments, ), - shadow: fastn_resolved_to_js::value::get_optional_js_value( - "shadow", properties, arguments, - ), - selectable: fastn_resolved_to_js::value::get_optional_js_value( + shadow: fastn_runtime::value::get_optional_js_value("shadow", properties, arguments), + selectable: fastn_runtime::value::get_optional_js_value( "selectable", properties, arguments, ), - mask: fastn_resolved_to_js::value::get_optional_js_value("mask", properties, arguments), + mask: fastn_runtime::value::get_optional_js_value("mask", properties, arguments), events: events.to_vec(), } } @@ -2760,7 +2710,7 @@ impl Common { &self, element_name: &str, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, ) -> Vec { let mut component_statements = vec![]; for event in self.events.iter() { @@ -3366,7 +3316,7 @@ impl Common { &self, element_name: &str, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, text_component_statement: fastn_js::ComponentStatement, ) -> Vec { // Property dependencies @@ -3386,7 +3336,7 @@ impl Common { &self, element_name: &str, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, ) -> Vec { let mut component_statements = vec![]; component_statements.extend(self.to_set_properties_without_role(element_name, doc, rdata)); @@ -3431,7 +3381,7 @@ pub(crate) fn create_element( element_kind: fastn_js::ElementKind, parent: &str, index: usize, - rdata: &mut fastn_resolved_to_js::ResolverData, + rdata: &mut fastn_runtime::ResolverData, ) -> fastn_js::Kernel { let kernel = fastn_js::Kernel::from_component(element_kind, parent, index); *rdata = rdata.clone_with_new_component_name(Some(kernel.name.to_string())); diff --git a/fastn-runtime/src/extensions.rs b/fastn-runtime/src/extensions.rs index f65605449..0cf1b507a 100644 --- a/fastn-runtime/src/extensions.rs +++ b/fastn-runtime/src/extensions.rs @@ -16,7 +16,7 @@ pub trait ComponentExt { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, should_return: bool, has_rive_components: &mut bool, ) -> Vec; @@ -25,7 +25,7 @@ pub trait ComponentExt { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, should_return: bool, has_rive_components: &mut bool, ) -> Vec; @@ -34,7 +34,7 @@ pub trait ComponentExt { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, should_return: bool, has_rive_components: &mut bool, ) -> Option>; @@ -43,7 +43,7 @@ pub trait ComponentExt { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, should_return: bool, has_rive_components: &mut bool, ) -> Option>; @@ -52,7 +52,7 @@ pub trait ComponentExt { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, should_return: bool, has_rive_components: &mut bool, ) -> Option>; @@ -61,7 +61,7 @@ pub trait ComponentExt { parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, should_return: bool, has_rive_components: &mut bool, ) -> Option>; @@ -77,7 +77,7 @@ pub(crate) trait EventExt { &self, element_name: &str, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, ) -> Option; } @@ -85,14 +85,14 @@ pub(crate) trait ValueExt { fn to_fastn_js_value( &self, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, has_rive_components: &mut bool, should_return: bool, ) -> fastn_js::SetPropertyValue; } pub trait PropertyValueExt { - fn get_deps(&self, rdata: &fastn_resolved_to_js::ResolverData) -> Vec; + fn get_deps(&self, rdata: &fastn_runtime::ResolverData) -> Vec; fn to_fastn_js_value_with_none( &self, @@ -103,45 +103,45 @@ pub trait PropertyValueExt { fn to_fastn_js_value( &self, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, should_return: bool, ) -> fastn_js::SetPropertyValue; fn to_fastn_js_value_with_ui( &self, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, has_rive_components: &mut bool, is_ui_component: bool, ) -> fastn_js::SetPropertyValue; - fn to_value(&self) -> fastn_resolved_to_js::Value; + fn to_value(&self) -> fastn_runtime::Value; } pub(crate) trait FunctionCallExt { fn to_js_function( &self, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, ) -> fastn_js::Function; } pub(crate) trait ExpressionExt { - fn get_deps(&self, rdata: &fastn_resolved_to_js::ResolverData) -> Vec; + fn get_deps(&self, rdata: &fastn_runtime::ResolverData) -> Vec; fn update_node_with_variable_reference_js( &self, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, ) -> fastn_resolved::evalexpr::ExprNode; } pub(crate) trait ArgumentExt { - fn get_default_value(&self) -> Option; + fn get_default_value(&self) -> Option; fn get_optional_value( &self, properties: &[fastn_resolved::Property], // doc_name: &str, // line_number: usize - ) -> Option; + ) -> Option; } pub trait WebComponentDefinitionExt { diff --git a/fastn-runtime/src/fastn_type_functions.rs b/fastn-runtime/src/fastn_type_functions.rs index 2bbb5c390..e7f537c30 100644 --- a/fastn-runtime/src/fastn_type_functions.rs +++ b/fastn-runtime/src/fastn_type_functions.rs @@ -1,10 +1,10 @@ -use fastn_resolved_to_js::extensions::*; +use fastn_runtime::extensions::*; impl FunctionCallExt for fastn_resolved::FunctionCall { fn to_js_function( &self, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, ) -> fastn_js::Function { let mut parameters = vec![]; let mut name = self.name.to_string(); @@ -12,7 +12,7 @@ impl FunctionCallExt for fastn_resolved::FunctionCall { if let Some((default_module, module_variable_name)) = &self.module_name { function_name = fastn_js::FunctionData::Definition(fastn_js::SetPropertyValue::Reference( - fastn_resolved_to_js::utils::update_reference(name.as_str(), rdata), + fastn_runtime::utils::update_reference(name.as_str(), rdata), )); name = name.replace( format!("{module_variable_name}.").as_str(), @@ -37,13 +37,11 @@ impl FunctionCallExt for fastn_resolved::FunctionCall { } } -impl fastn_resolved_to_js::extensions::PropertyValueExt for fastn_resolved::PropertyValue { - fn get_deps(&self, rdata: &fastn_resolved_to_js::ResolverData) -> Vec { +impl fastn_runtime::extensions::PropertyValueExt for fastn_resolved::PropertyValue { + fn get_deps(&self, rdata: &fastn_runtime::ResolverData) -> Vec { let mut deps = vec![]; if let Some(reference) = self.get_reference_or_clone() { - deps.push(fastn_resolved_to_js::utils::update_reference( - reference, rdata, - )); + deps.push(fastn_runtime::utils::update_reference(reference, rdata)); } else if let Some(function) = self.get_function() { for value in function.values.values() { deps.extend(value.get_deps(rdata)); @@ -59,7 +57,7 @@ impl fastn_resolved_to_js::extensions::PropertyValueExt for fastn_resolved::Prop ) -> fastn_js::SetPropertyValue { self.to_fastn_js_value_with_ui( doc, - &fastn_resolved_to_js::ResolverData::none(), + &fastn_runtime::ResolverData::none(), has_rive_components, false, ) @@ -68,7 +66,7 @@ impl fastn_resolved_to_js::extensions::PropertyValueExt for fastn_resolved::Prop fn to_fastn_js_value( &self, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, should_return: bool, ) -> fastn_js::SetPropertyValue { self.to_fastn_js_value_with_ui(doc, rdata, &mut false, should_return) @@ -77,7 +75,7 @@ impl fastn_resolved_to_js::extensions::PropertyValueExt for fastn_resolved::Prop fn to_fastn_js_value_with_ui( &self, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, has_rive_components: &mut bool, should_return: bool, ) -> fastn_js::SetPropertyValue { @@ -89,32 +87,32 @@ impl fastn_resolved_to_js::extensions::PropertyValueExt for fastn_resolved::Prop ) } - fn to_value(&self) -> fastn_resolved_to_js::Value { + fn to_value(&self) -> fastn_runtime::Value { match self { fastn_resolved::PropertyValue::Value { ref value, .. } => { - fastn_resolved_to_js::Value::Data(value.to_owned()) + fastn_runtime::Value::Data(value.to_owned()) } fastn_resolved::PropertyValue::Reference { ref name, .. } => { - fastn_resolved_to_js::Value::Reference(fastn_resolved_to_js::value::ReferenceData { + fastn_runtime::Value::Reference(fastn_runtime::value::ReferenceData { name: name.clone().to_string(), value: Some(self.clone()), }) } fastn_resolved::PropertyValue::FunctionCall(ref function_call) => { - fastn_resolved_to_js::Value::FunctionCall(function_call.to_owned()) + fastn_runtime::Value::FunctionCall(function_call.to_owned()) } fastn_resolved::PropertyValue::Clone { ref name, .. } => { - fastn_resolved_to_js::Value::Clone(name.to_owned()) + fastn_runtime::Value::Clone(name.to_owned()) } } } } -impl fastn_resolved_to_js::extensions::ValueExt for fastn_resolved::Value { +impl fastn_runtime::extensions::ValueExt for fastn_resolved::Value { fn to_fastn_js_value( &self, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, has_rive_components: &mut bool, should_return: bool, ) -> fastn_js::SetPropertyValue { @@ -146,12 +144,8 @@ impl fastn_resolved_to_js::extensions::ValueExt for fastn_resolved::Value { full_variant, variant, } => { - let (js_variant, has_value) = fastn_resolved_to_js::value::ftd_to_js_variant( - name, - variant, - full_variant, - value, - ); + let (js_variant, has_value) = + fastn_runtime::value::ftd_to_js_variant(name, variant, full_variant, value); if has_value { return fastn_js::SetPropertyValue::Value(fastn_js::Value::OrType { variant: js_variant, @@ -240,14 +234,14 @@ impl fastn_resolved_to_js::extensions::ValueExt for fastn_resolved::Value { } } -impl fastn_resolved_to_js::extensions::EventExt for fastn_resolved::Event { +impl fastn_runtime::extensions::EventExt for fastn_resolved::Event { fn to_event_handler_js( &self, element_name: &str, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, ) -> Option { - use fastn_resolved_to_js::fastn_type_functions::FunctionCallExt; + use fastn_runtime::fastn_type_functions::FunctionCallExt; self.name .to_js_event_name() @@ -259,7 +253,7 @@ impl fastn_resolved_to_js::extensions::EventExt for fastn_resolved::Event { } } -impl fastn_resolved_to_js::extensions::EventNameExt for fastn_resolved::EventName { +impl fastn_runtime::extensions::EventNameExt for fastn_resolved::EventName { fn to_js_event_name(&self) -> Option { use itertools::Itertools; @@ -270,12 +264,12 @@ impl fastn_resolved_to_js::extensions::EventNameExt for fastn_resolved::EventNam fastn_resolved::EventName::ClickOutside => Some(fastn_js::Event::ClickOutside), fastn_resolved::EventName::GlobalKey(gk) => Some(fastn_js::Event::GlobalKey( gk.iter() - .map(|v| fastn_resolved_to_js::utils::to_key(v)) + .map(|v| fastn_runtime::utils::to_key(v)) .collect_vec(), )), fastn_resolved::EventName::GlobalKeySeq(gk) => Some(fastn_js::Event::GlobalKeySeq( gk.iter() - .map(|v| fastn_resolved_to_js::utils::to_key(v)) + .map(|v| fastn_runtime::utils::to_key(v)) .collect_vec(), )), fastn_resolved::EventName::Input => Some(fastn_js::Event::Input), @@ -289,24 +283,24 @@ impl fastn_resolved_to_js::extensions::EventNameExt for fastn_resolved::EventNam } } -impl fastn_resolved_to_js::extensions::ComponentExt for fastn_resolved::ComponentInvocation { +impl fastn_runtime::extensions::ComponentExt for fastn_resolved::ComponentInvocation { fn to_component_statements( &self, parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, should_return: bool, has_rive_components: &mut bool, ) -> Vec { - use fastn_resolved_to_js::fastn_type_functions::PropertyValueExt; + use fastn_runtime::fastn_type_functions::PropertyValueExt; use itertools::Itertools; let loop_alias = self.iteration.clone().map(|v| v.alias); let loop_counter_alias = self.iteration.clone().and_then(|v| { if let Some(ref loop_counter_alias) = v.loop_counter_alias { let (_, loop_counter_alias, _remaining) = - fastn_resolved_to_js::utils::get_doc_name_and_thing_name_and_remaining( + fastn_runtime::utils::get_doc_name_and_thing_name_and_remaining( loop_counter_alias.as_str(), doc.name(), ); @@ -391,7 +385,7 @@ impl fastn_resolved_to_js::extensions::ComponentExt for fastn_resolved::Componen parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, should_return: bool, has_rive_components: &mut bool, ) -> Vec { @@ -447,17 +441,17 @@ impl fastn_resolved_to_js::extensions::ComponentExt for fastn_resolved::Componen parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, should_return: bool, has_rive_components: &mut bool, ) -> Option> { - if fastn_resolved_to_js::element::is_kernel(self.name.as_str()) { + if fastn_runtime::element::is_kernel(self.name.as_str()) { if !*has_rive_components { *has_rive_components = - fastn_resolved_to_js::element::is_rive_component(self.name.as_str()); + fastn_runtime::element::is_rive_component(self.name.as_str()); } Some( - fastn_resolved_to_js::Element::from_interpreter_component(self, doc) + fastn_runtime::Element::from_interpreter_component(self, doc) .to_component_statements( parent, index, @@ -477,12 +471,12 @@ impl fastn_resolved_to_js::extensions::ComponentExt for fastn_resolved::Componen parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, should_return: bool, has_rive_components: &mut bool, ) -> Option> { if let Some(arguments) = - fastn_resolved_to_js::utils::get_set_property_values_for_provided_component_properties( + fastn_runtime::utils::get_set_property_values_for_provided_component_properties( doc, rdata, self.name.as_str(), @@ -532,12 +526,12 @@ impl fastn_resolved_to_js::extensions::ComponentExt for fastn_resolved::Componen parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, should_return: bool, has_rive_components: &mut bool, ) -> Option> { let (component_name, remaining) = - fastn_resolved_to_js::utils::get_doc_name_and_remaining(self.name.as_str()); + fastn_runtime::utils::get_doc_name_and_remaining(self.name.as_str()); let remaining = remaining?; @@ -551,35 +545,30 @@ impl fastn_resolved_to_js::extensions::ComponentExt for fastn_resolved::Componen let mut arguments = vec![]; - if let Some(component_name) = fastn_resolved_to_js::utils::is_module_argument( + if let Some(component_name) = fastn_runtime::utils::is_module_argument( component.arguments.as_slice(), remaining.as_str(), ) { - arguments = fastn_resolved_to_js::utils::get_set_property_values_for_provided_component_properties( - doc, - rdata, - component_name.as_str(), - self.properties.as_slice(), - has_rive_components, - )?; - } else if !fastn_resolved_to_js::utils::is_ui_argument( + arguments = + fastn_runtime::utils::get_set_property_values_for_provided_component_properties( + doc, + rdata, + component_name.as_str(), + self.properties.as_slice(), + has_rive_components, + )?; + } else if !fastn_runtime::utils::is_ui_argument( component.arguments.as_slice(), remaining.as_str(), ) { return None; } - let value = - fastn_resolved_to_js::Value::Reference(fastn_resolved_to_js::value::ReferenceData { - name: self.name.to_owned(), - value: None, - }) - .to_set_property_value_with_ui( - doc, - rdata, - has_rive_components, - should_return, - ); + let value = fastn_runtime::Value::Reference(fastn_runtime::value::ReferenceData { + name: self.name.to_owned(), + value: None, + }) + .to_set_property_value_with_ui(doc, rdata, has_rive_components, should_return); let instantiate_component = fastn_js::InstantiateComponent::new_with_definition( value, arguments, @@ -616,7 +605,7 @@ impl fastn_resolved_to_js::extensions::ComponentExt for fastn_resolved::Componen parent: &str, index: usize, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, should_return: bool, has_rive_components: &mut bool, ) -> Option> { @@ -633,17 +622,11 @@ impl fastn_resolved_to_js::extensions::ComponentExt for fastn_resolved::Componen }*/ // The reference `self.name` is either the ftd.ui type variable or the loop-alias - let value = - fastn_resolved_to_js::Value::Reference(fastn_resolved_to_js::value::ReferenceData { - name: self.name.to_owned(), - value: None, - }) - .to_set_property_value_with_ui( - doc, - rdata, - has_rive_components, - should_return, - ); + let value = fastn_runtime::Value::Reference(fastn_runtime::value::ReferenceData { + name: self.name.to_owned(), + value: None, + }) + .to_set_property_value_with_ui(doc, rdata, has_rive_components, should_return); let instantiate_component = fastn_js::InstantiateComponent::new_with_definition( value, diff --git a/fastn-runtime/src/html.rs b/fastn-runtime/src/html.rs index 998cf4b47..8d02b7968 100644 --- a/fastn-runtime/src/html.rs +++ b/fastn-runtime/src/html.rs @@ -1,4 +1,4 @@ -use fastn_resolved_to_js::extensions::*; +use fastn_runtime::extensions::*; pub struct HtmlInput { pub package: Package, @@ -72,12 +72,9 @@ impl HtmlInput { } fn get_script_file(&self) -> String { - let mut scripts = - fastn_resolved_to_js::utils::get_external_scripts(self.has_rive_component); - scripts.push(fastn_resolved_to_js::utils::get_js_html( - self.js_files.as_slice(), - )); - scripts.push(fastn_resolved_to_js::utils::get_css_html( + let mut scripts = fastn_runtime::utils::get_external_scripts(self.has_rive_component); + scripts.push(fastn_runtime::utils::get_js_html(self.js_files.as_slice())); + scripts.push(fastn_runtime::utils::get_css_html( self.css_files.as_slice(), )); diff --git a/fastn-runtime/src/lib.rs b/fastn-runtime/src/lib.rs index b82b08a87..1df39c4d1 100644 --- a/fastn-runtime/src/lib.rs +++ b/fastn-runtime/src/lib.rs @@ -1,4 +1,4 @@ -extern crate self as fastn_resolved_to_js; +extern crate self as fastn_runtime; mod resolver; @@ -21,7 +21,7 @@ pub const CODE_DEFAULT_THEME: &str = "fastn-theme.dark"; pub const REFERENCE: &str = "$"; pub const CLONE: &str = "*$"; -impl fastn_resolved_to_js::extensions::FunctionExt for fastn_resolved::Function { +impl fastn_runtime::extensions::FunctionExt for fastn_resolved::Function { fn to_ast(&self, doc: &dyn fastn_resolved::tdoc::TDoc) -> fastn_js::Ast { use itertools::Itertools; @@ -42,7 +42,7 @@ impl fastn_resolved_to_js::extensions::FunctionExt for fastn_resolved::Function v.name.to_string(), val.to_set_property_value( doc, - &fastn_resolved_to_js::ResolverData::new_with_component_definition_name( + &fastn_runtime::ResolverData::new_with_component_definition_name( &Some(self.name.to_string()), ), ), @@ -71,7 +71,7 @@ impl VariableExt for fastn_resolved::Variable { name: self.name.to_string(), fields: value.to_fastn_js_value( doc, - &fastn_resolved_to_js::ResolverData::none(), + &fastn_runtime::ResolverData::none(), has_rive_components, false, ), @@ -106,15 +106,13 @@ impl VariableExt for fastn_resolved::Variable { } } -impl fastn_resolved_to_js::extensions::ComponentDefinitionExt - for fastn_resolved::ComponentDefinition -{ +impl fastn_runtime::extensions::ComponentDefinitionExt for fastn_resolved::ComponentDefinition { fn to_ast( &self, doc: &dyn fastn_resolved::tdoc::TDoc, has_rive_components: &mut bool, ) -> fastn_js::Ast { - use fastn_resolved_to_js::extensions::ComponentExt; + use fastn_runtime::extensions::ComponentExt; use itertools::Itertools; let mut statements = vec![]; @@ -122,7 +120,7 @@ impl fastn_resolved_to_js::extensions::ComponentDefinitionExt fastn_js::COMPONENT_PARENT, 0, doc, - &fastn_resolved_to_js::ResolverData::new_with_component_definition_name(&Some( + &fastn_runtime::ResolverData::new_with_component_definition_name(&Some( self.name.to_string(), )), true, @@ -139,9 +137,9 @@ impl fastn_resolved_to_js::extensions::ComponentDefinitionExt v.name.to_string(), val.to_set_property_value_with_ui( doc, - &fastn_resolved_to_js::ResolverData::new_with_component_definition_name(&Some( - self.name.to_string(), - )), + &fastn_runtime::ResolverData::new_with_component_definition_name( + &Some(self.name.to_string()), + ), has_rive_components, false, ), @@ -159,7 +157,7 @@ pub fn from_tree( doc: &dyn fastn_resolved::tdoc::TDoc, has_rive_components: &mut bool, ) -> fastn_js::Ast { - use fastn_resolved_to_js::extensions::ComponentExt; + use fastn_runtime::extensions::ComponentExt; let mut statements = vec![]; for (index, component) in tree.iter().enumerate() { @@ -167,7 +165,7 @@ pub fn from_tree( fastn_js::COMPONENT_PARENT, index, doc, - &fastn_resolved_to_js::ResolverData::none(), + &fastn_runtime::ResolverData::none(), false, has_rive_components, )) @@ -203,9 +201,9 @@ impl WebComponentDefinitionExt for fastn_resolved::WebComponentDefinition { v.name.to_string(), val.to_set_property_value( doc, - &fastn_resolved_to_js::ResolverData::new_with_component_definition_name(&Some( - self.name.to_string(), - )), + &fastn_runtime::ResolverData::new_with_component_definition_name( + &Some(self.name.to_string()), + ), ), v.mutable.to_owned(), ) @@ -358,7 +356,7 @@ pub fn get_all_asts<'a, T: Iterator>( let mut has_rive_components = false; let mut export_asts = vec![]; - let mut document_asts = vec![fastn_resolved_to_js::from_tree( + let mut document_asts = vec![fastn_runtime::from_tree( tree, doc, &mut has_rive_components, diff --git a/fastn-runtime/src/main.rs b/fastn-runtime/src/main.rs index 2a58d9cb6..b54e74492 100644 --- a/fastn-runtime/src/main.rs +++ b/fastn-runtime/src/main.rs @@ -16,13 +16,13 @@ fn main() { line_number: 0, }; - let doc = fastn_resolved_to_js::TDoc { + let doc = fastn_runtime::TDoc { name: "foo", // Todo: Package name definitions: Default::default(), builtins: fastn_builtins::builtins(), }; - let output = fastn_resolved_to_js::get_all_asts( + let output = fastn_runtime::get_all_asts( &doc, &[&c], std::iter::IntoIterator::into_iter([fastn_builtins::builtins().get("ftd#text").unwrap()]), @@ -30,12 +30,12 @@ fn main() { let js_document_script = fastn_js::to_js(output.ast.as_slice(), "foo"); let js_ftd_script = fastn_js::to_js( - fastn_resolved_to_js::default_bag_into_js_ast(&doc).as_slice(), + fastn_runtime::default_bag_into_js_ast(&doc).as_slice(), "foo", ); let js = format!("{js_ftd_script}\n{js_document_script}"); - let html = fastn_resolved_to_js::HtmlInput { - package: fastn_resolved_to_js::Package::new_name("foo"), // Todo + let html = fastn_runtime::HtmlInput { + package: fastn_runtime::Package::new_name("foo"), // Todo js, css_files: vec![], js_files: vec![], diff --git a/fastn-runtime/src/utils.rs b/fastn-runtime/src/utils.rs index e8f222027..66ef81035 100644 --- a/fastn-runtime/src/utils.rs +++ b/fastn-runtime/src/utils.rs @@ -1,4 +1,4 @@ -use fastn_resolved_to_js::extensions::*; +use fastn_runtime::extensions::*; #[allow(dead_code)] pub fn trim_all_lines(s: &str) -> String { @@ -30,11 +30,11 @@ pub fn get_css_html(external_css: &[String]) -> String { pub(crate) fn get_rive_event( events: &[fastn_resolved::Event], doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, element_name: &str, ) -> String { - let mut events_map: fastn_resolved_to_js::VecMap<(&String, &fastn_resolved::FunctionCall)> = - fastn_resolved_to_js::VecMap::new(); + let mut events_map: fastn_runtime::VecMap<(&String, &fastn_resolved::FunctionCall)> = + fastn_runtime::VecMap::new(); for event in events.iter() { let (event_name, input, action) = match &event.name { fastn_resolved::EventName::RivePlay(timeline) => ("onPlay", timeline, &event.action), @@ -50,9 +50,8 @@ pub(crate) fn get_rive_event( for (on, actions) in events_map.value { let mut actions_vec = vec![]; for (input, action) in actions { - let action = - fastn_resolved_to_js::utils::function_call_to_js_formula(action, doc, rdata) - .formula_value_to_js(&Some(element_name.to_string())); + let action = fastn_runtime::utils::function_call_to_js_formula(action, doc, rdata) + .formula_value_to_js(&Some(element_name.to_string())); actions_vec.push(format!( indoc::indoc! {" if (input === \"{input}\") {{ @@ -108,10 +107,7 @@ pub(crate) fn to_key(key: &str) -> String { .to_string() } -pub(crate) fn update_reference( - reference: &str, - rdata: &fastn_resolved_to_js::ResolverData, -) -> String { +pub(crate) fn update_reference(reference: &str, rdata: &fastn_runtime::ResolverData) -> String { let name = reference.to_string(); if fastn_builtins::constants::FTD_SPECIAL_VALUE @@ -156,7 +152,7 @@ pub(crate) fn update_reference( if let Some(loop_counter_alias) = rdata.loop_counter_alias { if let Some(ref doc_name) = rdata.doc_name { - let resolved_alias = fastn_resolved_to_js::utils::resolve_name( + let resolved_alias = fastn_runtime::utils::resolve_name( loop_counter_alias, doc_name.as_str(), &fastn_builtins::default_aliases(), @@ -185,8 +181,8 @@ fn is_ftd_thing(name: &str) -> bool { pub(crate) fn get_js_value_from_properties( properties: &[fastn_resolved::Property], -) -> Option { - use fastn_resolved_to_js::extensions::PropertyValueExt; +) -> Option { + use fastn_runtime::extensions::PropertyValueExt; if properties.is_empty() { return None; } @@ -198,7 +194,7 @@ pub(crate) fn get_js_value_from_properties( } } - Some(fastn_resolved_to_js::Value::ConditionalFormula( + Some(fastn_runtime::Value::ConditionalFormula( properties.to_owned(), )) } @@ -206,7 +202,7 @@ pub(crate) fn get_js_value_from_properties( pub(crate) fn function_call_to_js_formula( function_call: &fastn_resolved::FunctionCall, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, ) -> fastn_js::Formula { let mut deps = vec![]; for property_value in function_call.values.values() { @@ -269,7 +265,7 @@ pub(crate) fn is_module_argument( /// conversion operation fails. pub(crate) fn get_set_property_values_for_provided_component_properties( doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, component_name: &str, component_properties: &[fastn_resolved::Property], has_rive_components: &mut bool, @@ -361,8 +357,8 @@ pub fn get_children_properties_from_properties( pub fn resolve_name(name: &str, doc_name: &str, aliases: &fastn_builtins::Map) -> String { let name = name - .trim_start_matches(fastn_resolved_to_js::CLONE) - .trim_start_matches(fastn_resolved_to_js::REFERENCE) + .trim_start_matches(fastn_runtime::CLONE) + .trim_start_matches(fastn_runtime::REFERENCE) .to_string(); if name.contains('#') { @@ -370,7 +366,7 @@ pub fn resolve_name(name: &str, doc_name: &str, aliases: &fastn_builtins::Map match aliases.get(m) { Some(m) => format!("{}#{}", m, v), None => format!("{}#{}.{}", doc_name, m, v), diff --git a/fastn-runtime/src/value.rs b/fastn-runtime/src/value.rs index 5cf12b5e9..92ee6dd15 100644 --- a/fastn-runtime/src/value.rs +++ b/fastn-runtime/src/value.rs @@ -1,4 +1,4 @@ -use fastn_resolved_to_js::extensions::*; +use fastn_runtime::extensions::*; #[derive(Debug)] pub enum Value { @@ -19,7 +19,7 @@ impl Value { pub(crate) fn to_set_property_value( &self, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, ) -> fastn_js::SetPropertyValue { self.to_set_property_value_with_ui(doc, rdata, &mut false, false) } @@ -27,7 +27,7 @@ impl Value { pub(crate) fn to_set_property_value_with_ui( &self, doc: &dyn fastn_resolved::tdoc::TDoc, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, has_rive_components: &mut bool, should_return: bool, ) -> fastn_js::SetPropertyValue { @@ -55,7 +55,7 @@ impl Value { return fastn_js::SetPropertyValue::Value(fastn_js::Value::OrType { variant: js_variant, value: Some(Box::new(fastn_js::SetPropertyValue::Reference( - fastn_resolved_to_js::utils::update_reference( + fastn_runtime::utils::update_reference( data.name.as_str(), rdata, ), @@ -72,18 +72,19 @@ impl Value { } // for other datatypes, simply return a reference - fastn_js::SetPropertyValue::Reference( - fastn_resolved_to_js::utils::update_reference(data.name.as_str(), rdata), - ) + fastn_js::SetPropertyValue::Reference(fastn_runtime::utils::update_reference( + data.name.as_str(), + rdata, + )) } Value::ConditionalFormula(formulas) => fastn_js::SetPropertyValue::Formula( properties_to_js_conditional_formula(doc, formulas, rdata), ), Value::FunctionCall(function_call) => fastn_js::SetPropertyValue::Formula( - fastn_resolved_to_js::utils::function_call_to_js_formula(function_call, doc, rdata), + fastn_runtime::utils::function_call_to_js_formula(function_call, doc, rdata), ), Value::Clone(name) => fastn_js::SetPropertyValue::Clone( - fastn_resolved_to_js::utils::update_reference(name, rdata), + fastn_runtime::utils::update_reference(name, rdata), ), } } @@ -93,7 +94,7 @@ impl Value { kind: fastn_js::PropertyKind, doc: &dyn fastn_resolved::tdoc::TDoc, element_name: &str, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, ) -> fastn_js::SetProperty { fastn_js::SetProperty { kind, @@ -120,7 +121,7 @@ impl Value { fn properties_to_js_conditional_formula( doc: &dyn fastn_resolved::tdoc::TDoc, properties: &[fastn_resolved::Property], - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, ) -> fastn_js::Formula { let mut deps = vec![]; let mut conditional_values = vec![]; @@ -145,8 +146,8 @@ fn properties_to_js_conditional_formula( } } -impl fastn_resolved_to_js::extensions::ExpressionExt for fastn_resolved::Expression { - fn get_deps(&self, rdata: &fastn_resolved_to_js::ResolverData) -> Vec { +impl fastn_runtime::extensions::ExpressionExt for fastn_resolved::Expression { + fn get_deps(&self, rdata: &fastn_runtime::ResolverData) -> Vec { let mut deps = vec![]; for property_value in self.references.values() { deps.extend(property_value.get_deps(rdata)); @@ -156,14 +157,14 @@ impl fastn_resolved_to_js::extensions::ExpressionExt for fastn_resolved::Express fn update_node_with_variable_reference_js( &self, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, ) -> fastn_resolved::evalexpr::ExprNode { return update_node_with_variable_reference_js_(&self.expression, &self.references, rdata); fn update_node_with_variable_reference_js_( expr: &fastn_resolved::evalexpr::ExprNode, references: &fastn_builtins::Map, - rdata: &fastn_resolved_to_js::ResolverData, + rdata: &fastn_runtime::ResolverData, ) -> fastn_resolved::evalexpr::ExprNode { let mut operator = expr.operator().clone(); if let fastn_resolved::evalexpr::Operator::VariableIdentifierRead { ref identifier } = @@ -182,7 +183,7 @@ impl fastn_resolved_to_js::extensions::ExpressionExt for fastn_resolved::Express } else if let Some(fastn_resolved::PropertyValue::Reference { name, .. }) = references.get(identifier) { - let name = fastn_resolved_to_js::utils::update_reference(name, rdata); + let name = fastn_runtime::utils::update_reference(name, rdata); operator = fastn_resolved::evalexpr::Operator::VariableIdentifierRead { identifier: fastn_js::utils::reference_to_js(name.as_str()), } @@ -199,19 +200,17 @@ impl fastn_resolved_to_js::extensions::ExpressionExt for fastn_resolved::Express } } -impl fastn_resolved_to_js::extensions::ArgumentExt for fastn_resolved::Argument { - fn get_default_value(&self) -> Option { +impl fastn_runtime::extensions::ArgumentExt for fastn_resolved::Argument { + fn get_default_value(&self) -> Option { if let Some(ref value) = self.value { Some(value.to_value()) } else if self.kind.is_list() { - Some(fastn_resolved_to_js::Value::Data( - fastn_resolved::Value::List { - data: vec![], - kind: self.kind.clone(), - }, - )) + Some(fastn_runtime::Value::Data(fastn_resolved::Value::List { + data: vec![], + kind: self.kind.clone(), + })) } else if self.kind.is_optional() { - Some(fastn_resolved_to_js::Value::Data( + Some(fastn_runtime::Value::Data( fastn_resolved::Value::Optional { data: Box::new(None), kind: self.kind.clone(), @@ -227,15 +226,15 @@ impl fastn_resolved_to_js::extensions::ArgumentExt for fastn_resolved::Argument properties: &[fastn_resolved::Property], // doc_name: &str, // line_number: usize - ) -> Option { + ) -> Option { let sources = self.to_sources(); - let properties = fastn_resolved_to_js::utils::find_properties_by_source_without_default( + let properties = fastn_runtime::utils::find_properties_by_source_without_default( sources.as_slice(), properties, ); - fastn_resolved_to_js::utils::get_js_value_from_properties(properties.as_slice()) + fastn_runtime::utils::get_js_value_from_properties(properties.as_slice()) /* .map(|v| if let Some(fastn_resolved::Value::Module {}) = self.value.and_then(|v| v.value_optional()) { @@ -247,7 +246,7 @@ pub(crate) fn get_optional_js_value( key: &str, properties: &[fastn_resolved::Property], arguments: &[fastn_resolved::Argument], -) -> Option { +) -> Option { let argument = arguments.iter().find(|v| v.name.eq(key)).unwrap(); argument.get_optional_value(properties) } @@ -256,7 +255,7 @@ pub(crate) fn get_optional_js_value_with_default( key: &str, properties: &[fastn_resolved::Property], arguments: &[fastn_resolved::Argument], -) -> Option { +) -> Option { let argument = arguments.iter().find(|v| v.name.eq(key)).unwrap(); argument .get_optional_value(properties) @@ -267,10 +266,9 @@ pub(crate) fn get_js_value_with_default( key: &str, properties: &[fastn_resolved::Property], arguments: &[fastn_resolved::Argument], - default: fastn_resolved_to_js::Value, -) -> fastn_resolved_to_js::Value { - fastn_resolved_to_js::value::get_optional_js_value(key, properties, arguments) - .unwrap_or(default) + default: fastn_runtime::Value, +) -> fastn_runtime::Value { + fastn_runtime::value::get_optional_js_value(key, properties, arguments).unwrap_or(default) } pub(crate) fn ftd_to_js_variant( diff --git a/ftd/Cargo.toml b/ftd/Cargo.toml index ae1be8f52..65b370127 100644 --- a/ftd/Cargo.toml +++ b/ftd/Cargo.toml @@ -41,7 +41,7 @@ fastn-js.workspace = true indexmap.workspace = true fastn-resolved = { workspace = true, features = ["owned-tdoc"] } fastn-builtins.workspace = true -fastn-resolved-to-js.workspace = true +fastn-runtime.workspace = true [dev-dependencies] diffy.workspace = true diff --git a/ftd/src/executor/main.rs b/ftd/src/executor/main.rs index b9b795174..c1062820f 100644 --- a/ftd/src/executor/main.rs +++ b/ftd/src/executor/main.rs @@ -1,4 +1,4 @@ -use fastn_resolved_to_js::extensions::*; +use fastn_runtime::extensions::*; use ftd::interpreter::expression::ExpressionExt; #[derive(Debug, PartialEq)] diff --git a/ftd/src/interpreter/things/component.rs b/ftd/src/interpreter/things/component.rs index d9c9a80bd..35126a579 100644 --- a/ftd/src/interpreter/things/component.rs +++ b/ftd/src/interpreter/things/component.rs @@ -1,4 +1,4 @@ -use fastn_resolved_to_js::extensions::*; +use fastn_runtime::extensions::*; use ftd::interpreter::expression::ExpressionExt; use ftd::interpreter::things::function::FunctionCallExt; use ftd::interpreter::things::record::FieldExt; diff --git a/ftd/src/js/mod.rs b/ftd/src/js/mod.rs index ace3756c2..42379e14f 100644 --- a/ftd/src/js/mod.rs +++ b/ftd/src/js/mod.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] -use fastn_resolved_to_js::extensions::*; +use fastn_runtime::extensions::*; #[cfg(test)] #[macro_use] @@ -83,14 +83,14 @@ pub struct JSAstData { } pub fn document_into_js_ast(document: ftd::interpreter::Document) -> JSAstData { - use fastn_resolved_to_js::extensions::*; + use fastn_runtime::extensions::*; use itertools::Itertools; let doc = ftd::interpreter::TDoc::new(&document.name, &document.aliases, &document.data); // Check if document tree has rive. This is used to add rive script. let mut has_rive_components = false; - let mut document_asts = vec![fastn_resolved_to_js::from_tree( + let mut document_asts = vec![fastn_runtime::from_tree( &document.tree.as_slice().iter().collect::>(), &doc, &mut has_rive_components, @@ -157,11 +157,11 @@ pub fn document_into_js_ast(document: ftd::interpreter::Document) -> JSAstData { } document_asts.extend(export_asts); - let mut scripts = fastn_resolved_to_js::utils::get_external_scripts(has_rive_components); - scripts.push(fastn_resolved_to_js::utils::get_js_html( + let mut scripts = fastn_runtime::utils::get_external_scripts(has_rive_components); + scripts.push(fastn_runtime::utils::get_js_html( document.js.into_iter().collect_vec().as_slice(), )); - scripts.push(fastn_resolved_to_js::utils::get_css_html( + scripts.push(fastn_runtime::utils::get_css_html( document.css.into_iter().collect_vec().as_slice(), ));