Expand description
The engine thread of one surface.
The engine owns a nsh_core::Core on a dedicated thread and runs one
app (App): a Rust app’s root component, or a JS bundle in a QuickJS
VM (nsh_js::Host, feature js). Each wake-up (input event, timer,
resize) runs the app’s code (component tasks; JS and its microtasks),
applies what JS committed, lays out, and hands one MountBatch to the
platform through a MountSink. The platform thread never blocks on
the engine.
Re-exports§
pub use nsh_package as package;
Modules§
- perf
- Performance monitoring: what a surface’s frames and commits cost while it
runs, for an on-screen monitor (
--fps) or the app’s own tooling.
Structs§
- Access
- What an app may do: its declaration and the embedder’s grant (when the embedder limits it); an action must be allowed by both.
- Bundle
- An app bundle: its code plus, in development, a source map.
- Capabilities
- What an app may do (one declaration, or one grant).
- Engine
- A running engine. Dropping it stops the thread.
- Engine
Config - Engine settings.
- Engine
Control - A cheap, cloneable handle for sending input to the engine from any thread.
- Environment
- What the platform knows about the surface.
- HotUpdate
- A development update that replaces the app’s changed modules in place,
keeping the JS context, the views and the state of everything else
(made by
nsh_bundler::HotBundle::patch). - Http
Head - The status line and headers of a response, before its body.
- Http
Request - An HTTP request for the platform’s network stack (made by JS
fetch). - Insets
- Edge insets in points.
- Limits
- Resource limits of one VM.
- Loaded
Package - A verified package, unpacked (
load_package). - Local
Engine - An engine driven by its host’s event loop instead of a thread of its
own: the browser’s main thread in WebAssembly, where there are no
threads to block. Input sent through its
EngineControlis handled at the nextLocalEngine::pump. - Locale
- A BCP 47 language tag (
en-US,zh-Hans-CN), held inline so that the environment staysCopy: the language, script and region subtags fit; variants and extensions are dropped. - Policy
- What a bundle’s code may do.
- Root
- The root of a Rust app: makes the app’s top component (on the engine
thread, where elements live). The engine mounts it as the content of the
surface (
nsh_engine::App::Rust). - Theme
- The theme components render with (
super::RenderCx::theme). Derefs to its colors:theme.primary.
Enums§
- App
- The app an engine runs.
- Bundle
Code - The code of a bundle.
- Color
Scheme - The system appearance.
- Fetch
Event - What happens to a request, in order: (for a streamed body) any number
of
BodyWanted; thenHead,Data… andEnd— orFailedat any point. - FetchOp
- What JS asks of a request it made (the JS host queues these for the engine, which hands them to the stack).
- Http
Body - The body of an
HttpRequest. - Idiom
- The kind of device (React Native’s
Platform.isPad,isTV). - Os
- The operating system (
Platform.OS).
Constants§
- BYTECODE_
VERSION - Identifies the bytecode format produced by
compile_bytecodeand accepted bycrate::Host::eval_bytecode: QuickJS bytecode is only valid for the exact engine build. Bump together with therquickjspin.
Traits§
- Assets
- Reads the app’s bundled files (
asset:/…URIs): from the app’s resources, or from the dev server during development. - Fetch
Task - A request in flight, driven from the engine thread.
- Mount
Sink - Receives mount batches on the engine thread. Implementations forward them to the UI thread.
- Network
- The platform’s HTTP stack, used by JS
fetch.
Functions§
- load_
package - Verifies the package
byteswithtrust, writes its assets underassets_root(<root>/<app id>/<package hash>/, once per package) and records its build (older builds of the app are refused from now on). - parse_
capabilities - Parses capabilities in their JSON form (
capabilities.json, the dev protocol, an embedder’s grant).
Type Aliases§
- Fetch
Events - Receives what happens to a request started by
Network::fetch, in order, on any thread. AfterFetchTask::cancelit may still be called (the engine then ignores it).