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