pub mod fast;
pub mod fast_v2;
pub mod fast_v3;
pub mod webui;
use crate::component_registry::Component;
use crate::{ParserOptions, Result};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AttributeAction {
Keep,
Skip,
SkipAndCountBinding,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ParserPluginArtifacts {
None,
ComponentTemplates(Vec<ComponentTemplateArtifact>),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ComponentTemplateArtifact {
pub tag_name: String,
pub template: String,
pub template_json: String,
pub template_functions: String,
}
impl ComponentTemplateArtifact {
#[must_use]
pub fn template(tag_name: String, template: String) -> Self {
Self {
tag_name,
template,
template_json: String::new(),
template_functions: String::new(),
}
}
#[must_use]
pub fn webui(tag_name: String, template_json: String, template_functions: String) -> Self {
Self {
tag_name,
template: String::new(),
template_json,
template_functions,
}
}
}
pub trait ParserPlugin {
fn start_fragment(&mut self, _fragment_id: &str) {}
fn configure(&mut self, _options: &ParserOptions) {}
fn register_component_template(
&mut self,
tag_name: &str,
component: &Component,
processed_template: &str,
) -> Result<()>;
fn classify_attribute(&mut self, attr_name: &str) -> AttributeAction;
fn finish_element(&mut self, binding_attribute_count: u32) -> Option<Vec<u8>>;
fn into_artifacts(self: Box<Self>) -> Result<ParserPluginArtifacts> {
Ok(ParserPluginArtifacts::None)
}
}