root.d.ts 2.1 KB

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