postcss 8.5.11 → 8.5.13

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.
@@ -379,7 +379,10 @@ class LazyResult {
379
379
  if (str.stringify) str = str.stringify
380
380
 
381
381
  let rootSource = this.result.root.source
382
- if (opts.map === undefined && !(rootSource && rootSource.input && rootSource.input.map)) {
382
+ if (
383
+ opts.map === undefined &&
384
+ !(rootSource && rootSource.input && rootSource.input.map)
385
+ ) {
383
386
  let result = ''
384
387
  str(this.result.root, i => {
385
388
  result += i
package/lib/postcss.d.ts CHANGED
@@ -351,6 +351,11 @@ declare namespace postcss {
351
351
  * to generate correct source maps.
352
352
  */
353
353
  to?: string
354
+
355
+ /**
356
+ * Disable source map file protections.
357
+ */
358
+ unsafeMap?: boolean
354
359
  }
355
360
 
356
361
  export type Postcss = typeof postcss
@@ -16,6 +16,7 @@ function fromBase64(str) {
16
16
  class PreviousMap {
17
17
  constructor(css, opts) {
18
18
  if (opts.map === false) return
19
+ if (opts.unsafeMap) this.unsafeMap = true
19
20
  this.loadAnnotation(css)
20
21
  this.inline = this.startWith(this.annotation, 'data:')
21
22
 
@@ -30,7 +31,7 @@ class PreviousMap {
30
31
 
31
32
  consumer() {
32
33
  if (!this.consumerCache) {
33
- this.consumerCache = new SourceMapConsumer(this.text)
34
+ this.consumerCache = new SourceMapConsumer(this.json || this.text)
34
35
  }
35
36
  return this.consumerCache
36
37
  }
@@ -83,7 +84,13 @@ class PreviousMap {
83
84
  }
84
85
  }
85
86
 
86
- loadFile(path) {
87
+ loadFile(path, cssFile, trusted) {
88
+ /* c8 ignore next 5 */
89
+ if (!trusted && !this.unsafeMap) {
90
+ if (!/\.map$/i.test(path)) {
91
+ return undefined
92
+ }
93
+ }
87
94
  this.root = dirname(path)
88
95
  if (existsSync(path)) {
89
96
  this.mapFile = path
@@ -100,7 +107,7 @@ class PreviousMap {
100
107
  } else if (typeof prev === 'function') {
101
108
  let prevPath = prev(file)
102
109
  if (prevPath) {
103
- let map = this.loadFile(prevPath)
110
+ let map = this.loadFile(prevPath, file, true)
104
111
  if (!map) {
105
112
  throw new Error(
106
113
  'Unable to load previous source map: ' + prevPath.toString()
@@ -124,7 +131,16 @@ class PreviousMap {
124
131
  } else if (this.annotation) {
125
132
  let map = this.annotation
126
133
  if (file) map = join(dirname(file), map)
127
- return this.loadFile(map)
134
+ let unknown = this.loadFile(map, file, false)
135
+ if (unknown) {
136
+ try {
137
+ /* c8 ignore next 4 */
138
+ this.json = JSON.parse(unknown.replace(/^\)]}'[^\n]*\n/, ''))
139
+ } catch {
140
+ return undefined
141
+ }
142
+ }
143
+ return unknown
128
144
  }
129
145
  }
130
146
 
package/lib/processor.js CHANGED
@@ -7,7 +7,7 @@ let Root = require('./root')
7
7
 
8
8
  class Processor {
9
9
  constructor(plugins = []) {
10
- this.version = '8.5.11'
10
+ this.version = '8.5.13'
11
11
  this.plugins = this.normalize(plugins)
12
12
  }
13
13
 
@@ -86,21 +86,22 @@ class Stringifier {
86
86
 
87
87
  block(node, start) {
88
88
  let raws = node.raws
89
- let between = typeof raws.between !== 'undefined'
90
- ? raws.between
91
- : this.raw(node, 'between', 'beforeOpen')
89
+ let between =
90
+ typeof raws.between !== 'undefined'
91
+ ? raws.between
92
+ : this.raw(node, 'between', 'beforeOpen')
92
93
  this.builder(escapeHTMLInCSS(start + between) + '{', node, 'start')
93
94
 
94
95
  let after
95
96
  if (node.nodes && node.nodes.length) {
96
97
  this.body(node)
97
- after = typeof raws.after !== 'undefined'
98
- ? raws.after
99
- : this.raw(node, 'after')
98
+ after =
99
+ typeof raws.after !== 'undefined' ? raws.after : this.raw(node, 'after')
100
100
  } else {
101
- after = typeof raws.after !== 'undefined'
102
- ? raws.after
103
- : this.raw(node, 'after', 'emptyBody')
101
+ after =
102
+ typeof raws.after !== 'undefined'
103
+ ? raws.after
104
+ : this.raw(node, 'after', 'emptyBody')
104
105
  }
105
106
 
106
107
  if (after) this.builder(escapeHTMLInCSS(after))
@@ -130,25 +131,25 @@ class Stringifier {
130
131
 
131
132
  comment(node) {
132
133
  let raws = node.raws
133
- let left = typeof raws.left !== 'undefined'
134
- ? raws.left
135
- : this.raw(node, 'left', 'commentLeft')
136
- let right = typeof raws.right !== 'undefined'
137
- ? raws.right
138
- : this.raw(node, 'right', 'commentRight')
134
+ let left =
135
+ typeof raws.left !== 'undefined'
136
+ ? raws.left
137
+ : this.raw(node, 'left', 'commentLeft')
138
+ let right =
139
+ typeof raws.right !== 'undefined'
140
+ ? raws.right
141
+ : this.raw(node, 'right', 'commentRight')
139
142
  this.builder(escapeHTMLInCSS('/*' + left + node.text + right + '*/'), node)
140
143
  }
141
144
 
142
145
  decl(node, semicolon) {
143
146
  let raws = node.raws
144
- let between = typeof raws.between !== 'undefined'
145
- ? raws.between
146
- : this.raw(node, 'between', 'colon')
147
+ let between =
148
+ typeof raws.between !== 'undefined'
149
+ ? raws.between
150
+ : this.raw(node, 'between', 'colon')
147
151
 
148
- let rawVal = raws.value
149
- let value = rawVal && rawVal.value === node.value ? rawVal.raw : node.value
150
-
151
- let string = node.prop + between + value
152
+ let string = node.prop + between + this.rawValue(node, 'value')
152
153
 
153
154
  if (node.important) {
154
155
  string += raws.important || ' !important'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss",
3
- "version": "8.5.11",
3
+ "version": "8.5.13",
4
4
  "description": "Tool for transforming styles with JS plugins",
5
5
  "keywords": [
6
6
  "css",