Comparing version 8.4.28 to 8.4.31
@@ -129,11 +129,2 @@ import AtRule from './at-rule.js' | ||
/** | ||
* The container’s first child. | ||
* | ||
* ```js | ||
* rule.first === rules.nodes[0] | ||
* ``` | ||
*/ | ||
get first(): Child | undefined | ||
/** | ||
* Returns a `child`’s index within the `Container#nodes` array. | ||
@@ -149,2 +140,3 @@ * | ||
index(child: Child | number): number | ||
/** | ||
@@ -161,21 +153,3 @@ * Insert new node after old node within the container. | ||
): this | ||
/** | ||
* Traverses the container’s descendant nodes, calling callback | ||
* for each comment node. | ||
* | ||
* Like `Container#each`, this method is safe | ||
* to use if you are mutating arrays during iteration. | ||
* | ||
* ```js | ||
* root.walkComments(comment => { | ||
* comment.remove() | ||
* }) | ||
* ``` | ||
* | ||
* @param callback Iterator receives each node and index. | ||
* @return Returns `false` if iteration was broke. | ||
*/ | ||
/** | ||
* Insert new node before old node within the container. | ||
@@ -195,10 +169,19 @@ * | ||
): this | ||
/** | ||
* The container’s last child. | ||
* Traverses the container’s descendant nodes, calling callback | ||
* for each comment node. | ||
* | ||
* Like `Container#each`, this method is safe | ||
* to use if you are mutating arrays during iteration. | ||
* | ||
* ```js | ||
* rule.last === rule.nodes[rule.nodes.length - 1] | ||
* root.walkComments(comment => { | ||
* comment.remove() | ||
* }) | ||
* ``` | ||
* | ||
* @param callback Iterator receives each node and index. | ||
* @return Returns `false` if iteration was broke. | ||
*/ | ||
get last(): Child | undefined | ||
@@ -228,3 +211,2 @@ /** | ||
): this | ||
/** | ||
@@ -342,2 +324,3 @@ * Add child to the end of the node. | ||
): false | undefined | ||
/** | ||
@@ -380,3 +363,2 @@ * Traverses the container’s descendant nodes, calling callback | ||
): false | undefined | ||
walkComments( | ||
@@ -423,5 +405,7 @@ callback: (comment: Comment, indexed: number) => false | void | ||
): false | undefined | ||
walkDecls( | ||
callback: (decl: Declaration, index: number) => false | void | ||
): false | undefined | ||
/** | ||
@@ -456,2 +440,18 @@ * Traverses the container’s descendant nodes, calling callback | ||
): false | undefined | ||
/** | ||
* The container’s first child. | ||
* | ||
* ```js | ||
* rule.first === rules.nodes[0] | ||
* ``` | ||
*/ | ||
get first(): Child | undefined | ||
/** | ||
* The container’s last child. | ||
* | ||
* ```js | ||
* rule.last === rule.nodes[rule.nodes.length - 1] | ||
* ``` | ||
*/ | ||
get last(): Child | undefined | ||
} | ||
@@ -458,0 +458,0 @@ |
@@ -67,7 +67,2 @@ 'use strict' | ||
get first() { | ||
if (!this.proxyOf.nodes) return undefined | ||
return this.proxyOf.nodes[0] | ||
} | ||
getIterator() { | ||
@@ -179,7 +174,2 @@ if (!this.lastEach) this.lastEach = 0 | ||
get last() { | ||
if (!this.proxyOf.nodes) return undefined | ||
return this.proxyOf.nodes[this.proxyOf.nodes.length - 1] | ||
} | ||
normalize(nodes, sample) { | ||
@@ -398,2 +388,12 @@ if (typeof nodes === 'string') { | ||
} | ||
get first() { | ||
if (!this.proxyOf.nodes) return undefined | ||
return this.proxyOf.nodes[0] | ||
} | ||
get last() { | ||
if (!this.proxyOf.nodes) return undefined | ||
return this.proxyOf.nodes[this.proxyOf.nodes.length - 1] | ||
} | ||
} | ||
@@ -400,0 +400,0 @@ |
@@ -147,15 +147,2 @@ import { CssSyntaxError, ProcessOptions } from './postcss.js' | ||
/** | ||
* The CSS source identifier. Contains `Input#file` if the user | ||
* set the `from` option, or `Input#id` if they did not. | ||
* | ||
* ```js | ||
* const root = postcss.parse(css, { from: 'a.css' }) | ||
* root.source.input.from //=> "/home/ai/a.css" | ||
* | ||
* const root = postcss.parse(css) | ||
* root.source.input.from //=> "<input css 1>" | ||
* ``` | ||
*/ | ||
get from(): string | ||
/** | ||
* Converts source offset to line and column. | ||
@@ -191,2 +178,15 @@ * | ||
): false | Input.FilePosition | ||
/** | ||
* The CSS source identifier. Contains `Input#file` if the user | ||
* set the `from` option, or `Input#id` if they did not. | ||
* | ||
* ```js | ||
* const root = postcss.parse(css, { from: 'a.css' }) | ||
* root.source.input.from //=> "/home/ai/a.css" | ||
* | ||
* const root = postcss.parse(css) | ||
* root.source.input.from //=> "<input css 1>" | ||
* ``` | ||
*/ | ||
get from(): string | ||
} | ||
@@ -193,0 +193,0 @@ |
@@ -127,6 +127,2 @@ 'use strict' | ||
get from() { | ||
return this.file || this.id | ||
} | ||
fromOffset(offset) { | ||
@@ -242,2 +238,6 @@ let lastLine, lineToIndex | ||
} | ||
get from() { | ||
return this.file || this.id | ||
} | ||
} | ||
@@ -244,0 +244,0 @@ |
@@ -85,2 +85,28 @@ import Document from './document.js' | ||
/** | ||
* Run plugin in sync way and return `Result`. | ||
* | ||
* @return Result with output content. | ||
*/ | ||
sync(): Result<RootNode> | ||
/** | ||
* Alias for the `LazyResult#css` property. | ||
* | ||
* ```js | ||
* lazy + '' === lazy.css | ||
* ``` | ||
* | ||
* @return Output CSS. | ||
*/ | ||
toString(): string | ||
/** | ||
* Processes input CSS through synchronous plugins | ||
* and calls `Result#warnings`. | ||
* | ||
* @return Warnings from plugins. | ||
*/ | ||
warnings(): Warning[] | ||
/** | ||
* An alias for the `css` property. Use it with syntaxes | ||
@@ -159,28 +185,2 @@ * that generate non-CSS output. | ||
get [Symbol.toStringTag](): string | ||
/** | ||
* Run plugin in sync way and return `Result`. | ||
* | ||
* @return Result with output content. | ||
*/ | ||
sync(): Result<RootNode> | ||
/** | ||
* Alias for the `LazyResult#css` property. | ||
* | ||
* ```js | ||
* lazy + '' === lazy.css | ||
* ``` | ||
* | ||
* @return Output CSS. | ||
*/ | ||
toString(): string | ||
/** | ||
* Processes input CSS through synchronous plugins | ||
* and calls `Result#warnings`. | ||
* | ||
* @return Warnings from plugins. | ||
*/ | ||
warnings(): Warning[] | ||
} | ||
@@ -187,0 +187,0 @@ |
@@ -169,10 +169,2 @@ 'use strict' | ||
get content() { | ||
return this.stringify().content | ||
} | ||
get css() { | ||
return this.stringify().css | ||
} | ||
finally(onFinally) { | ||
@@ -225,14 +217,2 @@ return this.async().then(onFinally, onFinally) | ||
get map() { | ||
return this.stringify().map | ||
} | ||
get messages() { | ||
return this.sync().messages | ||
} | ||
get opts() { | ||
return this.result.opts | ||
} | ||
prepareVisitors() { | ||
@@ -276,10 +256,2 @@ this.listeners = {} | ||
get processor() { | ||
return this.result.processor | ||
} | ||
get root() { | ||
return this.sync().root | ||
} | ||
async runAsync() { | ||
@@ -388,6 +360,2 @@ this.plugin = 0 | ||
get [Symbol.toStringTag]() { | ||
return 'LazyResult' | ||
} | ||
sync() { | ||
@@ -544,2 +512,34 @@ if (this.error) throw this.error | ||
} | ||
get content() { | ||
return this.stringify().content | ||
} | ||
get css() { | ||
return this.stringify().css | ||
} | ||
get map() { | ||
return this.stringify().map | ||
} | ||
get messages() { | ||
return this.sync().messages | ||
} | ||
get opts() { | ||
return this.result.opts | ||
} | ||
get processor() { | ||
return this.result.processor | ||
} | ||
get root() { | ||
return this.sync().root | ||
} | ||
get [Symbol.toStringTag]() { | ||
return 'LazyResult' | ||
} | ||
} | ||
@@ -546,0 +546,0 @@ |
@@ -20,2 +20,6 @@ 'use strict' | ||
this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute | ||
this.memoizedFileURLs = new Map() | ||
this.memoizedPaths = new Map() | ||
this.memoizedURLs = new Map() | ||
} | ||
@@ -245,5 +249,7 @@ | ||
path(file) { | ||
if (file.indexOf('<') === 0) return file | ||
if (this.mapOpts.absolute) return file | ||
if (file.charCodeAt(0) === 60 /* `<` */) return file | ||
if (/^\w+:\/\//.test(file)) return file | ||
if (this.mapOpts.absolute) return file | ||
let cached = this.memoizedPaths.get(file) | ||
if (cached) return cached | ||
@@ -256,4 +262,6 @@ let from = this.opts.to ? dirname(this.opts.to) : '.' | ||
file = relative(from, file) | ||
return file | ||
let path = relative(from, file) | ||
this.memoizedPaths.set(file, path) | ||
return path | ||
} | ||
@@ -324,4 +332,10 @@ | ||
toFileUrl(path) { | ||
let cached = this.memoizedFileURLs.get(path) | ||
if (cached) return cached | ||
if (pathToFileURL) { | ||
return pathToFileURL(path).toString() | ||
let fileURL = pathToFileURL(path).toString() | ||
this.memoizedFileURLs.set(path, fileURL) | ||
return fileURL | ||
} else { | ||
@@ -335,6 +349,13 @@ throw new Error( | ||
toUrl(path) { | ||
let cached = this.memoizedURLs.get(path) | ||
if (cached) return cached | ||
if (sep === '\\') { | ||
path = path.replace(/\\/g, '/') | ||
} | ||
return encodeURI(path).replace(/[#?]/g, encodeURIComponent) | ||
let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent) | ||
this.memoizedURLs.set(path, url) | ||
return url | ||
} | ||
@@ -341,0 +362,0 @@ } |
@@ -31,2 +31,5 @@ import LazyResult from './lazy-result.js' | ||
async(): Promise<Result<Root>> | ||
sync(): Result<Root> | ||
toString(): string | ||
warnings(): Warning[] | ||
get content(): string | ||
@@ -40,5 +43,2 @@ get css(): string | ||
get [Symbol.toStringTag](): string | ||
sync(): Result<Root> | ||
toString(): string | ||
warnings(): Warning[] | ||
} | ||
@@ -45,0 +45,0 @@ |
@@ -52,2 +52,33 @@ 'use strict' | ||
finally(onFinally) { | ||
return this.async().then(onFinally, onFinally) | ||
} | ||
sync() { | ||
if (this.error) throw this.error | ||
return this.result | ||
} | ||
then(onFulfilled, onRejected) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (!('from' in this._opts)) { | ||
warnOnce( | ||
'Without `from` option PostCSS could generate wrong source map ' + | ||
'and will not find Browserslist config. Set it to CSS file path ' + | ||
'or to `undefined` to prevent this warning.' | ||
) | ||
} | ||
} | ||
return this.async().then(onFulfilled, onRejected) | ||
} | ||
toString() { | ||
return this._css | ||
} | ||
warnings() { | ||
return [] | ||
} | ||
get content() { | ||
@@ -61,6 +92,2 @@ return this.result.css | ||
finally(onFinally) { | ||
return this.async().then(onFinally, onFinally) | ||
} | ||
get map() { | ||
@@ -107,29 +134,2 @@ return this.result.map | ||
} | ||
sync() { | ||
if (this.error) throw this.error | ||
return this.result | ||
} | ||
then(onFulfilled, onRejected) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (!('from' in this._opts)) { | ||
warnOnce( | ||
'Without `from` option PostCSS could generate wrong source map ' + | ||
'and will not find Browserslist config. Set it to CSS file path ' + | ||
'or to `undefined` to prevent this warning.' | ||
) | ||
} | ||
} | ||
return this.async().then(onFulfilled, onRejected) | ||
} | ||
toString() { | ||
return this._css | ||
} | ||
warnings() { | ||
return [] | ||
} | ||
} | ||
@@ -136,0 +136,0 @@ |
@@ -207,6 +207,2 @@ 'use strict' | ||
get proxyOf() { | ||
return this | ||
} | ||
rangeBy(opts) { | ||
@@ -379,2 +375,6 @@ let start = { | ||
} | ||
get proxyOf() { | ||
return this | ||
} | ||
} | ||
@@ -381,0 +381,0 @@ |
@@ -68,2 +68,3 @@ 'use strict' | ||
node.source.end = this.getPosition(token[2]) | ||
node.source.end.offset++ | ||
this.semicolon = true | ||
@@ -83,2 +84,3 @@ break | ||
node.source.end = this.getPosition(prev[3] || prev[2]) | ||
node.source.end.offset++ | ||
} | ||
@@ -108,2 +110,3 @@ } | ||
node.source.end = this.getPosition(token[3] || token[2]) | ||
node.source.end.offset++ | ||
this.spaces = node.raws.between | ||
@@ -177,2 +180,3 @@ node.raws.between = '' | ||
node.source.end = this.getPosition(token[3] || token[2]) | ||
node.source.end.offset++ | ||
@@ -209,2 +213,3 @@ let text = token[1].slice(2, -2) | ||
) | ||
node.source.end.offset++ | ||
@@ -328,2 +333,3 @@ while (tokens[0][0] !== 'word') { | ||
this.current.source.end = this.getPosition(token[2]) | ||
this.current.source.end.offset++ | ||
this.current = this.current.parent | ||
@@ -330,0 +336,0 @@ } else { |
@@ -10,3 +10,3 @@ 'use strict' | ||
constructor(plugins = []) { | ||
this.version = '8.4.28' | ||
this.version = '8.4.31' | ||
this.plugins = this.normalize(plugins) | ||
@@ -13,0 +13,0 @@ } |
@@ -154,12 +154,2 @@ import { | ||
/** | ||
* An alias for the `Result#css` property. | ||
* Use it with syntaxes that generate non-CSS output. | ||
* | ||
* ```js | ||
* result.css === result.content | ||
* ``` | ||
*/ | ||
get content(): string | ||
/** | ||
* Returns for `Result#css` content. | ||
@@ -203,2 +193,12 @@ * | ||
warnings(): Warning[] | ||
/** | ||
* An alias for the `Result#css` property. | ||
* Use it with syntaxes that generate non-CSS output. | ||
* | ||
* ```js | ||
* result.css === result.content | ||
* ``` | ||
*/ | ||
get content(): string | ||
} | ||
@@ -205,0 +205,0 @@ |
@@ -15,6 +15,2 @@ 'use strict' | ||
get content() { | ||
return this.css | ||
} | ||
toString() { | ||
@@ -40,2 +36,6 @@ return this.css | ||
} | ||
get content() { | ||
return this.css | ||
} | ||
} | ||
@@ -42,0 +42,0 @@ |
@@ -25,3 +25,3 @@ 'use strict' | ||
const RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g | ||
const RE_BAD_BRACKET = /.[\n"'(/\\]/ | ||
const RE_BAD_BRACKET = /.[\r\n"'(/\\]/ | ||
const RE_HEX_ESCAPE = /[\da-f]/i | ||
@@ -28,0 +28,0 @@ |
{ | ||
"name": "postcss", | ||
"version": "8.4.28", | ||
"version": "8.4.31", | ||
"description": "Tool for transforming styles with JS plugins", | ||
@@ -5,0 +5,0 @@ "engines": { |
@@ -12,16 +12,9 @@ # PostCSS | ||
PostCSS is used by industry leaders including Wikipedia, Twitter, Alibaba, | ||
and JetBrains. The [Autoprefixer] PostCSS plugin is one of the most popular | ||
CSS processors. | ||
and JetBrains. The [Autoprefixer] and [Stylelint] PostCSS plugins is one of the most popular CSS tools. | ||
PostCSS takes a CSS file and provides an API to analyze and modify its rules | ||
(by transforming them into an [Abstract Syntax Tree]). | ||
This API can then be used by [plugins] to do a lot of useful things, | ||
e.g., to find errors automatically, or to insert vendor prefixes. | ||
--- | ||
**Twitter account:** [@postcss](https://twitter.com/postcss)<br> | ||
**中文翻译**: [`docs/README-cn.md`](./docs/README-cn.md) | ||
<img src="https://cdn.evilmartians.com/badges/logo-no-label.svg" alt="" width="22" height="16" /> Made in <b><a href="https://evilmartians.com/?utm_source=postcss&utm_campaign=devtools-button&utm_medium=github">Evil Martians</a></b>, product consulting for <b>developer tools</b>. | ||
For PostCSS commercial support (consulting, improving the front-end culture | ||
of your company, PostCSS plugins), contact [Evil Martians] | ||
at <postcss@evilmartians.com>. | ||
--- | ||
@@ -31,11 +24,7 @@ [Abstract Syntax Tree]: https://en.wikipedia.org/wiki/Abstract_syntax_tree | ||
[Autoprefixer]: https://github.com/postcss/autoprefixer | ||
[Stylelint]: https://stylelint.io/ | ||
[plugins]: https://github.com/postcss/postcss#plugins | ||
<a href="https://evilmartians.com/?utm_source=postcss"> | ||
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" | ||
alt="Sponsored by Evil Martians" width="236" height="54"> | ||
</a> | ||
## Docs | ||
Read full docs **[here](https://postcss.org/)**. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
196517
6745
29