lazy-result.d.ts 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import Processor from './processor';
  2. import * as postcss from './postcss';
  3. import Result from './result';
  4. import Root from './root';
  5. export default class LazyResult implements postcss.LazyResult {
  6. private stringified;
  7. private processed;
  8. private result;
  9. private error;
  10. private plugin;
  11. private processing;
  12. /**
  13. * A promise proxy for the result of PostCSS transformations.
  14. */
  15. constructor(processor: Processor,
  16. /**
  17. * String with input CSS or any object with toString() method, like a Buffer.
  18. * Optionally, send Result instance and the processor will take the existing
  19. * [Root] parser from it.
  20. */
  21. css: string | {
  22. toString(): string;
  23. } | LazyResult | Result, opts?: postcss.ProcessOptions);
  24. /**
  25. * @returns A processor used for CSS transformations.
  26. */
  27. processor: Processor;
  28. /**
  29. * @returns Options from the Processor#process(css, opts) call that produced
  30. * this Result instance.
  31. */
  32. opts: postcss.ResultOptions;
  33. /**
  34. * Processes input CSS through synchronous plugins and converts Root to a
  35. * CSS string. This property will only work with synchronous plugins. If
  36. * the processor contains any asynchronous plugins it will throw an error.
  37. * In this case, you should use LazyResult#then() instead.
  38. */
  39. css: string;
  40. /**
  41. * Alias for css property to use when syntaxes generate non-CSS output.
  42. */
  43. content: string;
  44. /**
  45. * Processes input CSS through synchronous plugins. This property will
  46. * only work with synchronous plugins. If the processor contains any
  47. * asynchronous plugins it will throw an error. In this case, you should
  48. * use LazyResult#then() instead.
  49. */
  50. map: postcss.ResultMap;
  51. /**
  52. * Processes input CSS through synchronous plugins. This property will only
  53. * work with synchronous plugins. If the processor contains any asynchronous
  54. * plugins it will throw an error. In this case, you should use
  55. * LazyResult#then() instead.
  56. */
  57. root: Root;
  58. /**
  59. * Processes input CSS through synchronous plugins. This property will only
  60. * work with synchronous plugins. If the processor contains any asynchronous
  61. * plugins it will throw an error. In this case, you should use
  62. * LazyResult#then() instead.
  63. */
  64. messages: postcss.ResultMessage[];
  65. /**
  66. * Processes input CSS through synchronous plugins and calls Result#warnings().
  67. * This property will only work with synchronous plugins. If the processor
  68. * contains any asynchronous plugins it will throw an error. In this case, you
  69. * You should use LazyResult#then() instead.
  70. */
  71. warnings(): postcss.ResultMessage[];
  72. /**
  73. * Alias for css property.
  74. */
  75. toString(): string;
  76. /**
  77. * Processes input CSS through synchronous and asynchronous plugins.
  78. * @param onRejected Called if any plugin throws an error.
  79. */
  80. then(onFulfilled: (result: Result) => void, onRejected?: (error: Error) => void): Function | any;
  81. /**
  82. * Processes input CSS through synchronous and asynchronous plugins.
  83. * @param onRejected Called if any plugin throws an error.
  84. */
  85. catch(onRejected: (error: Error) => void): Function | any;
  86. private handleError(error, plugin);
  87. private asyncTick(resolve, reject);
  88. private async();
  89. sync(): Result;
  90. private run(plugin);
  91. stringify(): Result;
  92. }