Skip to main content

euv_core/
lib.rs

1//! euv-core
2//!
3//! Core cross-platform runtime for euv featuring arena-based fine-grained reactivity,
4//! deterministic Flexbox/Grid layout, flat retained scene graph, multi-mode rendering
5//! (Auto, Software, Hardware, Hybrid), unified window abstractions, and direct OS API
6//! backends for Web, Android, iOS, iPadOS, macOS, Windows, and Linux.
7
8mod app;
9mod build_mode;
10mod dynamic;
11mod font;
12mod game;
13mod layout;
14mod media;
15mod panic_forensics;
16mod parallel;
17mod platform;
18mod reactive;
19mod render;
20mod runtime;
21mod scene;
22mod style;
23mod system;
24mod window;
25
26#[cfg(test)]
27#[path = "../tests/mod.rs"]
28mod tests;
29
30pub use {
31    app::*, dynamic::*, font::*, game::*, layout::*, media::*, panic_forensics::*, parallel::*,
32    platform::*, reactive::*, render::*, runtime::*, scene::*, style::*, system::*, window::*,
33};
34
35#[cfg(target_arch = "aarch64")]
36use std::arch::aarch64::{
37    float32x4_t, uint32x4_t, vaddq_f32, vaddvq_f32, vaddvq_u32, vandq_u32, vcgeq_f32, vcleq_f32,
38    vdupq_n_f32, vld1q_f32, vld1q_u32, vmlaq_f32, vorrq_u32, vst1q_f32,
39};
40#[cfg(all(target_arch = "wasm32", target_feature = "simd128"))]
41use std::arch::wasm32::{
42    f32x4, f32x4_add, f32x4_extract_lane, f32x4_ge, f32x4_le, f32x4_mul, f32x4_splat, i8x16,
43    i32x4_bitmask, u8x16_narrow_i16x8, u8x16_splat, u8x16_sub, u8x16_swizzle, u16x8_add,
44    u16x8_extend_high_u8x16, u16x8_extend_low_u8x16, u16x8_mul, u16x8_shr, u16x8_splat,
45    u32x4_splat, v128, v128_load, v128_or, v128_store,
46};
47#[cfg(target_arch = "x86_64")]
48use std::arch::x86_64::{
49    __m128, _mm_add_ps, _mm_cmpge_ps, _mm_cmple_ps, _mm_loadu_ps, _mm_movemask_ps, _mm_mul_ps,
50    _mm_or_ps, _mm_set1_ps, _mm_storeu_ps,
51};
52#[cfg(all(unix, not(target_os = "watchos")))]
53use std::ffi::CStr;
54#[cfg(all(unix, not(target_os = "watchos")))]
55use std::ffi::CString;
56#[cfg(all(unix, not(target_os = "watchos")))]
57use std::ffi::c_char;
58#[cfg(any(target_os = "macos", target_os = "ios"))]
59use std::mem::size_of_val;
60#[cfg(windows)]
61use std::os::windows::io::AsRawHandle;
62#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
63use std::process::{Command, Stdio};
64#[cfg(target_os = "android")]
65use std::ptr::copy_nonoverlapping;
66#[cfg(any(all(unix, not(target_os = "android")), windows))]
67use std::ptr::null;
68#[cfg(target_arch = "wasm32")]
69use std::sync::{Arc, Mutex, MutexGuard, OnceLock};
70use std::{
71    any::{Any, TypeId},
72    borrow::Cow,
73    cell::{Cell, Ref, RefCell, RefMut, UnsafeCell},
74    collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque},
75    error::Error,
76    f32::consts::{FRAC_PI_2, FRAC_PI_3, PI, SQRT_2, TAU},
77    fmt::{self, Formatter},
78    hash::{Hash, Hasher},
79    marker::PhantomData,
80    mem::{MaybeUninit, align_of, size_of, swap, take, transmute},
81    ops::{Add, Mul, Sub},
82    panic::{AssertUnwindSafe, PanicHookInfo, catch_unwind, set_hook, take_hook},
83    path::{Path, PathBuf},
84    ptr::{drop_in_place, null_mut},
85    rc::Rc,
86    slice::{from_raw_parts, from_raw_parts_mut},
87    str::{Chars, from_utf8},
88    sync::atomic::{AtomicBool, AtomicPtr, AtomicU8, AtomicU32, AtomicU64, AtomicUsize, Ordering},
89    thread::panicking,
90};
91#[cfg(not(target_arch = "wasm32"))]
92use std::{
93    backtrace::Backtrace,
94    env,
95    fs::{self, File},
96    hint::spin_loop,
97    io::{
98        self, BufRead, BufReader, ErrorKind, IsTerminal, Read, Seek, SeekFrom, Write, stderr,
99        stdout,
100    },
101    net::{SocketAddr, TcpStream, ToSocketAddrs},
102    str::Lines,
103    sync::{Arc, Condvar, Mutex, MutexGuard, OnceLock, PoisonError},
104    thread::{Builder, JoinHandle, available_parallelism, current, sleep},
105    time::{Duration, Instant, SystemTime, UNIX_EPOCH},
106};
107#[cfg(any(unix, windows))]
108use std::{ffi::c_void, ptr::NonNull};
109#[cfg(unix)]
110use std::{mem::zeroed, os::unix::io::AsRawFd, sync::atomic::AtomicI32};
111#[cfg(all(test, not(target_arch = "wasm32")))]
112use std::{net::TcpListener, thread::spawn};
113
114use {
115    lombok_macros::{CustomDebug, Data, Getter, New},
116    serde::{
117        Deserialize, Serialize,
118        ser::{SerializeStruct, Serializer},
119    },
120    serde_json::{Value, from_str, to_string, to_string_pretty},
121};
122
123#[cfg(target_arch = "wasm32")]
124use {
125    js_sys::{Array, Function, Object, Promise, Reflect, Uint8Array, global},
126    wasm_bindgen::{Clamped, JsCast, JsValue, closure::Closure},
127    web_sys::{
128        CanvasRenderingContext2d, Document, DomRect, Element, Event, HtmlCanvasElement,
129        HtmlElement, ImageData, MediaQueryList, Navigator, Performance, TextMetrics,
130        WebGl2RenderingContext, WebGlBuffer, WebGlFramebuffer, WebGlProgram, WebGlRenderbuffer,
131        WebGlShader, WebGlTexture, WebGlUniformLocation, WebGlVertexArrayObject, Window, window,
132    },
133};