postcss 8.5.8 → 8.5.10

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright 2013 Andrey Sitnik <andrey@sitnik.ru>
3
+ Copyright 2013 Andrey Sitnik <andrey@sitnik.es>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
package/README.md CHANGED
@@ -14,16 +14,15 @@ and JetBrains. The [Autoprefixer] and [Stylelint] PostCSS plugins are some o
14
14
  ---
15
15
 
16
16
  <img src="https://cdn.evilmartians.com/badges/logo-no-label.svg" alt="" width="22" height="16" />  Built by
17
- <b><a href="https://evilmartians.com/devtools?utm_source=postcss&utm_campaign=devtools-button&utm_medium=github">Evil Martians</a></b>, go-to agency for <b>developer tools</b>.
17
+ <b><a href="https://evilmartians.com/devtools?utm_source=postcss&utm_campaign=devtools-button&utm_medium=github">Evil Martians</a></b>, go-to agency for <b>developer tools</b>.
18
18
 
19
19
  ---
20
20
 
21
- [Abstract Syntax Tree]: https://en.wikipedia.org/wiki/Abstract_syntax_tree
22
- [Evil Martians]: https://evilmartians.com/?utm_source=postcss
23
- [Autoprefixer]: https://github.com/postcss/autoprefixer
24
- [Stylelint]: https://stylelint.io/
25
- [plugins]: https://github.com/postcss/postcss#plugins
26
-
21
+ [Abstract Syntax Tree]: https://en.wikipedia.org/wiki/Abstract_syntax_tree
22
+ [Evil Martians]: https://evilmartians.com/?utm_source=postcss
23
+ [Autoprefixer]: https://github.com/postcss/autoprefixer
24
+ [Stylelint]: https://stylelint.io/
25
+ [plugins]: https://github.com/postcss/postcss#plugins
27
26
 
28
27
  ## Docs
29
28
  Read full docs **[here](https://postcss.org/)**.
package/lib/at-rule.d.ts CHANGED
@@ -49,7 +49,6 @@ declare namespace AtRule {
49
49
  raws?: AtRuleRaws
50
50
  }
51
51
 
52
-
53
52
  export { AtRule_ as default }
54
53
  }
55
54
 
package/lib/comment.d.ts CHANGED
@@ -26,7 +26,6 @@ declare namespace Comment {
26
26
  text: string
27
27
  }
28
28
 
29
-
30
29
  export { Comment_ as default }
31
30
  }
32
31
 
@@ -8,11 +8,7 @@ import Rule from './rule.js'
8
8
  declare namespace Container {
9
9
  export type ContainerWithChildren<Child extends Node = ChildNode> = {
10
10
  nodes: Child[]
11
- } & (
12
- | AtRule
13
- | Root
14
- | Rule
15
- )
11
+ } & (AtRule | Root | Rule)
16
12
 
17
13
  export interface ValueOptions {
18
14
  /**
@@ -43,7 +39,6 @@ declare namespace Container {
43
39
  | string
44
40
  | undefined
45
41
 
46
-
47
42
  export { Container_ as default }
48
43
  }
49
44
 
@@ -16,7 +16,6 @@ declare namespace CssSyntaxError {
16
16
  line: number
17
17
  }
18
18
 
19
-
20
19
  export { CssSyntaxError_ as default }
21
20
  }
22
21
 
@@ -39,7 +39,6 @@ declare namespace Declaration {
39
39
  value: string
40
40
  }
41
41
 
42
-
43
42
  export { Declaration_ as default }
44
43
  }
45
44
 
package/lib/document.d.ts CHANGED
@@ -16,7 +16,6 @@ declare namespace Document {
16
16
  raws?: Record<string, any>
17
17
  }
18
18
 
19
-
20
19
  export { Document_ as default }
21
20
  }
22
21
 
package/lib/fromJSON.d.ts CHANGED
@@ -4,6 +4,6 @@ interface FromJSON extends JSONHydrator {
4
4
  default: FromJSON
5
5
  }
6
6
 
7
- declare const fromJSON: FromJSON
7
+ declare let fromJSON: FromJSON
8
8
 
9
9
  export = fromJSON
package/lib/input.d.ts CHANGED
@@ -49,7 +49,6 @@ declare namespace Input {
49
49
  url: string
50
50
  }
51
51
 
52
-
53
52
  export { Input_ as default }
54
53
  }
55
54
 
package/lib/input.js CHANGED
@@ -142,7 +142,15 @@ class Input {
142
142
  )
143
143
  }
144
144
 
145
- result.input = { column, endColumn, endLine, endOffset, line, offset, source: this.css }
145
+ result.input = {
146
+ column,
147
+ endColumn,
148
+ endLine,
149
+ endOffset,
150
+ line,
151
+ offset,
152
+ source: this.css
153
+ }
146
154
  if (this.file) {
147
155
  if (pathToFileURL) {
148
156
  result.input.url = pathToFileURL(this.file).toString()
@@ -6,7 +6,6 @@ import Root from './root.js'
6
6
  import Warning from './warning.js'
7
7
 
8
8
  declare namespace LazyResult {
9
-
10
9
  export { LazyResult_ as default }
11
10
  }
12
11
 
@@ -19,9 +18,9 @@ declare namespace LazyResult {
19
18
  * const lazy = postcss([autoprefixer]).process(css)
20
19
  * ```
21
20
  */
22
- declare class LazyResult_<RootNode = Document | Root>
23
- implements PromiseLike<Result<RootNode>>
24
- {
21
+ declare class LazyResult_<RootNode = Document | Root> implements PromiseLike<
22
+ Result<RootNode>
23
+ > {
25
24
  /**
26
25
  * Processes input CSS through synchronous and asynchronous plugins
27
26
  * and calls onRejected for each error thrown in any plugin.
package/lib/list.d.ts CHANGED
@@ -55,6 +55,6 @@ declare namespace list {
55
55
  }
56
56
  }
57
57
 
58
- declare const list: list.List
58
+ declare let list: list.List
59
59
 
60
60
  export = list
@@ -6,7 +6,6 @@ import Root from './root.js'
6
6
  import Warning from './warning.js'
7
7
 
8
8
  declare namespace NoWorkResult {
9
-
10
9
  export { NoWorkResult_ as default }
11
10
  }
12
11
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  let MapGenerator = require('./map-generator')
4
4
  let parse = require('./parse')
5
- const Result = require('./result')
5
+ let Result = require('./result')
6
6
  let stringify = require('./stringify')
7
7
  let warnOnce = require('./warn-once')
8
8
 
package/lib/node.d.ts CHANGED
@@ -126,7 +126,6 @@ declare namespace Node {
126
126
  word?: string
127
127
  }
128
128
 
129
-
130
129
  class Node extends Node_ {}
131
130
  export { Node as default }
132
131
  }
package/lib/parse.d.ts CHANGED
@@ -4,6 +4,6 @@ interface Parse extends Parser {
4
4
  default: Parse
5
5
  }
6
6
 
7
- declare const parse: Parse
7
+ declare let parse: Parse
8
8
 
9
9
  export = parse
package/lib/postcss.d.mts CHANGED
@@ -1,7 +1,6 @@
1
1
  export {
2
2
  // Type-only exports
3
3
  AcceptedPlugin,
4
-
5
4
  AnyNode,
6
5
  atRule,
7
6
  AtRule,
@@ -27,7 +26,6 @@ export {
27
26
  fromJSON,
28
27
  Helpers,
29
28
  Input,
30
-
31
29
  JSONHydrator,
32
30
  // This is a class, but it’s not re-exported. That’s why it’s exported as type-only here.
33
31
  type LazyResult,
@@ -64,6 +62,5 @@ export {
64
62
  TransformCallback,
65
63
  Transformer,
66
64
  Warning,
67
-
68
65
  WarningOptions
69
66
  } from './postcss.js'
package/lib/postcss.d.ts CHANGED
@@ -450,9 +450,7 @@ declare namespace postcss {
450
450
  * @param plugins PostCSS plugins.
451
451
  * @return Processor to process multiple CSS.
452
452
  */
453
- declare function postcss(
454
- plugins?: readonly postcss.AcceptedPlugin[]
455
- ): Processor
453
+ declare function postcss(plugins?: readonly postcss.AcceptedPlugin[]): Processor
456
454
  declare function postcss(...plugins: postcss.AcceptedPlugin[]): Processor
457
455
 
458
456
  export = postcss
@@ -3,7 +3,6 @@ import { SourceMapConsumer } from 'source-map-js'
3
3
  import { ProcessOptions } from './postcss.js'
4
4
 
5
5
  declare namespace PreviousMap {
6
-
7
6
  export { PreviousMap_ as default }
8
7
  }
9
8
 
@@ -51,7 +51,8 @@ class PreviousMap {
51
51
  return fromBase64(text.substr(baseUriMatch[0].length))
52
52
  }
53
53
 
54
- let encoding = text.match(/data:application\/json;([^,]+),/)[1]
54
+ let encoding = text.slice('data:application/json;'.length)
55
+ encoding = encoding.slice(0, encoding.indexOf(','))
55
56
  throw new Error('Unsupported source map encoding ' + encoding)
56
57
  }
57
58
 
@@ -12,7 +12,6 @@ import Result from './result.js'
12
12
  import Root from './root.js'
13
13
 
14
14
  declare namespace Processor {
15
-
16
15
  export { Processor_ as default }
17
16
  }
18
17
 
package/lib/processor.js CHANGED
@@ -7,7 +7,7 @@ let Root = require('./root')
7
7
 
8
8
  class Processor {
9
9
  constructor(plugins = []) {
10
- this.version = '8.5.8'
10
+ this.version = '8.5.10'
11
11
  this.plugins = this.normalize(plugins)
12
12
  }
13
13
 
package/lib/result.d.ts CHANGED
@@ -39,7 +39,6 @@ declare namespace Result {
39
39
  plugin?: string
40
40
  }
41
41
 
42
-
43
42
  export { Result_ as default }
44
43
  }
45
44
 
package/lib/root.d.ts CHANGED
@@ -40,7 +40,6 @@ declare namespace Root {
40
40
  raws?: RootRaws
41
41
  }
42
42
 
43
-
44
43
  export { Root_ as default }
45
44
  }
46
45
 
package/lib/rule.d.ts CHANGED
@@ -44,19 +44,19 @@ declare namespace Rule {
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
  } & (
47
- | {
48
- /** Selector or selectors of the rule. */
49
- selector: string
50
- selectors?: never
51
- }
52
- | {
53
- selector?: never
54
- /** Selectors of the rule represented as an array of strings. */
55
- selectors: readonly string[]
56
- }
57
- ) & ContainerProps
47
+ | {
48
+ /** Selector or selectors of the rule. */
49
+ selector: string
50
+ selectors?: never
51
+ }
52
+ | {
53
+ selector?: never
54
+ /** Selectors of the rule represented as an array of strings. */
55
+ selectors: readonly string[]
56
+ }
57
+ ) &
58
+ ContainerProps
58
59
 
59
-
60
60
  export { Rule_ as default }
61
61
  }
62
62
 
@@ -11,7 +11,6 @@ import {
11
11
  } from './postcss.js'
12
12
 
13
13
  declare namespace Stringifier {
14
-
15
14
  export { Stringifier_ as default }
16
15
  }
17
16
 
@@ -1,5 +1,17 @@
1
1
  'use strict'
2
2
 
3
+ // Escapes sequences that could break out of an HTML <style> context.
4
+ // Uses CSS unicode escaping (\3c = '<') which is valid CSS and parsed
5
+ // correctly by all compliant CSS consumers.
6
+ const STYLE_TAG = /(<)(\/?style\b)/gi
7
+ const COMMENT_OPEN = /(<)(!--)/g
8
+
9
+ function escapeHTMLInCSS(str) {
10
+ if (typeof str !== 'string') return str
11
+ if (!str.includes('<')) return str
12
+ return str.replace(STYLE_TAG, '\\3c $2').replace(COMMENT_OPEN, '\\3c $2')
13
+ }
14
+
3
15
  const DEFAULT_RAW = {
4
16
  after: '\n',
5
17
  beforeClose: '\n',
@@ -38,7 +50,7 @@ class Stringifier {
38
50
  this.block(node, name + params)
39
51
  } else {
40
52
  let end = (node.raws.between || '') + (semicolon ? ';' : '')
41
- this.builder(name + params + end, node)
53
+ this.builder(escapeHTMLInCSS(name + params + end), node)
42
54
  }
43
55
  }
44
56
 
@@ -73,7 +85,7 @@ class Stringifier {
73
85
 
74
86
  block(node, start) {
75
87
  let between = this.raw(node, 'between', 'beforeOpen')
76
- this.builder(start + between + '{', node, 'start')
88
+ this.builder(escapeHTMLInCSS(start + between) + '{', node, 'start')
77
89
 
78
90
  let after
79
91
  if (node.nodes && node.nodes.length) {
@@ -83,7 +95,7 @@ class Stringifier {
83
95
  after = this.raw(node, 'after', 'emptyBody')
84
96
  }
85
97
 
86
- if (after) this.builder(after)
98
+ if (after) this.builder(escapeHTMLInCSS(after))
87
99
  this.builder('}', node, 'end')
88
100
  }
89
101
 
@@ -95,10 +107,11 @@ class Stringifier {
95
107
  }
96
108
 
97
109
  let semicolon = this.raw(node, 'semicolon')
110
+ let isDocument = node.type === 'document'
98
111
  for (let i = 0; i < node.nodes.length; i++) {
99
112
  let child = node.nodes[i]
100
113
  let before = this.raw(child, 'before')
101
- if (before) this.builder(before)
114
+ if (before) this.builder(isDocument ? before : escapeHTMLInCSS(before))
102
115
  this.stringify(child, last !== i || semicolon)
103
116
  }
104
117
  }
@@ -106,7 +119,7 @@ class Stringifier {
106
119
  comment(node) {
107
120
  let left = this.raw(node, 'left', 'commentLeft')
108
121
  let right = this.raw(node, 'right', 'commentRight')
109
- this.builder('/*' + left + node.text + right + '*/', node)
122
+ this.builder(escapeHTMLInCSS('/*' + left + node.text + right + '*/'), node)
110
123
  }
111
124
 
112
125
  decl(node, semicolon) {
@@ -118,7 +131,7 @@ class Stringifier {
118
131
  }
119
132
 
120
133
  if (semicolon) string += ';'
121
- this.builder(string, node)
134
+ this.builder(escapeHTMLInCSS(string), node)
122
135
  }
123
136
 
124
137
  document(node) {
@@ -324,13 +337,17 @@ class Stringifier {
324
337
 
325
338
  root(node) {
326
339
  this.body(node)
327
- if (node.raws.after) this.builder(node.raws.after)
340
+ if (node.raws.after) {
341
+ let after = node.raws.after
342
+ let isDocument = node.parent && node.parent.type === 'document'
343
+ this.builder(isDocument ? after : escapeHTMLInCSS(after))
344
+ }
328
345
  }
329
346
 
330
347
  rule(node) {
331
348
  this.block(node, this.rawValue(node, 'selector'))
332
349
  if (node.raws.ownSemicolon) {
333
- this.builder(node.raws.ownSemicolon, node, 'end')
350
+ this.builder(escapeHTMLInCSS(node.raws.ownSemicolon), node, 'end')
334
351
  }
335
352
  }
336
353
 
@@ -4,6 +4,6 @@ interface Stringify extends Stringifier {
4
4
  default: Stringify
5
5
  }
6
6
 
7
- declare const stringify: Stringify
7
+ declare let stringify: Stringify
8
8
 
9
9
  export = stringify
package/lib/warning.d.ts CHANGED
@@ -40,7 +40,6 @@ declare namespace Warning {
40
40
  word?: string
41
41
  }
42
42
 
43
-
44
43
  export { Warning_ as default }
45
44
  }
46
45
 
package/package.json CHANGED
@@ -1,10 +1,48 @@
1
1
  {
2
2
  "name": "postcss",
3
- "version": "8.5.8",
3
+ "version": "8.5.10",
4
4
  "description": "Tool for transforming styles with JS plugins",
5
- "engines": {
6
- "node": "^10 || ^12 || >=14"
5
+ "keywords": [
6
+ "css",
7
+ "manipulation",
8
+ "parser",
9
+ "postcss",
10
+ "preprocessor",
11
+ "rework",
12
+ "source map",
13
+ "transform",
14
+ "transpiler"
15
+ ],
16
+ "homepage": "https://postcss.org/",
17
+ "bugs": {
18
+ "url": "https://github.com/postcss/postcss/issues"
7
19
  },
20
+ "license": "MIT",
21
+ "author": "Andrey Sitnik <andrey@sitnik.es>",
22
+ "repository": "postcss/postcss",
23
+ "funding": [
24
+ {
25
+ "type": "opencollective",
26
+ "url": "https://opencollective.com/postcss/"
27
+ },
28
+ {
29
+ "type": "tidelift",
30
+ "url": "https://tidelift.com/funding/github/npm/postcss"
31
+ },
32
+ {
33
+ "type": "github",
34
+ "url": "https://github.com/sponsors/ai"
35
+ }
36
+ ],
37
+ "main": "./lib/postcss.js",
38
+ "browser": {
39
+ "./lib/terminal-highlight": false,
40
+ "source-map-js": false,
41
+ "path": false,
42
+ "url": false,
43
+ "fs": false
44
+ },
45
+ "types": "./lib/postcss.d.ts",
8
46
  "exports": {
9
47
  ".": {
10
48
  "import": "./lib/postcss.mjs",
@@ -39,50 +77,12 @@
39
77
  "./lib/warning": "./lib/warning.js",
40
78
  "./package.json": "./package.json"
41
79
  },
42
- "main": "./lib/postcss.js",
43
- "types": "./lib/postcss.d.ts",
44
- "keywords": [
45
- "css",
46
- "postcss",
47
- "rework",
48
- "preprocessor",
49
- "parser",
50
- "source map",
51
- "transform",
52
- "manipulation",
53
- "transpiler"
54
- ],
55
- "funding": [
56
- {
57
- "type": "opencollective",
58
- "url": "https://opencollective.com/postcss/"
59
- },
60
- {
61
- "type": "tidelift",
62
- "url": "https://tidelift.com/funding/github/npm/postcss"
63
- },
64
- {
65
- "type": "github",
66
- "url": "https://github.com/sponsors/ai"
67
- }
68
- ],
69
- "author": "Andrey Sitnik <andrey@sitnik.ru>",
70
- "license": "MIT",
71
- "homepage": "https://postcss.org/",
72
- "repository": "postcss/postcss",
73
- "bugs": {
74
- "url": "https://github.com/postcss/postcss/issues"
75
- },
76
80
  "dependencies": {
77
81
  "nanoid": "^3.3.11",
78
82
  "picocolors": "^1.1.1",
79
83
  "source-map-js": "^1.2.1"
80
84
  },
81
- "browser": {
82
- "./lib/terminal-highlight": false,
83
- "source-map-js": false,
84
- "path": false,
85
- "url": false,
86
- "fs": false
85
+ "engines": {
86
+ "node": "^10 || ^12 || >=14"
87
87
  }
88
88
  }