From db1241a1d23932ec5571f7f6ef145acf874b61cf Mon Sep 17 00:00:00 2001 From: Amit Upadhyay Date: Thu, 21 Nov 2024 13:55:15 +0530 Subject: [PATCH] external_js_files implmented --- fastn-resolved/src/function.rs | 10 ++++++++++ v0.5/fastn-compiler/src/utils.rs | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/fastn-resolved/src/function.rs b/fastn-resolved/src/function.rs index 325a692ad..cb44a8c59 100644 --- a/fastn-resolved/src/function.rs +++ b/fastn-resolved/src/function.rs @@ -28,6 +28,16 @@ impl Function { external_implementation: false, } } + + pub fn js(&self) -> Option<&str> { + match self.js { + Some(fastn_resolved::PropertyValue::Value { + value: fastn_resolved::Value::String { ref text }, + .. + }) => Some(text), + _ => None, + } + } } #[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)] diff --git a/v0.5/fastn-compiler/src/utils.rs b/v0.5/fastn-compiler/src/utils.rs index c9cff1921..d273a02ef 100644 --- a/v0.5/fastn-compiler/src/utils.rs +++ b/v0.5/fastn-compiler/src/utils.rs @@ -29,11 +29,11 @@ impl fastn_compiler::Compiler { used_definitions .values() .filter_map(|definition| match definition { - fastn_resolved::Definition::WebComponent(web_component) => { - web_component.js().map(ToOwned::to_owned) - } + fastn_resolved::Definition::WebComponent(web_component) => web_component.js(), + fastn_resolved::Definition::Function(f) => f.js(), _ => None, }) + .map(ToOwned::to_owned) .collect() }