@rsbuild/core 1.3.4 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiled/chokidar/index.d.ts +2 -1
- package/compiled/css-loader/index.js +18 -18
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/http-proxy-middleware/index.d.ts +3 -2
- package/compiled/postcss/lib/at-rule.d.ts +140 -0
- package/compiled/postcss/lib/comment.d.ts +68 -0
- package/compiled/postcss/lib/container.d.ts +480 -0
- package/compiled/postcss/lib/css-syntax-error.d.ts +248 -0
- package/compiled/postcss/lib/declaration.d.ts +151 -0
- package/compiled/postcss/lib/document.d.ts +69 -0
- package/compiled/postcss/lib/fromJSON.d.ts +9 -0
- package/compiled/postcss/lib/input.d.ts +206 -0
- package/compiled/postcss/lib/lazy-result.d.ts +190 -0
- package/compiled/postcss/lib/list.d.ts +60 -0
- package/compiled/postcss/lib/no-work-result.d.ts +46 -0
- package/compiled/postcss/lib/node.d.ts +541 -0
- package/compiled/postcss/lib/parse.d.ts +9 -0
- package/compiled/postcss/lib/postcss.d.ts +458 -0
- package/compiled/postcss/lib/previous-map.d.ts +81 -0
- package/compiled/postcss/lib/processor.d.ts +115 -0
- package/compiled/postcss/lib/result.d.ts +205 -0
- package/compiled/postcss/lib/root.d.ts +87 -0
- package/compiled/postcss/lib/rule.d.ts +126 -0
- package/compiled/postcss/lib/stringifier.d.ts +46 -0
- package/compiled/postcss/lib/stringify.d.ts +9 -0
- package/compiled/postcss/lib/warning.d.ts +147 -0
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rslog/index.d.ts +2 -1
- package/compiled/rspack-chain/index.js +66 -66
- package/compiled/rspack-chain/package.json +1 -1
- package/compiled/rspack-chain/{index.d.ts → types/index.d.ts} +18 -2
- package/compiled/rspack-manifest-plugin/index.d.ts +2 -1
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/compiled/tinyglobby/index.d.ts +2 -1
- package/dist/index.cjs +92 -51
- package/dist/index.js +90 -50
- package/dist-types/configChain.d.ts +1 -1
- package/dist-types/helpers/exitHook.d.ts +3 -0
- package/dist-types/helpers/index.d.ts +1 -1
- package/dist-types/types/config.d.ts +2 -3
- package/dist-types/types/hooks.d.ts +6 -2
- package/dist-types/types/plugin.d.ts +1 -1
- package/dist-types/types/rspack.d.ts +1 -1
- package/dist-types/types/thirdParty.d.ts +2 -2
- package/package.json +6 -6
- package/types.d.ts +8 -8
- package/compiled/postcss/index.d.ts +0 -1
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { FilePosition } from './input.js'
|
|
2
|
+
|
|
3
|
+
declare namespace CssSyntaxError {
|
|
4
|
+
/**
|
|
5
|
+
* A position that is part of a range.
|
|
6
|
+
*/
|
|
7
|
+
export interface RangePosition {
|
|
8
|
+
/**
|
|
9
|
+
* The column number in the input.
|
|
10
|
+
*/
|
|
11
|
+
column: number
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The line number in the input.
|
|
15
|
+
*/
|
|
16
|
+
line: number
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
20
|
+
export { CssSyntaxError_ as default }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The CSS parser throws this error for broken CSS.
|
|
25
|
+
*
|
|
26
|
+
* Custom parsers can throw this error for broken custom syntax using
|
|
27
|
+
* the `Node#error` method.
|
|
28
|
+
*
|
|
29
|
+
* PostCSS will use the input source map to detect the original error location.
|
|
30
|
+
* If you wrote a Sass file, compiled it to CSS and then parsed it with PostCSS,
|
|
31
|
+
* PostCSS will show the original position in the Sass file.
|
|
32
|
+
*
|
|
33
|
+
* If you need the position in the PostCSS input
|
|
34
|
+
* (e.g., to debug the previous compiler), use `error.input.file`.
|
|
35
|
+
*
|
|
36
|
+
* ```js
|
|
37
|
+
* // Raising error from plugin
|
|
38
|
+
* throw node.error('Unknown variable', { plugin: 'postcss-vars' })
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* ```js
|
|
42
|
+
* // Catching and checking syntax error
|
|
43
|
+
* try {
|
|
44
|
+
* postcss.parse('a{')
|
|
45
|
+
* } catch (error) {
|
|
46
|
+
* if (error.name === 'CssSyntaxError') {
|
|
47
|
+
* error //=> CssSyntaxError
|
|
48
|
+
* }
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare class CssSyntaxError_ extends Error {
|
|
53
|
+
/**
|
|
54
|
+
* Source column of the error.
|
|
55
|
+
*
|
|
56
|
+
* ```js
|
|
57
|
+
* error.column //=> 1
|
|
58
|
+
* error.input.column //=> 4
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* PostCSS will use the input source map to detect the original location.
|
|
62
|
+
* If you need the position in the PostCSS input, use `error.input.column`.
|
|
63
|
+
*/
|
|
64
|
+
column?: number
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Source column of the error's end, exclusive. Provided if the error pertains
|
|
68
|
+
* to a range.
|
|
69
|
+
*
|
|
70
|
+
* ```js
|
|
71
|
+
* error.endColumn //=> 1
|
|
72
|
+
* error.input.endColumn //=> 4
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* PostCSS will use the input source map to detect the original location.
|
|
76
|
+
* If you need the position in the PostCSS input, use `error.input.endColumn`.
|
|
77
|
+
*/
|
|
78
|
+
endColumn?: number
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Source line of the error's end, exclusive. Provided if the error pertains
|
|
82
|
+
* to a range.
|
|
83
|
+
*
|
|
84
|
+
* ```js
|
|
85
|
+
* error.endLine //=> 3
|
|
86
|
+
* error.input.endLine //=> 4
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* PostCSS will use the input source map to detect the original location.
|
|
90
|
+
* If you need the position in the PostCSS input, use `error.input.endLine`.
|
|
91
|
+
*/
|
|
92
|
+
endLine?: number
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Absolute path to the broken file.
|
|
96
|
+
*
|
|
97
|
+
* ```js
|
|
98
|
+
* error.file //=> 'a.sass'
|
|
99
|
+
* error.input.file //=> 'a.css'
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* PostCSS will use the input source map to detect the original location.
|
|
103
|
+
* If you need the position in the PostCSS input, use `error.input.file`.
|
|
104
|
+
*/
|
|
105
|
+
file?: string
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Input object with PostCSS internal information
|
|
109
|
+
* about input file. If input has source map
|
|
110
|
+
* from previous tool, PostCSS will use origin
|
|
111
|
+
* (for example, Sass) source. You can use this
|
|
112
|
+
* object to get PostCSS input source.
|
|
113
|
+
*
|
|
114
|
+
* ```js
|
|
115
|
+
* error.input.file //=> 'a.css'
|
|
116
|
+
* error.file //=> 'a.sass'
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
input?: FilePosition
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Source line of the error.
|
|
123
|
+
*
|
|
124
|
+
* ```js
|
|
125
|
+
* error.line //=> 2
|
|
126
|
+
* error.input.line //=> 4
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* PostCSS will use the input source map to detect the original location.
|
|
130
|
+
* If you need the position in the PostCSS input, use `error.input.line`.
|
|
131
|
+
*/
|
|
132
|
+
line?: number
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Full error text in the GNU error format
|
|
136
|
+
* with plugin, file, line and column.
|
|
137
|
+
*
|
|
138
|
+
* ```js
|
|
139
|
+
* error.message //=> 'a.css:1:1: Unclosed block'
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
message: string
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Always equal to `'CssSyntaxError'`. You should always check error type
|
|
146
|
+
* by `error.name === 'CssSyntaxError'`
|
|
147
|
+
* instead of `error instanceof CssSyntaxError`,
|
|
148
|
+
* because npm could have several PostCSS versions.
|
|
149
|
+
*
|
|
150
|
+
* ```js
|
|
151
|
+
* if (error.name === 'CssSyntaxError') {
|
|
152
|
+
* error //=> CssSyntaxError
|
|
153
|
+
* }
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
name: 'CssSyntaxError'
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Plugin name, if error came from plugin.
|
|
160
|
+
*
|
|
161
|
+
* ```js
|
|
162
|
+
* error.plugin //=> 'postcss-vars'
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
plugin?: string
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Error message.
|
|
169
|
+
*
|
|
170
|
+
* ```js
|
|
171
|
+
* error.message //=> 'Unclosed block'
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
reason: string
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Source code of the broken file.
|
|
178
|
+
*
|
|
179
|
+
* ```js
|
|
180
|
+
* error.source //=> 'a { b {} }'
|
|
181
|
+
* error.input.source //=> 'a b { }'
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
source?: string
|
|
185
|
+
|
|
186
|
+
stack: string
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Instantiates a CSS syntax error. Can be instantiated for a single position
|
|
190
|
+
* or for a range.
|
|
191
|
+
* @param message Error message.
|
|
192
|
+
* @param lineOrStartPos If for a single position, the line number, or if for
|
|
193
|
+
* a range, the inclusive start position of the error.
|
|
194
|
+
* @param columnOrEndPos If for a single position, the column number, or if for
|
|
195
|
+
* a range, the exclusive end position of the error.
|
|
196
|
+
* @param source Source code of the broken file.
|
|
197
|
+
* @param file Absolute path to the broken file.
|
|
198
|
+
* @param plugin PostCSS plugin name, if error came from plugin.
|
|
199
|
+
*/
|
|
200
|
+
constructor(
|
|
201
|
+
message: string,
|
|
202
|
+
lineOrStartPos?: CssSyntaxError.RangePosition | number,
|
|
203
|
+
columnOrEndPos?: CssSyntaxError.RangePosition | number,
|
|
204
|
+
source?: string,
|
|
205
|
+
file?: string,
|
|
206
|
+
plugin?: string
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Returns a few lines of CSS source that caused the error.
|
|
211
|
+
*
|
|
212
|
+
* If the CSS has an input source map without `sourceContent`,
|
|
213
|
+
* this method will return an empty string.
|
|
214
|
+
*
|
|
215
|
+
* ```js
|
|
216
|
+
* error.showSourceCode() //=> " 4 | }
|
|
217
|
+
* // 5 | a {
|
|
218
|
+
* // > 6 | bad
|
|
219
|
+
* // | ^
|
|
220
|
+
* // 7 | }
|
|
221
|
+
* // 8 | b {"
|
|
222
|
+
* ```
|
|
223
|
+
*
|
|
224
|
+
* @param color Whether arrow will be colored red by terminal
|
|
225
|
+
* color codes. By default, PostCSS will detect
|
|
226
|
+
* color support by `process.stdout.isTTY`
|
|
227
|
+
* and `process.env.NODE_DISABLE_COLORS`.
|
|
228
|
+
* @return Few lines of CSS source that caused the error.
|
|
229
|
+
*/
|
|
230
|
+
showSourceCode(color?: boolean): string
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Returns error position, message and source code of the broken part.
|
|
234
|
+
*
|
|
235
|
+
* ```js
|
|
236
|
+
* error.toString() //=> "CssSyntaxError: app.css:1:1: Unclosed block
|
|
237
|
+
* // > 1 | a {
|
|
238
|
+
* // | ^"
|
|
239
|
+
* ```
|
|
240
|
+
*
|
|
241
|
+
* @return Error position, message and source code.
|
|
242
|
+
*/
|
|
243
|
+
toString(): string
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
declare class CssSyntaxError extends CssSyntaxError_ {}
|
|
247
|
+
|
|
248
|
+
export = CssSyntaxError
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { ContainerWithChildren } from './container.js'
|
|
2
|
+
import Node from './node.js'
|
|
3
|
+
|
|
4
|
+
declare namespace Declaration {
|
|
5
|
+
export interface DeclarationRaws extends Record<string, unknown> {
|
|
6
|
+
/**
|
|
7
|
+
* The space symbols before the node. It also stores `*`
|
|
8
|
+
* and `_` symbols before the declaration (IE hack).
|
|
9
|
+
*/
|
|
10
|
+
before?: string
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The symbols between the property and value for declarations.
|
|
14
|
+
*/
|
|
15
|
+
between?: string
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The content of the important statement, if it is not just `!important`.
|
|
19
|
+
*/
|
|
20
|
+
important?: string
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Declaration value with comments.
|
|
24
|
+
*/
|
|
25
|
+
value?: {
|
|
26
|
+
raw: string
|
|
27
|
+
value: string
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface DeclarationProps {
|
|
32
|
+
/** Whether the declaration has an `!important` annotation. */
|
|
33
|
+
important?: boolean
|
|
34
|
+
/** Name of the declaration. */
|
|
35
|
+
prop: string
|
|
36
|
+
/** Information used to generate byte-to-byte equal node string as it was in the origin input. */
|
|
37
|
+
raws?: DeclarationRaws
|
|
38
|
+
/** Value of the declaration. */
|
|
39
|
+
value: string
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
43
|
+
export { Declaration_ as default }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* It represents a class that handles
|
|
48
|
+
* [CSS declarations](https://developer.mozilla.org/en-US/docs/Web/CSS/Syntax#css_declarations)
|
|
49
|
+
*
|
|
50
|
+
* ```js
|
|
51
|
+
* Once (root, { Declaration }) {
|
|
52
|
+
* const color = new Declaration({ prop: 'color', value: 'black' })
|
|
53
|
+
* root.append(color)
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* ```js
|
|
58
|
+
* const root = postcss.parse('a { color: black }')
|
|
59
|
+
* const decl = root.first?.first
|
|
60
|
+
*
|
|
61
|
+
* decl.type //=> 'decl'
|
|
62
|
+
* decl.toString() //=> ' color: black'
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
declare class Declaration_ extends Node {
|
|
66
|
+
parent: ContainerWithChildren | undefined
|
|
67
|
+
raws: Declaration.DeclarationRaws
|
|
68
|
+
|
|
69
|
+
type: 'decl'
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* It represents a specificity of the declaration.
|
|
73
|
+
*
|
|
74
|
+
* If true, the CSS declaration will have an
|
|
75
|
+
* [important](https://developer.mozilla.org/en-US/docs/Web/CSS/important)
|
|
76
|
+
* specifier.
|
|
77
|
+
*
|
|
78
|
+
* ```js
|
|
79
|
+
* const root = postcss.parse('a { color: black !important; color: red }')
|
|
80
|
+
*
|
|
81
|
+
* root.first.first.important //=> true
|
|
82
|
+
* root.first.last.important //=> undefined
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
get important(): boolean
|
|
86
|
+
set important(value: boolean)
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The property name for a CSS declaration.
|
|
90
|
+
*
|
|
91
|
+
* ```js
|
|
92
|
+
* const root = postcss.parse('a { color: black }')
|
|
93
|
+
* const decl = root.first.first
|
|
94
|
+
*
|
|
95
|
+
* decl.prop //=> 'color'
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
get prop(): string
|
|
99
|
+
|
|
100
|
+
set prop(value: string)
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The property value for a CSS declaration.
|
|
104
|
+
*
|
|
105
|
+
* Any CSS comments inside the value string will be filtered out.
|
|
106
|
+
* CSS comments present in the source value will be available in
|
|
107
|
+
* the `raws` property.
|
|
108
|
+
*
|
|
109
|
+
* Assigning new `value` would ignore the comments in `raws`
|
|
110
|
+
* property while compiling node to string.
|
|
111
|
+
*
|
|
112
|
+
* ```js
|
|
113
|
+
* const root = postcss.parse('a { color: black }')
|
|
114
|
+
* const decl = root.first.first
|
|
115
|
+
*
|
|
116
|
+
* decl.value //=> 'black'
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
get value(): string
|
|
120
|
+
set value(value: string)
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* It represents a getter that returns `true` if a declaration starts with
|
|
124
|
+
* `--` or `$`, which are used to declare variables in CSS and SASS/SCSS.
|
|
125
|
+
*
|
|
126
|
+
* ```js
|
|
127
|
+
* const root = postcss.parse(':root { --one: 1 }')
|
|
128
|
+
* const one = root.first.first
|
|
129
|
+
*
|
|
130
|
+
* one.variable //=> true
|
|
131
|
+
* ```
|
|
132
|
+
*
|
|
133
|
+
* ```js
|
|
134
|
+
* const root = postcss.parse('$one: 1')
|
|
135
|
+
* const one = root.first
|
|
136
|
+
*
|
|
137
|
+
* one.variable //=> true
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
get variable(): boolean
|
|
141
|
+
constructor(defaults?: Declaration.DeclarationProps)
|
|
142
|
+
|
|
143
|
+
assign(overrides: Declaration.DeclarationProps | object): this
|
|
144
|
+
clone(overrides?: Partial<Declaration.DeclarationProps>): this
|
|
145
|
+
cloneAfter(overrides?: Partial<Declaration.DeclarationProps>): this
|
|
146
|
+
cloneBefore(overrides?: Partial<Declaration.DeclarationProps>): this
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
declare class Declaration extends Declaration_ {}
|
|
150
|
+
|
|
151
|
+
export = Declaration
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import Container, { ContainerProps } from './container.js'
|
|
2
|
+
import { ProcessOptions } from './postcss.js'
|
|
3
|
+
import Result from './result.js'
|
|
4
|
+
import Root from './root.js'
|
|
5
|
+
|
|
6
|
+
declare namespace Document {
|
|
7
|
+
export interface DocumentProps extends ContainerProps {
|
|
8
|
+
nodes?: readonly Root[]
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Information to generate byte-to-byte equal node string as it was
|
|
12
|
+
* in the origin input.
|
|
13
|
+
*
|
|
14
|
+
* Every parser saves its own properties.
|
|
15
|
+
*/
|
|
16
|
+
raws?: Record<string, any>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
20
|
+
export { Document_ as default }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Represents a file and contains all its parsed nodes.
|
|
25
|
+
*
|
|
26
|
+
* **Experimental:** some aspects of this node could change within minor
|
|
27
|
+
* or patch version releases.
|
|
28
|
+
*
|
|
29
|
+
* ```js
|
|
30
|
+
* const document = htmlParser(
|
|
31
|
+
* '<html><style>a{color:black}</style><style>b{z-index:2}</style>'
|
|
32
|
+
* )
|
|
33
|
+
* document.type //=> 'document'
|
|
34
|
+
* document.nodes.length //=> 2
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
declare class Document_ extends Container<Root> {
|
|
38
|
+
nodes: Root[]
|
|
39
|
+
parent: undefined
|
|
40
|
+
type: 'document'
|
|
41
|
+
|
|
42
|
+
constructor(defaults?: Document.DocumentProps)
|
|
43
|
+
|
|
44
|
+
assign(overrides: Document.DocumentProps | object): this
|
|
45
|
+
clone(overrides?: Partial<Document.DocumentProps>): this
|
|
46
|
+
cloneAfter(overrides?: Partial<Document.DocumentProps>): this
|
|
47
|
+
cloneBefore(overrides?: Partial<Document.DocumentProps>): this
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Returns a `Result` instance representing the document’s CSS roots.
|
|
51
|
+
*
|
|
52
|
+
* ```js
|
|
53
|
+
* const root1 = postcss.parse(css1, { from: 'a.css' })
|
|
54
|
+
* const root2 = postcss.parse(css2, { from: 'b.css' })
|
|
55
|
+
* const document = postcss.document()
|
|
56
|
+
* document.append(root1)
|
|
57
|
+
* document.append(root2)
|
|
58
|
+
* const result = document.toResult({ to: 'all.css', map: true })
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @param opts Options.
|
|
62
|
+
* @return Result with current document’s CSS.
|
|
63
|
+
*/
|
|
64
|
+
toResult(options?: ProcessOptions): Result
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
declare class Document extends Document_ {}
|
|
68
|
+
|
|
69
|
+
export = Document
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { CssSyntaxError, ProcessOptions } from './postcss.js'
|
|
2
|
+
import PreviousMap from './previous-map.js'
|
|
3
|
+
|
|
4
|
+
declare 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
|
+
*/
|
|
54
|
+
declare 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
|
+
* Input source with support for non-CSS documents.
|
|
67
|
+
*
|
|
68
|
+
* ```js
|
|
69
|
+
* const input = postcss.parse('a{}', { from: file, document: '<style>a {}</style>' }).input
|
|
70
|
+
* input.document //=> "<style>a {}</style>"
|
|
71
|
+
* input.css //=> "a{}"
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
document: string
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The absolute path to the CSS source file defined
|
|
78
|
+
* with the `from` option.
|
|
79
|
+
*
|
|
80
|
+
* ```js
|
|
81
|
+
* const root = postcss.parse(css, { from: 'a.css' })
|
|
82
|
+
* root.source.input.file //=> '/home/ai/a.css'
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
file?: string
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The flag to indicate whether or not the source code has Unicode BOM.
|
|
89
|
+
*/
|
|
90
|
+
hasBOM: boolean
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The unique ID of the CSS source. It will be created if `from` option
|
|
94
|
+
* is not provided (because PostCSS does not know the file path).
|
|
95
|
+
*
|
|
96
|
+
* ```js
|
|
97
|
+
* const root = postcss.parse(css)
|
|
98
|
+
* root.source.input.file //=> undefined
|
|
99
|
+
* root.source.input.id //=> "<input css 8LZeVF>"
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
id?: string
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The input source map passed from a compilation step before PostCSS
|
|
106
|
+
* (for example, from Sass compiler).
|
|
107
|
+
*
|
|
108
|
+
* ```js
|
|
109
|
+
* root.source.input.map.consumer().sources //=> ['a.sass']
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
map: PreviousMap
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The CSS source identifier. Contains `Input#file` if the user
|
|
116
|
+
* set the `from` option, or `Input#id` if they did not.
|
|
117
|
+
*
|
|
118
|
+
* ```js
|
|
119
|
+
* const root = postcss.parse(css, { from: 'a.css' })
|
|
120
|
+
* root.source.input.from //=> "/home/ai/a.css"
|
|
121
|
+
*
|
|
122
|
+
* const root = postcss.parse(css)
|
|
123
|
+
* root.source.input.from //=> "<input css 1>"
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
get from(): string
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @param css Input CSS source.
|
|
130
|
+
* @param opts Process options.
|
|
131
|
+
*/
|
|
132
|
+
constructor(css: string, opts?: ProcessOptions)
|
|
133
|
+
|
|
134
|
+
error(
|
|
135
|
+
message: string,
|
|
136
|
+
start:
|
|
137
|
+
| {
|
|
138
|
+
column: number
|
|
139
|
+
line: number
|
|
140
|
+
}
|
|
141
|
+
| {
|
|
142
|
+
offset: number
|
|
143
|
+
},
|
|
144
|
+
end:
|
|
145
|
+
| {
|
|
146
|
+
column: number
|
|
147
|
+
line: number
|
|
148
|
+
}
|
|
149
|
+
| {
|
|
150
|
+
offset: number
|
|
151
|
+
},
|
|
152
|
+
opts?: { plugin?: CssSyntaxError['plugin'] }
|
|
153
|
+
): CssSyntaxError
|
|
154
|
+
/**
|
|
155
|
+
* Returns `CssSyntaxError` with information about the error and its position.
|
|
156
|
+
*/
|
|
157
|
+
error(
|
|
158
|
+
message: string,
|
|
159
|
+
line: number,
|
|
160
|
+
column: number,
|
|
161
|
+
opts?: { plugin?: CssSyntaxError['plugin'] }
|
|
162
|
+
): CssSyntaxError
|
|
163
|
+
error(
|
|
164
|
+
message: string,
|
|
165
|
+
offset: number,
|
|
166
|
+
opts?: { plugin?: CssSyntaxError['plugin'] }
|
|
167
|
+
): CssSyntaxError
|
|
168
|
+
/**
|
|
169
|
+
* Converts source offset to line and column.
|
|
170
|
+
*
|
|
171
|
+
* @param offset Source offset.
|
|
172
|
+
*/
|
|
173
|
+
fromOffset(offset: number): { col: number; line: number } | null
|
|
174
|
+
/**
|
|
175
|
+
* Reads the input source map and returns a symbol position
|
|
176
|
+
* in the input source (e.g., in a Sass file that was compiled
|
|
177
|
+
* to CSS before being passed to PostCSS). Optionally takes an
|
|
178
|
+
* end position, exclusive.
|
|
179
|
+
*
|
|
180
|
+
* ```js
|
|
181
|
+
* root.source.input.origin(1, 1) //=> { file: 'a.css', line: 3, column: 1 }
|
|
182
|
+
* root.source.input.origin(1, 1, 1, 4)
|
|
183
|
+
* //=> { file: 'a.css', line: 3, column: 1, endLine: 3, endColumn: 4 }
|
|
184
|
+
* ```
|
|
185
|
+
*
|
|
186
|
+
* @param line Line for inclusive start position in input CSS.
|
|
187
|
+
* @param column Column for inclusive start position in input CSS.
|
|
188
|
+
* @param endLine Line for exclusive end position in input CSS.
|
|
189
|
+
* @param endColumn Column for exclusive end position in input CSS.
|
|
190
|
+
*
|
|
191
|
+
* @return Position in input source.
|
|
192
|
+
*/
|
|
193
|
+
origin(
|
|
194
|
+
line: number,
|
|
195
|
+
column: number,
|
|
196
|
+
endLine?: number,
|
|
197
|
+
endColumn?: number
|
|
198
|
+
): false | Input.FilePosition
|
|
199
|
+
|
|
200
|
+
/** Converts this to a JSON-friendly object representation. */
|
|
201
|
+
toJSON(): object
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
declare class Input extends Input_ {}
|
|
205
|
+
|
|
206
|
+
export = Input
|