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.
- package/lib/lazy-result.js +4 -1
- package/lib/postcss.d.ts +5 -0
- package/lib/previous-map.js +20 -4
- package/lib/processor.js +1 -1
- package/lib/stringifier.js +23 -22
- package/package.json +1 -1
package/lib/lazy-result.js
CHANGED
|
@@ -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 (
|
|
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
package/lib/previous-map.js
CHANGED
|
@@ -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
|
-
|
|
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
package/lib/stringifier.js
CHANGED
|
@@ -86,21 +86,22 @@ class Stringifier {
|
|
|
86
86
|
|
|
87
87
|
block(node, start) {
|
|
88
88
|
let raws = node.raws
|
|
89
|
-
let between =
|
|
90
|
-
|
|
91
|
-
|
|
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 =
|
|
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 =
|
|
102
|
-
|
|
103
|
-
|
|
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 =
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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 =
|
|
145
|
-
|
|
146
|
-
|
|
147
|
+
let between =
|
|
148
|
+
typeof raws.between !== 'undefined'
|
|
149
|
+
? raws.between
|
|
150
|
+
: this.raw(node, 'between', 'colon')
|
|
147
151
|
|
|
148
|
-
let
|
|
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'
|