postcss 8.2.2 → 8.2.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.

Potentially problematic release.


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

package/CHANGELOG.md CHANGED
@@ -1,6 +1,20 @@
1
1
  # Change Log
2
2
  This project adheres to [Semantic Versioning](https://semver.org/).
3
3
 
4
+ ## 8.2.6
5
+ * Fixed `Maximum call stack size exceeded` in `Node#toJSON`.
6
+ * Fixed docs (by inokawa).
7
+
8
+ ## 8.2.5
9
+ * Fixed escaped characters handling in `list.split` (by Natalie Weizenbaum).
10
+
11
+ ## 8.2.4
12
+ * Added plugin name to `postcss.plugin()` warning (by Tom Williams).
13
+ * Fixed docs (by Bill Columbia).
14
+
15
+ ## 8.2.3
16
+ * Fixed `JSON.stringify(Node[])` support (by Niklas Mischkulnig).
17
+
4
18
  ## 8.2.2
5
19
  * Fixed CSS-in-JS support (by James Garbutt).
6
20
  * Fixed plugin types (by Ludovico Fischer).
package/README.md CHANGED
@@ -416,7 +416,7 @@ fs.readFile('src/app.css', (err, css) => {
416
416
  .then(result => {
417
417
  fs.writeFile('dest/app.css', result.css, () => true)
418
418
  if ( result.map ) {
419
- fs.writeFile('dest/app.css.map', result.map, () => true)
419
+ fs.writeFile('dest/app.css.map', result.map.toString(), () => true)
420
420
  }
421
421
  })
422
422
  })
@@ -298,7 +298,7 @@ export default abstract class Container extends Node {
298
298
  * Add child to the end of the node.
299
299
  *
300
300
  * ```js
301
- * rule.push(new Declaration({ prop: 'color', value: 'black' }}))
301
+ * rule.push(new Declaration({ prop: 'color', value: 'black' }))
302
302
  * ```
303
303
  *
304
304
  * @param child New node.
@@ -1,4 +1,4 @@
1
- import Input, { FilePosition } from './input.js'
1
+ import { FilePosition } from './input.js'
2
2
 
3
3
  /**
4
4
  * The CSS parser throws this error for broken CSS.
package/lib/fromJSON.js CHANGED
@@ -9,6 +9,8 @@ let Root = require('./root')
9
9
  let Rule = require('./rule')
10
10
 
11
11
  function fromJSON (json, inputs) {
12
+ if (Array.isArray(json)) return json.map(n => fromJSON(n))
13
+
12
14
  let { inputs: ownInputs, ...defaults } = json
13
15
  if (ownInputs) {
14
16
  inputs = []
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 (quote) {
15
- if (escape) {
16
- escape = false
17
- } else if (letter === '\\') {
18
- escape = true
19
- } else if (letter === quote) {
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 === "'") {
@@ -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.map.addMapping({
223
- source: this.sourcePath(node),
224
- generated: { line, column: column - 1 },
225
- original: {
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
- this.map.addMapping({
232
- source: '<no source>',
233
- original: { line: 1, column: 0 },
234
- generated: { line, column: column - 1 }
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.map.addMapping({
253
- source: this.sourcePath(node),
254
- generated: { line, column: column - 2 },
255
- original: {
256
- line: node.source.end.line,
257
- column: node.source.end.column - 1
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
- this.map.addMapping({
262
- source: '<no source>',
263
- original: { line: 1, column: 0 },
264
- generated: { line, column: column - 1 }
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()
@@ -177,19 +177,19 @@ class Node {
177
177
  // istanbul ignore next
178
178
  continue
179
179
  }
180
- if (name === 'parent') continue
180
+ if (name === 'parent' || name === 'proxyCache') continue
181
181
  let value = this[name]
182
182
 
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
@@ -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, postcss)
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
- 'postcss.plugin was deprecated. Migration guide:\n' +
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
- 'postcss.plugin 被弃用. 迁移指南:\n' +
38
+ name +
39
+ ': 里面 postcss.plugin 被弃用. 迁移指南:\n' +
38
40
  'https://www.w3ctech.com/topic/2226'
39
41
  )
40
42
  }
package/lib/processor.js CHANGED
@@ -5,7 +5,7 @@ let Root = require('./root')
5
5
 
6
6
  class Processor {
7
7
  constructor (plugins = []) {
8
- this.version = '8.2.2'
8
+ this.version = '8.2.6'
9
9
  this.plugins = this.normalize(plugins)
10
10
  }
11
11
 
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss",
3
- "version": "8.2.2",
3
+ "version": "8.2.6",
4
4
  "description": "Tool for transforming styles with JS plugins",
5
5
  "engines": {
6
6
  "node": "^10 || ^12 || >=14"