Comparing version
@@ -100,3 +100,3 @@ import Container, { | ||
*/ | ||
nodes: Container['nodes'] | ||
nodes: Container['nodes'] | undefined | ||
parent: ContainerWithChildren | undefined | ||
@@ -106,10 +106,2 @@ | ||
type: 'atrule' | ||
constructor(defaults?: AtRule.AtRuleProps) | ||
assign(overrides: AtRule.AtRuleProps | object): this | ||
clone(overrides?: Partial<AtRule.AtRuleProps>): this | ||
cloneAfter(overrides?: Partial<AtRule.AtRuleProps>): this | ||
cloneBefore(overrides?: Partial<AtRule.AtRuleProps>): this | ||
/** | ||
@@ -126,2 +118,3 @@ * The at-rule’s name immediately follows the `@`. | ||
set name(value: string) | ||
/** | ||
@@ -138,3 +131,10 @@ * The at-rule’s parameters, the values that follow the at-rule’s name | ||
get params(): string | ||
set params(value: string) | ||
constructor(defaults?: AtRule.AtRuleProps) | ||
assign(overrides: AtRule.AtRuleProps | object): this | ||
clone(overrides?: Partial<AtRule.AtRuleProps>): this | ||
cloneAfter(overrides?: Partial<AtRule.AtRuleProps>): this | ||
cloneBefore(overrides?: Partial<AtRule.AtRuleProps>): this | ||
} | ||
@@ -141,0 +141,0 @@ |
@@ -52,14 +52,14 @@ import Container from './container.js' | ||
type: 'comment' | ||
/** | ||
* The comment's text. | ||
*/ | ||
get text(): string | ||
set text(value: string) | ||
constructor(defaults?: Comment.CommentProps) | ||
assign(overrides: Comment.CommentProps | object): this | ||
clone(overrides?: Partial<Comment.CommentProps>): this | ||
cloneAfter(overrides?: Partial<Comment.CommentProps>): this | ||
cloneBefore(overrides?: Partial<Comment.CommentProps>): this | ||
/** | ||
* The comment's text. | ||
*/ | ||
get text(): string | ||
set text(value: string) | ||
} | ||
@@ -66,0 +66,0 @@ |
@@ -68,22 +68,19 @@ import AtRule from './at-rule.js' | ||
/** | ||
* An internal method that converts a {@link NewChild} into a list of actual | ||
* child nodes that can then be added to this container. | ||
* The container’s first child. | ||
* | ||
* This ensures that the nodes' parent is set to this container, that they use | ||
* the correct prototype chain, and that they're marked as dirty. | ||
* | ||
* @param mnodes The new node or nodes to add. | ||
* @param sample A node from whose raws the new node's `before` raw should be | ||
* taken. | ||
* @param type This should be set to `'prepend'` if the new nodes will be | ||
* inserted at the beginning of the container. | ||
* @hidden | ||
* ```js | ||
* rule.first === rules.nodes[0] | ||
* ``` | ||
*/ | ||
protected normalize( | ||
nodes: Container.NewChild, | ||
sample: Node | undefined, | ||
type?: 'prepend' | false | ||
): Child[] | ||
get first(): Child | undefined | ||
/** | ||
* The container’s last child. | ||
* | ||
* ```js | ||
* rule.last === rule.nodes[rule.nodes.length - 1] | ||
* ``` | ||
*/ | ||
get last(): Child | undefined | ||
/** | ||
* Inserts new nodes to the end of the container. | ||
@@ -111,6 +108,6 @@ * | ||
clone(overrides?: Partial<Container.ContainerProps>): this | ||
cloneAfter(overrides?: Partial<Container.ContainerProps>): this | ||
cloneBefore(overrides?: Partial<Container.ContainerProps>): this | ||
/** | ||
@@ -152,2 +149,3 @@ * Iterates through the container’s immediate children, | ||
): false | undefined | ||
/** | ||
@@ -167,3 +165,2 @@ * Returns `true` if callback returns `true` | ||
): boolean | ||
/** | ||
@@ -180,2 +177,3 @@ * Returns a `child`’s index within the `Container#nodes` array. | ||
index(child: Child | number): number | ||
/** | ||
@@ -191,15 +189,2 @@ * Insert new node after old node within the container. | ||
/** | ||
* Insert new node before old node within the container. | ||
* | ||
* ```js | ||
* rule.insertBefore(decl, decl.clone({ prop: '-webkit-' + decl.prop })) | ||
* ``` | ||
* | ||
* @param oldNode Child or child’s index. | ||
* @param newNode New node. | ||
* @return This node for methods chain. | ||
*/ | ||
insertBefore(oldNode: Child | number, newNode: Container.NewChild): this | ||
/** | ||
* Traverses the container’s descendant nodes, calling callback | ||
@@ -222,2 +207,14 @@ * for each comment node. | ||
/** | ||
* Insert new node before old node within the container. | ||
* | ||
* ```js | ||
* rule.insertBefore(decl, decl.clone({ prop: '-webkit-' + decl.prop })) | ||
* ``` | ||
* | ||
* @param oldNode Child or child’s index. | ||
* @param newNode New node. | ||
* @return This node for methods chain. | ||
*/ | ||
insertBefore(oldNode: Child | number, newNode: Container.NewChild): this | ||
/** | ||
* Inserts new nodes to the start of the container. | ||
@@ -243,2 +240,3 @@ * | ||
prepend(...nodes: Container.NewChild[]): this | ||
/** | ||
@@ -289,3 +287,2 @@ * Add child to the end of the node. | ||
): this | ||
/** | ||
@@ -391,10 +388,9 @@ * Passes all declaration values within the container that match pattern | ||
): false | undefined | ||
walkAtRules( | ||
callback: (atRule: AtRule, index: number) => false | void | ||
): false | undefined | ||
walkComments( | ||
callback: (comment: Comment, indexed: number) => false | void | ||
): false | undefined | ||
walkComments( | ||
@@ -437,7 +433,5 @@ callback: (comment: Comment, indexed: number) => false | void | ||
): false | undefined | ||
walkDecls( | ||
callback: (decl: Declaration, index: number) => false | void | ||
): false | undefined | ||
/** | ||
@@ -473,17 +467,20 @@ * Traverses the container’s descendant nodes, calling callback | ||
/** | ||
* The container’s first child. | ||
* An internal method that converts a {@link NewChild} into a list of actual | ||
* child nodes that can then be added to this container. | ||
* | ||
* ```js | ||
* rule.first === rules.nodes[0] | ||
* ``` | ||
*/ | ||
get first(): Child | undefined | ||
/** | ||
* The container’s last child. | ||
* This ensures that the nodes' parent is set to this container, that they use | ||
* the correct prototype chain, and that they're marked as dirty. | ||
* | ||
* ```js | ||
* rule.last === rule.nodes[rule.nodes.length - 1] | ||
* ``` | ||
* @param mnodes The new node or nodes to add. | ||
* @param sample A node from whose raws the new node's `before` raw should be | ||
* taken. | ||
* @param type This should be set to `'prepend'` if the new nodes will be | ||
* inserted at the beginning of the container. | ||
* @hidden | ||
*/ | ||
get last(): Child | undefined | ||
protected normalize( | ||
nodes: Container.NewChild, | ||
sample: Node | undefined, | ||
type?: 'prepend' | false | ||
): Child[] | ||
} | ||
@@ -490,0 +487,0 @@ |
@@ -28,2 +28,12 @@ 'use strict' | ||
class Container extends Node { | ||
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] | ||
} | ||
append(...children) { | ||
@@ -395,12 +405,2 @@ for (let child of children) { | ||
} | ||
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] | ||
} | ||
} | ||
@@ -407,0 +407,0 @@ |
@@ -71,10 +71,2 @@ import { ContainerWithChildren } from './container.js' | ||
constructor(defaults?: Declaration.DeclarationProps) | ||
assign(overrides: Declaration.DeclarationProps | object): this | ||
clone(overrides?: Partial<Declaration.DeclarationProps>): this | ||
cloneAfter(overrides?: Partial<Declaration.DeclarationProps>): this | ||
cloneBefore(overrides?: Partial<Declaration.DeclarationProps>): this | ||
/** | ||
@@ -95,4 +87,4 @@ * It represents a specificity of the declaration. | ||
get important(): boolean | ||
set important(value: boolean) | ||
set important(value: boolean) | ||
/** | ||
@@ -111,2 +103,3 @@ * The property name for a CSS declaration. | ||
set prop(value: string) | ||
/** | ||
@@ -131,2 +124,3 @@ * The property value for a CSS declaration. | ||
set value(value: string) | ||
/** | ||
@@ -151,2 +145,8 @@ * It represents a getter that returns `true` if a declaration starts with | ||
get variable(): boolean | ||
constructor(defaults?: Declaration.DeclarationProps) | ||
assign(overrides: Declaration.DeclarationProps | object): this | ||
clone(overrides?: Partial<Declaration.DeclarationProps>): this | ||
cloneAfter(overrides?: Partial<Declaration.DeclarationProps>): this | ||
cloneBefore(overrides?: Partial<Declaration.DeclarationProps>): this | ||
} | ||
@@ -153,0 +153,0 @@ |
@@ -6,2 +6,6 @@ 'use strict' | ||
class Declaration extends Node { | ||
get variable() { | ||
return this.prop.startsWith('--') || this.prop[0] === '$' | ||
} | ||
constructor(defaults) { | ||
@@ -18,6 +22,2 @@ if ( | ||
} | ||
get variable() { | ||
return this.prop.startsWith('--') || this.prop[0] === '$' | ||
} | ||
} | ||
@@ -24,0 +24,0 @@ |
@@ -115,2 +115,16 @@ 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 | ||
/** | ||
* @param css Input CSS source. | ||
@@ -141,3 +155,2 @@ * @param opts Process options. | ||
): CssSyntaxError | ||
/** | ||
@@ -152,3 +165,2 @@ * Returns `CssSyntaxError` with information about the error and its position. | ||
): CssSyntaxError | ||
error( | ||
@@ -159,3 +171,2 @@ message: string, | ||
): CssSyntaxError | ||
/** | ||
@@ -192,18 +203,5 @@ * Converts source offset to line and column. | ||
): false | Input.FilePosition | ||
/** Converts this to a JSON-friendly object representation. */ | ||
toJSON(): object | ||
/** | ||
* 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 | ||
} | ||
@@ -210,0 +208,0 @@ |
@@ -18,2 +18,6 @@ 'use strict' | ||
class Input { | ||
get from() { | ||
return this.file || this.id | ||
} | ||
constructor(css, opts = {}) { | ||
@@ -241,6 +245,2 @@ if ( | ||
} | ||
get from() { | ||
return this.file || this.id | ||
} | ||
} | ||
@@ -247,0 +247,0 @@ |
@@ -71,42 +71,2 @@ import Document from './document.js' | ||
/** | ||
* @param processor Processor used for this transformation. | ||
* @param css CSS to parse and transform. | ||
* @param opts Options from the `Processor#process` or `Root#toResult`. | ||
*/ | ||
constructor(processor: Processor, css: string, opts: ResultOptions) | ||
/** | ||
* Run plugin in async way and return `Result`. | ||
* | ||
* @return Result with output content. | ||
*/ | ||
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 | ||
@@ -185,2 +145,42 @@ * that generate non-CSS output. | ||
get [Symbol.toStringTag](): string | ||
/** | ||
* @param processor Processor used for this transformation. | ||
* @param css CSS to parse and transform. | ||
* @param opts Options from the `Processor#process` or `Root#toResult`. | ||
*/ | ||
constructor(processor: Processor, css: string, opts: ResultOptions) | ||
/** | ||
* Run plugin in async way and return `Result`. | ||
* | ||
* @return Result with output content. | ||
*/ | ||
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[] | ||
} | ||
@@ -187,0 +187,0 @@ |
@@ -108,2 +108,34 @@ 'use strict' | ||
class LazyResult { | ||
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' | ||
} | ||
constructor(processor, css, opts) { | ||
@@ -509,34 +541,2 @@ this.stringified = false | ||
} | ||
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' | ||
} | ||
} | ||
@@ -543,0 +543,0 @@ |
@@ -29,7 +29,2 @@ import LazyResult from './lazy-result.js' | ||
then: Promise<Result<Root>>['then'] | ||
constructor(processor: Processor, css: string, opts: ResultOptions) | ||
async(): Promise<Result<Root>> | ||
sync(): Result<Root> | ||
toString(): string | ||
warnings(): Warning[] | ||
get content(): string | ||
@@ -43,2 +38,7 @@ get css(): string | ||
get [Symbol.toStringTag](): string | ||
constructor(processor: Processor, css: string, opts: ResultOptions) | ||
async(): Promise<Result<Root>> | ||
sync(): Result<Root> | ||
toString(): string | ||
warnings(): Warning[] | ||
} | ||
@@ -45,0 +45,0 @@ |
@@ -10,2 +10,52 @@ 'use strict' | ||
class NoWorkResult { | ||
get content() { | ||
return this.result.css | ||
} | ||
get css() { | ||
return this.result.css | ||
} | ||
get map() { | ||
return this.result.map | ||
} | ||
get messages() { | ||
return [] | ||
} | ||
get opts() { | ||
return this.result.opts | ||
} | ||
get processor() { | ||
return this.result.processor | ||
} | ||
get root() { | ||
if (this._root) { | ||
return this._root | ||
} | ||
let root | ||
let parser = parse | ||
try { | ||
root = parser(this._css, this._opts) | ||
} catch (error) { | ||
this.error = error | ||
} | ||
if (this.error) { | ||
throw this.error | ||
} else { | ||
this._root = root | ||
return root | ||
} | ||
} | ||
get [Symbol.toStringTag]() { | ||
return 'NoWorkResult' | ||
} | ||
constructor(processor, css, opts) { | ||
@@ -86,52 +136,2 @@ css = css.toString() | ||
} | ||
get content() { | ||
return this.result.css | ||
} | ||
get css() { | ||
return this.result.css | ||
} | ||
get map() { | ||
return this.result.map | ||
} | ||
get messages() { | ||
return [] | ||
} | ||
get opts() { | ||
return this.result.opts | ||
} | ||
get processor() { | ||
return this.result.processor | ||
} | ||
get root() { | ||
if (this._root) { | ||
return this._root | ||
} | ||
let root | ||
let parser = parse | ||
try { | ||
root = parser(this._css, this._opts) | ||
} catch (error) { | ||
this.error = error | ||
} | ||
if (this.error) { | ||
throw this.error | ||
} else { | ||
this._root = root | ||
return root | ||
} | ||
} | ||
get [Symbol.toStringTag]() { | ||
return 'NoWorkResult' | ||
} | ||
} | ||
@@ -138,0 +138,0 @@ |
@@ -238,10 +238,2 @@ import AtRule = require('./at-rule.js') | ||
/** | ||
* If this node isn't already dirty, marks it and its ancestors as such. This | ||
* indicates to the LazyResult processor that the {@link Root} has been | ||
* modified by the current plugin and may need to be processed again by other | ||
* plugins. | ||
*/ | ||
protected markDirty(): void | ||
/** | ||
* Insert new node after current node to current node’s parent. | ||
@@ -538,2 +530,10 @@ * | ||
warn(result: Result, message: string, options?: WarningOptions): Warning | ||
/** | ||
* If this node isn't already dirty, marks it and its ancestors as such. This | ||
* indicates to the LazyResult processor that the {@link Root} has been | ||
* modified by the current plugin and may need to be processed again by other | ||
* plugins. | ||
*/ | ||
protected markDirty(): void | ||
} | ||
@@ -540,0 +540,0 @@ |
@@ -66,2 +66,6 @@ 'use strict' | ||
class Node { | ||
get proxyOf() { | ||
return this | ||
} | ||
constructor(defaults = {}) { | ||
@@ -428,6 +432,2 @@ this.raws = {} | ||
} | ||
get proxyOf() { | ||
return this | ||
} | ||
} | ||
@@ -434,0 +434,0 @@ |
@@ -596,3 +596,3 @@ 'use strict' | ||
throw this.input.error( | ||
'Unknown word', | ||
'Unknown word ' + tokens[0][1], | ||
{ offset: tokens[0][2] }, | ||
@@ -599,0 +599,0 @@ { offset: tokens[0][2] + tokens[0][1].length } |
@@ -10,3 +10,3 @@ 'use strict' | ||
constructor(plugins = []) { | ||
this.version = '8.5.2' | ||
this.version = '8.5.3' | ||
this.plugins = this.normalize(plugins) | ||
@@ -13,0 +13,0 @@ } |
@@ -146,2 +146,12 @@ 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 | ||
/** | ||
* @param processor Processor used for this transformation. | ||
@@ -192,12 +202,2 @@ * @param root Root node after all transformations. | ||
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 | ||
} | ||
@@ -204,0 +204,0 @@ |
@@ -6,2 +6,6 @@ 'use strict' | ||
class Result { | ||
get content() { | ||
return this.css | ||
} | ||
constructor(processor, root, opts) { | ||
@@ -36,6 +40,2 @@ this.processor = processor | ||
} | ||
get content() { | ||
return this.css | ||
} | ||
} | ||
@@ -42,0 +42,0 @@ |
@@ -86,10 +86,2 @@ import Container, { | ||
type: 'rule' | ||
constructor(defaults?: Rule.RuleProps) | ||
assign(overrides: object | Rule.RuleProps): this | ||
clone(overrides?: Partial<Rule.RuleProps>): this | ||
cloneAfter(overrides?: Partial<Rule.RuleProps>): this | ||
cloneBefore(overrides?: Partial<Rule.RuleProps>): this | ||
/** | ||
@@ -105,2 +97,3 @@ * The rule’s full selector represented as a string. | ||
get selector(): string | ||
set selector(value: string) | ||
@@ -123,3 +116,10 @@ /** | ||
get selectors(): string[] | ||
set selectors(values: string[]) | ||
constructor(defaults?: Rule.RuleProps) | ||
assign(overrides: object | Rule.RuleProps): this | ||
clone(overrides?: Partial<Rule.RuleProps>): this | ||
cloneAfter(overrides?: Partial<Rule.RuleProps>): this | ||
cloneBefore(overrides?: Partial<Rule.RuleProps>): this | ||
} | ||
@@ -126,0 +126,0 @@ |
@@ -7,8 +7,2 @@ 'use strict' | ||
class Rule extends Container { | ||
constructor(defaults) { | ||
super(defaults) | ||
this.type = 'rule' | ||
if (!this.nodes) this.nodes = [] | ||
} | ||
get selectors() { | ||
@@ -23,2 +17,8 @@ return list.comma(this.selector) | ||
} | ||
constructor(defaults) { | ||
super(defaults) | ||
this.type = 'rule' | ||
if (!this.nodes) this.nodes = [] | ||
} | ||
} | ||
@@ -25,0 +25,0 @@ |
{ | ||
"name": "postcss", | ||
"version": "8.5.2", | ||
"version": "8.5.3", | ||
"description": "Tool for transforming styles with JS plugins", | ||
@@ -5,0 +5,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
201969
0.01%