postcss 8.4.39 → 8.4.41
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/at-rule.d.ts +25 -22
- package/lib/comment.d.ts +10 -9
- package/lib/container.d.ts +8 -8
- package/lib/container.js +9 -5
- package/lib/declaration.d.ts +20 -17
- package/lib/document.d.ts +3 -3
- package/lib/input.d.ts +3 -0
- package/lib/list.d.ts +0 -1
- package/lib/map-generator.js +1 -1
- package/lib/node.d.ts +5 -5
- package/lib/postcss.d.mts +1 -4
- package/lib/postcss.d.ts +14 -5
- package/lib/previous-map.js +7 -5
- package/lib/processor.js +1 -1
- package/lib/result.d.ts +0 -1
- package/lib/root.d.ts +3 -3
- package/lib/rule.d.ts +26 -17
- package/package.json +1 -1
package/lib/at-rule.d.ts
CHANGED
@@ -79,16 +79,6 @@ declare namespace AtRule {
|
|
79
79
|
* ```
|
80
80
|
*/
|
81
81
|
declare class AtRule_ extends Container {
|
82
|
-
/**
|
83
|
-
* The at-rule’s name immediately follows the `@`.
|
84
|
-
*
|
85
|
-
* ```js
|
86
|
-
* const root = postcss.parse('@media print {}')
|
87
|
-
* const media = root.first
|
88
|
-
* media.name //=> 'media'
|
89
|
-
* ```
|
90
|
-
*/
|
91
|
-
name: string
|
92
82
|
/**
|
93
83
|
* An array containing the layer’s children.
|
94
84
|
*
|
@@ -108,6 +98,29 @@ declare class AtRule_ extends Container {
|
|
108
98
|
* ```
|
109
99
|
*/
|
110
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
|
113
|
+
/**
|
114
|
+
* The at-rule’s name immediately follows the `@`.
|
115
|
+
*
|
116
|
+
* ```js
|
117
|
+
* const root = postcss.parse('@media print {}')
|
118
|
+
* const media = root.first
|
119
|
+
* media.name //=> 'media'
|
120
|
+
* ```
|
121
|
+
*/
|
122
|
+
get name(): string
|
123
|
+
set name(value: string)
|
111
124
|
/**
|
112
125
|
* The at-rule’s parameters, the values that follow the at-rule’s name
|
113
126
|
* but precede any `{}` block.
|
@@ -118,18 +131,8 @@ declare class AtRule_ extends Container {
|
|
118
131
|
* media.params //=> 'print, screen'
|
119
132
|
* ```
|
120
133
|
*/
|
121
|
-
params: string
|
122
|
-
|
123
|
-
|
124
|
-
raws: AtRule.AtRuleRaws
|
125
|
-
|
126
|
-
type: 'atrule'
|
127
|
-
|
128
|
-
constructor(defaults?: AtRule.AtRuleProps)
|
129
|
-
assign(overrides: AtRule.AtRuleProps | object): this
|
130
|
-
clone(overrides?: Partial<AtRule.AtRuleProps>): AtRule
|
131
|
-
cloneAfter(overrides?: Partial<AtRule.AtRuleProps>): AtRule
|
132
|
-
cloneBefore(overrides?: Partial<AtRule.AtRuleProps>): AtRule
|
134
|
+
get params(): string
|
135
|
+
set params(value: string)
|
133
136
|
}
|
134
137
|
|
135
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
@@ -24,7 +24,7 @@ declare namespace Container {
|
|
24
24
|
}
|
25
25
|
|
26
26
|
export interface ContainerProps extends NodeProps {
|
27
|
-
nodes?: (
|
27
|
+
nodes?: (Node | ChildProps)[]
|
28
28
|
}
|
29
29
|
|
30
30
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
@@ -84,9 +84,9 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
84
84
|
): this
|
85
85
|
|
86
86
|
assign(overrides: Container.ContainerProps | object): this
|
87
|
-
clone(overrides?: Partial<Container.ContainerProps>):
|
88
|
-
cloneAfter(overrides?: Partial<Container.ContainerProps>):
|
89
|
-
cloneBefore(overrides?: Partial<Container.ContainerProps>):
|
87
|
+
clone(overrides?: Partial<Container.ContainerProps>): this
|
88
|
+
cloneAfter(overrides?: Partial<Container.ContainerProps>): this
|
89
|
+
cloneBefore(overrides?: Partial<Container.ContainerProps>): this
|
90
90
|
|
91
91
|
/**
|
92
92
|
* Iterates through the container’s immediate children,
|
@@ -161,8 +161,8 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
161
161
|
insertAfter(
|
162
162
|
oldNode: Child | number,
|
163
163
|
newNode:
|
164
|
-
|
|
165
|
-
|
|
164
|
+
| Node
|
165
|
+
| Node[]
|
166
166
|
| ChildProps
|
167
167
|
| ChildProps[]
|
168
168
|
| string
|
@@ -183,8 +183,8 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
183
183
|
insertBefore(
|
184
184
|
oldNode: Child | number,
|
185
185
|
newNode:
|
186
|
-
|
|
187
|
-
|
|
186
|
+
| Node
|
187
|
+
| Node[]
|
188
188
|
| ChildProps
|
189
189
|
| ChildProps[]
|
190
190
|
| string
|
package/lib/container.js
CHANGED
@@ -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
|
|
@@ -194,7 +198,7 @@ class Container extends Node {
|
|
194
198
|
nodes.value = String(nodes.value)
|
195
199
|
}
|
196
200
|
nodes = [new Declaration(nodes)]
|
197
|
-
} else if (nodes.selector) {
|
201
|
+
} else if (nodes.selector || nodes.selectors) {
|
198
202
|
nodes = [new Rule(nodes)]
|
199
203
|
} else if (nodes.name) {
|
200
204
|
nodes = [new AtRule(nodes)]
|
@@ -209,7 +213,7 @@ class Container extends Node {
|
|
209
213
|
if (!i[my]) Container.rebuild(i)
|
210
214
|
i = i.proxyOf
|
211
215
|
if (i.parent) i.parent.removeChild(i)
|
212
|
-
if (i[isClean])
|
216
|
+
if (i[isClean]) markTreeDirty(i)
|
213
217
|
if (typeof i.raws.before === 'undefined') {
|
214
218
|
if (sample && typeof sample.raws.before !== 'undefined') {
|
215
219
|
i.raws.before = sample.raws.before.replace(/\S/g, '')
|
package/lib/declaration.d.ts
CHANGED
@@ -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: ContainerWithChildren | 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
@@ -42,9 +42,9 @@ declare class Document_ extends Container<Root> {
|
|
42
42
|
constructor(defaults?: Document.DocumentProps)
|
43
43
|
|
44
44
|
assign(overrides: Document.DocumentProps | object): this
|
45
|
-
clone(overrides?: Partial<Document.DocumentProps>):
|
46
|
-
cloneAfter(overrides?: Partial<Document.DocumentProps>):
|
47
|
-
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
|
48
48
|
|
49
49
|
/**
|
50
50
|
* Returns a `Result` instance representing the document’s CSS roots.
|
package/lib/input.d.ts
CHANGED
package/lib/list.d.ts
CHANGED
package/lib/map-generator.js
CHANGED
package/lib/node.d.ts
CHANGED
@@ -303,7 +303,7 @@ declare abstract class Node_ {
|
|
303
303
|
*
|
304
304
|
* @return Duplicate of the node instance.
|
305
305
|
*/
|
306
|
-
clone(overrides?: object):
|
306
|
+
clone(overrides?: object): this
|
307
307
|
|
308
308
|
/**
|
309
309
|
* Shortcut to clone the node and insert the resulting cloned node
|
@@ -312,7 +312,7 @@ declare abstract class Node_ {
|
|
312
312
|
* @param overrides New properties to override in the clone.
|
313
313
|
* @return New node.
|
314
314
|
*/
|
315
|
-
cloneAfter(overrides?: object):
|
315
|
+
cloneAfter(overrides?: object): this
|
316
316
|
|
317
317
|
/**
|
318
318
|
* Shortcut to clone the node and insert the resulting cloned node
|
@@ -326,7 +326,7 @@ declare abstract class Node_ {
|
|
326
326
|
*
|
327
327
|
* @return New node
|
328
328
|
*/
|
329
|
-
cloneBefore(overrides?: object):
|
329
|
+
cloneBefore(overrides?: object): this
|
330
330
|
|
331
331
|
/**
|
332
332
|
* It creates an instance of the class `CssSyntaxError` and parameters passed
|
@@ -472,8 +472,8 @@ declare abstract class Node_ {
|
|
472
472
|
*/
|
473
473
|
replaceWith(
|
474
474
|
...nodes: (
|
475
|
-
| Node
|
476
|
-
| Node
|
475
|
+
| Node
|
476
|
+
| Node[]
|
477
477
|
| Node.ChildProps
|
478
478
|
| Node.ChildProps[]
|
479
479
|
)[]
|
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
@@ -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
|
@@ -176,9 +185,9 @@ declare namespace postcss {
|
|
176
185
|
WarningOptions
|
177
186
|
}
|
178
187
|
|
179
|
-
export type SourceMap =
|
188
|
+
export type SourceMap = {
|
180
189
|
toJSON(): RawSourceMap
|
181
|
-
}
|
190
|
+
} & SourceMapGenerator
|
182
191
|
|
183
192
|
export type Helpers = { postcss: Postcss; result: Result } & Postcss
|
184
193
|
|
package/lib/previous-map.js
CHANGED
@@ -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.js
CHANGED
package/lib/result.d.ts
CHANGED
package/lib/root.d.ts
CHANGED
@@ -62,9 +62,9 @@ declare class Root_ extends Container {
|
|
62
62
|
constructor(defaults?: Root.RootProps)
|
63
63
|
|
64
64
|
assign(overrides: object | Root.RootProps): this
|
65
|
-
clone(overrides?: Partial<Root.RootProps>):
|
66
|
-
cloneAfter(overrides?: Partial<Root.RootProps>):
|
67
|
-
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
|
68
68
|
|
69
69
|
/**
|
70
70
|
* Returns a `Result` instance representing the root’s CSS.
|
package/lib/rule.d.ts
CHANGED
@@ -40,14 +40,21 @@ declare namespace Rule {
|
|
40
40
|
semicolon?: boolean
|
41
41
|
}
|
42
42
|
|
43
|
-
export
|
43
|
+
export type RuleProps = ContainerProps & {
|
44
44
|
/** Information used to generate byte-to-byte equal node string as it was in the origin input. */
|
45
45
|
raws?: RuleRaws
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
} & (
|
47
|
+
| {
|
48
|
+
/** Selector or selectors of the rule. */
|
49
|
+
selector: string
|
50
|
+
selectors?: never
|
51
|
+
}
|
52
|
+
| {
|
53
|
+
/** Selectors of the rule represented as an array of strings. */
|
54
|
+
selectors: string[]
|
55
|
+
selector?: never
|
56
|
+
}
|
57
|
+
)
|
51
58
|
|
52
59
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
53
60
|
export { Rule_ as default }
|
@@ -75,6 +82,15 @@ declare class Rule_ extends Container {
|
|
75
82
|
nodes: NonNullable<Container['nodes']>
|
76
83
|
parent: ContainerWithChildren | undefined
|
77
84
|
raws: Rule.RuleRaws
|
85
|
+
type: 'rule'
|
86
|
+
constructor(defaults?: Rule.RuleProps)
|
87
|
+
|
88
|
+
assign(overrides: object | Rule.RuleProps): this
|
89
|
+
clone(overrides?: Partial<Rule.RuleProps>): this
|
90
|
+
|
91
|
+
cloneAfter(overrides?: Partial<Rule.RuleProps>): this
|
92
|
+
|
93
|
+
cloneBefore(overrides?: Partial<Rule.RuleProps>): this
|
78
94
|
/**
|
79
95
|
* The rule’s full selector represented as a string.
|
80
96
|
*
|
@@ -84,8 +100,8 @@ declare class Rule_ extends Container {
|
|
84
100
|
* rule.selector //=> 'a, b'
|
85
101
|
* ```
|
86
102
|
*/
|
87
|
-
selector: string
|
88
|
-
|
103
|
+
get selector(): string
|
104
|
+
set selector(value: string)
|
89
105
|
/**
|
90
106
|
* An array containing the rule’s individual selectors.
|
91
107
|
* Groups of selectors are split at commas.
|
@@ -101,15 +117,8 @@ declare class Rule_ extends Container {
|
|
101
117
|
* rule.selector //=> 'a, strong'
|
102
118
|
* ```
|
103
119
|
*/
|
104
|
-
selectors: string[]
|
105
|
-
|
106
|
-
type: 'rule'
|
107
|
-
|
108
|
-
constructor(defaults?: Rule.RuleProps)
|
109
|
-
assign(overrides: object | Rule.RuleProps): this
|
110
|
-
clone(overrides?: Partial<Rule.RuleProps>): Rule
|
111
|
-
cloneAfter(overrides?: Partial<Rule.RuleProps>): Rule
|
112
|
-
cloneBefore(overrides?: Partial<Rule.RuleProps>): Rule
|
120
|
+
get selectors(): string[]
|
121
|
+
set selectors(values: string[])
|
113
122
|
}
|
114
123
|
|
115
124
|
declare class Rule extends Rule_ {}
|