postcss 8.2.1 → 8.2.5
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/CHANGELOG.md +15 -0
- package/README.md +5 -3
- package/lib/container.d.ts +23 -28
- package/lib/css-syntax-error.d.ts +1 -1
- package/lib/fromJSON.js +2 -0
- package/lib/list.js +6 -6
- package/lib/map-generator.js +29 -26
- package/lib/node.js +3 -3
- package/lib/postcss.d.ts +2 -1
- package/lib/postcss.js +5 -3
- package/lib/processor.js +1 -1
- package/lib/result.d.ts +1 -1
- package/lib/root.d.ts +0 -5
- package/lib/stringifier.js +9 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
# Change Log
|
2
2
|
This project adheres to [Semantic Versioning](https://semver.org/).
|
3
3
|
|
4
|
+
## 8.2.5
|
5
|
+
* Fixed escaped characters handling in `list.split` (by Natalie Weizenbaum).
|
6
|
+
|
7
|
+
## 8.2.4
|
8
|
+
* Added plugin name to `postcss.plugin()` warning (by Tom Williams).
|
9
|
+
* Fixed docs (by Bill Columbia).
|
10
|
+
|
11
|
+
## 8.2.3
|
12
|
+
* Fixed `JSON.stringify(Node[])` support (by Niklas Mischkulnig).
|
13
|
+
|
14
|
+
## 8.2.2
|
15
|
+
* Fixed CSS-in-JS support (by James Garbutt).
|
16
|
+
* Fixed plugin types (by Ludovico Fischer).
|
17
|
+
* Fixed `Result#warn()` types.
|
18
|
+
|
4
19
|
## 8.2.1
|
5
20
|
* Fixed `Node#toJSON()` and `postcss.fromJSON()` (by Niklas Mischkulnig).
|
6
21
|
|
package/README.md
CHANGED
@@ -100,7 +100,8 @@ If you have any new ideas, [PostCSS plugin development] is really easy.
|
|
100
100
|
* [`font-magician`] generates all the `@font-face` rules needed in CSS.
|
101
101
|
* [`postcss-inline-svg`] allows you to inline SVG and customize its styles.
|
102
102
|
* [`postcss-write-svg`] allows you to write simple SVG directly in your CSS.
|
103
|
-
|
103
|
+
* [`webp-in-css`] to use WebP image format in CSS background.
|
104
|
+
* [`avif-in-css`] to use AVIF image format in CSS background.
|
104
105
|
|
105
106
|
### Linters
|
106
107
|
|
@@ -136,6 +137,8 @@ If you have any new ideas, [PostCSS plugin development] is really easy.
|
|
136
137
|
[`postcss-rtl`]: https://github.com/vkalinichev/postcss-rtl
|
137
138
|
[`postcss-use`]: https://github.com/postcss/postcss-use
|
138
139
|
[`css-modules`]: https://github.com/css-modules/css-modules
|
140
|
+
[`webp-in-css`]: https://github.com/ai/webp-in-css
|
141
|
+
[`avif-in-css`]: https://github.com/nucliweb/avif-in-css
|
139
142
|
[`colorguard`]: https://github.com/SlexAxton/css-colorguard
|
140
143
|
[`stylelint`]: https://github.com/stylelint/stylelint
|
141
144
|
[`stylefmt`]: https://github.com/morishitter/stylefmt
|
@@ -146,7 +149,6 @@ If you have any new ideas, [PostCSS plugin development] is really easy.
|
|
146
149
|
[`short`]: https://github.com/jonathantneal/postcss-short
|
147
150
|
[`lost`]: https://github.com/peterramsing/lost
|
148
151
|
|
149
|
-
|
150
152
|
## Syntaxes
|
151
153
|
|
152
154
|
PostCSS can transform styles in any syntax, not just CSS.
|
@@ -414,7 +416,7 @@ fs.readFile('src/app.css', (err, css) => {
|
|
414
416
|
.then(result => {
|
415
417
|
fs.writeFile('dest/app.css', result.css, () => true)
|
416
418
|
if ( result.map ) {
|
417
|
-
fs.writeFile('dest/app.css.map', result.map, () => true)
|
419
|
+
fs.writeFile('dest/app.css.map', result.map.toString(), () => true)
|
418
420
|
}
|
419
421
|
})
|
420
422
|
})
|
package/lib/container.d.ts
CHANGED
@@ -91,8 +91,9 @@ export default abstract class Container extends Node {
|
|
91
91
|
* @param callback Iterator receives each node and index.
|
92
92
|
* @return Returns `false` if iteration was broke.
|
93
93
|
*/
|
94
|
-
each (
|
95
|
-
|
94
|
+
each (
|
95
|
+
callback: (node: ChildNode, index: number) => false | void
|
96
|
+
): false | undefined
|
96
97
|
|
97
98
|
/**
|
98
99
|
* Traverses the container’s descendant nodes, calling callback
|
@@ -113,8 +114,9 @@ export default abstract class Container extends Node {
|
|
113
114
|
* @param callback Iterator receives each node and index.
|
114
115
|
* @return Returns `false` if iteration was broke.
|
115
116
|
*/
|
116
|
-
walk (
|
117
|
-
|
117
|
+
walk (
|
118
|
+
callback: (node: ChildNode, index: number) => false | void
|
119
|
+
): false | undefined
|
118
120
|
|
119
121
|
/**
|
120
122
|
* Traverses the container’s descendant nodes, calling callback
|
@@ -147,14 +149,11 @@ export default abstract class Container extends Node {
|
|
147
149
|
*/
|
148
150
|
walkDecls (
|
149
151
|
propFilter: string | RegExp,
|
150
|
-
callback: (decl: Declaration, index: number) => void
|
151
|
-
):
|
152
|
-
walkDecls (callback: (decl: Declaration, index: number) => void): void
|
152
|
+
callback: (decl: Declaration, index: number) => false | void
|
153
|
+
): false | undefined
|
153
154
|
walkDecls (
|
154
|
-
|
155
|
-
|
156
|
-
): false
|
157
|
-
walkDecls (callback: (decl: Declaration, index: number) => false): false
|
155
|
+
callback: (decl: Declaration, index: number) => false | void
|
156
|
+
): false | undefined
|
158
157
|
|
159
158
|
/**
|
160
159
|
* Traverses the container’s descendant nodes, calling callback
|
@@ -180,14 +179,11 @@ export default abstract class Container extends Node {
|
|
180
179
|
*/
|
181
180
|
walkRules (
|
182
181
|
selectorFilter: string | RegExp,
|
183
|
-
callback: (atRule: Rule, index: number) => void
|
184
|
-
):
|
185
|
-
walkRules (callback: (atRule: Rule, index: number) => void): void
|
182
|
+
callback: (atRule: Rule, index: number) => false | void
|
183
|
+
): false | undefined
|
186
184
|
walkRules (
|
187
|
-
|
188
|
-
|
189
|
-
): false
|
190
|
-
walkRules (callback: (atRule: Rule, index: number) => false): false
|
185
|
+
callback: (atRule: Rule, index: number) => false | void
|
186
|
+
): false | undefined
|
191
187
|
|
192
188
|
/**
|
193
189
|
* Traverses the container’s descendant nodes, calling callback
|
@@ -220,14 +216,11 @@ export default abstract class Container extends Node {
|
|
220
216
|
*/
|
221
217
|
walkAtRules (
|
222
218
|
nameFilter: string | RegExp,
|
223
|
-
callback: (atRule: AtRule, index: number) => void
|
224
|
-
):
|
225
|
-
walkAtRules (callback: (atRule: AtRule, index: number) => void): void
|
219
|
+
callback: (atRule: AtRule, index: number) => false | void
|
220
|
+
): false | undefined
|
226
221
|
walkAtRules (
|
227
|
-
|
228
|
-
|
229
|
-
): false
|
230
|
-
walkAtRules (callback: (atRule: AtRule, index: number) => false): false
|
222
|
+
callback: (atRule: AtRule, index: number) => false | void
|
223
|
+
): false | undefined
|
231
224
|
|
232
225
|
/**
|
233
226
|
* Traverses the container’s descendant nodes, calling callback
|
@@ -246,10 +239,12 @@ export default abstract class Container extends Node {
|
|
246
239
|
* @return Returns `false` if iteration was broke.
|
247
240
|
*/
|
248
241
|
|
249
|
-
walkComments (callback: (comment: Comment, indexed: number) => void): void
|
250
242
|
walkComments (
|
251
|
-
callback: (comment: Comment, indexed: number) =>
|
252
|
-
):
|
243
|
+
callback: (comment: Comment, indexed: number) => false | void
|
244
|
+
): false | undefined
|
245
|
+
walkComments (
|
246
|
+
callback: (comment: Comment, indexed: number) => false | void
|
247
|
+
): false | undefined
|
253
248
|
|
254
249
|
/**
|
255
250
|
* Inserts new nodes to the end of the container.
|
package/lib/fromJSON.js
CHANGED
package/lib/list.js
CHANGED
@@ -11,12 +11,12 @@ let list = {
|
|
11
11
|
let escape = false
|
12
12
|
|
13
13
|
for (let letter of string) {
|
14
|
-
if (
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
if (escape) {
|
15
|
+
escape = false
|
16
|
+
} else if (letter === '\\') {
|
17
|
+
escape = true
|
18
|
+
} else if (quote) {
|
19
|
+
if (letter === quote) {
|
20
20
|
quote = false
|
21
21
|
}
|
22
22
|
} else if (letter === '"' || letter === "'") {
|
package/lib/map-generator.js
CHANGED
@@ -213,26 +213,30 @@ class MapGenerator {
|
|
213
213
|
let line = 1
|
214
214
|
let column = 1
|
215
215
|
|
216
|
+
let noSource = '<no source>'
|
217
|
+
let mapping = {
|
218
|
+
source: '',
|
219
|
+
generated: { line: 0, column: 0 },
|
220
|
+
original: { line: 0, column: 0 }
|
221
|
+
}
|
222
|
+
|
216
223
|
let lines, last
|
217
224
|
this.stringify(this.root, (str, node, type) => {
|
218
225
|
this.css += str
|
219
226
|
|
220
227
|
if (node && type !== 'end') {
|
228
|
+
mapping.generated.line = line
|
229
|
+
mapping.generated.column = column - 1
|
221
230
|
if (node.source && node.source.start) {
|
222
|
-
this.
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
line: node.source.start.line,
|
227
|
-
column: node.source.start.column - 1
|
228
|
-
}
|
229
|
-
})
|
231
|
+
mapping.source = this.sourcePath(node)
|
232
|
+
mapping.original.line = node.source.start.line
|
233
|
+
mapping.original.column = node.source.start.column - 1
|
234
|
+
this.map.addMapping(mapping)
|
230
235
|
} else {
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
})
|
236
|
+
mapping.source = noSource
|
237
|
+
mapping.original.line = 1
|
238
|
+
mapping.original.column = 0
|
239
|
+
this.map.addMapping(mapping)
|
236
240
|
}
|
237
241
|
}
|
238
242
|
|
@@ -249,20 +253,19 @@ class MapGenerator {
|
|
249
253
|
let p = node.parent || { raws: {} }
|
250
254
|
if (node.type !== 'decl' || node !== p.last || p.raws.semicolon) {
|
251
255
|
if (node.source && node.source.end) {
|
252
|
-
this.
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
}
|
259
|
-
})
|
256
|
+
mapping.source = this.sourcePath(node)
|
257
|
+
mapping.original.line = node.source.end.line
|
258
|
+
mapping.original.column = node.source.end.column - 1
|
259
|
+
mapping.generated.line = line
|
260
|
+
mapping.generated.column = column - 2
|
261
|
+
this.map.addMapping(mapping)
|
260
262
|
} else {
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
263
|
+
mapping.source = noSource
|
264
|
+
mapping.original.line = 1
|
265
|
+
mapping.original.column = 0
|
266
|
+
mapping.generated.line = line
|
267
|
+
mapping.generated.column = column - 1
|
268
|
+
this.map.addMapping(mapping)
|
266
269
|
}
|
267
270
|
}
|
268
271
|
}
|
package/lib/node.js
CHANGED
@@ -166,7 +166,7 @@ class Node {
|
|
166
166
|
if (!keepBetween) delete this.raws.between
|
167
167
|
}
|
168
168
|
|
169
|
-
toJSON (inputs) {
|
169
|
+
toJSON (_, inputs) {
|
170
170
|
let fixed = {}
|
171
171
|
let emitInputs = inputs == null
|
172
172
|
inputs = inputs || new Map()
|
@@ -183,13 +183,13 @@ class Node {
|
|
183
183
|
if (Array.isArray(value)) {
|
184
184
|
fixed[name] = value.map(i => {
|
185
185
|
if (typeof i === 'object' && i.toJSON) {
|
186
|
-
return i.toJSON(inputs)
|
186
|
+
return i.toJSON(null, inputs)
|
187
187
|
} else {
|
188
188
|
return i
|
189
189
|
}
|
190
190
|
})
|
191
191
|
} else if (typeof value === 'object' && value.toJSON) {
|
192
|
-
fixed[name] = value.toJSON(inputs)
|
192
|
+
fixed[name] = value.toJSON(null, inputs)
|
193
193
|
} else if (name === 'source') {
|
194
194
|
let inputId = inputs.get(value.input)
|
195
195
|
if (inputId == null) {
|
package/lib/postcss.d.ts
CHANGED
@@ -170,7 +170,7 @@ export interface Plugin extends Processors {
|
|
170
170
|
}
|
171
171
|
|
172
172
|
export interface PluginCreator<PluginOptions> {
|
173
|
-
(opts?: PluginOptions): Plugin
|
173
|
+
(opts?: PluginOptions): Plugin | Processor
|
174
174
|
postcss: true
|
175
175
|
}
|
176
176
|
|
@@ -214,6 +214,7 @@ export interface Stringifier {
|
|
214
214
|
}
|
215
215
|
|
216
216
|
export interface JSONHydrator {
|
217
|
+
(data: object[]): Node[]
|
217
218
|
(data: object): Node
|
218
219
|
}
|
219
220
|
|
package/lib/postcss.js
CHANGED
@@ -22,19 +22,21 @@ function postcss (...plugins) {
|
|
22
22
|
if (plugins.length === 1 && Array.isArray(plugins[0])) {
|
23
23
|
plugins = plugins[0]
|
24
24
|
}
|
25
|
-
return new Processor(plugins
|
25
|
+
return new Processor(plugins)
|
26
26
|
}
|
27
27
|
|
28
28
|
postcss.plugin = function plugin (name, initializer) {
|
29
29
|
if (console && console.warn) {
|
30
30
|
console.warn(
|
31
|
-
|
31
|
+
name +
|
32
|
+
': postcss.plugin was deprecated. Migration guide:\n' +
|
32
33
|
'https://evilmartians.com/chronicles/postcss-8-plugin-migration'
|
33
34
|
)
|
34
35
|
if (process.env.LANG && process.env.LANG.startsWith('cn')) {
|
35
36
|
// istanbul ignore next
|
36
37
|
console.warn(
|
37
|
-
|
38
|
+
name +
|
39
|
+
': 里面 postcss.plugin 被弃用. 迁移指南:\n' +
|
38
40
|
'https://www.w3ctech.com/topic/2226'
|
39
41
|
)
|
40
42
|
}
|
package/lib/processor.js
CHANGED
package/lib/result.d.ts
CHANGED
@@ -177,7 +177,7 @@ export default class Result {
|
|
177
177
|
* @param opts Warning options.
|
178
178
|
* @return Created warning.
|
179
179
|
*/
|
180
|
-
warn (message: string, options?: WarningOptions):
|
180
|
+
warn (message: string, options?: WarningOptions): Warning
|
181
181
|
|
182
182
|
/**
|
183
183
|
* Returns warnings from plugins. Filters `Warning` instances
|
package/lib/root.d.ts
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
import Container, { ContainerProps } from './container.js'
|
2
2
|
import { ProcessOptions } from './postcss.js'
|
3
|
-
import { ChildNode } from './node.js'
|
4
|
-
import Declaration from './declaration.js'
|
5
|
-
import Comment from './comment.js'
|
6
|
-
import AtRule from './at-rule.js'
|
7
3
|
import Result from './result.js'
|
8
|
-
import Rule from './rule.js'
|
9
4
|
|
10
5
|
interface RootRaws {
|
11
6
|
/**
|
package/lib/stringifier.js
CHANGED
@@ -25,11 +25,19 @@ class Stringifier {
|
|
25
25
|
}
|
26
26
|
|
27
27
|
stringify (node, semicolon) {
|
28
|
+
/* istanbul ignore if */
|
29
|
+
if (!this[node.type]) {
|
30
|
+
throw new Error(
|
31
|
+
'Unknown AST node type ' +
|
32
|
+
node.type +
|
33
|
+
'. ' +
|
34
|
+
'Maybe you need to change PostCSS stringifier.'
|
35
|
+
)
|
36
|
+
}
|
28
37
|
this[node.type](node, semicolon)
|
29
38
|
}
|
30
39
|
|
31
40
|
root (node) {
|
32
|
-
this.root = node
|
33
41
|
this.body(node)
|
34
42
|
if (node.raws.after) this.builder(node.raws.after)
|
35
43
|
}
|