postcss 8.2.6 → 8.2.10

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.

@@ -4,7 +4,7 @@ let { existsSync, readFileSync } = require('fs')
4
4
  let { dirname, join } = require('path')
5
5
  let mozilla = require('source-map')
6
6
 
7
- function fromBase64 (str) {
7
+ function fromBase64(str) {
8
8
  if (Buffer) {
9
9
  return Buffer.from(str, 'base64').toString()
10
10
  } else {
@@ -14,7 +14,7 @@ function fromBase64 (str) {
14
14
  }
15
15
 
16
16
  class PreviousMap {
17
- constructor (css, opts) {
17
+ constructor(css, opts) {
18
18
  if (opts.map === false) return
19
19
  this.loadAnnotation(css)
20
20
  this.inline = this.startWith(this.annotation, 'data:')
@@ -28,33 +28,31 @@ class PreviousMap {
28
28
  if (text) this.text = text
29
29
  }
30
30
 
31
- consumer () {
31
+ consumer() {
32
32
  if (!this.consumerCache) {
33
33
  this.consumerCache = new mozilla.SourceMapConsumer(this.text)
34
34
  }
35
35
  return this.consumerCache
36
36
  }
37
37
 
38
- withContent () {
38
+ withContent() {
39
39
  return !!(
40
40
  this.consumer().sourcesContent &&
41
41
  this.consumer().sourcesContent.length > 0
42
42
  )
43
43
  }
44
44
 
45
- startWith (string, start) {
45
+ startWith(string, start) {
46
46
  if (!string) return false
47
47
  return string.substr(0, start.length) === start
48
48
  }
49
49
 
50
- getAnnotationURL (sourceMapString) {
51
- return sourceMapString
52
- .match(/\/\*\s*# sourceMappingURL=(.*)\s*\*\//)[1]
53
- .trim()
50
+ getAnnotationURL(sourceMapString) {
51
+ return sourceMapString.match(/\/\*\s*# sourceMappingURL=(.*)\*\//)[1].trim()
54
52
  }
55
53
 
56
- loadAnnotation (css) {
57
- let annotations = css.match(/\/\*\s*# sourceMappingURL=.*\s*\*\//gm)
54
+ loadAnnotation(css) {
55
+ let annotations = css.match(/\/\*\s*# sourceMappingURL=.*\*\//gm)
58
56
 
59
57
  if (annotations && annotations.length > 0) {
60
58
  // Locate the last sourceMappingURL to avoid picking up
@@ -66,7 +64,7 @@ class PreviousMap {
66
64
  }
67
65
  }
68
66
 
69
- decodeInline (text) {
67
+ decodeInline(text) {
70
68
  let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/
71
69
  let baseUri = /^data:application\/json;base64,/
72
70
  let charsetUri = /^data:application\/json;charset=utf-?8,/
@@ -84,7 +82,7 @@ class PreviousMap {
84
82
  throw new Error('Unsupported source map encoding ' + encoding)
85
83
  }
86
84
 
87
- loadFile (path) {
85
+ loadFile(path) {
88
86
  this.root = dirname(path)
89
87
  if (existsSync(path)) {
90
88
  this.mapFile = path
@@ -92,7 +90,7 @@ class PreviousMap {
92
90
  }
93
91
  }
94
92
 
95
- loadMap (file, prev) {
93
+ loadMap(file, prev) {
96
94
  if (prev === false) return false
97
95
 
98
96
  if (prev) {
@@ -129,7 +127,7 @@ class PreviousMap {
129
127
  }
130
128
  }
131
129
 
132
- isMap (map) {
130
+ isMap(map) {
133
131
  if (typeof map !== 'object') return false
134
132
  return (
135
133
  typeof map.mappings === 'string' ||
@@ -44,7 +44,7 @@ export default class Processor {
44
44
  /**
45
45
  * @param plugins PostCSS plugins
46
46
  */
47
- constructor (plugins?: AcceptedPlugin[])
47
+ constructor(plugins?: AcceptedPlugin[])
48
48
 
49
49
  /**
50
50
  * Adds a plugin to be used as a CSS processor.
@@ -73,7 +73,7 @@ export default class Processor {
73
73
  * @param plugin PostCSS plugin or `Processor` with plugins.
74
74
  * @return {Processes} Current processor to make methods chain.
75
75
  */
76
- use (plugin: AcceptedPlugin): this
76
+ use(plugin: AcceptedPlugin): this
77
77
 
78
78
  /**
79
79
  * Parses source CSS and returns a `LazyResult` Promise proxy.
@@ -94,7 +94,7 @@ export default class Processor {
94
94
  * @param opts Options.
95
95
  * @return Promise proxy.
96
96
  */
97
- process (
97
+ process(
98
98
  css: string | { toString(): string } | Result | LazyResult | Root,
99
99
  options?: ProcessOptions
100
100
  ): LazyResult
package/lib/processor.js CHANGED
@@ -4,17 +4,17 @@ let LazyResult = require('./lazy-result')
4
4
  let Root = require('./root')
5
5
 
6
6
  class Processor {
7
- constructor (plugins = []) {
8
- this.version = '8.2.6'
7
+ constructor(plugins = []) {
8
+ this.version = '8.2.10'
9
9
  this.plugins = this.normalize(plugins)
10
10
  }
11
11
 
12
- use (plugin) {
12
+ use(plugin) {
13
13
  this.plugins = this.plugins.concat(this.normalize([plugin]))
14
14
  return this
15
15
  }
16
16
 
17
- process (css, opts = {}) {
17
+ process(css, opts = {}) {
18
18
  if (
19
19
  this.plugins.length === 0 &&
20
20
  opts.parser === opts.stringifier &&
@@ -33,7 +33,7 @@ class Processor {
33
33
  return new LazyResult(this, css, opts)
34
34
  }
35
35
 
36
- normalize (plugins) {
36
+ normalize(plugins) {
37
37
  let normalized = []
38
38
  for (let i of plugins) {
39
39
  if (i.postcss === true) {
package/lib/result.d.ts CHANGED
@@ -141,7 +141,7 @@ export default class Result {
141
141
  * @param root Root node after all transformations.
142
142
  * @param opts Options from the `Processor#process` or `Root#toResult`.
143
143
  */
144
- constructor (processor: Processor, root: Root, opts: ResultOptions)
144
+ constructor(processor: Processor, root: Root, opts: ResultOptions)
145
145
 
146
146
  /**
147
147
  * An alias for the `Result#css` property.
@@ -151,7 +151,7 @@ export default class Result {
151
151
  * result.css === result.content
152
152
  * ```
153
153
  */
154
- get content (): string
154
+ get content(): string
155
155
 
156
156
  /**
157
157
  * Returns for `Result#css` content.
@@ -162,7 +162,7 @@ export default class Result {
162
162
  *
163
163
  * @return String representing of `Result#root`.
164
164
  */
165
- toString (): string
165
+ toString(): string
166
166
 
167
167
  /**
168
168
  * Creates an instance of `Warning` and adds it to `Result#messages`.
@@ -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): Warning
180
+ warn(message: string, options?: WarningOptions): Warning
181
181
 
182
182
  /**
183
183
  * Returns warnings from plugins. Filters `Warning` instances
@@ -191,5 +191,5 @@ export default class Result {
191
191
  *
192
192
  * @return Warnings from plugins.
193
193
  */
194
- warnings (): Warning[]
194
+ warnings(): Warning[]
195
195
  }
package/lib/result.js CHANGED
@@ -3,7 +3,7 @@
3
3
  let Warning = require('./warning')
4
4
 
5
5
  class Result {
6
- constructor (processor, root, opts) {
6
+ constructor(processor, root, opts) {
7
7
  this.processor = processor
8
8
  this.messages = []
9
9
  this.root = root
@@ -12,11 +12,11 @@ class Result {
12
12
  this.map = undefined
13
13
  }
14
14
 
15
- toString () {
15
+ toString() {
16
16
  return this.css
17
17
  }
18
18
 
19
- warn (text, opts = {}) {
19
+ warn(text, opts = {}) {
20
20
  if (!opts.plugin) {
21
21
  if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
22
22
  opts.plugin = this.lastPlugin.postcssPlugin
@@ -29,11 +29,11 @@ class Result {
29
29
  return warning
30
30
  }
31
31
 
32
- warnings () {
32
+ warnings() {
33
33
  return this.messages.filter(i => i.type === 'warning')
34
34
  }
35
35
 
36
- get content () {
36
+ get content() {
37
37
  return this.css
38
38
  }
39
39
  }
package/lib/root.d.ts CHANGED
@@ -32,7 +32,7 @@ export default class Root extends Container {
32
32
  parent: undefined
33
33
  raws: RootRaws
34
34
 
35
- constructor (defaults?: RootProps)
35
+ constructor(defaults?: RootProps)
36
36
 
37
37
  /**
38
38
  * Returns a `Result` instance representing the root’s CSS.
@@ -47,5 +47,5 @@ export default class Root extends Container {
47
47
  * @param opts Options.
48
48
  * @return Result with current root’s CSS.
49
49
  */
50
- toResult (options?: ProcessOptions): Result
50
+ toResult(options?: ProcessOptions): Result
51
51
  }
package/lib/root.js CHANGED
@@ -5,13 +5,13 @@ let Container = require('./container')
5
5
  let LazyResult, Processor
6
6
 
7
7
  class Root extends Container {
8
- constructor (defaults) {
8
+ constructor(defaults) {
9
9
  super(defaults)
10
10
  this.type = 'root'
11
11
  if (!this.nodes) this.nodes = []
12
12
  }
13
13
 
14
- removeChild (child, ignore) {
14
+ removeChild(child, ignore) {
15
15
  let index = this.index(child)
16
16
 
17
17
  if (!ignore && index === 0 && this.nodes.length > 1) {
@@ -21,7 +21,7 @@ class Root extends Container {
21
21
  return super.removeChild(child)
22
22
  }
23
23
 
24
- normalize (child, sample, type) {
24
+ normalize(child, sample, type) {
25
25
  let nodes = super.normalize(child)
26
26
 
27
27
  if (sample) {
@@ -41,7 +41,7 @@ class Root extends Container {
41
41
  return nodes
42
42
  }
43
43
 
44
- toResult (opts = {}) {
44
+ toResult(opts = {}) {
45
45
  let lazy = new LazyResult(new Processor(), this, opts)
46
46
  return lazy.stringify()
47
47
  }
package/lib/rule.d.ts CHANGED
@@ -92,8 +92,8 @@ export default class Rule extends Container {
92
92
  */
93
93
  selectors: string[]
94
94
 
95
- constructor (defaults?: RuleProps)
96
- clone (overrides?: Partial<RuleProps>): this
97
- cloneBefore (overrides?: Partial<RuleProps>): this
98
- cloneAfter (overrides?: Partial<RuleProps>): this
95
+ constructor(defaults?: RuleProps)
96
+ clone(overrides?: Partial<RuleProps>): this
97
+ cloneBefore(overrides?: Partial<RuleProps>): this
98
+ cloneAfter(overrides?: Partial<RuleProps>): this
99
99
  }
package/lib/rule.js CHANGED
@@ -4,17 +4,17 @@ let Container = require('./container')
4
4
  let list = require('./list')
5
5
 
6
6
  class Rule extends Container {
7
- constructor (defaults) {
7
+ constructor(defaults) {
8
8
  super(defaults)
9
9
  this.type = 'rule'
10
10
  if (!this.nodes) this.nodes = []
11
11
  }
12
12
 
13
- get selectors () {
13
+ get selectors() {
14
14
  return list.comma(this.selector)
15
15
  }
16
16
 
17
- set selectors (values) {
17
+ set selectors(values) {
18
18
  let match = this.selector ? this.selector.match(/,\s*/) : null
19
19
  let sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen')
20
20
  this.selector = values.join(sep)
@@ -15,16 +15,16 @@ const DEFAULT_RAW = {
15
15
  semicolon: false
16
16
  }
17
17
 
18
- function capitalize (str) {
18
+ function capitalize(str) {
19
19
  return str[0].toUpperCase() + str.slice(1)
20
20
  }
21
21
 
22
22
  class Stringifier {
23
- constructor (builder) {
23
+ constructor(builder) {
24
24
  this.builder = builder
25
25
  }
26
26
 
27
- stringify (node, semicolon) {
27
+ stringify(node, semicolon) {
28
28
  /* istanbul ignore if */
29
29
  if (!this[node.type]) {
30
30
  throw new Error(
@@ -37,18 +37,18 @@ class Stringifier {
37
37
  this[node.type](node, semicolon)
38
38
  }
39
39
 
40
- root (node) {
40
+ root(node) {
41
41
  this.body(node)
42
42
  if (node.raws.after) this.builder(node.raws.after)
43
43
  }
44
44
 
45
- comment (node) {
45
+ comment(node) {
46
46
  let left = this.raw(node, 'left', 'commentLeft')
47
47
  let right = this.raw(node, 'right', 'commentRight')
48
48
  this.builder('/*' + left + node.text + right + '*/', node)
49
49
  }
50
50
 
51
- decl (node, semicolon) {
51
+ decl(node, semicolon) {
52
52
  let between = this.raw(node, 'between', 'colon')
53
53
  let string = node.prop + between + this.rawValue(node, 'value')
54
54
 
@@ -60,14 +60,14 @@ class Stringifier {
60
60
  this.builder(string, node)
61
61
  }
62
62
 
63
- rule (node) {
63
+ rule(node) {
64
64
  this.block(node, this.rawValue(node, 'selector'))
65
65
  if (node.raws.ownSemicolon) {
66
66
  this.builder(node.raws.ownSemicolon, node, 'end')
67
67
  }
68
68
  }
69
69
 
70
- atrule (node, semicolon) {
70
+ atrule(node, semicolon) {
71
71
  let name = '@' + node.name
72
72
  let params = node.params ? this.rawValue(node, 'params') : ''
73
73
 
@@ -85,7 +85,7 @@ class Stringifier {
85
85
  }
86
86
  }
87
87
 
88
- body (node) {
88
+ body(node) {
89
89
  let last = node.nodes.length - 1
90
90
  while (last > 0) {
91
91
  if (node.nodes[last].type !== 'comment') break
@@ -101,7 +101,7 @@ class Stringifier {
101
101
  }
102
102
  }
103
103
 
104
- block (node, start) {
104
+ block(node, start) {
105
105
  let between = this.raw(node, 'between', 'beforeOpen')
106
106
  this.builder(start + between + '{', node, 'start')
107
107
 
@@ -117,7 +117,7 @@ class Stringifier {
117
117
  this.builder('}', node, 'end')
118
118
  }
119
119
 
120
- raw (node, own, detect) {
120
+ raw(node, own, detect) {
121
121
  let value
122
122
  if (!detect) detect = own
123
123
 
@@ -166,7 +166,7 @@ class Stringifier {
166
166
  return value
167
167
  }
168
168
 
169
- rawSemicolon (root) {
169
+ rawSemicolon(root) {
170
170
  let value
171
171
  root.walk(i => {
172
172
  if (i.nodes && i.nodes.length && i.last.type === 'decl') {
@@ -177,7 +177,7 @@ class Stringifier {
177
177
  return value
178
178
  }
179
179
 
180
- rawEmptyBody (root) {
180
+ rawEmptyBody(root) {
181
181
  let value
182
182
  root.walk(i => {
183
183
  if (i.nodes && i.nodes.length === 0) {
@@ -188,7 +188,7 @@ class Stringifier {
188
188
  return value
189
189
  }
190
190
 
191
- rawIndent (root) {
191
+ rawIndent(root) {
192
192
  if (root.raws.indent) return root.raws.indent
193
193
  let value
194
194
  root.walk(i => {
@@ -205,7 +205,7 @@ class Stringifier {
205
205
  return value
206
206
  }
207
207
 
208
- rawBeforeComment (root, node) {
208
+ rawBeforeComment(root, node) {
209
209
  let value
210
210
  root.walkComments(i => {
211
211
  if (typeof i.raws.before !== 'undefined') {
@@ -224,7 +224,7 @@ class Stringifier {
224
224
  return value
225
225
  }
226
226
 
227
- rawBeforeDecl (root, node) {
227
+ rawBeforeDecl(root, node) {
228
228
  let value
229
229
  root.walkDecls(i => {
230
230
  if (typeof i.raws.before !== 'undefined') {
@@ -243,7 +243,7 @@ class Stringifier {
243
243
  return value
244
244
  }
245
245
 
246
- rawBeforeRule (root) {
246
+ rawBeforeRule(root) {
247
247
  let value
248
248
  root.walk(i => {
249
249
  if (i.nodes && (i.parent !== root || root.first !== i)) {
@@ -260,7 +260,7 @@ class Stringifier {
260
260
  return value
261
261
  }
262
262
 
263
- rawBeforeClose (root) {
263
+ rawBeforeClose(root) {
264
264
  let value
265
265
  root.walk(i => {
266
266
  if (i.nodes && i.nodes.length > 0) {
@@ -277,7 +277,7 @@ class Stringifier {
277
277
  return value
278
278
  }
279
279
 
280
- rawBeforeOpen (root) {
280
+ rawBeforeOpen(root) {
281
281
  let value
282
282
  root.walk(i => {
283
283
  if (i.type !== 'decl') {
@@ -288,7 +288,7 @@ class Stringifier {
288
288
  return value
289
289
  }
290
290
 
291
- rawColon (root) {
291
+ rawColon(root) {
292
292
  let value
293
293
  root.walkDecls(i => {
294
294
  if (typeof i.raws.between !== 'undefined') {
@@ -299,7 +299,7 @@ class Stringifier {
299
299
  return value
300
300
  }
301
301
 
302
- beforeAfter (node, detect) {
302
+ beforeAfter(node, detect) {
303
303
  let value
304
304
  if (node.type === 'decl') {
305
305
  value = this.raw(node, null, 'beforeDecl')
@@ -328,7 +328,7 @@ class Stringifier {
328
328
  return value
329
329
  }
330
330
 
331
- rawValue (node, prop) {
331
+ rawValue(node, prop) {
332
332
  let value = node[prop]
333
333
  let raw = node.raws[prop]
334
334
  if (raw && raw.value === value) {
package/lib/stringify.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  let Stringifier = require('./stringifier')
4
4
 
5
- function stringify (node, builder) {
5
+ function stringify(node, builder) {
6
6
  let str = new Stringifier(builder)
7
7
  str.stringify(node)
8
8
  }
@@ -6,7 +6,7 @@ let tokenizer = require('./tokenize')
6
6
 
7
7
  let Input
8
8
 
9
- function registerInput (dependant) {
9
+ function registerInput(dependant) {
10
10
  Input = dependant
11
11
  }
12
12
 
@@ -28,7 +28,7 @@ const HIGHLIGHT_THEME = {
28
28
  ';': yellow
29
29
  }
30
30
 
31
- function getTokenType ([type, value], processor) {
31
+ function getTokenType([type, value], processor) {
32
32
  if (type === 'word') {
33
33
  if (value[0] === '.') {
34
34
  return 'class'
@@ -47,7 +47,7 @@ function getTokenType ([type, value], processor) {
47
47
  return type
48
48
  }
49
49
 
50
- function terminalHighlight (css) {
50
+ function terminalHighlight(css) {
51
51
  let processor = tokenizer(new Input(css), { ignoreErrors: true })
52
52
  let result = ''
53
53
  while (!processor.endOfFile()) {
package/lib/tokenize.js CHANGED
@@ -25,7 +25,7 @@ const RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g
25
25
  const RE_BAD_BRACKET = /.[\n"'(/\\]/
26
26
  const RE_HEX_ESCAPE = /[\da-f]/i
27
27
 
28
- module.exports = function tokenizer (input, options = {}) {
28
+ module.exports = function tokenizer(input, options = {}) {
29
29
  let css = input.css.valueOf()
30
30
  let ignore = options.ignoreErrors
31
31
 
@@ -37,19 +37,19 @@ module.exports = function tokenizer (input, options = {}) {
37
37
  let buffer = []
38
38
  let returned = []
39
39
 
40
- function position () {
40
+ function position() {
41
41
  return pos
42
42
  }
43
43
 
44
- function unclosed (what) {
44
+ function unclosed(what) {
45
45
  throw input.error('Unclosed ' + what, pos)
46
46
  }
47
47
 
48
- function endOfFile () {
48
+ function endOfFile() {
49
49
  return returned.length === 0 && pos >= length
50
50
  }
51
51
 
52
- function nextToken (opts) {
52
+ function nextToken(opts) {
53
53
  if (returned.length) return returned.pop()
54
54
  if (pos >= length) return
55
55
 
@@ -253,7 +253,7 @@ module.exports = function tokenizer (input, options = {}) {
253
253
  return currentToken
254
254
  }
255
255
 
256
- function back (token) {
256
+ function back(token) {
257
257
  returned.push(token)
258
258
  }
259
259
 
package/lib/warn-once.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  let printed = {}
4
4
 
5
- module.exports = function warnOnce (message) {
5
+ module.exports = function warnOnce(message) {
6
6
  if (printed[message]) return
7
7
  printed[message] = true
8
8
 
package/lib/warning.d.ts CHANGED
@@ -89,7 +89,7 @@ export default class Warning {
89
89
  * @param text Warning message.
90
90
  * @param opts Warning options.
91
91
  */
92
- constructor (text: string, opts?: WarningOptions)
92
+ constructor(text: string, opts?: WarningOptions)
93
93
 
94
94
  /**
95
95
  * Returns a warning position and message.
@@ -100,5 +100,5 @@ export default class Warning {
100
100
  *
101
101
  * @return Warning position and message.
102
102
  */
103
- toString (): string
103
+ toString(): string
104
104
  }
package/lib/warning.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  class Warning {
4
- constructor (text, opts = {}) {
4
+ constructor(text, opts = {}) {
5
5
  this.type = 'warning'
6
6
  this.text = text
7
7
 
@@ -14,7 +14,7 @@ class Warning {
14
14
  for (let opt in opts) this[opt] = opts[opt]
15
15
  }
16
16
 
17
- toString () {
17
+ toString() {
18
18
  if (this.node) {
19
19
  return this.node.error(this.text, {
20
20
  plugin: this.plugin,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss",
3
- "version": "8.2.6",
3
+ "version": "8.2.10",
4
4
  "description": "Tool for transforming styles with JS plugins",
5
5
  "engines": {
6
6
  "node": "^10 || ^12 || >=14"
@@ -35,13 +35,15 @@
35
35
  "homepage": "https://postcss.org/",
36
36
  "repository": "postcss/postcss",
37
37
  "dependencies": {
38
- "colorette": "^1.2.1",
39
- "nanoid": "^3.1.20",
38
+ "colorette": "^1.2.2",
39
+ "nanoid": "^3.1.22",
40
40
  "source-map": "^0.6.1"
41
41
  },
42
42
  "browser": {
43
43
  "./lib/terminal-highlight": false,
44
44
  "colorette": false,
45
- "fs": false
45
+ "fs": false,
46
+ "path": false,
47
+ "url": false
46
48
  }
47
49
  }