#![forbid(unsafe_code)]
#![allow(clippy::type_complexity)]
#![cfg_attr(
not(test),
deny(clippy::unwrap_used, clippy::expect_used, clippy::panic)
)]
pub mod format;
pub mod parser;
pub mod slot;
pub mod walker;
#[cfg(any(test, feature = "__fault-injection"))]
#[doc(hidden)]
pub mod fault_injection {
pub const FAULT_TRIGGER: &str = "\u{0}forma-test-fault\u{0}";
}
#[cfg(feature = "dump")]
pub mod dump;
#[cfg(all(doctest, feature = "wasm"))]
mod deprecations;
pub use format::{
IrError, IrHeader, IslandEntry, IslandTrigger, Opcode, PropsMode, SectionDescriptor,
SectionTable, SlotEntry, SlotSource, SlotType, HEADER_SIZE, IR_VERSION, MAGIC,
SECTION_TABLE_SIZE,
};
pub use parser::{IrModule, IslandTableParsed, SlotTable, StringTable};
pub use slot::{json_to_slot_value, SlotData, SlotValue};
pub use walker::{
walk_island, walk_island_with_limits, walk_to_html, walk_to_html_counted,
walk_to_html_with_limits, WalkCounts, WalkFailure, WalkLimits, WalkOutput,
DEFAULT_MAX_LIST_ITERATIONS, DEFAULT_MAX_OUTPUT_BYTES,
};
#[cfg(feature = "wasm")]
use wasm_bindgen::prelude::*;
#[cfg(feature = "wasm")]
#[deprecated(
since = "0.2.2",
note = "the WASM walker goes with the `wasm` feature: re-render an island in the browser \
with @getforma/core's `h()`, as islands already do. Removed in 3.0.0"
)]
#[allow(deprecated)]
#[wasm_bindgen]
#[allow(clippy::panic)]
pub fn render(ir_bytes: &[u8], slots_json: &str) -> String {
let module = parser::IrModule::parse(ir_bytes).unwrap_or_else(|e| panic!("IR parse: {e}"));
let slots =
slot::SlotData::from_json(slots_json, &module).unwrap_or_else(|e| panic!("slots: {e}"));
walker::walk_to_html(&module, &slots).unwrap_or_else(|e| panic!("walk: {e}"))
}
#[cfg(feature = "wasm")]
#[deprecated(
since = "0.2.2",
note = "the WASM walker goes with the `wasm` feature: re-render an island in the browser \
with @getforma/core's `h()`, as islands already do. Removed in 3.0.0"
)]
#[allow(deprecated)] #[wasm_bindgen]
#[allow(clippy::panic)] pub fn render_island(ir_bytes: &[u8], slots_json: &str, island_id: u16) -> String {
let module = parser::IrModule::parse(ir_bytes).unwrap_or_else(|e| panic!("IR parse: {e}"));
let slots =
slot::SlotData::from_json(slots_json, &module).unwrap_or_else(|e| panic!("slots: {e}"));
walker::walk_island(&module, &slots, island_id).unwrap_or_else(|e| panic!("walk island: {e}"))
}