1 | import Container, { ContainerProps } from './container.js'
|
---|
2 | import { ProcessOptions } from './postcss.js'
|
---|
3 | import Result from './result.js'
|
---|
4 | import Root from './root.js'
|
---|
5 |
|
---|
6 | declare namespace Document {
|
---|
7 | export interface DocumentProps extends ContainerProps {
|
---|
8 | nodes?: Root[]
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * Information to generate byte-to-byte equal node string as it was
|
---|
12 | * in the origin input.
|
---|
13 | *
|
---|
14 | * Every parser saves its own properties.
|
---|
15 | */
|
---|
16 | raws?: Record<string, any>
|
---|
17 | }
|
---|
18 |
|
---|
19 | // eslint-disable-next-line @typescript-eslint/no-use-before-define
|
---|
20 | export { Document_ as default }
|
---|
21 | }
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * Represents a file and contains all its parsed nodes.
|
---|
25 | *
|
---|
26 | * **Experimental:** some aspects of this node could change within minor
|
---|
27 | * or patch version releases.
|
---|
28 | *
|
---|
29 | * ```js
|
---|
30 | * const document = htmlParser(
|
---|
31 | * '<html><style>a{color:black}</style><style>b{z-index:2}</style>'
|
---|
32 | * )
|
---|
33 | * document.type //=> 'document'
|
---|
34 | * document.nodes.length //=> 2
|
---|
35 | * ```
|
---|
36 | */
|
---|
37 | declare class Document_ extends Container<Root> {
|
---|
38 | nodes: Root[]
|
---|
39 | parent: undefined
|
---|
40 | type: 'document'
|
---|
41 |
|
---|
42 | constructor(defaults?: Document.DocumentProps)
|
---|
43 |
|
---|
44 | assign(overrides: Document.DocumentProps | object): this
|
---|
45 | clone(overrides?: Partial<Document.DocumentProps>): Document
|
---|
46 | cloneAfter(overrides?: Partial<Document.DocumentProps>): Document
|
---|
47 | cloneBefore(overrides?: Partial<Document.DocumentProps>): Document
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * Returns a `Result` instance representing the document’s CSS roots.
|
---|
51 | *
|
---|
52 | * ```js
|
---|
53 | * const root1 = postcss.parse(css1, { from: 'a.css' })
|
---|
54 | * const root2 = postcss.parse(css2, { from: 'b.css' })
|
---|
55 | * const document = postcss.document()
|
---|
56 | * document.append(root1)
|
---|
57 | * document.append(root2)
|
---|
58 | * const result = document.toResult({ to: 'all.css', map: true })
|
---|
59 | * ```
|
---|
60 | *
|
---|
61 | * @param opts Options.
|
---|
62 | * @return Result with current document’s CSS.
|
---|
63 | */
|
---|
64 | toResult(options?: ProcessOptions): Result
|
---|
65 | }
|
---|
66 |
|
---|
67 | declare class Document extends Document_ {}
|
---|
68 |
|
---|
69 | export = Document
|
---|