postcss 8.2.11 → 8.2.15

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/input.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  let { fileURLToPath, pathToFileURL } = require('url')
4
4
  let { resolve, isAbsolute } = require('path')
5
+ let { SourceMapConsumer, SourceMapGenerator } = require('source-map')
5
6
  let { nanoid } = require('nanoid/non-secure')
6
7
 
7
8
  let terminalHighlight = require('./terminal-highlight')
@@ -10,6 +11,7 @@ let PreviousMap = require('./previous-map')
10
11
 
11
12
  let fromOffsetCache = Symbol('fromOffset cache')
12
13
 
14
+ let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator)
13
15
  let pathAvailable = Boolean(resolve && isAbsolute)
14
16
 
15
17
  class Input {
@@ -43,7 +45,7 @@ class Input {
43
45
  }
44
46
  }
45
47
 
46
- if (pathAvailable) {
48
+ if (pathAvailable && sourceMapAvailable) {
47
49
  let map = new PreviousMap(this.css, opts)
48
50
  if (map.text) {
49
51
  this.map = map
@@ -168,7 +170,7 @@ class Input {
168
170
  result.file = fileURLToPath(fromUrl)
169
171
  } else {
170
172
  // istanbul ignore next
171
- throw new Error(`file: protocol is not available in this PostCSS build`);
173
+ throw new Error(`file: protocol is not available in this PostCSS build`)
172
174
  }
173
175
  }
174
176
 
package/lib/list.d.ts CHANGED
@@ -1,4 +1,19 @@
1
1
  export type List = {
2
+ /**
3
+ * Safely splits values.
4
+ *
5
+ * ```js
6
+ * Once (root, { list }) {
7
+ * list.split('1px calc(10% + 1px)', [' ', '\n', '\t']) //=> ['1px', 'calc(10% + 1px)']
8
+ * }
9
+ * ```
10
+ *
11
+ * @param string separated values.
12
+ * @param separators array of separators.
13
+ * @param last boolean indicator.
14
+ * @return Split values.
15
+ */
16
+ split(string: string, separators: string[], last: boolean): string[]
2
17
  /**
3
18
  * Safely splits space-separated values (such as those for `background`,
4
19
  * `border-radius`, and other shorthand properties).
@@ -2,8 +2,9 @@
2
2
 
3
3
  let { dirname, resolve, relative, sep } = require('path')
4
4
  let { pathToFileURL } = require('url')
5
- let mozilla = require('source-map')
5
+ let { SourceMapConsumer, SourceMapGenerator } = require('source-map')
6
6
 
7
+ let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator)
7
8
  let pathAvailable = Boolean(dirname && resolve && relative && sep)
8
9
 
9
10
  class MapGenerator {
@@ -99,7 +100,7 @@ class MapGenerator {
99
100
  let map
100
101
 
101
102
  if (this.mapOpts.sourcesContent === false) {
102
- map = new mozilla.SourceMapConsumer(prev.text)
103
+ map = new SourceMapConsumer(prev.text)
103
104
  if (map.sourcesContent) {
104
105
  map.sourcesContent = map.sourcesContent.map(() => null)
105
106
  }
@@ -206,7 +207,9 @@ class MapGenerator {
206
207
  return pathToFileURL(node.source.input.from).toString()
207
208
  } else {
208
209
  // istanbul ignore next
209
- throw new Error('`map.absolute` option is not available in this PostCSS build')
210
+ throw new Error(
211
+ '`map.absolute` option is not available in this PostCSS build'
212
+ )
210
213
  }
211
214
  } else {
212
215
  return this.toUrl(this.path(node.source.input.from))
@@ -215,7 +218,7 @@ class MapGenerator {
215
218
 
216
219
  generateString() {
217
220
  this.css = ''
218
- this.map = new mozilla.SourceMapGenerator({ file: this.outputFile() })
221
+ this.map = new SourceMapGenerator({ file: this.outputFile() })
219
222
 
220
223
  let line = 1
221
224
  let column = 1
@@ -282,7 +285,7 @@ class MapGenerator {
282
285
  generate() {
283
286
  this.clearAnnotation()
284
287
 
285
- if (pathAvailable && this.isMap()) {
288
+ if (pathAvailable && sourceMapAvailable && this.isMap()) {
286
289
  return this.generateMap()
287
290
  }
288
291
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  let { existsSync, readFileSync } = require('fs')
4
4
  let { dirname, join } = require('path')
5
- let mozilla = require('source-map')
5
+ let { SourceMapConsumer, SourceMapGenerator } = require('source-map')
6
6
 
7
7
  function fromBase64(str) {
8
8
  if (Buffer) {
@@ -30,7 +30,7 @@ class PreviousMap {
30
30
 
31
31
  consumer() {
32
32
  if (!this.consumerCache) {
33
- this.consumerCache = new mozilla.SourceMapConsumer(this.text)
33
+ this.consumerCache = new SourceMapConsumer(this.text)
34
34
  }
35
35
  return this.consumerCache
36
36
  }
@@ -48,11 +48,15 @@ class PreviousMap {
48
48
  }
49
49
 
50
50
  getAnnotationURL(sourceMapString) {
51
- return sourceMapString.match(/\/\*\s*# sourceMappingURL=(.*)\*\//)[1].trim()
51
+ return sourceMapString
52
+ .match(/\/\*\s*# sourceMappingURL=((?:(?!sourceMappingURL=).)*)\*\//)[1]
53
+ .trim()
52
54
  }
53
55
 
54
56
  loadAnnotation(css) {
55
- let annotations = css.match(/\/\*\s*# sourceMappingURL=.*\*\//gm)
57
+ let annotations = css.match(
58
+ /\/\*\s*# sourceMappingURL=(?:(?!sourceMappingURL=).)*\*\//gm
59
+ )
56
60
 
57
61
  if (annotations && annotations.length > 0) {
58
62
  // Locate the last sourceMappingURL to avoid picking up
@@ -107,9 +111,9 @@ class PreviousMap {
107
111
  }
108
112
  return map
109
113
  }
110
- } else if (prev instanceof mozilla.SourceMapConsumer) {
111
- return mozilla.SourceMapGenerator.fromSourceMap(prev).toString()
112
- } else if (prev instanceof mozilla.SourceMapGenerator) {
114
+ } else if (prev instanceof SourceMapConsumer) {
115
+ return SourceMapGenerator.fromSourceMap(prev).toString()
116
+ } else if (prev instanceof SourceMapGenerator) {
113
117
  return prev.toString()
114
118
  } else if (this.isMap(prev)) {
115
119
  return JSON.stringify(prev)
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.11'
8
+ this.version = '8.2.15'
9
9
  this.plugins = this.normalize(plugins)
10
10
  }
11
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss",
3
- "version": "8.2.11",
3
+ "version": "8.2.15",
4
4
  "description": "Tool for transforming styles with JS plugins",
5
5
  "engines": {
6
6
  "node": "^10 || ^12 || >=14"
@@ -36,7 +36,8 @@
36
36
  "./lib/terminal-highlight": "./lib/terminal-highlight.js",
37
37
  "./lib/tokenize": "./lib/tokenize.js",
38
38
  "./lib/warn-once": "./lib/warn-once.js",
39
- "./lib/warning": "./lib/warning.js"
39
+ "./lib/warning": "./lib/warning.js",
40
+ "./package.json": "./package.json"
40
41
  },
41
42
  "main": "./lib/postcss.js",
42
43
  "types": "./lib/postcss.d.ts",
@@ -61,7 +62,7 @@
61
62
  "repository": "postcss/postcss",
62
63
  "dependencies": {
63
64
  "colorette": "^1.2.2",
64
- "nanoid": "^3.1.22",
65
+ "nanoid": "^3.1.23",
65
66
  "source-map": "^0.6.1"
66
67
  },
67
68
  "browser": {
@@ -69,6 +70,7 @@
69
70
  "colorette": false,
70
71
  "fs": false,
71
72
  "path": false,
72
- "url": false
73
+ "url": false,
74
+ "source-map": false
73
75
  }
74
76
  }