feat(embed): exportPNG canvas compositor + postMessage export protocol#28
Merged
Conversation
handle.exportPNG({scale, includeWidgets}) composites the per-panel canvas
stack (gpu/plot/axes/colorbar/markers/scalebar/title, insets on top) onto
one offscreen canvas at DPR*scale and returns a PNG data URL. WebGPU
panels are force-redrawn and read back in the same synchronous task, so
callers need no settling delay. Standalone HTML gains a message listener
(anyplotlib_export_png -> anyplotlib_export_png_result) riding the same
channel as awi_state, for iframe hosts.
render() now returns its internal api ({panels, exportPNG, gpu disposers});
mount() captures it — this also fixes mount().dispose(), which previously
referenced closure-scoped state it could not reach and silently no-oped.
This was referenced Jul 12, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #28 +/- ##
=======================================
Coverage 88.97% 88.97%
=======================================
Files 38 38
Lines 3511 3511
=======================================
Hits 3124 3124
Misses 387 387 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
handle.exportPNG({scale, includeWidgets})composites the per-panel canvas stack (gpu/plot/axes/colorbar/markers/scalebar/title, insets on top) onto one offscreen canvas at DPR×scale and resolves to a PNG data URL.messagelistener (anyplotlib_export_png→anyplotlib_export_png_result) so iframe hosts (SpyDE report cells) can harvest WYSIWYG snapshots.render()now returns its internal api andmount()captures it —mount().dispose()previously referenced closure state it couldn't reach and silently no-oped.Branch is based on
release/v0.2.0(main hasn't caught up to the release-prep commits), so those two commits appear in the diff until main is fast-forwarded.Tests
tests/test_embed/test_export_png.py: 7 passed (basic pixel/LUT checks, multi-panel arrangement, iframe postMessage round-trip, WebGPU readback — skips cleanly without an adapter). Fulltest_embed/+test_plot2d/+test_layouts/regression: 439 passed, 6 pre-existing baseline skips.