lang_core library

The low-level OpenUI Lang API with @openuidev/lang-core's names: lexer, parser, serializer, evaluator, store and query manager.

Classes

ActionPlan
An evaluated action: the steps a click runs, in order.
ActionStep
A step of a plan; jsFields are lang-core's step object.
ArrNode
AssignNode
Ast
The OpenUI Lang 1.0 syntax tree, mirroring lang-core's ASTNode.
BinOpNode
BoolNode
CompiledSchema
The library schema compiled for parsing: component params by name, and the call registry (built-ins plus library functions and actions).
CompNode
A call: a component, a built-in or library @function, an action step, Action([...]), Query or Mutation.
CustomStep
A library action call such as @CopyToClipboard(text). Only an evaluated call creates one, so data cannot pose as a custom action.
ElementNode
A component instance after materialization or evaluation.
EvaluationContext
What evaluation reads from: state, statement refs, library calls.
IndexNode
MemberNode
MutationNode
lang-core MutationNode: a Mutation statement and the tool it runs.
MutationStatementInfo
NullNode
NumNode
ObjNode
OpenUrlStep
ParseMeta
Parser
lang-core Parser: parses whole programs against one library schema.
ParseResult
PlaceholderNode
A placeholder for a reference that did not resolve (yet).
PromptEntry
One line of the prompt: a component, function or action signature.
PromptGroup
PromptSpec
Everything lang-core's generatePrompt reads.
PromptTool
A tool the program may call from Query/Mutation, as the prompt shows it.
QueryManager
lang-core createQueryManager: fetches Query tools, caches by tool + args + state deps, serves defaults until data arrives, and runs Mutations on demand.
QueryNode
A Query statement evaluated against the current state.
QuerySnapshot
lang-core QuerySnapshot: every statement's data plus loading, refetching and error lists.
QueryStatementInfo
RawStatement
ReactiveAssign
A two-way binding: writing $value runs expr and stores the result in target. Bound inputs receive this instead of the state's value.
RefNode
A reference to another statement, or an @Each loop variable.
ResetStep
RunStep
RuntimeFunction
A library @function as the runtime calls it.
RuntimeRefNode
SetStep
StateField<T>
lang-core StateField: a form field's value and setter, bound to a $variable or held by the form.
StateRefNode
Store
lang-core createStore: $variables and form fields. Keys still at their declared default are pristine and follow new defaults while the program streams; a key the user changed keeps its value.
StreamParser
lang-core's streaming parser: caches completed statements and re-parses only the pending tail on each update.
StrNode
TernaryNode
ToAssistantStep
Token
UnaryOpNode
ValidationError
ValueNode
A runtime value spliced into an @Each template that has no literal form (a component, an action, a binding); it evaluates to itself.

Constants

actionSteps → const Map<String, String>
lang-core ACTION_STEPS: each built-in step's runtime step type.

Functions

astFromJson(Map<Object?, Object?> json) → Ast
The node of lang-core's JSON form (Ast.jsFields as JSON).
autoClose(String input) → ({String text, bool wasIncomplete})
lang-core autoClose: closes unclosed strings and brackets of a partial program so it parses.
buildSignature(String componentName, Map<String, Schema> props) → String
lang-core buildSignature: a component's prompt signature, such as Card(title: string, subtitle?: string).
createParser(JsonSchema schema, {String? rootName}) → Parser
lang-core createParser; pass library.toJsonSchema().
createQueryManager(ToolProvider? toolProvider) → QueryManager
lang-core createQueryManager.
createStreamingParser(JsonSchema schema, {String? rootName}) → StreamParser
lang-core createStreamingParser; pass library.toJsonSchema().
enrichErrors(List<ValidationError> validationErrors, Map<String, Object?> schema, List<String> componentNames) → List<OpenUiError>
lang-core enrichErrors: parser validation errors as OpenUiErrors with fix hints.
evaluate(Ast node, EvaluationContext ctx, [IsReactiveProp? reactive]) → Object?
lang-core evaluate. reactive is lang-core's schema context: present when evaluating props for rendering.
evaluateElementProps(ElementNode el, EvaluationContext ctx, IsReactiveProp reactive, List<OpenUiError> errors) → ElementNode
lang-core evaluateElementProps: evaluates each prop, reporting a failure to errors instead of throwing.
evaluateRoot(ParseResult result, EvaluationContext ctx, IsReactiveProp reactive, List<OpenUiError> errors) → ElementNode?
lang-core evaluateRoot: the root element, or the component a runtime entry picks; null if none.
generatePrompt(PromptSpec spec) → String
lang-core generatePrompt.
generateSystemPrompt(OpenUiLibrary library, [PromptOptions options = const PromptOptions()]) → String
lang-core generateSystemPrompt for a library: OpenUiLibrary.systemPrompt. For OpenUI Cloud's config block use cloudSystemPrompt.
isAstJson(Object? value) → bool
lang-core isASTNode for a JSON value: a map with a known k.
isElementNodeJson(Object? value) → bool
lang-core isElementNode for a JSON value.
jsonToOpenUI(Object json, OpenUiLibrary library, {Map<String, Object?>? stateDeclarations}) → String
lang-core jsonToOpenUI: an element tree back to program text that mergeStatements accepts. json is an ElementNode (a parse result's root) or its JSON form (ElementNode.toJson).
mergeStatements(String existing, String patch, [String rootId = 'root']) → String
lang-core mergeStatements: patch statements replace existing ones by name, name = null deletes one, and statements no longer reachable from rootId are dropped ($state is always kept).
parse(String input, CompiledSchema schema, [String? rootName]) → ParseResult
lang-core parse: one complete (or partial) program against a compiled schema (CompiledSchema.fromJsonSchema(library.toJsonSchema())).
parseExpression(List<Token> tokens) → Ast
lang-core parseExpression: a Pratt parser over one statement's tokens.
resolveStateField<T>(String name, Object? bindingValue, Store? store, EvaluationContext? context, Object? fieldGetter(String fieldName), void fieldSetter(String fieldName, Object? value)) → StateField<T>
lang-core resolveStateField: a $binding (ReactiveAssign) reads and writes the store, running its expression with $value; any other field reads fieldGetter (falling back to bindingValue) and writes fieldSetter.
split(List<Token> tokens) → List<RawStatement>
lang-core split: one statement per identifier = expression line, with newlines inside brackets and before a ternary's ?/: ignored.
stripReactiveAssign(Object? value, EvaluationContext ctx) → Object?
lang-core stripReactiveAssign: a binding read as its current state value.
tokenize(String src) → List<Token>
lang-core tokenize.
walkAst(Ast node, void visit(Ast node)) → void

Typedefs

IsReactiveProp = bool Function(String component, String prop)
Whether a component's prop is a $binding (two-way) prop.
JsonSchema = Map<String, Object?>
MutationResult = Map<String, Object?>
lang-core MutationResult: {status: "idle" | "loading" | "success" | "error", data?, error?}.
ToolCaller = Future<Object?> Function(String name, Map<String, Object?> args)
Calls a tool by name: what Query and Mutation run.
ToolProvider = ToolCaller
lang-core ToolProvider: what a QueryManager calls tools with.