2023-08-17 09:47:40 +00:00
|
|
|
|
import { RawSourceMap, SourceMapGenerator } from 'source-map-js'
|
2022-01-21 08:28:41 +00:00
|
|
|
|
|
2023-08-17 09:47:40 +00:00
|
|
|
|
import AtRule, { AtRuleProps } from './at-rule.js'
|
|
|
|
|
import Comment, { CommentProps } from './comment.js'
|
|
|
|
|
import Container, { ContainerProps } from './container.js'
|
|
|
|
|
import CssSyntaxError from './css-syntax-error.js'
|
|
|
|
|
import Declaration, { DeclarationProps } from './declaration.js'
|
|
|
|
|
import Document, { DocumentProps } from './document.js'
|
|
|
|
|
import Input, { FilePosition } from './input.js'
|
|
|
|
|
import LazyResult from './lazy-result.js'
|
|
|
|
|
import list from './list.js'
|
|
|
|
|
import Node, {
|
|
|
|
|
AnyNode,
|
|
|
|
|
ChildNode,
|
|
|
|
|
ChildProps,
|
|
|
|
|
NodeErrorOptions,
|
|
|
|
|
NodeProps,
|
|
|
|
|
Position,
|
|
|
|
|
Source
|
|
|
|
|
} from './node.js'
|
|
|
|
|
import Processor from './processor.js'
|
|
|
|
|
import Result, { Message } from './result.js'
|
|
|
|
|
import Root, { RootProps } from './root.js'
|
|
|
|
|
import Rule, { RuleProps } from './rule.js'
|
|
|
|
|
import Warning, { WarningOptions } from './warning.js'
|
|
|
|
|
|
|
|
|
|
type DocumentProcessor = (
|
|
|
|
|
document: Document,
|
|
|
|
|
helper: postcss.Helpers
|
|
|
|
|
) => Promise<void> | void
|
|
|
|
|
type RootProcessor = (root: Root, helper: postcss.Helpers) => Promise<void> | void
|
|
|
|
|
type DeclarationProcessor = (
|
|
|
|
|
decl: Declaration,
|
|
|
|
|
helper: postcss.Helpers
|
|
|
|
|
) => Promise<void> | void
|
|
|
|
|
type RuleProcessor = (rule: Rule, helper: postcss.Helpers) => Promise<void> | void
|
|
|
|
|
type AtRuleProcessor = (atRule: AtRule, helper: postcss.Helpers) => Promise<void> | void
|
|
|
|
|
type CommentProcessor = (
|
|
|
|
|
comment: Comment,
|
|
|
|
|
helper: postcss.Helpers
|
|
|
|
|
) => Promise<void> | void
|
|
|
|
|
|
|
|
|
|
interface Processors {
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Will be called on all`AtRule` nodes.
|
|
|
|
|
*
|
|
|
|
|
* Will be called again on node or children changes.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
AtRule?: { [name: string]: AtRuleProcessor } | AtRuleProcessor
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Will be called on all `AtRule` nodes, when all children will be processed.
|
|
|
|
|
*
|
|
|
|
|
* Will be called again on node or children changes.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
AtRuleExit?: { [name: string]: AtRuleProcessor } | AtRuleProcessor
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Will be called on all `Comment` nodes.
|
|
|
|
|
*
|
|
|
|
|
* Will be called again on node or children changes.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
Comment?: CommentProcessor
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Will be called on all `Comment` nodes after listeners
|
|
|
|
|
* for `Comment` event.
|
|
|
|
|
*
|
|
|
|
|
* Will be called again on node or children changes.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
CommentExit?: CommentProcessor
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Will be called on all `Declaration` nodes after listeners
|
|
|
|
|
* for `Declaration` event.
|
|
|
|
|
*
|
|
|
|
|
* Will be called again on node or children changes.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
Declaration?: { [prop: string]: DeclarationProcessor } | DeclarationProcessor
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Will be called on all `Declaration` nodes.
|
|
|
|
|
*
|
|
|
|
|
* Will be called again on node or children changes.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
DeclarationExit?:
|
|
|
|
|
| { [prop: string]: DeclarationProcessor }
|
|
|
|
|
| DeclarationProcessor
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Will be called on `Document` node.
|
|
|
|
|
*
|
|
|
|
|
* Will be called again on children changes.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
Document?: DocumentProcessor
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Will be called on `Document` node, when all children will be processed.
|
|
|
|
|
*
|
|
|
|
|
* Will be called again on children changes.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
DocumentExit?: DocumentProcessor
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Will be called on `Root` node once.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
Once?: RootProcessor
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Will be called on `Root` node once, when all children will be processed.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
OnceExit?: RootProcessor
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Will be called on `Root` node.
|
|
|
|
|
*
|
|
|
|
|
* Will be called again on children changes.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
Root?: RootProcessor
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Will be called on `Root` node, when all children will be processed.
|
|
|
|
|
*
|
|
|
|
|
* Will be called again on children changes.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
RootExit?: RootProcessor
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Will be called on all `Rule` nodes.
|
|
|
|
|
*
|
|
|
|
|
* Will be called again on node or children changes.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
Rule?: RuleProcessor
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Will be called on all `Rule` nodes, when all children will be processed.
|
|
|
|
|
*
|
|
|
|
|
* Will be called again on node or children changes.
|
|
|
|
|
*/
|
|
|
|
|
RuleExit?: RuleProcessor
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
declare namespace postcss {
|
|
|
|
|
export {
|
|
|
|
|
AnyNode,
|
|
|
|
|
AtRule,
|
|
|
|
|
AtRuleProps,
|
|
|
|
|
ChildNode,
|
|
|
|
|
ChildProps,
|
|
|
|
|
Comment,
|
|
|
|
|
CommentProps,
|
|
|
|
|
Container,
|
|
|
|
|
ContainerProps,
|
|
|
|
|
CssSyntaxError,
|
|
|
|
|
Declaration,
|
|
|
|
|
DeclarationProps,
|
|
|
|
|
Document,
|
|
|
|
|
DocumentProps,
|
|
|
|
|
FilePosition,
|
|
|
|
|
Input,
|
|
|
|
|
LazyResult,
|
|
|
|
|
list,
|
|
|
|
|
Message,
|
|
|
|
|
Node,
|
|
|
|
|
NodeErrorOptions,
|
|
|
|
|
NodeProps,
|
|
|
|
|
Position,
|
|
|
|
|
Processor,
|
|
|
|
|
Result,
|
|
|
|
|
Root,
|
|
|
|
|
RootProps,
|
|
|
|
|
Rule,
|
|
|
|
|
RuleProps,
|
|
|
|
|
Source,
|
|
|
|
|
Warning,
|
|
|
|
|
WarningOptions
|
2022-01-21 08:28:41 +00:00
|
|
|
|
}
|
2023-08-17 09:47:40 +00:00
|
|
|
|
|
|
|
|
|
export type SourceMap = SourceMapGenerator & {
|
|
|
|
|
toJSON(): RawSourceMap
|
2022-01-21 08:28:41 +00:00
|
|
|
|
}
|
2023-08-17 09:47:40 +00:00
|
|
|
|
|
|
|
|
|
export type Helpers = { postcss: Postcss; result: Result } & Postcss
|
|
|
|
|
|
|
|
|
|
export interface Plugin extends Processors {
|
|
|
|
|
postcssPlugin: string
|
|
|
|
|
prepare?: (result: Result) => Processors
|
2022-01-21 08:28:41 +00:00
|
|
|
|
}
|
2023-08-17 09:47:40 +00:00
|
|
|
|
|
|
|
|
|
export interface PluginCreator<PluginOptions> {
|
|
|
|
|
(opts?: PluginOptions): Plugin | Processor
|
|
|
|
|
postcss: true
|
2022-01-21 08:28:41 +00:00
|
|
|
|
}
|
2023-08-17 09:47:40 +00:00
|
|
|
|
|
|
|
|
|
export interface Transformer extends TransformCallback {
|
|
|
|
|
postcssPlugin: string
|
|
|
|
|
postcssVersion: string
|
2022-01-21 08:28:41 +00:00
|
|
|
|
}
|
2023-08-17 09:47:40 +00:00
|
|
|
|
|
|
|
|
|
export interface TransformCallback {
|
|
|
|
|
(root: Root, result: Result): Promise<void> | void
|
2022-01-21 08:28:41 +00:00
|
|
|
|
}
|
2023-08-17 09:47:40 +00:00
|
|
|
|
|
|
|
|
|
export interface OldPlugin<T> extends Transformer {
|
|
|
|
|
(opts?: T): Transformer
|
|
|
|
|
postcss: Transformer
|
2022-01-21 08:28:41 +00:00
|
|
|
|
}
|
2023-08-17 09:47:40 +00:00
|
|
|
|
|
|
|
|
|
export type AcceptedPlugin =
|
|
|
|
|
| {
|
|
|
|
|
postcss: Processor | TransformCallback
|
|
|
|
|
}
|
|
|
|
|
| OldPlugin<any>
|
|
|
|
|
| Plugin
|
|
|
|
|
| PluginCreator<any>
|
|
|
|
|
| Processor
|
|
|
|
|
| TransformCallback
|
|
|
|
|
|
|
|
|
|
export interface Parser<RootNode = Document | Root> {
|
|
|
|
|
(
|
|
|
|
|
css: { toString(): string } | string,
|
|
|
|
|
opts?: Pick<ProcessOptions, 'from' | 'map'>
|
|
|
|
|
): RootNode
|
2022-01-21 08:28:41 +00:00
|
|
|
|
}
|
2023-08-17 09:47:40 +00:00
|
|
|
|
|
|
|
|
|
export interface Builder {
|
|
|
|
|
(part: string, node?: AnyNode, type?: 'end' | 'start'): void
|
2022-01-21 08:28:41 +00:00
|
|
|
|
}
|
2023-08-17 09:47:40 +00:00
|
|
|
|
|
|
|
|
|
export interface Stringifier {
|
|
|
|
|
(node: AnyNode, builder: Builder): void
|
2022-01-21 08:28:41 +00:00
|
|
|
|
}
|
2023-08-17 09:47:40 +00:00
|
|
|
|
|
|
|
|
|
export interface JSONHydrator {
|
|
|
|
|
(data: object): Node
|
|
|
|
|
(data: object[]): Node[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface Syntax<RootNode = Document | Root> {
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Function to generate AST by string.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
parse?: Parser<RootNode>
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Class to generate string by AST.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
stringify?: Stringifier
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface SourceMapOptions {
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Use absolute path in generated source map.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
absolute?: boolean
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Indicates that PostCSS should add annotation comments to the CSS.
|
|
|
|
|
* By default, PostCSS will always add a comment with a path
|
|
|
|
|
* to the source map. PostCSS will not add annotations to CSS files
|
|
|
|
|
* that do not contain any comments.
|
|
|
|
|
*
|
|
|
|
|
* By default, PostCSS presumes that you want to save the source map as
|
|
|
|
|
* `opts.to + '.map'` and will use this path in the annotation comment.
|
|
|
|
|
* A different path can be set by providing a string value for annotation.
|
|
|
|
|
*
|
|
|
|
|
* If you have set `inline: true`, annotation cannot be disabled.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
annotation?: ((file: string, root: Root) => string) | boolean | string
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Override `from` in map’s sources.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
from?: string
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Indicates that the source map should be embedded in the output CSS
|
|
|
|
|
* as a Base64-encoded comment. By default, it is `true`.
|
|
|
|
|
* But if all previous maps are external, not inline, PostCSS will not embed
|
|
|
|
|
* the map even if you do not set this option.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* If you have an inline source map, the result.map property will be empty,
|
|
|
|
|
* as the source map will be contained within the text of `result.css`.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
inline?: boolean
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Source map content from a previous processing step (e.g., Sass).
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* PostCSS will try to read the previous source map
|
|
|
|
|
* automatically (based on comments within the source CSS), but you can use
|
|
|
|
|
* this option to identify it manually.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* If desired, you can omit the previous map with prev: `false`.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
prev?: ((file: string) => string) | boolean | object | string
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Indicates that PostCSS should set the origin content (e.g., Sass source)
|
|
|
|
|
* of the source map. By default, it is true. But if all previous maps do not
|
|
|
|
|
* contain sources content, PostCSS will also leave it out even if you
|
|
|
|
|
* do not set this option.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
sourcesContent?: boolean
|
2022-01-21 08:28:41 +00:00
|
|
|
|
}
|
2023-08-17 09:47:40 +00:00
|
|
|
|
|
|
|
|
|
export interface ProcessOptions<RootNode = Document | Root> {
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* The path of the CSS source file. You should always set `from`,
|
|
|
|
|
* because it is used in source map generation and syntax error messages.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
from?: string
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Source map options
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
map?: boolean | SourceMapOptions
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Function to generate AST by string.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
parser?: Parser<RootNode> | Syntax<RootNode>
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Class to generate string by AST.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
stringifier?: Stringifier | Syntax<RootNode>
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Object with parse and stringify.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
syntax?: Syntax<RootNode>
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* The path where you'll put the output CSS file. You should always set `to`
|
|
|
|
|
* to generate correct source maps.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
to?: string
|
2022-01-21 08:28:41 +00:00
|
|
|
|
}
|
2023-08-17 09:47:40 +00:00
|
|
|
|
|
|
|
|
|
export type Postcss = typeof postcss
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Default function to convert a node tree into a CSS string.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
export let stringify: Stringifier
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Parses source css and returns a new `Root` or `Document` node,
|
|
|
|
|
* which contains the source CSS nodes.
|
|
|
|
|
*
|
|
|
|
|
* ```js
|
|
|
|
|
* // Simple CSS concatenation with source map support
|
|
|
|
|
* const root1 = postcss.parse(css1, { from: file1 })
|
|
|
|
|
* const root2 = postcss.parse(css2, { from: file2 })
|
|
|
|
|
* root1.append(root2).toResult().css
|
|
|
|
|
* ```
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
export let parse: Parser<Root>
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Rehydrate a JSON AST (from `Node#toJSON`) back into the AST classes.
|
|
|
|
|
*
|
|
|
|
|
* ```js
|
|
|
|
|
* const json = root.toJSON()
|
|
|
|
|
* // save to file, send by network, etc
|
|
|
|
|
* const root2 = postcss.fromJSON(json)
|
|
|
|
|
* ```
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
export let fromJSON: JSONHydrator
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Creates a new `Comment` node.
|
|
|
|
|
*
|
|
|
|
|
* @param defaults Properties for the new node.
|
|
|
|
|
* @return New comment node
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
export function comment(defaults?: CommentProps): Comment
|
|
|
|
|
|
2022-01-21 08:28:41 +00:00
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
|
* Creates a new `AtRule` node.
|
|
|
|
|
*
|
|
|
|
|
* @param defaults Properties for the new node.
|
|
|
|
|
* @return New at-rule node.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
|
export function atRule(defaults?: AtRuleProps): AtRule
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a new `Declaration` node.
|
|
|
|
|
*
|
|
|
|
|
* @param defaults Properties for the new node.
|
|
|
|
|
* @return New declaration node.
|
|
|
|
|
*/
|
|
|
|
|
export function decl(defaults?: DeclarationProps): Declaration
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a new `Rule` node.
|
|
|
|
|
*
|
|
|
|
|
* @param default Properties for the new node.
|
|
|
|
|
* @return New rule node.
|
|
|
|
|
*/
|
|
|
|
|
export function rule(defaults?: RuleProps): Rule
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a new `Root` node.
|
|
|
|
|
*
|
|
|
|
|
* @param defaults Properties for the new node.
|
|
|
|
|
* @return New root node.
|
|
|
|
|
*/
|
|
|
|
|
export function root(defaults?: RootProps): Root
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a new `Document` node.
|
|
|
|
|
*
|
|
|
|
|
* @param defaults Properties for the new node.
|
|
|
|
|
* @return New document node.
|
|
|
|
|
*/
|
|
|
|
|
export function document(defaults?: DocumentProps): Document
|
|
|
|
|
|
|
|
|
|
export { postcss as default }
|
2022-01-21 08:28:41 +00:00
|
|
|
|
}
|
2023-08-17 09:47:40 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new `Processor` instance that will apply `plugins`
|
|
|
|
|
* as CSS processors.
|
|
|
|
|
*
|
|
|
|
|
* ```js
|
|
|
|
|
* let postcss = require('postcss')
|
|
|
|
|
*
|
|
|
|
|
* postcss(plugins).process(css, { from, to }).then(result => {
|
|
|
|
|
* console.log(result.css)
|
|
|
|
|
* })
|
|
|
|
|
* ```
|
|
|
|
|
*
|
|
|
|
|
* @param plugins PostCSS plugins.
|
|
|
|
|
* @return Processor to process multiple CSS.
|
|
|
|
|
*/
|
|
|
|
|
declare function postcss(plugins?: postcss.AcceptedPlugin[]): Processor
|
|
|
|
|
declare function postcss(...plugins: postcss.AcceptedPlugin[]): Processor
|
|
|
|
|
|
|
|
|
|
export = postcss
|