@expofp/floorplan
Version:
Interactive floor plan library for expos and events
46 lines • 2.28 kB
TypeScript
import { type Booth } from '../store/BoothStore';
/** One `<image>` from a layer's drawing: where it sits, and the pixels to draw there. */
export interface LayerImage {
/** The booth this image belongs to, or null for a plain layer graphic. */
booth: Booth | null;
/** The image's name, when it has one. */
name?: string;
/**
* The bytes the renderer packs. An SVG image is rasterized and re-encoded as PNG.
*
* `createImageBitmap` rejects SVG bytes, so an SVG cannot travel to the atlas worker as it is.
* It stays a `Blob` all the same: a layer packs in the worker only while every one of its
* sources is a `Blob`, so one canvas among a layer's graphics would drop the whole layer back
* onto the main thread.
*/
source: Blob;
/** Placement read off the SVG element: top-left, size, and rotation in degrees. */
bounds: {
x: number;
y: number;
width: number;
height: number;
angle: number;
};
}
/**
* Loads a layer's drawing images as bytes.
*
* The placement comes from the SVG element, not from the file. Nothing here needs the image's
* intrinsic size, so a raster image is never decoded. Avoiding that decode on the main thread is
* the reason for this change.
*
* Most of these hrefs are inline `data:image/webp;base64` URLs, not file references. The
* converter embeds designer graphics directly in the drawing payload. In a real plan, the first
* such image is 74KB of WebP inside a 68-unit box. `fetch` serves a `data:` URL from the browser
* itself, with no network call and no CORS check, and returns a Blob whose `type` matches the one
* the URL declares. These Blobs reach the renderer exactly as a fetched logo does, and take the
* same worker path. A drawing can also carry `svg-images/…` file references. `@expofp/config`
* rebases those to absolute URLs before this function sees them. Both forms go through `loadBlob`
* unchanged.
* @param svgImages - The `<image>` elements to load.
* @returns One entry per image that loaded, in element order. Images that failed to load are
* dropped.
*/
export declare function loadLayerImages(svgImages: SVGImageElement[]): Promise<LayerImage[]>;
//# sourceMappingURL=loadLayerImages.d.ts.map