pax-runtime-api 0.39.1

Userland constructs used at the runtime API boundary of Pax Engine
Documentation
#![allow(unused)]
//! Compiler-facing type and property spelling constants.

// Runtime API type names used by parser and manifest plumbing.
pub const NUMERIC: &str = "Numeric";
pub const SIZE: &str = "Size";
pub const ROTATION: &str = "Rotation";
pub const DURATION: &str = "Duration";
pub const OPACITY: &str = "Opacity";
pub const DEGREES: &str = "Degrees";
pub const RADIANS: &str = "Radians";
pub const PIXELS: &str = "Pixels";
pub const PERCENT: &str = "Percent";
pub const MILLISECONDS: &str = "Milliseconds";
pub const SECONDS: &str = "Seconds";
pub const FRAMES: &str = "Frames";
pub const INTEGER: &str = "Integer";
pub const I64: &str = "I64";
pub const F64: &str = "F64";
pub const TRUE: &str = "true";
pub const COLOR: &str = "Color";
pub const COLOR_CHANNEL: &str = "ColorChannel";

// Template-node sentinel type IDs.
pub const TYPE_ID_IF: &str = "IF";
pub const TYPE_ID_REPEAT: &str = "REPEAT";
pub const TYPE_ID_SLOT: &str = "SLOT";
pub const TYPE_ID_COMMENT: &str = "COMMENT";

// Property names that every renderable node may accept.
pub const COMMON_PROPERTIES: [&str; 20] = [
    "id",
    "x",
    "y",
    "padding_x",
    "padding_y",
    "scale",
    "scale_x",
    "scale_y",
    "skew",
    "skew_x",
    "skew_y",
    "anchor",
    "anchor_x",
    "anchor_y",
    "rotate",
    "transform",
    "width",
    "height",
    "opacity",
    "layout_role",
];

// Multi-axis common-property aliases expanded into their axis-specific forms.
// These intentionally cover the suffix-based common properties; generic names
// like `size` would shadow existing component APIs.
pub const COMMON_PROPERTIES_2D: &[(&str, [&str; 2])] = &[
    ("scale", ["scale_x", "scale_y"]),
    ("skew", ["skew_x", "skew_y"]),
    ("anchor", ["anchor_x", "anchor_y"]),
];

// Checks whether contextual `into` inference should be attempted for a target type.
pub fn is_intoable_downstream_type(type_to_check: &str) -> bool {
    BLESSED_INTOABLE_DOWNSTREAM_TYPES
        .iter()
        .any(|bidt| type_to_check.contains(*bidt))
}

// Only when parsing values for one of the types in this slice
// will we look ahead and parse for an IntoableLiteral value.
const BLESSED_INTOABLE_DOWNSTREAM_TYPES: [&'static str; 7] = [
    "pax_engine::api::Size",
    "pax_engine::api::Rotation",
    "pax_engine::api::ColorChannel",
    "pax_engine::api::Opacity",
    "pax_engine::api::Stroke",
    "pax_engine::api::Paint",
    "pax_engine::api::Fill",
];

// Common property names paired with their compiler-facing type spellings.
pub const COMMON_PROPERTIES_TYPE: &[(&str, &str)] = &[
    ("id", "String"),
    ("x", "pax_engine::api::Size"),
    ("y", "pax_engine::api::Size"),
    ("padding_x", "pax_engine::api::Size"),
    ("padding_y", "pax_engine::api::Size"),
    ("scale", "pax_engine::api::Size"),
    ("scale_x", "pax_engine::api::Size"),
    ("scale_y", "pax_engine::api::Size"),
    ("skew", "pax_engine::api::Rotation"),
    ("skew_x", "pax_engine::api::Rotation"),
    ("skew_y", "pax_engine::api::Rotation"),
    ("anchor", "pax_engine::api::Size"),
    ("anchor_x", "pax_engine::api::Size"),
    ("anchor_y", "pax_engine::api::Size"),
    ("rotate", "pax_engine::api::Rotation"),
    ("transform", "pax_engine::api::Transform2D"),
    ("width", "pax_engine::api::Size"),
    ("height", "pax_engine::api::Size"),
    ("opacity", "pax_engine::api::Opacity"),
    ("layout_role", "pax_engine::api::LayoutRole"),
    ("_raycastable", "bool"),
];