source: imaps-frontend/node_modules/postcss/lib/input.d.ts

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

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