UNPKG

cssnano

Version:

A modular CSS minifier, built on top of the PostCSS ecosystem.

104 lines • 4.29 kB
import { VendorPrefixSummary } from './vendorPrefixSummary.js'; import type { Declaration, Rule } from 'postcss'; export type RuleDeclarationKeys = { keys: number[]; keySet: Set<number>; }; export type RuleElementKeys = { /** * the distinct keys, in order of first appearance */ list: string[]; /** * the same keys, for membership tests */ seen: Set<string>; }; export type SelectorLookup = (selector: string) => import('./ensureCompatibility.js').SelectorInfo; /** * The selector list of a rule with what is derived from it. Every field is * set up front so all instances share one object layout. */ export declare class RuleMeta { #private; /** * @param {string[]} selectors * @param {Declaration[]} declarations */ constructor(selectors: string[], declarations: Declaration[]); /** @return {string[]} change it only through the methods of this class */ get selectors(): string[]; /** @return {Declaration[]} */ get declarations(): Declaration[]; /** @param {Declaration[]} declarations */ setDeclarations(declarations: Declaration[]): void; /** * Numbers the declarations so equal ones share a key. The numbering is * the caller's, and the keys last until the declarations change; adding * selectors leaves them valid. * * @param {(declaration: Declaration) => number} keyOf * @return {RuleDeclarationKeys} */ declarationKeys(keyOf: (declaration: Declaration) => number): RuleDeclarationKeys; /** * @param {SelectorLookup} lookup * @return {VendorPrefixSummary} */ vendorProfile(lookup: SelectorLookup): VendorPrefixSummary; /** * The elements the selector list can match, as `elementKeyOf` in * `elementKeys.js` describes them, or null when any selector has no key or * there are none, which must not read as a rule that writes to no element. * A caller must not hold the list across a change to the rule. * * @param {(selector: string) => string | null} [keyOf] the key of one selector * @return {string[] | null} */ elementKeys(keyOf?: (selector: string) => string | null): string[] | null; /** @return {string} */ selectorText(): string; /** * Lists of different lengths differ in text too, since a selector holds no * top-level comma, so the text of long lists is joined only when needed. * * @param {RuleMeta} other * @return {boolean} */ hasSameSelectors(other: RuleMeta): boolean; /** * @param {string[]} selectors appended to the rule's selector list * @param {SelectorLookup} lookup * @param {(selector: string) => string | null} [keyOf] * @return {readonly string[] | null} the element keys the selectors add to * those listed, or null when the rule's elements are not listed */ addSelectors(selectors: string[], lookup: SelectorLookup, keyOf?: (selector: string) => string | null): readonly string[] | null; /** * @param {string[]} selectors replaces the rule's selector list * @param {VendorPrefixSummary} [vendor] the profile of `selectors` when the caller * already knows it; otherwise it is derived on the next `vendorProfile` */ setSelectors(selectors: string[], vendor?: VendorPrefixSummary): void; /** * Takes the place of a rule that is dropped and stood before this one, so * its selectors come first. The dropped rule's list grows in place and * passes to this one, and the joined text is concatenated from the two * texts: copying or re-joining a long list on every merge would take * quadratic time. * * @param {RuleMeta} earlier left unusable * @param {SelectorLookup} lookup * @param {(selector: string) => string | null} [keyOf] */ absorbEarlier(earlier: RuleMeta, lookup: SelectorLookup, keyOf?: (selector: string) => string | null): void; } /** * @param {Rule} rule * @param {WeakMap<Rule, RuleMeta>} [ruleMeta] * @return {RuleMeta} */ export declare function getMeta(rule: Rule, ruleMeta?: WeakMap<Rule, RuleMeta>): RuleMeta; /** @param {Rule} rule @return {Declaration[]} */ export declare function getDecls(rule: Rule): Declaration[]; //# sourceMappingURL=ruleMeta.d.ts.map