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

input.d.ts 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. import { CssSyntaxError, ProcessOptions } from './postcss.js'
  2. import PreviousMap from './previous-map.js'
  3. declare namespace Input {
  4. export interface FilePosition {
  5. /**
  6. * Column of inclusive start position in source file.
  7. */
  8. column: number
  9. /**
  10. * Column of exclusive end position in source file.
  11. */
  12. endColumn?: number
  13. /**
  14. * Line of exclusive end position in source file.
  15. */
  16. endLine?: number
  17. /**
  18. * Absolute path to the source file.
  19. */
  20. file?: string
  21. /**
  22. * Line of inclusive start position in source file.
  23. */
  24. line: number
  25. /**
  26. * Source code.
  27. */
  28. source?: string
  29. /**
  30. * URL for the source file.
  31. */
  32. url: string
  33. }
  34. // eslint-disable-next-line @typescript-eslint/no-use-before-define
  35. export { Input_ as default }
  36. }
  37. /**
  38. * Represents the source CSS.
  39. *
  40. * ```js
  41. * const root = postcss.parse(css, { from: file })
  42. * const input = root.source.input
  43. * ```
  44. */
  45. declare class Input_ {
  46. /**
  47. * Input CSS source.
  48. *
  49. * ```js
  50. * const input = postcss.parse('a{}', { from: file }).input
  51. * input.css //=> "a{}"
  52. * ```
  53. */
  54. css: string
  55. /**
  56. * The absolute path to the CSS source file defined
  57. * with the `from` option.
  58. *
  59. * ```js
  60. * const root = postcss.parse(css, { from: 'a.css' })
  61. * root.source.input.file //=> '/home/ai/a.css'
  62. * ```
  63. */
  64. file?: string
  65. /**
  66. * The flag to indicate whether or not the source code has Unicode BOM.
  67. */
  68. hasBOM: boolean
  69. /**
  70. * The unique ID of the CSS source. It will be created if `from` option
  71. * is not provided (because PostCSS does not know the file path).
  72. *
  73. * ```js
  74. * const root = postcss.parse(css)
  75. * root.source.input.file //=> undefined
  76. * root.source.input.id //=> "<input css 8LZeVF>"
  77. * ```
  78. */
  79. id?: string
  80. /**
  81. * The input source map passed from a compilation step before PostCSS
  82. * (for example, from Sass compiler).
  83. *
  84. * ```js
  85. * root.source.input.map.consumer().sources //=> ['a.sass']
  86. * ```
  87. */
  88. map: PreviousMap
  89. /**
  90. * @param css Input CSS source.
  91. * @param opts Process options.
  92. */
  93. constructor(css: string, opts?: ProcessOptions)
  94. error(
  95. message: string,
  96. start:
  97. | {
  98. column: number
  99. line: number
  100. }
  101. | {
  102. offset: number
  103. },
  104. end:
  105. | {
  106. column: number
  107. line: number
  108. }
  109. | {
  110. offset: number
  111. },
  112. opts?: { plugin?: CssSyntaxError['plugin'] }
  113. ): CssSyntaxError
  114. /**
  115. * Returns `CssSyntaxError` with information about the error and its position.
  116. */
  117. error(
  118. message: string,
  119. line: number,
  120. column: number,
  121. opts?: { plugin?: CssSyntaxError['plugin'] }
  122. ): CssSyntaxError
  123. error(
  124. message: string,
  125. offset: number,
  126. opts?: { plugin?: CssSyntaxError['plugin'] }
  127. ): CssSyntaxError
  128. /**
  129. * Converts source offset to line and column.
  130. *
  131. * @param offset Source offset.
  132. */
  133. fromOffset(offset: number): { col: number; line: number } | null
  134. /**
  135. * Reads the input source map and returns a symbol position
  136. * in the input source (e.g., in a Sass file that was compiled
  137. * to CSS before being passed to PostCSS). Optionally takes an
  138. * end position, exclusive.
  139. *
  140. * ```js
  141. * root.source.input.origin(1, 1) //=> { file: 'a.css', line: 3, column: 1 }
  142. * root.source.input.origin(1, 1, 1, 4)
  143. * //=> { file: 'a.css', line: 3, column: 1, endLine: 3, endColumn: 4 }
  144. * ```
  145. *
  146. * @param line Line for inclusive start position in input CSS.
  147. * @param column Column for inclusive start position in input CSS.
  148. * @param endLine Line for exclusive end position in input CSS.
  149. * @param endColumn Column for exclusive end position in input CSS.
  150. *
  151. * @return Position in input source.
  152. */
  153. origin(
  154. line: number,
  155. column: number,
  156. endLine?: number,
  157. endColumn?: number
  158. ): false | Input.FilePosition
  159. /**
  160. * The CSS source identifier. Contains `Input#file` if the user
  161. * set the `from` option, or `Input#id` if they did not.
  162. *
  163. * ```js
  164. * const root = postcss.parse(css, { from: 'a.css' })
  165. * root.source.input.from //=> "/home/ai/a.css"
  166. *
  167. * const root = postcss.parse(css)
  168. * root.source.input.from //=> "<input css 1>"
  169. * ```
  170. */
  171. get from(): string
  172. /** Converts this to a JSON-friendly object representation. */
  173. toJSON(): object
  174. }
  175. declare class Input extends Input_ {}
  176. export = Input