AK-21/Graphite-Industrial-Intelligence
0
1import { CssSyntaxError, ProcessOptions } from './postcss.js'2import PreviousMap from './previous-map.js'3 4declare namespace Input {5 export interface FilePosition {6 /**7 * Column of inclusive start position in source file.8 */9 column: number10 11 /**12 * Column of exclusive end position in source file.13 */14 endColumn?: number15 16 /**17 * Line of exclusive end position in source file.18 */19 endLine?: number20 21 /**22 * Offset of exclusive end position in source file.23 */24 endOffset?: number25 26 /**27 * Absolute path to the source file.28 */29 file?: string30 31 /**32 * Line of inclusive start position in source file.33 */34 line: number35 36 /**37 * Offset of inclusive start position in source file.38 */39 offset: number40 41 /**42 * Source code.43 */44 source?: string45 46 /**47 * URL for the source file.48 */49 url: string50 }51 52 export { Input_ as default }53}54 55/**56 * Represents the source CSS.57 *58 * ```js59 * const root = postcss.parse(css, { from: file })60 * const input = root.source.input61 * ```62 */63declare class Input_ {64 /**65 * Input CSS source.66 *67 * ```js68 * const input = postcss.parse('a{}', { from: file }).input69 * input.css //=> "a{}"70 * ```71 */72 css: string73 74 /**75 * Input source with support for non-CSS documents.76 *77 * ```js78 * const input = postcss.parse('a{}', { from: file, document: '<style>a {}</style>' }).input79 * input.document //=> "<style>a {}</style>"80 * input.css //=> "a{}"81 * ```82 */83 document: string84 85 /**86 * The absolute path to the CSS source file defined87 * with the `from` option.88 *89 * ```js90 * const root = postcss.parse(css, { from: 'a.css' })91 * root.source.input.file //=> '/home/ai/a.css'92 * ```93 */94 file?: string95 96 /**97 * The flag to indicate whether or not the source code has Unicode BOM.98 */99 hasBOM: boolean100 101 /**102 * The unique ID of the CSS source. It will be created if `from` option103 * is not provided (because PostCSS does not know the file path).104 *105 * ```js106 * const root = postcss.parse(css)107 * root.source.input.file //=> undefined108 * root.source.input.id //=> "<input css 8LZeVF>"109 * ```110 */111 id?: string112 113 /**114 * The input source map passed from a compilation step before PostCSS115 * (for example, from Sass compiler).116 *117 * ```js118 * root.source.input.map.consumer().sources //=> ['a.sass']119 * ```120 */121 map: PreviousMap122 123 /**124 * The CSS source identifier. Contains `Input#file` if the user125 * set the `from` option, or `Input#id` if they did not.126 *127 * ```js128 * const root = postcss.parse(css, { from: 'a.css' })129 * root.source.input.from //=> "/home/ai/a.css"130 *131 * const root = postcss.parse(css)132 * root.source.input.from //=> "<input css 1>"133 * ```134 */135 get from(): string136 137 /**138 * @param css Input CSS source.139 * @param opts Process options.140 */141 constructor(css: string, opts?: ProcessOptions)142 143 /**144 * Returns `CssSyntaxError` with information about the error and its position.145 */146 error(147 message: string,148 start:149 | {150 column: number151 line: number152 }153 | {154 offset: number155 },156 end:157 | {158 column: number159 line: number160 }161 | {162 offset: number163 },164 opts?: { plugin?: CssSyntaxError['plugin'] }165 ): CssSyntaxError166 error(167 message: string,168 line: number,169 column: number,170 opts?: { plugin?: CssSyntaxError['plugin'] }171 ): CssSyntaxError172 error(173 message: string,174 offset: number,175 opts?: { plugin?: CssSyntaxError['plugin'] }176 ): CssSyntaxError177 178 /**179 * Converts source line and column to offset.180 *181 * @param line Source line.182 * @param column Source column.183 * @return Source offset.184 */185 fromLineAndColumn(line: number, column: number): number186 187 /**188 * Converts source offset to line and column.189 *190 * @param offset Source offset.191 */192 fromOffset(offset: number): { col: number; line: number } | null193 194 /**195 * Reads the input source map and returns a symbol position196 * in the input source (e.g., in a Sass file that was compiled197 * to CSS before being passed to PostCSS). Optionally takes an198 * end position, exclusive.199 *200 * ```js201 * root.source.input.origin(1, 1) //=> { file: 'a.css', line: 3, column: 1 }202 * root.source.input.origin(1, 1, 1, 4)203 * //=> { file: 'a.css', line: 3, column: 1, endLine: 3, endColumn: 4 }204 * ```205 *206 * @param line Line for inclusive start position in input CSS.207 * @param column Column for inclusive start position in input CSS.208 * @param endLine Line for exclusive end position in input CSS.209 * @param endColumn Column for exclusive end position in input CSS.210 *211 * @return Position in input source.212 */213 origin(214 line: number,215 column: number,216 endLine?: number,217 endColumn?: number218 ): false | Input.FilePosition219 220 /** Converts this to a JSON-friendly object representation. */221 toJSON(): object222}223 224declare class Input extends Input_ {}225 226export = Input227 