import { type Rule, type AtRule, type Root } from 'postcss'; import { type ClassName } from 'postcss-selector-parser'; /** The pair of line number and column number. */ export type Position = { /** The line number in the source file. It is 1-based (compatible with postcss). */ line: number; /** The column number in the source file. It is 1-based (compatible with postcss). */ column: number; }; /** The original location of class selector. If the original location is not found, all fields are `undefined`. */ export type Location = { filePath: string; /** The inclusive starting position of the node's source (compatible with postcss). */ start: Position; /** The inclusive ending position of the node's source (compatible with postcss). */ end: Position; } | { filePath: undefined; start: undefined; end: undefined; }; /** * Traverses a local token from the AST and returns its name. * @param ast The AST to traverse. * @returns The name of the local token. */ export declare function generateLocalTokenNames(ast: Root): Promise; /** * Get the original location of the class selector. * @param rule The rule node that contains the token. * @param classSelector The class selector node that contains the token. * @returns The original location of the class selector. */ export declare function getOriginalLocationOfClassSelector(rule: Rule, classSelector: ClassName): Location; /** * Get the original location of `@value`. * @param atValue The `@value` rule. * @returns The location of the `@value` rule. */ export declare function getOriginalLocationOfAtValue(atValue: AtRule, valueDeclaration: ValueDeclaration): Location; type CollectNodesResult = { atImports: AtRule[]; atValues: AtRule[]; classSelectors: { rule: Rule; classSelector: ClassName; }[]; }; /** * Collect nodes from the AST. * @param ast The AST. */ export declare function collectNodes(ast: Root): CollectNodesResult; /** * Parse the `@import` rule. * @param atImport The `@import` rule to parse. * @returns The imported sheet path. */ export declare function parseAtImport(atImport: AtRule): string | undefined; type ValueDeclaration = { type: 'valueDeclaration'; tokenName: string; }; type ValueImportDeclaration = { type: 'valueImportDeclaration'; imports: { importedTokenName: string; localTokenName: string; }[]; from: string; }; type ParsedAtValue = ValueDeclaration | ValueImportDeclaration; /** * Parse the `@value` rule. * Forked from https://github.com/css-modules/postcss-modules-values/blob/v4.0.0/src/index.js. * * @license * ISC License (ISC) * Copyright (c) 2015, Glen Maddern * * Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, * provided that the above copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * THE USE OR PERFORMANCE OF THIS SOFTWARE. */ export declare function parseAtValue(atValue: AtRule): ParsedAtValue; export {};