rfw_catalog_compiler library
Public entry point for the Remote Flutter Widget catalog compiler.
The compiler's full internal IR lives under src/ir; selected walker and
lowering entry points are exported for reflector integration.
Classes
- AddMemberWireIdEvent
- Event that adds a structured member to a union.
- AllocWireIdEvent
- Event that allocates a new wire ID.
- CatalogChange
- One detected per-entry change between two canonical catalog versions.
- CatalogDiffReport
- The full result of diffing two canonical catalog versions: every detected change with its classification, plus the emitted CompatRules.
- CategoryHeuristics
- Heuristic rules for property category inference.
- CategoryRule
- One category inference rule.
- ClassifiedChange
- A detected CatalogChange paired with its compatibility classification.
- CrossRefResolutionIndex
- Plain-data cross-reference resolution keys captured before lowering.
- DenylistFilter
- Pure type predicate. Stateless and depth-agnostic so it can walk analyzer type structures without depending on the rest of the compiler.
- DenylistMatch
- A type predicate's verdict. Null means "allowed". A non-null value names which category of the DenylistPolicy matched and carries a human-readable reason for the audit trail.
- DenylistPolicy
- Type-, type-suffix-, widget-, and per-class-property exclusions.
- DeprecateWireIdEvent
- Event that marks an entry as deprecated.
- DesignTokenHeuristics
- Heuristics that map property-name patterns to design-token wire IDs.
- DiagnosticIR
- One internal compiler diagnostic attached to IR.
- EntryAdded
- A new entry appeared in the new catalog version. Additive — no existing blob references it.
- EntryDeprecated
-
An entry gained a catalog-lifecycle deprecation —
deprecated.catalogis present in the new version and absent in the old. Additive — blobs continue to resolve; the editor warns. - EntryRemoved
- An entry present in the old version is absent from the new version. Breaking — blobs referencing the wire ID no longer resolve.
- EntryRenamed
- An entry's advisory label (display name, source path, or variant accessor) shifted while its wire ID stayed stable. Free under wire IDs.
- EntryReplaced
-
An entry gained a successor via a
replaceevent — itsdeprecated.catalog.replaceWithis present in the new version. Forwarding — the decoder remaps old references to successor. - LibraryWalkResult
-
Result of walking a barrel library for an
@RestageLibrarydeclaration. - MutexPolicy
- Mutually-exclusive property groups, keyed by widget flutterType.
- PolicyDecisionIR
- One compiler policy decision retained for audit trails.
- PolicyLedger
- Immutable bag of every compiler policy. Constructed once per compile pass and threaded through the analysis pipeline.
- PriorityHeuristics
- Heuristic settings that control property-priority ordering.
- PropertyDefaultChanged
-
A property's or structured field's
defaultSourcechanged — including anull↔ non-nulltransition or a change ofDefaultValueSourceKind. Additive — blobs carrying an explicit value are unaffected. - PropertyMetadataChanged
-
A property's editor metadata (
category/priority) changed. Additive — editor-surface metadata only. - PropertyTypeChanged
-
A property's or structured field's catalog
PropertyTypechanged. Alwayskind == WireIdKind.property. - RenameWireIdEvent
- Event that renames an existing wire-ID-backed entry.
- ReplaceWireIdEvent
- Event that links an entry to its successor.
- RequiredFlagChanged
-
A property's or structured field's
requiredflag flipped. - RestageCatalogGenAdapter
- Adapter from restage_catalog_gen's reflected schema entries into compiler IR.
- RestageCatalogGenEventLogWireIdResolver
- Replayed event-log resolver for restage_catalog_gen's adapter.
- RestageCatalogGenWireIdHooks
- Optional wire-ID hooks for the transitional restage_catalog_gen adapter.
- RestageLibraryDeclaration
- The declared identity of a customer widget library.
- StabilityPolicy
- Stability-tier rules for catalog entries.
- StructuredWalkPolicy
-
Whitelist + abstract-base list governing how the compiler recurses
into structured value types (e.g.
BoxDecoration,TextStyle). - StructuredWalkResult
- Result of walking one structured type entry point.
- SyntheticStrategyChanged
-
A property's
syntheticcodegen strategy changed. Breaking — the decoder semantics for the slot shift. - ThemeBindingSeeds
-
(widget-name, property-name) →
ThemeBindingPathseeds for theme-binding inference. - TokenFallbackChanged
-
A design token's
literalFallbackchanged. Additive — same render-time resolution contract as a resolver change. - TokenResolverChanged
-
A design token's
resolver(theme-binding path) changed. Additive — existing blobs see the new resolved value at render time. - TokenTypeChanged
-
A design token's
DesignTokenTypechanged. Breaking — properties referencing the token may have type-mismatched defaults. - UnionDiscriminatorChanged
- A union's discriminator field changed. Breaking — the on-wire format for the union slot shifts.
- UnionMemberAdded
- A member structured type was added to a union. Additive — a new option; existing blobs are unaffected.
- UnionMemberRemoved
- A member structured type was removed from a union. Breaking — blobs carrying that discriminator value fail.
- UnionRegistry
-
Built-in + customer-supplied abstract-type → concrete-subtype
mappings (Gradient →
LinearGradient, …). - UnionRegistryEntry
- One entry in a UnionRegistry, describing an abstract type and its known concrete subtypes.
- UnionResolution
- The product of resolving one abstract base into a discriminated union.
- UpdateTokenWireIdEvent
- Event that updates mutable design-token payload.
- VariantArgumentsChanged
-
A factory variant's argument shape changed — its
sourceKindor arg-to-fieldargMappingsdiffer. Breaking — the decoder semantics for the variant shift. - WidgetChildrenSlotChanged
-
A widget's
childrenSlotchanged (none ↔ single ↔ list). Breaking — a structural blob change is required. - WireIdAllocationCandidate
- A source/catalog entry that needs a wire ID allocation.
- WireIdAllocator
- Monotonic per-library wire-ID allocator.
- WireIdCurrentState
- Per-library materialized view derived from a wire-ID event log.
- WireIdEntryState
- Materialized current-state entry produced by replay.
- WireIdEvent
- Base type for all wire-ID event-log records.
-
WireIdEventField<
T> - Optional event field that preserves JSON field presence.
- WireIdReplayBuilder
- Incremental builder for wire-ID current-state replay.
Enums
- CompatClassification
- The four-way compatibility classification for a catalog change.
- DiagnosticSeverity
- Severity values for internal compiler diagnostics.
- RequiredFlagDirection
-
Direction of a
required-flag flip on a property or structured field. - StructuredKind
- Three-way verdict for classifyStructured.
- WireIdEventKind
- One of the append-only wire-ID event verbs.
Constants
- abstractTypeAwaitingUnion → const IssueCode
- Structured-type walk reached an abstract base type.
-
kBuiltInCategoryHeuristics
→ const List<
CategoryRule> - Built-in category heuristics seeding the obvious cases. Patterns are anchored regex source strings; the consumer compiles them at filter time.
-
kBuiltInThemeBindingSeeds
→ const Map<
String, ThemeBindingPath> -
Initial closed set of (widget, property) → ThemeBindingPath seeds.
Key shape:
'WidgetName.propertyName'. - kBuiltInWireIdBackfillActor → const String
- Actor recorded on the initial built-in catalog backfill events.
- kBuiltInWireIdBackfillTimestamp → const String
- Timestamp recorded on the initial built-in catalog backfill events.
-
knownRecipeStructuredTypes
→ const Set<
String> -
Structured value types the recipe path decomposes natively. A field or
parameter of one of these resolves to a
StructuredShapewhosestructuredRefpoints at the type's own catalog entry. - restageLibraryForeignWidget → const IssueCode
-
A walked
@RestageWidgetclass originates outside the declared package. - restageLibraryMalformed → const IssueCode
-
The
@RestageLibraryannotation could not be const-evaluated, or is missing its requiredlibraryfield. - restageLibraryReservedNamespace → const IssueCode
-
@RestageLibrarydeclares a built-in Restage namespace as its own library. - restageLibraryUnexportedWidget → const IssueCode
-
An
@RestageWidgetclass is reachable through a library in the@RestageLibrarybarrel's export closure, but is not itself exposed by the barrel's export namespace (ashow/hideclause excludes it). - structuredCycle → const IssueCode
- Structured-type walk encountered a repeated type while recursing.
- structuredDepthExceeded → const IssueCode
- Structured-type walk exceeded its configured recursion depth.
- structuredFactoryUnsupportedParam → const IssueCode
- Structured factory variant has an unsupported parameter type.
- unionMemberInvalid → const IssueCode
- A union member resolved to a class element that is not a valid concrete subtype of the union's abstract base.
- unionMemberUnresolved → const IssueCode
- A union member named in the registry did not resolve to a class element.
Functions
-
abstractStructuredFallback(
DartType type) → PropertyType? -
Maps an abstract Flutter base type (e.g.
Gradient,BoxBorder) to the legacyPropertyTypemember that downstream code uses to lower it on the wire. -
appendWireIdEventsSync(
File file, Iterable< WireIdEvent> events) → void - Appends canonical event lines to an existing log.
-
backfillRestageCatalogWireIds(
{required Catalog catalog, required WidgetLibrary library, Iterable< WireIdEvent> existingEvents = const [], String at = kBuiltInWireIdBackfillTimestamp, String by = kBuiltInWireIdBackfillActor}) → List<WireIdEvent> -
Allocates the initial built-in wire-ID backfill for
catalog. -
catalogDeprecationFor(
WireId id, List< WireIdEvent> events) → CatalogDeprecationInfo? -
Returns the catalog-lifecycle deprecation for
idby scanningeventsfor DeprecateWireIdEvents that targetid, ornullwhen none exist. -
classElementFor(
DartType type) → ClassElement? -
The
ClassElementbackingtype, or null whentypeis not an interface type with a resolvable class element. -
classifyCatalogChange(
CatalogChange change) → CompatClassification - Classifies a detected CatalogChange per the compatibility taxonomy.
-
classifyStructured(
DartType type, PolicyLedger policy) → StructuredKind -
Classifies
typeagainst the structured-walk policy inpolicy. -
computeCatalogDiff(
Catalog baseline, Catalog current, {String? fromVersion, String? toVersion}) → CatalogDiffReport -
Diffs two canonical catalog versions end to end: detects every per-entry
change, classifies each per the compatibility taxonomy, and emits the
CompatRules for the
forwarding/breakingones. -
crossRefIndexForStructured(
StructuredIR ir) → CrossRefResolutionIndex - Builds the cross-reference index for one structured type IR entry.
-
crossRefIndexForUnion(
UnionIR ir) → CrossRefResolutionIndex - Unions resolve from lowered member source types, so they add no index data.
-
diffCatalogs(
Catalog baseline, Catalog current) → List< CatalogChange> - Detects every per-entry change between two canonical catalog versions.
-
elementFqn(
ClassElement element) → String - Fully-qualified-name helpers for analyzer elements.
-
emitCompatRules(
List< CatalogChange> changes, {required String fromVersion, required String toVersion}) → List<CompatRule> -
Emits a
CompatRulefor everyforwardingandbreakingchange inchanges, in input order. -
encodeWireIdCurrentStateJson(
WireIdCurrentState state) → String - Encodes a current-state snapshot as pretty deterministic JSON.
-
encodeWireIdEventJson(
WireIdEvent event) → String - Returns a deterministic JSON string for a single event.
-
encodeWireIdEventsJsonl(
Iterable< WireIdEvent> events) → String - Encodes events as canonical JSONL with LF line endings.
-
inferPropertyCategory(
String name, CategoryHeuristics heuristics, {String? typeName}) → PropertyCategory? -
Returns the
PropertyCategoryfor a property namedname, ornullif no rule inheuristicsmatches. -
inferPropertyPriority(
{required bool required, required PriorityHeuristics heuristics}) → PropertyPriority? -
Returns the
PropertyPriorityfor a property, ornullif no priority claim can be made with confidence. -
interfaceFqn(
InterfaceElement element) → String -
The
<library-identifier>#<ClassName>identity forelement. -
interfaceFqnOrNull(
InterfaceElement element) → String? -
The
<library-identifier>#<ClassName>identity forelement, or null when the element has no name. -
linkCrossReferences(
Catalog catalog, CrossRefResolutionIndex index) → Catalog - Applies allocated wire IDs to post-allocation cross-reference sites.
-
literalFromDartObject(
DartObject value) → Object? -
Classifies a
DartObjectinto a catalog-bakeable literal, ornullwhen the value is not a supported literal shape. Mirrors the reflector's_decodePrimitiveclassification so the projecteddefaultValuestays byte-identical across the two default-resolution paths. -
lowerStructured(
StructuredIR ir) → StructuredEntry - Lowers one structured type IR entry to the public schema.
-
lowerUnion(
UnionIR ir) → UnionEntry - Lowers one union IR entry to the public schema.
-
parseWireIdEventsJsonl(
String contents, {String sourceDescription = 'wire_ids.events.jsonl'}) → List< WireIdEvent> -
Parses
wire_ids.events.jsonlcontents. -
readWireIdEventLogSync(
File file) → List< WireIdEvent> - Reads a wire-ID event log from disk using strict UTF-8.
-
replayWireIdEvents(
{required String library, required Iterable< WireIdEvent> events, String? generatedAt, Map<String, WireIdCurrentState> externalStates = const {}}) → WireIdCurrentState - Replays one library's event stream into a materialized current state.
-
resolveDefaultFromConstant(
{required bool hasDefault, required DartObject? value}) → DefaultValueSource? -
Resolves a parameter's pre-computed constant default into a
DefaultValueSource, following the catalog output rule. Returnsnullwhen the catalog makes no claim about the default. -
resolveParameterDefault(
FormalParameterElement param, {required PropertyType targetType}) → DefaultValueSource? -
Resolves the default of a constructor parameter into a
DefaultValueSource, per the catalog output rule. This is the element-facing entry point the reflector calls — it holds the liveFormalParameterElementand so can recover identifier names that a bareDartObjectcannot (true enum members, class static-consts). -
resolveThemeBindingDefault(
{required String widgetName, required String propertyName, required ThemeBindingSeeds seeds}) → ThemeBindingDefault? -
Resolves a theme-binding default for
widgetName.propertyNameby looking the pair up in the policy'sseedstable. Returnsnullwhen no seed matches. This is deterministic table application — not analyzer source inference; the seed table is a hand-maintained policy artifact. -
resolveUnion(
{required ClassElement abstractElement, required WidgetLibrary library, required PolicyLedger policy, required String location, required MemberElementResolver resolveMember}) → UnionResolution? -
Resolves
abstractElementinto a UnionResolution when its FQN is a registered abstract base inpolicy's union registry; returns null for an unregistered type (the caller keeps its existing fallback). -
resolveValueShape(
DartType type, {WidgetLibrary? library, PolicyLedger? policy, Set< String> ? referencedUnionFqns}) → CatalogValueShape? -
Resolves the semantic
CatalogValueShapeof a Darttype. -
staticConstMemberName(
DartObject value) → String? -
Returns the name of the static-const field on
value's declaring class whose constant value structurally equalsvalue, ornullwhenvalueis not a class-typed value or no field matches. -
typeFqn(
DartType type) → String? -
The
<library-identifier>#<ClassName>identity fortype, or null whentypeis not an interface type with a resolvableClassElement. -
valueShapeNeedsLinking(
CatalogValueShape? shape) → bool -
Whether
shapecarries a reference that a later linking pass must resolve. -
variantIdentity(
FactoryVariant variant) → String - Stable plain-data identity for a lowered factory variant.
-
variantIdentityIr(
FactoryVariantIR variant) → String - Stable plain-data identity for a factory variant IR entry.
-
walkRestageLibrary(
{required LibraryElement barrel, required AssetId barrelAssetId}) → LibraryWalkResult -
Walks
barrelfor an@RestageLibrarydeclaration and enumerates the@RestageWidget-annotated classes exposed by its export namespace. -
walkStructuredType(
{required ClassElement element, required WidgetLibrary library, required PolicyLedger policy, required String location, required Set< String> visited, required int depth}) → StructuredWalkResult - Walks a structured value type and returns its compiler IR.
-
wireIdEventFromJson(
Map< String, Object?> json, {int? lineNumber}) → WireIdEvent - Parses one wire-ID event from its JSON object representation.
-
wireIdEventRefFromJson(
Object? raw, {int? lineNumber}) → WireIdRef - Parses an event reference tuple from JSON.
-
wireIdEventRefToJson(
WireIdRef ref) → Map< String, Object?> - Converts an event reference tuple to JSON.
-
wireIdKindFromEventType(
String value) → WireIdKind -
Parses an event-log
typestring. -
wireIdKindToEventType(
WireIdKind kind) → String -
Converts a schema wire-ID kind to the event-log
typestring. -
writeWireIdCurrentStateSync(
File file, WireIdCurrentState state) → void -
Writes a derived
wire_ids.current.jsonfile. -
writeWireIdEventLogSync(
File file, Iterable< WireIdEvent> events) → void - Writes a complete canonical wire-ID event log to disk.
Typedefs
- MemberElementResolver = ClassElement? Function(String memberFqn)
- Resolves a member FQN to its analyzer class element, or null when the member cannot be located in the resolved element graph.
- RestageCatalogDeprecationResolver = DeprecationInfo? Function(WireId resolvedId, DeprecationInfo? existing)
- Merges or replaces the deprecation on a catalog entry.
- RestageDecompositionResolver = DecompositionRecipe Function(WidgetEntry widget, DecompositionRecipe recipe)
- Resolves decomposition wire-ID references for the catalog-gen adapter.
- RestagePropertyWireIdResolver = WireId Function(WidgetEntry widget, PropertyEntry property)
- Resolves property wire IDs for the catalog-gen adapter.
- RestageStructuredResolver = StructuredEntry Function(StructuredEntry entry)
- Resolves structured entry wire identity for the catalog-gen adapter.
- RestageUnionResolver = UnionEntry Function(UnionEntry entry)
- Resolves union entry wire identity for the catalog-gen adapter.
- RestageWidgetWireIdResolver = WireId Function(WidgetEntry widget)
- Resolves widget wire IDs for the catalog-gen adapter.
Exceptions / Errors
- CrossRefIndexException
- Thrown when CrossRefResolutionIndex.merge hits a duplicate key whose targets differ — the upstream capture produced conflicting cross-reference resolution data for one site.
- CrossRefLinkException
- Thrown when a cross-reference cannot be resolved from the supplied index.
- WireIdEventException
- Error thrown when a wire-ID event is structurally invalid.
- WireIdReplayException
- Error thrown when event replay violates wire-ID invariants.