import { CSSRuleToken, CSSToken, CSSAtRuleToken } from '../css/parser/types.js'; import { ParseSVGCallbackItem } from './parse.js'; import { SVG } from './index.js'; import '../misc/cheerio.js'; import '@iconizza/types'; import '@iconizza/utils/lib/customisations/defaults'; /** * Item in callback */ interface ParseSVGStyleCallbackItemCommon { prop: string; value: string; } interface ParseSVGStyleCallbackItemInline extends ParseSVGStyleCallbackItemCommon { type: 'inline'; item: ParseSVGCallbackItem; } interface ParseSVGStyleCallbackItemGlobal extends ParseSVGStyleCallbackItemCommon { type: 'global'; token: CSSRuleToken; selectors: string[]; selectorTokens: CSSToken[]; prevTokens: (CSSToken | null)[]; nextTokens: CSSToken[]; } interface ParseSVGStyleCallbackItemGlobalAtRule extends ParseSVGStyleCallbackItemCommon { token: CSSAtRuleToken; childTokens: CSSToken[]; prevTokens: (CSSToken | null)[]; nextTokens: CSSToken[]; } interface ParseSVGStyleCallbackItemGlobalGenericAtRule extends ParseSVGStyleCallbackItemGlobalAtRule { type: 'at-rule'; } interface ParseSVGStyleCallbackItemGlobalKeyframesAtRule extends ParseSVGStyleCallbackItemGlobalAtRule { type: 'keyframes'; from: Record; } type ParseSVGStyleCallbackItem = ParseSVGStyleCallbackItemInline | ParseSVGStyleCallbackItemGlobal | ParseSVGStyleCallbackItemGlobalGenericAtRule | ParseSVGStyleCallbackItemGlobalKeyframesAtRule; /** * Result: undefined to remove item, string to change/keep item */ type ParseSVGStyleCallbackResult = string | undefined; /** * Callback function */ type ParseSVGStyleCallback = (item: ParseSVGStyleCallbackItem) => ParseSVGStyleCallbackResult | Promise; type ParseSVGStyleCallbackSync = (item: ParseSVGStyleCallbackItem) => ParseSVGStyleCallbackResult; /** * Parse styles in SVG * * This function finds CSS in SVG, parses it, calls callback for each rule. * Callback should return new value (string) or undefined to remove rule. * Callback can be asynchronous. */ declare function parseSVGStyle(svg: SVG, callback: ParseSVGStyleCallback): Promise; /** * Synchronous version */ declare function parseSVGStyleSync(svg: SVG, callback: ParseSVGStyleCallbackSync): void; export { ParseSVGStyleCallback, ParseSVGStyleCallbackItem, ParseSVGStyleCallbackResult, ParseSVGStyleCallbackSync, parseSVGStyle, parseSVGStyleSync };