+3
-3
@@ -108,5 +108,5 @@ import Container, { ContainerProps } from './container.js' | ||
| assign(overrides: AtRule.AtRuleProps | object): this | ||
| clone(overrides?: Partial<AtRule.AtRuleProps>): this | ||
| cloneAfter(overrides?: Partial<AtRule.AtRuleProps>): this | ||
| cloneBefore(overrides?: Partial<AtRule.AtRuleProps>): this | ||
| clone(overrides?: Partial<AtRule.AtRuleProps>): AtRule | ||
| cloneAfter(overrides?: Partial<AtRule.AtRuleProps>): AtRule | ||
| cloneBefore(overrides?: Partial<AtRule.AtRuleProps>): AtRule | ||
| } | ||
@@ -113,0 +113,0 @@ |
+3
-3
@@ -60,5 +60,5 @@ import Container from './container.js' | ||
| assign(overrides: Comment.CommentProps | object): this | ||
| clone(overrides?: Partial<Comment.CommentProps>): this | ||
| cloneAfter(overrides?: Partial<Comment.CommentProps>): this | ||
| cloneBefore(overrides?: Partial<Comment.CommentProps>): this | ||
| clone(overrides?: Partial<Comment.CommentProps>): Comment | ||
| cloneAfter(overrides?: Partial<Comment.CommentProps>): Comment | ||
| cloneBefore(overrides?: Partial<Comment.CommentProps>): Comment | ||
| } | ||
@@ -65,0 +65,0 @@ |
+49
-48
@@ -35,5 +35,3 @@ import AtRule from './at-rule.js' | ||
| */ | ||
| declare abstract class Container_< | ||
| Child extends Node = ChildNode | ||
| > extends Node { | ||
| declare abstract class Container_<Child extends Node = ChildNode> extends Node { | ||
| /** | ||
@@ -75,2 +73,7 @@ * An array containing the container’s children. | ||
| assign(overrides: Container.ContainerProps | object): this | ||
| clone(overrides?: Partial<Container.ContainerProps>): Container<Child> | ||
| cloneAfter(overrides?: Partial<Container.ContainerProps>): Container<Child> | ||
| cloneBefore(overrides?: Partial<Container.ContainerProps>): Container<Child> | ||
| /** | ||
@@ -127,13 +130,3 @@ * Iterates through the container’s immediate children, | ||
| ): boolean | ||
| /** | ||
| * 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 +142,3 @@ * | ||
| index(child: Child | number): number | ||
| /** | ||
@@ -161,3 +155,2 @@ * Insert new node after old node within the container. | ||
| ): this | ||
| /** | ||
@@ -178,10 +171,19 @@ * Insert new node before old node within the container. | ||
| ): 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 | ||
@@ -224,19 +226,2 @@ /** | ||
| /** | ||
| * 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. | ||
| */ | ||
| /** | ||
| * Removes all children from the container | ||
@@ -253,2 +238,3 @@ * and cleans their parent properties. | ||
| removeAll(): this | ||
| /** | ||
@@ -270,2 +256,7 @@ * Removes node from the container and cleans the parent properties | ||
| replaceValues( | ||
| pattern: RegExp | string, | ||
| replaced: { (substring: string, ...args: any[]): string } | string | ||
| ): this | ||
| /** | ||
@@ -300,7 +291,2 @@ * Passes all declaration values within the container that match pattern | ||
| replaceValues( | ||
| pattern: RegExp | string, | ||
| replaced: { (substring: string, ...args: any[]): string } | string | ||
| ): this | ||
| /** | ||
@@ -344,6 +330,2 @@ * Returns `true` if callback returns `true` for (at least) one | ||
| walkAtRules( | ||
| callback: (atRule: AtRule, index: number) => false | void | ||
| ): false | undefined | ||
| /** | ||
@@ -383,2 +365,5 @@ * Traverses the container’s descendant nodes, calling callback | ||
| walkAtRules( | ||
| callback: (atRule: AtRule, index: number) => false | void | ||
| ): false | undefined | ||
| walkComments( | ||
@@ -391,5 +376,2 @@ callback: (comment: Comment, indexed: number) => false | void | ||
| ): false | undefined | ||
| walkDecls( | ||
| callback: (decl: Declaration, index: number) => false | void | ||
| ): false | undefined | ||
@@ -430,4 +412,4 @@ /** | ||
| walkRules( | ||
| callback: (rule: Rule, index: number) => false | void | ||
| walkDecls( | ||
| callback: (decl: Declaration, index: number) => false | void | ||
| ): false | undefined | ||
@@ -461,2 +443,21 @@ | ||
| ): false | undefined | ||
| walkRules( | ||
| callback: (rule: Rule, index: number) => false | void | ||
| ): 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 | ||
| } | ||
@@ -463,0 +464,0 @@ |
+10
-10
@@ -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 @@ |
+16
-14
@@ -61,4 +61,4 @@ import Container from './container.js' | ||
| * | ||
| * console.log(decl.type) //=> 'decl' | ||
| * console.log(decl.toString()) //=> ' color: black' | ||
| * decl.type //=> 'decl' | ||
| * decl.toString() //=> ' color: black' | ||
| * ``` | ||
@@ -77,8 +77,10 @@ */ | ||
| * | ||
| * console.log(root.first?.first?.important) //=> true | ||
| * console.log(root.first?.last?.important) //=> undefined | ||
| * root.first.first.important //=> true | ||
| * root.first.last.important //=> undefined | ||
| * ``` | ||
| */ | ||
| important: boolean | ||
| parent: Container | undefined | ||
| /** | ||
@@ -89,5 +91,5 @@ * The property name for a CSS declaration. | ||
| * const root = postcss.parse('a { color: black }') | ||
| * const decl = root.first?.first | ||
| * const decl = root.first.first | ||
| * | ||
| * console.log(decl.prop) //=> 'color' | ||
| * decl.prop //=> 'color' | ||
| * ``` | ||
@@ -113,5 +115,5 @@ */ | ||
| * const root = postcss.parse('a { color: black }') | ||
| * const decl = root.first?.first | ||
| * const decl = root.first.first | ||
| * | ||
| * console.log(decl.value) //=> 'black' | ||
| * decl.value //=> 'black' | ||
| * ``` | ||
@@ -127,5 +129,5 @@ */ | ||
| * const root = postcss.parse(':root { --one: 1 }') | ||
| * const one = root.first?.first | ||
| * const one = root.first.first | ||
| * | ||
| * console.log(one?.variable) //=> true | ||
| * one.variable //=> true | ||
| * ``` | ||
@@ -137,3 +139,3 @@ * | ||
| * | ||
| * console.log(one?.variable) //=> true | ||
| * one.variable //=> true | ||
| * ``` | ||
@@ -145,5 +147,5 @@ */ | ||
| assign(overrides: Declaration.DeclarationProps | object): this | ||
| clone(overrides?: Partial<Declaration.DeclarationProps>): this | ||
| cloneAfter(overrides?: Partial<Declaration.DeclarationProps>): this | ||
| cloneBefore(overrides?: Partial<Declaration.DeclarationProps>): this | ||
| clone(overrides?: Partial<Declaration.DeclarationProps>): Declaration | ||
| cloneAfter(overrides?: Partial<Declaration.DeclarationProps>): Declaration | ||
| cloneBefore(overrides?: Partial<Declaration.DeclarationProps>): Declaration | ||
| } | ||
@@ -150,0 +152,0 @@ |
@@ -43,2 +43,7 @@ import Container, { ContainerProps } from './container.js' | ||
| assign(overrides: Document.DocumentProps | object): this | ||
| clone(overrides?: Partial<Document.DocumentProps>): Document | ||
| cloneAfter(overrides?: Partial<Document.DocumentProps>): Document | ||
| cloneBefore(overrides?: Partial<Document.DocumentProps>): Document | ||
| /** | ||
@@ -45,0 +50,0 @@ * Returns a `Result` instance representing the document’s CSS roots. |
+13
-13
@@ -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 @@ |
+4
-4
@@ -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 @@ |
+38
-33
@@ -0,1 +1,2 @@ | ||
| import Document from './document.js' | ||
| import { SourceMap } from './postcss.js' | ||
@@ -21,3 +22,5 @@ import Processor from './processor.js' | ||
| */ | ||
| declare class LazyResult_ implements PromiseLike<Result> { | ||
| declare class LazyResult_<RootNode = Document | Root> | ||
| implements PromiseLike<Result<RootNode>> | ||
| { | ||
| /** | ||
@@ -37,3 +40,3 @@ * Processes input CSS through synchronous and asynchronous plugins | ||
| */ | ||
| catch: Promise<Result>['catch'] | ||
| catch: Promise<Result<RootNode>>['catch'] | ||
@@ -52,3 +55,3 @@ /** | ||
| */ | ||
| finally: Promise<Result>['finally'] | ||
| finally: Promise<Result<RootNode>>['finally'] | ||
@@ -68,3 +71,3 @@ /** | ||
| */ | ||
| then: Promise<Result>['then'] | ||
| then: Promise<Result<RootNode>>['then'] | ||
@@ -83,5 +86,31 @@ /** | ||
| */ | ||
| async(): Promise<Result> | ||
| async(): Promise<Result<RootNode>> | ||
| /** | ||
| * 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 | ||
@@ -153,3 +182,3 @@ * that generate non-CSS output. | ||
| */ | ||
| get root(): Root | ||
| get root(): RootNode | ||
@@ -161,32 +190,8 @@ /** | ||
| get [Symbol.toStringTag](): string | ||
| /** | ||
| * Run plugin in sync way and return `Result`. | ||
| * | ||
| * @return Result with output content. | ||
| */ | ||
| sync(): Result | ||
| /** | ||
| * 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[] | ||
| } | ||
| declare class LazyResult extends LazyResult_ {} | ||
| declare class LazyResult< | ||
| RootNode = Document | Root | ||
| > extends LazyResult_<RootNode> {} | ||
| export = LazyResult |
+32
-32
@@ -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 @@ |
+27
-6
@@ -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 @@ } |
@@ -25,8 +25,11 @@ import LazyResult from './lazy-result.js' | ||
| */ | ||
| declare class NoWorkResult_ implements LazyResult { | ||
| catch: Promise<Result>['catch'] | ||
| finally: Promise<Result>['finally'] | ||
| then: Promise<Result>['then'] | ||
| declare class NoWorkResult_ implements LazyResult<Root> { | ||
| catch: Promise<Result<Root>>['catch'] | ||
| finally: Promise<Result<Root>>['finally'] | ||
| then: Promise<Result<Root>>['then'] | ||
| constructor(processor: Processor, css: string, opts: ResultOptions) | ||
| async(): Promise<Result> | ||
| 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 | ||
| toString(): string | ||
| warnings(): Warning[] | ||
| } | ||
@@ -45,0 +45,0 @@ |
+31
-31
@@ -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 @@ |
+10
-10
@@ -131,3 +131,3 @@ import AtRule = require('./at-rule.js') | ||
| * ```js | ||
| * console.log(root.nodes[0].parent === root) //=> true | ||
| * root.nodes[0].parent === root //=> true | ||
| * ``` | ||
@@ -168,3 +168,3 @@ */ | ||
| * const root = postcss.parse('a {\n color:black\n}') | ||
| * console.log(root.first.first.raws) //=> { before: '\n ', between: ':' } | ||
| * root.first.first.raws //=> { before: '\n ', between: ':' } | ||
| * ``` | ||
@@ -188,5 +188,5 @@ */ | ||
| * ```js | ||
| * console.log(decl.source.input.from) //=> '/home/ai/source.css' | ||
| * console.log(decl.source.start) //=> { line: 10, column: 2 } | ||
| * console.log(decl.source.end) //=> { line: 10, column: 12 } | ||
| * decl.source.input.from //=> '/home/ai/source.css' | ||
| * decl.source.start //=> { line: 10, column: 2 } | ||
| * decl.source.end //=> { line: 10, column: 12 } | ||
| * ``` | ||
@@ -233,3 +233,3 @@ * | ||
| * | ||
| * console.log(declaration.type) //=> 'decl' | ||
| * declaration.type //=> 'decl' | ||
| * ``` | ||
@@ -310,3 +310,3 @@ */ | ||
| */ | ||
| clone(overrides?: object): Node_ | ||
| clone(overrides?: object): Node | ||
@@ -320,3 +320,3 @@ /** | ||
| */ | ||
| cloneAfter(overrides?: object): this | ||
| cloneAfter(overrides?: object): Node | ||
@@ -335,3 +335,3 @@ /** | ||
| */ | ||
| cloneBefore(overrides?: object): this | ||
| cloneBefore(overrides?: object): Node | ||
@@ -512,3 +512,3 @@ /** | ||
| * ```js | ||
| * console.log(new Rule({ selector: 'a' }).toString()) //=> "a {}" | ||
| * new Rule({ selector: 'a' }).toString() //=> "a {}" | ||
| * ``` | ||
@@ -515,0 +515,0 @@ * |
+4
-4
@@ -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 @@ |
+7
-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 | ||
@@ -341,2 +347,3 @@ } else { | ||
| this.current.raws.after = (this.current.raws.after || '') + this.spaces | ||
| this.root.source.end = this.getPosition(this.tokenizer.position()) | ||
| } | ||
@@ -343,0 +350,0 @@ |
+7
-7
@@ -239,7 +239,7 @@ import { RawSourceMap, SourceMapGenerator } from 'source-map-js' | ||
| export interface Syntax { | ||
| export interface Syntax<RootNode = Document | Root> { | ||
| /** | ||
| * Function to generate AST by string. | ||
| */ | ||
| parse?: Parser | ||
| parse?: Parser<RootNode> | ||
@@ -308,3 +308,3 @@ /** | ||
| export interface ProcessOptions { | ||
| export interface ProcessOptions<RootNode = Document | Root> { | ||
| /** | ||
@@ -314,3 +314,3 @@ * The path of the CSS source file. You should always set `from`, | ||
| */ | ||
| from?: string | ||
| from?: string | undefined | ||
@@ -325,3 +325,3 @@ /** | ||
| */ | ||
| parser?: Parser | Syntax | ||
| parser?: Parser<RootNode> | Syntax<RootNode> | ||
@@ -331,3 +331,3 @@ /** | ||
| */ | ||
| stringifier?: Stringifier | Syntax | ||
| stringifier?: Stringifier | Syntax<RootNode> | ||
@@ -337,3 +337,3 @@ /** | ||
| */ | ||
| syntax?: Syntax | ||
| syntax?: Syntax<RootNode> | ||
@@ -340,0 +340,0 @@ /** |
@@ -0,1 +1,2 @@ | ||
| import Document from './document.js' | ||
| import LazyResult from './lazy-result.js' | ||
@@ -75,5 +76,8 @@ import NoWorkResult from './no-work-result.js' | ||
| process( | ||
| css: { toString(): string } | LazyResult | Result | Root | string | ||
| ): LazyResult | NoWorkResult | ||
| process<RootNode extends Document | Root = Root>( | ||
| css: { toString(): string } | LazyResult | Result | Root | string, | ||
| options?: ProcessOptions | ||
| ): LazyResult | NoWorkResult | ||
| options: ProcessOptions<RootNode> | ||
| ): LazyResult<RootNode> | ||
@@ -80,0 +84,0 @@ /** |
+1
-1
@@ -10,3 +10,3 @@ 'use strict' | ||
| constructor(plugins = []) { | ||
| this.version = '8.4.25' | ||
| this.version = '8.4.32' | ||
| this.plugins = this.normalize(plugins) | ||
@@ -13,0 +13,0 @@ } |
+14
-14
@@ -63,3 +63,3 @@ import { | ||
| */ | ||
| declare class Result_ { | ||
| declare class Result_<RootNode = Document | Root> { | ||
| /** | ||
@@ -145,3 +145,3 @@ * A CSS string representing of `Result#root`. | ||
| */ | ||
| root: Document | Root | ||
| root: RootNode | ||
@@ -153,15 +153,5 @@ /** | ||
| */ | ||
| constructor(processor: Processor, root: Document | Root, opts: Result.ResultOptions) | ||
| constructor(processor: Processor, root: RootNode, opts: Result.ResultOptions) | ||
| /** | ||
| * 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. | ||
@@ -205,6 +195,16 @@ * | ||
| 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 | ||
| } | ||
| declare class Result extends Result_ {} | ||
| declare class Result<RootNode = Document | Root> extends Result_<RootNode> {} | ||
| export = Result |
+4
-4
@@ -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 @@ |
+5
-1
@@ -64,2 +64,6 @@ import Container, { ContainerProps } from './container.js' | ||
| assign(overrides: object | Root.RootProps): this | ||
| clone(overrides?: Partial<Root.RootProps>): Root | ||
| cloneAfter(overrides?: Partial<Root.RootProps>): Root | ||
| cloneBefore(overrides?: Partial<Root.RootProps>): Root | ||
| /** | ||
@@ -78,3 +82,3 @@ * Returns a `Result` instance representing the root’s CSS. | ||
| */ | ||
| toResult(options?: ProcessOptions): Result | ||
| toResult(options?: ProcessOptions): Result | ||
| } | ||
@@ -81,0 +85,0 @@ |
+3
-3
@@ -106,5 +106,5 @@ import Container, { ContainerProps } from './container.js' | ||
| assign(overrides: object | Rule.RuleProps): this | ||
| clone(overrides?: Partial<Rule.RuleProps>): this | ||
| cloneAfter(overrides?: Partial<Rule.RuleProps>): this | ||
| cloneBefore(overrides?: Partial<Rule.RuleProps>): this | ||
| clone(overrides?: Partial<Rule.RuleProps>): Rule | ||
| cloneAfter(overrides?: Partial<Rule.RuleProps>): Rule | ||
| cloneBefore(overrides?: Partial<Rule.RuleProps>): Rule | ||
| } | ||
@@ -111,0 +111,0 @@ |
+1
-1
@@ -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 @@ |
+2
-2
| { | ||
| "name": "postcss", | ||
| "version": "8.4.25", | ||
| "version": "8.4.32", | ||
| "description": "Tool for transforming styles with JS plugins", | ||
@@ -77,3 +77,3 @@ "engines": { | ||
| "dependencies": { | ||
| "nanoid": "^3.3.6", | ||
| "nanoid": "^3.3.7", | ||
| "picocolors": "^1.0.0", | ||
@@ -80,0 +80,0 @@ "source-map-js": "^1.0.2" |
+6
-22
@@ -1,2 +0,2 @@ | ||
| # PostCSS [![Gitter][chat-img]][chat] | ||
| # PostCSS | ||
@@ -7,5 +7,2 @@ <img align="right" width="95" height="95" | ||
| [chat-img]: https://img.shields.io/badge/Gitter-Join_the_PostCSS_chat-brightgreen.svg | ||
| [chat]: https://gitter.im/postcss/postcss | ||
| PostCSS is a tool for transforming styles with JS plugins. | ||
@@ -16,18 +13,9 @@ These plugins can lint your CSS, support variables and mixins, | ||
| 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. | ||
| --- | ||
| **Support / Discussion:** [Gitter](https://gitter.im/postcss/postcss)<br> | ||
| **Twitter account:** [@postcss](https://twitter.com/postcss)<br> | ||
| **VK.com page:** [postcss](https://vk.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/devtools?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>. | ||
| --- | ||
@@ -37,11 +25,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/)**. |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
196537
0.61%6745
0.58%29
-35.56%Updated