Skip to main content

bloc_signals_genui_jaspr 2.2.0 copy "bloc_signals_genui_jaspr: ^2.2.0" to clipboard
bloc_signals_genui_jaspr: ^2.2.0 copied to clipboard

Jaspr web component bindings and DOM catalog adapters for BlocSignal Generative UI (A2UI).

bloc_signals_genui_jaspr

⚡ bloc_signals_genui_jaspr

"With the rigor of BLoC and the flex and speed of Signals"

Jaspr web component bindings, HTML DOM catalog adapters, and 0ms reactive two-way data bindings for bloc_signals_genui and Google's A2UI (Agent-to-User Interface) protocol.

pub points pub package license

bloc_signals_genui_jaspr connects the pure-Dart A2uiSurfaceBloc state machine to Jaspr's web component hierarchy via A2uiSurfaceView, A2uiJasprCatalog, A2uiComponentContext, and standard DOM catalog components.


🌐 Ecosystem Packages #

The BlocSignal monorepo consists of 14 modular packages:

Package Version Description
bloc_signals pub Core pure Dart reactive state primitives bridging BLoC & Signals
bloc_signals_flutter pub Flutter UI bindings, providers, builders, listeners & selectors
bloc_signals_bloc pub Classic BLoC 8/9 interop adapters & bidirectional event bridges
bloc_signals_riverpod pub Bidirectional Riverpod 2/3 interop adapters & provider extensions
bloc_signals_jaspr pub Jaspr web component integration and state binding for BlocSignal
bloc_signals_hydrate pub Automated synchronous local state persistence & hydration
bloc_signals_replay pub Undo & redo state history tracking for CubitSignal and BlocSignal
bloc_signals_otel pub OpenTelemetry tracing and span generation for state transitions
bloc_signals_devtools pub Universal DevTools telemetry observer using dart:developer
bloc_signals_test pub Declarative unit testing utilities (blocSignalTest)
bloc_signals_lint pub Custom analyzer lint rules & automated IDE quick-fixes
bloc_signals_genui pub Pure-Dart A2UI streaming state machine & Generative UI runtime adapter
bloc_signals_genui_flutter pub Declarative Flutter surface containers & A2UI catalog widget adapters
bloc_signals_genui_jaspr pub Declarative Jaspr web components & DOM catalog adapters for A2UI

⚡ Key Features #

  • 🎨 A2uiSurfaceView: Reactive Jaspr web component handling the complete A2uiSurfaceState lifecycle (SurfaceInitial, SurfaceStreaming, SurfaceReady, SurfaceSubmitting, and SurfaceError) with customizable builders, per-component error boundaries, and bounded per-render maxDepth (default 32) / nodeBudget (default 1000) guards against exponential DAG payloads.
  • 🧱 A2uiJasprCatalog: Extensible component registry pre-populated with all 16 BasicCatalog DOM components (Text, Row, Column, Card, Divider, Button, TextField, List, Tabs, Modal, Icon, Image, CheckBox, ChoicePicker, Slider, and DateTimeInput) alongside immutable composition helpers (copyWith, copyWithout, registerAll). A2uiJasprCatalog.standard(imagePolicy: ...) enforces the shared A2uiImageUrlPolicy (re-exported from bloc_signals_genui), blocking http://, loopback, link-local, private/CGNAT/ULA/IPv4-compat/NAT64 networks (allowPrivateNetworks: false), and IPv4 SSRF parser differentials (octal, hex, shorthand, and 32-bit integer hosts) by default.
  • ♿ A2UI 1.0 Conformance (NodeAction, weight, accessibility, metadata): Supports NodeAction functionCall execution via A2uiComponentContext.triggerAction(), positive finite child weight (flex-grow) via buildWeightedChildren, universal accessibility envelopes (hidden, aria-label, aria-description), and component metadata access.
  • ✅ Reactive CheckRule Validation UI: Automatically surfaces GenericBinder validation state (isValid, validationErrors, validationResults) across form inputs and disables button submissions when validation rules fail.
  • ⚡ Granular Signal Bindings & Two-Way Sync: Each rendered component subscribes to its own resolved properties and writes two-way input mutations via A2uiComponentContext.updateBoundValue, updating leaf DOM elements and A2uiSurfaceBloc form data in 0ms on data changes without tearing down parent containers.
  • 🧭 Multi-Surface & Split-Pane Support: Pin A2uiSurfaceView(bloc: bloc, surfaceId: '...') to a specific surface or omit surfaceId to follow bloc.activeSurfaceId reactively across tabs and split views.
  • 🛡️ Defensive LLM Property Coercion: Built-in safe_prop_parser.dart utilities (unwrapBinding, asString, asInt, asDouble, asBool, extractChildId, extractChildIds, parseSliderRange) protect the DOM tree from malformed or stringified LLM JSON properties.

📦 Installation #

Add bloc_signals_genui_jaspr to your Jaspr project:

dart pub add bloc_signals_genui_jaspr

Or declare it in your pubspec.yaml:

dependencies:
  jaspr: ^0.23.1
  bloc_signals: ^1.9.0
  bloc_signals_jaspr: ^1.3.1
  bloc_signals_genui: ^2.1.0
  bloc_signals_genui_jaspr: ^2.1.0
  a2ui_core: ^0.7.0

🚀 Quick Start #

Rendering an Interactive A2UI Surface #

import 'package:bloc_signals_genui/bloc_signals_genui.dart';
import 'package:bloc_signals_genui_jaspr/bloc_signals_genui_jaspr.dart';
import 'package:bloc_signals_jaspr/bloc_signals_jaspr.dart';
import 'package:jaspr/dom.dart';
import 'package:jaspr/jaspr.dart';

// Dart 3.5+ (Standard)
class AgentSurfacePage extends StatelessComponent {
  const AgentSurfacePage({
    required this.surfaceBloc,
    super.key,
  });

  final A2uiSurfaceBloc surfaceBloc;

  @override
  Component build(BuildContext context) {
    return section(classes: 'agent-surface-page', [
      const h1([Component.text('Generative UI Surface')]),
      A2uiSurfaceView(
        bloc: surfaceBloc,
        // Enforces A2uiImageUrlPolicy (shared from bloc_signals_genui) by default.
        catalog: A2uiJasprCatalog.standard(
          imagePolicy: const A2uiImageUrlPolicy(),
        ),
      ),
    ]);
  }
}

// Dart 3.13+ (Modern Primary Constructor)
class const ModernAgentSurfacePage({
  required this.surfaceBloc,
  super.key,
}) extends StatelessComponent {
  final A2uiSurfaceBloc surfaceBloc;

  @override
  Component build(BuildContext context) {
    return section(classes: 'agent-surface-page', [
      const h1([Component.text('Generative UI Surface')]),
      A2uiSurfaceView(
        bloc: surfaceBloc,
        // Enforces A2uiImageUrlPolicy (shared from bloc_signals_genui) by default.
        catalog: A2uiJasprCatalog.standard(
          imagePolicy: const A2uiImageUrlPolicy(),
        ),
      ),
    ]);
  }
}

Registering Custom Catalog Components #

Extend A2uiJasprCatalog.standard() using copyWith (or register) to bind domain-specific A2UI components to custom Jaspr web components while reading and mutating form signals through A2uiComponentContext:

final customCatalog = A2uiJasprCatalog.standard().copyWith({
  'MetricBadge': (context, A2uiComponentContext componentContext) {
    final label = componentContext.props['label'] as String? ?? 'Metric';
    final value = componentContext.props['value']?.toString() ?? '0';

    return button(
      classes: 'metric-badge-btn',
      onClick: () => componentContext.dispatchAction('inspect_metric'),
      [Component.text('$label: $value')],
    );
  },
});

🛡️ License #

MIT License. See LICENSE for details.

0
likes
160
points
584
downloads

Documentation

API reference

Publisher

verified publisherblocsignal.dev

Weekly Downloads

Jaspr web component bindings and DOM catalog adapters for BlocSignal Generative UI (A2UI).

Repository (GitHub)
View/report issues
Contributing

Topics

#bloc #signals #genui #a2ui #jaspr

License

MIT (license)

Dependencies

a2ui_core, bloc_signals, bloc_signals_genui, bloc_signals_jaspr, jaspr, json_schema_builder, meta

More

Packages that depend on bloc_signals_genui_jaspr