hyperlens 0.1.1
hyperlens: ^0.1.1 copied to clipboard
Source-linked preview for Markdown and HTML: rendering, outline and reading position share one address (source line or DOM path), so editors can jump either way.
0.1.1 #
No change to the library itself — this release only tidies what the package ships with.
- The example is split by responsibility:
lib/main.dartkeeps the render pipeline (commit, receipt routing, reading-position semantics), while the sample documents, toolbar, outline drawer, status bar, syntax sheet and platform fallback moved tolib/src/. - The
descriptioninpubspec.yamlwas tightened to the length the pub specification asks for.
0.1.0 #
First extraction from the preview implementation of an editor app.
- Markdown rendering payload with line/block markers, safe HTML (DOMPurify), and KaTeX / mhchem math.
- HTML rendering payload with a DOM-path address for restoring the reading position.
- The HTML outline also picks up ARIA headings (
role="heading"witharia-level, defaulting to 2 and capped at 6) next to<h1>~<h6>; one entry per heading, so a heading nested inside another keeps only the outer one. - The HTML outline watches the document height (
ResizeObserver) and re-scans after a disclosure panel opens or closes, or an image grows — no page reload needed. - New syntax-tree skeleton receipt (
ast): Markdown reuses the same lexer as the render pass, HTML walks the browser's owndocument; the payload is clipped by node count, depth and byte gates. Dart side exposesPreviewSyntaxTree/PreviewSyntaxNode. - The full tree (nested blocks plus inline tokens) is fetched on demand through
HyperlensCommands.requestSyntaxAst(), sharing the same tokens and line numbers as the skeleton. - Syntax issue list (
issuesin theastreceipt): the page reports unclosed code fences, table rows whose cell count differs from the header, and reference-style links with no definition; the Dart side addsscanHtmlTagIssues(), a tag-stack scan over the source text that finds unclosed and stray end tags the browser's fixed-updocumentno longer shows. When both sources are merged the page's entries come first, and a duplicate (same kind, same place) is dropped. - Receipt protocol: render ready, link tapped, position reported, outline reported, focus applied, anchor scrolled, unknown message.
- Source-linked outline and syntax tree built from the same parse.
- Web assets (marked, DOMPurify, KaTeX, mhchem, highlight.js, Mermaid) declared by the package; the caller stops declaring them.
- Public surface:
HyperlensPage.fromTextis the single render entry (Markdown and HTML alike);HyperlensAssets,HyperlensBridge,HyperlensTheme,HyperlensLoggerandHyperlensAssetLoader(HyperlensRootBundleAssetLoaderfor Flutter) are the rest of it. - The WebView channel name is injected instead of being hard-coded: the Markdown
template takes it through a placeholder,
htmlAnchorScript(channelName:)for the HTML side, so the caller can register its own name. Either has to matchaddJavaScriptChannel, and a name that is not a valid identifier is rejected while the script is assembled. - Missing enhanced assets (KaTeX, mhchem, Mermaid) degrade to plain text and report
through
HyperlensLoggerinstead of failing the whole page. HyperlensThemetreats dark and ink as independent axes: ink is a monochrome overlay shipped in both polarities (*-ink.cssfor the default light e-ink look,*-ink-dark.cssfor its inverse).- Mermaid stays fully visible on dark backdrops: Sankey link bands were lost because
Mermaid hard-codes
mix-blend-mode: multiplyon them, which only works over a light page; the blend mode is now set back tonormalfor the dark themes only, so the light and light-ink looks are unchanged. - Reading positions are one address type (breaking):
PreviewSourceAddressfor a Markdown source line,PreviewDomAddressfor an HTML DOM path such asbody>div#main>p:nth(3), plusPreviewViewportcarrying the per-frame viewport lines that drive outline highlighting.PreviewAnchor(block/offset/scrollY) is gone, pages are only told to scroll throughHyperlensCommands(mdScrollToLine/hyperLensScrollToPath), and a position that cannot be resolved puts the reader back at the top instead of guessing. Saved positions still parse: a storedlineis reused, a pixel-only record falls back to top. - Documented that
HyperlensThemeis the sole definition of "how this page looks" for a host that has to decide whether to reload: the rendered page is a snapshot (background, text colour and overlay layers are baked into the HTML at load time), so a new knob has to be added together with==/hashCode. The case that bit us: ink and light share the same#ffffffbackground, so a host comparing only the background skipped the reload on "ink → light" and kept the ink monochrome overlay — coloured headings turned black (see theHyperlensThemeclass docs).