Skip to main content

nsh_core/
lib.rs

1//! Platform-independent core of nsh.
2//!
3//! The core receives [`Op`]s from the JS renderer, maintains the shadow tree,
4//! converts styles to [`taffy`] layout, merges inline text into
5//! [`AttributedText`], runs layout and finally emits a [`MountBatch`] of
6//! [`MountItem`]s that a platform backend applies to native views.
7//!
8//! Everything here is single-threaded and allocation-conscious: the core runs
9//! on the engine thread, between the JS host and the platform backend.
10
11mod byte_size;
12pub use byte_size::ByteSize;
13pub mod access;
14pub mod animation;
15pub mod audio;
16pub mod canvas;
17pub mod clipboard;
18pub mod color;
19mod core;
20mod css;
21mod css_named;
22pub mod desktop;
23mod effects;
24pub mod element;
25pub mod fake;
26mod fenwick;
27pub mod file_dialog;
28pub mod file_type;
29pub mod filesystem;
30pub mod geometry;
31pub mod gpu;
32mod grid;
33pub mod host_channel;
34pub mod i18n;
35pub mod id_table;
36pub mod image;
37pub mod input;
38pub mod js;
39pub mod keyboard;
40pub mod keymap;
41pub mod list_diff;
42pub mod log_file;
43pub mod main_thread;
44pub mod mobile;
45mod mount;
46pub mod navigation;
47pub mod notifications;
48pub mod open_url;
49mod ops;
50pub mod overlay;
51pub mod picker;
52pub mod platform;
53pub mod prelude;
54mod props;
55pub mod reactive;
56pub mod resource;
57#[doc(hidden)]
58pub mod restart;
59pub mod runtime;
60pub mod runtime_data;
61pub mod scroll;
62pub mod selection;
63pub mod shader;
64pub mod shape;
65pub mod single_instance;
66pub mod storage;
67mod style;
68#[cfg(feature = "svg")]
69pub mod svg;
70/// SVG without the renderer: recognized, never drawn.
71#[cfg(not(feature = "svg"))]
72#[path = "svg_off.rs"]
73pub mod svg;
74
75/// Expanded by `asset!`/`assets!` for an SVG file: fails the build when the
76/// native runtime has no SVG renderer, instead of an image that never shows.
77/// The web runtime leaves `svg` off on purpose: the browser draws SVG.
78#[doc(hidden)]
79#[macro_export]
80#[cfg(any(feature = "svg", target_arch = "wasm32"))]
81macro_rules! __require_svg {
82    () => {};
83}
84#[doc(hidden)]
85#[macro_export]
86#[cfg(not(any(feature = "svg", target_arch = "wasm32")))]
87macro_rules! __require_svg {
88    () => {
89        ::core::compile_error!(
90            "this app uses SVG assets, but NSH was built without the `svg` feature: \
91             add \"svg\" to the features of the crate's `nsh-core` dependency (a \
92             `nsh-platform-*` dependency has it on by default; `default-features = \
93             false` turns it off)"
94        );
95    };
96}
97pub mod tailwind;
98mod text;
99pub mod text_edit;
100pub mod time;
101mod transform;
102pub mod transition;
103pub mod url_scheme;
104pub mod web_resource;
105pub mod websocket;
106pub mod webview;
107
108// The derive macros name `::nsh_core`, also in this crate's own tests.
109extern crate self as nsh_core;
110
111/// The values registered native components take and emit (props, events,
112/// command arguments): JSON.
113pub use serde_json::Value as JsonValue;
114#[doc(hidden)]
115pub use text::ApproxPrepared;
116
117pub use crate::{
118    color::{Hsla, Rgba},
119    core::{
120        ApplyError, Core, ListBind, ListScrollPosition, MAX_TREE_DEPTH, Measurement,
121        set_part_requester,
122    },
123    effects::{
124        BackdropMaterial, BlendMode, BoxShadow, ClipInset, ColorStop, Cursor, Effects, Filter,
125        GlassEffect, Gradient, GradientKind, GradientSize, KeyframeAnimation, Keyframes,
126        MacOsBackdrop, MacOsBackdropBlending, MacOsBackdropMaterial, MacOsBackdropState, Outline,
127        Transition, TransitionProps, WindowsBackdrop, WindowsBackdropMaterial, blur_radius,
128        compose_color_matrices,
129    },
130    geometry::{Bounds, Corners, Edges, Point, Points, Size},
131    image::ImageData,
132    keyboard::{KeyCapture, KeyEvent},
133    mount::{
134        AudioSession, ImageOptions, InputConfig, ModalConfig, MountBatch, MountItem,
135        NO_NATIVE_HEADER, NativeProps, NavShader, ScreenConfig, ScrollBehavior, StickyCell,
136        VideoProps, ViewKind, WebProps,
137    },
138    ops::{
139        AlertDialogRequest, AutoCapitalize, AutoFill, BackPhase, BackProgressEvent, CellSlot,
140        CoalescedSample, Command, ContextMenuEvent, DialogButton, DialogButtonStyle, DialogInput,
141        EditAction, EventKind, EventMask, EventPayload, FileContents, FpsMode, Haptic,
142        HapticImpact, HapticNotification, HeaderItem, HeaderItemContent, HeaderSlot,
143        HeaderSystemItem, HeaderTitleAlign, IMAGE_SCALES, ImageProp, ImageScales, ImageSource,
144        KeyboardAppearance, KeyboardDismissMode, KeyboardTaps, KeyboardType, ListAlignment,
145        ListContentStyle, ListViewport, ModalAnimation, ModalPresentation, ModalProp, MouseButton,
146        MouseEvent, NativeProp, NodeId, Op, OverlayProp, PasteBehavior, PasteEvent, PastedFile,
147        PayloadValue, PinchEvent, PinchPhase, PointerType, PressEvent, Prop, ROOT_ID, ResizeMode,
148        ReturnKeyType, RevealOptions, ScreenAnimation, ScreenProp, ScrollAlignment, ScrollProp,
149        ScrollbarSetting, SheetDetent, SnapAlignment, StatusBarConfig, StatusBarSetting,
150        StatusBarStyle, SubmitBehavior, Tag, TextDrop, TouchEvent, TouchPhase, TouchPoint,
151        TransitionFallback, Viewability, WebElement, WebInput, WebKey, WebLoad, WebSource,
152        WheelDelta, WheelEvent, dialog_default_button,
153    },
154    props::{
155        Accessibility, AccessibilityActionDef, AccessibilityCurrent, AccessibilityProp,
156        AccessibilityRole, AccessibilityState, AccessibilityValue, Checked, EdgeInsets,
157        GestureValues, LayoutAnimation, LayoutCurve, LayoutProperty, LayoutTransition, LiveRegion,
158        PanActivation, PanDirection, PanEdge, PointerEvents, Ripple, ScrollEdge, ScrollEdgeElement,
159        ViewProps,
160    },
161    style::{
162        BorderStyle, Borders, Color, CornerRadii, DecorationStyle, EllipsizeMode, EnvVar,
163        FamilyName, FontFamily, FontVariant, GridTemplateValue, LineHeight, ObjectPosition,
164        PaintStyle, PositionAxis, PropertyValue, Style, StyleDecl, StyleError, StyleKey,
165        StylePatch, StyleValue, SvgPaint, TextAlign, TextDecoration, TextShadow, TextStyle,
166        TextTransform, TransformOrigin, TransformProperty, VerticalAlign, ViewStyle,
167        css_font_families, font_families, for_each_font_family,
168    },
169    text::{
170        ATTACHMENT_CHAR, Affinity, ApproxTextEngine, AttachmentAlignments, AttachmentCopyText,
171        AttributedText, BackgroundBox, FontExtent, LinePiece, LinkHref, ResolvedTextStyle,
172        SpanTestId, TextAttachment, TextBackground, TextEngine, TextGeometry, TextLayout, TextLine,
173        TextLink, TextOptions, TextPosition, TextSpan, font_data, font_family, keep_font,
174    },
175    transform::{
176        Decomposed, MAX_TRANSFORMS, Matrix, Transform, TransformKind, TransformOp, translation,
177    },
178};