Node-Red configuration
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

result.d.ts 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. import {
  2. Document,
  3. Node,
  4. Plugin,
  5. ProcessOptions,
  6. Root,
  7. SourceMap,
  8. TransformCallback,
  9. Warning,
  10. WarningOptions
  11. } from './postcss.js'
  12. import Processor from './processor.js'
  13. declare namespace Result {
  14. export interface Message {
  15. [others: string]: any
  16. /**
  17. * Source PostCSS plugin name.
  18. */
  19. plugin?: string
  20. /**
  21. * Message type.
  22. */
  23. type: string
  24. }
  25. export interface ResultOptions extends ProcessOptions {
  26. /**
  27. * The CSS node that was the source of the warning.
  28. */
  29. node?: Node
  30. /**
  31. * Name of plugin that created this warning. `Result#warn` will fill it
  32. * automatically with `Plugin#postcssPlugin` value.
  33. */
  34. plugin?: string
  35. }
  36. // eslint-disable-next-line @typescript-eslint/no-use-before-define
  37. export { Result_ as default }
  38. }
  39. /**
  40. * Provides the result of the PostCSS transformations.
  41. *
  42. * A Result instance is returned by `LazyResult#then`
  43. * or `Root#toResult` methods.
  44. *
  45. * ```js
  46. * postcss([autoprefixer]).process(css).then(result => {
  47. * console.log(result.css)
  48. * })
  49. * ```
  50. *
  51. * ```js
  52. * const result2 = postcss.parse(css).toResult()
  53. * ```
  54. */
  55. declare class Result_<RootNode = Document | Root> {
  56. /**
  57. * A CSS string representing of `Result#root`.
  58. *
  59. * ```js
  60. * postcss.parse('a{}').toResult().css //=> "a{}"
  61. * ```
  62. */
  63. css: string
  64. /**
  65. * Last runned PostCSS plugin.
  66. */
  67. lastPlugin: Plugin | TransformCallback
  68. /**
  69. * An instance of `SourceMapGenerator` class from the `source-map` library,
  70. * representing changes to the `Result#root` instance.
  71. *
  72. * ```js
  73. * result.map.toJSON() //=> { version: 3, file: 'a.css', … }
  74. * ```
  75. *
  76. * ```js
  77. * if (result.map) {
  78. * fs.writeFileSync(result.opts.to + '.map', result.map.toString())
  79. * }
  80. * ```
  81. */
  82. map: SourceMap
  83. /**
  84. * Contains messages from plugins (e.g., warnings or custom messages).
  85. * Each message should have type and plugin properties.
  86. *
  87. * ```js
  88. * AtRule: {
  89. * import: (atRule, { result }) {
  90. * const importedFile = parseImport(atRule)
  91. * result.messages.push({
  92. * type: 'dependency',
  93. * plugin: 'postcss-import',
  94. * file: importedFile,
  95. * parent: result.opts.from
  96. * })
  97. * }
  98. * }
  99. * ```
  100. */
  101. messages: Result.Message[]
  102. /**
  103. * Options from the `Processor#process` or `Root#toResult` call
  104. * that produced this Result instance.]
  105. *
  106. * ```js
  107. * root.toResult(opts).opts === opts
  108. * ```
  109. */
  110. opts: Result.ResultOptions
  111. /**
  112. * The Processor instance used for this transformation.
  113. *
  114. * ```js
  115. * for (const plugin of result.processor.plugins) {
  116. * if (plugin.postcssPlugin === 'postcss-bad') {
  117. * throw 'postcss-good is incompatible with postcss-bad'
  118. * }
  119. * })
  120. * ```
  121. */
  122. processor: Processor
  123. /**
  124. * Root node after all transformations.
  125. *
  126. * ```js
  127. * root.toResult().root === root
  128. * ```
  129. */
  130. root: RootNode
  131. /**
  132. * @param processor Processor used for this transformation.
  133. * @param root Root node after all transformations.
  134. * @param opts Options from the `Processor#process` or `Root#toResult`.
  135. */
  136. constructor(processor: Processor, root: RootNode, opts: Result.ResultOptions)
  137. /**
  138. * Returns for `Result#css` content.
  139. *
  140. * ```js
  141. * result + '' === result.css
  142. * ```
  143. *
  144. * @return String representing of `Result#root`.
  145. */
  146. toString(): string
  147. /**
  148. * Creates an instance of `Warning` and adds it to `Result#messages`.
  149. *
  150. * ```js
  151. * if (decl.important) {
  152. * result.warn('Avoid !important', { node: decl, word: '!important' })
  153. * }
  154. * ```
  155. *
  156. * @param text Warning message.
  157. * @param opts Warning options.
  158. * @return Created warning.
  159. */
  160. warn(message: string, options?: WarningOptions): Warning
  161. /**
  162. * Returns warnings from plugins. Filters `Warning` instances
  163. * from `Result#messages`.
  164. *
  165. * ```js
  166. * result.warnings().forEach(warn => {
  167. * console.warn(warn.toString())
  168. * })
  169. * ```
  170. *
  171. * @return Warnings from plugins.
  172. */
  173. warnings(): Warning[]
  174. /**
  175. * An alias for the `Result#css` property.
  176. * Use it with syntaxes that generate non-CSS output.
  177. *
  178. * ```js
  179. * result.css === result.content
  180. * ```
  181. */
  182. get content(): string
  183. }
  184. declare class Result<RootNode = Document | Root> extends Result_<RootNode> {}
  185. export = Result