[d565449] | 1 | import Container, { ContainerProps } from './container.js'
|
---|
| 2 | import Document from './document.js'
|
---|
| 3 | import { ProcessOptions } from './postcss.js'
|
---|
| 4 | import Result from './result.js'
|
---|
| 5 |
|
---|
| 6 | declare namespace Root {
|
---|
| 7 | export interface RootRaws extends Record<string, any> {
|
---|
| 8 | /**
|
---|
| 9 | * The space symbols after the last child to the end of file.
|
---|
| 10 | */
|
---|
| 11 | after?: string
|
---|
| 12 |
|
---|
| 13 | /**
|
---|
| 14 | * Non-CSS code after `Root`, when `Root` is inside `Document`.
|
---|
| 15 | *
|
---|
| 16 | * **Experimental:** some aspects of this node could change within minor
|
---|
| 17 | * or patch version releases.
|
---|
| 18 | */
|
---|
| 19 | codeAfter?: string
|
---|
| 20 |
|
---|
| 21 | /**
|
---|
| 22 | * Non-CSS code before `Root`, when `Root` is inside `Document`.
|
---|
| 23 | *
|
---|
| 24 | * **Experimental:** some aspects of this node could change within minor
|
---|
| 25 | * or patch version releases.
|
---|
| 26 | */
|
---|
| 27 | codeBefore?: string
|
---|
| 28 |
|
---|
| 29 | /**
|
---|
| 30 | * Is the last child has an (optional) semicolon.
|
---|
| 31 | */
|
---|
| 32 | semicolon?: boolean
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | export interface RootProps extends ContainerProps {
|
---|
| 36 | /**
|
---|
| 37 | * Information used to generate byte-to-byte equal node string
|
---|
| 38 | * as it was in the origin input.
|
---|
| 39 | * */
|
---|
| 40 | raws?: RootRaws
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | // eslint-disable-next-line @typescript-eslint/no-use-before-define
|
---|
| 44 | export { Root_ as default }
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | /**
|
---|
| 48 | * Represents a CSS file and contains all its parsed nodes.
|
---|
| 49 | *
|
---|
| 50 | * ```js
|
---|
| 51 | * const root = postcss.parse('a{color:black} b{z-index:2}')
|
---|
| 52 | * root.type //=> 'root'
|
---|
| 53 | * root.nodes.length //=> 2
|
---|
| 54 | * ```
|
---|
| 55 | */
|
---|
| 56 | declare class Root_ extends Container {
|
---|
| 57 | nodes: NonNullable<Container['nodes']>
|
---|
| 58 | parent: Document | undefined
|
---|
| 59 | raws: Root.RootRaws
|
---|
| 60 | type: 'root'
|
---|
| 61 |
|
---|
| 62 | constructor(defaults?: Root.RootProps)
|
---|
| 63 |
|
---|
| 64 | assign(overrides: object | Root.RootProps): this
|
---|
[0c6b92a] | 65 | clone(overrides?: Partial<Root.RootProps>): this
|
---|
| 66 | cloneAfter(overrides?: Partial<Root.RootProps>): this
|
---|
| 67 | cloneBefore(overrides?: Partial<Root.RootProps>): this
|
---|
[d565449] | 68 |
|
---|
| 69 | /**
|
---|
| 70 | * Returns a `Result` instance representing the root’s CSS.
|
---|
| 71 | *
|
---|
| 72 | * ```js
|
---|
| 73 | * const root1 = postcss.parse(css1, { from: 'a.css' })
|
---|
| 74 | * const root2 = postcss.parse(css2, { from: 'b.css' })
|
---|
| 75 | * root1.append(root2)
|
---|
| 76 | * const result = root1.toResult({ to: 'all.css', map: true })
|
---|
| 77 | * ```
|
---|
| 78 | *
|
---|
[0c6b92a] | 79 | * @param options Options.
|
---|
[d565449] | 80 | * @return Result with current root’s CSS.
|
---|
| 81 | */
|
---|
| 82 | toResult(options?: ProcessOptions): Result
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | declare class Root extends Root_ {}
|
---|
| 86 |
|
---|
| 87 | export = Root
|
---|