notation library
The compact notation (docs/design/13-compact-notation.md): the form an agent writes for a small UI, expanded to an ordinary document.
Classes
- A2uiResult
- What parseA2ui gives: the document, the notation it was read through, and what was approximated.
- DefinedWords
- The defined words of a text being read, one line at a time: each line is given to rewrite with its indent, and the lines it stands for come back (itself, moved into the slot of a use it is under, or a use's expansion). finish gives what is still open at the end.
- DefinitionReads
- What definition's lines leave unused, and what they read from outside.
- LinePart
-
One part of a line after its head: a string, a key=value, a bare word
or the
{…}at its end. - LineParts
- A line split into its head and parts, as the grammar says a line is.
- NotationDefinition
- One definition of a word: its signature and the lines it stands for.
- NotationIssue
- A problem in the notation's text: where and what.
- NotationOptions
- How the notation expands.
- NotationPage
- One page of a text (notationPages).
- NotationPages
- The pages of a text (notationPages).
- NotationResult
- NotationStream
-
The notation read as it arrives: add takes text in any chunks and
returns the edit operations of the lines completed so far (a
setper node under its parent,varsfor the state a line introduced), ready forapplyOps; close gives the last line's. - NotationVocabulary
- The alias table: many names, one meaning. A name here is never a word the notation (or the design system in use) already has: that word wins.
- TypeAlias
-
A type read as another:
RangeSlideris aSlider, with its own names for that type's parameters;GoKeyis aButton.primarywithsize=lg. - UniversalWord
- A word every line understands.
- VocabularyUse
- One use of a word the notation has no meaning for (or an alias of one it has): what was written, where, and enough of its line to map the word to one that exists or to build it.
- WantedBlock
-
What parseNotation gives: the document and what it could not read.
A component an answer asked for because none fitted a part of its UI:
Wanted "PollResults" "each option with its share of the votes", with the part built from plain parts under it. The part shows as written; a host may have the component designed and added for the answers that follow.
Enums
- UniversalKind
- Whether a universal word is written key=value, as a bare word, or as an on… event.
Constants
-
Button.<variant>: the button type and props it stands for. -
defaultTextVariants
→ const Map<
String, Object> - notationDefinePreface → const String
-
What the open prompt asks after
notationOpenPreface: every word the answer invents, defined in the notation after its last screen (docs/design/20-defined-words.md; the vocabulary loop's Review 4, D19). Each example expands with no issue (a test reads them from here). - notationPagesRule → const String
-
How an app or a site of several screens is written as one answer
(notationPrompt with
pages): the rules, as lines of the prompt's list.notationPagesreads a text written this way. - notationSiteRule → const String
-
How an app or a site of several screens is written as files
(notationPrompt with
site): the layoutexpand <site folder>reads (docs/reference/notation: site.md, and "Calling one" of components.md), as lines of the prompt's list. -
notationTypes
→ const Map<
String, ({Json node, String type})> - Short names: what an agent writes → the node type and what it implies.
-
notationUniversal
→ const Map<
String, UniversalWord> - The words every line understands: the grammar's own, and the universal words of docs/design/21-universal-words.md.
-
notationVerbAliases
→ const Map<
String, String> - A verb's other spelling the parser reads, by the verb it is.
-
notationVerbs
→ const Set<
String> -
The verbs an action is written with (design 13 section 3), beside
name=valueandcond ? a : b; every other action is its type and its fields by name. The reference documents each (tool/reference).
Properties
-
universalWords
→ Iterable<
String> -
The universal words of note 21 (not the grammar's own).
no setter
Functions
-
a2uiToDocument(
List< Json> messages, {required Catalog catalog, String? surfaceId, NotationOptions options = const NotationOptions()}) → A2uiResult -
messages(decoded agent-to-renderer envelopes) as a document. -
checkDefinitions(
NotationVocabulary vocabulary, {required Catalog catalog, NotationOptions options = const NotationOptions()}) → List< String> -
Each definition expanded once with its defaults (and a line in each
slot), as the parser reads it with the vocabulary closed: what is wrong,
each as
file:line: message. A design system's folder is checked with this before a page uses it. -
definitionLines(
NotationVocabulary vocabulary) → List< String> -
The signature lines of
vocabulary's definitions, with their purposes, as the taught prompt lists a design system's components. -
definitionReads(
NotationDefinition definition) → DefinitionReads -
What
definition's lines leave unused and read from outside (DefinitionReads). A primitive's lines stand in for what no line can express, so what they leave unused is expected: it has none. -
isUniversal(
String word) → bool -
Whether
word(a key, a bare word or an event) is a word every line understands. -
notationBindForm(
String line, {Catalog? catalog}) → String -
linewith its bindings in the form the notation reads (lineitself when it has none to rewrite). -
notationBindRewrite(
String line, {Catalog? catalog}) → NotationBindRewrite -
line(one line, its indentation and what follows it kept as they are) with the bindings codelessly_api 33 read rewritten, and the plain variables those bind (a mark already written@nameis the line's as it is: neither rewritten nor listed). Only what 33 read as a binding is rewritten:bind=andbindEnd=(a name, a path, or one in braces), a block's variable parameter given a bare name (direction=dir), a RangeSlider's ends given bare names. A value in braces anywhere else (value={s},lo={lo}) was shown, one way, and is left as written. -
notationBracketIssues(
String text) → List< NotationIssue> -
The issues of
text's brackets, at most one per line, each at its line and column (1-based). -
notationBuiltInDefinition(
String word, String builtIn, {String kind = 'definition'}) → String -
What is said at a writer's definition of
word, whichbuiltIn(notationBuiltInWord) says the notation has: it is not used. -
notationBuiltInWord(
String word, {Catalog? catalog, NotationVocabulary vocabulary = NotationVocabulary.core, bool primitive = false}) → String? -
What the notation already has under
word, in one line with its signature, or null when it has nothing a writer's definition would hide: a type of the notation or of the catalog (Card,Text), a page word (App,Rail,Footer), or a namevocabulary's alias table reads as one of those (RangeSlider, aSlider). A design system's component (a page's definition may replace it, docs/design/20 section 6) and a word the design system defines are not. -
notationGlossary(
DesignSystem designSystem, NotationVocabulary vocabulary, {required String prompt}) → List< String> -
The names
designSystemhas beyond what the openpromptteaches: its components and the wordsvocabularydefines in the notation, sorted, leaving out a type of the notation, a page word and any name the prompt already writes (Button,Card, and the define examples'StickyNote). -
notationGlossaryComponentLine(
DesignSystemComponent component) → String -
componentas the glossary of signatures lists it:Counter "label" "detail" @value min max step=1 icon onChange : number raised and lowered with minus and plus. -
notationGlossaryDefinitionLine(
NotationDefinition d) → String -
das the glossary of signatures lists it: its signature with its defaults shortened to their kind (fill=#…,items=[]; a text's is left out), its slots and what its//line says it is, in a few words. -
notationGlossaryLead(
{bool define = true}) → String - What the glossary of the open prompt says before the names (the wording of the glossary experiment, the vocabulary loop's Review 6).
-
notationGlossaryLines(
DesignSystem designSystem, NotationVocabulary vocabulary, {required String prompt}) → List< String> -
The lines of the open prompt's glossary of signatures: for each word
designSystemhas beyond what the openpromptteaches (the names notationGlossary gives), one line as a line uses it, with what it is for in a few words (notationGlossaryComponentLine, notationGlossaryDefinitionLine). A word defined with several meanings has a line for each; a component's word, a line for the component and one for each meaning a definition names (Stepper#steps). -
notationIsLiteral(
String v) → bool -
Whether
v, a signature's default, is a value as written (a number, true, false, null, a string in quotes, a list or a map): whatx=@0.5takes after its@. -
notationOptionsFor(
Json document) → NotationOptions - The options printNotation's output is parsed with: the document's canvas id and width, and no reflow: a document printed is as it is, its media rules written on its lines. A component's document has no canvas: its screen is a name none of its nodes has.
-
notationPageHeading(
String line) → String? -
The heading a line is (
### Name): its name, or null. -
notationPages(
String text, {String fallback = 'Page'}) → NotationPages -
textas its pages: each### Nameline starts one. See the library's comment for what each page's text holds. A text without a heading is one page calledfallbackwith the idscreen, its text as written. -
notationPrompt(
{Catalog? catalog, NotationOptions options = const NotationOptions(), DesignSystem? designSystem, Set< String> ? only, bool natural = false, bool wanted = false, bool open = false, bool define = true, bool glossary = true, bool signatures = true, bool pages = false, bool site = false}) → String -
The prompt for the notation over
catalog(its level 0 and 1 types). -
notationRefusedState(
String name) → bool -
Whether a
stateline namingnameis refused:device(read-only input) and the names the runtime gives every expression of a screen (theme,data,route…). -
notationScreen(
String word, Iterable< String> screens) → String? -
The screen of
screens(ids,cook-mode) thatwordafter agonames: its id, its id written with underscores or capitals (go cook_mode), or the one screen whose id starts with it or holds all its words (go cook); null when none or several do. -
notationSignaturesLead(
String name, {bool define = true}) → String -
What the glossary of signatures says before its lines (the open prompt's
last section, notationPrompt with
signatures). -
notationUnbraced(
String expr) → String -
exprwithout braces around it all, where they are the expression's ({length(sel) > 0}afterwhen,{n + 1}aftern=in an action), askey={expression}reads everywhere else: one rule for an expression wherever it is written. A map literal ({a: 1},{"id": x},{}) keeps its braces. -
notationWordOrigin(
String word, {Catalog? catalog, NotationVocabulary vocabulary = NotationVocabulary.core}) → String? -
Where the meaning of
word(a line's first word) is written:base(a node type of the notation or the catalog, a statement: the renderer and the parser implement it),code(a word of the page's frames the expander writes out in Dart: App, Section, Nav…, or a line of another shape the alias table names), the name of the dictionaryvocabularyhas it from (a folder of definitions a caller gave: NotationVocabulary.dictionary), or null (no word of the notation's: a design system's, a writer's, unknown). -
parseA2ui(
String text, {required Catalog catalog, String? surfaceId, NotationOptions options = const NotationOptions()}) → A2uiResult -
The surface A2UI's JSONL
textdescribes (the last one created, orsurfaceId), as a document. -
parseNotation(
String text, {Catalog? catalog, NotationOptions options = const NotationOptions(), String? definitions}) → NotationResult -
textin the compact notation as a layout document. Never throws: what cannot be read is reported and skipped. -
printNotation(
Json document, {required Catalog catalog, void whole(String why)?}) → String -
documentin the notation. Parse it back with notationOptionsFor. A document of a schema other than kSchemaVersion, or with none, is refused (UnsupportedSchemaException). -
readDefinitions(
Map< String, String> texts, {String? dictionary}) → ({List<String> problems, Map<String, List< words})NotationDefinition> > -
The definitions in
texts(each by its file name:StickyNote.txt), by word, with what could not be read (StickyNote.txt:3: …). A word that uses itself, directly or through others, is left out. -
readPageDefinitions(
String text, {Map< String, List< others = const {}}) → ({List<NotationDefinition> >({int line, String message})> problems, Set<String> signatures, Map<String, List< words})NotationDefinition> > -
The words a text (a page, or an answer of several screens) defines with
define Word …(or declares withprimitive Word …, for what no line can express) at the margin, wherever they are written: a definition holds for the whole text, before or after its uses. A//line directly above adefineis its purpose. A word defined twice is the later definition, unless both name their meaning (define Timeline#route), when the word has both. A word that uses itself, through these orothers(the design system's), is left out. What is wrong is inproblems, each with the 1-based line oftextit is on;signaturesare everydefineline read, as written withoutdefine(what DefinedWords.preread skips).
Typedefs
- DefinedLine = ({String? from, int indent, String text})
-
A line the expansion gives: its indent, its text, and where it was
written when it comes from a definition (
StickyNote.txt:3; null: the page's own line). -
NotationBindRewrite
= ({List<
NotationBound> bound, String line, List<String> refused}) -
What notationBindRewrite gives: the line, the variables its rewritten
bindings bind, and the names it left as written because the runtime
reserves them (
theme,device: no state line can declare them, so they are renamed by hand). - NotationBound = ({String name, Object? start})
-
A variable a rewritten line binds, with the value a
stateline for it would start at (the control's natural empty value).