Expand description
day-core: the Piece model, realized tree, mounter, layout engine, and event routing (DESIGN.md §5, §7). Build-once: pieces are constructed exactly once; all dynamism flows through reactive bindings (day-reactive) writing to the thread-local tree.
Re-exports§
pub use element_id::ElementId;pub use element_id::IntoElementKey;pub use frame::FrameConsumer;pub use frame::add_frame_consumer;pub use frame::frame_consumer_count;pub use frame::install_frame_requester;pub use frame::remove_frame_consumer;pub use image::Bitmap;pub use image::CanvasExports;pub use image::RenderBitmap;pub use image::RenderPdf;pub use image::canvas_exports;pub use image::decode as decode_image;pub use image::decode_async as decode_image_async;pub use image::image_decode_support;pub use image::image_encode_formats;pub use image::image_encode_support;pub use image::render_bitmap;pub use image::render_bitmap_async;pub use image::render_pdf;pub use image::render_pdf_async;pub use image::resolve_bitmap_render;pub use image::resolve_image_decode;pub use image::resolve_image_encode;pub use image::resolve_pdf_render;pub use lifecycle::dispatch_lifecycle;pub use lifecycle::lifecycle_supported;pub use lifecycle::on_lifecycle;pub use list::BuiltRow;pub use list::ListDeleteDriver;pub use list::ListDriver;pub use list::ListReorderDriver;pub use list::ListSectionsDriver;pub use list::ListSwipeDriver;pub use list::install_list;pub use list::list_reload;pub use list::list_scroll_to_end;pub use list::list_scroll_to_row;pub use list::list_set_editing;pub use list::list_set_selected;pub use list::list_splice;pub use list::list_try_delete;pub use list::list_try_reorder;pub use list::list_try_swipe;pub use list::set_scripted_reorder;pub use shortcuts::set_launcher_shortcuts;pub use status::KeepRunning;pub use status::remove_status_item;pub use status::set_app_progress;pub use status::set_dock_visible;pub use status::set_keep_running;pub use status::set_status_item;pub use status::status_items;pub use documents::on_open_files;pub use documents::request_open_files;pub use toolbar::Chrome;pub use toolbar::chrome_changed;pub use toolbar::current_chrome;pub use toolbar::current_page_column;pub use toolbar::current_page_gate;pub use toolbar::current_page_window;pub use toolbar::dispatch_toolbar_value;pub use toolbar::patch_chrome;pub use toolbar::patch_toolbar;pub use toolbar::register_contribution;pub use toolbar::register_contribution_gated;pub use toolbar::register_toolbar_value;pub use toolbar::relabel_contribution;pub use toolbar::unregister_contribution;pub use toolbar::update_contribution;pub use toolbar::window_being_built;pub use toolbar::with_page;pub use toolbar::with_page_gated;pub use toolbar::with_page_in;pub use tree_driver::TreeBuiltRow;pub use tree_driver::TreeDriver;pub use tree_driver::TreeMovesDriver;pub use tree_driver::install_tree;pub use tree_driver::tree_driver;pub use tree_driver::tree_reload;pub use tree_driver::tree_reveal;pub use tree_driver::tree_set_expanded;pub use tree_driver::tree_set_selected;pub use tree_driver::tree_try_move;pub use tree_driver::tree_visible_rows;pub use windows::WindowHandle;pub use windows::about_action_id;pub use windows::check_for_updates;pub use windows::check_for_updates_action_id;pub use windows::current_window;pub use windows::finish_window_open;pub use windows::focused_scope;pub use windows::focused_window;pub use windows::initial_window;pub use windows::launch_options;pub use windows::monitors;pub use windows::open_about;pub use windows::open_new_window;pub use windows::open_new_window_for_group;pub use windows::open_preferences;pub use windows::open_window;pub use windows::quit;pub use windows::register_about;pub use windows::register_about_window;pub use windows::register_check_for_updates;pub use windows::register_new_window;pub use windows::register_new_window_for;pub use windows::register_preferences;pub use windows::register_preferences_with;pub use windows::window_by_key;pub use windows::window_title;pub use linkme;
Modules§
- conformance
- Tests that run inside a built Day app (docs/testing.md): a
Caseis a page plus a drive, or a headless run, declared next to the code it tests with#[day::test]and collected in a registry. The dayscript engine runs them on a real toolkit underday test; the mock harness runs the same functions undercargo test. Nothing here knows how a step is executed: aDriveBackenddoes, and the engine supplies one. - documents
- File activation is data delivery, never route navigation. See docs/documents.md.
- element_
id - Declared element identities.
id!is the only declaration surface; the catalog is collected at link time, including declarations in helpers which have never mounted. - frame
- Window-scoped display scheduling (docs/frames.md). Native frame requests are shared by
one-shot clients, continuous subscriptions and the legacy
frame_clockpiece. No timers, no implicit physics clamp, and no native request when there is no demand. - image
- Raster images (docs/images.md): decoding encoded bytes into a native image, reading what it
is, encoding it back, and releasing it again. Rendering a canvas drawing into a bitmap or a
PDF (docs/canvas.md “Exporting”) lives here too: a rendered bitmap is the same
Bitmapa decode returns, held in the same toolkit table. - lifecycle
- App-lifecycle callbacks (docs/lifecycle.md). An app registers closures for
day_spec::Lifecyclephases withon_lifecycle; each backend, at the matching moment in its native app/activity delegate, emitsEvent::Lifecycle(phase)(or day-core dispatches the launch phases uniformly), and the event pump routes it here to run the closures inside a reactive batch, the same rails asEvent::MenuAction, so a lifecycle handler that writes signals updates the UI like any callback. - list
- Recycling-list driver (docs/list.md, §10). The native list host owns scrolling + cell reuse;
Day owns row content. day-core injects a
day_spec::ListSourceinto the backend; when the native data-source pulls a cell,bind_rowbuilds it once (per physical cell) and thereafter rebinds it (one slot-write) as the cell recycles. - menu
- Menu action dispatch (§ menus). The model (
day_spec::MenuItem) is toolkit-neutral and carries only ids for its actions; the closures live here, keyed by id. A backend firesEvent::MenuAction(id)when a native item is chosen; the event pump routes it todispatch_menu_action, which runs the app’s closure. Ids are process-unique and monotonic. - shield
- The system-gesture / interactive-dismiss / status-bar shield (docs/cover.md): the registries
behind the
defers_system_gestures,interactive_dismiss_disabledandstatus_bar_hiddenmodifiers. Each mounted modifier pushes an entry while its subtree is alive; the union of entries is the app’s current request. - shortcuts
- The app’s launcher shortcuts at run time (docs/deep-links.md “Launcher shortcuts”).
- status
- The app’s presence outside its windows (docs/status-item.md): status items, progress on the Dock or taskbar icon, the macOS Dock icon itself, and whether the app keeps running when its last window closes.
- testing
- Opt-in presentation policy for functional walkthroughs: fast mode is reduced motion forced on (docs/accessibility.md), nothing more. This is not a virtual clock: timers, network requests, physics and media retain their real timing.
- toolbar
- Toolbar contributions (docs/toolbars.md). The model (
day_spec::ToolbarItem) is toolkit-neutral and carries only ids for its commands; the closures live here, keyed by id, the same shape ascrate::menuand the same id space, so one closure can back both a toolbar button and its menu-bar twin. - tree_
driver - Recycling-tree driver (docs/tree.md).
crate::list’s shape addressed by token instead of row index: the native tree host owns scrolling, disclosure and cell reuse; Day owns row content. day-core injects aday_spec::TreeSourceinto the backend; when the native data-source pulls a cell,bind_rowbuilds it once (per physical cell) and thereafter rebinds it (one slot-write) as the cell recycles. - tween
- Tweening for self-drawn content (docs/tween.md): the pieces a canvas animation needs that native widgets get from their toolkit.
- windows
- Secondary windows (docs/windows.md): the app-facing
open_windowAPI, the per-window registry, and the fallback that presents window content as a fullscreen cover where the toolkit cannot open windows (Cap::MultiWindow=Unsupported).
Macros§
- id
- Declare an ID at its piece, including a link-time catalog entry.
- tls_
group - Re-exported so every crate above day-core can reach it without taking a direct day-reactive dependency (see day-reactive for what it does and why Android needs it).
Structs§
- AnyPiece
- Type-erased piece for heterogeneous branches and dynamic construction.
- Aspect
Ratio Layout - The
aspect_ratiodecorator (§5.2): the largestwidth / height == ratiobox that fits what the parent proposes, with the child given that whole box. - Asset
Dir - A bundled-asset directory (§18.5): a folder’s path relative to
resource/assets/,/-separated, no trailing slash. The generatedres::assets::…tree carries one constant per folder, sharing its module’s name:res::assets::web::minisiteis theAssetDirandres::assets::web::minisite::index_htmla file within it. - Asset
Name - The bundled-data name that
resourceresolves by: the file’s path relative toresource/assets/,/-separated (a top-level file is just its file name, extension included). - Blocking
- The blocking pool (docs/async.md):
spawn_blockingruns a job on a worker thread and resolves on the awaiting side; std-only, so it lives in day-async and is re-exported here. The futurespawn_blockingreturns: the job’s value once a pool thread has run it. - BuildCx
- Cell
Center - A recycled tree cell’s anchor layout (docs/tree.md): row content hugs its own height, so
center it in the cell’s fixed row height;
PassThroughpins it to the top, which reads as a misaligned row whenever the content is shorter than the row (a 16pt label in a 28pt row sat 6pt high). Width still fills; a content taller than the row clamps to it. - Cell
Metrics - A list cell’s anchor layout (docs/list.md “Row metrics”): the row sits inside the platform’s
row margins and the cell is at least the platform’s row height, content centered in it.
With zero metrics it is
PassThrough. - Composed
Sheet - A composed modal sheet (docs/cover.md “Modal sheet”): the cover’s content on a card in the window’s own background color, centered over a dimmed fill that spans the cover. The cover itself is clear and takes every click, so the page shows through but stays out of reach.
- Cover
Layout - Fullscreen cover (docs/cover.md): the cover node occupies no space where it sits in the
tree (its native surface is presented over the window, outside the parent’s bounds), and
its content is laid out at the size the backend reported via
Event::FrameChanged, the same native-owned-frame contract asNavLayoutpages. - Engine
Cx - Fill
Through - Paint/clip wrapper (
.background,.corner_radius, the animatable layers): likePassThroughfor measurement, but the granted rect flows to the child verbatim at place time. These containers exist to paint or clip the area the parent granted, so a grow stretch above them must reach the painted surface (the grid-cell card case) instead of being re-hugged at every wrapper. Under a parent that places at measured size (every stack, grid rigid cell, and overlay) bounds equal the measure and nothing changes. - Flex
- Read-only layout facts a parent may consult about a child (§7.2 ChildRef).
- Flow
Layout - A wrapping row (docs/size-classes.md “Adaptive pieces”): children keep their natural
measure and lay out leading-to-trailing, breaking onto a new line where the next child
would overflow the proposed width. Wrapping replaces main-axis negotiation, so flex is
inert here: nothing grows, and a
spacer()contributes nothing. RTL mirroring comes fromplace_child, the same as every layout. - Font
Family - The family name of a bundled custom font, feeding
Font::custom. Holds a&'static str(soFontstaysCopy); generatedres::fonts::…constants supply it. The untypedFont::Custom(&'static str, f64)variant remains the escape hatch for a family known another way. - Frame
Layout - Grid
Facts - Per-node grid facts (docs/grid.md), carried on
Flex: the shipped form of the §7.2 ChildRef facts surface. Set at build time bygrid_rowand the.grid_span/.grid_alignmodifiers; onlyGridLayoutreads them. - Grid
Layout - SwiftUI-style grid negotiation (docs/grid.md): columns are inferred from
grid_rowchildren, a column’s width is the max ideal width of its span-1 cells, agrow_wcell makes its column flexible (leftover width split evenly, theStackLayoutshare rule), and a non-row child is a full-width cell spanning every column.spacer()is an inert empty cell. The contract: exactly two measure proposals per cell per layout, unconstrained (pass A) and at the final column width (pass B), andplacere-runs the same proposals, so it measures from cache. - Grow
Layout - The
grow/grow_w/grow_hdecorators (§5.2): a single-child wrapper carrying growFlexso the parent stack OFFERS it the space, and a greedy measure/place so the child actually FILLS it. Non-grown axes hug the child (likeframe(maxWidth: .infinity)on one axis). - Image
Name - The bundled-image name that
resource()callers resolve by (the file stem). - Inspector
Layout - Inspector split (docs/inspector.md): the two pane frames are native-owned (an
NSSplitView’s panes, a dock widget), so Day lays each pane’s content within the size the toolkit last reported viaEvent::FrameChanged, the same native-owned-frame contract asNavLayoutpages. The fallback before the first report splits the host bounds at the pane width when visible, and gives the content everything when hidden. - Leaf
Layout - Native leaf: measurement delegates to the toolkit.
- MaxHeight
Layout - The
.max_height(h)decorator,MaxWidthLayout’s vertical twin: proposes at mosthto the child, so a scroll or anything else that takes the height it is offered stops ath, while shorter content still hugs. Where the parent offers less thanh(a phone held sideways), the child gets that, so a capped box still fits a short screen. The horizontal axis passes through untouched. - MaxWidth
Layout - The
.max_width(w)decorator (docs/layout.md): proposes at mostwto the child, so text wraps instead of overflowing, while narrower content still hugs. The vertical axis passes through untouched. - MinWidth
Layout - The
.min_width(w)decorator: the child measures as it would, but never reports narrower thanw, and is placed across whatever width the wrapper is given. A stretching control (a slider) in a row that is being squeezed thereby overflows its row instead of shrinking to nothing, which is what lets alabeledrow notice and stack (docs/forms.md). The vertical axis passes through untouched. - NavController
- A mounted host’s control surface. Closures run user code (route builders), so the registry
Never holds a borrow across a call (§3.3 discipline: clone the
Rcout, then call). - NavLayout
- Navigation host (docs/navigation.md): page frames are native-owned (splitter panes,
nav-controller views), so
set_frameon pages is a toolkit no-op; Day lays each page’s content within the size the toolkit last reported viaEvent::FrameChanged, falling back to a sidebar/detail split (or the full host) of the host bounds. - NavToken
- Opaque handle from
register_nav; a nested host callsunregister_navon dispose. - Node
Data - Node
Probe - Cached last-applied props for the dayscript element index (§14.2).
- Overlay
Layout - Z-layering (§overlay): children share the container bounds, stacked back-to-front in child
order (first child = bottom of the z-order), each positioned by a single
Alignment.size_to_firstreports only the first child’s natural size, the badge/annotation sizing ofoverlay(the annotation does not grow the frame); otherwise the layout reports the union (max) of all children’s natural sizes, the ZStack sizing ofzstack. No native work: the container is the same panel ascolumn/row, so backends stack children by attach order. - Padding
Layout - Pass
Through - Single-child pass-through (root, wrappers, group fallback): top-leading.
- PieceFn
- A closure kept as a concrete piece: the deferral primitive (§5.2).
- Present
Future - RNode
- Realized-node key.
NodeId(the spec-boundary id) is its FFI encoding. - Reserve
Layout - Reserve at least the size of a sample child, then lay the content out inside it.
- Resource
- A handle to a bundled resource’s bytes with efficient random read-only access.
- Scroll
Layout - Scroll viewport (§7.6): greedy on the proposal; content measured unconstrained on the
scroll axis and reported via
set_scroll_content. Children are placed in the scroll’s content coordinate space (the scroll node is their native ancestor). - Sleep
- Future returned by
sleep. - Split
Layout - Native split (docs/split.md): the two pane frames are native-owned (an
NSSplitView’s, aGtkPaned’s, aQSplitter’s), so Day lays each pane’s content within the size the toolkit last reported viaEvent::FrameChanged, theInspectorLayoutcontract. The fallback before the first report divides the host bounds by the bound fraction along the axis. - Stack
Layout - Column/row negotiation (§7.2): rigid children first, remaining main-axis space divided
among flexible children;
spacer()is maximally flexible; group anchors expand inline. - Task
Handle - A handle to a spawned
task.Copyand!Send(the executor is thread-local). - Text
Metrics Cache Stats - What
measure_text’s cache has done on this thread: a diagnostic, for an app that wants to see whether its drawing is measuring the same strings over and over (it usually is). - Tree
- Vector
Name - The bundled-vector name that
resource()callers resolve by (docs/vectors.md): the stem of aresource/vectors/SVG (or.symbolsetbundle). Vectors and images share one per-backend resolution namespace; staging guarantees every vector name resolves as whatever form that backend loads natively (a VectorDrawable, a catalog entry, a rasterized PNG).
Enums§
- Alignment
- Two-axis placement of a child within a container’s bounds (SwiftUI’s
Alignment). Used by the z-layering primitives (OverlayLayout):zstack,overlay/overlay_aligned. - Axis
- Blocking
Error - The blocking pool (docs/async.md):
spawn_blockingruns a job on a worker thread and resolves on the awaiting side; std-only, so it lives in day-async and is re-exported here. Why aBlockingfuture resolved without its job’s value. - Boundary
- Measure-invalidation boundary (§7.4):
Yesstops upward needs-measure propagation (scroll viewports, nav pages). Named enum instead of a bare bool at call sites (docs/api-style.md). - Cross
Align - Either
- A build-time branch between two piece TYPES, without erasing either (§5.1).
- Presentation
Mode - Whether Day presents native controls or holds requests for an explicit script response. Scripted mode does not synthesize answers or affect OS permissions/external applications.
- Scroll
Target - A programmatic scroll destination (§7.6, docs/scroll.md). Edges are axis extremes
(
Top/Bottomvertical,Leading/Trailinghorizontal, i.e. start/end in layout direction);Offsetpins the viewport origin to a content-space point (clamped by the platform);Idreveals the element with that dayscript id inside its nearest enclosing scroll. - Window
Root Reply TreeOps::open_window_root’s answer: the tree-level face ofday_spec::WindowOpenReply, carrying the adopted (or parked) root node.
Constants§
- NAV_
LIST_ WIDTH - Default preferred width of a navigation host’s content-list pane
(
props::NavProps::list_width, docs/navigation.md), Mail’s message-list proportion. - NAV_
SIDEBAR_ WIDTH - SYNTHESIZED_
TEXT - The tag of the
Event::Customsynthesize_textsends to a piece of a kind day-core does not paint itself, carrying the text, just before theTextChangedthat follows it. A piece whose native view owns the characters shows the text on this event and then sees theTextChangedas the echo it already handles. - VERSION
- The linked Day runtime version, for diagnostics from independently versioned extensions.
Traits§
- Ambient
- State an ancestor provides once and any descendant reads back by type: SwiftUI’s
@EnvironmentObject, and Day’s answer to “where does app state live?” (docs/state.md). - Layout
- Open layout protocol (§7.2).
childrenare the node’s direct children; group nodes (when/eachanchors) are layout-transparent: stacks expand them inline. - Layout
Ops - The engine surface visible to
Layoutimplementations. - NavStore
- A key/value sink a nav surface’s
.restorepersists its state through, so navigation survives a relaunch or an Android process death (docs/navigation.md).day::launchinstalls the preferences store (day_part_preferences::install_nav_store) unless the app installed one first; an app marks the surfaces it wants remembered with.restore(key). With no store installed,.restoreis a silent no-op, so a surface’s.restorecall never fails to build. - Piece
- A UI description consumed once (§5.2). Returns the root realized node it created.
- Piece
Seq - Children of a container (§5.1): a tuple of pieces (the floem
ViewTuplepattern), aVecor array of one piece type, or anOptionof a piece. Implemented for exactly those shapes, never via a blanket, to stay coherent. All of them are build-time children: evaluated once when the parent builds, with no keyed identity or reconciliation. A child that must come and go at runtime is awhen, akeyed, or aneach. - TreeOps
Functions§
- announce
- Speak
textthrough the screen reader without moving its focus (docs/accessibility.md): the outcome of an action the user cannot otherwise learn about (“Saved”, “3 results”). The sentence waits for whatever is being read to finish;announce_urgentinterrupts it. Nothing happens when no screen reader is running, and nothing happens on a toolkit that answersCap::AnnouncewithUnsupported. - announce_
urgent announce, interrupting what the screen reader is saying: an error, or a change that cannot wait.- app_
environment - The app-wide
T: created on the reactive root scope the first time it is asked for, and returned unchanged by every later call (docs/state.md). - app_
temp_ dir - An app-writable scratch directory (docs/files.md), re-exported from
day_spec::presentsoday_core::app_temp_dir()keeps working for the pieces layer’s file-save staging. An app-writable scratch directory: the backend-supplied one, elsestd::env::temp_dir(). Used by the file-save flow (docs/files.md) to stage bytes before the native save picker. - application_
handlers - Query current system associations on the UI thread. macOS AppKit implements all query
kinds; other backends return
Unsupported. No application is launched by discovery. - backend_
name - The compile-time target key of the running backend (
"macos-appkit","ios-uikit", …, thePlatform::TARGETstring), recorded bylaunch_with.Nonebefore launch. - blocking_
inline - The blocking pool (docs/async.md):
spawn_blockingruns a job on a worker thread and resolves on the awaiting side; std-only, so it lives in day-async and is re-exported here. Whetherspawn_blockingruns jobs inline: always on the web, else perset_blocking_inline. - blocking_
limit - The blocking pool (docs/async.md):
spawn_blockingruns a job on a worker thread and resolves on the awaiting side; std-only, so it lives in day-async and is re-exported here. How many threads the blocking pool may hold at once: the machine’s parallelism, at least four (a job waiting behind three slow ones still gets a thread), at most thirty-two. Zero on the web, where jobs run inline. - blocking_
threads - The blocking pool (docs/async.md):
spawn_blockingruns a job on a worker thread and resolves on the awaiting side; std-only, so it lives in day-async and is re-exported here. How many pool threads exist right now, idle ones included: for diagnostics and tests. - capability
- Query the active toolkit’s support for a capability (docs). Lets app/piece code adapt its
content to the backend, e.g. a page can skip a title the native nav already shows in a header
(
Cap::NavHeader), or pick a presentation fromCap::NavSplit. - clear_
controllers - Drop every controller: a fresh mount / test boot (called from tree install/uninstall).
- clear_
text_ metrics_ cache - Drop every cached measurement (the counters keep running).
- current_
anim - The ambient animation set by the innermost enclosing
with_animation, if any. - current_
route - The full current route: every mounted surface’s contribution, outermost to innermost,
/-joined (docs/navigation.md).None= no surface mounted;Some("")= everything at its root. Round-trips throughnavigate, so persisting navigation state issave(current_route())on the way out andnavigate(&saved)on the way back in. - dark_
mode - Whether the platform is rendering in dark appearance (see
Toolkit::dark_mode): the branch apps take when painting custom opaque surfaces so fills track the theme that the default text colors already follow. - debug_
title_ tag - The development tag every window title carries in a debug build:
(<version>/<toolkit>[/<script>]), for example(1.1.0/appkit), or(1.1.0/gtk/walkthrough.yaml)while a dayscript is driving. With several apps, toolkits and scripted runs open at once, the title bar is the only place that says which window is which. - default_
browser - The OS-chosen browser for HTTPS links, read afresh rather than cached by Day.
- direction_
of_ locale - The writing direction a locale implies (language subtag match).
- edit_
action_ id - The standing dispatch id behind a
MenuRole::Cut/Copy/Pasteitem on a toolkit whose role items come back as plain menu actions (docs/menus.md): the closure invokes the installed edit bridge. Durable across menu installs, like the undo pair. - encode_
route - Assemble a route string from segments and params, the inverse of
parse_route. Reserved characters (/,?,&,=,%) in segments and params are percent-encoded. - enqueue_
event - The enqueue-only event sink installed into every backend (§8.3). May be invoked re-entrantly from inside any Toolkit method; dispatch happens at the next safe point.
- enqueue_
events - Enqueue several events into one drain before dispatching. Backends that observe a focus
move at a single point (Qt’s
focusChanged(old, new), an AppKit first-responder change) deliver the loss+gain pair through this so the pump can dispatch the gain first and a shared group signal never passes throughNone(docs/focus.md). - environment
- Read the nearest ambient
Tprovided by an enclosingwith_environment, orNoneif none is in scope. Call it while constructing or building a piece within that subtree. - focus_
search - Activate the focused window’s searchable navigation surface (for a Find command).
- focused_
environment - The ambient
Tof the window that currently has focus (docs/state.md): SwiftUI’s@FocusedValue. - focused_
node - The node that currently has the keyboard, as the platform last reported it. Keys follow
focus (docs/menus.md), so this is where a synthetic key has to land for a scripted run to
exercise the same route a real one does.
Nonewhen nothing focusable holds it. - font_
families - The platform’s font families with their faces (docs/fonts.md), enumerated once per
process through
Toolkit::font_familiesand cached: the answer is stable for the process (bundled fonts register before the tree exists, and nothing tracks a system font install under a running app; the OS font panels cache too), enumeration is expensive, and the query is synchronous on the UI thread. Sorted case-insensitively by family, deduplicated, and unioned with the bundled fonts (day_spec::fonts::bundled_fonts) the toolkit’s own database did not report, which is how ares/font/(Android),ms-appx(XAML) orregisterFont(HarmonyOS) family reaches a font menu without each shim parsing sfnt. Empty where the toolkit answersCap::FontList=Unsupported. - has_
launch_ deeplink - Whether a launch deep link is pending (
DAY_DEEPLINKor a platform hint). A nav surface’s.restorereads this so a deep link wins over restored state (docs/navigation.md). - has_
nav_ store - Whether a
NavStoreis installed.day::launchinstalls the preferences store when the app has not installed one of its own. - has_
tree - id_of
- Resolve a dispatched
NodeIdback to the app-authored.id()string that named its node (find_by_id’s inverse, §5.5), orNonefor an id-less node or one no longer in the tree. The recorder (day::record, §14.6) calls this from inside its event observer to label a tap/input with the id an app would target in a dayscript step. Borrow-safe: returnsNonerather than panicking if the tree is momentarily borrowed by a re-entrant backend call. - id_
to_ rnode - init_
logging - Install Day’s default logger and level, unless the app already installed its own.
- init_
presentation_ mode - Initialize browser hosts, which have no process environment, before constructing the UI. Further windows must not reset a policy selected by a running script.
- inline_
search_ host - The inline search host the reserved
day::searchid names when no bar item carries it: the most recently shown one in the focused window. - install_
edit_ bridge - Wire the app’s standard-edit handlers to the platform (docs/menus.md):
stateis a tracked read whose value mirrors into the toolkit (Cap::EditBridge: native menu validation enables the stock Cut/Copy/Paste exactly as it does for text widgets), and every invocation a platform route delivers comes back throughon_invoke. On a toolkit with no native route, themenu_role(Cut/Copy/Paste)items dispatch here instead (the same standing-id fallback the undo pair uses). Call once, after launch; installing again replaces the wiring. Most apps wantday::install_edit_commands, which adds the clipboard transport. - install_
undo_ bridge - Wire an undo history to the platform (docs/model.md): the four signals mirror into the
toolkit’s native front where one exists (
Cap::UndoBridge: the stock Edit menu retitles and enables itself, the platform’s gestures land), and every invocation the platform delivers comes back throughon_invoke(redo). On a toolkit without a native undo system the state goes nowhere and the app’s own affordances call the stack directly; installing the bridge is still harmless. Call once, after launch; installing again replaces the wiring. - invalidate_
size - Tell layout that a node’s intrinsic size may have changed. For tweaks (docs/tweaks.md): after a native call that alters a widget’s preferred size (fonts, tick marks, bezel styles), the measure cache along the node’s path must be invalidated, since Day can’t see native mutations it didn’t make. Relayout runs at the next turn boundary as usual. No-op on a disposed node.
- invoke_
edit - Invoke the installed edit bridge (the same handler the platform’s Cut/Copy/Paste route reaches, clipboard transport included), returning whether one is installed. An app’s own affordances (a context menu’s Cut/Copy) call this rather than duplicating the clipboard plumbing (docs/menus.md).
- invoke_
undo - Invoke the installed undo bridge (the same handler a native front reaches: ⌘Z, the Edit
menu, a three-finger swipe), returning whether one is installed. The dayscript
undo:/redo:steps drive history through this, so a walkthrough needs no app-provided undo button on any target. - is_
mounted - Whether a tree is installed on this thread, i.e. whether the app has already launched.
- is_rtl
- Whether the app is being rendered right-to-left (docs/localization), a convenience over
layout_direction. The layout engine already mirrors widget placement under an RTL locale, but acanvasdraws in its own coordinate space, so a custom drawing that has a reading direction (a battery that drains one way, an arrow, a progress sweep) can call this to mirror itself. Fixed for the life of the process, likelayout_direction. - label_
of - A human-readable label for a node, for annotating a recorded script (§14.6): the accessibility
label if one is set (
.a11y(label = …), the localized string the screen reader speaks), otherwise the control’s own visible text.Nonewhen the node carries neither. - launch_
with - Launch a Day app on the given platform backend: sets up the reactive scheduler and the cross-thread poster, mounts the root piece into the window’s content container, runs the initial layout, and installs the turn-end layout callback (§3.3). The backend then owns the native main loop.
- layout_
direction - The app-wide layout direction (docs/localization): mirrors every horizontal placement in
the place pass when
day_geometry::LayoutDirection::Rtl. Resolved lazily from theDAY_LOCALElaunch environment (so toolkits can read it before any UI exists);set_layout_direction(called byinstall_localesfor the resolved locale) overrides. Fixed for the life of the process; switching locale at runtime does not re-mirror. - measure_
text - Measure one line of canvas text at
sizepoints infont(docs/fonts.md), in the engine that drawsDrawOp::Text; a toolkit that cannot measure answersTextMetrics::approximate, so a caller always gets a usable box. - modifiers
- The keyboard modifiers held right now, for interactions whose meaning they change (shift-click adds to a selection). Touch backends answer all-false; a dayscript step’s declared modifiers take precedence while it dispatches.
- nav_
back - Pop one level, day-initiated (the toolkit presents the pop). Native-initiated pops arrive as
Event::NavBackand go through the owning host’spopdirectly. - nav_
store_ load - Read a
.restorekey through the installedNavStore(Noneif none is installed or the key was never saved). - nav_
store_ save - Write a
.restorekey through the installedNavStore(a no-op if none is installed). - navigate
- Navigate to a route (docs/navigation.md).
- note_
appearance_ changed - Re-read the toolkit’s appearance into the reactive
dark_modesignal. Backends call this when the system appearance changes under a running app (macOS theme switch, GTK style-manager change), andset_appearancecalls it after applying an override, so closures readingdark_mode()recolor live instead of going stale until a rebuild. - note_
motion_ changed - Re-read the toolkit’s reduce-motion setting into
reduce_motion. Backends call this when the user flips the setting under a running app;launch_withcalls it once the tree stands, which is the launch read. Likenote_appearance_changed, it may fire before the tree is installed and then does nothing. - note_
navigation - Announce a navigation to
routefrom its source: a nav host (the sidebar nav host) calls this the instant it changes the bound selection, so the observer sees it synchronously instead of waiting for the route to settle intoNAV_STACKa frame later (whichmaybe_notify_route_changereads). Deduped like the pump-boundary path.routeis the host’s local key, which replays as a relativenavigate(innermost-first), correct for both a top-level sidebar and a nested one. - note_
text_ size_ changed - The system text size changed under a running app (iOS Dynamic Type, a desktop’s text
scaling): every text measurement Day holds is stale. Backends call this from the platform’s
notification, once the native text has taken the new size. Day re-measures every node and
re-lays every bound list row, so a content-sized row (docs/list.md “Row heights”) takes its
new height through
ListPatch::RowSizeInvalidated. Skipped when the tree is busy or not installed yet: a tree built after the change measures at the new size anyway. - on_
open_ url - Register on the UI thread. Return true to consume a URL; false retains normal deep-link routing. Delivery never performs a privileged action.
- open_
url - Open
urlin the platform’s default handler (system browser forhttp(s), mail client formailto:, …). The function behind thelinkpiece; call it directly from a tap handler for a custom affordance. Fire and forget: no result, unopenable URLs are ignored by the backend. - open_
url_ with_ application - Open a URL or file URL in a chosen application. Await on the UI executor. Success means the OS accepted the open request; tab/window presentation belongs to the receiving app.
- override_
size_ class - Force a class the window is not at: dayscript’s
size_class:step and tests. - parse_
route - Split a route string into its path segments and query params. Segments and param
names/values are percent-decoded (
%2F→/, …); everything else is taken literally. - pending_
presentation - The most recently opened still-pending presentation, for dayscript inspection/response.
- piece_
fn - A piece from a closure, built when the tree reaches it.
- piece_
operation - Dispatch to the live node’s kind. Returns false without calling
doneif the node or operation is absent. A true result means the handler accepted responsibility for completion. The registry and tree are not borrowed while the handler runs, so it may update the tree or register another operation. - prepare_
remount - Tear the current mount down so the app can be built again in the same process (docs/settings.md “Appearance on Android”).
- present
- Present a modal request under the current policy and await its answer (docs/dialogs.md).
The pieces layer wraps
this in
Alert/confirm/prompt; call it directly for a customPresentSpec. - presentation_
mode - The current UI-thread presentation policy. Ordinary app launches default to native.
- pump_
events - Dispatch queued native events from the backend queue, containing any panic. Native event
callbacks reach Day through
extern "C"signal trampolines (GTK’svalue_changed_trampoline, Qt’s event filters, …) that abort the process on unwind (panic_cannot_unwind). A panic in a Day event handler or its reactive drain (e.g. the reactive-cycle assertion firing during a slider drag) would thereforeSIGABRTthe whole app instead of surfacing. Catch it at this single backend-agnostic boundary, log it (the message carries the offending effect’s source location), and reset the runtime so the app keeps running (degraded) rather than crashing. - pump_
generation - The current pump generation (see
PUMP_GEN). Read by the recorder’s nav coalescing. - rc_
layout - Helper for constructing shared layout Rcs.
- reduce_
motion - Whether motion should be reduced (docs/accessibility.md): the user’s system setting
(
Toolkit::reduce_motion), or a launch that forced it (DAY_REDUCE_MOTION=1, andday launch --fast, whose fast mode is this setting forced on). Day already applies every finite animation at its destination under it and keeps only indeterminate motion; this read is for the motion an app drives itself, such as aday::framesimulation or a decorative loop, which the app opts down. Reactive: a closure reading it re-runs when the setting flips. - reduce_
motion_ now reduce_motionuntracked and borrow-free, for the animation gates inside the tree.- register_
nav - Install a controller (innermost = last). Returns its token. The root
nav()registers once and never unregisters; nested hosts (tabs()in a route) unregister when their scope disposes. - register_
piece_ operation - Register a named operation for one piece kind. Use a namespaced name and document its input and output. Registering the same kind and name replaces only that handler.
- register_
search_ host - Record
hostas showing an inline search field. Registered by the host’s builder for the life of its scope; seeinline_search_host. - request_
open_ url - Platform intake. Keeps the original URL, including its scheme, query and escaping.
- request_
route - Ask the app to navigate, from anywhere, at any time.
- reset_
ambient - Reset every window’s ambient state (tests; pairs with
uninstall_tree). - resolve_
presentation - Deliver a native answer (the modal already dismissed itself). Called from
pump_eventsonEvent::PresentResult. - resource
- Open a bundled resource by name for efficient random read-only access.
- respond_
presentation - Answer a pending modal programmatically (dayscript). Resolves with the given result first (removing the pending request), then dismisses the control only if it was presented natively. Scripted requests never enter the toolkit. The native dismissal’s own completion event finds nothing pending and is a no-op. False = no such pending request.
- restore_
reported_ size_ class - Undo an
override_size_class: back to the class the window itself last reported. - rnode_
to_ id - route_
param - The value of one query param of the most recent
navigate(None= not present). - route_
params - The query params carried by the most recent
navigatecall (?name=value&…). Read them inside a destination builder:route_param("id"). They describe the navigation in flight; a push you perform by writing a path signal directly carries its data in your own state instead (docs/navigation.md). - safe_
area - The window’s safe-area insets, in points. Zero on every backend that clamps Day’s root to
the safe area natively (the default everywhere); nonzero only where a backend runs the root
edge-to-edge, today day-toolkit-material’s opt-in immersive mode (docs/layout.md, the android
platform page). Compose it yourself where a background should run under the system bars:
paint the background unpadded, pad the content by these insets. The read is tracked, but
layout attributes like
.paddingcapture the value at build time, so a mid-run inset change (rotation) does not re-pad already-built pages. - scroll_
to - Imperatively scroll a
scrollpiece (docs/scroll.md):nodeis the scroll node for edge and offset targets (ScrollTarget::Idignores it and reveals the named element in its own nearest scroll). Animated on-screen; dayscript uses the unanimated variant for determinism. Call with no tree borrow held. - seed_
safe_ area - Backend-facing: the first window’s safe-area insets, known before its content builds and
before the tree that owns them exists (an overlay title bar’s height, docs/window-chrome.md).
The first window’s content reads them at build time; later changes go through
set_safe_area. - set_
app_ badge - Put a badge on the app’s icon: the Dock, launcher, home screen, or taskbar (docs/badge.md).
- set_
appearance - Override the app’s appearance:
Some(true)dark,Some(false)light,Nonefollow the system again. On backends reportingCap::Appearancethe native widgets restyle in place anddark_modeanswers the override; app-painted surfaces pick it up on their next rebuild. Other backends ignore the call; probe before offering a theme picker. - set_
contained_ panic_ observer - Register the contained-panic observer. First registration wins; later calls are no-ops (there is one crash reporter per process).
- set_
event_ observer - Install (or clear, with
None) an observer that sees every event day-core dispatches, in queue order, at the one point every backend funnels native events through (enqueue_events, §8.3), before the event reaches the app, so it observes exactly what the app receives. This is the recording/telemetry hook behindday::record(§14.6): a higher layer captures user actions into a replayable dayscript without touching any of the backends. Main-thread only; aNoneobserver adds no cost to the event path. The boxed closure is adopted into anRcinternally soenqueue_eventscan call it with no borrow held. - set_
launch_ deeplink - Record the host’s launch deep link before
launch_withruns (docs/navigation.md). Platform glue only; apps navigate withnavigate.DAY_DEEPLINK, where a process environment exists, takes precedence. - set_
layout_ direction - Override the layout direction (normally from
install_locales). Must be called before the first layout pass to take effect everywhere. - set_
log_ level - Set the maximum level that will be emitted. Separate from
init_loggingbecause the web launch path has to supply the level from the page URL rather than the environment, and because an app may want to raise or lower it at runtime. - set_
log_ sink - Install the line sink. First registration wins (one host per process). Called before launch;
day::web::startdoes it for the browser. - set_
modifier_ override - Scoped modifier stand-in for the dayscript executor:
Somewhile a step with declared modifiers dispatches, back toNoneafter. - set_
nav_ observer - Install (or clear, with
None) the navigation observer. Resets the dedup baseline so the next change fires regardless of where recording started. - set_
nav_ store - Install the app’s navigation persistence store (docs/navigation.md). Call once at startup,
before the UI mounts, so a
.restoresurface reads it on first build. A later call replaces the store. - set_
presentation_ mode - Change policy for subsequent presentations. Answer existing requests first: switching cannot make an already-open system picker disappear.
- set_
resource_ opener - Register the active backend’s resource opener (Android
AAssetManager, GTKGResource, QtQResource, ArkUI rawfile, …). Called once during backend init. A second call is ignored, so a backend that shares the default file opener need not call this at all. - set_
safe_ area set_window_safe_areaagainst the primary window, which is what a single-window backend reports.- set_
size_ class set_window_size_classagainst the primary window, which is what a single-window backend reports.- set_
window_ safe_ area - Backend-facing: report a window’s safe-area insets (points). Call from the native inset pass
whenever the value changes; apps observe it through
safe_area. - set_
window_ size_ class - Backend-facing: report a window’s size class. Call whenever the window’s size changes; the signal only notifies when the bucket changes, so a resize within one class is free.
- share_
support - Whether the current toolkit can present a native sharing chooser.
- share_
url - Present a native chooser for a URL. Call directly from user activation (required on web). Returns false if unavailable or presentation failed; cancellation is not an error and no completion is implied. The caller owns any explicitly labeled fallback.
- size_
class - The current window’s size class, or
Noneon a backend that does not report one yet. Tracked: a piece that lays out from this rebuilds when the window crosses a breakpoint. - sleep
- Resolve after (at least)
msmilliseconds, on the UI thread: the portable delay forday::taskflows (docs/async.md). RidesPlatform::post_delayed, so it works on single-threaded hosts (web) wherestd::thread::sleep+Settercannot. - spawn_
blocking - The blocking pool (docs/async.md):
spawn_blockingruns a job on a worker thread and resolves on the awaiting side; std-only, so it lives in day-async and is re-exported here. Runjobon a pool thread and resolve to its value on the awaiting side. - synthesize_
text - Deliver synthetic typing to a text control (the dayscript
inputstep and the autodrive string commands both route here): paint the widget via the ordinary app-write patch, then enqueue theTextChangedevent. Both halves are needed: when a real user types, the text is already in the native field by the time its change event fires, so the two-way binding’s echo guard suppresses the write-back (§4.4); a synthesized event alone would drive the app’s signal while the widget kept showing its old text. - task
- Spawn an async flow onto Day’s main-loop executor. This is the opt-in entry point for actions
that open modals or pickers:
button.action(|| day::task(async move { … .await … })). The future is polled once before this returns; the returned handle canTaskHandle::abortit and is freely discardable. At app termination pending tasks are dropped while reactive state is still available. Tasks submitted after shutdown begins are dropped without being polled. - text_
metrics_ cache_ stats - Read the
measure_textcache’s counters (docs/fonts.md). - toolkit_
key - The toolkit key of the running backend (
"appkit","gtk", …, thePlatform::TOOLKITstring), recorded bylaunch_with.Nonebefore launch. - try_
with_ tree - Like
with_tree, but returnsNoneinstead of panicking when the tree can’t be entered: already borrowed, or not installed yet. A snapshot (TreeOps::snapshot) holds the borrow while the backend draws the window synchronously, and that draw can re-enter Day through a native callback, e.g. a lazy list’sviewForRow/connect_bind/cellForRowfiring duringcacheDisplayInRect. And platform style callbacks can fire beforeinstall_tree, e.g. GTK’s StyleManager emits adarknotify whilestartupapplies a forcedDAY_THEMEscheme, beforeactivatemounts the tree; a panic there unwinds into a C signal trampoline and aborts the process. Such callbacks use this and skip their work; the next real layout (or the signal’s first post-mount read) catches up. - undo_
action_ id - The standing dispatch id behind a
MenuRole::Undo/Redoitem on a toolkit with no native undo responder (docs/menus.md): activating the item comes back as a plain menu action, and this id’s closure invokes the installed undo bridge. Registered once and durable across menu installs, like the preferences id. Toolkits with a native undo system (appkit) keep their responder-chain selector instead, so a focused text field’s own undo stays ahead of the app stack there. - uninstall_
tree - Reset the thread-local tree + queues (tests).
- unregister_
nav - Remove a controller whose host was disposed. No-op if already gone.
- unregister_
search_ host - Forget
host, once its scope is disposed. - window_
safe_ area safe_areaagainst an explicit window root.- window_
size_ class size_classagainst an explicit window root.- window_
size_ class_ untracked size_classwithout subscribing, for code that reacts to the change itself.- with_
animation - Explicitly animate every state change made in
f, Day’s equivalent of SwiftUI’swithAnimation. The mutation runs inside aday_reactive::batch; that batch’s synchronous fixpoint drain (bindings →patch, plus the turn-end layout →set_frame) executes whilespecis ambient, so the resulting native updates carry the animation intent and the toolkit animates them on its own compositor. Nesting overrides; the previous ambient restores after. - with_
environment - Provide an ambient value
Ttocontentand its entire descendant subtree (the SwiftUI@Environment/.environment(_)analog, layered over day-reactive’s scope context).content, and any piece built within it, reads it back withenvironment. A thin, non-reactive wrapper:Tis a snapshot captured here; for a value that must react, provide aSignal<T>(or aMemo<T>) and read it reactively inside the subtree. - with_
tree - Access the installed tree. Tree methods never run user code, so nesting cannot occur while a borrow is held; if events were queued during the call, they are pumped after the borrow is released (the “safe point” of §3.3).
Type Aliases§
- Event
Handler - An event handler registered on a realized node.
- Event
Observer - The recording/telemetry observer installed via
set_event_observer(§14.6): called with every dispatched(NodeId, Event), in queue order, before the app receives it. - NavObserver
- A navigation observer (§14.6): called with the new full route each time it changes, from any
source: imperative
navigate/nav_back, a nav_link or sidebar row (which navigate from an event handler, bypassing the event observer), a stack push, or a native back gesture.""is the root. Installed by the recorder in day-script; day-core only fires it. - Piece
Operation Done - Completes an operation with its textual result or a human-readable error. The operation defines the payload format. Completion may be immediate or asynchronous.
- Piece
Operation Fn - An operation on a live node of the registered kind. Copy the input if retaining it. Accepted requests must complete, including when the native operation fails.
- Resource
Opener - A backend’s resource opener: maps a declared name (e.g.
"stations.json") to its bytes, orNoneif there is no such resource.