import type { StyleValue, CssProperty, StyleProperty } from "@webstudio-is/css-engine"; export type ParsedStyleDecl = { breakpoint?: string; selector: string; state?: string; property: CssProperty; value: StyleValue; }; export declare const hasUnsupportedCssTemplateRules: (source: string) => boolean; /** * Store prefixed properties without change * and convert to camel case only unprefixed properties * @todo stop converting to camel case and use hyphenated format */ export declare const camelCaseProperty: (property: CssProperty | StyleProperty) => StyleProperty; export type ParseCssResult = { styles: ParsedStyleDecl[]; errors: string[]; }; /** * Extract all CSS custom property (--*) declarations from a CSS string, * regardless of which selector rule they appear in. * Useful when CSS from multiple rules (e.g. Tailwind utility classes) needs * to be resolved together as if they apply to the same element. */ export declare const extractCssCustomProperties: (css: string) => Map; export declare const parseCss: (css: string, cssVars: Map) => ParseCssResult; export type ParsedClassSelector = { /** Token name: "card" for .card, "card__title" for .card .title */ tokenName: string; /** Target class names (the last segment): ["card"] or ["title"] */ classNames: string[]; /** * Non-class selector suffixes on the target: attribute selectors, pseudo-classes, pseudo-elements. * e.g. ["[disabled]"] for .btn[disabled], [":hover"] for .card:hover */ states?: string[]; /** * Ancestor constraints for nested selectors (e.g., .card .title). * Ordered from outermost to innermost ancestor. * Each entry's combinator describes the relationship to the next segment. */ ancestors?: Array<{ classNames: string[]; combinator: "descendant" | "child"; }>; }; /** * Parse a selector string and determine if it's a class-based selector * suitable for token extraction. Uses css-tree to handle the full CSS * selector spec. * * Supports simple selectors, compound selectors, and nested selectors * using descendant (" ") and child (">") combinators where ALL segments * are class-based. * * Supported patterns: * .card → { tokenName: "card", classNames: ["card"] } * .card.active → { tokenName: "card.active", classNames: ["card", "active"] } * .btn[disabled] → { tokenName: "btn", ..., states: ["[disabled]"] } * .card:hover → { tokenName: "card", ..., states: [":hover"] } * .card .title → { tokenName: "card__title", ..., ancestors: [{classNames:["card"], combinator:"descendant"}] } * .card > .title → { tokenName: "card__title", ..., ancestors: [{classNames:["card"], combinator:"child"}] } * .a .b .c → { tokenName: "a__b__c", ..., ancestors: [{..,"descendant"},{..,"descendant"}] } * .card > .title:hover → { tokenName: "card__title", ..., states: [":hover"], ancestors: [...] } * * Returns undefined for: * - Selectors with sibling combinators (+, ~) * - Selectors with non-class nodes in ancestor segments (e.g., .card h1, h1 .card) * - Pure element/id selectors */ export declare const parseClassBasedSelector: (selector: string) => ParsedClassSelector | undefined; type ParsedBreakpoint = { minWidth?: number; maxWidth?: number; condition?: string; }; export declare const parseMediaQuery: (mediaQuery: string) => undefined | ParsedBreakpoint; export {};