postcss 8.4.49 → 8.5.0
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/input.d.ts +11 -0
- package/lib/input.js +3 -0
- package/lib/node.js +8 -8
- package/lib/postcss.d.ts +6 -1
- package/lib/processor.js +1 -1
- package/lib/rule.d.ts +1 -1
- package/package.json +2 -2
package/lib/input.d.ts
CHANGED
@@ -62,6 +62,17 @@ declare class Input_ {
|
|
62
62
|
*/
|
63
63
|
css: string
|
64
64
|
|
65
|
+
/**
|
66
|
+
* Input source with support for non-CSS documents.
|
67
|
+
*
|
68
|
+
* ```js
|
69
|
+
* const input = postcss.parse('a{}', { from: file, document: '<style>a {}</style>' }).input
|
70
|
+
* input.document //=> "<style>a {}</style>"
|
71
|
+
* input.css //=> "a{}"
|
72
|
+
* ```
|
73
|
+
*/
|
74
|
+
document: string
|
75
|
+
|
65
76
|
/**
|
66
77
|
* The absolute path to the CSS source file defined
|
67
78
|
* with the `from` option.
|
package/lib/input.js
CHANGED
package/lib/node.js
CHANGED
@@ -209,9 +209,9 @@ class Node {
|
|
209
209
|
if (opts.index) {
|
210
210
|
pos = this.positionInside(opts.index)
|
211
211
|
} else if (opts.word) {
|
212
|
-
let stringRepresentation = this.source.input.
|
213
|
-
sourceOffset(this.source.input.
|
214
|
-
sourceOffset(this.source.input.
|
212
|
+
let stringRepresentation = this.source.input.document.slice(
|
213
|
+
sourceOffset(this.source.input.document, this.source.start),
|
214
|
+
sourceOffset(this.source.input.document, this.source.end)
|
215
215
|
)
|
216
216
|
let index = stringRepresentation.indexOf(opts.word)
|
217
217
|
if (index !== -1) pos = this.positionInside(index)
|
@@ -222,11 +222,11 @@ class Node {
|
|
222
222
|
positionInside(index) {
|
223
223
|
let column = this.source.start.column
|
224
224
|
let line = this.source.start.line
|
225
|
-
let offset = sourceOffset(this.source.input.
|
225
|
+
let offset = sourceOffset(this.source.input.document, this.source.start)
|
226
226
|
let end = offset + index
|
227
227
|
|
228
228
|
for (let i = offset; i < end; i++) {
|
229
|
-
if (this.source.input.
|
229
|
+
if (this.source.input.document[i] === '\n') {
|
230
230
|
column = 1
|
231
231
|
line += 1
|
232
232
|
} else {
|
@@ -259,9 +259,9 @@ class Node {
|
|
259
259
|
}
|
260
260
|
|
261
261
|
if (opts.word) {
|
262
|
-
let stringRepresentation = this.source.input.
|
263
|
-
sourceOffset(this.source.input.
|
264
|
-
sourceOffset(this.source.input.
|
262
|
+
let stringRepresentation = this.source.input.document.slice(
|
263
|
+
sourceOffset(this.source.input.document, this.source.start),
|
264
|
+
sourceOffset(this.source.input.document, this.source.end)
|
265
265
|
)
|
266
266
|
let index = stringRepresentation.indexOf(opts.word)
|
267
267
|
if (index !== -1) {
|
package/lib/postcss.d.ts
CHANGED
@@ -229,7 +229,7 @@ declare namespace postcss {
|
|
229
229
|
export interface Parser<RootNode = Document | Root> {
|
230
230
|
(
|
231
231
|
css: { toString(): string } | string,
|
232
|
-
opts?: Pick<ProcessOptions, 'from' | 'map'>
|
232
|
+
opts?: Pick<ProcessOptions, 'document' | 'from' | 'map'>
|
233
233
|
): RootNode
|
234
234
|
}
|
235
235
|
|
@@ -315,6 +315,11 @@ declare namespace postcss {
|
|
315
315
|
}
|
316
316
|
|
317
317
|
export interface ProcessOptions<RootNode = Document | Root> {
|
318
|
+
/**
|
319
|
+
* Input file if it is not simple CSS file, but HTML with <style> or JS with CSS-in-JS blocks.
|
320
|
+
*/
|
321
|
+
document?: string
|
322
|
+
|
318
323
|
/**
|
319
324
|
* The path of the CSS source file. You should always set `from`,
|
320
325
|
* because it is used in source map generation and syntax error messages.
|
package/lib/processor.js
CHANGED
package/lib/rule.d.ts
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "postcss",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.5.0",
|
4
4
|
"description": "Tool for transforming styles with JS plugins",
|
5
5
|
"engines": {
|
6
6
|
"node": "^10 || ^12 || >=14"
|
@@ -74,7 +74,7 @@
|
|
74
74
|
"url": "https://github.com/postcss/postcss/issues"
|
75
75
|
},
|
76
76
|
"dependencies": {
|
77
|
-
"nanoid": "^3.3.
|
77
|
+
"nanoid": "^3.3.8",
|
78
78
|
"picocolors": "^1.1.1",
|
79
79
|
"source-map-js": "^1.2.1"
|
80
80
|
},
|