import { bytesToBase64 } from './image-bytes.js'; /** * Resolve a `url(#id)` paint value to its gradient def and the editor-format * string naming its colours — the SAME string `getColors` puts in the palette, * and therefore the key a stored `colorsReplace` is written against. Null for * any other paint (pattern, missing def, no stops, a plain colour). * * Exported for converters that keep their own colour matching (pptx): a * gradient key can never match by RGBA, so without this they resolve nothing * and silently leave the original gradient in place. */ export declare function resolveGradientPaint(doc: any, color: string): { grad: any; serialized: string; }; /** * Recolor an existing gradient def in place. Stops are always replaced; * geometry is kept untouched when only colors changed (so a pure recolor never * shifts userSpaceOnUse gradients visually) and regenerated in the unit box * only when the rotation was edited. A keeps its geometry * unconditionally — its shape is cx/cy/r/fx/fy, which no rotation describes. */ export declare function recolorGradientDef(grad: any, newColor: string): void; export interface UrlFetchOptions { /** * Keyed string cache shared across a render (pdf-export's ImageCache). * Entries are set to the IN-FLIGHT promise first, then replaced by the * resolved string — parallel renders of the same URL fetch once. Failed * fetches are evicted so a later attempt can retry. */ cache?: { buffers: Map>; } | null; /** * Custom fetcher. Defaults to `fetchWithRetry` (`@polotno/core/retry`), so * every caller gets the shared timeout + retry policy without asking. * Override to add a byte cache or a per-hop SSRF guard — pdf-export routes * these through its own `srcToBuffer` instead. */ fetchImpl?: (url: string) => Promise; /** * urlToBase64 only: base64-encode the raw response bytes instead of * decode-to-text + re-encode. Byte-identical for UTF-8 SVGs; binary-safe * for anything else. */ binary?: boolean; } export declare function urlToBase64(url: string, { cache, fetchImpl, binary, }?: UrlFetchOptions): Promise; export declare function urlToString(url: string, { cache, fetchImpl }?: UrlFetchOptions): Promise; export declare function getColors(svgString: any): string[]; export declare function applyOpacityToColor(color: string, opacity: number): string; export declare function svgToURL(s: any): string; export declare function fixRatio(svgString: string): string; export { bytesToBase64 }; /** A url the canvas renders as an SVG document instead of a raster image. */ export declare function isSvgUrl(url: string): boolean; export interface SvgSize { width: number; height: number; /** This axis came from the viewBox — the document states none the renderer can use. */ derivedWidth: boolean; derivedHeight: boolean; } /** * The intrinsic size of an SVG document, in px: its width/height attributes, * with the viewBox filling in whatever they don't state. NaN when it has * neither. */ export declare function resolveSvgSize(doc: any): SvgSize; /** * Normalize a root that leaves either axis to the renderer: browsers fall back * to 300x150, and node-canvas throws "Width and height must be set on the svg * element" outright. BOTH axes are rewritten in px, never just the missing one * — librsvg reads a surviving `210mm` at 90dpi where a browser uses 96, so a * mixed pair would rasterize at the wrong ratio. */ export declare function fixSizeInPlace(doc: any): void; /** * The intrinsic size an SVG url states; throws when it cannot be read. A `.svg` * url is parsed whatever the server labels it, since a host that serves it as * text/plain still holds a real document; any other url is gated on mime. */ export declare function getSvgSize(url: string): Promise; export declare function fixSize(svgString: string): string; export declare const sameColors: (color1: any, color2: any) => boolean; /** * Colour-replaced SVG markup. Prefer `replaceColors` unless you need to keep * transforming the string — going through the data URL and back is a wasted * base64 round-trip. */ export declare function replaceColorsInMarkup(svgString: string, replaceMap: Map): string; export declare function replaceColors(svgString: string, replaceMap: Map): string; /** * The data URL a renderer should draw for an SVG source: intrinsic size * normalized (`fixSizeInPlace`) and the element's colour replacements applied, * in one parse and one serialize rather than `fixSize` then `replaceColors`. */ export declare function prepareSvgSource(svgString: string, replaceMap?: Map | null): string;