/** * Shared utilities for building drawing models (anchors + relationships) * used by both the streaming WorksheetWriter and the non-streaming WorkSheetXform. * * This eliminates the duplicated anchor/rel building logic and provides * a single, correct image-rel deduplication strategy. */ export interface DrawingAnchor { picture: { rId: string; hyperlinks?: { tooltip?: string; rId: string; }; /** Alpha modulation for transparency (OOXML percentage, e.g. 15000 = 15%). */ alphaModFix?: number; /** * When true, the picture references an external linked image * (``) instead of an embedded one (``). */ external?: boolean; /** * Relationship id of an SVG companion. When set, the raster `a:blip` * (referenced by `rId`) carries an `asvg:svgBlip` extension pointing at * the SVG media via this id. */ svgRId?: string; }; range: any; } export interface DrawingRel { Id: string; Type: string; Target: string; TargetMode?: string; } export interface DrawingModel { anchors: DrawingAnchor[]; rels: DrawingRel[]; } interface ImageMedium { imageId: string | number; range: any; hyperlinks?: { hyperlink?: string; tooltip?: string; }; /** Opacity 0-1 for watermark overlay mode. */ opacity?: number; } /** * Minimal shape of a book-level media entry needed by the embed-vs-link * decision and image-rel construction. Carries the optional link target plus * the three mutually-exclusive embedded byte sources. */ export interface MediaLike { name?: string; extension?: string; link?: string; buffer?: unknown; base64?: unknown; filename?: unknown; /** Media index of an SVG companion (raster blip + svgBlip extension). */ svgMediaId?: number; } /** * Resolves a media filename into the drawing-level relative target path. * * In the non-streaming path, media entries have separate `name` and `extension` * fields (e.g. name="image0", extension="png"). * In the streaming path, `name` already includes the extension (e.g. "image0.png"). * * This function accepts both forms and returns e.g. `"../media/image0.png"`. */ export declare function resolveMediaTarget(medium: { name?: string; extension?: string; }): string; /** * Determine whether a media entry is an **external (linked) image** rather than * an embedded one. An external image carries a `link` target and supplies no * embedded bytes (`buffer`/`base64`/`filename`). Embedding always takes * precedence: if any byte source is present the image is embedded even if a * `link` was also provided. */ export declare function isExternalImage(medium: MediaLike): boolean; /** * Best-effort image extension inference from an external link's path. * * Normalises to the extension vocabulary used by `ImageData` * (`"jpeg" | "png" | "gif"`); unknown extensions fall back to `"png"`. * The extension is advisory only for linked images — the relationship * Target carries the real reference — but keeping it within the documented * set avoids surprising consumers that branch on `medium.extension`. */ export declare function inferExternalImageExtension(link: string): "jpeg" | "png" | "gif"; /** * Build an image relationship for the given rId, choosing between an embedded * package target (`../media/imageN.ext`) and an external link target * (`TargetMode="External"`) based on whether the image is external. * * Shared by the drawing, background, and watermark write paths so the * embed-vs-link decision lives in exactly one place. */ export declare function buildImageRel(rId: string, bookImage: MediaLike): DrawingRel; /** Options for {@link buildDrawingAnchorsAndRels}. */ interface BuildDrawingOptions { /** Look up a book-level image by its id. Return `undefined` if not found. */ getBookImage: (imageId: string | number) => MediaLike | undefined; /** Generate the next unique rId string for the drawing rels. */ nextRId: (rels: DrawingRel[]) => string; } /** * Build the drawing anchors and relationships from a list of image media entries. * * This is the core logic shared between: * - `WorksheetWriter._writeDrawing()` (streaming) * - `WorkSheetXform.prepare()` (non-streaming) * * It correctly deduplicates image rels: if the same `imageId` is used for * multiple anchors, only one image relationship is created and shared. */ export declare function buildDrawingAnchorsAndRels(media: ImageMedium[], existingRels: DrawingRel[], options: BuildDrawingOptions): DrawingModel; /** * Filter drawing anchors to remove invalid entries before XML generation. * * Shared between streaming `WorkbookWriterBase.addDrawings()` and * non-streaming `XLSX.addDrawings()`. */ export declare function filterDrawingAnchors(anchors: any[]): any[]; export {};