This function creates an anchor element, sets its href attribute to the provided image URL,
and triggers a click event to initiate a download with the specified filename.
What does it unlock?
Main exported function to save images from the configurator. Converts base64 image data to actual image
files and saves them to the local filesystem.
Practical Application
Exported utility function that converts base64 screenshot data (from screenshotReady event) to a downloadable
image file. Handles the base64 → blob → browser download flow. Import directly from the API package.
AI Coding Best Practices
Pattern: api.addEventListener('screenshotReady', (data) => { if(data) saveImage(data, 'config-screenshot.png'); }).
Filename extension should match the MimeType passed to GetScreenshot.
Import: import { saveImage } from '@3dsource/metabox-modular-configurator-api'.
Only the three data-URL formats the configurator actually produces are
accepted (image/png, image/jpeg, image/webp). The documented usage above
feeds this an event payload straight off the wire, and the body below sets
href on an anchor and clicks it — so without the check any data: URL that
reached a screenshotReady listener would land in the user's downloads.
Anything else is reported and ignored.
Saves an image by triggering a download.
This function creates an anchor element, sets its
hrefattribute to the provided image URL, and triggers a click event to initiate a download with the specified filename.What does it unlock?
Main exported function to save images from the configurator. Converts base64 image data to actual image files and saves them to the local filesystem.
Practical Application
Exported utility function that converts base64 screenshot data (from screenshotReady event) to a downloadable image file. Handles the base64 → blob → browser download flow. Import directly from the API package.
AI Coding Best Practices
Pattern:
api.addEventListener('screenshotReady', (data) => { if(data) saveImage(data, 'config-screenshot.png'); }). Filename extension should match the MimeType passed to GetScreenshot. Import:import { saveImage } from '@3dsource/metabox-modular-configurator-api'.Only the three data-URL formats the configurator actually produces are accepted (
image/png,image/jpeg,image/webp). The documented usage above feeds this an event payload straight off the wire, and the body below setshrefon an anchor and clicks it — so without the check anydata:URL that reached ascreenshotReadylistener would land in the user's downloads. Anything else is reported and ignored.