Package-level declarations

Types

Link copied to clipboard
data class MilanoAction(val name: String, val parameters: Map<String, MilanoValue>, val viewIdentity: String, val dispatch: Int = 0, val dispatchId: String = "")

A dispatched custom action, delivered as data.

Link copied to clipboard
class MilanoActionFailure(val value: MilanoValue? = null, message: String = "action failed")

The exception a handler throws to fail a dispatch with a payload: the value is validated against the action's declared failure type and bound to the failure root inside onFailure. Any other exception is a failure with no payload.

Link copied to clipboard
fun interface MilanoActionHandler

An asynchronous receiver of custom actions: one funnel per view. Normal return is success and the returned value, validated against the action's declared result type, binds the result root inside onSuccess; return null for actions declaring no result. Throwing is failure: a MilanoActionFailure carries the failure payload, validated against the declared failure type and bound to the failure root inside onFailure; any other exception is a failure with no payload. Completion-exactly-once holds by construction.

Link copied to clipboard

The closed set of typed errors the gate can throw, per the document model spec. Every error carries structured detail; the diagnostic message is non-normative.

Link copied to clipboard

One materialized child, ready to place in a layout.

Link copied to clipboard

The standard context source: create it with initial values, push updates from any thread.

Link copied to clipboard

Supplies and updates context values. Milano validates each change atomically; an invalid update is rejected whole and reported. subscribe returns a cancellation, invoked by the runtime at teardown so a source never retains callbacks for views that are gone.

Link copied to clipboard
fun interface MilanoDispatcher

The serialization seam: everything that touches a view's state runs through its dispatcher, one item at a time. The platform layer binds it to the main thread; the conformance harness injects a pump.

Link copied to clipboard
class MilanoEngine(vocabularyJson: String, registry: MilanoRegistry, val defaultUnknownTypePolicy: MilanoUnknownTypePolicy = MilanoUnknownTypePolicy.FAIL, val limits: MilanoLimits = MilanoLimits(), observer: MilanoObserver? = null, userInteractionObserver: MilanoUserInteractionObserver? = null, functionHandler: MilanoFunctionHandler? = null)

The instantiable root of the framework. An engine holds one configuration: the vocabulary, the registry, the default unknown-type policy, resource limits, the two observers, and the host function handler. It is immutable after creation and safe to share across threads. MilanoViewBuilders are obtained from an engine, so every MilanoView is traceable to exactly one configuration.

Link copied to clipboard

Engine-creation errors, per the vocabulary schema spec. These arise at engine creation only; they can never occur at the gate or later.

Link copied to clipboard
data class MilanoFunctionCall(val name: String, val arguments: List<MilanoValue>)

A host function call (expression spec, Host functions): the declared function's name and its evaluated arguments, in declared order, each already of its declared type.

Link copied to clipboard
fun interface MilanoFunctionHandler

The engine's synchronous resolver of host functions (contract 2.1), one for every view and every surface's declarations. Invoked on the thread evaluating the expression, during resolution and action evaluation: it must be fast, must not block, must not touch the view, and must be pure over its arguments (vocabulary schema spec, Function declarations). The value is validated against the declared returns; a mismatch or a thrown exception is an invalid function result, reported and replaced by the zero value of the return type. Returning null is the null value.

Link copied to clipboard
object MilanoInfo

Milano SDK: a client-only, design-system-agnostic Document-Driven UI framework for Compose.

Link copied to clipboard

The common-code default: runs inline, serialized by the caller's thread. The Android source set supplies MilanoMainDispatcher, bound to the main thread; this default suits single-threaded hosts and tests.

Link copied to clipboard
data class MilanoLimits(val maxTreeDepth: Int = 32, val maxNodeCount: Int, val maxDocumentBytes: Int, val maxExpressionLength: Int, val maxValueSize: Int)

Resource limits; safe defaults fixed by the document model spec, adjustable per engine.

Link copied to clipboard

The Android main-thread dispatcher, per the threading contract. Runs inline when already on the main thread, so renderer emissions are processed synchronously in FIFO order.

Link copied to clipboard

What a renderer receives: the node's resolved values, its materialized children, and the emission surface.

Link copied to clipboard
fun interface MilanoObserver

Engine-scoped observer: one integration point per engine for logging and telemetry. Every reported occurrence flows here.

Link copied to clipboard
data class MilanoOccurrence(val kind: MilanoOccurrence.Kind, val viewIdentity: String, val node: String?, val name: String? = null, val expected: String? = null, val found: String? = null)

One reported occurrence, delivered to the engine observer, tagged with the originating view. Kinds are the closed union defined by the runtime API spec.

Link copied to clipboard

The consumer-provided renderer for unknown component types under the placeholder policy. Receives the raw subtree as data, never as live children.

Link copied to clipboard

The binding from vocabulary component types to consumer renderers.

Link copied to clipboard
interface MilanoRenderer

A consumer-provided renderer for one component type: receives the node, emits Compose UI. Invoked in composition on the main thread.

Link copied to clipboard

An asynchronous source of initial state values, awaited during building and validated against the document's declarations. Provider errors propagate to the build caller unchanged: they are host errors, not Milano errors.

Link copied to clipboard
data class MilanoType(val kind: MilanoType.Kind, val optional: Boolean = false)

A type from the document type system: bool, int, double, string, enum over named members, array of T, or record with named typed fields; each optionally optional.

Link copied to clipboard
data class MilanoUnknownNode(val type: String, val reference: String, val rawSubtree: MilanoValue)

An unknown node routed to the placeholder renderer.

Link copied to clipboard

How unknown component types are handled: engine default, per-view override.

Link copied to clipboard
data class MilanoUserInteraction(val kind: MilanoUserInteraction.Kind, val viewIdentity: String, val node: String? = null, val name: String? = null, val value: MilanoValue? = null, val dispatch: Int? = null)

One user interaction, delivered to the engine's user-interaction observer. Records pass everything through unredacted (payloads, action parameters, document metadata): Milano implements no tracker, the receiving host owns the data and decides what to do with it.

Link copied to clipboard

A receiver of user interactions: the engine's product-analytics stream, separate from MilanoObserver, which carries engine observability only.

Link copied to clipboard
sealed class MilanoValue

The single representation for every value crossing a Milano boundary: resolved properties into renderers, event payloads out of them, action parameters into handlers, context and state values in from the host.

Link copied to clipboard

The built, guaranteed-renderable view: bound to one document at a time. Runtime semantics per the state and actions spec; everything mutable runs through the view's serial dispatcher.

Link copied to clipboard

The construction gate's public face: a MilanoView is created exclusively through a MilanoViewBuilder, obtained from a MilanoEngine.

Functions

Link copied to clipboard
fun MilanoHost(builder: MilanoViewBuilder, loading: @Composable () -> Unit = {}, failure: @Composable (Throwable) -> Unit = {})

The hosting container, for hosts that want the swap managed for them: presents the loading content immediately, awaits the build, replaces it with the MilanoView's content on success or the failure content on failure. Building starts once per composition lifetime; recompose a new MilanoHost to retry.

fun MilanoHost(documentText: String, vocabularyJson: String, renderers: Map<String, MilanoRenderer>, context: Map<String, MilanoValue> = emptyMap(), state: Map<String, MilanoValue> = emptyMap(), onAction: suspend (MilanoAction) -> MilanoValue?? = null, loading: @Composable () -> Unit = {}, failure: @Composable (Throwable) -> Unit = {})

The quick path: one composable from raw document and vocabulary text. Engine, registry, and builder are created inside; declared state is synthesized as zero-values (overridable via state); engine and build failures both land in the failure content. Ideal for a first integration or a simple embed; real apps share one engine and use the builder overload.

Link copied to clipboard
fun synthesizedState(declarations: Map<String, MilanoType>, supplied: Map<String, MilanoValue> = emptyMap()): Map<String, MilanoValue>

Zero-values per declaration, overridden by supplied values. The zero is the contract's own (zeroValueOf), so a synthesized value is the same value an invalid function result of that type would produce. Enums are why that matters: this once took the alphabetically first member while the contract takes the first declared, so a preview could differ from the engine over the same declaration. Every value satisfies its declaration, so a provider built on this never fails the gate's data check. The quick path uses it; it is public for providers that have nothing better than a zero-value for some keys. The same function on every engine.

Link copied to clipboard

Creates a builder for one document given as raw bytes. The document-size limit is checked against these bytes exactly; the text is decoded as UTF-8.

Creates a builder for one document given as text.