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