postcss 8.5.11 → 8.5.12
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/postcss.d.ts +5 -0
- package/lib/previous-map.js +20 -4
- package/lib/processor.js +1 -1
- package/package.json +1 -1
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