Skip to content

feat: replace webshot widget export with client-side PNG capture#335

Open
mbarrenechea wants to merge 3 commits into
v2from
feat/client-side-png-export
Open

feat: replace webshot widget export with client-side PNG capture#335
mbarrenechea wants to merge 3 commits into
v2from
feat/client-side-png-export

Conversation

@mbarrenechea

Copy link
Copy Markdown
Member

Summary

  • Replace server-side webshot pipeline with fully client-side PNG export using html-to-image (toPng), eliminating the round-trip to the webshot NestJS service for individual indicator card exports
  • Clone-based export strategy: clones the card off-screen, composites map screenshots as image overlays, inlines foreignObject computed styles (preserving CHROMA-luminance text colors), then captures — the original DOM is never modified (no visual flash)
  • Remove dead webshot widget code: delete the widgets controller/service/module from the webshot service, the Next.js webshot page/route, and the client-side mutation/constants

Changes

Added

  • CardExportProvider context (export-provider.tsx) — manages map registrations and clone-based exportAsPng
  • MapExportRegistrar component (export-registrar.tsx) — registers ArcGIS map takeScreenshot callbacks
  • html-to-image dependency in client

Modified

  • card.tsx — wraps each indicator card with CardExportProvider, uses client-side export instead of webshot mutation
  • map/index.tsx — integrates MapExportRegistrar for map canvas capture
  • legend/index.tsx — opens legend by default in non-interactive (export) mode
  • legend/item.tsx — uses data-export-exclude attribute consistently
  • webshot.ts — removed usePostWebshotWidgetsMutation and related types
  • app.module.ts — removed WidgetsModule import

Removed

  • webshot/src/widgets/ — controller, service, module (server-side widget capture)
  • client/src/app/(frontend)/[locale]/webshot/widgets/ — webshot page
  • client/src/app/(frontend)/local-api/webshot/widgets/route.ts — proxy route
  • client/src/constants/webshot.ts — webshot widget constants
  • client/src/containers/webshot/widgets/ — webshot widget containers

Test plan

  • All 132 unit tests pass (including 15 new export-provider tests + 6 export-registrar tests)
  • TypeScript types clean (pnpm check-types)
  • ESLint clean (pnpm lint)
  • Manual: verify PNG export produces correct output (text colors, map overlays, layout)
  • Manual: verify original card does not flash/change during export
  • Manual: verify legend appears expanded in export

Replace the server-side webshot widget export pipeline with a fully
client-side approach using html-to-image (toPng). This eliminates the
round-trip to the webshot service for individual indicator card exports.

Key changes:
- Add CardExportProvider context with clone-based export strategy that
  never modifies the original DOM (no visual flash during capture)
- Add MapExportRegistrar to capture ArcGIS map canvases via takeScreenshot
  and composite them as image overlays on the export clone
- Inline foreignObject computed styles from the original onto the clone
  to preserve CHROMA-luminance text colors in SVG charts
- Remove webshot widgets endpoint, controller, service, and route
- Remove webshot constants and usePostWebshotWidgetsMutation
- Add html-to-image dependency to client
- Open legend by default and hide interactive controls in export mode
@vercel

vercel Bot commented Mar 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
amazonia-360 Ready Ready Preview, Comment Mar 9, 2026 10:04pm

Request Review

@sonarqubecloud

sonarqubecloud Bot commented Mar 9, 2026

Copy link
Copy Markdown

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