genui_gen_builder 0.7.1
genui_gen_builder: ^0.7.1 copied to clipboard
build_runner generator for genui_gen. Turns @GenUiWidget widgets and @GenUiData classes into genui CatalogItems whose schema, builder and examples come from the constructor.
0.7.1 #
- Documentation only; no generator change.
- Corrected the install instructions, which listed
json_schema_builderas a direct dependency and imported it in the annotated file. It has not been needed sincegenui_gen0.3.0. - Documented the runtime floor each builder needs. The generator emits calls to
runtime helpers as they are added, so a new builder against an old
genui_gengenerates code that does not compile, and nothing enforces it: the builder deliberately does not depend on the runtime. 0.7.x needsgenui_gen >= 0.8.0. - Added
homepage, pointing at https://diegolopezrm.github.io/genui_gen/.
0.7.0 #
-
Added
@GenUiProp(template: true), which lets aList<Widget>property accept a child template as well as a list of ids:@GenUiWidget(description: 'A titled list of rows.') class TaskList extends StatelessWidget { const TaskList({ super.key, required this.title, @GenUiProp(template: true) required this.rows, });The property's schema becomes
A2uiSchemas.componentArrayReference(), the path the template repeats over is bound so new entries rebuild the children, and the children are built with each entry as its own data context. -
Off by default: the schema a template property publishes is not the one a prompt tuned against the previous version was written for, so turning it on is the author's call.
-
@GenUiProp(template: true)on anything but aList<Widget>is a build error naming the parameter.
0.6.0 #
-
lib/genui_catalog.g.dartnow declares the assembledCatalogas well as the list of items, so an app hands genui the catalog directly instead of wrapping the list by hand:final catalog = genUiCatalog.copyWith( newItems: BasicCatalogItems.asCatalog().items.toList(), ); -
Added the
catalog_idbuild option, which becomes that catalog's id:targets: $default: builders: genui_gen_builder:genui_catalog: options: catalog_id: com.example.appIt cannot be derived here — the id names the catalog to the agent that composes against it and the clients that render it, which is not something a generator can invent. Without it the catalog is still assembled, just without an id, and the generated file says how to set one.
-
A
catalog_idthat is not a string, or that could not survive being written into the generated file, is a build error naming the option rather than broken Dart or an id nobody chose.
0.5.0 #
-
Added an aggregating builder. Every
CatalogItemgenerated in the package is collected into onelib/genui_catalog.g.dart, which declaresgenUiCatalogItemsand imports the libraries that hold them. Registering a catalog was otherwise a hand-maintained import list plus a hand-maintained list of variable names — the same drift this package exists to remove, one level up, since adding a@GenUiWidgetleft the catalog silently as it was.import 'genui_catalog.g.dart'; final catalog = Catalog([ ...genUiCatalogItems, ...BasicCatalogItems.asCatalog().items, ], catalogId: 'com.example.app'); -
The list is sorted by variable name, so the file does not reorder itself between builds, and a package with nothing annotated gets no file rather than an empty one.
-
Two libraries whose generated items would arrive under the same name are now a build error naming both files. The per-library generator already rejected a collision inside one library; across libraries the two only meet in the aggregate, which names each unprefixed.
-
A
@GenUiWidget(name: '...')on a private class generates a private variable, which no other library can name. It is left out of the aggregate with a warning that says why, rather than emitting a file that does not compile. -
genui_genstays at 0.4.0. This release changes the builder only: the generated file importspackage:genui/genui.dartand nothing from the annotations package.
0.4.0 #
- Recognises
@GenUiWrites('<property>')on avoid Function(T)parameter and emits a callback that writes the user's value into the data model. The callback is left out of the schema and out ofrequired, since the model never supplies it; what the model supplies is the binding on the property it writes to. - A property some callback writes to is read back through the path it is
written to (
genUiWriteReference), with the literal the model sent as the fallback until that path holds something. Enums are written as their name, matching how they are read back. - Appends a sentence to the written property's schema description, so the model knows that binding it to a path is how the answer is read.
- New build errors, each naming both sides: a
void Function(T)with no@GenUiWrites,@GenUiWriteson something that is not such a callback, a property the widget does not have (listing the ones it could write to), a property that cannot be written back, a callback whose argument does not match the property, and a nullable argument. - A callback with more than one argument, or one whose argument is not a
String, a number, aboolor an enum, stays unsupported and keeps the general message. - Additive release: a widget that uses only 0.3 types generates identical code.
0.3.0 #
- Added lists of scalars: a
@GenUiWidgetparameter or@GenUiDatafield may now be aList<int>,List<double>,List<num>, or aList<E>for an enumE. Each was a build error in 0.2. - Added
GenUiBinding.numberListandGenUiValues.numberList, resolved through genui'sBoundList. Entries that are not numbers are dropped, and a numeric string is parsed, the way the core catalog's number binding does. - Added the coercion helper
genUiAsNumList, used by generated decoders for numeric list fields of a@GenUiDataclass. - A list of enums is carried as strings and mapped back by name. A name the enum does not declare is dropped rather than defaulted: the list is the model's, and one bad entry should not silently become a value the author never wrote.
- Additive release: widgets that only use 0.2 types generate identical code.
- Requires
genui_gen0.3.0 or newer: generated decoders callgenUiAsNumList, and generated builders callGenUiBinding.numberList. - The builder now warns when a component name shadows one of genui's basic
catalog items (
Card,Row,Image, ...).Textremains an error, because generated examples compose it for child components.
0.2.0 #
- Added
@GenUiData: a plain Dart class annotated with it gets a generatedfinal ObjectSchema <name>GenUiSchemaand a<Type> <name>FromGenUiJson(Map<String, Object?> json, [reporter])decoder in the same.genui.dartpart, and may then be used as a widget parameter. Requiresgenui_gen0.2.0 or newer for the runtime helpers it calls. - A widget parameter may now be a
@GenUiDataclass or aListof one. The object property is resolved throughGenUiBinding.object/GenUiBinding.objectList(so{"path": ...}and{"call": ...}work on the whole object) and decoded with the generated decoder. - Data-class fields use the plain
S.string/S.integer/S.number/S.boolean/S.listschemas instead ofA2uiSchemas.*Reference: the values inside a data object are literals the model emits, not per-field bindings. Anintfield isS.integer, so a fractional value is rejected by validation rather than silently truncated. - Generated decoders never cast. Fields go through the
genUiAs*coercions exported bygenui_gen, so a model that puts a number where a string was declared degrades exactly as it does for a widget property instead of throwing aTypeErrorinsidebuild. Required fields that fell back are reported throughgenUiReportMissingas<property>.<field>, but only once the property itself has resolved, so a data binding that is still pending does not turn into one false field error per required field. - The schema of a data property is a
oneOfof the object schema, a data binding and a function call, and a list property usesA2uiSchemas.listOrReference. The builder resolves those forms throughBoundObject/BoundList, so the schema now says so and a data-bound table validates. - Data classes may nest: a nested schema is inlined by reference to its own
generated variable (never a
$ref) and the decoder calls the nested decoder. Enums andList<String>work inside a data class. - A data class may live in another library, as long as the widget's library
imports it without a prefix and that library declares its own
part '<file>.genui.dart';. Both are checked, with a build error naming the fix. - New build errors: a
Widget,List<Widget>or callback field inside a@GenUiDataclass, a data-class cycle (the message names the whole path), a@GenUiDataclass with no usable constructor, a generic@GenUiDataclass, a field whose wire key would be the reservedpathorcall, a class carrying both@GenUiWidgetand@GenUiData, two data classes whose lower-camel names collide (in one library or across the libraries one generated part refers to), a data class imported with ashow/hidecombinator that hides its generated schema and decoder, and a parameter whose type does not resolve at all (usually a missing import or an ambiguous name). An unsupported parameter type that is a class of your own now points at@GenUiData. - A constructor parameter called
keyis kept inside a@GenUiDataclass: a data class has nosuper.keyto skip, and dropping it produced a decoder that did not compile. - Generated examples include a sample object for a data property and two
sample objects for a list property. The entries of a list are numbered
(
Sample label 1,Sample label 2), their numbers are spread (42/43,42.5/43.5) and their enum fields walk the enum instead of repeating the first value, so the example shows the model that a field varies from row to row. A standalone object property is entry 0 and keeps the 0.1 samples. - A doc comment or
@GenUiProp(description:)on a property or field whose type is a data class is carried into the schema: on a widget property it becomes the description of theoneOfwrapper, and on a field of another data class the inlined schema is copied with that description in place of the class's own@GenUiData(description:). - Output for widgets that only use 0.1 types is unchanged, byte for byte.
0.1.2 #
- Corrected the declared dependency lower bounds so they match what the
generator actually requires:
source_gen>= 4.1.0 (forTypeChecker.typeNamedLiterally) andanalyzer>= 10.0.0 (where the element API the generator uses is no longer marked experimental). The previous 0.1.0/0.1.1 lower bounds did not resolve to a working build.