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/README.md
CHANGED
@@ -13,7 +13,7 @@ and JetBrains. The [Autoprefixer] and [Stylelint] PostCSS plugins is one of
|
|
13
13
|
|
14
14
|
---
|
15
15
|
|
16
|
-
<img src="https://cdn.evilmartians.com/badges/logo-no-label.svg" alt="" width="22" height="16" /> Made
|
16
|
+
<img src="https://cdn.evilmartians.com/badges/logo-no-label.svg" alt="" width="22" height="16" /> Made at <b><a href="https://evilmartians.com/devtools?utm_source=postcss&utm_campaign=devtools-button&utm_medium=github">Evil Martians</a></b>, product consulting for <b>developer tools</b>.
|
17
17
|
|
18
18
|
---
|
19
19
|
|
package/lib/at-rule.d.ts
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
import Container, {
|
1
|
+
import Container, {
|
2
|
+
ContainerProps,
|
3
|
+
ContainerWithChildren
|
4
|
+
} from './container.js'
|
2
5
|
|
3
6
|
declare namespace AtRule {
|
4
7
|
export interface AtRuleRaws extends Record<string, unknown> {
|
@@ -76,16 +79,48 @@ declare namespace AtRule {
|
|
76
79
|
* ```
|
77
80
|
*/
|
78
81
|
declare class AtRule_ extends Container {
|
82
|
+
/**
|
83
|
+
* An array containing the layer’s children.
|
84
|
+
*
|
85
|
+
* ```js
|
86
|
+
* const root = postcss.parse('@layer example { a { color: black } }')
|
87
|
+
* const layer = root.first
|
88
|
+
* layer.nodes.length //=> 1
|
89
|
+
* layer.nodes[0].selector //=> 'a'
|
90
|
+
* ```
|
91
|
+
*
|
92
|
+
* Can be `undefinded` if the at-rule has no body.
|
93
|
+
*
|
94
|
+
* ```js
|
95
|
+
* const root = postcss.parse('@layer a, b, c;')
|
96
|
+
* const layer = root.first
|
97
|
+
* layer.nodes //=> undefined
|
98
|
+
* ```
|
99
|
+
*/
|
100
|
+
nodes: Container['nodes']
|
101
|
+
parent: ContainerWithChildren | undefined
|
102
|
+
|
103
|
+
raws: AtRule.AtRuleRaws
|
104
|
+
type: 'atrule'
|
105
|
+
constructor(defaults?: AtRule.AtRuleProps)
|
106
|
+
assign(overrides: AtRule.AtRuleProps | object): this
|
107
|
+
|
108
|
+
clone(overrides?: Partial<AtRule.AtRuleProps>): this
|
109
|
+
|
110
|
+
cloneAfter(overrides?: Partial<AtRule.AtRuleProps>): this
|
111
|
+
|
112
|
+
cloneBefore(overrides?: Partial<AtRule.AtRuleProps>): this
|
79
113
|
/**
|
80
114
|
* The at-rule’s name immediately follows the `@`.
|
81
115
|
*
|
82
116
|
* ```js
|
83
117
|
* const root = postcss.parse('@media print {}')
|
84
|
-
* media.name //=> 'media'
|
85
118
|
* const media = root.first
|
119
|
+
* media.name //=> 'media'
|
86
120
|
* ```
|
87
121
|
*/
|
88
|
-
name: string
|
122
|
+
get name(): string
|
123
|
+
set name(value: string)
|
89
124
|
/**
|
90
125
|
* The at-rule’s parameters, the values that follow the at-rule’s name
|
91
126
|
* but precede any `{}` block.
|
@@ -96,18 +131,8 @@ declare class AtRule_ extends Container {
|
|
96
131
|
* media.params //=> 'print, screen'
|
97
132
|
* ```
|
98
133
|
*/
|
99
|
-
params: string
|
100
|
-
|
101
|
-
|
102
|
-
raws: AtRule.AtRuleRaws
|
103
|
-
|
104
|
-
type: 'atrule'
|
105
|
-
|
106
|
-
constructor(defaults?: AtRule.AtRuleProps)
|
107
|
-
assign(overrides: AtRule.AtRuleProps | object): this
|
108
|
-
clone(overrides?: Partial<AtRule.AtRuleProps>): AtRule
|
109
|
-
cloneAfter(overrides?: Partial<AtRule.AtRuleProps>): AtRule
|
110
|
-
cloneBefore(overrides?: Partial<AtRule.AtRuleProps>): AtRule
|
134
|
+
get params(): string
|
135
|
+
set params(value: string)
|
111
136
|
}
|
112
137
|
|
113
138
|
declare class AtRule extends AtRule_ {}
|
package/lib/comment.d.ts
CHANGED
@@ -48,18 +48,19 @@ declare namespace Comment {
|
|
48
48
|
declare class Comment_ extends Node {
|
49
49
|
parent: Container | undefined
|
50
50
|
raws: Comment.CommentRaws
|
51
|
-
/**
|
52
|
-
* The comment's text.
|
53
|
-
*/
|
54
|
-
text: string
|
55
|
-
|
56
51
|
type: 'comment'
|
57
|
-
|
58
52
|
constructor(defaults?: Comment.CommentProps)
|
53
|
+
|
59
54
|
assign(overrides: Comment.CommentProps | object): this
|
60
|
-
|
61
|
-
|
62
|
-
|
55
|
+
|
56
|
+
clone(overrides?: Partial<Comment.CommentProps>): this
|
57
|
+
cloneAfter(overrides?: Partial<Comment.CommentProps>): this
|
58
|
+
cloneBefore(overrides?: Partial<Comment.CommentProps>): this
|
59
|
+
/**
|
60
|
+
* The comment's text.
|
61
|
+
*/
|
62
|
+
get text(): string
|
63
|
+
set text(value: string)
|
63
64
|
}
|
64
65
|
|
65
66
|
declare class Comment extends Comment_ {}
|
package/lib/container.d.ts
CHANGED
@@ -5,6 +5,12 @@ import Node, { ChildNode, ChildProps, NodeProps } from './node.js'
|
|
5
5
|
import Rule from './rule.js'
|
6
6
|
|
7
7
|
declare namespace Container {
|
8
|
+
export class ContainerWithChildren<
|
9
|
+
Child extends Node = ChildNode
|
10
|
+
> extends Container_<Child> {
|
11
|
+
nodes: Child[]
|
12
|
+
}
|
13
|
+
|
8
14
|
export interface ValueOptions {
|
9
15
|
/**
|
10
16
|
* String that’s used to narrow down values and speed up the regexp search.
|
@@ -14,13 +20,26 @@ declare namespace Container {
|
|
14
20
|
/**
|
15
21
|
* An array of property names.
|
16
22
|
*/
|
17
|
-
props?: string[]
|
23
|
+
props?: readonly string[]
|
18
24
|
}
|
19
25
|
|
20
26
|
export interface ContainerProps extends NodeProps {
|
21
|
-
nodes?: (
|
27
|
+
nodes?: readonly (ChildProps | Node)[]
|
22
28
|
}
|
23
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
|
+
|
24
43
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
25
44
|
export { Container_ as default }
|
26
45
|
}
|
@@ -43,7 +62,27 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
43
62
|
* root.nodes[0].nodes[0].prop //=> 'color'
|
44
63
|
* ```
|
45
64
|
*/
|
46
|
-
nodes: Child[]
|
65
|
+
nodes: Child[] | undefined
|
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[]
|
47
86
|
|
48
87
|
/**
|
49
88
|
* Inserts new nodes to the end of the container.
|
@@ -65,14 +104,12 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
65
104
|
* @param nodes New nodes.
|
66
105
|
* @return This node for methods chain.
|
67
106
|
*/
|
68
|
-
append(
|
69
|
-
...nodes: (ChildProps | ChildProps[] | Node | Node[] | string | string[])[]
|
70
|
-
): this
|
71
|
-
|
107
|
+
append(...nodes: Container.NewChild[]): this
|
72
108
|
assign(overrides: Container.ContainerProps | object): this
|
73
|
-
clone(overrides?: Partial<Container.ContainerProps>):
|
74
|
-
cloneAfter(overrides?: Partial<Container.ContainerProps>):
|
75
|
-
|
109
|
+
clone(overrides?: Partial<Container.ContainerProps>): this
|
110
|
+
cloneAfter(overrides?: Partial<Container.ContainerProps>): this
|
111
|
+
|
112
|
+
cloneBefore(overrides?: Partial<Container.ContainerProps>): this
|
76
113
|
|
77
114
|
/**
|
78
115
|
* Iterates through the container’s immediate children,
|
@@ -110,7 +147,6 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
110
147
|
each(
|
111
148
|
callback: (node: Child, index: number) => false | void
|
112
149
|
): false | undefined
|
113
|
-
|
114
150
|
/**
|
115
151
|
* Returns `true` if callback returns `true`
|
116
152
|
* for all of the container’s children.
|
@@ -125,6 +161,7 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
125
161
|
every(
|
126
162
|
condition: (node: Child, index: number, nodes: Child[]) => boolean
|
127
163
|
): boolean
|
164
|
+
|
128
165
|
/**
|
129
166
|
* Returns a `child`’s index within the `Container#nodes` array.
|
130
167
|
*
|
@@ -136,7 +173,6 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
136
173
|
* @return Child index.
|
137
174
|
*/
|
138
175
|
index(child: Child | number): number
|
139
|
-
|
140
176
|
/**
|
141
177
|
* Insert new node after old node within the container.
|
142
178
|
*
|
@@ -144,10 +180,8 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
144
180
|
* @param newNode New node.
|
145
181
|
* @return This node for methods chain.
|
146
182
|
*/
|
147
|
-
insertAfter(
|
148
|
-
|
149
|
-
newNode: Child | Child[] | ChildProps | ChildProps[] | string | string[]
|
150
|
-
): this
|
183
|
+
insertAfter(oldNode: Child | number, newNode: Container.NewChild): this
|
184
|
+
|
151
185
|
/**
|
152
186
|
* Insert new node before old node within the container.
|
153
187
|
*
|
@@ -159,10 +193,7 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
159
193
|
* @param newNode New node.
|
160
194
|
* @return This node for methods chain.
|
161
195
|
*/
|
162
|
-
insertBefore(
|
163
|
-
oldNode: Child | number,
|
164
|
-
newNode: Child | Child[] | ChildProps | ChildProps[] | string | string[]
|
165
|
-
): this
|
196
|
+
insertBefore(oldNode: Child | number, newNode: Container.NewChild): this
|
166
197
|
|
167
198
|
/**
|
168
199
|
* Traverses the container’s descendant nodes, calling callback
|
@@ -201,9 +232,7 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
201
232
|
* @param nodes New nodes.
|
202
233
|
* @return This node for methods chain.
|
203
234
|
*/
|
204
|
-
prepend(
|
205
|
-
...nodes: (ChildProps | ChildProps[] | Node | Node[] | string | string[])[]
|
206
|
-
): this
|
235
|
+
prepend(...nodes: Container.NewChild[]): this
|
207
236
|
/**
|
208
237
|
* Add child to the end of the node.
|
209
238
|
*
|
@@ -265,8 +294,8 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
265
294
|
* ```
|
266
295
|
*
|
267
296
|
* @param pattern Replace pattern.
|
268
|
-
* @param {object}
|
269
|
-
* @param
|
297
|
+
* @param {object} options Options to speed up the search.
|
298
|
+
* @param replaced String to replace pattern or callback
|
270
299
|
* that returns a new value. The callback
|
271
300
|
* will receive the same arguments
|
272
301
|
* as those passed to a function parameter
|
@@ -447,6 +476,8 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
447
476
|
get last(): Child | undefined
|
448
477
|
}
|
449
478
|
|
450
|
-
declare class Container<
|
479
|
+
declare class Container<
|
480
|
+
Child extends Node = ChildNode
|
481
|
+
> extends Container_<Child> {}
|
451
482
|
|
452
483
|
export = Container
|
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 => {
|
@@ -15,11 +15,11 @@ function cleanSource(nodes) {
|
|
15
15
|
})
|
16
16
|
}
|
17
17
|
|
18
|
-
function
|
18
|
+
function markTreeDirty(node) {
|
19
19
|
node[isClean] = false
|
20
20
|
if (node.proxyOf.nodes) {
|
21
21
|
for (let i of node.proxyOf.nodes) {
|
22
|
-
|
22
|
+
markTreeDirty(i)
|
23
23
|
}
|
24
24
|
}
|
25
25
|
}
|
@@ -153,7 +153,11 @@ class Container extends Node {
|
|
153
153
|
insertBefore(exist, add) {
|
154
154
|
let existIndex = this.index(exist)
|
155
155
|
let type = existIndex === 0 ? 'prepend' : false
|
156
|
-
let nodes = this.normalize(
|
156
|
+
let nodes = this.normalize(
|
157
|
+
add,
|
158
|
+
this.proxyOf.nodes[existIndex],
|
159
|
+
type
|
160
|
+
).reverse()
|
157
161
|
existIndex = this.index(exist)
|
158
162
|
for (let node of nodes) this.proxyOf.nodes.splice(existIndex, 0, node)
|
159
163
|
|
@@ -173,6 +177,8 @@ class Container extends Node {
|
|
173
177
|
normalize(nodes, sample) {
|
174
178
|
if (typeof nodes === 'string') {
|
175
179
|
nodes = cleanSource(parse(nodes).nodes)
|
180
|
+
} else if (typeof nodes === 'undefined') {
|
181
|
+
nodes = []
|
176
182
|
} else if (Array.isArray(nodes)) {
|
177
183
|
nodes = nodes.slice(0)
|
178
184
|
for (let i of nodes) {
|
@@ -192,7 +198,7 @@ class Container extends Node {
|
|
192
198
|
nodes.value = String(nodes.value)
|
193
199
|
}
|
194
200
|
nodes = [new Declaration(nodes)]
|
195
|
-
} else if (nodes.selector) {
|
201
|
+
} else if (nodes.selector || nodes.selectors) {
|
196
202
|
nodes = [new Rule(nodes)]
|
197
203
|
} else if (nodes.name) {
|
198
204
|
nodes = [new AtRule(nodes)]
|
@@ -207,7 +213,9 @@ class Container extends Node {
|
|
207
213
|
if (!i[my]) Container.rebuild(i)
|
208
214
|
i = i.proxyOf
|
209
215
|
if (i.parent) i.parent.removeChild(i)
|
210
|
-
if (i[isClean])
|
216
|
+
if (i[isClean]) markTreeDirty(i)
|
217
|
+
|
218
|
+
if (!i.raws) i.raws = {}
|
211
219
|
if (typeof i.raws.before === 'undefined') {
|
212
220
|
if (sample && typeof sample.raws.before !== 'undefined') {
|
213
221
|
i.raws.before = sample.raws.before.replace(/\S/g, '')
|
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/declaration.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import { ContainerWithChildren } from './container.js'
|
2
2
|
import Node from './node.js'
|
3
3
|
|
4
4
|
declare namespace Declaration {
|
@@ -63,6 +63,19 @@ declare namespace Declaration {
|
|
63
63
|
* ```
|
64
64
|
*/
|
65
65
|
declare class Declaration_ extends Node {
|
66
|
+
parent: ContainerWithChildren | undefined
|
67
|
+
raws: Declaration.DeclarationRaws
|
68
|
+
|
69
|
+
type: 'decl'
|
70
|
+
|
71
|
+
constructor(defaults?: Declaration.DeclarationProps)
|
72
|
+
assign(overrides: Declaration.DeclarationProps | object): this
|
73
|
+
|
74
|
+
clone(overrides?: Partial<Declaration.DeclarationProps>): this
|
75
|
+
|
76
|
+
cloneAfter(overrides?: Partial<Declaration.DeclarationProps>): this
|
77
|
+
|
78
|
+
cloneBefore(overrides?: Partial<Declaration.DeclarationProps>): this
|
66
79
|
/**
|
67
80
|
* It represents a specificity of the declaration.
|
68
81
|
*
|
@@ -77,10 +90,9 @@ declare class Declaration_ extends Node {
|
|
77
90
|
* root.first.last.important //=> undefined
|
78
91
|
* ```
|
79
92
|
*/
|
80
|
-
important: boolean
|
81
|
-
|
82
|
-
parent: Container | undefined
|
93
|
+
get important(): boolean
|
83
94
|
|
95
|
+
set important(value: boolean)
|
84
96
|
/**
|
85
97
|
* The property name for a CSS declaration.
|
86
98
|
*
|
@@ -91,12 +103,9 @@ declare class Declaration_ extends Node {
|
|
91
103
|
* decl.prop //=> 'color'
|
92
104
|
* ```
|
93
105
|
*/
|
94
|
-
prop: string
|
95
|
-
|
96
|
-
raws: Declaration.DeclarationRaws
|
97
|
-
|
98
|
-
type: 'decl'
|
106
|
+
get prop(): string
|
99
107
|
|
108
|
+
set prop(value: string)
|
100
109
|
/**
|
101
110
|
* The property value for a CSS declaration.
|
102
111
|
*
|
@@ -114,8 +123,8 @@ declare class Declaration_ extends Node {
|
|
114
123
|
* decl.value //=> 'black'
|
115
124
|
* ```
|
116
125
|
*/
|
117
|
-
value: string
|
118
|
-
|
126
|
+
get value(): string
|
127
|
+
set value(value: string)
|
119
128
|
/**
|
120
129
|
* It represents a getter that returns `true` if a declaration starts with
|
121
130
|
* `--` or `$`, which are used to declare variables in CSS and SASS/SCSS.
|
@@ -134,13 +143,7 @@ declare class Declaration_ extends Node {
|
|
134
143
|
* one.variable //=> true
|
135
144
|
* ```
|
136
145
|
*/
|
137
|
-
variable: boolean
|
138
|
-
|
139
|
-
constructor(defaults?: Declaration.DeclarationProps)
|
140
|
-
assign(overrides: Declaration.DeclarationProps | object): this
|
141
|
-
clone(overrides?: Partial<Declaration.DeclarationProps>): Declaration
|
142
|
-
cloneAfter(overrides?: Partial<Declaration.DeclarationProps>): Declaration
|
143
|
-
cloneBefore(overrides?: Partial<Declaration.DeclarationProps>): Declaration
|
146
|
+
get variable(): boolean
|
144
147
|
}
|
145
148
|
|
146
149
|
declare class Declaration extends Declaration_ {}
|
package/lib/document.d.ts
CHANGED
@@ -5,7 +5,7 @@ import Root from './root.js'
|
|
5
5
|
|
6
6
|
declare namespace Document {
|
7
7
|
export interface DocumentProps extends ContainerProps {
|
8
|
-
nodes?: Root[]
|
8
|
+
nodes?: readonly Root[]
|
9
9
|
|
10
10
|
/**
|
11
11
|
* Information to generate byte-to-byte equal node string as it was
|
@@ -35,15 +35,16 @@ declare namespace Document {
|
|
35
35
|
* ```
|
36
36
|
*/
|
37
37
|
declare class Document_ extends Container<Root> {
|
38
|
+
nodes: Root[]
|
38
39
|
parent: undefined
|
39
40
|
type: 'document'
|
40
41
|
|
41
42
|
constructor(defaults?: Document.DocumentProps)
|
42
43
|
|
43
44
|
assign(overrides: Document.DocumentProps | object): this
|
44
|
-
clone(overrides?: Partial<Document.DocumentProps>):
|
45
|
-
cloneAfter(overrides?: Partial<Document.DocumentProps>):
|
46
|
-
cloneBefore(overrides?: Partial<Document.DocumentProps>):
|
45
|
+
clone(overrides?: Partial<Document.DocumentProps>): this
|
46
|
+
cloneAfter(overrides?: Partial<Document.DocumentProps>): this
|
47
|
+
cloneBefore(overrides?: Partial<Document.DocumentProps>): this
|
47
48
|
|
48
49
|
/**
|
49
50
|
* Returns a `Result` instance representing the document’s CSS roots.
|
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.
|
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',
|
package/lib/list.d.ts
CHANGED
@@ -47,11 +47,14 @@ 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
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
55
58
|
declare const list: list.List
|
56
59
|
|
57
60
|
export = list
|