euv-core 0.48.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";

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

/// `VisualViewport.width` property name.
pub(crate) const WEB_PROP_WIDTH: &str = "width";

/// `VisualViewport.height` property name.
pub(crate) const WEB_PROP_HEIGHT: &str = "height";

/// `window.open` target name opening external links in a new browser tab.
pub(crate) const WEB_OPEN_TARGET_BLANK: &str = "_blank";

/// `window.open` feature flags preventing reverse tabnabbing on external links.
pub(crate) const WEB_OPEN_FEATURES_SAFE: &str = "noopener,noreferrer";

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

/// Uniform name carrying the physical drawing-buffer size (`vec2`) in `WEB_GL2_BLIT_FRAG_SHADER`.
pub(crate) const WEB_GL2_UNIFORM_VIEW: &str = "u_view";

/// 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";

/// DOM `id` attribute name used to deduplicate injected `<style>` elements.
pub(crate) const WEB_ATTR_ID: &str = "id";

/// HTML `<style>` tag name injected to suppress browser tap-highlight and focus-ring overlays.
pub(crate) const WEB_STYLE_TAG: &str = "style";

/// CSS selector locating the document `<head>` element without extra `web-sys` feature flags.
pub(crate) const WEB_HEAD_SELECTOR: &str = "head";

/// DOM id assigned to the injected zero-highlight browser reset stylesheet.
pub(crate) const WEB_RESET_STYLE_ID: &str = "euv-web-reset";

/// CSS rules suppressing full-canvas tap-highlight blue overlays, touch callouts, text selection, and focus outlines across Chrome, Safari, and Firefox.
pub(crate) const WEB_RESET_STYLE_CSS: &str = "html,body,canvas{-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;user-select:none;-webkit-user-select:none;outline:none;}canvas:focus,canvas:focus-visible{outline:none;}";

/// 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, tap highlights, and borders.
pub(crate) const WEB_BODY_STYLE: &str = "margin:0;padding:0;width:100vw;height:100vh;height:100dvh;overflow:hidden;background:#09090b;touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;outline:none;";

/// 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, tap-highlight overlays, callouts, and text selection on the active foreground canvas surface.
pub(crate) const WEB_CANVAS_STYLE_SUFFIX: &str = ";margin:0;touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;z-index:1;visibility:visible;opacity:1;pointer-events:auto;";

/// Inline CSS style keeping a pre-warming standby `<canvas>` hidden underneath the active canvas until atomic frame-boundary handoff.
pub(crate) const WEB_STANDBY_CANVAS_STYLE: &str = "position:fixed;inset:0;width:100%;height:100%;display:block;outline:none;margin:0;touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;z-index:0;visibility:hidden;opacity:0;pointer-events:none;";

/// HTML `data-euv-canvas-role` attribute name marking active vs standby presentation canvases.
pub(crate) const WEB_ATTR_CANVAS_ROLE: &str = "data-euv-canvas-role";

/// Role attribute value applied to the visible foreground `<canvas>`.
pub(crate) const WEB_CANVAS_ROLE_ACTIVE: &str = "active";

/// Role attribute value applied to a hidden pre-warming standby `<canvas>`.
pub(crate) const WEB_CANVAS_ROLE_STANDBY: &str = "standby";

/// Error message when WebGL2 direct GPU presentation is requested without a live WebGL2 direct pipeline.
pub(crate) const ERR_WEB_GL2_DIRECT_MISSING: &str =
    "WebGL2 direct GPU primitive pipeline unavailable on active canvas";

/// Error message when a WebGL2 context cannot be acquired on a fresh independent canvas.
pub(crate) const ERR_WEB_GL2_CONTEXT_MISSING: &str =
    "failed to acquire independent webgl2 canvas rendering context";

/// WebGL2 direct GPU primitive vertex shader (`#version 300 es`, `precision highp float`) drawing screen-space rectangles without CPU framebuffer upload.
pub(crate) const WEB_GL2_DIRECT_VERT_SHADER: &str = "#version 300 es\n\
precision highp float;\n\
precision highp int;\n\
uniform highp vec2 u_view;\n\
uniform highp vec4 u_rect;\n\
void main() {\n\
    vec2 corner = vec2((gl_VertexID == 1 || gl_VertexID == 4 || gl_VertexID == 5) ? 1.0 : 0.0,\n\
                       (gl_VertexID == 2 || gl_VertexID == 3 || gl_VertexID == 5) ? 1.0 : 0.0);\n\
    vec2 px = u_rect.xy + corner * u_rect.zw;\n\
    vec2 ndc = vec2((px.x / max(u_view.x, 1.0)) * 2.0 - 1.0, 1.0 - (px.y / max(u_view.y, 1.0)) * 2.0);\n\
    gl_Position = vec4(ndc, 0.0, 1.0);\n\
}\n";

/// WebGL2 direct GPU primitive fragment shader (`#version 300 es`, `precision highp float`).
pub(crate) const WEB_GL2_DIRECT_FRAG_SHADER: &str = "#version 300 es\n\
precision highp float;\n\
uniform highp vec4 u_color;\n\
out highp vec4 out_color;\n\
void main() {\n\
    out_color = u_color;\n\
}\n";

/// Uniform name carrying the primitive bounds `[x, y, w, h]` in `WEB_GL2_DIRECT_VERT_SHADER`.
pub(crate) const WEB_GL2_DIRECT_UNIFORM_RECT: &str = "u_rect";

/// Uniform name carrying the normalized RGBA primitive color in `WEB_GL2_DIRECT_FRAG_SHADER`.
pub(crate) const WEB_GL2_DIRECT_UNIFORM_COLOR: &str = "u_color";

/// 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";

/// WebKit-prefixed DOM Element method name entering browser fullscreen on Safari.
pub(crate) const WEB_METHOD_WEBKIT_REQUEST_FULLSCREEN: &str = "webkitRequestFullscreen";

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

/// WebKit-prefixed DOM Document method name exiting browser fullscreen on Safari.
pub(crate) const WEB_METHOD_WEBKIT_EXIT_FULLSCREEN: &str = "webkitExitFullscreen";

/// WebKit-prefixed DOM Document property reporting the active fullscreen element on Safari.
pub(crate) const WEB_PROP_WEBKIT_FULLSCREEN_ELEMENT: &str = "webkitFullscreenElement";

/// 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;

/// DOM element ID for the reusable hidden CSS `env(safe-area-inset-*)` length probe.
pub(crate) const WEB_SAFE_PROBE_ID: &str = "euv-safe-area-probe";

/// HTML `div` tag name used for the hidden safe-area CSS probe element.
pub(crate) const WEB_TAG_DIV: &str = "div";

/// HTML `img` tag name used for browser-native async image decoding.
pub(crate) const WEB_TAG_IMG: &str = "img";

/// Inline CSS rule mapping `env(safe-area-inset-*)` onto real box `padding-*` lengths so every browser resolves exact pixel values.
pub(crate) const WEB_SAFE_PROBE_STYLE: &str = "position:fixed;top:0;left:0;width:0;height:0;visibility:hidden;pointer-events:none;padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px);";

/// CSS computed property name for top padding on the hidden safe-area probe.
pub(crate) const WEB_CSS_PADDING_TOP: &str = "padding-top";

/// CSS computed property name for right padding on the hidden safe-area probe.
pub(crate) const WEB_CSS_PADDING_RIGHT: &str = "padding-right";

/// CSS computed property name for bottom padding on the hidden safe-area probe.
pub(crate) const WEB_CSS_PADDING_BOTTOM: &str = "padding-bottom";

/// CSS computed property name for left padding on the hidden safe-area probe.
pub(crate) const WEB_CSS_PADDING_LEFT: &str = "padding-left";

/// DOM `HTMLImageElement.crossOrigin` property name.
pub(crate) const WEB_PROP_CROSS_ORIGIN: &str = "crossOrigin";

/// CORS anonymous attribute value enabling `<canvas>` pixel readback on cross-origin images.
pub(crate) const WEB_CORS_ANONYMOUS: &str = "anonymous";

/// DOM `HTMLImageElement.src` property name.
pub(crate) const WEB_PROP_SRC: &str = "src";

/// DOM `HTMLImageElement.naturalWidth` property name.
pub(crate) const WEB_PROP_NATURAL_WIDTH: &str = "naturalWidth";

/// DOM `HTMLImageElement.naturalHeight` property name.
pub(crate) const WEB_PROP_NATURAL_HEIGHT: &str = "naturalHeight";

/// DOM `CanvasRenderingContext2D.drawImage` method name.
pub(crate) const WEB_METHOD_DRAW_IMAGE: &str = "drawImage";

/// DOM `load` event name for image elements.
pub(crate) const WEB_EVENT_LOAD: &str = "load";

/// DOM `error` event name for image elements.
pub(crate) const WEB_EVENT_ERROR: &str = "error";

/// HTTP scheme prefix used to detect cross-origin image fetches.
pub(crate) const WEB_SCHEME_HTTP: &str = "http://";

/// HTTPS scheme prefix used to detect cross-origin image fetches.
pub(crate) const WEB_SCHEME_HTTPS: &str = "https://";

/// Maximum rasterized image dimension in pixels when decoding network images onto a 2D canvas.
pub(crate) const WEB_IMAGE_MAX_DIM: u32 = 1024;

/// Default fallback width in pixels for vector SVG images reporting zero intrinsic width.
pub(crate) const WEB_SVG_FALLBACK_WIDTH: u32 = 120;

/// Default fallback height in pixels for vector SVG images reporting zero intrinsic height.
pub(crate) const WEB_SVG_FALLBACK_HEIGHT: u32 = 24;