postcss 8.3.9 → 8.4.31

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 (44) hide show
  1. package/README.md +7 -23
  2. package/lib/at-rule.d.ts +58 -49
  3. package/lib/comment.d.ts +43 -32
  4. package/lib/container.d.ts +233 -223
  5. package/lib/container.js +251 -244
  6. package/lib/css-syntax-error.d.ts +117 -61
  7. package/lib/css-syntax-error.js +10 -3
  8. package/lib/declaration.d.ts +85 -61
  9. package/lib/document.d.ts +27 -16
  10. package/lib/fromJSON.d.ts +6 -2
  11. package/lib/input.d.ts +118 -54
  12. package/lib/input.js +87 -55
  13. package/lib/lazy-result.d.ts +82 -67
  14. package/lib/lazy-result.js +234 -232
  15. package/lib/list.d.ts +53 -47
  16. package/lib/list.js +16 -14
  17. package/lib/map-generator.js +231 -172
  18. package/lib/no-work-result.d.ts +46 -0
  19. package/lib/no-work-result.js +135 -0
  20. package/lib/node.d.ts +345 -253
  21. package/lib/node.js +200 -139
  22. package/lib/parse.d.ts +6 -2
  23. package/lib/parser.js +354 -309
  24. package/lib/postcss.d.mts +72 -0
  25. package/lib/postcss.d.ts +288 -319
  26. package/lib/postcss.js +18 -12
  27. package/lib/postcss.mjs +1 -0
  28. package/lib/previous-map.d.ts +23 -14
  29. package/lib/previous-map.js +37 -40
  30. package/lib/processor.d.ts +55 -41
  31. package/lib/processor.js +20 -27
  32. package/lib/result.d.ts +87 -76
  33. package/lib/root.d.ts +49 -36
  34. package/lib/root.js +12 -10
  35. package/lib/rule.d.ts +54 -45
  36. package/lib/stringifier.d.ts +46 -0
  37. package/lib/stringifier.js +140 -138
  38. package/lib/stringify.d.ts +6 -2
  39. package/lib/terminal-highlight.js +11 -11
  40. package/lib/tokenize.js +2 -2
  41. package/lib/warn-once.js +1 -0
  42. package/lib/warning.d.ts +79 -36
  43. package/lib/warning.js +6 -4
  44. package/package.json +20 -10
@@ -1,5 +1,9 @@
1
1
  import { Stringifier } from './postcss.js'
2
2
 
3
- declare const stringify: Stringifier
3
+ interface Stringify extends Stringifier {
4
+ default: Stringify
5
+ }
4
6
 
5
- export default stringify
7
+ declare const stringify: Stringify
8
+
9
+ export = stringify
@@ -11,21 +11,21 @@ function registerInput(dependant) {
11
11
  }
12
12
 
13
13
  const HIGHLIGHT_THEME = {
14
- 'brackets': pico.cyan,
15
- 'at-word': pico.cyan,
16
- 'comment': pico.gray,
17
- 'string': pico.green,
18
- 'class': pico.yellow,
19
- 'hash': pico.magenta,
20
- 'call': pico.cyan,
14
+ ';': pico.yellow,
15
+ ':': pico.yellow,
21
16
  '(': pico.cyan,
22
17
  ')': pico.cyan,
23
- '{': pico.yellow,
24
- '}': pico.yellow,
25
18
  '[': pico.yellow,
26
19
  ']': pico.yellow,
27
- ':': pico.yellow,
28
- ';': pico.yellow
20
+ '{': pico.yellow,
21
+ '}': pico.yellow,
22
+ 'at-word': pico.cyan,
23
+ 'brackets': pico.cyan,
24
+ 'call': pico.cyan,
25
+ 'class': pico.yellow,
26
+ 'comment': pico.gray,
27
+ 'hash': pico.magenta,
28
+ 'string': pico.green
29
29
  }
30
30
 
31
31
  function getTokenType([type, value], processor) {
package/lib/tokenize.js CHANGED
@@ -22,7 +22,7 @@ const AT = '@'.charCodeAt(0)
22
22
 
23
23
  const RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g
24
24
  const RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g
25
- const RE_BAD_BRACKET = /.[\n"'(/\\]/
25
+ const RE_BAD_BRACKET = /.[\r\n"'(/\\]/
26
26
  const RE_HEX_ESCAPE = /[\da-f]/i
27
27
 
28
28
  module.exports = function tokenizer(input, options = {}) {
@@ -259,8 +259,8 @@ module.exports = function tokenizer(input, options = {}) {
259
259
 
260
260
  return {
261
261
  back,
262
- nextToken,
263
262
  endOfFile,
263
+ nextToken,
264
264
  position
265
265
  }
266
266
  }
package/lib/warn-once.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-console */
1
2
  'use strict'
2
3
 
3
4
  let printed = {}
package/lib/warning.d.ts CHANGED
@@ -1,26 +1,47 @@
1
+ import { RangePosition } from './css-syntax-error.js'
1
2
  import Node from './node.js'
2
3
 
3
- export interface WarningOptions {
4
- /**
5
- * CSS node that caused the warning.
6
- */
7
- node?: Node
4
+ declare namespace Warning {
5
+ export interface WarningOptions {
6
+ /**
7
+ * End position, exclusive, in CSS node string that caused the warning.
8
+ */
9
+ end?: RangePosition
8
10
 
9
- /**
10
- * Word in CSS source that caused the warning.
11
- */
12
- word?: string
11
+ /**
12
+ * End index, exclusive, in CSS node string that caused the warning.
13
+ */
14
+ endIndex?: number
13
15
 
14
- /**
15
- * Index in CSS node string that caused the warning.
16
- */
17
- index?: number
16
+ /**
17
+ * Start index, inclusive, in CSS node string that caused the warning.
18
+ */
19
+ index?: number
18
20
 
19
- /**
20
- * Name of the plugin that created this warning. `Result#warn` fills
21
- * this property automatically.
22
- */
23
- plugin?: string
21
+ /**
22
+ * CSS node that caused the warning.
23
+ */
24
+ node?: Node
25
+
26
+ /**
27
+ * Name of the plugin that created this warning. `Result#warn` fills
28
+ * this property automatically.
29
+ */
30
+ plugin?: string
31
+
32
+ /**
33
+ * Start position, inclusive, in CSS node string that caused the warning.
34
+ */
35
+ start?: RangePosition
36
+
37
+ /**
38
+ * Word in CSS source that caused the warning.
39
+ */
40
+ word?: string
41
+ }
42
+
43
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
44
+ export { Warning_ as default }
24
45
  }
25
46
 
26
47
  /**
@@ -32,31 +53,42 @@ export interface WarningOptions {
32
53
  * }
33
54
  * ```
34
55
  */
35
- export default class Warning {
56
+ declare class Warning_ {
36
57
  /**
37
- * Type to filter warnings from `Result#messages`.
38
- * Always equal to `"warning"`.
58
+ * Column for inclusive start position in the input file with this warning’s source.
59
+ *
60
+ * ```js
61
+ * warning.column //=> 6
62
+ * ```
39
63
  */
40
- type: 'warning'
64
+ column: number
41
65
 
42
66
  /**
43
- * The warning message.
67
+ * Column for exclusive end position in the input file with this warning’s source.
44
68
  *
45
69
  * ```js
46
- * warning.text //=> 'Try to avoid !important'
70
+ * warning.endColumn //=> 4
47
71
  * ```
48
72
  */
49
- text: string
73
+ endColumn?: number
50
74
 
51
75
  /**
52
- * The name of the plugin that created this warning.
53
- * When you call `Node#warn` it will fill this property automatically.
76
+ * Line for exclusive end position in the input file with this warning’s source.
54
77
  *
55
78
  * ```js
56
- * warning.plugin //=> 'postcss-important'
79
+ * warning.endLine //=> 6
57
80
  * ```
58
81
  */
59
- plugin: string
82
+ endLine?: number
83
+
84
+ /**
85
+ * Line for inclusive start position in the input file with this warning’s source.
86
+ *
87
+ * ```js
88
+ * warning.line //=> 5
89
+ * ```
90
+ */
91
+ line: number
60
92
 
61
93
  /**
62
94
  * Contains the CSS node that caused the warning.
@@ -68,28 +100,35 @@ export default class Warning {
68
100
  node: Node
69
101
 
70
102
  /**
71
- * Line in the input file with this warning’s source.
103
+ * The name of the plugin that created this warning.
104
+ * When you call `Node#warn` it will fill this property automatically.
72
105
  *
73
106
  * ```js
74
- * warning.line //=> 5
107
+ * warning.plugin //=> 'postcss-important'
75
108
  * ```
76
109
  */
77
- line: number
110
+ plugin: string
78
111
 
79
112
  /**
80
- * Column in the input file with this warning’s source.
113
+ * The warning message.
81
114
  *
82
115
  * ```js
83
- * warning.column //=> 6
116
+ * warning.text //=> 'Try to avoid !important'
84
117
  * ```
85
118
  */
86
- column: number
119
+ text: string
120
+
121
+ /**
122
+ * Type to filter warnings from `Result#messages`.
123
+ * Always equal to `"warning"`.
124
+ */
125
+ type: 'warning'
87
126
 
88
127
  /**
89
128
  * @param text Warning message.
90
129
  * @param opts Warning options.
91
130
  */
92
- constructor(text: string, opts?: WarningOptions)
131
+ constructor(text: string, opts?: Warning.WarningOptions)
93
132
 
94
133
  /**
95
134
  * Returns a warning position and message.
@@ -102,3 +141,7 @@ export default class Warning {
102
141
  */
103
142
  toString(): string
104
143
  }
144
+
145
+ declare class Warning extends Warning_ {}
146
+
147
+ export = Warning
package/lib/warning.js CHANGED
@@ -6,9 +6,11 @@ class Warning {
6
6
  this.text = text
7
7
 
8
8
  if (opts.node && opts.node.source) {
9
- let pos = opts.node.positionBy(opts)
10
- this.line = pos.line
11
- this.column = pos.column
9
+ let range = opts.node.rangeBy(opts)
10
+ this.line = range.start.line
11
+ this.column = range.start.column
12
+ this.endLine = range.end.line
13
+ this.endColumn = range.end.column
12
14
  }
13
15
 
14
16
  for (let opt in opts) this[opt] = opts[opt]
@@ -17,8 +19,8 @@ class Warning {
17
19
  toString() {
18
20
  if (this.node) {
19
21
  return this.node.error(this.text, {
20
- plugin: this.plugin,
21
22
  index: this.index,
23
+ plugin: this.plugin,
22
24
  word: this.word
23
25
  }).message
24
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss",
3
- "version": "8.3.9",
3
+ "version": "8.4.31",
4
4
  "description": "Tool for transforming styles with JS plugins",
5
5
  "engines": {
6
6
  "node": "^10 || ^12 || >=14"
@@ -8,8 +8,7 @@
8
8
  "exports": {
9
9
  ".": {
10
10
  "require": "./lib/postcss.js",
11
- "import": "./lib/postcss.mjs",
12
- "types": "./lib/postcss.d.ts"
11
+ "import": "./lib/postcss.mjs"
13
12
  },
14
13
  "./lib/at-rule": "./lib/at-rule.js",
15
14
  "./lib/comment": "./lib/comment.js",
@@ -19,6 +18,7 @@
19
18
  "./lib/fromJSON": "./lib/fromJSON.js",
20
19
  "./lib/input": "./lib/input.js",
21
20
  "./lib/lazy-result": "./lib/lazy-result.js",
21
+ "./lib/no-work-result": "./lib/no-work-result.js",
22
22
  "./lib/list": "./lib/list.js",
23
23
  "./lib/map-generator": "./lib/map-generator.js",
24
24
  "./lib/node": "./lib/node.js",
@@ -52,10 +52,20 @@
52
52
  "manipulation",
53
53
  "transpiler"
54
54
  ],
55
- "funding": {
56
- "type": "opencollective",
57
- "url": "https://opencollective.com/postcss/"
58
- },
55
+ "funding": [
56
+ {
57
+ "type": "opencollective",
58
+ "url": "https://opencollective.com/postcss/"
59
+ },
60
+ {
61
+ "type": "tidelift",
62
+ "url": "https://tidelift.com/funding/github/npm/postcss"
63
+ },
64
+ {
65
+ "type": "github",
66
+ "url": "https://github.com/sponsors/ai"
67
+ }
68
+ ],
59
69
  "author": "Andrey Sitnik <andrey@sitnik.ru>",
60
70
  "license": "MIT",
61
71
  "homepage": "https://postcss.org/",
@@ -64,9 +74,9 @@
64
74
  "url": "https://github.com/postcss/postcss/issues"
65
75
  },
66
76
  "dependencies": {
67
- "nanoid": "^3.1.28",
68
- "picocolors": "^0.2.1",
69
- "source-map-js": "^0.6.2"
77
+ "nanoid": "^3.3.6",
78
+ "picocolors": "^1.0.0",
79
+ "source-map-js": "^1.0.2"
70
80
  },
71
81
  "browser": {
72
82
  "./lib/terminal-highlight": false,