#![deny(missing_docs)]
#![doc = include_str!("../README.md")]
mod attribute;
pub mod callback;
pub mod context;
pub mod data_element_value;
pub mod dom;
mod event_listener;
pub mod input;
pub mod local_storage;
pub mod node_property;
pub mod stripe;
mod output_change;
#[cfg(feature = "macros")]
pub use afia_component_macro::*;
#[doc(hidden)]
pub mod _macro;
#[cfg(feature = "emulate-imports")]
pub mod emulated;
#[derive(Clone)]
pub struct ComponentImports {
component_imports_ptr: *const std::ffi::c_void,
#[expect(
unused,
reason = "Only here to ensure that the emulated imports don't get dropped."
)]
#[cfg(feature = "emulate-imports")]
created_via_emulated_imports: Option<std::sync::Arc<emulated::EmulatedImportsPtr>>,
}
impl ComponentImports {
pub const fn new_dynamically_linked() -> Self {
Self {
component_imports_ptr: std::ptr::null(),
#[cfg(feature = "emulate-imports")]
created_via_emulated_imports: None,
}
}
#[cfg(feature = "emulate-imports")]
pub fn new_emulated() -> (emulated::EmulatedImports, Self) {
let emulated = emulated::EmulatedImports::new();
let imports = emulated.component_imports();
(emulated, imports)
}
pub(crate) fn pointer(&self) -> *const std::ffi::c_void {
self.component_imports_ptr
}
}
#[derive(Clone)]
pub struct ComponentOutputArgs {
pub ctx: *mut (),
pub imports: ComponentImports,
pub inputs_ptr: *const u8,
}
pub trait FromComponentOutputArgs {
fn from_args(args: ComponentOutputArgs) -> Self;
}
impl FromComponentOutputArgs for ComponentImports {
fn from_args(args: ComponentOutputArgs) -> Self {
args.imports.clone()
}
}