UNPKG

1.37 kBTypeScriptView Raw
1import Container, { ContainerProps } from './container.js'
2import { ProcessOptions } from './postcss.js'
3import { ChildNode } from './node.js'
4import Declaration from './declaration.js'
5import Comment from './comment.js'
6import AtRule from './at-rule.js'
7import Result from './result.js'
8import Rule from './rule.js'
9
10interface RootRaws {
11 /**
12 * The space symbols after the last child to the end of file.
13 */
14 after?: string
15
16 /**
17 * Is the last child has an (optional) semicolon.
18 */
19 semicolon?: boolean
20}
21
22export interface RootProps extends ContainerProps {
23 raws?: RootRaws
24}
25
26/**
27 * Represents a CSS file and contains all its parsed nodes.
28 *
29 * ```js
30 * const root = postcss.parse('a{color:black} b{z-index:2}')
31 * root.type //=> 'root'
32 * root.nodes.length //=> 2
33 * ```
34 */
35export default class Root extends Container {
36 type: 'root'
37 parent: undefined
38 raws: RootRaws
39
40 constructor (defaults?: RootProps)
41
42 /**
43 * Returns a `Result` instance representing the root’s CSS.
44 *
45 * ```js
46 * const root1 = postcss.parse(css1, { from: 'a.css' })
47 * const root2 = postcss.parse(css2, { from: 'b.css' })
48 * root1.append(root2)
49 * const result = root1.toResult({ to: 'all.css', map: true })
50 * ```
51 *
52 * @param opts Options.
53 * @return Result with current root’s CSS.
54 */
55 toResult (options?: ProcessOptions): Result
56}