genui_jaspr 0.1.0
genui_jaspr: ^0.1.0 copied to clipboard
Render A2UI generative user interfaces in Jaspr, so a web app can offer a generative UI without shipping Flutter web.
0.1.0 #
First release. Renders A2UI generative user interfaces in Jaspr, building on
a2ui_core for the protocol runtime.
GenUiConversationowns the surfaces of one conversation and turns each model reply into aStream<GenUiEvent>:GenUiTextfor prose,GenUiSurfacefor each surface the model opens, andGenUiErrorfor each message it got wrong. Actions, later errors, and deleted surfaces reach the app through theonAction,onError, andonSurfaceDeletedcallbacks.receiveMessagestakes A2UI that arrives already parsed, andactionTextcomposes the text a chat app sends the model after an interaction.ReplyBuilderfolds a reply's events into aReplyand rebuilds as they arrive, built on Jaspr'sStreamBuilderBase, withonCompletefor the finished reply. Outside a component,Stream<GenUiEvent>.repliesand.replydo the same fold.a2uiActionMessage,a2uiErrorMessage, andclientErrorFromproduce the client-to-server envelopes the protocol defines.a2uiInstructionswrites the protocol half of a system prompt from a catalog, so the model is told exactly what the renderer can draw. ItsallowUpdatesflag matches the two waysreceivecan treat surface ids.Surfacerenders a surface and fills in as messages arrive, withplaceholderandfallbackbuilders for the moments before a root exists and for a component the catalog cannot render.MinimalJasprCatalogrenders the five components of the A2UI minimal catalog,TextComponent,RowComponent,ColumnComponent,ButtonComponent, andTextFieldComponent. Schemas and the catalog id come froma2ui_coreunchanged.JasprComponentis the base class for a component of your own, declaring its name and schema alongsidebuild.ExternalApiJasprComponentrenders an API defined elsewhere, as the minimal components do witha2ui_core's.copyWithderives a catalog from an existing one.BasicJasprCatalogimplements the complete A2UI v0.9 standard catalog: all 18 components, all 14 functions, and its theme.Iconrenders the 59 names the catalog permits as inline SVG, with no font, network request, or icon package, and those paths are tree-shaken from a build that uses only the minimal catalog.localesets the locale for number, currency, date, and plural formatting, andurlOpenerlets an app restrict whatopenUrlwill navigate to.ComponentScopehands a builder its resolved properties, its children, and a way to report errors. An action obtained through it never throws out of a click handler. ItsinstanceIdis unique to each rendered instance across the page, so DOM ids and radio group names derived from it stay distinct between surfaces and between rows of a template.JasprComponent.stylesdeclares the default rules for the classes a component emits, and thestylesgetterJasprCatalogCompositionadds to aCatalog<JasprComponent>gathers them, so a catalog derived withcopyWithcarries the right bundle.JasprComponent.inlinetakes them too. Surface-level markup is left unstyled for the app to own. A surface publishes its theme as CSS custom properties.A2uiParserTransformerturns a model's text stream into prose and A2UI messages, buffering across chunk boundaries, for apps that want the raw events. A reply that ends part-way through a message reports it as an error instead of showing the raw JSON as prose.- The example app serves a server-rendered shell with the conversation as a
@clientcomponent, and a Genkit agent served bygenkit_shelfthat keeps each conversation's history in a session store.