euv-core 0.47.0

Core cross-platform runtime for euv featuring arena-based fine-grained reactivity, deterministic layout, flat scene graph, multi-mode rendering, and direct OS platform adapters.
Documentation
use super::*;

/// HTML tag name created when mounting a cross-platform canvas surface.
pub(crate) const WEB_CANVAS_TAG: &str = "canvas";

/// CSS custom property exposing `env(safe-area-inset-top)` without DOM mutation or layout reflow.
pub(crate) const WEB_CSS_SAFE_TOP: &str = "--euv-safe-top";

/// CSS custom property exposing `env(safe-area-inset-right)` without DOM mutation or layout reflow.
pub(crate) const WEB_CSS_SAFE_RIGHT: &str = "--euv-safe-right";

/// CSS custom property exposing `env(safe-area-inset-bottom)` without DOM mutation or layout reflow.
pub(crate) const WEB_CSS_SAFE_BOTTOM: &str = "--euv-safe-bottom";

/// CSS custom property exposing `env(safe-area-inset-left)` without DOM mutation or layout reflow.
pub(crate) const WEB_CSS_SAFE_LEFT: &str = "--euv-safe-left";

/// `window.getComputedStyle` property name.
pub(crate) const WEB_METHOD_GET_COMPUTED_STYLE: &str = "getComputedStyle";

/// `CSSStyleDeclaration.getPropertyValue` property name.
pub(crate) const WEB_METHOD_GET_PROPERTY_VALUE: &str = "getPropertyValue";

/// `navigator.gpu` WebGPU capability property name.
pub(crate) const WEB_PROP_GPU: &str = "gpu";

/// WebGPU rendering context identifier passed to `HTMLCanvasElement.getContext`.
pub(crate) const WEB_CONTEXT_WEBGPU: &str = "webgpu";

/// WebGL2 rendering context identifier passed to `HTMLCanvasElement.getContext`.
pub(crate) const WEB_CONTEXT_WEBGL2: &str = "webgl2";

/// WebGL2 context option key disabling alpha compositing overhead.
pub(crate) const WEB_GL_OPT_ALPHA: &str = "alpha";

/// WebGL2 context option key disabling MSAA overhead.
pub(crate) const WEB_GL_OPT_ANTIALIAS: &str = "antialias";

/// WebGL2 context option key disabling depth buffer allocation.
pub(crate) const WEB_GL_OPT_DEPTH: &str = "depth";

/// WebGL2 context option key requesting low-latency desynchronized presentation.
pub(crate) const WEB_GL_OPT_DESYNCHRONIZED: &str = "desynchronized";

/// WebGL2 context option key requesting discrete/high-performance GPU adapter.
pub(crate) const WEB_GL_OPT_POWER_PREF: &str = "powerPreference";

/// WebGL2 `powerPreference` value selecting the highest-throughput GPU.
pub(crate) const WEB_GL_OPT_HIGH_PERFORMANCE: &str = "high-performance";

/// WebGL2 context option key avoiding redundant drawing buffer copies.
pub(crate) const WEB_GL_OPT_PRESERVE_DRAWING: &str = "preserveDrawingBuffer";

/// Global browser `ResizeObserver` constructor name.
pub(crate) const WEB_CTOR_RESIZE_OBSERVER: &str = "ResizeObserver";

/// `ResizeObserver.observe` method name.
pub(crate) const WEB_METHOD_OBSERVE: &str = "observe";

/// `ResizeObserver.disconnect` method name.
pub(crate) const WEB_METHOD_DISCONNECT: &str = "disconnect";

/// WebGL2 `createTexture` method name.
pub(crate) const WEB_GL_CREATE_TEXTURE: &str = "createTexture";

/// WebGL2 `activeTexture` method name.
pub(crate) const WEB_GL_ACTIVE_TEXTURE: &str = "activeTexture";

/// WebGL2 `bindTexture` method name.
pub(crate) const WEB_GL_BIND_TEXTURE: &str = "bindTexture";

/// WebGL2 `texParameteri` method name.
pub(crate) const WEB_GL_TEX_PARAMETERI: &str = "texParameteri";

/// WebGL2 `texImage2D` method name.
pub(crate) const WEB_GL_TEX_IMAGE_2D: &str = "texImage2D";

/// WebGL2 `texSubImage2D` method name.
pub(crate) const WEB_GL_TEX_SUB_IMAGE_2D: &str = "texSubImage2D";

/// Fullscreen triangle vertex shader for WebGL2 GPU-composited framebuffer/dirty-rect presentation.
pub(crate) const WEB_GL2_BLIT_VERT_SHADER: &str = "#version 300 es\n\
out vec2 v_uv;\n\
void main() {\n\
    vec2 pos = vec2((gl_VertexID == 1) ? 3.0 : -1.0, (gl_VertexID == 2) ? 3.0 : -1.0);\n\
    v_uv = vec2(pos.x * 0.5 + 0.5, 0.5 - pos.y * 0.5);\n\
    gl_Position = vec4(pos, 0.0, 1.0);\n\
}\n";

/// Fullscreen triangle fragment shader sampling the uploaded RGBA8 WebGL2 texture.
pub(crate) const WEB_GL2_BLIT_FRAG_SHADER: &str = "#version 300 es\n\
precision mediump float;\n\
in vec2 v_uv;\n\
uniform sampler2D u_tex;\n\
out vec4 out_color;\n\
void main() {\n\
    out_color = texture(u_tex, v_uv);\n\
}\n";

/// Uniform name binding sampler unit 0 in `WEB_GL2_BLIT_FRAG_SHADER`.
pub(crate) const WEB_GL2_UNIFORM_TEX: &str = "u_tex";

/// CSS pixel unit suffix stripped when parsing `getComputedStyle` inset strings.
pub(crate) const WEB_CSS_PX_SUFFIX: &str = "px";

/// Argument index key for single-argument `Reflect::construct` invocation.
pub(crate) const WEB_REFLECT_ARG0_KEY: &str = "0";

/// Inline style HTML attribute name.
pub(crate) const WEB_ATTR_STYLE: &str = "style";

/// Tabindex HTML attribute name enabling keyboard focus on canvas.
pub(crate) const WEB_ATTR_TABINDEX: &str = "tabindex";

/// Default full-viewport body inline CSS eliminating scrollbars and borders.
pub(crate) const WEB_BODY_STYLE: &str =
    "margin:0;padding:0;width:100vw;height:100vh;overflow:hidden;background:#09090b;";

/// Inline CSS prefix for the full-viewport 1:1 physical canvas surface.
pub(crate) const WEB_CANVAS_STYLE_PREFIX: &str =
    "position:fixed;inset:0;width:100%;height:100%;display:block;outline:none;cursor:";

/// Inline CSS suffix disabling browser touch panning and text selection on the canvas surface.
pub(crate) const WEB_CANVAS_STYLE_SUFFIX: &str =
    ";margin:0;touch-action:none;user-select:none;-webkit-user-select:none;";

/// Default canvas tabindex value enabling keyboard focus.
pub(crate) const WEB_ATTR_TABINDEX_ZERO: &str = "0";

/// 2D rendering context identifier passed to `HTMLCanvasElement.getContext`.
pub(crate) const WEB_CONTEXT_2D: &str = "2d";

/// Media query string used to detect browser dark mode preference.
pub(crate) const WEB_DARK_MEDIA_QUERY: &str = "(prefers-color-scheme: dark)";

/// Error message when browser `window` or `document` is unavailable.
pub(crate) const ERR_WEB_WINDOW_MISSING: &str = "browser window or document unavailable";

/// Error message when `HTMLCanvasElement` creation or casting fails.
pub(crate) const ERR_WEB_CANVAS_CREATE: &str = "failed to create HTMLCanvasElement";

/// Error message when `CanvasRenderingContext2d` cannot be acquired.
pub(crate) const ERR_WEB_CTX2D_MISSING: &str = "failed to acquire 2d canvas rendering context";

/// Error message when `ImageData` creation or `putImageData` fails.
pub(crate) const ERR_WEB_PRESENT_FAILED: &str = "failed to blit ImageData to canvas";

/// CSS cursor keyword for default arrow.
pub(crate) const WEB_CURSOR_DEFAULT: &str = "default";

/// CSS cursor keyword for clickable hand pointer.
pub(crate) const WEB_CURSOR_POINTER: &str = "pointer";

/// CSS cursor keyword for text selection I-beam.
pub(crate) const WEB_CURSOR_TEXT: &str = "text";

/// CSS cursor keyword for precision crosshair.
pub(crate) const WEB_CURSOR_CROSSHAIR: &str = "crosshair";

/// CSS cursor keyword for disabled control.
pub(crate) const WEB_CURSOR_NOT_ALLOWED: &str = "not-allowed";

/// CSS cursor keyword for open grab hand.
pub(crate) const WEB_CURSOR_GRAB: &str = "grab";

/// CSS cursor keyword for active grabbing hand.
pub(crate) const WEB_CURSOR_GRABBING: &str = "grabbing";

/// CSS cursor keyword for omnidirectional move.
pub(crate) const WEB_CURSOR_MOVE: &str = "move";

/// CSS cursor keyword for horizontal resize.
pub(crate) const WEB_CURSOR_EW_RESIZE: &str = "ew-resize";

/// CSS cursor keyword for vertical resize.
pub(crate) const WEB_CURSOR_NS_RESIZE: &str = "ns-resize";

/// DOM Element method name entering browser fullscreen.
pub(crate) const WEB_METHOD_REQUEST_FULLSCREEN: &str = "requestFullscreen";

/// DOM Document method name exiting browser fullscreen.
pub(crate) const WEB_METHOD_EXIT_FULLSCREEN: &str = "exitFullscreen";

/// DOM `devicemotion` window event name.
pub(crate) const WEB_EVENT_DEVICE_MOTION: &str = "devicemotion";

/// DOM `deviceorientation` window event name.
pub(crate) const WEB_EVENT_DEVICE_ORIENTATION: &str = "deviceorientation";

/// Global `DeviceMotionEvent` constructor property name on `window`.
pub(crate) const WEB_CTOR_DEVICE_MOTION_EVENT: &str = "DeviceMotionEvent";

/// Global `DeviceOrientationEvent` constructor property name on `window`.
pub(crate) const WEB_CTOR_DEVICE_ORIENTATION_EVENT: &str = "DeviceOrientationEvent";

/// iOS Safari sensor permission static method name on `DeviceMotionEvent` / `DeviceOrientationEvent`.
pub(crate) const WEB_METHOD_REQUEST_PERMISSION: &str = "requestPermission";

/// iOS Safari granted permission string value.
pub(crate) const WEB_PERMISSION_GRANTED: &str = "granted";

/// `window.screen` property name.
pub(crate) const WEB_PROP_SCREEN: &str = "screen";

/// `screen.orientation` / legacy `window.orientation` property name.
pub(crate) const WEB_PROP_ORIENTATION: &str = "orientation";

/// `screen.orientation.angle` property name.
pub(crate) const WEB_PROP_ANGLE: &str = "angle";

/// `DeviceMotionEvent.accelerationIncludingGravity` property name.
pub(crate) const WEB_PROP_ACCEL_INCLUDING_GRAVITY: &str = "accelerationIncludingGravity";

/// `DeviceMotionEvent.acceleration` property name.
pub(crate) const WEB_PROP_ACCELERATION: &str = "acceleration";

/// `DeviceMotionEvent.rotationRate` property name.
pub(crate) const WEB_PROP_ROTATION_RATE: &str = "rotationRate";

/// `DeviceOrientationEvent` / `rotationRate` alpha axis property name.
pub(crate) const WEB_PROP_ALPHA: &str = "alpha";

/// `DeviceOrientationEvent` / `rotationRate` beta axis property name.
pub(crate) const WEB_PROP_BETA: &str = "beta";

/// `DeviceOrientationEvent` / `rotationRate` gamma axis property name.
pub(crate) const WEB_PROP_GAMMA: &str = "gamma";

/// Cartesian `x` component property name.
pub(crate) const WEB_PROP_AXIS_X: &str = "x";

/// Cartesian `y` component property name.
pub(crate) const WEB_PROP_AXIS_Y: &str = "y";

/// Cartesian `z` component property name.
pub(crate) const WEB_PROP_AXIS_Z: &str = "z";

/// Degree-to-radian conversion constant (`PI / 180`).
pub(crate) const WEB_DEG_TO_RAD: f32 = PI / 180.0;

/// Exponential low-pass filter factor used to separate gravity when `DeviceMotionEvent.acceleration` is null.
pub(crate) const WEB_GRAVITY_LPF_ALPHA: f32 = 0.22;

/// Minimum dot-product magnitude between orientation gravity and accelerometer gravity to auto-detect Safari vs W3C sign convention.
pub(crate) const WEB_GRAVITY_SIGN_DOT_THRESHOLD: f32 = 12.0;