Начат фронтенд

This commit is contained in:
Georgiy Syralev
2025-09-16 14:47:30 +03:00
parent f37e85e2e0
commit 40de29041d
2100 changed files with 305701 additions and 11807 deletions

648
node_modules/postcss/lib/node.d.ts generated vendored
View File

@@ -1,162 +1,166 @@
import AtRule = require('./at-rule.js')
import { AtRuleProps } from './at-rule.js'
import Comment, { CommentProps } from './comment.js'
import Container, { NewChild } from './container.js'
import CssSyntaxError from './css-syntax-error.js'
import Declaration, { DeclarationProps } from './declaration.js'
import Document from './document.js'
import Input from './input.js'
import Comment, { CommentProps } from './comment.js'
import { Stringifier, Syntax } from './postcss.js'
import Result from './result.js'
import Root from './root.js'
import AtRule, { AtRuleProps } from './at-rule.js'
import Rule, { RuleProps } from './rule.js'
import Warning, { WarningOptions } from './warning.js'
import CssSyntaxError from './css-syntax-error.js'
import Result from './result.js'
import Input from './input.js'
import Root from './root.js'
import Document from './document.js'
import Container from './container.js'
declare namespace Node {
export type ChildNode = AtRule.default | Comment | Declaration | Rule
export type ChildNode = AtRule | Rule | Declaration | Comment
export type AnyNode =
| AtRule.default
| Comment
| Declaration
| Document
| Root
| Rule
export type AnyNode = AtRule | Rule | Declaration | Comment | Root | Document
export type ChildProps =
| AtRuleProps
| CommentProps
| DeclarationProps
| RuleProps
export type ChildProps =
| AtRuleProps
| RuleProps
| DeclarationProps
| CommentProps
export interface Position {
/**
* Source line in file. In contrast to `offset` it starts from 1.
*/
column: number
/**
* Source column in file.
*/
line: number
/**
* Source offset in file. It starts from 0.
*/
offset: number
}
export interface Range {
/**
* End position, exclusive.
*/
end: Position
/**
* Start position, inclusive.
*/
start: Position
}
export interface Position {
/**
* Source offset in file. It starts from 0.
*/
offset: number
/**
* Source represents an interface for the {@link Node.source} property.
* Source line in file. In contrast to `offset` it starts from 1.
*/
export interface Source {
/**
* The inclusive ending position for the source
* code of a node.
*
* However, `end.offset` of a non `Root` node is the exclusive position.
* See https://github.com/postcss/postcss/pull/1879 for details.
*
* ```js
* const root = postcss.parse('a { color: black }')
* const a = root.first
* const color = a.first
*
* // The offset of `Root` node is the inclusive position
* css.source.end // { line: 1, column: 19, offset: 18 }
*
* // The offset of non `Root` node is the exclusive position
* a.source.end // { line: 1, column: 18, offset: 18 }
* color.source.end // { line: 1, column: 16, offset: 16 }
* ```
*/
end?: Position
/**
* The source file from where a node has originated.
*/
input: Input
/**
* The inclusive starting position for the source
* code of a node.
*/
start?: Position
}
column: number
/**
* Interface represents an interface for an object received
* as parameter by Node class constructor.
* Source column in file.
*/
export interface NodeProps {
source?: Source
}
line: number
}
export interface NodeErrorOptions {
/**
* An ending index inside a node's string that should be highlighted as
* source of error.
*/
endIndex?: number
/**
* An index inside a node's string that should be highlighted as source
* of error.
*/
index?: number
/**
* Plugin name that created this error. PostCSS will set it automatically.
*/
plugin?: string
/**
* A word inside a node's string, that should be highlighted as source
* of error.
*/
word?: string
}
export interface Range {
/**
* Start position, inclusive.
*/
start: Position
// eslint-disable-next-line @typescript-eslint/no-shadow
class Node extends Node_ {}
export { Node as default }
/**
* End position, exclusive.
*/
end: Position
}
export interface Source {
/**
* The file source of the node.
*/
input: Input
/**
* The inclusive starting position of the nodes source.
*/
start?: Position
/**
* The inclusive ending position of the node's source.
*/
end?: Position
}
export interface NodeProps {
source?: Source
}
interface NodeErrorOptions {
/**
* Plugin name that created this error. PostCSS will set it automatically.
*/
plugin?: string
/**
* A word inside a node's string, that should be highlighted as source
* of error.
*/
word?: string
/**
* An index inside a node's string that should be highlighted as source
* of error.
*/
index?: number
/**
* An ending index inside a node's string that should be highlighted as
* source of error.
*/
endIndex?: number
}
/**
* It represents an abstract class that handles common
* methods for other CSS abstract syntax tree nodes.
* All node classes inherit the following common methods.
*
* Any node that represents CSS selector or value should
* not extend the `Node` class.
* You should not extend this classes to create AST for selector or value
* parser.
*/
declare abstract class Node_ {
export default abstract class Node {
/**
* It represents parent of the current node.
* tring representing the nodes type. Possible values are `root`, `atrule`,
* `rule`, `decl`, or `comment`.
*
* ```js
* root.nodes[0].parent === root //=> true
* new Declaration({ prop: 'color', value: 'black' }).type //=> 'decl'
* ```
*/
parent: Container | Document | undefined
type: string
/**
* It represents unnecessary whitespace and characters present
* in the css source code.
* The nodes parent node.
*
* ```js
* root.nodes[0].parent === root
* ```
*/
parent: Document | Container | undefined
/**
* The input source of the node.
*
* The property is used in source map generation.
*
* If you create a node manually (e.g., with `postcss.decl()`),
* that node will not have a `source` property and will be absent
* from the source map. For this reason, the plugin developer should
* consider cloning nodes to create new ones (in which case the new nodes
* source will reference the original, cloned node) or setting
* the `source` property manually.
*
* ```js
* decl.source.input.from //=> '/home/ai/a.sass'
* decl.source.start //=> { line: 10, column: 2 }
* decl.source.end //=> { line: 10, column: 12 }
* ```
*
* ```js
* // Bad
* const prefixed = postcss.decl({
* prop: '-moz-' + decl.prop,
* value: decl.value
* })
*
* // Good
* const prefixed = decl.clone({ prop: '-moz-' + decl.prop })
* ```
*
* ```js
* if (atrule.name === 'add-link') {
* const rule = postcss.rule({ selector: 'a', source: atrule.source })
* atrule.parent.insertBefore(atrule, rule)
* }
* ```
*/
source?: Source
/**
* Information to generate byte-to-byte equal node string as it was
* in the origin input.
*
* The properties of the raws object are decided by parser,
* the default parser uses the following properties:
* Every parser saves its own properties,
* but the default CSS parser uses:
*
* * `before`: the space symbols before the node. It also stores `*`
* and `_` symbols before the declaration (IE hack).
@@ -171,11 +175,13 @@ declare abstract class Node_ {
* * `left`: the space symbols between `/*` and the comments text.
* * `right`: the space symbols between the comments text
* and <code>*&#47;</code>.
* - `important`: the content of the important statement,
* * `important`: the content of the important statement,
* if it is not just `!important`.
*
* PostCSS filters out the comments inside selectors, declaration values
* and at-rule parameters but it stores the origin content in raws.
* PostCSS cleans selectors, declaration values and at-rule parameters
* from comments and extra spaces, but it stores origin content in raws
* properties. As such, if you dont change a declarations value,
* PostCSS will use the raw value with comments.
*
* ```js
* const root = postcss.parse('a {\n color:black\n}')
@@ -185,131 +191,101 @@ declare abstract class Node_ {
raws: any
/**
* It represents information related to origin of a node and is required
* for generating source maps.
*
* The nodes that are created manually using the public APIs
* provided by PostCSS will have `source` undefined and
* will be absent in the source map.
*
* For this reason, the plugin developer should consider
* duplicating nodes as the duplicate node will have the
* same source as the original node by default or assign
* source to a node created manually.
*
* ```js
* decl.source.input.from //=> '/home/ai/source.css'
* decl.source.start //=> { line: 10, column: 2 }
* decl.source.end //=> { line: 10, column: 12 }
* ```
*
* ```js
* // Incorrect method, source not specified!
* const prefixed = postcss.decl({
* prop: '-moz-' + decl.prop,
* value: decl.value
* })
*
* // Correct method, source is inherited when duplicating.
* const prefixed = decl.clone({
* prop: '-moz-' + decl.prop
* })
* ```
*
* ```js
* if (atrule.name === 'add-link') {
* const rule = postcss.rule({
* selector: 'a',
* source: atrule.source
* })
*
* atrule.parent.insertBefore(atrule, rule)
* }
* ```
* @param defaults Value for node properties.
*/
source?: Node.Source
/**
* It represents type of a node in
* an abstract syntax tree.
*
* A type of node helps in identification of a node
* and perform operation based on it's type.
*
* ```js
* const declaration = new Declaration({
* prop: 'color',
* value: 'black'
* })
*
* declaration.type //=> 'decl'
* ```
*/
type: string
constructor(defaults?: object)
/**
* Insert new node after current node to current nodes parent.
* Returns a `CssSyntaxError` instance containing the original position
* of the node in the source, showing line and column numbers and also
* a small excerpt to facilitate debugging.
*
* Just alias for `node.parent.insertAfter(node, add)`.
* If present, an input source map will be used to get the original position
* of the source, even from a previous compilation step
* (e.g., from Sass compilation).
*
* This method produces very useful error messages.
*
* ```js
* decl.after('color: black')
* if (!variables[name]) {
* throw decl.error(`Unknown variable ${name}`, { word: name })
* // CssSyntaxError: postcss-vars:a.sass:4:3: Unknown variable $black
* // color: $black
* // a
* // ^
* // background: white
* }
* ```
*
* @param newNode New node.
* @return This node for methods chain.
* @param message Error description.
* @param opts Options.
*
* @return Error object to throw it.
*/
after(
newNode: Node | Node.ChildProps | readonly Node[] | string | undefined
): this
error(message: string, options?: NodeErrorOptions): CssSyntaxError
/**
* It assigns properties to an existing node instance.
* This method is provided as a convenience wrapper for `Result#warn`.
*
* ```js
* Declaration: {
* bad: (decl, { result }) => {
* decl.warn(result, 'Deprecated property bad')
* }
* }
* ```
*
* @param result The `Result` instance that will receive the warning.
* @param text Warning message.
* @param opts Warning Options.
*
* @return Created warning object.
*/
warn(result: Result, text: string, opts?: WarningOptions): Warning
/**
* Removes the node from its parent and cleans the parent properties
* from the node and its children.
*
* ```js
* if (decl.prop.match(/^-webkit-/)) {
* decl.remove()
* }
* ```
*
* @return Node to make calls chain.
*/
remove(): this
/**
* Returns a CSS string representing the node.
*
* ```js
* new Rule({ selector: 'a' }).toString() //=> "a {}"
* ```
*
* @param stringifier A syntax to use in string generation.
* @return CSS string of this node.
*/
toString(stringifier?: Stringifier | Syntax): string
/**
* Assigns properties to the current node.
*
* ```js
* decl.assign({ prop: 'word-wrap', value: 'break-word' })
* ```
*
* @param overrides New properties to override the node.
*
* @return `this` for method chaining.
* @return Current node to methods chain.
*/
assign(overrides: object): this
/**
* Insert new node before current node to current nodes parent.
* Returns an exact clone of the node.
*
* Just alias for `node.parent.insertBefore(node, add)`.
*
* ```js
* decl.before('content: ""')
* ```
*
* @param newNode New node.
* @return This node for methods chain.
*/
before(
newNode: Node | Node.ChildProps | readonly Node[] | string | undefined
): this
/**
* Clear the code style properties for the node and its children.
*
* ```js
* node.raws.before //=> ' '
* node.cleanRaws()
* node.raws.before //=> undefined
* ```
*
* @param keepBetween Keep the `raws.between` symbols.
*/
cleanRaws(keepBetween?: boolean): void
/**
* It creates clone of an existing node, which includes all the properties
* and their values, that includes `raws` but not `type`.
* The resulting cloned node and its (cloned) children will retain
* code style properties.
*
* ```js
* decl.raws.before //=> "\n "
@@ -319,20 +295,10 @@ declare abstract class Node_ {
* ```
*
* @param overrides New properties to override in the clone.
*
* @return Duplicate of the node instance.
* @return Clone of the node.
*/
clone(overrides?: object): this
/**
* Shortcut to clone the node and insert the resulting cloned node
* after the current node.
*
* @param overrides New properties to override in the clone.
* @return New node.
*/
cloneAfter(overrides?: object): this
/**
* Shortcut to clone the node and insert the resulting cloned node
* before the current node.
@@ -348,40 +314,31 @@ declare abstract class Node_ {
cloneBefore(overrides?: object): this
/**
* It creates an instance of the class `CssSyntaxError` and parameters passed
* to this method are assigned to the error instance.
* Shortcut to clone the node and insert the resulting cloned node
* after the current node.
*
* The error instance will have description for the
* error, original position of the node in the
* source, showing line and column number.
*
* If any previous map is present, it would be used
* to get original position of the source.
*
* The Previous Map here is referred to the source map
* generated by previous compilation, example: Less,
* Stylus and Sass.
*
* This method returns the error instance instead of
* throwing it.
* @param overrides New properties to override in the clone.
* @return New node.
*/
cloneAfter(overrides?: object): this
/**
* Inserts node(s) before the current node and removes the current node.
*
* ```js
* if (!variables[name]) {
* throw decl.error(`Unknown variable ${name}`, { word: name })
* // CssSyntaxError: postcss-vars:a.sass:4:3: Unknown variable $black
* // color: $black
* // a
* // ^
* // background: white
* AtRule: {
* mixin: atrule => {
* atrule.replaceWith(mixinRules[atrule.params])
* }
* }
* ```
*
* @param message Description for the error instance.
* @param options Options for the error instance.
*
* @return Error instance is returned.
* @param nodes Mode(s) to replace current one.
* @return Current node to methods chain.
*/
error(message: string, options?: Node.NodeErrorOptions): CssSyntaxError
replaceWith(
...nodes: (ChildNode | ChildProps | ChildNode[] | ChildProps[])[]
): this
/**
* Returns the next child of the nodes parent.
@@ -398,23 +355,7 @@ declare abstract class Node_ {
*
* @return Next node.
*/
next(): Node.ChildNode | undefined
/**
* Get the position for a word or an index inside the node.
*
* @param opts Options.
* @return Position.
*/
positionBy(opts?: Pick<WarningOptions, 'index' | 'word'>): Node.Position
/**
* Convert string index to line/column.
*
* @param index The symbol number in the nodes string.
* @return Symbol position in file.
*/
positionInside(index: number): Node.Position
next(): ChildNode | undefined
/**
* Returns the previous child of the nodes parent.
@@ -429,21 +370,49 @@ declare abstract class Node_ {
*
* @return Previous node.
*/
prev(): Node.ChildNode | undefined
prev(): ChildNode | undefined
/**
* Get the range for a word or start and end index inside the node.
* The start index is inclusive; the end index is exclusive.
* Insert new node before current node to current nodes parent.
*
* @param opts Options.
* @return Range.
* Just alias for `node.parent.insertBefore(node, add)`.
*
* ```js
* decl.before('content: ""')
* ```
*
* @param newNode New node.
* @return This node for methods chain.
*/
rangeBy(
opts?: Pick<WarningOptions, 'end' | 'endIndex' | 'index' | 'start' | 'word'>
): Node.Range
before(newNode: Node | ChildProps | string | Node[]): this
/**
* Returns a `raws` value. If the node is missing
* Insert new node after current node to current nodes parent.
*
* Just alias for `node.parent.insertAfter(node, add)`.
*
* ```js
* decl.after('color: black')
* ```
*
* @param newNode New node.
* @return This node for methods chain.
*/
after(newNode: Node | ChildProps | string | Node[]): this
/**
* Finds the Root instance of the nodes tree.
*
* ```js
* root.nodes[0].nodes[0].root() === root
* ```
*
* @return Root parent.
*/
root(): Root
/**
* Returns a `Node#raws` value. If the node is missing
* the code style property (because the node was manually built or cloned),
* PostCSS will try to autodetect the code style property by looking
* at other nodes in the tree.
@@ -463,44 +432,17 @@ declare abstract class Node_ {
raw(prop: string, defaultType?: string): string
/**
* It removes the node from its parent and deletes its parent property.
* Clear the code style properties for the node and its children.
*
* ```js
* if (decl.prop.match(/^-webkit-/)) {
* decl.remove()
* }
* node.raws.before //=> ' '
* node.cleanRaws()
* node.raws.before //=> undefined
* ```
*
* @return `this` for method chaining.
* @param keepBetween Keep the `raws.between` symbols.
*/
remove(): this
/**
* Inserts node(s) before the current node and removes the current node.
*
* ```js
* AtRule: {
* mixin: atrule => {
* atrule.replaceWith(mixinRules[atrule.params])
* }
* }
* ```
*
* @param nodes Mode(s) to replace current one.
* @return Current node to methods chain.
*/
replaceWith(...nodes: NewChild[]): this
/**
* Finds the Root instance of the nodes tree.
*
* ```js
* root.nodes[0].nodes[0].root() === root
* ```
*
* @return Root parent.
*/
root(): Root
cleanRaws(keepBetween?: boolean): void
/**
* Fix circular links on `JSON.stringify()`.
@@ -510,47 +452,27 @@ declare abstract class Node_ {
toJSON(): object
/**
* It compiles the node to browser readable cascading style sheets string
* depending on it's type.
* Convert string index to line/column.
*
* ```js
* new Rule({ selector: 'a' }).toString() //=> "a {}"
* ```
*
* @param stringifier A syntax to use in string generation.
* @return CSS string of this node.
* @param index The symbol number in the nodes string.
* @return Symbol position in file.
*/
toString(stringifier?: Stringifier | Syntax): string
positionInside(index: number): Position
/**
* It is a wrapper for {@link Result#warn}, providing convenient
* way of generating warnings.
* Get the position for a word or an index inside the node.
*
* ```js
* Declaration: {
* bad: (decl, { result }) => {
* decl.warn(result, 'Deprecated property: bad')
* }
* }
* ```
*
* @param result The `Result` instance that will receive the warning.
* @param message Description for the warning.
* @param options Options for the warning.
*
* @return `Warning` instance is returned
* @param opts Options.
* @return Position.
*/
warn(result: Result, message: string, options?: WarningOptions): Warning
positionBy(opts?: Pick<WarningOptions, 'word' | 'index'>): Position
/**
* 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.
* Get the range for a word or start and end index inside the node.
* The start index is inclusive; the end index is exclusive.
*
* @param opts Options.
* @return Range.
*/
protected markDirty(): void
rangeBy(opts?: Pick<WarningOptions, 'word' | 'index' | 'endIndex'>): Range
}
declare class Node extends Node_ {}
export = Node