use vize_carton::String;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum ParseMode {
#[default]
Base,
Html,
Sfc,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum TextMode {
#[default]
Data,
RcData,
RawText,
CData,
AttributeValue,
}
#[derive(Debug, Clone)]
pub struct ParserOptions {
pub mode: ParseMode,
pub whitespace: WhitespaceStrategy,
pub delimiters: (String, String),
pub is_pre_tag: fn(&str) -> bool,
pub is_native_tag: Option<fn(&str) -> bool>,
pub is_custom_element: Option<fn(&str) -> bool>,
pub is_void_tag: fn(&str) -> bool,
pub get_namespace: fn(&str, Option<&str>) -> crate::Namespace,
pub on_error: Option<fn(crate::CompilerError)>,
pub on_warn: Option<fn(crate::CompilerError)>,
pub comments: bool,
}
impl Default for ParserOptions {
fn default() -> Self {
Self {
mode: ParseMode::Base,
whitespace: WhitespaceStrategy::Condense,
delimiters: (String::from("{{"), String::from("}}")),
is_pre_tag: |_| false,
is_native_tag: None,
is_custom_element: None,
is_void_tag: vize_carton::is_void_tag,
get_namespace: |_, _| crate::Namespace::Html,
on_error: None,
on_warn: None,
comments: true,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum WhitespaceStrategy {
#[default]
Condense,
Preserve,
}
#[derive(Debug, Clone)]
pub struct TransformOptions {
pub filename: String,
pub prefix_identifiers: bool,
pub hoist_static: bool,
pub cache_handlers: bool,
pub scope_id: Option<String>,
pub ssr: bool,
pub ssr_css_vars: Option<String>,
pub binding_metadata: Option<BindingMetadata>,
pub inline: bool,
pub is_ts: bool,
}
impl Default for TransformOptions {
fn default() -> Self {
Self {
filename: String::from("template.vue"),
prefix_identifiers: false,
hoist_static: false,
cache_handlers: false,
scope_id: None,
ssr: false,
ssr_css_vars: None,
binding_metadata: None,
inline: false,
is_ts: false,
}
}
}
#[derive(Debug, Clone, Default)]
pub struct BindingMetadata {
pub bindings: rustc_hash::FxHashMap<String, BindingType>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BindingType {
SetupLet,
SetupMaybeRef,
SetupRef,
SetupReactiveConst,
SetupConst,
Props,
PropsAliased,
Data,
Options,
LiteralConst,
}
#[derive(Debug, Clone)]
pub struct CodegenOptions {
pub mode: CodegenMode,
pub prefix_identifiers: bool,
pub source_map: bool,
pub filename: String,
pub scope_id: Option<String>,
pub ssr: bool,
pub optimize_imports: bool,
pub runtime_module_name: String,
pub runtime_global_name: String,
pub is_ts: bool,
pub inline: bool,
pub binding_metadata: Option<BindingMetadata>,
}
impl Default for CodegenOptions {
fn default() -> Self {
Self {
mode: CodegenMode::Function,
prefix_identifiers: false,
source_map: false,
filename: String::from("template.vue"),
scope_id: None,
ssr: false,
optimize_imports: false,
runtime_module_name: String::from("vue"),
runtime_global_name: String::from("Vue"),
is_ts: false,
inline: false,
binding_metadata: None,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum CodegenMode {
#[default]
Function,
Module,
}
#[derive(Debug, Clone, Default)]
pub struct CompilerOptions {
pub parser: ParserOptions,
pub transform: TransformOptions,
pub codegen: CodegenOptions,
}