postcss 8.4.41 → 8.4.42
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/container.d.ts +44 -51
- package/lib/container.js +3 -3
- package/lib/css-syntax-error.js +47 -14
- package/lib/document.d.ts +1 -1
- package/lib/fromJSON.js +3 -3
- package/lib/input.d.ts +3 -3
- package/lib/input.js +4 -4
- package/lib/lazy-result.js +10 -10
- package/lib/list.d.ts +5 -1
- package/lib/map-generator.js +3 -3
- package/lib/no-work-result.js +2 -2
- package/lib/node.d.ts +16 -11
- package/lib/node.js +5 -1
- package/lib/parse.js +1 -1
- package/lib/parser.js +6 -6
- package/lib/postcss.d.ts +5 -2
- package/lib/postcss.js +12 -12
- package/lib/previous-map.js +1 -1
- package/lib/processor.d.ts +1 -1
- package/lib/processor.js +3 -3
- package/lib/root.d.ts +1 -1
- package/lib/rule.d.ts +4 -4
- package/lib/tokenize.js +2 -2
- package/package.json +1 -1
package/lib/container.d.ts
CHANGED
@@ -20,13 +20,26 @@ declare namespace Container {
|
|
20
20
|
/**
|
21
21
|
* An array of property names.
|
22
22
|
*/
|
23
|
-
props?: string[]
|
23
|
+
props?: readonly string[]
|
24
24
|
}
|
25
25
|
|
26
26
|
export interface ContainerProps extends NodeProps {
|
27
|
-
nodes?: (
|
27
|
+
nodes?: readonly (ChildProps | Node)[]
|
28
28
|
}
|
29
29
|
|
30
|
+
/**
|
31
|
+
* All types that can be passed into container methods to create or add a new
|
32
|
+
* child node.
|
33
|
+
*/
|
34
|
+
export type NewChild =
|
35
|
+
| ChildProps
|
36
|
+
| Node
|
37
|
+
| readonly ChildProps[]
|
38
|
+
| readonly Node[]
|
39
|
+
| readonly string[]
|
40
|
+
| string
|
41
|
+
| undefined
|
42
|
+
|
30
43
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
31
44
|
export { Container_ as default }
|
32
45
|
}
|
@@ -51,6 +64,26 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
51
64
|
*/
|
52
65
|
nodes: Child[] | undefined
|
53
66
|
|
67
|
+
/**
|
68
|
+
* An internal method that converts a {@link NewChild} into a list of actual
|
69
|
+
* child nodes that can then be added to this container.
|
70
|
+
*
|
71
|
+
* This ensures that the nodes' parent is set to this container, that they use
|
72
|
+
* the correct prototype chain, and that they're marked as dirty.
|
73
|
+
*
|
74
|
+
* @param mnodes The new node or nodes to add.
|
75
|
+
* @param sample A node from whose raws the new node's `before` raw should be
|
76
|
+
* taken.
|
77
|
+
* @param type This should be set to `'prepend'` if the new nodes will be
|
78
|
+
* inserted at the beginning of the container.
|
79
|
+
* @hidden
|
80
|
+
*/
|
81
|
+
protected normalize(
|
82
|
+
nodes: Container.NewChild,
|
83
|
+
sample: Node | undefined,
|
84
|
+
type?: 'prepend' | false
|
85
|
+
): Child[]
|
86
|
+
|
54
87
|
/**
|
55
88
|
* Inserts new nodes to the end of the container.
|
56
89
|
*
|
@@ -71,21 +104,11 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
71
104
|
* @param nodes New nodes.
|
72
105
|
* @return This node for methods chain.
|
73
106
|
*/
|
74
|
-
append(
|
75
|
-
...nodes: (
|
76
|
-
| ChildProps
|
77
|
-
| ChildProps[]
|
78
|
-
| Node
|
79
|
-
| Node[]
|
80
|
-
| string
|
81
|
-
| string[]
|
82
|
-
| undefined
|
83
|
-
)[]
|
84
|
-
): this
|
85
|
-
|
107
|
+
append(...nodes: Container.NewChild[]): this
|
86
108
|
assign(overrides: Container.ContainerProps | object): this
|
87
109
|
clone(overrides?: Partial<Container.ContainerProps>): this
|
88
110
|
cloneAfter(overrides?: Partial<Container.ContainerProps>): this
|
111
|
+
|
89
112
|
cloneBefore(overrides?: Partial<Container.ContainerProps>): this
|
90
113
|
|
91
114
|
/**
|
@@ -124,7 +147,6 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
124
147
|
each(
|
125
148
|
callback: (node: Child, index: number) => false | void
|
126
149
|
): false | undefined
|
127
|
-
|
128
150
|
/**
|
129
151
|
* Returns `true` if callback returns `true`
|
130
152
|
* for all of the container’s children.
|
@@ -139,6 +161,7 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
139
161
|
every(
|
140
162
|
condition: (node: Child, index: number, nodes: Child[]) => boolean
|
141
163
|
): boolean
|
164
|
+
|
142
165
|
/**
|
143
166
|
* Returns a `child`’s index within the `Container#nodes` array.
|
144
167
|
*
|
@@ -150,7 +173,6 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
150
173
|
* @return Child index.
|
151
174
|
*/
|
152
175
|
index(child: Child | number): number
|
153
|
-
|
154
176
|
/**
|
155
177
|
* Insert new node after old node within the container.
|
156
178
|
*
|
@@ -158,17 +180,8 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
158
180
|
* @param newNode New node.
|
159
181
|
* @return This node for methods chain.
|
160
182
|
*/
|
161
|
-
insertAfter(
|
162
|
-
|
163
|
-
newNode:
|
164
|
-
| Node
|
165
|
-
| Node[]
|
166
|
-
| ChildProps
|
167
|
-
| ChildProps[]
|
168
|
-
| string
|
169
|
-
| string[]
|
170
|
-
| undefined
|
171
|
-
): this
|
183
|
+
insertAfter(oldNode: Child | number, newNode: Container.NewChild): this
|
184
|
+
|
172
185
|
/**
|
173
186
|
* Insert new node before old node within the container.
|
174
187
|
*
|
@@ -180,17 +193,7 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
180
193
|
* @param newNode New node.
|
181
194
|
* @return This node for methods chain.
|
182
195
|
*/
|
183
|
-
insertBefore(
|
184
|
-
oldNode: Child | number,
|
185
|
-
newNode:
|
186
|
-
| Node
|
187
|
-
| Node[]
|
188
|
-
| ChildProps
|
189
|
-
| ChildProps[]
|
190
|
-
| string
|
191
|
-
| string[]
|
192
|
-
| undefined
|
193
|
-
): this
|
196
|
+
insertBefore(oldNode: Child | number, newNode: Container.NewChild): this
|
194
197
|
|
195
198
|
/**
|
196
199
|
* Traverses the container’s descendant nodes, calling callback
|
@@ -229,17 +232,7 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
229
232
|
* @param nodes New nodes.
|
230
233
|
* @return This node for methods chain.
|
231
234
|
*/
|
232
|
-
prepend(
|
233
|
-
...nodes: (
|
234
|
-
| ChildProps
|
235
|
-
| ChildProps[]
|
236
|
-
| Node
|
237
|
-
| Node[]
|
238
|
-
| string
|
239
|
-
| string[]
|
240
|
-
| undefined
|
241
|
-
)[]
|
242
|
-
): this
|
235
|
+
prepend(...nodes: Container.NewChild[]): this
|
243
236
|
/**
|
244
237
|
* Add child to the end of the node.
|
245
238
|
*
|
@@ -301,8 +294,8 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
301
294
|
* ```
|
302
295
|
*
|
303
296
|
* @param pattern Replace pattern.
|
304
|
-
* @param {object}
|
305
|
-
* @param
|
297
|
+
* @param {object} options Options to speed up the search.
|
298
|
+
* @param replaced String to replace pattern or callback
|
306
299
|
* that returns a new value. The callback
|
307
300
|
* will receive the same arguments
|
308
301
|
* as those passed to a function parameter
|
package/lib/container.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
'use strict'
|
2
2
|
|
3
|
-
let { isClean, my } = require('./symbols')
|
4
|
-
let Declaration = require('./declaration')
|
5
3
|
let Comment = require('./comment')
|
4
|
+
let Declaration = require('./declaration')
|
6
5
|
let Node = require('./node')
|
6
|
+
let { isClean, my } = require('./symbols')
|
7
7
|
|
8
|
-
let
|
8
|
+
let AtRule, parse, Root, Rule
|
9
9
|
|
10
10
|
function cleanSource(nodes) {
|
11
11
|
return nodes.map(i => {
|
package/lib/css-syntax-error.js
CHANGED
@@ -52,37 +52,70 @@ class CssSyntaxError extends Error {
|
|
52
52
|
|
53
53
|
let css = this.source
|
54
54
|
if (color == null) color = pico.isColorSupported
|
55
|
-
if (terminalHighlight) {
|
56
|
-
if (color) css = terminalHighlight(css)
|
57
|
-
}
|
58
|
-
|
59
|
-
let lines = css.split(/\r?\n/)
|
60
|
-
let start = Math.max(this.line - 3, 0)
|
61
|
-
let end = Math.min(this.line + 2, lines.length)
|
62
55
|
|
63
|
-
let
|
64
|
-
|
65
|
-
let
|
56
|
+
let aside = text => text
|
57
|
+
let mark = text => text
|
58
|
+
let highlight = text => text
|
66
59
|
if (color) {
|
67
60
|
let { bold, gray, red } = pico.createColors(true)
|
68
61
|
mark = text => bold(red(text))
|
69
62
|
aside = text => gray(text)
|
70
|
-
|
71
|
-
|
63
|
+
if (terminalHighlight) {
|
64
|
+
highlight = text => terminalHighlight(text)
|
65
|
+
}
|
72
66
|
}
|
73
67
|
|
68
|
+
let lines = css.split(/\r?\n/)
|
69
|
+
let start = Math.max(this.line - 3, 0)
|
70
|
+
let end = Math.min(this.line + 2, lines.length)
|
71
|
+
let maxWidth = String(end).length
|
72
|
+
|
74
73
|
return lines
|
75
74
|
.slice(start, end)
|
76
75
|
.map((line, index) => {
|
77
76
|
let number = start + 1 + index
|
78
77
|
let gutter = ' ' + (' ' + number).slice(-maxWidth) + ' | '
|
79
78
|
if (number === this.line) {
|
79
|
+
if (line.length > 160) {
|
80
|
+
let padding = 20
|
81
|
+
let subLineStart = Math.max(0, this.column - padding)
|
82
|
+
let subLineEnd = Math.max(
|
83
|
+
this.column + padding,
|
84
|
+
this.endColumn + padding
|
85
|
+
)
|
86
|
+
let subLine = line.slice(subLineStart, subLineEnd)
|
87
|
+
|
88
|
+
let spacing =
|
89
|
+
aside(gutter.replace(/\d/g, ' ')) +
|
90
|
+
line
|
91
|
+
.slice(0, Math.min(this.column - 1, padding - 1))
|
92
|
+
.replace(/[^\t]/g, ' ')
|
93
|
+
|
94
|
+
return (
|
95
|
+
mark('>') +
|
96
|
+
aside(gutter) +
|
97
|
+
highlight(subLine) +
|
98
|
+
'\n ' +
|
99
|
+
spacing +
|
100
|
+
mark('^')
|
101
|
+
)
|
102
|
+
}
|
103
|
+
|
80
104
|
let spacing =
|
81
105
|
aside(gutter.replace(/\d/g, ' ')) +
|
82
106
|
line.slice(0, this.column - 1).replace(/[^\t]/g, ' ')
|
83
|
-
|
107
|
+
|
108
|
+
return (
|
109
|
+
mark('>') +
|
110
|
+
aside(gutter) +
|
111
|
+
highlight(line) +
|
112
|
+
'\n ' +
|
113
|
+
spacing +
|
114
|
+
mark('^')
|
115
|
+
)
|
84
116
|
}
|
85
|
-
|
117
|
+
|
118
|
+
return ' ' + aside(gutter) + highlight(line)
|
86
119
|
})
|
87
120
|
.join('\n')
|
88
121
|
}
|
package/lib/document.d.ts
CHANGED
package/lib/fromJSON.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
'use strict'
|
2
2
|
|
3
|
-
let Declaration = require('./declaration')
|
4
|
-
let PreviousMap = require('./previous-map')
|
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 Input = require('./input')
|
7
|
+
let PreviousMap = require('./previous-map')
|
8
8
|
let Root = require('./root')
|
9
9
|
let Rule = require('./rule')
|
10
10
|
|
package/lib/input.d.ts
CHANGED
@@ -174,6 +174,9 @@ declare class Input_ {
|
|
174
174
|
endLine?: number,
|
175
175
|
endColumn?: number
|
176
176
|
): false | Input.FilePosition
|
177
|
+
/** Converts this to a JSON-friendly object representation. */
|
178
|
+
toJSON(): object
|
179
|
+
|
177
180
|
/**
|
178
181
|
* The CSS source identifier. Contains `Input#file` if the user
|
179
182
|
* set the `from` option, or `Input#id` if they did not.
|
@@ -187,9 +190,6 @@ declare class Input_ {
|
|
187
190
|
* ```
|
188
191
|
*/
|
189
192
|
get from(): string
|
190
|
-
|
191
|
-
/** Converts this to a JSON-friendly object representation. */
|
192
|
-
toJSON(): object
|
193
193
|
}
|
194
194
|
|
195
195
|
declare class Input extends Input_ {}
|
package/lib/input.js
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
'use strict'
|
2
2
|
|
3
|
+
let { nanoid } = require('nanoid/non-secure')
|
4
|
+
let { isAbsolute, resolve } = require('path')
|
3
5
|
let { SourceMapConsumer, SourceMapGenerator } = require('source-map-js')
|
4
6
|
let { fileURLToPath, pathToFileURL } = require('url')
|
5
|
-
let { isAbsolute, resolve } = require('path')
|
6
|
-
let { nanoid } = require('nanoid/non-secure')
|
7
7
|
|
8
|
-
let terminalHighlight = require('./terminal-highlight')
|
9
8
|
let CssSyntaxError = require('./css-syntax-error')
|
10
9
|
let PreviousMap = require('./previous-map')
|
10
|
+
let terminalHighlight = require('./terminal-highlight')
|
11
11
|
|
12
12
|
let fromOffsetCache = Symbol('fromOffsetCache')
|
13
13
|
|
@@ -61,7 +61,7 @@ class Input {
|
|
61
61
|
}
|
62
62
|
|
63
63
|
error(message, line, column, opts = {}) {
|
64
|
-
let
|
64
|
+
let endColumn, endLine, result
|
65
65
|
|
66
66
|
if (line && typeof line === 'object') {
|
67
67
|
let start = line
|
package/lib/lazy-result.js
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
'use strict'
|
2
2
|
|
3
|
-
let { isClean, my } = require('./symbols')
|
4
|
-
let MapGenerator = require('./map-generator')
|
5
|
-
let stringify = require('./stringify')
|
6
3
|
let Container = require('./container')
|
7
4
|
let Document = require('./document')
|
8
|
-
let
|
9
|
-
let Result = require('./result')
|
5
|
+
let MapGenerator = require('./map-generator')
|
10
6
|
let parse = require('./parse')
|
7
|
+
let Result = require('./result')
|
11
8
|
let Root = require('./root')
|
9
|
+
let stringify = require('./stringify')
|
10
|
+
let { isClean, my } = require('./symbols')
|
11
|
+
let warnOnce = require('./warn-once')
|
12
12
|
|
13
13
|
const TYPE_TO_CLASS_NAME = {
|
14
14
|
atrule: 'AtRule',
|
@@ -269,7 +269,7 @@ class LazyResult {
|
|
269
269
|
if (this.hasListener) {
|
270
270
|
let root = this.result.root
|
271
271
|
while (!root[isClean]) {
|
272
|
-
root
|
272
|
+
root.markClean()
|
273
273
|
let stack = [toStack(root)]
|
274
274
|
while (stack.length > 0) {
|
275
275
|
let promise = this.visitTick(stack)
|
@@ -374,7 +374,7 @@ class LazyResult {
|
|
374
374
|
if (this.hasListener) {
|
375
375
|
let root = this.result.root
|
376
376
|
while (!root[isClean]) {
|
377
|
-
root
|
377
|
+
root.markClean()
|
378
378
|
this.walkSync(root)
|
379
379
|
}
|
380
380
|
if (this.listeners.OnceExit) {
|
@@ -456,7 +456,7 @@ class LazyResult {
|
|
456
456
|
while ((child = node.nodes[node.indexes[iterator]])) {
|
457
457
|
node.indexes[iterator] += 1
|
458
458
|
if (!child[isClean]) {
|
459
|
-
child
|
459
|
+
child.markClean()
|
460
460
|
stack.push(toStack(child))
|
461
461
|
return
|
462
462
|
}
|
@@ -471,7 +471,7 @@ class LazyResult {
|
|
471
471
|
visit.eventIndex += 1
|
472
472
|
if (event === CHILDREN) {
|
473
473
|
if (node.nodes && node.nodes.length) {
|
474
|
-
node
|
474
|
+
node.markClean()
|
475
475
|
visit.iterator = node.getIterator()
|
476
476
|
}
|
477
477
|
return
|
@@ -484,7 +484,7 @@ class LazyResult {
|
|
484
484
|
}
|
485
485
|
|
486
486
|
walkSync(node) {
|
487
|
-
node
|
487
|
+
node.markClean()
|
488
488
|
let events = getEvents(node)
|
489
489
|
for (let event of events) {
|
490
490
|
if (event === CHILDREN) {
|
package/lib/list.d.ts
CHANGED
@@ -47,7 +47,11 @@ declare namespace list {
|
|
47
47
|
* @param last boolean indicator.
|
48
48
|
* @return Split values.
|
49
49
|
*/
|
50
|
-
split(
|
50
|
+
split(
|
51
|
+
string: string,
|
52
|
+
separators: readonly string[],
|
53
|
+
last: boolean
|
54
|
+
): string[]
|
51
55
|
}
|
52
56
|
}
|
53
57
|
|
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')
|
@@ -70,7 +70,7 @@ class MapGenerator {
|
|
70
70
|
for (let i = this.root.nodes.length - 1; i >= 0; i--) {
|
71
71
|
node = this.root.nodes[i]
|
72
72
|
if (node.type !== 'comment') continue
|
73
|
-
if (node.text.
|
73
|
+
if (node.text.startsWith('# sourceMappingURL=')) {
|
74
74
|
this.root.removeChild(i)
|
75
75
|
}
|
76
76
|
}
|
@@ -143,7 +143,7 @@ class MapGenerator {
|
|
143
143
|
source: ''
|
144
144
|
}
|
145
145
|
|
146
|
-
let
|
146
|
+
let last, lines
|
147
147
|
this.stringify(this.root, (str, node, type) => {
|
148
148
|
this.css += str
|
149
149
|
|
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) {
|
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.
|
@@ -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
|
476
|
-
| Node[]
|
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.
|
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()
|
@@ -153,6 +153,10 @@ class Node {
|
|
153
153
|
}
|
154
154
|
}
|
155
155
|
|
156
|
+
markClean() {
|
157
|
+
this[isClean] = true;
|
158
|
+
}
|
159
|
+
|
156
160
|
markDirty() {
|
157
161
|
if (this[isClean]) {
|
158
162
|
this[isClean] = false
|
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,
|
@@ -143,7 +143,7 @@ class Parser {
|
|
143
143
|
|
144
144
|
colon(tokens) {
|
145
145
|
let brackets = 0
|
146
|
-
let token, type
|
146
|
+
let prev, token, type
|
147
147
|
for (let [i, element] of tokens.entries()) {
|
148
148
|
token = element
|
149
149
|
type = token[0]
|
@@ -267,12 +267,12 @@ class Parser {
|
|
267
267
|
let str = ''
|
268
268
|
for (let j = i; j > 0; j--) {
|
269
269
|
let type = cache[j][0]
|
270
|
-
if (str.trim().
|
270
|
+
if (str.trim().startsWith('!') && type !== 'space') {
|
271
271
|
break
|
272
272
|
}
|
273
273
|
str = cache.pop()[1] + str
|
274
274
|
}
|
275
|
-
if (str.trim().
|
275
|
+
if (str.trim().startsWith('!')) {
|
276
276
|
node.important = true
|
277
277
|
node.raws.important = str
|
278
278
|
tokens = cache
|
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'
|
@@ -170,6 +170,7 @@ declare namespace postcss {
|
|
170
170
|
LazyResult,
|
171
171
|
list,
|
172
172
|
Message,
|
173
|
+
NewChild,
|
173
174
|
Node,
|
174
175
|
NodeErrorOptions,
|
175
176
|
NodeProps,
|
@@ -444,7 +445,9 @@ declare namespace postcss {
|
|
444
445
|
* @param plugins PostCSS plugins.
|
445
446
|
* @return Processor to process multiple CSS.
|
446
447
|
*/
|
447
|
-
declare function postcss(
|
448
|
+
declare function postcss(
|
449
|
+
plugins?: readonly postcss.AcceptedPlugin[]
|
450
|
+
): Processor
|
448
451
|
declare function postcss(...plugins: postcss.AcceptedPlugin[]): Processor
|
449
452
|
|
450
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) {
|
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.42'
|
11
11
|
this.plugins = this.normalize(plugins)
|
12
12
|
}
|
13
13
|
|
package/lib/root.d.ts
CHANGED
@@ -76,7 +76,7 @@ declare class Root_ extends Container {
|
|
76
76
|
* const result = root1.toResult({ to: 'all.css', map: true })
|
77
77
|
* ```
|
78
78
|
*
|
79
|
-
* @param
|
79
|
+
* @param options Options.
|
80
80
|
* @return Result with current root’s CSS.
|
81
81
|
*/
|
82
82
|
toResult(options?: ProcessOptions): Result
|
package/lib/rule.d.ts
CHANGED
@@ -40,7 +40,7 @@ declare namespace Rule {
|
|
40
40
|
semicolon?: boolean
|
41
41
|
}
|
42
42
|
|
43
|
-
export type RuleProps =
|
43
|
+
export type RuleProps = {
|
44
44
|
/** Information used to generate byte-to-byte equal node string as it was in the origin input. */
|
45
45
|
raws?: RuleRaws
|
46
46
|
} & (
|
@@ -50,11 +50,11 @@ declare namespace Rule {
|
|
50
50
|
selectors?: never
|
51
51
|
}
|
52
52
|
| {
|
53
|
-
/** Selectors of the rule represented as an array of strings. */
|
54
|
-
selectors: string[]
|
55
53
|
selector?: never
|
54
|
+
/** Selectors of the rule represented as an array of strings. */
|
55
|
+
selectors: readonly string[]
|
56
56
|
}
|
57
|
-
)
|
57
|
+
) & ContainerProps
|
58
58
|
|
59
59
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
60
60
|
export { Rule_ as default }
|
package/lib/tokenize.js
CHANGED
@@ -29,8 +29,8 @@ module.exports = function tokenizer(input, options = {}) {
|
|
29
29
|
let css = input.css.valueOf()
|
30
30
|
let ignore = options.ignoreErrors
|
31
31
|
|
32
|
-
let code,
|
33
|
-
let escaped, escapePos,
|
32
|
+
let code, content, escape, next, quote
|
33
|
+
let currentToken, escaped, escapePos, n, prev
|
34
34
|
|
35
35
|
let length = css.length
|
36
36
|
let pos = 0
|