Skip to content

Browser splash: print a receipt of the download on a thermal printer - #19

Merged
danielmeza merged 1 commit into
mainfrom
feat/printing-splash
Sep 22, 2026
Merged

danielmeza merged 1 commit into
mainfrom
feat/printing-splash

Conversation

@danielmeza

Copy link
Copy Markdown
Owner

Follow-up to #18, which merged the first splash (a blank strip that grew with the file count). This turns it into a real printing animation. While the browser version downloads (~45 MB, 235 files), a small thermal printer prints a receipt of the download.

What it does

  • One receipt line per downloaded file. Each line shows the name, with the build hash stripped, and the size. The paper feeds up in motor steps, older lines fade out at the top, and a status LED blinks while it prints.
  • Hand-off. When the runtime is ready, the receipt prints the total and a barcode, the status switches to "Starting the emulator…", and Avalonia's first frame fades the splash out. Avalonia 12 adds .splash-close to #avalonia-splash, and main.js adds it too after runMain as a fallback.
  • Failure. The LED turns red, the receipt prints *** PRINT FAILED *** at once, and the status says to reload, followed by the underlying error.
  • Accessibility. Only phase changes are announced (role="status"), not each receipt line. With prefers-reduced-motion, lines appear without the feed animation and the LED doesn't blink.
  • Where the data comes from. The Resource Timing API (PerformanceObserver), so names and sizes are real and cache hits count. The first commit used onDownloadResourceProgress. That hook isn't in dotnet.d.ts, and its file total grows during startup (25, then 54, then 140), so progress could jump backwards.

Tested locally

I published with -c Release -p:PublishTrimmed=false -p:CompressionEnabled=false, served wwwroot, and drove Chromium via Playwright:

  • Throttled to 30 Mbit/s: lines print as files arrive, and the splash hands off to the app at about 13 s.
  • Unthrottled: no script errors, and the app starts normally.
  • Runtime blocked (dotnet.native*.wasm aborted): the error state shows the red LED, the PRINT FAILED line and the error message.

Merging redeploys the Pages demo. No new tag is needed.

🤖 Generated with Claude Code

The loading splash is now a small receipt printer. Each downloaded file prints as a receipt line
(name without the fingerprint, and size) and feeds the paper up in motor steps; a status LED blinks
while printing. When the runtime is ready it prints the total and a barcode, then Avalonia's first
frame fades the splash out.

Lines come from the Resource Timing API (PerformanceObserver), so names and sizes are real and cache
hits count. This replaces onDownloadResourceProgress, which isn't in dotnet.d.ts and whose file
total grows during startup, so its progress could jump backwards. On failure the LED turns red, the
receipt prints "*** PRINT FAILED ***" right away, and the status explains how to recover. With
prefers-reduced-motion, lines appear without the feed animation and the LED doesn't blink.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@danielmeza
danielmeza merged commit b2523d0 into main Sep 22, 2026
1 check passed
danielmeza added a commit that referenced this pull request Sep 22, 2026
Revert the printing-receipt splash (#19); restore the first splash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant