@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.
Files changed (48) hide show
  1. package/compiled/chokidar/index.d.ts +2 -1
  2. package/compiled/css-loader/index.js +18 -18
  3. package/compiled/html-rspack-plugin/index.js +14 -14
  4. package/compiled/http-proxy-middleware/index.d.ts +3 -2
  5. package/compiled/postcss/lib/at-rule.d.ts +140 -0
  6. package/compiled/postcss/lib/comment.d.ts +68 -0
  7. package/compiled/postcss/lib/container.d.ts +480 -0
  8. package/compiled/postcss/lib/css-syntax-error.d.ts +248 -0
  9. package/compiled/postcss/lib/declaration.d.ts +151 -0
  10. package/compiled/postcss/lib/document.d.ts +69 -0
  11. package/compiled/postcss/lib/fromJSON.d.ts +9 -0
  12. package/compiled/postcss/lib/input.d.ts +206 -0
  13. package/compiled/postcss/lib/lazy-result.d.ts +190 -0
  14. package/compiled/postcss/lib/list.d.ts +60 -0
  15. package/compiled/postcss/lib/no-work-result.d.ts +46 -0
  16. package/compiled/postcss/lib/node.d.ts +541 -0
  17. package/compiled/postcss/lib/parse.d.ts +9 -0
  18. package/compiled/postcss/lib/postcss.d.ts +458 -0
  19. package/compiled/postcss/lib/previous-map.d.ts +81 -0
  20. package/compiled/postcss/lib/processor.d.ts +115 -0
  21. package/compiled/postcss/lib/result.d.ts +205 -0
  22. package/compiled/postcss/lib/root.d.ts +87 -0
  23. package/compiled/postcss/lib/rule.d.ts +126 -0
  24. package/compiled/postcss/lib/stringifier.d.ts +46 -0
  25. package/compiled/postcss/lib/stringify.d.ts +9 -0
  26. package/compiled/postcss/lib/warning.d.ts +147 -0
  27. package/compiled/postcss/package.json +1 -1
  28. package/compiled/postcss-loader/index.js +6 -6
  29. package/compiled/rslog/index.d.ts +2 -1
  30. package/compiled/rspack-chain/index.js +66 -66
  31. package/compiled/rspack-chain/package.json +1 -1
  32. package/compiled/rspack-chain/{index.d.ts → types/index.d.ts} +18 -2
  33. package/compiled/rspack-manifest-plugin/index.d.ts +2 -1
  34. package/compiled/rspack-manifest-plugin/index.js +4 -4
  35. package/compiled/tinyglobby/index.d.ts +2 -1
  36. package/dist/index.cjs +92 -51
  37. package/dist/index.js +90 -50
  38. package/dist-types/configChain.d.ts +1 -1
  39. package/dist-types/helpers/exitHook.d.ts +3 -0
  40. package/dist-types/helpers/index.d.ts +1 -1
  41. package/dist-types/types/config.d.ts +2 -3
  42. package/dist-types/types/hooks.d.ts +6 -2
  43. package/dist-types/types/plugin.d.ts +1 -1
  44. package/dist-types/types/rspack.d.ts +1 -1
  45. package/dist-types/types/thirdParty.d.ts +2 -2
  46. package/package.json +6 -6
  47. package/types.d.ts +8 -8
  48. package/compiled/postcss/index.d.ts +0 -1
@@ -0,0 +1,541 @@
1
+ import AtRule = require('./at-rule.js')
2
+
3
+ import { AtRuleProps } from './at-rule.js'
4
+ import Comment, { CommentProps } from './comment.js'
5
+ import Container, { NewChild } from './container.js'
6
+ import CssSyntaxError from './css-syntax-error.js'
7
+ import Declaration, { DeclarationProps } from './declaration.js'
8
+ import Document from './document.js'
9
+ import Input from './input.js'
10
+ import { Stringifier, Syntax } from './postcss.js'
11
+ import Result from './result.js'
12
+ import Root from './root.js'
13
+ import Rule, { RuleProps } from './rule.js'
14
+ import Warning, { WarningOptions } from './warning.js'
15
+
16
+ declare namespace Node {
17
+ export type ChildNode = AtRule.default | Comment | Declaration | Rule
18
+
19
+ export type AnyNode =
20
+ | AtRule.default
21
+ | Comment
22
+ | Declaration
23
+ | Document
24
+ | Root
25
+ | Rule
26
+
27
+ export type ChildProps =
28
+ | AtRuleProps
29
+ | CommentProps
30
+ | DeclarationProps
31
+ | RuleProps
32
+
33
+ export interface Position {
34
+ /**
35
+ * Source line in file. In contrast to `offset` it starts from 1.
36
+ */
37
+ column: number
38
+
39
+ /**
40
+ * Source column in file.
41
+ */
42
+ line: number
43
+
44
+ /**
45
+ * Source offset in file. It starts from 0.
46
+ */
47
+ offset: number
48
+ }
49
+
50
+ export interface Range {
51
+ /**
52
+ * End position, exclusive.
53
+ */
54
+ end: Position
55
+
56
+ /**
57
+ * Start position, inclusive.
58
+ */
59
+ start: Position
60
+ }
61
+
62
+ /**
63
+ * Source represents an interface for the {@link Node.source} property.
64
+ */
65
+ export interface Source {
66
+ /**
67
+ * The inclusive ending position for the source
68
+ * code of a node.
69
+ */
70
+ end?: Position
71
+
72
+ /**
73
+ * The source file from where a node has originated.
74
+ */
75
+ input: Input
76
+
77
+ /**
78
+ * The inclusive starting position for the source
79
+ * code of a node.
80
+ */
81
+ start?: Position
82
+ }
83
+
84
+ /**
85
+ * Interface represents an interface for an object received
86
+ * as parameter by Node class constructor.
87
+ */
88
+ export interface NodeProps {
89
+ source?: Source
90
+ }
91
+
92
+ export interface NodeErrorOptions {
93
+ /**
94
+ * An ending index inside a node's string that should be highlighted as
95
+ * source of error.
96
+ */
97
+ endIndex?: number
98
+ /**
99
+ * An index inside a node's string that should be highlighted as source
100
+ * of error.
101
+ */
102
+ index?: number
103
+ /**
104
+ * Plugin name that created this error. PostCSS will set it automatically.
105
+ */
106
+ plugin?: string
107
+ /**
108
+ * A word inside a node's string, that should be highlighted as source
109
+ * of error.
110
+ */
111
+ word?: string
112
+ }
113
+
114
+ // eslint-disable-next-line @typescript-eslint/no-shadow
115
+ class Node extends Node_ {}
116
+ export { Node as default }
117
+ }
118
+
119
+ /**
120
+ * It represents an abstract class that handles common
121
+ * methods for other CSS abstract syntax tree nodes.
122
+ *
123
+ * Any node that represents CSS selector or value should
124
+ * not extend the `Node` class.
125
+ */
126
+ declare abstract class Node_ {
127
+ /**
128
+ * It represents parent of the current node.
129
+ *
130
+ * ```js
131
+ * root.nodes[0].parent === root //=> true
132
+ * ```
133
+ */
134
+ parent: Container | Document | undefined
135
+
136
+ /**
137
+ * It represents unnecessary whitespace and characters present
138
+ * in the css source code.
139
+ *
140
+ * Information to generate byte-to-byte equal node string as it was
141
+ * in the origin input.
142
+ *
143
+ * The properties of the raws object are decided by parser,
144
+ * the default parser uses the following properties:
145
+ *
146
+ * * `before`: the space symbols before the node. It also stores `*`
147
+ * and `_` symbols before the declaration (IE hack).
148
+ * * `after`: the space symbols after the last child of the node
149
+ * to the end of the node.
150
+ * * `between`: the symbols between the property and value
151
+ * for declarations, selector and `{` for rules, or last parameter
152
+ * and `{` for at-rules.
153
+ * * `semicolon`: contains true if the last child has
154
+ * an (optional) semicolon.
155
+ * * `afterName`: the space between the at-rule name and its parameters.
156
+ * * `left`: the space symbols between `/*` and the comment’s text.
157
+ * * `right`: the space symbols between the comment’s text
158
+ * and <code>*&#47;</code>.
159
+ * - `important`: the content of the important statement,
160
+ * if it is not just `!important`.
161
+ *
162
+ * PostCSS filters out the comments inside selectors, declaration values
163
+ * and at-rule parameters but it stores the origin content in raws.
164
+ *
165
+ * ```js
166
+ * const root = postcss.parse('a {\n color:black\n}')
167
+ * root.first.first.raws //=> { before: '\n ', between: ':' }
168
+ * ```
169
+ */
170
+ raws: any
171
+
172
+ /**
173
+ * It represents information related to origin of a node and is required
174
+ * for generating source maps.
175
+ *
176
+ * The nodes that are created manually using the public APIs
177
+ * provided by PostCSS will have `source` undefined and
178
+ * will be absent in the source map.
179
+ *
180
+ * For this reason, the plugin developer should consider
181
+ * duplicating nodes as the duplicate node will have the
182
+ * same source as the original node by default or assign
183
+ * source to a node created manually.
184
+ *
185
+ * ```js
186
+ * decl.source.input.from //=> '/home/ai/source.css'
187
+ * decl.source.start //=> { line: 10, column: 2 }
188
+ * decl.source.end //=> { line: 10, column: 12 }
189
+ * ```
190
+ *
191
+ * ```js
192
+ * // Incorrect method, source not specified!
193
+ * const prefixed = postcss.decl({
194
+ * prop: '-moz-' + decl.prop,
195
+ * value: decl.value
196
+ * })
197
+ *
198
+ * // Correct method, source is inherited when duplicating.
199
+ * const prefixed = decl.clone({
200
+ * prop: '-moz-' + decl.prop
201
+ * })
202
+ * ```
203
+ *
204
+ * ```js
205
+ * if (atrule.name === 'add-link') {
206
+ * const rule = postcss.rule({
207
+ * selector: 'a',
208
+ * source: atrule.source
209
+ * })
210
+ *
211
+ * atrule.parent.insertBefore(atrule, rule)
212
+ * }
213
+ * ```
214
+ */
215
+ source?: Node.Source
216
+
217
+ /**
218
+ * It represents type of a node in
219
+ * an abstract syntax tree.
220
+ *
221
+ * A type of node helps in identification of a node
222
+ * and perform operation based on it's type.
223
+ *
224
+ * ```js
225
+ * const declaration = new Declaration({
226
+ * prop: 'color',
227
+ * value: 'black'
228
+ * })
229
+ *
230
+ * declaration.type //=> 'decl'
231
+ * ```
232
+ */
233
+ type: string
234
+
235
+ constructor(defaults?: object)
236
+
237
+ /**
238
+ * Insert new node after current node to current node’s parent.
239
+ *
240
+ * Just alias for `node.parent.insertAfter(node, add)`.
241
+ *
242
+ * ```js
243
+ * decl.after('color: black')
244
+ * ```
245
+ *
246
+ * @param newNode New node.
247
+ * @return This node for methods chain.
248
+ */
249
+ after(
250
+ newNode: Node | Node.ChildProps | readonly Node[] | string | undefined
251
+ ): this
252
+
253
+ /**
254
+ * It assigns properties to an existing node instance.
255
+ *
256
+ * ```js
257
+ * decl.assign({ prop: 'word-wrap', value: 'break-word' })
258
+ * ```
259
+ *
260
+ * @param overrides New properties to override the node.
261
+ *
262
+ * @return `this` for method chaining.
263
+ */
264
+ assign(overrides: object): this
265
+
266
+ /**
267
+ * Insert new node before current node to current node’s parent.
268
+ *
269
+ * Just alias for `node.parent.insertBefore(node, add)`.
270
+ *
271
+ * ```js
272
+ * decl.before('content: ""')
273
+ * ```
274
+ *
275
+ * @param newNode New node.
276
+ * @return This node for methods chain.
277
+ */
278
+ before(
279
+ newNode: Node | Node.ChildProps | readonly Node[] | string | undefined
280
+ ): this
281
+
282
+ /**
283
+ * Clear the code style properties for the node and its children.
284
+ *
285
+ * ```js
286
+ * node.raws.before //=> ' '
287
+ * node.cleanRaws()
288
+ * node.raws.before //=> undefined
289
+ * ```
290
+ *
291
+ * @param keepBetween Keep the `raws.between` symbols.
292
+ */
293
+ cleanRaws(keepBetween?: boolean): void
294
+
295
+ /**
296
+ * It creates clone of an existing node, which includes all the properties
297
+ * and their values, that includes `raws` but not `type`.
298
+ *
299
+ * ```js
300
+ * decl.raws.before //=> "\n "
301
+ * const cloned = decl.clone({ prop: '-moz-' + decl.prop })
302
+ * cloned.raws.before //=> "\n "
303
+ * cloned.toString() //=> -moz-transform: scale(0)
304
+ * ```
305
+ *
306
+ * @param overrides New properties to override in the clone.
307
+ *
308
+ * @return Duplicate of the node instance.
309
+ */
310
+ clone(overrides?: object): this
311
+
312
+ /**
313
+ * Shortcut to clone the node and insert the resulting cloned node
314
+ * after the current node.
315
+ *
316
+ * @param overrides New properties to override in the clone.
317
+ * @return New node.
318
+ */
319
+ cloneAfter(overrides?: object): this
320
+
321
+ /**
322
+ * Shortcut to clone the node and insert the resulting cloned node
323
+ * before the current node.
324
+ *
325
+ * ```js
326
+ * decl.cloneBefore({ prop: '-moz-' + decl.prop })
327
+ * ```
328
+ *
329
+ * @param overrides Mew properties to override in the clone.
330
+ *
331
+ * @return New node
332
+ */
333
+ cloneBefore(overrides?: object): this
334
+
335
+ /**
336
+ * It creates an instance of the class `CssSyntaxError` and parameters passed
337
+ * to this method are assigned to the error instance.
338
+ *
339
+ * The error instance will have description for the
340
+ * error, original position of the node in the
341
+ * source, showing line and column number.
342
+ *
343
+ * If any previous map is present, it would be used
344
+ * to get original position of the source.
345
+ *
346
+ * The Previous Map here is referred to the source map
347
+ * generated by previous compilation, example: Less,
348
+ * Stylus and Sass.
349
+ *
350
+ * This method returns the error instance instead of
351
+ * throwing it.
352
+ *
353
+ * ```js
354
+ * if (!variables[name]) {
355
+ * throw decl.error(`Unknown variable ${name}`, { word: name })
356
+ * // CssSyntaxError: postcss-vars:a.sass:4:3: Unknown variable $black
357
+ * // color: $black
358
+ * // a
359
+ * // ^
360
+ * // background: white
361
+ * }
362
+ * ```
363
+ *
364
+ * @param message Description for the error instance.
365
+ * @param options Options for the error instance.
366
+ *
367
+ * @return Error instance is returned.
368
+ */
369
+ error(message: string, options?: Node.NodeErrorOptions): CssSyntaxError
370
+
371
+ /**
372
+ * Returns the next child of the node’s parent.
373
+ * Returns `undefined` if the current node is the last child.
374
+ *
375
+ * ```js
376
+ * if (comment.text === 'delete next') {
377
+ * const next = comment.next()
378
+ * if (next) {
379
+ * next.remove()
380
+ * }
381
+ * }
382
+ * ```
383
+ *
384
+ * @return Next node.
385
+ */
386
+ next(): Node.ChildNode | undefined
387
+
388
+ /**
389
+ * Get the position for a word or an index inside the node.
390
+ *
391
+ * @param opts Options.
392
+ * @return Position.
393
+ */
394
+ positionBy(opts?: Pick<WarningOptions, 'index' | 'word'>): Node.Position
395
+
396
+ /**
397
+ * Convert string index to line/column.
398
+ *
399
+ * @param index The symbol number in the node’s string.
400
+ * @return Symbol position in file.
401
+ */
402
+ positionInside(index: number): Node.Position
403
+
404
+ /**
405
+ * Returns the previous child of the node’s parent.
406
+ * Returns `undefined` if the current node is the first child.
407
+ *
408
+ * ```js
409
+ * const annotation = decl.prev()
410
+ * if (annotation.type === 'comment') {
411
+ * readAnnotation(annotation.text)
412
+ * }
413
+ * ```
414
+ *
415
+ * @return Previous node.
416
+ */
417
+ prev(): Node.ChildNode | undefined
418
+
419
+ /**
420
+ * Get the range for a word or start and end index inside the node.
421
+ * The start index is inclusive; the end index is exclusive.
422
+ *
423
+ * @param opts Options.
424
+ * @return Range.
425
+ */
426
+ rangeBy(
427
+ opts?: Pick<WarningOptions, 'endIndex' | 'index' | 'word'>
428
+ ): Node.Range
429
+
430
+ /**
431
+ * Returns a `raws` value. If the node is missing
432
+ * the code style property (because the node was manually built or cloned),
433
+ * PostCSS will try to autodetect the code style property by looking
434
+ * at other nodes in the tree.
435
+ *
436
+ * ```js
437
+ * const root = postcss.parse('a { background: white }')
438
+ * root.nodes[0].append({ prop: 'color', value: 'black' })
439
+ * root.nodes[0].nodes[1].raws.before //=> undefined
440
+ * root.nodes[0].nodes[1].raw('before') //=> ' '
441
+ * ```
442
+ *
443
+ * @param prop Name of code style property.
444
+ * @param defaultType Name of default value, it can be missed
445
+ * if the value is the same as prop.
446
+ * @return {string} Code style value.
447
+ */
448
+ raw(prop: string, defaultType?: string): string
449
+
450
+ /**
451
+ * It removes the node from its parent and deletes its parent property.
452
+ *
453
+ * ```js
454
+ * if (decl.prop.match(/^-webkit-/)) {
455
+ * decl.remove()
456
+ * }
457
+ * ```
458
+ *
459
+ * @return `this` for method chaining.
460
+ */
461
+ remove(): this
462
+
463
+ /**
464
+ * Inserts node(s) before the current node and removes the current node.
465
+ *
466
+ * ```js
467
+ * AtRule: {
468
+ * mixin: atrule => {
469
+ * atrule.replaceWith(mixinRules[atrule.params])
470
+ * }
471
+ * }
472
+ * ```
473
+ *
474
+ * @param nodes Mode(s) to replace current one.
475
+ * @return Current node to methods chain.
476
+ */
477
+ replaceWith(...nodes: NewChild[]): this
478
+
479
+ /**
480
+ * Finds the Root instance of the node’s tree.
481
+ *
482
+ * ```js
483
+ * root.nodes[0].nodes[0].root() === root
484
+ * ```
485
+ *
486
+ * @return Root parent.
487
+ */
488
+ root(): Root
489
+
490
+ /**
491
+ * Fix circular links on `JSON.stringify()`.
492
+ *
493
+ * @return Cleaned object.
494
+ */
495
+ toJSON(): object
496
+
497
+ /**
498
+ * It compiles the node to browser readable cascading style sheets string
499
+ * depending on it's type.
500
+ *
501
+ * ```js
502
+ * new Rule({ selector: 'a' }).toString() //=> "a {}"
503
+ * ```
504
+ *
505
+ * @param stringifier A syntax to use in string generation.
506
+ * @return CSS string of this node.
507
+ */
508
+ toString(stringifier?: Stringifier | Syntax): string
509
+
510
+ /**
511
+ * It is a wrapper for {@link Result#warn}, providing convenient
512
+ * way of generating warnings.
513
+ *
514
+ * ```js
515
+ * Declaration: {
516
+ * bad: (decl, { result }) => {
517
+ * decl.warn(result, 'Deprecated property: bad')
518
+ * }
519
+ * }
520
+ * ```
521
+ *
522
+ * @param result The `Result` instance that will receive the warning.
523
+ * @param message Description for the warning.
524
+ * @param options Options for the warning.
525
+ *
526
+ * @return `Warning` instance is returned
527
+ */
528
+ warn(result: Result, message: string, options?: WarningOptions): Warning
529
+
530
+ /**
531
+ * If this node isn't already dirty, marks it and its ancestors as such. This
532
+ * indicates to the LazyResult processor that the {@link Root} has been
533
+ * modified by the current plugin and may need to be processed again by other
534
+ * plugins.
535
+ */
536
+ protected markDirty(): void
537
+ }
538
+
539
+ declare class Node extends Node_ {}
540
+
541
+ export = Node
@@ -0,0 +1,9 @@
1
+ import { Parser } from './postcss.js'
2
+
3
+ interface Parse extends Parser {
4
+ default: Parse
5
+ }
6
+
7
+ declare const parse: Parse
8
+
9
+ export = parse