pub mod ambient;
pub(crate) mod animated;
mod asset;
mod back;
mod component;
pub(crate) mod element;
mod element_ref;
pub(crate) mod env;
mod events;
pub(crate) mod flow;
pub(crate) mod host;
pub(crate) mod keys;
mod module;
mod once;
pub mod palette;
mod prop;
pub mod reactive;
pub(crate) mod responder;
mod scrollable;
pub(crate) mod services;
pub(crate) mod status_bar;
mod style;
pub(crate) mod task;
mod theme;
mod value;
pub(crate) mod virtual_list;
pub const DECLARATIONS: bool = !cfg!(target_arch = "wasm32");
#[macro_export]
macro_rules! decl {
([$($text:expr),* $(,)?]) => {
if $crate::ui::DECLARATIONS { &[$($text),*] as &[&'static str] } else { &[] }
};
($text:expr) => {
if $crate::ui::DECLARATIONS { $text } else { "" }
};
}
pub use nsh_animation::{
Curve, EaseMode, Easing, Extrapolate, Output as AnimationOutput, sample_easing,
};
pub use nsh_macros::{
Event, JsObject, PropEnum, Props, asset, assets, component, methods, module, native_module,
};
pub use self::{
animated::{
Animated, Animation, AnimationEnd, AnimationOperand, Interpolation, NativeNode,
NativeValue, Spring, Timing, sample_decay, sample_decay_within, sample_spring,
},
asset::{AssetFile, AssetKind, FileAsset, FontAsset, ImageAsset, ImageSrc},
component::{
Api, Component, ComponentError, ComponentSpec, Event, EventSpec, Method, MethodSpec,
Methods, NoEvent, Param, PropKind, PropSpec, Props, Registry, Root, declarations,
},
element::{
Accessible, AnyElement, Attrs, BoundListConfig, Child, Children, ComponentElement, ElNode,
Element, FluentBuilder, Image, Interactive, IntoElement, Items, ListConfig, ListElement,
Listener, ParentElement, Position, Slot, SlotElement, Style, Text, View, image, text, view,
},
element_ref::{ComponentRef, ElementRef},
env::Environment,
events::{
GestureEvent, ImageProgress, NativeEvent, PanEvent, ScrollEvent, ScrollOffset, Selection,
VideoInfo, VideoProgress, WebNavigation,
},
flow::{Each, If, IntoElements, Reset, catch_error, dynamic},
host::{
CanvasArg, CanvasPaint, CanvasView, Input, InputAccessoryView, Modal, NativeView,
Orientation, Painter, Screen, Scroll, Stack, Video, WebView, canvas, input,
input_accessory_view, modal, native, screen, scroll, stack, video, web_view, web_view_html,
},
module::{
Function, FunctionCall, FunctionSpec, Module, ModuleCx, ModuleFuture, ModuleParam,
ModuleSpec,
},
once::Scope,
prop::Prop,
reactive::{
IntoReactive, Memo, Owner, Reactive, ReadSignal, Runtime, Signal, SignalEquals, Stored,
batch, cleanup, computed, create_root, effect, provide_context, signal, signal_with,
stored, untracked, use_context,
},
responder::{ClaimRequest, PanGesture, ResponderEvent, TouchClaim},
scrollable::Scrollable,
services::{Prefetch, ToastDuration},
status_bar::StatusBarEntry,
style::{
AdaptiveColor, BorderCurve, FontWeight, Length, StyleRefinement, Styled, WritingDirection,
px, relative, rgb, rgba,
},
task::{Answer, DialogAnswer, ImageSize, Task},
theme::{Theme, ThemeColors, ThemeError},
value::{JsValue, NodeRef, PropError, SharedString, TsType, TsTypes, ts_of},
virtual_list::{ListLayout, ViewableItems, VirtualList, virtual_list},
};
pub(crate) use self::{
back::BackListener,
component::{AnyInstance, caught},
element::{ElKind, PlaceFn},
task::{Action, AnswerSlot, ClipboardRead, Executor},
};
pub use crate::{
AccessibilityRole, AccessibilityState, AutoCapitalize, AutoFill, BlendMode, BoxShadow, Dialog,
DialogButton, DialogButtonStyle, EdgeInsets, EllipsizeMode, EventKind, EventPayload,
KeyboardAppearance, KeyboardDismissMode, KeyboardTaps, KeyboardType, KeyframeAnimation,
Keyframes, LayoutAnimation, LayoutCurve, LayoutProperty, LayoutTransition, Measurement,
ModalAnimation, ModalPresentation, PanActivation, PointerEvents, ResizeMode, ReturnKeyType,
ScreenAnimation, SnapAlignment, StatusBarConfig, StatusBarSetting, StatusBarStyle,
SubmitBehavior, TouchEvent, TransformKind, TransformOrigin, Viewability,
platform::{Appearance, Idiom, Locale, Os},
style::{Color, OriginLen},
};
pub mod prelude {
#[cfg(not(target_arch = "wasm32"))]
pub use super::ambient::{background, blocking};
pub use super::{
AccessibilityRole,
AccessibilityState,
Accessible,
AdaptiveColor,
Animated,
Animation,
AnimationOutput,
AnyElement,
Appearance,
AutoCapitalize,
BlendMode,
BorderCurve,
BoxShadow,
CanvasView,
Child,
Children,
ClaimRequest,
Color,
Component,
ComponentElement,
ComponentError,
ComponentRef,
Curve,
DialogAnswer,
EaseMode,
Easing,
EdgeInsets,
Element,
ElementRef,
Environment,
Event,
EventKind,
EventPayload,
Extrapolate,
FluentBuilder,
FontAsset,
FontWeight,
GestureEvent,
ImageAsset,
Input,
InputAccessoryView,
Interactive,
Interpolation,
IntoElement,
Items,
JsObject,
JsValue,
KeyboardAppearance,
KeyboardDismissMode,
KeyboardTaps,
KeyboardType,
KeyframeAnimation,
Keyframes,
Length,
ListLayout,
Listener,
Measurement,
Method,
Methods,
Modal,
ModalAnimation,
ModalPresentation,
ModuleCx,
NativeEvent,
NativeNode,
NativeValue,
NativeView,
NoEvent,
Orientation,
Painter,
PanActivation,
PanEvent,
PanGesture,
ParentElement,
PointerEvents,
Position,
PropEnum,
Props,
Registry,
ResizeMode,
ResponderEvent,
ReturnKeyType,
Screen,
ScreenAnimation,
Scroll,
ScrollEvent,
ScrollOffset,
Scrollable,
Selection,
SharedString,
Slot,
SnapAlignment,
Spring,
Stack,
Styled,
SubmitBehavior,
Task,
Text,
Theme,
Timing,
ToastDuration,
TouchClaim,
Video,
VideoInfo,
VideoProgress,
View,
Viewability,
ViewableItems,
VirtualList,
WebNavigation,
WebView,
WritingDirection,
asset,
assets,
canvas,
image,
input,
input_accessory_view,
methods,
modal,
module,
native,
native_module,
px,
relative,
rgb,
rgba,
screen,
scroll,
stack,
text,
video,
view,
virtual_list,
web_view,
web_view_html,
};
pub use super::{
Each, If, IntoElements, IntoReactive, Memo, Owner, Prop, Reactive, ReadSignal, Scope,
Signal, SignalEquals, Stored,
ambient::{
Delay, KeyOptions, Spawned, add_status_bar, allow_rtl, animate_layout,
announce_for_accessibility, clipboard_has_string, clipboard_string, color,
component_ref, dark, dialog, dismiss_keyboard, element_ref, font_scale, force_rtl,
global, idiom, image_size, is_desktop, key_label, keyboard_duration, keyboard_height,
locale, measure_text, native_value, next_frame, on_back_press, on_key, on_key_with, os,
os_version, pixel_ratio, prefetch_image, reduce_motion, request_animation_frame,
round_to_nearest_pixel, rtl, safe_area, screen_reader, set_clipboard, set_color_scheme,
set_interval, set_timeout, spawn, theme, timer, timer_until, toast, update_status_bar,
window,
},
batch, catch_error, cleanup, component, computed, dynamic, effect, provide_context, signal,
signal_with, stored, untracked, use_context,
};
}
#[doc(hidden)]
pub mod __private {
pub use serde_json::Map as JsonMap;
#[diagnostic::on_unimplemented(
message = "the app's crate (nsh.json \"rust\") has no `#[native_module(\"…\")]` at its root",
label = "the app's UI set",
note = "add to the crate's lib.rs, with the specifier its TSX imports the set by: `#[native_module(\"my-app/native\")] fn native(registry: &mut Registry) {{ registry.register::<MyComponent>(); }}` (`use nsh_core::ui::prelude::*`)"
)]
pub trait NoNativeModule {}
#[diagnostic::on_unimplemented(
message = "`#[native_module]` goes at the root of the crate (lib.rs)",
label = "nsh's generated workspace calls the entry it makes there",
note = "move the function with `#[native_module(\"…\")]` to the crate's lib.rs"
)]
pub trait NotAtRoot {}
pub fn no_native_module<R: NoNativeModule>() -> R {
unreachable!("never compiles")
}
pub fn native_module_not_at_root<R: NotAtRoot>() -> R {
unreachable!("never compiles")
}
}