/** * DiagView Utility Functions * Framework-agnostic helper functions * @module core/utils */ /** * Check if code is running in browser */ export function isBrowser(): boolean; /** * Detect if device is mobile/touch-capable */ export function isMobileDevice(): any; /** * Remove DiagView-specific parameters from URL without refreshing * Prevents URL pollution and ensures clean bookmarks */ export function stripDiagViewParams(): void; /** * Download a file from URL */ export function downloadFile(url: any, filename: any): void; /** * Debounce function execution * @param {Function} func - Function to debounce * @param {number} wait - Wait time in milliseconds * @returns {Function} Debounced function */ export function debounce(func: Function, wait: number): Function; /** * Throttle function execution with trailing-edge support * @param {Function} func - Function to throttle * @param {number} limit - Throttle limit in ms * @returns {any|undefined} - Function result if executed, undefined if throttled */ export function throttle(func: Function, limit: number): any | undefined; /** * Check if clipboard API is available */ export function isClipboardAvailable(): boolean; /** * Generate safe filename from text */ export function sanitizeFilename(text: any, fallback?: string): any; /** * Get timestamp string for filenames */ export function getTimestamp(): string; /** * Safe query selector all */ export function safeQuerySelectorAll(selector: any, context?: Document): any[]; /** * Lazy load script with synchronization to prevent thundering herd race conditions. * * @param {string} url - Script URL * @param {string|null} [integrity=null] - SRI hash * @returns {Promise} */ export function loadScript(url: string, integrity?: string | null): Promise; /** * Sanitize an SVG string or DOM Node to prevent XSS. * * Uses a secure DOM-walking approach (DOMParser + attribute walker) rather * than regex-based string replacement, which is trivially bypassed. * * Three modes are supported: * - 'strict' (default) — Blocks dangerous tags, animation vectors, * style injection, and external hrefs. * - 'permissive' — Blocks only scripts/iframes/objects and on* * event attributes. Matches legacy v0.x behavior. * - 'off' — Returns input unchanged. Use ONLY for SVGs * from a fully trusted, developer-controlled source. * * @param {string|Node} input - The SVG string or DOM Node to sanitize. * @param {'strict'|'permissive'|'off'} [mode='strict'] - Sanitization mode. * @param {number|object} [options=0] - Character limit (number) or options object. * @returns {string|Node} The sanitized string or Node. */ export function sanitizeSVG(input: string | Node, mode?: "strict" | "permissive" | "off", options?: number | object): string | Node; /** * Check for required dependencies */ export function checkPanzoomDependency(): boolean; /** * Fix ID collisions in SVG elements using a secure DOM-walking approach. * Replaces the unsafe and slow outerHTML/RegExp strategy with direct attribute manipulation. * This prevents XSS (no innerHTML parsing) and is significantly faster. * * @param {SVGElement} svg - The SVG element to fix * @param {string} uniqueId - Unique prefix for IDs * @returns {SVGElement} - The modified SVG element */ export function fixIds(svg: SVGElement, uniqueId: string, changes?: null): SVGElement; /** * Clear the SVG content cache. * MEM-1: Prevents memory leaks in long-running SPAs by releasing cached DOM nodes. */ export function clearSVGContentCache(): void; /** * Safely set SVG content using DOMParser to prevent XSS. * Optimized with a caching layer for static strings (icons, UI elements). * * @param {Element} el - Target element * @param {string} svgContent - SVG string content * @param {'replace'|'append'|'prepend'} mode - Insertion mode */ export function setSVGContent(el: Element, svgContent: string, mode?: "replace" | "append" | "prepend"): void; /** * Generate a unique ID for diagram instances * @returns {string} Unique generated ID */ export function generateUniqueId(): string; /** * Robust dimension calculator * Prioritizes BBox to ensure we capture the actual visible content area, * preventing alignment issues if the diagram doesn't start at 0,0. * * @param {SVGSVGElement} svg - The SVG element * @returns {object} Dimensions object {x, y, w, h, src} */ export function getRobustDimensions(svg: SVGSVGElement): object; /** * Adjust an SVG's viewBox to center its actual content (ink) * This fixes diagrams with internal offsets (like Mermaid) without * breaking the browser's native 'fit-to-container' scaling. * * @param {SVGSVGElement} svg - The SVG diagram to adjust */ export function centerSVGViewBox(svg: SVGSVGElement): void; //# sourceMappingURL=utils.d.ts.map