build library

Pure-Dart SSG build surface - safe to import from a bin/build.dart executed on the plain Dart VM (no Flutter engine, no dart:ui).

The umbrella package:hydraline_flutter/hydraline_flutter.dart library pulls in Flutter widgets and cannot be compiled for VM executables; this library exposes only the build-time pieces plus the core re-export.

Classes

AnchorNode
An anchor <a href>; href is always a SafeUrl.
Audit
CLI audit entry points.
AuditReport
The result of an audit: findings plus a process exit code (0 = ok).
BlockquoteNode
A <blockquote> with an optional cite.
CodeNode
A <code> span/block with optional language hint.
ContentSource
Content owner: Flutter widgets (surface A) or a pure-Dart builder (surface B).
Csp
Helper for the recommended Content-Security-Policy: script-src 'self' 'wasm-unsafe-eval' (no unsafe-inline; CanvasKit needs wasm-unsafe-eval).
DartBuilderContent
Surface B: a pure-Dart DocumentNode builder (e.g. BlogPostBuilder.new).
DetailsNode
A <details> disclosure with its <summary>.
DocumentNode
Root of the node hierarchy.
DocumentRootNode
The document root: an optional <head> plus a body.
DynamicSegments
Expands dynamic segment patterns into concrete paths.
GoRouterAdapter
First-class go_router adapter: wraps a go_router object and reads its route configuration. The constructor accepts Object so the package does not need an explicit go_router dependency - route extraction works at runtime via reflection-ish inspection of the GoRouter.routes property.
HeadingNode
A heading <h1>..<h6>.
HeadNode
The <head> container (title/meta/link children).
HreflangAlternate
An hreflang alternate (en, ru, x-default, …).
HtmlSerializer
Serializes a DocumentNode tree to HTML.
HtmxIslandNode
An HTMX island (level 1).
ImageNode
An image <img src alt>; src is always a SafeUrl.
IslandManifest
The set of islands on a page, embedded into the HTML and consumed by the dispatcher.
IslandPlaceholderNode
A Flutter island (level 2).
IslandSize
Reserved placeholder size in px to prevent layout shift.
IslandSpec
A serialisable island descriptor.
IslandStateCodec
Serialises island props across the server → HTML → client boundary.
JsonLd
Type-safe JSON-LD builders.
JsonLdNode
A <script type="application/ld+json"> structured-data block.
JsonLdSchema
A structured-data schema serialised into <script type="application/ld+json">.
LinkNode
A <link rel href> (e.g. canonical, hreflang alternate).
ListItemNode
A list item <li>.
ListNode
An ordered (<ol>) or unordered (<ul>) list.
MetaNode
A <meta> tag (name/property/content/charset).
Fallback for bare Navigator 2.0 applications.
OpenGraph
Open Graph metadata (full set).
ParagraphNode
A paragraph <p>.
PreNode
A <pre> block.
Robots
robots.txt generator.
RobotsDirectives
Robots directives for a route.
RobotsRule
A User-agent group with its allow/disallow paths.
RouteAdapter
Interface: any router can provide the list of routes the SSG runner should iterate over for extraction.
RouteEntry
A single route entry.
RouteInfo
A single route descriptor.
RouteManifest
The route manifest. YAML is primary; the Dart builder emits the same YAML.
RouteManifestBuilder
Builder for a RouteManifest.
SafeUrl
A URL that has passed scheme sanitisation. There is no public constructor: instances come only from SafeUrl.parse/SafeUrl.tryParse, so a node can never be built with an unchecked URL.
SectionNode
A sectioning wrapper (<section>/<article>/<nav>/<header>/<footer>/<main>).
SeoMeta
The full metadata model of a route.
SeoValidator
Validates SEO/safety rules: title/description lengths, required alt text, duplicate canonical links, malformed hreflang, unsafe HTML.
Sitemap
Sitemap generator.
SitemapEntry
A single sitemap URL entry.
SitemapOutput
The generation result: one file, or an index plus shards.
SitemapSource
A source of sitemap entries: route manifest, DB provider, etc.
SsgCollector
Instance-scoped collector. Immutable after seal.
SsgListScope
A nested list scope returned by SsgCollector.beginList. Each beginItem appends a <li> to the list and returns a collector that gathers that item's content.
SsgResult
The result of an SSG run.
SsgRunner
Runs on the plain Dart VM (dart run hydraline_flutter:build or a custom bin/build.dart). Page content comes from registered pure-Dart SsgPageBuilders (surface B); routes without a builder produce a metadata-only shell from the manifest. Widget-based extraction (surface A) happens separately via SsgCollector inside a flutter test --tags ssg harness.
SummaryNode
A <summary>.
TableCellNode
A table cell (<th> when header, otherwise <td>).
TableNode
A <table>.
TableRowNode
A table row <tr>.
TextNode
Text content. Stored raw; always escaped on serialization.
TimeNode
A <time> element carrying an ISO-8601 dateTime.
TitleNode
The <title>.
TwitterCard
Twitter Card metadata.
UnsafeHtmlNode
The only path for raw HTML. The name intentionally contains "Unsafe". Without a sanitizer the SeoValidator emits a warning.
ValidationIssue
A single validation finding.
VanillaIslandNode
A vanilla island (level 1): accordion|tabs|carousel|theme|copy-button|lazy-image.
WidgetContent
Surface A: content extracted from route widgets at build time (SSG).

Enums

ChangeFreq
changefreq values.
HydrationDirective
When an island hydrates.
IslandRenderMode
What an island emits into the HTML.
IslandStyleMode
How island styles are scoped.
IslandType
Island kind.
RouteMode
Render mode of a route (WebRouteRenderMode).
SectionRole
Semantic sectioning role.
TwitterCardType
Twitter Card type.
ValidationSeverity
Severity of a validation issue.

Constants

htmxGlueJs → const String
vanillaIslandsJs → const String

Functions

buildHead(SeoMeta meta, {List<JsonLdSchema> structuredData = const []}) HeadNode
Builds a deterministic <head> from meta.
defaultHtmlFetcher({Duration timeout = const Duration(seconds: 30)}) HtmlFetcher
The default dart:io HtmlFetcher used when none is injected.
escapeHtmlAttribute(String input) String
Escapes an attribute value: &, <, >, ", ' become entities.
escapeHtmlText(String input) String
Escapes text content: &, <, > become entities.
islandRuntime({String engineScript = '/flutter_bootstrap.js', String? islandElementIntegrity, String? dispatcherIntegrity}) List<DocumentNode>
Returns the runtime script nodes needed for island hydration: the engine bootstrap location via HYDRALINE_CONFIG, the custom element, and the dispatcher. engineScript points to the Flutter engine bootstrap (defaults to /flutter_bootstrap.js).
runAuditCli(List<String> args, {HtmlFetcher? fetch, StringSink? out, StringSink? err}) Future<int>
Runs the audit CLI. Returns the process exit code.
runSsgCli({required String manifestPath, required String outputDir, required Map<String, Object?> islandFactories, RouteAdapter? adapter, Map<String, SsgPageBuilder> builders = const {}}) Future<int>
sanitizeHtml(String html) String
Strips the most common XSS vectors from raw HTML: <script> elements and inline event-handler attributes (on*). This is a baseline defence, not a full HTML sanitizer - pass it as UnsafeHtmlNode.sanitizer when the raw HTML cannot be fully trusted.

Typedefs

HtmlFetcher = Future<String> Function(Uri uri, {Map<String, String> headers})
Fetches the HTML body of uri. Injectable for tests.
IslandState = Map<String, Object?>
JSON-safe island state: String|int|double|bool|null|List|Map<String,Object?>.
SsgPageBuilder = DocumentNode Function(String path)
A pure-Dart page builder (surface B) invoked at build time for each concrete path expanded from the route pattern it is registered under.

Exceptions / Errors

UnsafeUrlException
Thrown by SafeUrl.parse when a URL's scheme is not allowed.