@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,480 @@
1
+ import AtRule from './at-rule.js'
2
+ import Comment from './comment.js'
3
+ import Declaration from './declaration.js'
4
+ import Node, { ChildNode, ChildProps, NodeProps } from './node.js'
5
+ import Rule from './rule.js'
6
+
7
+ declare namespace Container {
8
+ export class ContainerWithChildren<
9
+ Child extends Node = ChildNode
10
+ > extends Container_<Child> {
11
+ nodes: Child[]
12
+ }
13
+
14
+ export interface ValueOptions {
15
+ /**
16
+ * String that’s used to narrow down values and speed up the regexp search.
17
+ */
18
+ fast?: string
19
+
20
+ /**
21
+ * An array of property names.
22
+ */
23
+ props?: readonly string[]
24
+ }
25
+
26
+ export interface ContainerProps extends NodeProps {
27
+ nodes?: readonly (ChildProps | Node)[]
28
+ }
29
+
30
+ /**
31
+ * All types that can be passed into container methods to create or add a new
32
+ * child node.
33
+ */
34
+ export type NewChild =
35
+ | ChildProps
36
+ | Node
37
+ | readonly ChildProps[]
38
+ | readonly Node[]
39
+ | readonly string[]
40
+ | string
41
+ | undefined
42
+
43
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
44
+ export { Container_ as default }
45
+ }
46
+
47
+ /**
48
+ * The `Root`, `AtRule`, and `Rule` container nodes
49
+ * inherit some common methods to help work with their children.
50
+ *
51
+ * Note that all containers can store any content. If you write a rule inside
52
+ * a rule, PostCSS will parse it.
53
+ */
54
+ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
55
+ /**
56
+ * An array containing the container’s children.
57
+ *
58
+ * ```js
59
+ * const root = postcss.parse('a { color: black }')
60
+ * root.nodes.length //=> 1
61
+ * root.nodes[0].selector //=> 'a'
62
+ * root.nodes[0].nodes[0].prop //=> 'color'
63
+ * ```
64
+ */
65
+ nodes: Child[] | undefined
66
+
67
+ /**
68
+ * The container’s first child.
69
+ *
70
+ * ```js
71
+ * rule.first === rules.nodes[0]
72
+ * ```
73
+ */
74
+ get first(): Child | undefined
75
+
76
+ /**
77
+ * The container’s last child.
78
+ *
79
+ * ```js
80
+ * rule.last === rule.nodes[rule.nodes.length - 1]
81
+ * ```
82
+ */
83
+ get last(): Child | undefined
84
+ /**
85
+ * Inserts new nodes to the end of the container.
86
+ *
87
+ * ```js
88
+ * const decl1 = new Declaration({ prop: 'color', value: 'black' })
89
+ * const decl2 = new Declaration({ prop: 'background-color', value: 'white' })
90
+ * rule.append(decl1, decl2)
91
+ *
92
+ * root.append({ name: 'charset', params: '"UTF-8"' }) // at-rule
93
+ * root.append({ selector: 'a' }) // rule
94
+ * rule.append({ prop: 'color', value: 'black' }) // declaration
95
+ * rule.append({ text: 'Comment' }) // comment
96
+ *
97
+ * root.append('a {}')
98
+ * root.first.append('color: black; z-index: 1')
99
+ * ```
100
+ *
101
+ * @param nodes New nodes.
102
+ * @return This node for methods chain.
103
+ */
104
+ append(...nodes: Container.NewChild[]): this
105
+ assign(overrides: Container.ContainerProps | object): this
106
+ clone(overrides?: Partial<Container.ContainerProps>): this
107
+
108
+ cloneAfter(overrides?: Partial<Container.ContainerProps>): this
109
+
110
+ cloneBefore(overrides?: Partial<Container.ContainerProps>): this
111
+ /**
112
+ * Iterates through the container’s immediate children,
113
+ * calling `callback` for each child.
114
+ *
115
+ * Returning `false` in the callback will break iteration.
116
+ *
117
+ * This method only iterates through the container’s immediate children.
118
+ * If you need to recursively iterate through all the container’s descendant
119
+ * nodes, use `Container#walk`.
120
+ *
121
+ * Unlike the for `{}`-cycle or `Array#forEach` this iterator is safe
122
+ * if you are mutating the array of child nodes during iteration.
123
+ * PostCSS will adjust the current index to match the mutations.
124
+ *
125
+ * ```js
126
+ * const root = postcss.parse('a { color: black; z-index: 1 }')
127
+ * const rule = root.first
128
+ *
129
+ * for (const decl of rule.nodes) {
130
+ * decl.cloneBefore({ prop: '-webkit-' + decl.prop })
131
+ * // Cycle will be infinite, because cloneBefore moves the current node
132
+ * // to the next index
133
+ * }
134
+ *
135
+ * rule.each(decl => {
136
+ * decl.cloneBefore({ prop: '-webkit-' + decl.prop })
137
+ * // Will be executed only for color and z-index
138
+ * })
139
+ * ```
140
+ *
141
+ * @param callback Iterator receives each node and index.
142
+ * @return Returns `false` if iteration was broke.
143
+ */
144
+ each(
145
+ callback: (node: Child, index: number) => false | void
146
+ ): false | undefined
147
+
148
+ /**
149
+ * Returns `true` if callback returns `true`
150
+ * for all of the container’s children.
151
+ *
152
+ * ```js
153
+ * const noPrefixes = rule.every(i => i.prop[0] !== '-')
154
+ * ```
155
+ *
156
+ * @param condition Iterator returns true or false.
157
+ * @return Is every child pass condition.
158
+ */
159
+ every(
160
+ condition: (node: Child, index: number, nodes: Child[]) => boolean
161
+ ): boolean
162
+ /**
163
+ * Returns a `child`’s index within the `Container#nodes` array.
164
+ *
165
+ * ```js
166
+ * rule.index( rule.nodes[2] ) //=> 2
167
+ * ```
168
+ *
169
+ * @param child Child of the current container.
170
+ * @return Child index.
171
+ */
172
+ index(child: Child | number): number
173
+
174
+ /**
175
+ * Insert new node after old node within the container.
176
+ *
177
+ * @param oldNode Child or child’s index.
178
+ * @param newNode New node.
179
+ * @return This node for methods chain.
180
+ */
181
+ insertAfter(oldNode: Child | number, newNode: Container.NewChild): this
182
+
183
+ /**
184
+ * Traverses the container’s descendant nodes, calling callback
185
+ * for each comment node.
186
+ *
187
+ * Like `Container#each`, this method is safe
188
+ * to use if you are mutating arrays during iteration.
189
+ *
190
+ * ```js
191
+ * root.walkComments(comment => {
192
+ * comment.remove()
193
+ * })
194
+ * ```
195
+ *
196
+ * @param callback Iterator receives each node and index.
197
+ * @return Returns `false` if iteration was broke.
198
+ */
199
+
200
+ /**
201
+ * Insert new node before old node within the container.
202
+ *
203
+ * ```js
204
+ * rule.insertBefore(decl, decl.clone({ prop: '-webkit-' + decl.prop }))
205
+ * ```
206
+ *
207
+ * @param oldNode Child or child’s index.
208
+ * @param newNode New node.
209
+ * @return This node for methods chain.
210
+ */
211
+ insertBefore(oldNode: Child | number, newNode: Container.NewChild): this
212
+ /**
213
+ * Inserts new nodes to the start of the container.
214
+ *
215
+ * ```js
216
+ * const decl1 = new Declaration({ prop: 'color', value: 'black' })
217
+ * const decl2 = new Declaration({ prop: 'background-color', value: 'white' })
218
+ * rule.prepend(decl1, decl2)
219
+ *
220
+ * root.append({ name: 'charset', params: '"UTF-8"' }) // at-rule
221
+ * root.append({ selector: 'a' }) // rule
222
+ * rule.append({ prop: 'color', value: 'black' }) // declaration
223
+ * rule.append({ text: 'Comment' }) // comment
224
+ *
225
+ * root.append('a {}')
226
+ * root.first.append('color: black; z-index: 1')
227
+ * ```
228
+ *
229
+ * @param nodes New nodes.
230
+ * @return This node for methods chain.
231
+ */
232
+ prepend(...nodes: Container.NewChild[]): this
233
+
234
+ /**
235
+ * Add child to the end of the node.
236
+ *
237
+ * ```js
238
+ * rule.push(new Declaration({ prop: 'color', value: 'black' }))
239
+ * ```
240
+ *
241
+ * @param child New node.
242
+ * @return This node for methods chain.
243
+ */
244
+ push(child: Child): this
245
+
246
+ /**
247
+ * Removes all children from the container
248
+ * and cleans their parent properties.
249
+ *
250
+ * ```js
251
+ * rule.removeAll()
252
+ * rule.nodes.length //=> 0
253
+ * ```
254
+ *
255
+ * @return This node for methods chain.
256
+ */
257
+ removeAll(): this
258
+
259
+ /**
260
+ * Removes node from the container and cleans the parent properties
261
+ * from the node and its children.
262
+ *
263
+ * ```js
264
+ * rule.nodes.length //=> 5
265
+ * rule.removeChild(decl)
266
+ * rule.nodes.length //=> 4
267
+ * decl.parent //=> undefined
268
+ * ```
269
+ *
270
+ * @param child Child or child’s index.
271
+ * @return This node for methods chain.
272
+ */
273
+ removeChild(child: Child | number): this
274
+
275
+ replaceValues(
276
+ pattern: RegExp | string,
277
+ replaced: { (substring: string, ...args: any[]): string } | string
278
+ ): this
279
+ /**
280
+ * Passes all declaration values within the container that match pattern
281
+ * through callback, replacing those values with the returned result
282
+ * of callback.
283
+ *
284
+ * This method is useful if you are using a custom unit or function
285
+ * and need to iterate through all values.
286
+ *
287
+ * ```js
288
+ * root.replaceValues(/\d+rem/, { fast: 'rem' }, string => {
289
+ * return 15 * parseInt(string) + 'px'
290
+ * })
291
+ * ```
292
+ *
293
+ * @param pattern Replace pattern.
294
+ * @param {object} options Options to speed up the search.
295
+ * @param replaced String to replace pattern or callback
296
+ * that returns a new value. The callback
297
+ * will receive the same arguments
298
+ * as those passed to a function parameter
299
+ * of `String#replace`.
300
+ * @return This node for methods chain.
301
+ */
302
+ replaceValues(
303
+ pattern: RegExp | string,
304
+ options: Container.ValueOptions,
305
+ replaced: { (substring: string, ...args: any[]): string } | string
306
+ ): this
307
+
308
+ /**
309
+ * Returns `true` if callback returns `true` for (at least) one
310
+ * of the container’s children.
311
+ *
312
+ * ```js
313
+ * const hasPrefix = rule.some(i => i.prop[0] === '-')
314
+ * ```
315
+ *
316
+ * @param condition Iterator returns true or false.
317
+ * @return Is some child pass condition.
318
+ */
319
+ some(
320
+ condition: (node: Child, index: number, nodes: Child[]) => boolean
321
+ ): boolean
322
+
323
+ /**
324
+ * Traverses the container’s descendant nodes, calling callback
325
+ * for each node.
326
+ *
327
+ * Like container.each(), this method is safe to use
328
+ * if you are mutating arrays during iteration.
329
+ *
330
+ * If you only need to iterate through the container’s immediate children,
331
+ * use `Container#each`.
332
+ *
333
+ * ```js
334
+ * root.walk(node => {
335
+ * // Traverses all descendant nodes.
336
+ * })
337
+ * ```
338
+ *
339
+ * @param callback Iterator receives each node and index.
340
+ * @return Returns `false` if iteration was broke.
341
+ */
342
+ walk(
343
+ callback: (node: ChildNode, index: number) => false | void
344
+ ): false | undefined
345
+
346
+ /**
347
+ * Traverses the container’s descendant nodes, calling callback
348
+ * for each at-rule node.
349
+ *
350
+ * If you pass a filter, iteration will only happen over at-rules
351
+ * that have matching names.
352
+ *
353
+ * Like `Container#each`, this method is safe
354
+ * to use if you are mutating arrays during iteration.
355
+ *
356
+ * ```js
357
+ * root.walkAtRules(rule => {
358
+ * if (isOld(rule.name)) rule.remove()
359
+ * })
360
+ *
361
+ * let first = false
362
+ * root.walkAtRules('charset', rule => {
363
+ * if (!first) {
364
+ * first = true
365
+ * } else {
366
+ * rule.remove()
367
+ * }
368
+ * })
369
+ * ```
370
+ *
371
+ * @param name String or regular expression to filter at-rules by name.
372
+ * @param callback Iterator receives each node and index.
373
+ * @return Returns `false` if iteration was broke.
374
+ */
375
+ walkAtRules(
376
+ nameFilter: RegExp | string,
377
+ callback: (atRule: AtRule, index: number) => false | void
378
+ ): false | undefined
379
+ walkAtRules(
380
+ callback: (atRule: AtRule, index: number) => false | void
381
+ ): false | undefined
382
+
383
+ walkComments(
384
+ callback: (comment: Comment, indexed: number) => false | void
385
+ ): false | undefined
386
+ walkComments(
387
+ callback: (comment: Comment, indexed: number) => false | void
388
+ ): false | undefined
389
+
390
+ /**
391
+ * Traverses the container’s descendant nodes, calling callback
392
+ * for each declaration node.
393
+ *
394
+ * If you pass a filter, iteration will only happen over declarations
395
+ * with matching properties.
396
+ *
397
+ * ```js
398
+ * root.walkDecls(decl => {
399
+ * checkPropertySupport(decl.prop)
400
+ * })
401
+ *
402
+ * root.walkDecls('border-radius', decl => {
403
+ * decl.remove()
404
+ * })
405
+ *
406
+ * root.walkDecls(/^background/, decl => {
407
+ * decl.value = takeFirstColorFromGradient(decl.value)
408
+ * })
409
+ * ```
410
+ *
411
+ * Like `Container#each`, this method is safe
412
+ * to use if you are mutating arrays during iteration.
413
+ *
414
+ * @param prop String or regular expression to filter declarations
415
+ * by property name.
416
+ * @param callback Iterator receives each node and index.
417
+ * @return Returns `false` if iteration was broke.
418
+ */
419
+ walkDecls(
420
+ propFilter: RegExp | string,
421
+ callback: (decl: Declaration, index: number) => false | void
422
+ ): false | undefined
423
+ walkDecls(
424
+ callback: (decl: Declaration, index: number) => false | void
425
+ ): false | undefined
426
+ /**
427
+ * Traverses the container’s descendant nodes, calling callback
428
+ * for each rule node.
429
+ *
430
+ * If you pass a filter, iteration will only happen over rules
431
+ * with matching selectors.
432
+ *
433
+ * Like `Container#each`, this method is safe
434
+ * to use if you are mutating arrays during iteration.
435
+ *
436
+ * ```js
437
+ * const selectors = []
438
+ * root.walkRules(rule => {
439
+ * selectors.push(rule.selector)
440
+ * })
441
+ * console.log(`Your CSS uses ${ selectors.length } selectors`)
442
+ * ```
443
+ *
444
+ * @param selector String or regular expression to filter rules by selector.
445
+ * @param callback Iterator receives each node and index.
446
+ * @return Returns `false` if iteration was broke.
447
+ */
448
+ walkRules(
449
+ selectorFilter: RegExp | string,
450
+ callback: (rule: Rule, index: number) => false | void
451
+ ): false | undefined
452
+ walkRules(
453
+ callback: (rule: Rule, index: number) => false | void
454
+ ): false | undefined
455
+ /**
456
+ * An internal method that converts a {@link NewChild} into a list of actual
457
+ * child nodes that can then be added to this container.
458
+ *
459
+ * This ensures that the nodes' parent is set to this container, that they use
460
+ * the correct prototype chain, and that they're marked as dirty.
461
+ *
462
+ * @param mnodes The new node or nodes to add.
463
+ * @param sample A node from whose raws the new node's `before` raw should be
464
+ * taken.
465
+ * @param type This should be set to `'prepend'` if the new nodes will be
466
+ * inserted at the beginning of the container.
467
+ * @hidden
468
+ */
469
+ protected normalize(
470
+ nodes: Container.NewChild,
471
+ sample: Node | undefined,
472
+ type?: 'prepend' | false
473
+ ): Child[]
474
+ }
475
+
476
+ declare class Container<
477
+ Child extends Node = ChildNode
478
+ > extends Container_<Child> {}
479
+
480
+ export = Container