import { ExtCssRuleData, ParsedSelectorData, RawCssRuleData, RawStyleGroup, SelectorPartData, RawResults } from './types'; import { AnySelectorNodeInterface, ExtCssDocument } from '../selector'; import { StyleDeclaration } from '../style-block'; /** * Checks the presence of action pseudo-classes and validates them * while parsing the selector part of a CSS rule. * * Action pseudo-classes are not about element selecting but about actions * with elements, so they are stripped from the selector and returned * as synthetic style declarations. * * @param rawSelector Selector which may contain an action pseudo-class. * * @returns Parsed selector data with selector and styles. * @throws An error on invalid action pseudo-class usage. */ export declare const parseActionSelector: (rawSelector: string) => ParsedSelectorData; /** * Parses cropped selector part found before `{`. * * @param selectorBuffer Buffered selector to parse. * @param extCssDoc Needed for caching of selector ast. * * @returns Parsed validation data for cropped part of stylesheet which may be a selector. * @throws An error on unsupported CSS features, e.g. at-rules. */ export declare const parseSelectorRulePart: (selectorBuffer: string, extCssDoc: ExtCssDocument) => SelectorPartData; /** * Creates a map for storing raw results of css rules parsing. * Used for merging styles for same selector. * * @returns Map where **key** is `selector` * and **value** is object with `ast` and `styles`. */ export declare const createRawResultsMap: () => RawResults; /** * Saves rules data for unique selectors. * * @param rawResults Previously collected results of parsing. * @param rawRuleData Parsed rule data. * * @throws An error if there is no rawRuleData.styles or rawRuleData.ast. */ export declare const saveToRawResults: (rawResults: RawResults, rawRuleData: RawCssRuleData) => void; /** * Checks whether styles contain action pseudo-class declarations. * * @param styles Array of styles. * * @returns True if styles contain action pseudo-class declarations. */ export declare const hasActionPseudoStyles: (styles: StyleDeclaration[]) => boolean; /** * Filters styles declared together with an action pseudo-class: * such styles are ignored except `content` and `debug` needed for internal usage. * * @param styles Array of styles. * * @returns Styles which should be kept. */ export declare const filterActionRuleStyles: (styles: StyleDeclaration[]) => StyleDeclaration[]; /** * Removes action pseudo-class declarations from style block styles: * `remove-attr` and `remove-class` are supported only as pseudo-classes. * * @param styles Array of styles. * * @returns Styles without action pseudo-class declarations. */ export declare const filterStyleBlockActionDeclarations: (styles: StyleDeclaration[]) => StyleDeclaration[]; /** * Filters style-block declarations of a rule according to its selector: * if the selector contains an action pseudo-class, styles declared in the block * are ignored except `content` and `debug`; * otherwise action declarations (`remove-attr` and `remove-class`) * are removed as they are supported only as pseudo-classes. * * @param styles Parsed style-block declarations. * @param hasActionStyles True if the selector contains an action pseudo-class. * * @returns Styles which should be kept for the rule. */ export declare const filterStyleBlockDeclarations: (styles: StyleDeclaration[], hasActionStyles: boolean) => StyleDeclaration[]; /** * Data of rules with the same selector needed to prepare the final rule data. */ type RawMergedRuleData = { /** * String selector. */ selector: string; /** * Parsed selector ast. */ ast?: AnySelectorNodeInterface; /** * Raw styles of each parsed rule with the same selector. */ styleGroups?: RawStyleGroup[]; }; /** * Prepares final RuleData. * Handles `debug` and action pseudo-classes in raw rule data styles: * action declarations are moved to `actionStyles`, * regular styles of rules with the same selector are kept in `style`, * and `content` of action rules is kept in `style` only for `beforeStyleApplied`. * * @param rawRuleData Raw data of selector css rule parsing. * * @returns Parsed ExtendedCss rule data. * @throws An error if rawRuleData.ast or rawRuleData.styleGroups not defined. */ export declare const prepareRuleData: (rawRuleData: RawMergedRuleData) => ExtCssRuleData; /** * Combines previously parsed css rules data objects * into rules which are ready to apply. * * @param rawResults Previously parsed css rules data objects. * * @returns Parsed ExtendedCss rule data. */ export declare const combineRulesData: (rawResults: RawResults) => ExtCssRuleData[]; export {};