postcss 8.4.31 → 8.4.49
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/README.md +1 -1
- package/lib/at-rule.d.ts +40 -15
- package/lib/comment.d.ts +10 -9
- package/lib/container.d.ts +57 -26
- package/lib/container.js +16 -8
- package/lib/css-syntax-error.d.ts +1 -1
- package/lib/css-syntax-error.js +47 -14
- package/lib/declaration.d.ts +21 -18
- package/lib/document.d.ts +5 -4
- package/lib/fromJSON.js +3 -3
- package/lib/input.d.ts +3 -0
- package/lib/input.js +4 -4
- package/lib/lazy-result.js +5 -5
- package/lib/list.d.ts +5 -2
- package/lib/map-generator.js +18 -9
- package/lib/no-work-result.js +5 -2
- package/lib/node.d.ts +20 -15
- package/lib/node.js +63 -19
- package/lib/parse.js +1 -1
- package/lib/parser.js +6 -7
- package/lib/postcss.d.mts +1 -4
- package/lib/postcss.d.ts +20 -8
- package/lib/postcss.js +12 -12
- package/lib/previous-map.js +8 -6
- package/lib/processor.d.ts +1 -1
- package/lib/processor.js +7 -7
- package/lib/result.d.ts +0 -1
- package/lib/root.d.ts +5 -4
- package/lib/rule.d.ts +32 -19
- package/lib/tokenize.js +2 -2
- package/package.json +4 -4
package/lib/map-generator.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
'use strict'
|
2
2
|
|
3
|
-
let { SourceMapConsumer, SourceMapGenerator } = require('source-map-js')
|
4
3
|
let { dirname, relative, resolve, sep } = require('path')
|
4
|
+
let { SourceMapConsumer, SourceMapGenerator } = require('source-map-js')
|
5
5
|
let { pathToFileURL } = require('url')
|
6
6
|
|
7
7
|
let Input = require('./input')
|
@@ -16,6 +16,7 @@ class MapGenerator {
|
|
16
16
|
this.root = root
|
17
17
|
this.opts = opts
|
18
18
|
this.css = cssString
|
19
|
+
this.originalCSS = cssString
|
19
20
|
this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute
|
20
21
|
|
21
22
|
this.memoizedFileURLs = new Map()
|
@@ -51,7 +52,7 @@ class MapGenerator {
|
|
51
52
|
if (this.mapOpts.sourcesContent === false) {
|
52
53
|
map = new SourceMapConsumer(prev.text)
|
53
54
|
if (map.sourcesContent) {
|
54
|
-
map.sourcesContent =
|
55
|
+
map.sourcesContent = null
|
55
56
|
}
|
56
57
|
} else {
|
57
58
|
map = prev.consumer()
|
@@ -69,12 +70,12 @@ class MapGenerator {
|
|
69
70
|
for (let i = this.root.nodes.length - 1; i >= 0; i--) {
|
70
71
|
node = this.root.nodes[i]
|
71
72
|
if (node.type !== 'comment') continue
|
72
|
-
if (node.text.
|
73
|
+
if (node.text.startsWith('# sourceMappingURL=')) {
|
73
74
|
this.root.removeChild(i)
|
74
75
|
}
|
75
76
|
}
|
76
77
|
} else if (this.css) {
|
77
|
-
this.css = this.css.replace(
|
78
|
+
this.css = this.css.replace(/\n*\/\*#[\S\s]*?\*\/$/gm, '')
|
78
79
|
}
|
79
80
|
}
|
80
81
|
|
@@ -97,9 +98,14 @@ class MapGenerator {
|
|
97
98
|
} else if (this.previous().length === 1) {
|
98
99
|
let prev = this.previous()[0].consumer()
|
99
100
|
prev.file = this.outputFile()
|
100
|
-
this.map = SourceMapGenerator.fromSourceMap(prev
|
101
|
+
this.map = SourceMapGenerator.fromSourceMap(prev, {
|
102
|
+
ignoreInvalidMapping: true
|
103
|
+
})
|
101
104
|
} else {
|
102
|
-
this.map = new SourceMapGenerator({
|
105
|
+
this.map = new SourceMapGenerator({
|
106
|
+
file: this.outputFile(),
|
107
|
+
ignoreInvalidMapping: true
|
108
|
+
})
|
103
109
|
this.map.addMapping({
|
104
110
|
generated: { column: 0, line: 1 },
|
105
111
|
original: { column: 0, line: 1 },
|
@@ -122,7 +128,10 @@ class MapGenerator {
|
|
122
128
|
|
123
129
|
generateString() {
|
124
130
|
this.css = ''
|
125
|
-
this.map = new SourceMapGenerator({
|
131
|
+
this.map = new SourceMapGenerator({
|
132
|
+
file: this.outputFile(),
|
133
|
+
ignoreInvalidMapping: true
|
134
|
+
})
|
126
135
|
|
127
136
|
let line = 1
|
128
137
|
let column = 1
|
@@ -134,7 +143,7 @@ class MapGenerator {
|
|
134
143
|
source: ''
|
135
144
|
}
|
136
145
|
|
137
|
-
let
|
146
|
+
let last, lines
|
138
147
|
this.stringify(this.root, (str, node, type) => {
|
139
148
|
this.css += str
|
140
149
|
|
@@ -276,7 +285,7 @@ class MapGenerator {
|
|
276
285
|
}
|
277
286
|
})
|
278
287
|
} else {
|
279
|
-
let input = new Input(this.
|
288
|
+
let input = new Input(this.originalCSS, this.opts)
|
280
289
|
if (input.map) this.previousMaps.push(input.map)
|
281
290
|
}
|
282
291
|
}
|
package/lib/no-work-result.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
'use strict'
|
2
2
|
|
3
3
|
let MapGenerator = require('./map-generator')
|
4
|
-
let stringify = require('./stringify')
|
5
|
-
let warnOnce = require('./warn-once')
|
6
4
|
let parse = require('./parse')
|
7
5
|
const Result = require('./result')
|
6
|
+
let stringify = require('./stringify')
|
7
|
+
let warnOnce = require('./warn-once')
|
8
8
|
|
9
9
|
class NoWorkResult {
|
10
10
|
constructor(processor, css, opts) {
|
@@ -37,6 +37,9 @@ class NoWorkResult {
|
|
37
37
|
if (generatedMap) {
|
38
38
|
this.result.map = generatedMap
|
39
39
|
}
|
40
|
+
} else {
|
41
|
+
map.clearAnnotation()
|
42
|
+
this.result.css = map.css
|
40
43
|
}
|
41
44
|
}
|
42
45
|
|
package/lib/node.d.ts
CHANGED
@@ -2,7 +2,7 @@ import AtRule = require('./at-rule.js')
|
|
2
2
|
|
3
3
|
import { AtRuleProps } from './at-rule.js'
|
4
4
|
import Comment, { CommentProps } from './comment.js'
|
5
|
-
import Container from './container.js'
|
5
|
+
import Container, { NewChild } from './container.js'
|
6
6
|
import CssSyntaxError from './css-syntax-error.js'
|
7
7
|
import Declaration, { DeclarationProps } from './declaration.js'
|
8
8
|
import Document from './document.js'
|
@@ -234,6 +234,14 @@ declare abstract class Node_ {
|
|
234
234
|
|
235
235
|
constructor(defaults?: object)
|
236
236
|
|
237
|
+
/**
|
238
|
+
* If this node isn't already dirty, marks it and its ancestors as such. This
|
239
|
+
* indicates to the LazyResult processor that the {@link Root} has been
|
240
|
+
* modified by the current plugin and may need to be processed again by other
|
241
|
+
* plugins.
|
242
|
+
*/
|
243
|
+
protected markDirty(): void
|
244
|
+
|
237
245
|
/**
|
238
246
|
* Insert new node after current node to current node’s parent.
|
239
247
|
*
|
@@ -246,7 +254,9 @@ declare abstract class Node_ {
|
|
246
254
|
* @param newNode New node.
|
247
255
|
* @return This node for methods chain.
|
248
256
|
*/
|
249
|
-
after(
|
257
|
+
after(
|
258
|
+
newNode: Node | Node.ChildProps | readonly Node[] | string | undefined
|
259
|
+
): this
|
250
260
|
|
251
261
|
/**
|
252
262
|
* It assigns properties to an existing node instance.
|
@@ -273,7 +283,9 @@ declare abstract class Node_ {
|
|
273
283
|
* @param newNode New node.
|
274
284
|
* @return This node for methods chain.
|
275
285
|
*/
|
276
|
-
before(
|
286
|
+
before(
|
287
|
+
newNode: Node | Node.ChildProps | readonly Node[] | string | undefined
|
288
|
+
): this
|
277
289
|
|
278
290
|
/**
|
279
291
|
* Clear the code style properties for the node and its children.
|
@@ -303,7 +315,7 @@ declare abstract class Node_ {
|
|
303
315
|
*
|
304
316
|
* @return Duplicate of the node instance.
|
305
317
|
*/
|
306
|
-
clone(overrides?: object):
|
318
|
+
clone(overrides?: object): this
|
307
319
|
|
308
320
|
/**
|
309
321
|
* Shortcut to clone the node and insert the resulting cloned node
|
@@ -312,7 +324,7 @@ declare abstract class Node_ {
|
|
312
324
|
* @param overrides New properties to override in the clone.
|
313
325
|
* @return New node.
|
314
326
|
*/
|
315
|
-
cloneAfter(overrides?: object):
|
327
|
+
cloneAfter(overrides?: object): this
|
316
328
|
|
317
329
|
/**
|
318
330
|
* Shortcut to clone the node and insert the resulting cloned node
|
@@ -326,7 +338,7 @@ declare abstract class Node_ {
|
|
326
338
|
*
|
327
339
|
* @return New node
|
328
340
|
*/
|
329
|
-
cloneBefore(overrides?: object):
|
341
|
+
cloneBefore(overrides?: object): this
|
330
342
|
|
331
343
|
/**
|
332
344
|
* It creates an instance of the class `CssSyntaxError` and parameters passed
|
@@ -470,14 +482,7 @@ declare abstract class Node_ {
|
|
470
482
|
* @param nodes Mode(s) to replace current one.
|
471
483
|
* @return Current node to methods chain.
|
472
484
|
*/
|
473
|
-
replaceWith(
|
474
|
-
...nodes: (
|
475
|
-
| Node.ChildNode
|
476
|
-
| Node.ChildNode[]
|
477
|
-
| Node.ChildProps
|
478
|
-
| Node.ChildProps[]
|
479
|
-
)[]
|
480
|
-
): this
|
485
|
+
replaceWith(...nodes: NewChild[]): this
|
481
486
|
|
482
487
|
/**
|
483
488
|
* Finds the Root instance of the node’s tree.
|
@@ -531,6 +536,6 @@ declare abstract class Node_ {
|
|
531
536
|
warn(result: Result, message: string, options?: WarningOptions): Warning
|
532
537
|
}
|
533
538
|
|
534
|
-
declare class Node extends Node_ {
|
539
|
+
declare class Node extends Node_ {}
|
535
540
|
|
536
541
|
export = Node
|
package/lib/node.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
'use strict'
|
2
2
|
|
3
|
-
let { isClean, my } = require('./symbols')
|
4
3
|
let CssSyntaxError = require('./css-syntax-error')
|
5
4
|
let Stringifier = require('./stringifier')
|
6
5
|
let stringify = require('./stringify')
|
6
|
+
let { isClean, my } = require('./symbols')
|
7
7
|
|
8
8
|
function cloneNode(obj, parent) {
|
9
9
|
let cloned = new obj.constructor()
|
@@ -32,6 +32,36 @@ function cloneNode(obj, parent) {
|
|
32
32
|
return cloned
|
33
33
|
}
|
34
34
|
|
35
|
+
function sourceOffset(inputCSS, position) {
|
36
|
+
// Not all custom syntaxes support `offset` in `source.start` and `source.end`
|
37
|
+
if (
|
38
|
+
position &&
|
39
|
+
typeof position.offset !== 'undefined'
|
40
|
+
) {
|
41
|
+
return position.offset;
|
42
|
+
}
|
43
|
+
|
44
|
+
let column = 1
|
45
|
+
let line = 1
|
46
|
+
let offset = 0
|
47
|
+
|
48
|
+
for (let i = 0; i < inputCSS.length; i++) {
|
49
|
+
if (line === position.line && column === position.column) {
|
50
|
+
offset = i
|
51
|
+
break
|
52
|
+
}
|
53
|
+
|
54
|
+
if (inputCSS[i] === '\n') {
|
55
|
+
column = 1
|
56
|
+
line += 1
|
57
|
+
} else {
|
58
|
+
column += 1
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
return offset
|
63
|
+
}
|
64
|
+
|
35
65
|
class Node {
|
36
66
|
constructor(defaults = {}) {
|
37
67
|
this.raws = {}
|
@@ -153,6 +183,11 @@ class Node {
|
|
153
183
|
}
|
154
184
|
}
|
155
185
|
|
186
|
+
/* c8 ignore next 3 */
|
187
|
+
markClean() {
|
188
|
+
this[isClean] = true
|
189
|
+
}
|
190
|
+
|
156
191
|
markDirty() {
|
157
192
|
if (this[isClean]) {
|
158
193
|
this[isClean] = false
|
@@ -169,25 +204,29 @@ class Node {
|
|
169
204
|
return this.parent.nodes[index + 1]
|
170
205
|
}
|
171
206
|
|
172
|
-
positionBy(opts
|
207
|
+
positionBy(opts) {
|
173
208
|
let pos = this.source.start
|
174
209
|
if (opts.index) {
|
175
|
-
pos = this.positionInside(opts.index
|
210
|
+
pos = this.positionInside(opts.index)
|
176
211
|
} else if (opts.word) {
|
177
|
-
stringRepresentation = this.
|
212
|
+
let stringRepresentation = this.source.input.css.slice(
|
213
|
+
sourceOffset(this.source.input.css, this.source.start),
|
214
|
+
sourceOffset(this.source.input.css, this.source.end)
|
215
|
+
)
|
178
216
|
let index = stringRepresentation.indexOf(opts.word)
|
179
|
-
if (index !== -1) pos = this.positionInside(index
|
217
|
+
if (index !== -1) pos = this.positionInside(index)
|
180
218
|
}
|
181
219
|
return pos
|
182
220
|
}
|
183
221
|
|
184
|
-
positionInside(index
|
185
|
-
let string = stringRepresentation || this.toString()
|
222
|
+
positionInside(index) {
|
186
223
|
let column = this.source.start.column
|
187
224
|
let line = this.source.start.line
|
225
|
+
let offset = sourceOffset(this.source.input.css, this.source.start)
|
226
|
+
let end = offset + index
|
188
227
|
|
189
|
-
for (let i =
|
190
|
-
if (
|
228
|
+
for (let i = offset; i < end; i++) {
|
229
|
+
if (this.source.input.css[i] === '\n') {
|
191
230
|
column = 1
|
192
231
|
line += 1
|
193
232
|
} else {
|
@@ -211,20 +250,25 @@ class Node {
|
|
211
250
|
}
|
212
251
|
let end = this.source.end
|
213
252
|
? {
|
214
|
-
|
215
|
-
|
216
|
-
|
253
|
+
column: this.source.end.column + 1,
|
254
|
+
line: this.source.end.line
|
255
|
+
}
|
217
256
|
: {
|
218
|
-
|
219
|
-
|
220
|
-
|
257
|
+
column: start.column + 1,
|
258
|
+
line: start.line
|
259
|
+
}
|
221
260
|
|
222
261
|
if (opts.word) {
|
223
|
-
let stringRepresentation = this.
|
262
|
+
let stringRepresentation = this.source.input.css.slice(
|
263
|
+
sourceOffset(this.source.input.css, this.source.start),
|
264
|
+
sourceOffset(this.source.input.css, this.source.end)
|
265
|
+
)
|
224
266
|
let index = stringRepresentation.indexOf(opts.word)
|
225
267
|
if (index !== -1) {
|
226
|
-
start = this.positionInside(index
|
227
|
-
end = this.positionInside(
|
268
|
+
start = this.positionInside(index)
|
269
|
+
end = this.positionInside(
|
270
|
+
index + opts.word.length,
|
271
|
+
)
|
228
272
|
}
|
229
273
|
} else {
|
230
274
|
if (opts.start) {
|
@@ -241,7 +285,7 @@ class Node {
|
|
241
285
|
column: opts.end.column,
|
242
286
|
line: opts.end.line
|
243
287
|
}
|
244
|
-
} else if (opts.endIndex) {
|
288
|
+
} else if (typeof opts.endIndex === 'number') {
|
245
289
|
end = this.positionInside(opts.endIndex)
|
246
290
|
} else if (opts.index) {
|
247
291
|
end = this.positionInside(opts.index + 1)
|
package/lib/parse.js
CHANGED
package/lib/parser.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
'use strict'
|
2
2
|
|
3
|
-
let Declaration = require('./declaration')
|
4
|
-
let tokenizer = require('./tokenize')
|
5
|
-
let Comment = require('./comment')
|
6
3
|
let AtRule = require('./at-rule')
|
4
|
+
let Comment = require('./comment')
|
5
|
+
let Declaration = require('./declaration')
|
7
6
|
let Root = require('./root')
|
8
7
|
let Rule = require('./rule')
|
8
|
+
let tokenizer = require('./tokenize')
|
9
9
|
|
10
10
|
const SAFE_COMMENT_NEIGHBOR = {
|
11
11
|
empty: true,
|
@@ -28,7 +28,6 @@ class Parser {
|
|
28
28
|
this.current = this.root
|
29
29
|
this.spaces = ''
|
30
30
|
this.semicolon = false
|
31
|
-
this.customProperty = false
|
32
31
|
|
33
32
|
this.createTokenizer()
|
34
33
|
this.root.source = { input, start: { column: 1, line: 1, offset: 0 } }
|
@@ -144,7 +143,7 @@ class Parser {
|
|
144
143
|
|
145
144
|
colon(tokens) {
|
146
145
|
let brackets = 0
|
147
|
-
let token, type
|
146
|
+
let prev, token, type
|
148
147
|
for (let [i, element] of tokens.entries()) {
|
149
148
|
token = element
|
150
149
|
type = token[0]
|
@@ -268,12 +267,12 @@ class Parser {
|
|
268
267
|
let str = ''
|
269
268
|
for (let j = i; j > 0; j--) {
|
270
269
|
let type = cache[j][0]
|
271
|
-
if (str.trim().
|
270
|
+
if (str.trim().startsWith('!') && type !== 'space') {
|
272
271
|
break
|
273
272
|
}
|
274
273
|
str = cache.pop()[1] + str
|
275
274
|
}
|
276
|
-
if (str.trim().
|
275
|
+
if (str.trim().startsWith('!')) {
|
277
276
|
node.important = true
|
278
277
|
node.raws.important = str
|
279
278
|
tokens = cache
|
package/lib/postcss.d.mts
CHANGED
@@ -9,14 +9,12 @@ export {
|
|
9
9
|
plugin,
|
10
10
|
parse,
|
11
11
|
list,
|
12
|
-
|
13
12
|
document,
|
14
13
|
comment,
|
15
14
|
atRule,
|
16
15
|
rule,
|
17
16
|
decl,
|
18
17
|
root,
|
19
|
-
|
20
18
|
CssSyntaxError,
|
21
19
|
Declaration,
|
22
20
|
Container,
|
@@ -67,6 +65,5 @@ export {
|
|
67
65
|
WarningOptions,
|
68
66
|
|
69
67
|
// This is a class, but it’s not re-exported. That’s why it’s exported as type-only here.
|
70
|
-
type LazyResult
|
71
|
-
|
68
|
+
type LazyResult
|
72
69
|
} from './postcss.js'
|
package/lib/postcss.d.ts
CHANGED
@@ -2,7 +2,7 @@ import { RawSourceMap, SourceMapGenerator } from 'source-map-js'
|
|
2
2
|
|
3
3
|
import AtRule, { AtRuleProps } from './at-rule.js'
|
4
4
|
import Comment, { CommentProps } from './comment.js'
|
5
|
-
import Container, { ContainerProps } from './container.js'
|
5
|
+
import Container, { ContainerProps, NewChild } from './container.js'
|
6
6
|
import CssSyntaxError from './css-syntax-error.js'
|
7
7
|
import Declaration, { DeclarationProps } from './declaration.js'
|
8
8
|
import Document, { DocumentProps } from './document.js'
|
@@ -28,13 +28,22 @@ type DocumentProcessor = (
|
|
28
28
|
document: Document,
|
29
29
|
helper: postcss.Helpers
|
30
30
|
) => Promise<void> | void
|
31
|
-
type RootProcessor = (
|
31
|
+
type RootProcessor = (
|
32
|
+
root: Root,
|
33
|
+
helper: postcss.Helpers
|
34
|
+
) => Promise<void> | void
|
32
35
|
type DeclarationProcessor = (
|
33
36
|
decl: Declaration,
|
34
37
|
helper: postcss.Helpers
|
35
38
|
) => Promise<void> | void
|
36
|
-
type RuleProcessor = (
|
37
|
-
|
39
|
+
type RuleProcessor = (
|
40
|
+
rule: Rule,
|
41
|
+
helper: postcss.Helpers
|
42
|
+
) => Promise<void> | void
|
43
|
+
type AtRuleProcessor = (
|
44
|
+
atRule: AtRule,
|
45
|
+
helper: postcss.Helpers
|
46
|
+
) => Promise<void> | void
|
38
47
|
type CommentProcessor = (
|
39
48
|
comment: Comment,
|
40
49
|
helper: postcss.Helpers
|
@@ -161,6 +170,7 @@ declare namespace postcss {
|
|
161
170
|
LazyResult,
|
162
171
|
list,
|
163
172
|
Message,
|
173
|
+
NewChild,
|
164
174
|
Node,
|
165
175
|
NodeErrorOptions,
|
166
176
|
NodeProps,
|
@@ -176,9 +186,9 @@ declare namespace postcss {
|
|
176
186
|
WarningOptions
|
177
187
|
}
|
178
188
|
|
179
|
-
export type SourceMap =
|
189
|
+
export type SourceMap = {
|
180
190
|
toJSON(): RawSourceMap
|
181
|
-
}
|
191
|
+
} & SourceMapGenerator
|
182
192
|
|
183
193
|
export type Helpers = { postcss: Postcss; result: Result } & Postcss
|
184
194
|
|
@@ -309,7 +319,7 @@ declare namespace postcss {
|
|
309
319
|
* The path of the CSS source file. You should always set `from`,
|
310
320
|
* because it is used in source map generation and syntax error messages.
|
311
321
|
*/
|
312
|
-
from?: string
|
322
|
+
from?: string | undefined
|
313
323
|
|
314
324
|
/**
|
315
325
|
* Source map options
|
@@ -435,7 +445,9 @@ declare namespace postcss {
|
|
435
445
|
* @param plugins PostCSS plugins.
|
436
446
|
* @return Processor to process multiple CSS.
|
437
447
|
*/
|
438
|
-
declare function postcss(
|
448
|
+
declare function postcss(
|
449
|
+
plugins?: readonly postcss.AcceptedPlugin[]
|
450
|
+
): Processor
|
439
451
|
declare function postcss(...plugins: postcss.AcceptedPlugin[]): Processor
|
440
452
|
|
441
453
|
export = postcss
|
package/lib/postcss.js
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
'use strict'
|
2
2
|
|
3
|
+
let AtRule = require('./at-rule')
|
4
|
+
let Comment = require('./comment')
|
5
|
+
let Container = require('./container')
|
3
6
|
let CssSyntaxError = require('./css-syntax-error')
|
4
7
|
let Declaration = require('./declaration')
|
5
|
-
let LazyResult = require('./lazy-result')
|
6
|
-
let Container = require('./container')
|
7
|
-
let Processor = require('./processor')
|
8
|
-
let stringify = require('./stringify')
|
9
|
-
let fromJSON = require('./fromJSON')
|
10
8
|
let Document = require('./document')
|
11
|
-
let
|
12
|
-
let Comment = require('./comment')
|
13
|
-
let AtRule = require('./at-rule')
|
14
|
-
let Result = require('./result.js')
|
9
|
+
let fromJSON = require('./fromJSON')
|
15
10
|
let Input = require('./input')
|
16
|
-
let
|
11
|
+
let LazyResult = require('./lazy-result')
|
17
12
|
let list = require('./list')
|
18
|
-
let Rule = require('./rule')
|
19
|
-
let Root = require('./root')
|
20
13
|
let Node = require('./node')
|
14
|
+
let parse = require('./parse')
|
15
|
+
let Processor = require('./processor')
|
16
|
+
let Result = require('./result.js')
|
17
|
+
let Root = require('./root')
|
18
|
+
let Rule = require('./rule')
|
19
|
+
let stringify = require('./stringify')
|
20
|
+
let Warning = require('./warning')
|
21
21
|
|
22
22
|
function postcss(...plugins) {
|
23
23
|
if (plugins.length === 1 && Array.isArray(plugins[0])) {
|
package/lib/previous-map.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
'use strict'
|
2
2
|
|
3
|
-
let { SourceMapConsumer, SourceMapGenerator } = require('source-map-js')
|
4
3
|
let { existsSync, readFileSync } = require('fs')
|
5
4
|
let { dirname, join } = require('path')
|
5
|
+
let { SourceMapConsumer, SourceMapGenerator } = require('source-map-js')
|
6
6
|
|
7
7
|
function fromBase64(str) {
|
8
8
|
if (Buffer) {
|
@@ -41,12 +41,14 @@ class PreviousMap {
|
|
41
41
|
let charsetUri = /^data:application\/json;charset=utf-?8,/
|
42
42
|
let uri = /^data:application\/json,/
|
43
43
|
|
44
|
-
|
45
|
-
|
44
|
+
let uriMatch = text.match(charsetUri) || text.match(uri)
|
45
|
+
if (uriMatch) {
|
46
|
+
return decodeURIComponent(text.substr(uriMatch[0].length))
|
46
47
|
}
|
47
48
|
|
48
|
-
|
49
|
-
|
49
|
+
let baseUriMatch = text.match(baseCharsetUri) || text.match(baseUri)
|
50
|
+
if (baseUriMatch) {
|
51
|
+
return fromBase64(text.substr(baseUriMatch[0].length))
|
50
52
|
}
|
51
53
|
|
52
54
|
let encoding = text.match(/data:application\/json;([^,]+),/)[1]
|
@@ -67,7 +69,7 @@ class PreviousMap {
|
|
67
69
|
}
|
68
70
|
|
69
71
|
loadAnnotation(css) {
|
70
|
-
let comments = css.match(/\/\*\s*# sourceMappingURL=/
|
72
|
+
let comments = css.match(/\/\*\s*# sourceMappingURL=/g)
|
71
73
|
if (!comments) return
|
72
74
|
|
73
75
|
// sourceMappingURLs from comments, strings, etc.
|
package/lib/processor.d.ts
CHANGED
package/lib/processor.js
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
'use strict'
|
2
2
|
|
3
|
-
let NoWorkResult = require('./no-work-result')
|
4
|
-
let LazyResult = require('./lazy-result')
|
5
3
|
let Document = require('./document')
|
4
|
+
let LazyResult = require('./lazy-result')
|
5
|
+
let NoWorkResult = require('./no-work-result')
|
6
6
|
let Root = require('./root')
|
7
7
|
|
8
8
|
class Processor {
|
9
9
|
constructor(plugins = []) {
|
10
|
-
this.version = '8.4.
|
10
|
+
this.version = '8.4.49'
|
11
11
|
this.plugins = this.normalize(plugins)
|
12
12
|
}
|
13
13
|
|
@@ -43,10 +43,10 @@ class Processor {
|
|
43
43
|
|
44
44
|
process(css, opts = {}) {
|
45
45
|
if (
|
46
|
-
this.plugins.length
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
!this.plugins.length &&
|
47
|
+
!opts.parser &&
|
48
|
+
!opts.stringifier &&
|
49
|
+
!opts.syntax
|
50
50
|
) {
|
51
51
|
return new NoWorkResult(this, css, opts)
|
52
52
|
} else {
|
package/lib/result.d.ts
CHANGED
package/lib/root.d.ts
CHANGED
@@ -54,6 +54,7 @@ declare namespace Root {
|
|
54
54
|
* ```
|
55
55
|
*/
|
56
56
|
declare class Root_ extends Container {
|
57
|
+
nodes: NonNullable<Container['nodes']>
|
57
58
|
parent: Document | undefined
|
58
59
|
raws: Root.RootRaws
|
59
60
|
type: 'root'
|
@@ -61,9 +62,9 @@ declare class Root_ extends Container {
|
|
61
62
|
constructor(defaults?: Root.RootProps)
|
62
63
|
|
63
64
|
assign(overrides: object | Root.RootProps): this
|
64
|
-
clone(overrides?: Partial<Root.RootProps>):
|
65
|
-
cloneAfter(overrides?: Partial<Root.RootProps>):
|
66
|
-
cloneBefore(overrides?: Partial<Root.RootProps>):
|
65
|
+
clone(overrides?: Partial<Root.RootProps>): this
|
66
|
+
cloneAfter(overrides?: Partial<Root.RootProps>): this
|
67
|
+
cloneBefore(overrides?: Partial<Root.RootProps>): this
|
67
68
|
|
68
69
|
/**
|
69
70
|
* Returns a `Result` instance representing the root’s CSS.
|
@@ -75,7 +76,7 @@ declare class Root_ extends Container {
|
|
75
76
|
* const result = root1.toResult({ to: 'all.css', map: true })
|
76
77
|
* ```
|
77
78
|
*
|
78
|
-
* @param
|
79
|
+
* @param options Options.
|
79
80
|
* @return Result with current root’s CSS.
|
80
81
|
*/
|
81
82
|
toResult(options?: ProcessOptions): Result
|