use std::sync::atomic::{AtomicBool, Ordering};
use tairitsu_vdom::platform::DomRect;
static ANIMATION_FROZEN: AtomicBool = AtomicBool::new(false);
pub fn is_animation_frozen() -> bool {
ANIMATION_FROZEN.load(Ordering::SeqCst)
}
pub fn set_animation_frozen(frozen: bool) {
ANIMATION_FROZEN.store(frozen, Ordering::SeqCst);
}
pub fn freeze_animations() {
set_animation_frozen(true);
}
pub fn unfreeze_animations() {
set_animation_frozen(false);
}
pub fn log(message: &str) {
eprintln!("{}", message);
}
pub fn log_warn(message: &str) {
eprintln!("WARNING: {}", message);
}
pub fn log_error(message: &str) {
eprintln!("ERROR: {}", message);
}
pub fn inner_width() -> i32 {
1024
}
pub fn inner_height() -> i32 {
768
}
pub fn set_timeout(_callback: impl FnOnce() + 'static, _ms: i32) -> i32 {
0
}
pub fn get_scroll_y() -> f64 {
0.0
}
pub fn scroll_to_with_options(_top: f64, _behavior: &str) {}
pub fn on_resize(_callback: impl FnMut() + 'static) {}
pub fn create_resize_observer(_callback: impl FnMut() + 'static) -> u64 {
0
}
pub fn observe_resize<T>(_observer_id: u64, _element: &T) {}
pub fn disconnect_resize(_observer_id: u64) {}
pub fn create_mutation_observer(_callback: impl FnMut() + 'static) -> u64 {
0
}
pub fn observe_mutations<T>(_observer_id: u64, _element: &T, _options: &MutationObserverOptions) {}
pub fn disconnect_mutation(_observer_id: u64) {}
pub struct MutationObserverOptions {
pub child_list: bool,
pub attributes: bool,
pub character_data: bool,
pub subtree: Option<bool>,
}
impl Default for MutationObserverOptions {
fn default() -> Self {
Self {
child_list: true,
attributes: false,
character_data: false,
subtree: Some(true),
}
}
}
pub fn copy_to_clipboard(_text: &str) -> bool {
false
}
pub fn prefers_dark_mode() -> bool {
false
}
pub fn now_timestamp() -> f64 {
use std::time::SystemTime;
SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap_or_default()
.as_secs_f64()
}
pub fn element_from_point(_x: i32, _y: i32) -> Option<()> {
None
}
pub fn get_target_element_from_event(_client_x: i32, _client_y: i32) -> Option<()> {
None
}
pub fn element_closest<T>(_element: &T, _selector: &str) -> Option<()> {
None
}
pub fn get_bounding_client_rect<T>(_element: &T) -> Option<DomRect> {
None
}
pub fn get_scroll_top_from_point(_x: i32, _y: i32) -> f64 {
0.0
}
pub fn query_selector(_selector: &str) -> Option<()> {
None
}
pub fn query_selector_all(_selector: &str) -> Vec<()> {
Vec::new()
}
pub fn get_element_by_id(_id: &str) -> Option<()> {
None
}
pub fn get_element_rect_by_id(_id: &str) -> Option<DomRect> {
None
}
pub fn get_scroll_top_by_selector(_selector: &str) -> f64 {
0.0
}
pub fn request_animation_frame(callback: impl FnOnce() + 'static) {
let mut cb: Option<Box<dyn FnOnce()>> = Some(Box::new(callback));
let _ = tairitsu_vdom::dom_ops::request_animation_frame(Box::new(move |_| {
if let Some(f) = cb.take() {
f();
}
}));
}
pub fn request_animation_frame_with_timestamp(callback: impl FnOnce(f64) + 'static) -> i32 {
let mut cb: Option<Box<dyn FnOnce(f64)>> = Some(Box::new(callback));
let id = tairitsu_vdom::dom_ops::request_animation_frame(Box::new(move |ts| {
if let Some(f) = cb.take() {
f(ts);
}
}));
id as i32
}
pub fn on_scroll(_callback: impl FnMut() + 'static) {}
pub fn draw_qrcode_on_canvas_by_id(
_canvas_id: &str,
_matrix: &[Vec<bool>],
_modules: usize,
_color: &str,
_background: &str,
) -> bool {
false
}
pub fn get_bounding_rect_by_class_impl<T>(_class: &str, _element: &T) -> Option<DomRect> {
None
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct ContentEditableState {
pub editable: bool,
pub focused: bool,
}
pub fn get_contenteditable_state(_element_handle: u64) -> Option<ContentEditableState> {
None
}
pub fn set_content_editable(_element_handle: u64, _editable: bool) {}
pub fn exec_command(_command: &str, _value: Option<&str>) -> bool {
false
}
pub fn get_selection_start(_element_handle: u64) -> Option<u32> {
None
}
pub fn get_selection_end(_element_handle: u64) -> Option<u32> {
None
}
pub fn get_inner_html(_element_handle: u64) -> String {
String::new()
}
pub fn set_inner_html(_element_handle: u64, _html: &str) {}
pub fn request_fullscreen(_element_handle: u64) {}
pub fn get_element_scroll_top(_element_handle: u64) -> f64 {
0.0
}
pub fn set_element_scroll_top(_element_handle: u64, _value: f64) {}
pub fn video_play(_element_handle: u64) {}
pub fn video_pause(_element_handle: u64) {}
pub fn video_get_current_time(_element_handle: u64) -> f64 {
0.0
}
pub fn video_get_duration(_element_handle: u64) -> f64 {
0.0
}
pub fn video_seek(_element_handle: u64, _time: f64) {}
pub fn video_set_muted(_element_handle: u64, _muted: bool) {}
pub fn video_set_volume(_element_handle: u64, _volume: f64) {}
pub fn create_audio_context() -> u64 {
0
}
pub fn create_analyser_node(_audio_context: u64) -> u64 {
0
}
pub fn create_media_element_source(_audio_context: u64, _element_handle: u64) -> u64 {
0
}
pub fn analyser_node_get_frequency_data(_analyser: u64) -> Vec<f32> {
Vec::new()
}
pub fn analyser_node_get_time_domain_data(_analyser: u64) -> Vec<f32> {
Vec::new()
}