postcss 8.4.20 → 8.4.22

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.

Potentially problematic release.


This version of postcss might be problematic. Click here for more details.

package/lib/at-rule.d.ts CHANGED
@@ -1,48 +1,53 @@
1
1
  import Container, { ContainerProps } from './container.js'
2
2
 
3
- interface AtRuleRaws extends Record<string, unknown> {
4
- /**
5
- * The space symbols before the node. It also stores `*`
6
- * and `_` symbols before the declaration (IE hack).
7
- */
8
- before?: string
3
+ declare namespace AtRule {
4
+ export interface AtRuleRaws extends Record<string, unknown> {
5
+ /**
6
+ * The space symbols before the node. It also stores `*`
7
+ * and `_` symbols before the declaration (IE hack).
8
+ */
9
+ before?: string
9
10
 
10
- /**
11
- * The space symbols after the last child of the node to the end of the node.
12
- */
13
- after?: string
11
+ /**
12
+ * The space symbols after the last child of the node to the end of the node.
13
+ */
14
+ after?: string
14
15
 
15
- /**
16
- * The space between the at-rule name and its parameters.
17
- */
18
- afterName?: string
16
+ /**
17
+ * The space between the at-rule name and its parameters.
18
+ */
19
+ afterName?: string
19
20
 
20
- /**
21
- * The symbols between the last parameter and `{` for rules.
22
- */
23
- between?: string
21
+ /**
22
+ * The symbols between the last parameter and `{` for rules.
23
+ */
24
+ between?: string
24
25
 
25
- /**
26
- * Contains `true` if the last child has an (optional) semicolon.
27
- */
28
- semicolon?: boolean
26
+ /**
27
+ * Contains `true` if the last child has an (optional) semicolon.
28
+ */
29
+ semicolon?: boolean
29
30
 
30
- /**
31
- * The rule’s selector with comments.
32
- */
33
- params?: {
34
- value: string
35
- raw: string
31
+ /**
32
+ * The rule’s selector with comments.
33
+ */
34
+ params?: {
35
+ value: string
36
+ raw: string
37
+ }
36
38
  }
37
- }
38
39
 
39
- export interface AtRuleProps extends ContainerProps {
40
- /** Name of the at-rule. */
41
- name: string
42
- /** Parameters following the name of the at-rule. */
43
- params?: string | number
44
- /** Information used to generate byte-to-byte equal node string as it was in the origin input. */
45
- raws?: AtRuleRaws
40
+ export interface AtRuleProps extends ContainerProps {
41
+ /** Name of the at-rule. */
42
+ name: string
43
+ /** Parameters following the name of the at-rule. */
44
+ params?: string | number
45
+ /** Information used to generate byte-to-byte equal node string as it was in the origin input. */
46
+ raws?: AtRuleRaws
47
+ }
48
+
49
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
50
+ export { AtRule_ as default }
46
51
  }
47
52
 
48
53
  /**
@@ -70,10 +75,10 @@ export interface AtRuleProps extends ContainerProps {
70
75
  * media.nodes //=> []
71
76
  * ```
72
77
  */
73
- export default class AtRule extends Container {
78
+ declare class AtRule_ extends Container {
74
79
  type: 'atrule'
75
80
  parent: Container | undefined
76
- raws: AtRuleRaws
81
+ raws: AtRule.AtRuleRaws
77
82
 
78
83
  /**
79
84
  * The at-rule’s name immediately follows the `@`.
@@ -98,9 +103,13 @@ export default class AtRule extends Container {
98
103
  */
99
104
  params: string
100
105
 
101
- constructor(defaults?: AtRuleProps)
102
- assign(overrides: object | AtRuleProps): this
103
- clone(overrides?: Partial<AtRuleProps>): this
104
- cloneBefore(overrides?: Partial<AtRuleProps>): this
105
- cloneAfter(overrides?: Partial<AtRuleProps>): this
106
+ constructor(defaults?: AtRule.AtRuleProps)
107
+ assign(overrides: object | AtRule.AtRuleProps): this
108
+ clone(overrides?: Partial<AtRule.AtRuleProps>): this
109
+ cloneBefore(overrides?: Partial<AtRule.AtRuleProps>): this
110
+ cloneAfter(overrides?: Partial<AtRule.AtRuleProps>): this
106
111
  }
112
+
113
+ declare class AtRule extends AtRule_ {}
114
+
115
+ export = AtRule
package/lib/comment.d.ts CHANGED
@@ -1,28 +1,33 @@
1
1
  import Container from './container.js'
2
2
  import Node, { NodeProps } from './node.js'
3
3
 
4
- interface CommentRaws extends Record<string, unknown> {
5
- /**
6
- * The space symbols before the node.
7
- */
8
- before?: string
4
+ declare namespace Comment {
5
+ export interface CommentRaws extends Record<string, unknown> {
6
+ /**
7
+ * The space symbols before the node.
8
+ */
9
+ before?: string
9
10
 
10
- /**
11
- * The space symbols between `/*` and the comment’s text.
12
- */
13
- left?: string
11
+ /**
12
+ * The space symbols between `/*` and the comment’s text.
13
+ */
14
+ left?: string
14
15
 
15
- /**
16
- * The space symbols between the comment’s text.
17
- */
18
- right?: string
19
- }
16
+ /**
17
+ * The space symbols between the comment’s text.
18
+ */
19
+ right?: string
20
+ }
20
21
 
21
- export interface CommentProps extends NodeProps {
22
- /** Content of the comment. */
23
- text: string
24
- /** Information used to generate byte-to-byte equal node string as it was in the origin input. */
25
- raws?: CommentRaws
22
+ export interface CommentProps extends NodeProps {
23
+ /** Content of the comment. */
24
+ text: string
25
+ /** Information used to generate byte-to-byte equal node string as it was in the origin input. */
26
+ raws?: CommentRaws
27
+ }
28
+
29
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
30
+ export { Comment_ as default }
26
31
  }
27
32
 
28
33
  /**
@@ -38,19 +43,23 @@ export interface CommentProps extends NodeProps {
38
43
  * Comments inside selectors, at-rule parameters, or declaration values
39
44
  * will be stored in the `raws` properties explained above.
40
45
  */
41
- export default class Comment extends Node {
46
+ declare class Comment_ extends Node {
42
47
  type: 'comment'
43
48
  parent: Container | undefined
44
- raws: CommentRaws
49
+ raws: Comment.CommentRaws
45
50
 
46
51
  /**
47
52
  * The comment's text.
48
53
  */
49
54
  text: string
50
55
 
51
- constructor(defaults?: CommentProps)
52
- assign(overrides: object | CommentProps): this
53
- clone(overrides?: Partial<CommentProps>): this
54
- cloneBefore(overrides?: Partial<CommentProps>): this
55
- cloneAfter(overrides?: Partial<CommentProps>): this
56
+ constructor(defaults?: Comment.CommentProps)
57
+ assign(overrides: object | Comment.CommentProps): this
58
+ clone(overrides?: Partial<Comment.CommentProps>): this
59
+ cloneBefore(overrides?: Partial<Comment.CommentProps>): this
60
+ cloneAfter(overrides?: Partial<Comment.CommentProps>): this
56
61
  }
62
+
63
+ declare class Comment extends Comment_ {}
64
+
65
+ export = Comment
@@ -4,20 +4,25 @@ import Comment from './comment.js'
4
4
  import AtRule from './at-rule.js'
5
5
  import Rule from './rule.js'
6
6
 
7
- interface ValueOptions {
8
- /**
9
- * An array of property names.
10
- */
11
- props?: string[]
7
+ declare namespace Container {
8
+ export interface ValueOptions {
9
+ /**
10
+ * An array of property names.
11
+ */
12
+ props?: string[]
12
13
 
13
- /**
14
- * String that’s used to narrow down values and speed up the regexp search.
15
- */
16
- fast?: string
17
- }
14
+ /**
15
+ * String that’s used to narrow down values and speed up the regexp search.
16
+ */
17
+ fast?: string
18
+ }
19
+
20
+ export interface ContainerProps extends NodeProps {
21
+ nodes?: (ChildNode | ChildProps)[]
22
+ }
18
23
 
19
- export interface ContainerProps extends NodeProps {
20
- nodes?: (ChildNode | ChildProps)[]
24
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
25
+ export { Container_ as default }
21
26
  }
22
27
 
23
28
  /**
@@ -27,7 +32,7 @@ export interface ContainerProps extends NodeProps {
27
32
  * Note that all containers can store any content. If you write a rule inside
28
33
  * a rule, PostCSS will parse it.
29
34
  */
30
- export default abstract class Container<
35
+ declare abstract class Container_<
31
36
  Child extends Node = ChildNode
32
37
  > extends Node {
33
38
  /**
@@ -390,7 +395,7 @@ export default abstract class Container<
390
395
  */
391
396
  replaceValues(
392
397
  pattern: string | RegExp,
393
- options: ValueOptions,
398
+ options: Container.ValueOptions,
394
399
  replaced: string | { (substring: string, ...args: any[]): string }
395
400
  ): this
396
401
  replaceValues(
@@ -440,3 +445,7 @@ export default abstract class Container<
440
445
  */
441
446
  index(child: Child | number): number
442
447
  }
448
+
449
+ declare class Container<Child extends Node = ChildNode> extends Container_<Child> {}
450
+
451
+ export = Container
@@ -1,18 +1,23 @@
1
1
  import { FilePosition } from './input.js'
2
2
 
3
- /**
4
- * A position that is part of a range.
5
- */
6
- export interface RangePosition {
3
+ declare namespace CssSyntaxError {
7
4
  /**
8
- * The line number in the input.
5
+ * A position that is part of a range.
9
6
  */
10
- line: number
7
+ export interface RangePosition {
8
+ /**
9
+ * The line number in the input.
10
+ */
11
+ line: number
11
12
 
12
- /**
13
- * The column number in the input.
14
- */
15
- column: number
13
+ /**
14
+ * The column number in the input.
15
+ */
16
+ column: number
17
+ }
18
+
19
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
20
+ export { CssSyntaxError_ as default }
16
21
  }
17
22
 
18
23
  /**
@@ -44,7 +49,7 @@ export interface RangePosition {
44
49
  * }
45
50
  * ```
46
51
  */
47
- export default class CssSyntaxError {
52
+ declare class CssSyntaxError_ {
48
53
  /**
49
54
  * Instantiates a CSS syntax error. Can be instantiated for a single position
50
55
  * or for a range.
@@ -59,8 +64,8 @@ export default class CssSyntaxError {
59
64
  */
60
65
  constructor(
61
66
  message: string,
62
- lineOrStartPos?: number | RangePosition,
63
- columnOrEndPos?: number | RangePosition,
67
+ lineOrStartPos?: number | CssSyntaxError.RangePosition,
68
+ columnOrEndPos?: number | CssSyntaxError.RangePosition,
64
69
  source?: string,
65
70
  file?: string,
66
71
  plugin?: string
@@ -237,3 +242,7 @@ export default class CssSyntaxError {
237
242
  */
238
243
  showSourceCode(color?: boolean): string
239
244
  }
245
+
246
+ declare class CssSyntaxError extends CssSyntaxError_ {}
247
+
248
+ export = CssSyntaxError
@@ -1,41 +1,46 @@
1
1
  import Container from './container.js'
2
2
  import Node from './node.js'
3
3
 
4
- interface DeclarationRaws extends Record<string, unknown> {
5
- /**
6
- * The space symbols before the node. It also stores `*`
7
- * and `_` symbols before the declaration (IE hack).
8
- */
9
- before?: string
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
10
11
 
11
- /**
12
- * The symbols between the property and value for declarations.
13
- */
14
- between?: string
12
+ /**
13
+ * The symbols between the property and value for declarations.
14
+ */
15
+ between?: string
15
16
 
16
- /**
17
- * The content of the important statement, if it is not just `!important`.
18
- */
19
- important?: string
17
+ /**
18
+ * The content of the important statement, if it is not just `!important`.
19
+ */
20
+ important?: string
20
21
 
21
- /**
22
- * Declaration value with comments.
23
- */
24
- value?: {
22
+ /**
23
+ * Declaration value with comments.
24
+ */
25
+ value?: {
26
+ value: string
27
+ raw: string
28
+ }
29
+ }
30
+
31
+ export interface DeclarationProps {
32
+ /** Name of the declaration. */
33
+ prop: string
34
+ /** Value of the declaration. */
25
35
  value: string
26
- raw: string
36
+ /** Whether the declaration has an `!important` annotation. */
37
+ important?: boolean
38
+ /** Information used to generate byte-to-byte equal node string as it was in the origin input. */
39
+ raws?: DeclarationRaws
27
40
  }
28
- }
29
41
 
30
- export interface DeclarationProps {
31
- /** Name of the declaration. */
32
- prop: string
33
- /** Value of the declaration. */
34
- value: string
35
- /** Whether the declaration has an `!important` annotation. */
36
- important?: boolean
37
- /** Information used to generate byte-to-byte equal node string as it was in the origin input. */
38
- raws?: DeclarationRaws
42
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
43
+ export { Declaration_ as default }
39
44
  }
40
45
 
41
46
  /**
@@ -55,10 +60,10 @@ export interface DeclarationProps {
55
60
  * decl.toString() //=> ' color: black'
56
61
  * ```
57
62
  */
58
- export default class Declaration extends Node {
63
+ declare class Declaration_ extends Node {
59
64
  type: 'decl'
60
65
  parent: Container | undefined
61
- raws: DeclarationRaws
66
+ raws: Declaration.DeclarationRaws
62
67
 
63
68
  /**
64
69
  * The declaration's property name.
@@ -116,9 +121,13 @@ export default class Declaration extends Node {
116
121
  */
117
122
  variable: boolean
118
123
 
119
- constructor(defaults?: DeclarationProps)
120
- assign(overrides: object | DeclarationProps): this
121
- clone(overrides?: Partial<DeclarationProps>): this
122
- cloneBefore(overrides?: Partial<DeclarationProps>): this
123
- cloneAfter(overrides?: Partial<DeclarationProps>): this
124
+ constructor(defaults?: Declaration.DeclarationProps)
125
+ assign(overrides: object | Declaration.DeclarationProps): this
126
+ clone(overrides?: Partial<Declaration.DeclarationProps>): this
127
+ cloneBefore(overrides?: Partial<Declaration.DeclarationProps>): this
128
+ cloneAfter(overrides?: Partial<Declaration.DeclarationProps>): this
124
129
  }
130
+
131
+ declare class Declaration extends Declaration_ {}
132
+
133
+ export = Declaration
package/lib/document.d.ts CHANGED
@@ -1,22 +1,24 @@
1
1
  import Container, { ContainerProps } from './container.js'
2
2
  import { ProcessOptions } from './postcss.js'
3
3
  import Result from './result.js'
4
- import Root, { RootProps } from './root.js'
4
+ import Root from './root.js'
5
5
 
6
- export interface DocumentProps extends ContainerProps {
7
- nodes?: Root[]
6
+ declare namespace Document {
7
+ export interface DocumentProps extends ContainerProps {
8
+ nodes?: Root[]
8
9
 
9
- /**
10
- * Information to generate byte-to-byte equal node string as it was
11
- * in the origin input.
12
- *
13
- * Every parser saves its own properties.
14
- */
15
- raws?: Record<string, any>
16
- }
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
+ }
17
18
 
18
- type ChildNode = Root
19
- type ChildProps = RootProps
19
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
20
+ export { Document_ as default }
21
+ }
20
22
 
21
23
  /**
22
24
  * Represents a file and contains all its parsed nodes.
@@ -32,11 +34,11 @@ type ChildProps = RootProps
32
34
  * document.nodes.length //=> 2
33
35
  * ```
34
36
  */
35
- export default class Document extends Container<Root> {
37
+ declare class Document_ extends Container<Root> {
36
38
  type: 'document'
37
39
  parent: undefined
38
40
 
39
- constructor(defaults?: DocumentProps)
41
+ constructor(defaults?: Document.DocumentProps)
40
42
 
41
43
  /**
42
44
  * Returns a `Result` instance representing the document’s CSS roots.
@@ -55,3 +57,7 @@ export default class Document extends Container<Root> {
55
57
  */
56
58
  toResult(options?: ProcessOptions): Result
57
59
  }
60
+
61
+ declare class Document extends Document_ {}
62
+
63
+ export = Document
package/lib/fromJSON.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  import { JSONHydrator } from './postcss.js'
2
2
 
3
- declare const fromJSON: JSONHydrator
3
+ interface FromJSON extends JSONHydrator {
4
+ default: FromJSON
5
+ }
4
6
 
5
- export default fromJSON
7
+ declare const fromJSON: FromJSON
8
+
9
+ export = fromJSON
package/lib/input.d.ts CHANGED
@@ -1,41 +1,46 @@
1
- import { ProcessOptions } from './postcss.js'
1
+ import { CssSyntaxError, ProcessOptions } from './postcss.js'
2
2
  import PreviousMap from './previous-map.js'
3
3
 
4
- export interface FilePosition {
5
- /**
6
- * URL for the source file.
7
- */
8
- url: string
9
-
10
- /**
11
- * Absolute path to the source file.
12
- */
13
- file?: string
14
-
15
- /**
16
- * Line of inclusive start position in source file.
17
- */
18
- line: number
19
-
20
- /**
21
- * Column of inclusive start position in source file.
22
- */
23
- column: number
24
-
25
- /**
26
- * Line of exclusive end position in source file.
27
- */
28
- endLine?: number
4
+ declare namespace Input {
5
+ export interface FilePosition {
6
+ /**
7
+ * URL for the source file.
8
+ */
9
+ url: string
10
+
11
+ /**
12
+ * Absolute path to the source file.
13
+ */
14
+ file?: string
15
+
16
+ /**
17
+ * Line of inclusive start position in source file.
18
+ */
19
+ line: number
20
+
21
+ /**
22
+ * Column of inclusive start position in source file.
23
+ */
24
+ column: number
25
+
26
+ /**
27
+ * Line of exclusive end position in source file.
28
+ */
29
+ endLine?: number
30
+
31
+ /**
32
+ * Column of exclusive end position in source file.
33
+ */
34
+ endColumn?: number
29
35
 
30
- /**
31
- * Column of exclusive end position in source file.
32
- */
33
- endColumn?: number
36
+ /**
37
+ * Source code.
38
+ */
39
+ source?: string
40
+ }
34
41
 
35
- /**
36
- * Source code.
37
- */
38
- source?: string
42
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
43
+ export { Input_ as default }
39
44
  }
40
45
 
41
46
  /**
@@ -46,7 +51,7 @@ export interface FilePosition {
46
51
  * const input = root.source.input
47
52
  * ```
48
53
  */
49
- export default class Input {
54
+ declare class Input_ {
50
55
  /**
51
56
  * Input CSS source.
52
57
  *
@@ -139,7 +144,7 @@ export default class Input {
139
144
  column: number,
140
145
  endLine?: number,
141
146
  endColumn?: number
142
- ): FilePosition | false
147
+ ): Input.FilePosition | false
143
148
 
144
149
  /**
145
150
  * Converts source offset to line and column.
@@ -147,4 +152,43 @@ export default class Input {
147
152
  * @param offset Source offset.
148
153
  */
149
154
  fromOffset(offset: number): { line: number; col: number } | null
155
+
156
+ /**
157
+ * Returns `CssSyntaxError` with information about the error and its position.
158
+ */
159
+ error(
160
+ message: string,
161
+ line: number,
162
+ column: number,
163
+ opts?: { plugin?: CssSyntaxError['plugin'] }
164
+ ): CssSyntaxError
165
+ error(
166
+ message: string,
167
+ offset: number,
168
+ opts?: { plugin?: CssSyntaxError['plugin'] }
169
+ ): CssSyntaxError
170
+ error(
171
+ message: string,
172
+ start:
173
+ | {
174
+ offset: number
175
+ }
176
+ | {
177
+ line: number
178
+ column: number
179
+ },
180
+ end:
181
+ | {
182
+ offset: number
183
+ }
184
+ | {
185
+ line: number
186
+ column: number
187
+ },
188
+ opts?: { plugin?: CssSyntaxError['plugin'] }
189
+ ): CssSyntaxError
150
190
  }
191
+
192
+ declare class Input extends Input_ {}
193
+
194
+ export = Input
package/lib/input.js CHANGED
@@ -108,7 +108,7 @@ class Input {
108
108
  if (line && typeof line === 'object') {
109
109
  let start = line
110
110
  let end = column
111
- if (typeof line.offset === 'number') {
111
+ if (typeof start.offset === 'number') {
112
112
  let pos = this.fromOffset(start.offset)
113
113
  line = pos.line
114
114
  column = pos.col