🔧 npm update

This commit is contained in:
2025-04-15 20:50:11 +02:00
parent ce5b9ac0c8
commit 94a90edabd
828 changed files with 256807 additions and 197099 deletions

2
node_modules/postcss/README.md generated vendored
View File

@@ -13,7 +13,7 @@ and JetBrains. The [Autoprefixer] and [Stylelint] PostCSS plugins is one of
---
<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>.
<img src="https://cdn.evilmartians.com/badges/logo-no-label.svg" alt="" width="22" height="16" />  Made at <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>.
---

View File

@@ -1,4 +1,7 @@
import Container, { ContainerProps } from './container.js'
import Container, {
ContainerProps,
ContainerWithChildren
} from './container.js'
declare namespace AtRule {
export interface AtRuleRaws extends Record<string, unknown> {
@@ -76,16 +79,41 @@ declare namespace AtRule {
* ```
*/
declare class AtRule_ extends Container {
/**
* An array containing the layers children.
*
* ```js
* const root = postcss.parse('@layer example { a { color: black } }')
* const layer = root.first
* layer.nodes.length //=> 1
* layer.nodes[0].selector //=> 'a'
* ```
*
* Can be `undefinded` if the at-rule has no body.
*
* ```js
* const root = postcss.parse('@layer a, b, c;')
* const layer = root.first
* layer.nodes //=> undefined
* ```
*/
nodes: Container['nodes'] | undefined
parent: ContainerWithChildren | undefined
raws: AtRule.AtRuleRaws
type: 'atrule'
/**
* The at-rules name immediately follows the `@`.
*
* ```js
* const root = postcss.parse('@media print {}')
* media.name //=> 'media'
* const media = root.first
* media.name //=> 'media'
* ```
*/
name: string
get name(): string
set name(value: string)
/**
* The at-rules parameters, the values that follow the at-rules name
* but precede any `{}` block.
@@ -96,18 +124,15 @@ declare class AtRule_ extends Container {
* media.params //=> 'print, screen'
* ```
*/
params: string
parent: Container | undefined
get params(): string
raws: AtRule.AtRuleRaws
type: 'atrule'
set params(value: string)
constructor(defaults?: AtRule.AtRuleProps)
assign(overrides: AtRule.AtRuleProps | object): this
clone(overrides?: Partial<AtRule.AtRuleProps>): AtRule
cloneAfter(overrides?: Partial<AtRule.AtRuleProps>): AtRule
cloneBefore(overrides?: Partial<AtRule.AtRuleProps>): AtRule
clone(overrides?: Partial<AtRule.AtRuleProps>): this
cloneAfter(overrides?: Partial<AtRule.AtRuleProps>): this
cloneBefore(overrides?: Partial<AtRule.AtRuleProps>): this
}
declare class AtRule extends AtRule_ {}

View File

@@ -48,18 +48,19 @@ declare namespace Comment {
declare class Comment_ extends Node {
parent: Container | undefined
raws: Comment.CommentRaws
type: 'comment'
/**
* The comment's text.
*/
text: string
get text(): string
type: 'comment'
set text(value: string)
constructor(defaults?: Comment.CommentProps)
assign(overrides: Comment.CommentProps | object): this
clone(overrides?: Partial<Comment.CommentProps>): Comment
cloneAfter(overrides?: Partial<Comment.CommentProps>): Comment
cloneBefore(overrides?: Partial<Comment.CommentProps>): Comment
clone(overrides?: Partial<Comment.CommentProps>): this
cloneAfter(overrides?: Partial<Comment.CommentProps>): this
cloneBefore(overrides?: Partial<Comment.CommentProps>): this
}
declare class Comment extends Comment_ {}

View File

@@ -5,6 +5,12 @@ import Node, { ChildNode, ChildProps, NodeProps } from './node.js'
import Rule from './rule.js'
declare namespace Container {
export class ContainerWithChildren<
Child extends Node = ChildNode
> extends Container_<Child> {
nodes: Child[]
}
export interface ValueOptions {
/**
* String thats used to narrow down values and speed up the regexp search.
@@ -14,13 +20,26 @@ declare namespace Container {
/**
* An array of property names.
*/
props?: string[]
props?: readonly string[]
}
export interface ContainerProps extends NodeProps {
nodes?: (ChildNode | ChildProps)[]
nodes?: readonly (ChildProps | Node)[]
}
/**
* All types that can be passed into container methods to create or add a new
* child node.
*/
export type NewChild =
| ChildProps
| Node
| readonly ChildProps[]
| readonly Node[]
| readonly string[]
| string
| undefined
// eslint-disable-next-line @typescript-eslint/no-use-before-define
export { Container_ as default }
}
@@ -43,8 +62,25 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
* root.nodes[0].nodes[0].prop //=> 'color'
* ```
*/
nodes: Child[]
nodes: Child[] | undefined
/**
* The containers first child.
*
* ```js
* rule.first === rules.nodes[0]
* ```
*/
get first(): Child | undefined
/**
* The containers last child.
*
* ```js
* rule.last === rule.nodes[rule.nodes.length - 1]
* ```
*/
get last(): Child | undefined
/**
* Inserts new nodes to the end of the container.
*
@@ -65,15 +101,13 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
* @param nodes New nodes.
* @return This node for methods chain.
*/
append(
...nodes: (ChildProps | ChildProps[] | Node | Node[] | string | string[])[]
): this
append(...nodes: Container.NewChild[]): this
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>
clone(overrides?: Partial<Container.ContainerProps>): this
cloneAfter(overrides?: Partial<Container.ContainerProps>): this
cloneBefore(overrides?: Partial<Container.ContainerProps>): this
/**
* Iterates through the containers immediate children,
* calling `callback` for each child.
@@ -144,25 +178,7 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
* @param newNode New node.
* @return This node for methods chain.
*/
insertAfter(
oldNode: Child | number,
newNode: Child | Child[] | ChildProps | ChildProps[] | string | string[]
): this
/**
* Insert new node before old node within the container.
*
* ```js
* rule.insertBefore(decl, decl.clone({ prop: '-webkit-' + decl.prop }))
* ```
*
* @param oldNode Child or childs index.
* @param newNode New node.
* @return This node for methods chain.
*/
insertBefore(
oldNode: Child | number,
newNode: Child | Child[] | ChildProps | ChildProps[] | string | string[]
): this
insertAfter(oldNode: Child | number, newNode: Container.NewChild): this
/**
* Traverses the containers descendant nodes, calling callback
@@ -181,6 +197,18 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
* @return Returns `false` if iteration was broke.
*/
/**
* Insert new node before old node within the container.
*
* ```js
* rule.insertBefore(decl, decl.clone({ prop: '-webkit-' + decl.prop }))
* ```
*
* @param oldNode Child or childs 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.
*
@@ -201,9 +229,8 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
* @param nodes New nodes.
* @return This node for methods chain.
*/
prepend(
...nodes: (ChildProps | ChildProps[] | Node | Node[] | string | string[])[]
): this
prepend(...nodes: Container.NewChild[]): this
/**
* Add child to the end of the node.
*
@@ -249,7 +276,6 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
pattern: RegExp | string,
replaced: { (substring: string, ...args: any[]): string } | string
): this
/**
* Passes all declaration values within the container that match pattern
* through callback, replacing those values with the returned result
@@ -265,8 +291,8 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
* ```
*
* @param pattern Replace pattern.
* @param {object} opts Options to speed up the search.
* @param callback String to replace pattern or callback
* @param {object} options Options to speed up the search.
* @param replaced String to replace pattern or callback
* that returns a new value. The callback
* will receive the same arguments
* as those passed to a function parameter
@@ -350,14 +376,13 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
nameFilter: RegExp | string,
callback: (atRule: AtRule, index: number) => false | void
): false | undefined
walkAtRules(
callback: (atRule: AtRule, index: number) => false | void
): false | undefined
walkComments(
callback: (comment: Comment, indexed: number) => false | void
): false | undefined
walkComments(
callback: (comment: Comment, indexed: number) => false | void
): false | undefined
@@ -395,11 +420,9 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
propFilter: RegExp | string,
callback: (decl: Declaration, index: number) => false | void
): false | undefined
walkDecls(
callback: (decl: Declaration, index: number) => false | void
): false | undefined
/**
* Traverses the containers descendant nodes, calling callback
* for each rule node.
@@ -430,23 +453,28 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
callback: (rule: Rule, index: number) => false | void
): false | undefined
/**
* The containers 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 containers 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[]
}
declare class Container<Child extends Node = ChildNode> extends Container_<Child> {}
declare class Container<
Child extends Node = ChildNode
> extends Container_<Child> {}
export = Container

View File

@@ -1,11 +1,11 @@
'use strict'
let { isClean, my } = require('./symbols')
let Declaration = require('./declaration')
let Comment = require('./comment')
let Declaration = require('./declaration')
let Node = require('./node')
let { isClean, my } = require('./symbols')
let parse, Rule, AtRule, Root
let AtRule, parse, Root, Rule
function cleanSource(nodes) {
return nodes.map(i => {
@@ -15,16 +15,26 @@ function cleanSource(nodes) {
})
}
function markDirtyUp(node) {
function markTreeDirty(node) {
node[isClean] = false
if (node.proxyOf.nodes) {
for (let i of node.proxyOf.nodes) {
markDirtyUp(i)
markTreeDirty(i)
}
}
}
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) {
for (let child of children) {
let nodes = this.normalize(child, this.last)
@@ -153,7 +163,11 @@ class Container extends Node {
insertBefore(exist, add) {
let existIndex = this.index(exist)
let type = existIndex === 0 ? 'prepend' : false
let nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse()
let nodes = this.normalize(
add,
this.proxyOf.nodes[existIndex],
type
).reverse()
existIndex = this.index(exist)
for (let node of nodes) this.proxyOf.nodes.splice(existIndex, 0, node)
@@ -173,6 +187,8 @@ class Container extends Node {
normalize(nodes, sample) {
if (typeof nodes === 'string') {
nodes = cleanSource(parse(nodes).nodes)
} else if (typeof nodes === 'undefined') {
nodes = []
} else if (Array.isArray(nodes)) {
nodes = nodes.slice(0)
for (let i of nodes) {
@@ -192,7 +208,7 @@ class Container extends Node {
nodes.value = String(nodes.value)
}
nodes = [new Declaration(nodes)]
} else if (nodes.selector) {
} else if (nodes.selector || nodes.selectors) {
nodes = [new Rule(nodes)]
} else if (nodes.name) {
nodes = [new AtRule(nodes)]
@@ -207,7 +223,9 @@ class Container extends Node {
if (!i[my]) Container.rebuild(i)
i = i.proxyOf
if (i.parent) i.parent.removeChild(i)
if (i[isClean]) markDirtyUp(i)
if (i[isClean]) markTreeDirty(i)
if (!i.raws) i.raws = {}
if (typeof i.raws.before === 'undefined') {
if (sample && typeof sample.raws.before !== 'undefined') {
i.raws.before = sample.raws.before.replace(/\S/g, '')
@@ -383,16 +401,6 @@ 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]
}
}
Container.registerParse = dependant => {

View File

@@ -49,7 +49,7 @@ declare namespace CssSyntaxError {
* }
* ```
*/
declare class CssSyntaxError_ {
declare class CssSyntaxError_ extends Error {
/**
* Source column of the error.
*

View File

@@ -52,37 +52,70 @@ class CssSyntaxError extends Error {
let css = this.source
if (color == null) color = pico.isColorSupported
if (terminalHighlight) {
if (color) css = terminalHighlight(css)
let aside = text => text
let mark = text => text
let highlight = text => text
if (color) {
let { bold, gray, red } = pico.createColors(true)
mark = text => bold(red(text))
aside = text => gray(text)
if (terminalHighlight) {
highlight = text => terminalHighlight(text)
}
}
let lines = css.split(/\r?\n/)
let start = Math.max(this.line - 3, 0)
let end = Math.min(this.line + 2, lines.length)
let maxWidth = String(end).length
let mark, aside
if (color) {
let { bold, gray, red } = pico.createColors(true)
mark = text => bold(red(text))
aside = text => gray(text)
} else {
mark = aside = str => str
}
return lines
.slice(start, end)
.map((line, index) => {
let number = start + 1 + index
let gutter = ' ' + (' ' + number).slice(-maxWidth) + ' | '
if (number === this.line) {
if (line.length > 160) {
let padding = 20
let subLineStart = Math.max(0, this.column - padding)
let subLineEnd = Math.max(
this.column + padding,
this.endColumn + padding
)
let subLine = line.slice(subLineStart, subLineEnd)
let spacing =
aside(gutter.replace(/\d/g, ' ')) +
line
.slice(0, Math.min(this.column - 1, padding - 1))
.replace(/[^\t]/g, ' ')
return (
mark('>') +
aside(gutter) +
highlight(subLine) +
'\n ' +
spacing +
mark('^')
)
}
let spacing =
aside(gutter.replace(/\d/g, ' ')) +
line.slice(0, this.column - 1).replace(/[^\t]/g, ' ')
return mark('>') + aside(gutter) + line + '\n ' + spacing + mark('^')
return (
mark('>') +
aside(gutter) +
highlight(line) +
'\n ' +
spacing +
mark('^')
)
}
return ' ' + aside(gutter) + line
return ' ' + aside(gutter) + highlight(line)
})
.join('\n')
}

View File

@@ -1,4 +1,4 @@
import Container from './container.js'
import { ContainerWithChildren } from './container.js'
import Node from './node.js'
declare namespace Declaration {
@@ -63,6 +63,11 @@ declare namespace Declaration {
* ```
*/
declare class Declaration_ extends Node {
parent: ContainerWithChildren | undefined
raws: Declaration.DeclarationRaws
type: 'decl'
/**
* It represents a specificity of the declaration.
*
@@ -77,9 +82,8 @@ declare class Declaration_ extends Node {
* root.first.last.important //=> undefined
* ```
*/
important: boolean
parent: Container | undefined
get important(): boolean
set important(value: boolean)
/**
* The property name for a CSS declaration.
@@ -91,11 +95,9 @@ declare class Declaration_ extends Node {
* decl.prop //=> 'color'
* ```
*/
prop: string
get prop(): string
raws: Declaration.DeclarationRaws
type: 'decl'
set prop(value: string)
/**
* The property value for a CSS declaration.
@@ -114,7 +116,8 @@ declare class Declaration_ extends Node {
* decl.value //=> 'black'
* ```
*/
value: string
get value(): string
set value(value: string)
/**
* It represents a getter that returns `true` if a declaration starts with
@@ -134,13 +137,13 @@ declare class Declaration_ extends Node {
* one.variable //=> true
* ```
*/
variable: boolean
get variable(): boolean
constructor(defaults?: Declaration.DeclarationProps)
assign(overrides: Declaration.DeclarationProps | object): this
clone(overrides?: Partial<Declaration.DeclarationProps>): Declaration
cloneAfter(overrides?: Partial<Declaration.DeclarationProps>): Declaration
cloneBefore(overrides?: Partial<Declaration.DeclarationProps>): Declaration
clone(overrides?: Partial<Declaration.DeclarationProps>): this
cloneAfter(overrides?: Partial<Declaration.DeclarationProps>): this
cloneBefore(overrides?: Partial<Declaration.DeclarationProps>): this
}
declare class Declaration extends Declaration_ {}

View File

@@ -3,6 +3,10 @@
let Node = require('./node')
class Declaration extends Node {
get variable() {
return this.prop.startsWith('--') || this.prop[0] === '$'
}
constructor(defaults) {
if (
defaults &&
@@ -14,10 +18,6 @@ class Declaration extends Node {
super(defaults)
this.type = 'decl'
}
get variable() {
return this.prop.startsWith('--') || this.prop[0] === '$'
}
}
module.exports = Declaration

View File

@@ -5,7 +5,7 @@ import Root from './root.js'
declare namespace Document {
export interface DocumentProps extends ContainerProps {
nodes?: Root[]
nodes?: readonly Root[]
/**
* Information to generate byte-to-byte equal node string as it was
@@ -35,15 +35,16 @@ declare namespace Document {
* ```
*/
declare class Document_ extends Container<Root> {
nodes: Root[]
parent: undefined
type: 'document'
constructor(defaults?: Document.DocumentProps)
assign(overrides: Document.DocumentProps | object): this
clone(overrides?: Partial<Document.DocumentProps>): Document
cloneAfter(overrides?: Partial<Document.DocumentProps>): Document
cloneBefore(overrides?: Partial<Document.DocumentProps>): Document
clone(overrides?: Partial<Document.DocumentProps>): this
cloneAfter(overrides?: Partial<Document.DocumentProps>): this
cloneBefore(overrides?: Partial<Document.DocumentProps>): this
/**
* Returns a `Result` instance representing the documents CSS roots.

View File

@@ -1,10 +1,10 @@
'use strict'
let Declaration = require('./declaration')
let PreviousMap = require('./previous-map')
let Comment = require('./comment')
let AtRule = require('./at-rule')
let Comment = require('./comment')
let Declaration = require('./declaration')
let Input = require('./input')
let PreviousMap = require('./previous-map')
let Root = require('./root')
let Rule = require('./rule')

44
node_modules/postcss/lib/input.d.ts generated vendored
View File

@@ -62,6 +62,17 @@ declare class Input_ {
*/
css: string
/**
* Input source with support for non-CSS documents.
*
* ```js
* const input = postcss.parse('a{}', { from: file, document: '<style>a {}</style>' }).input
* input.document //=> "<style>a {}</style>"
* input.css //=> "a{}"
* ```
*/
document: string
/**
* The absolute path to the CSS source file defined
* with the `from` option.
@@ -100,6 +111,20 @@ declare class Input_ {
*/
map: PreviousMap
/**
* 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.
* @param opts Process options.
@@ -126,7 +151,6 @@ declare class Input_ {
},
opts?: { plugin?: CssSyntaxError['plugin'] }
): CssSyntaxError
/**
* Returns `CssSyntaxError` with information about the error and its position.
*/
@@ -136,13 +160,11 @@ declare class Input_ {
column: number,
opts?: { plugin?: CssSyntaxError['plugin'] }
): CssSyntaxError
error(
message: string,
offset: number,
opts?: { plugin?: CssSyntaxError['plugin'] }
): CssSyntaxError
/**
* Converts source offset to line and column.
*
@@ -174,19 +196,9 @@ declare class Input_ {
endLine?: number,
endColumn?: number
): 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
/** Converts this to a JSON-friendly object representation. */
toJSON(): object
}
declare class Input extends Input_ {}

19
node_modules/postcss/lib/input.js generated vendored
View File

@@ -1,13 +1,13 @@
'use strict'
let { nanoid } = require('nanoid/non-secure')
let { isAbsolute, resolve } = require('path')
let { SourceMapConsumer, SourceMapGenerator } = require('source-map-js')
let { fileURLToPath, pathToFileURL } = require('url')
let { isAbsolute, resolve } = require('path')
let { nanoid } = require('nanoid/non-secure')
let terminalHighlight = require('./terminal-highlight')
let CssSyntaxError = require('./css-syntax-error')
let PreviousMap = require('./previous-map')
let terminalHighlight = require('./terminal-highlight')
let fromOffsetCache = Symbol('fromOffsetCache')
@@ -15,6 +15,10 @@ let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator)
let pathAvailable = Boolean(resolve && isAbsolute)
class Input {
get from() {
return this.file || this.id
}
constructor(css, opts = {}) {
if (
css === null ||
@@ -33,6 +37,9 @@ class Input {
this.hasBOM = false
}
this.document = this.css
if (opts.document) this.document = opts.document.toString()
if (opts.from) {
if (
!pathAvailable ||
@@ -61,7 +68,7 @@ class Input {
}
error(message, line, column, opts = {}) {
let result, endLine, endColumn
let endColumn, endLine, result
if (line && typeof line === 'object') {
let start = line
@@ -234,10 +241,6 @@ class Input {
}
return json
}
get from() {
return this.file || this.id
}
}
module.exports = Input

View File

@@ -67,46 +67,6 @@ declare class LazyResult_<RootNode = Document | Root>
*/
then: Promise<Result<RootNode>>['then']
/**
* @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
* that generate non-CSS output.
@@ -181,6 +141,46 @@ declare class LazyResult_<RootNode = Document | Root>
* Required to implement the Promise interface.
*/
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[]
}
declare class LazyResult<

View File

@@ -1,14 +1,14 @@
'use strict'
let { isClean, my } = require('./symbols')
let MapGenerator = require('./map-generator')
let stringify = require('./stringify')
let Container = require('./container')
let Document = require('./document')
let warnOnce = require('./warn-once')
let Result = require('./result')
let MapGenerator = require('./map-generator')
let parse = require('./parse')
let Result = require('./result')
let Root = require('./root')
let stringify = require('./stringify')
let { isClean, my } = require('./symbols')
let warnOnce = require('./warn-once')
const TYPE_TO_CLASS_NAME = {
atrule: 'AtRule',
@@ -105,6 +105,38 @@ function cleanMarks(node) {
let postcss = {}
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) {
this.stringified = false
this.processed = false
@@ -505,38 +537,6 @@ class LazyResult {
warnings() {
return this.sync().warnings()
}
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'
}
}
LazyResult.registerPostcss = dependant => {

7
node_modules/postcss/lib/list.d.ts generated vendored
View File

@@ -47,11 +47,14 @@ declare namespace list {
* @param last boolean indicator.
* @return Split values.
*/
split(string: string, separators: string[], last: boolean): string[]
split(
string: string,
separators: readonly string[],
last: boolean
): string[]
}
}
// eslint-disable-next-line @typescript-eslint/no-redeclare
declare const list: list.List
export = list

View File

@@ -1,7 +1,7 @@
'use strict'
let { SourceMapConsumer, SourceMapGenerator } = require('source-map-js')
let { dirname, relative, resolve, sep } = require('path')
let { SourceMapConsumer, SourceMapGenerator } = require('source-map-js')
let { pathToFileURL } = require('url')
let Input = require('./input')
@@ -52,7 +52,7 @@ class MapGenerator {
if (this.mapOpts.sourcesContent === false) {
map = new SourceMapConsumer(prev.text)
if (map.sourcesContent) {
map.sourcesContent = map.sourcesContent.map(() => null)
map.sourcesContent = null
}
} else {
map = prev.consumer()
@@ -70,12 +70,12 @@ class MapGenerator {
for (let i = this.root.nodes.length - 1; i >= 0; i--) {
node = this.root.nodes[i]
if (node.type !== 'comment') continue
if (node.text.indexOf('# sourceMappingURL=') === 0) {
if (node.text.startsWith('# sourceMappingURL=')) {
this.root.removeChild(i)
}
}
} else if (this.css) {
this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, '')
this.css = this.css.replace(/\n*\/\*#[\S\s]*?\*\/$/gm, '')
}
}
@@ -98,9 +98,14 @@ class MapGenerator {
} else if (this.previous().length === 1) {
let prev = this.previous()[0].consumer()
prev.file = this.outputFile()
this.map = SourceMapGenerator.fromSourceMap(prev)
this.map = SourceMapGenerator.fromSourceMap(prev, {
ignoreInvalidMapping: true
})
} else {
this.map = new SourceMapGenerator({ file: this.outputFile() })
this.map = new SourceMapGenerator({
file: this.outputFile(),
ignoreInvalidMapping: true
})
this.map.addMapping({
generated: { column: 0, line: 1 },
original: { column: 0, line: 1 },
@@ -123,7 +128,10 @@ class MapGenerator {
generateString() {
this.css = ''
this.map = new SourceMapGenerator({ file: this.outputFile() })
this.map = new SourceMapGenerator({
file: this.outputFile(),
ignoreInvalidMapping: true
})
let line = 1
let column = 1
@@ -135,7 +143,7 @@ class MapGenerator {
source: ''
}
let lines, last
let last, lines
this.stringify(this.root, (str, node, type) => {
this.css += str

View File

@@ -26,11 +26,6 @@ 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<Root>>
sync(): Result<Root>
toString(): string
warnings(): Warning[]
get content(): string
get css(): string
get map(): SourceMap
@@ -39,6 +34,11 @@ declare class NoWorkResult_ implements LazyResult<Root> {
get processor(): Processor
get root(): Root
get [Symbol.toStringTag](): string
constructor(processor: Processor, css: string, opts: ResultOptions)
async(): Promise<Result<Root>>
sync(): Result<Root>
toString(): string
warnings(): Warning[]
}
declare class NoWorkResult extends NoWorkResult_ {}

View File

@@ -1,88 +1,12 @@
'use strict'
let MapGenerator = require('./map-generator')
let stringify = require('./stringify')
let warnOnce = require('./warn-once')
let parse = require('./parse')
const Result = require('./result')
let stringify = require('./stringify')
let warnOnce = require('./warn-once')
class NoWorkResult {
constructor(processor, css, opts) {
css = css.toString()
this.stringified = false
this._processor = processor
this._css = css
this._opts = opts
this._map = undefined
let root
let str = stringify
this.result = new Result(this._processor, root, this._opts)
this.result.css = css
let self = this
Object.defineProperty(this.result, 'root', {
get() {
return self.root
}
})
let map = new MapGenerator(str, root, this._opts, css)
if (map.isMap()) {
let [generatedCSS, generatedMap] = map.generate()
if (generatedCSS) {
this.result.css = generatedCSS
}
if (generatedMap) {
this.result.map = generatedMap
}
} else {
map.clearAnnotation();
this.result.css = map.css;
}
}
async() {
if (this.error) return Promise.reject(this.error)
return Promise.resolve(this.result)
}
catch(onRejected) {
return this.async().catch(onRejected)
}
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() {
return this.result.css
}
@@ -132,6 +56,82 @@ class NoWorkResult {
get [Symbol.toStringTag]() {
return 'NoWorkResult'
}
constructor(processor, css, opts) {
css = css.toString()
this.stringified = false
this._processor = processor
this._css = css
this._opts = opts
this._map = undefined
let root
let str = stringify
this.result = new Result(this._processor, root, this._opts)
this.result.css = css
let self = this
Object.defineProperty(this.result, 'root', {
get() {
return self.root
}
})
let map = new MapGenerator(str, root, this._opts, css)
if (map.isMap()) {
let [generatedCSS, generatedMap] = map.generate()
if (generatedCSS) {
this.result.css = generatedCSS
}
if (generatedMap) {
this.result.map = generatedMap
}
} else {
map.clearAnnotation()
this.result.css = map.css
}
}
async() {
if (this.error) return Promise.reject(this.error)
return Promise.resolve(this.result)
}
catch(onRejected) {
return this.async().catch(onRejected)
}
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 []
}
}
module.exports = NoWorkResult

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

@@ -2,7 +2,7 @@ import AtRule = require('./at-rule.js')
import { AtRuleProps } from './at-rule.js'
import Comment, { CommentProps } from './comment.js'
import Container from './container.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'
@@ -246,7 +246,9 @@ declare abstract class Node_ {
* @param newNode New node.
* @return This node for methods chain.
*/
after(newNode: Node | Node.ChildProps | Node[] | string): this
after(
newNode: Node | Node.ChildProps | readonly Node[] | string | undefined
): this
/**
* It assigns properties to an existing node instance.
@@ -273,7 +275,9 @@ declare abstract class Node_ {
* @param newNode New node.
* @return This node for methods chain.
*/
before(newNode: Node | Node.ChildProps | Node[] | string): this
before(
newNode: Node | Node.ChildProps | readonly Node[] | string | undefined
): this
/**
* Clear the code style properties for the node and its children.
@@ -303,7 +307,7 @@ declare abstract class Node_ {
*
* @return Duplicate of the node instance.
*/
clone(overrides?: object): Node
clone(overrides?: object): this
/**
* Shortcut to clone the node and insert the resulting cloned node
@@ -312,7 +316,7 @@ declare abstract class Node_ {
* @param overrides New properties to override in the clone.
* @return New node.
*/
cloneAfter(overrides?: object): Node
cloneAfter(overrides?: object): this
/**
* Shortcut to clone the node and insert the resulting cloned node
@@ -326,7 +330,7 @@ declare abstract class Node_ {
*
* @return New node
*/
cloneBefore(overrides?: object): Node
cloneBefore(overrides?: object): this
/**
* It creates an instance of the class `CssSyntaxError` and parameters passed
@@ -470,14 +474,7 @@ declare abstract class Node_ {
* @param nodes Mode(s) to replace current one.
* @return Current node to methods chain.
*/
replaceWith(
...nodes: (
| Node.ChildNode
| Node.ChildNode[]
| Node.ChildProps
| Node.ChildProps[]
)[]
): this
replaceWith(...nodes: NewChild[]): this
/**
* Finds the Root instance of the nodes tree.
@@ -529,8 +526,16 @@ declare abstract class Node_ {
* @return `Warning` instance is returned
*/
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
}
declare class Node extends Node_ { }
declare class Node extends Node_ {}
export = Node

99
node_modules/postcss/lib/node.js generated vendored
View File

@@ -1,9 +1,9 @@
'use strict'
let { isClean, my } = require('./symbols')
let CssSyntaxError = require('./css-syntax-error')
let Stringifier = require('./stringifier')
let stringify = require('./stringify')
let { isClean, my } = require('./symbols')
function cloneNode(obj, parent) {
let cloned = new obj.constructor()
@@ -32,7 +32,41 @@ function cloneNode(obj, parent) {
return cloned
}
function sourceOffset(inputCSS, position) {
// Not all custom syntaxes support `offset` in `source.start` and `source.end`
if (
position &&
typeof position.offset !== 'undefined'
) {
return position.offset;
}
let column = 1
let line = 1
let offset = 0
for (let i = 0; i < inputCSS.length; i++) {
if (line === position.line && column === position.column) {
offset = i
break
}
if (inputCSS[i] === '\n') {
column = 1
line += 1
} else {
column += 1
}
}
return offset
}
class Node {
get proxyOf() {
return this
}
constructor(defaults = {}) {
this.raws = {}
this[isClean] = false
@@ -153,6 +187,11 @@ class Node {
}
}
/* c8 ignore next 3 */
markClean() {
this[isClean] = true
}
markDirty() {
if (this[isClean]) {
this[isClean] = false
@@ -169,25 +208,35 @@ class Node {
return this.parent.nodes[index + 1]
}
positionBy(opts, stringRepresentation) {
positionBy(opts) {
let pos = this.source.start
if (opts.index) {
pos = this.positionInside(opts.index, stringRepresentation)
pos = this.positionInside(opts.index)
} else if (opts.word) {
stringRepresentation = this.toString()
let inputString = ('document' in this.source.input)
? this.source.input.document
: this.source.input.css
let stringRepresentation = inputString.slice(
sourceOffset(inputString, this.source.start),
sourceOffset(inputString, this.source.end)
)
let index = stringRepresentation.indexOf(opts.word)
if (index !== -1) pos = this.positionInside(index, stringRepresentation)
if (index !== -1) pos = this.positionInside(index)
}
return pos
}
positionInside(index, stringRepresentation) {
let string = stringRepresentation || this.toString()
positionInside(index) {
let column = this.source.start.column
let line = this.source.start.line
let inputString = ('document' in this.source.input)
? this.source.input.document
: this.source.input.css
let offset = sourceOffset(inputString, this.source.start)
let end = offset + index
for (let i = 0; i < index; i++) {
if (string[i] === '\n') {
for (let i = offset; i < end; i++) {
if (inputString[i] === '\n') {
column = 1
line += 1
} else {
@@ -211,20 +260,28 @@ class Node {
}
let end = this.source.end
? {
column: this.source.end.column + 1,
line: this.source.end.line
}
column: this.source.end.column + 1,
line: this.source.end.line
}
: {
column: start.column + 1,
line: start.line
}
column: start.column + 1,
line: start.line
}
if (opts.word) {
let stringRepresentation = this.toString()
let inputString = ('document' in this.source.input)
? this.source.input.document
: this.source.input.css
let stringRepresentation = inputString.slice(
sourceOffset(inputString, this.source.start),
sourceOffset(inputString, this.source.end)
)
let index = stringRepresentation.indexOf(opts.word)
if (index !== -1) {
start = this.positionInside(index, stringRepresentation)
end = this.positionInside(index + opts.word.length, stringRepresentation)
start = this.positionInside(index)
end = this.positionInside(
index + opts.word.length,
)
}
} else {
if (opts.start) {
@@ -241,7 +298,7 @@ class Node {
column: opts.end.column,
line: opts.end.line
}
} else if (opts.endIndex) {
} else if (typeof opts.endIndex === 'number') {
end = this.positionInside(opts.endIndex)
} else if (opts.index) {
end = this.positionInside(opts.index + 1)
@@ -371,10 +428,6 @@ class Node {
for (let i in opts) data[i] = opts[i]
return result.warn(text, data)
}
get proxyOf() {
return this
}
}
module.exports = Node

2
node_modules/postcss/lib/parse.js generated vendored
View File

@@ -1,8 +1,8 @@
'use strict'
let Container = require('./container')
let Parser = require('./parser')
let Input = require('./input')
let Parser = require('./parser')
function parse(css, opts) {
let input = new Input(css, opts)

17
node_modules/postcss/lib/parser.js generated vendored
View File

@@ -1,11 +1,11 @@
'use strict'
let Declaration = require('./declaration')
let tokenizer = require('./tokenize')
let Comment = require('./comment')
let AtRule = require('./at-rule')
let Comment = require('./comment')
let Declaration = require('./declaration')
let Root = require('./root')
let Rule = require('./rule')
let tokenizer = require('./tokenize')
const SAFE_COMMENT_NEIGHBOR = {
empty: true,
@@ -28,7 +28,6 @@ class Parser {
this.current = this.root
this.spaces = ''
this.semicolon = false
this.customProperty = false
this.createTokenizer()
this.root.source = { input, start: { column: 1, line: 1, offset: 0 } }
@@ -144,7 +143,7 @@ class Parser {
colon(tokens) {
let brackets = 0
let token, type, prev
let prev, token, type
for (let [i, element] of tokens.entries()) {
token = element
type = token[0]
@@ -268,12 +267,12 @@ class Parser {
let str = ''
for (let j = i; j > 0; j--) {
let type = cache[j][0]
if (str.trim().indexOf('!') === 0 && type !== 'space') {
if (str.trim().startsWith('!') && type !== 'space') {
break
}
str = cache.pop()[1] + str
}
if (str.trim().indexOf('!') === 0) {
if (str.trim().startsWith('!')) {
node.important = true
node.raws.important = str
tokens = cache
@@ -348,6 +347,8 @@ class Parser {
if (prev && prev.type === 'rule' && !prev.raws.ownSemicolon) {
prev.raws.ownSemicolon = this.spaces
this.spaces = ''
prev.source.end = this.getPosition(token[2])
prev.source.end.offset += prev.raws.ownSemicolon.length
}
}
}
@@ -592,7 +593,7 @@ class Parser {
unknownWord(tokens) {
throw this.input.error(
'Unknown word',
'Unknown word ' + tokens[0][1],
{ offset: tokens[0][2] },
{ offset: tokens[0][2] + tokens[0][1].length }
)

View File

@@ -1,72 +1,69 @@
export {
// postcss function / namespace
default,
// Value exports from postcss.mjs
stringify,
fromJSON,
// @ts-expect-error This value exists, but its untyped.
plugin,
parse,
list,
document,
comment,
atRule,
rule,
decl,
root,
CssSyntaxError,
Declaration,
Container,
Processor,
Document,
Comment,
Warning,
AtRule,
Result,
Input,
Rule,
Root,
Node,
// Type-only exports
AcceptedPlugin,
AnyNode,
atRule,
AtRule,
AtRuleProps,
Builder,
ChildNode,
ChildProps,
comment,
Comment,
CommentProps,
Container,
ContainerProps,
CssSyntaxError,
decl,
Declaration,
DeclarationProps,
// postcss function / namespace
default,
document,
Document,
DocumentProps,
FilePosition,
fromJSON,
Helpers,
Input,
JSONHydrator,
// This is a class, but its not re-exported. Thats why its exported as type-only here.
type LazyResult,
list,
Message,
Node,
NodeErrorOptions,
NodeProps,
OldPlugin,
parse,
Parser,
// @ts-expect-error This value exists, but its untyped.
plugin,
Plugin,
PluginCreator,
Position,
Postcss,
ProcessOptions,
Processor,
Result,
root,
Root,
RootProps,
rule,
Rule,
RuleProps,
Source,
SourceMap,
SourceMapOptions,
Stringifier,
// Value exports from postcss.mjs
stringify,
Syntax,
TransformCallback,
Transformer,
WarningOptions,
// This is a class, but its not re-exported. Thats why its exported as type-only here.
type LazyResult,
Warning,
WarningOptions
} from './postcss.js'

View File

@@ -2,7 +2,7 @@ import { RawSourceMap, SourceMapGenerator } from 'source-map-js'
import AtRule, { AtRuleProps } from './at-rule.js'
import Comment, { CommentProps } from './comment.js'
import Container, { ContainerProps } from './container.js'
import Container, { ContainerProps, NewChild } from './container.js'
import CssSyntaxError from './css-syntax-error.js'
import Declaration, { DeclarationProps } from './declaration.js'
import Document, { DocumentProps } from './document.js'
@@ -28,13 +28,22 @@ type DocumentProcessor = (
document: Document,
helper: postcss.Helpers
) => Promise<void> | void
type RootProcessor = (root: Root, helper: postcss.Helpers) => Promise<void> | void
type RootProcessor = (
root: Root,
helper: postcss.Helpers
) => Promise<void> | void
type DeclarationProcessor = (
decl: Declaration,
helper: postcss.Helpers
) => Promise<void> | void
type RuleProcessor = (rule: Rule, helper: postcss.Helpers) => Promise<void> | void
type AtRuleProcessor = (atRule: AtRule, helper: postcss.Helpers) => Promise<void> | void
type RuleProcessor = (
rule: Rule,
helper: postcss.Helpers
) => Promise<void> | void
type AtRuleProcessor = (
atRule: AtRule,
helper: postcss.Helpers
) => Promise<void> | void
type CommentProcessor = (
comment: Comment,
helper: postcss.Helpers
@@ -161,6 +170,7 @@ declare namespace postcss {
LazyResult,
list,
Message,
NewChild,
Node,
NodeErrorOptions,
NodeProps,
@@ -176,9 +186,9 @@ declare namespace postcss {
WarningOptions
}
export type SourceMap = SourceMapGenerator & {
export type SourceMap = {
toJSON(): RawSourceMap
}
} & SourceMapGenerator
export type Helpers = { postcss: Postcss; result: Result } & Postcss
@@ -219,7 +229,7 @@ declare namespace postcss {
export interface Parser<RootNode = Document | Root> {
(
css: { toString(): string } | string,
opts?: Pick<ProcessOptions, 'from' | 'map'>
opts?: Pick<ProcessOptions, 'document' | 'from' | 'map'>
): RootNode
}
@@ -305,6 +315,11 @@ declare namespace postcss {
}
export interface ProcessOptions<RootNode = Document | Root> {
/**
* Input file if it is not simple CSS file, but HTML with <style> or JS with CSS-in-JS blocks.
*/
document?: string
/**
* The path of the CSS source file. You should always set `from`,
* because it is used in source map generation and syntax error messages.
@@ -435,7 +450,9 @@ declare namespace postcss {
* @param plugins PostCSS plugins.
* @return Processor to process multiple CSS.
*/
declare function postcss(plugins?: postcss.AcceptedPlugin[]): Processor
declare function postcss(
plugins?: readonly postcss.AcceptedPlugin[]
): Processor
declare function postcss(...plugins: postcss.AcceptedPlugin[]): Processor
export = postcss

24
node_modules/postcss/lib/postcss.js generated vendored
View File

@@ -1,23 +1,23 @@
'use strict'
let AtRule = require('./at-rule')
let Comment = require('./comment')
let Container = require('./container')
let CssSyntaxError = require('./css-syntax-error')
let Declaration = require('./declaration')
let LazyResult = require('./lazy-result')
let Container = require('./container')
let Processor = require('./processor')
let stringify = require('./stringify')
let fromJSON = require('./fromJSON')
let Document = require('./document')
let Warning = require('./warning')
let Comment = require('./comment')
let AtRule = require('./at-rule')
let Result = require('./result.js')
let fromJSON = require('./fromJSON')
let Input = require('./input')
let parse = require('./parse')
let LazyResult = require('./lazy-result')
let list = require('./list')
let Rule = require('./rule')
let Root = require('./root')
let Node = require('./node')
let parse = require('./parse')
let Processor = require('./processor')
let Result = require('./result.js')
let Root = require('./root')
let Rule = require('./rule')
let stringify = require('./stringify')
let Warning = require('./warning')
function postcss(...plugins) {
if (plugins.length === 1 && Array.isArray(plugins[0])) {

View File

@@ -1,8 +1,8 @@
'use strict'
let { SourceMapConsumer, SourceMapGenerator } = require('source-map-js')
let { existsSync, readFileSync } = require('fs')
let { dirname, join } = require('path')
let { SourceMapConsumer, SourceMapGenerator } = require('source-map-js')
function fromBase64(str) {
if (Buffer) {
@@ -41,12 +41,14 @@ class PreviousMap {
let charsetUri = /^data:application\/json;charset=utf-?8,/
let uri = /^data:application\/json,/
if (charsetUri.test(text) || uri.test(text)) {
return decodeURIComponent(text.substr(RegExp.lastMatch.length))
let uriMatch = text.match(charsetUri) || text.match(uri)
if (uriMatch) {
return decodeURIComponent(text.substr(uriMatch[0].length))
}
if (baseCharsetUri.test(text) || baseUri.test(text)) {
return fromBase64(text.substr(RegExp.lastMatch.length))
let baseUriMatch = text.match(baseCharsetUri) || text.match(baseUri)
if (baseUriMatch) {
return fromBase64(text.substr(baseUriMatch[0].length))
}
let encoding = text.match(/data:application\/json;([^,]+),/)[1]
@@ -67,7 +69,7 @@ class PreviousMap {
}
loadAnnotation(css) {
let comments = css.match(/\/\*\s*# sourceMappingURL=/gm)
let comments = css.match(/\/\*\s*# sourceMappingURL=/g)
if (!comments) return
// sourceMappingURLs from comments, strings, etc.

View File

@@ -51,7 +51,7 @@ declare class Processor_ {
/**
* @param plugins PostCSS plugins
*/
constructor(plugins?: AcceptedPlugin[])
constructor(plugins?: readonly AcceptedPlugin[])
/**
* Parses source CSS and returns a `LazyResult` Promise proxy.

View File

@@ -1,13 +1,13 @@
'use strict'
let NoWorkResult = require('./no-work-result')
let LazyResult = require('./lazy-result')
let Document = require('./document')
let LazyResult = require('./lazy-result')
let NoWorkResult = require('./no-work-result')
let Root = require('./root')
class Processor {
constructor(plugins = []) {
this.version = '8.4.33'
this.version = '8.5.3'
this.plugins = this.normalize(plugins)
}

21
node_modules/postcss/lib/result.d.ts generated vendored
View File

@@ -39,7 +39,6 @@ declare namespace Result {
plugin?: string
}
// eslint-disable-next-line @typescript-eslint/no-use-before-define
export { Result_ as default }
}
@@ -143,6 +142,16 @@ declare class Result_<RootNode = Document | Root> {
*/
root: RootNode
/**
* 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.
* @param root Root node after all transformations.
@@ -189,16 +198,6 @@ declare class Result_<RootNode = Document | Root> {
* @return Warnings from plugins.
*/
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<RootNode = Document | Root> extends Result_<RootNode> {}

8
node_modules/postcss/lib/result.js generated vendored
View File

@@ -3,6 +3,10 @@
let Warning = require('./warning')
class Result {
get content() {
return this.css
}
constructor(processor, root, opts) {
this.processor = processor
this.messages = []
@@ -32,10 +36,6 @@ class Result {
warnings() {
return this.messages.filter(i => i.type === 'warning')
}
get content() {
return this.css
}
}
module.exports = Result

9
node_modules/postcss/lib/root.d.ts generated vendored
View File

@@ -54,6 +54,7 @@ declare namespace Root {
* ```
*/
declare class Root_ extends Container {
nodes: NonNullable<Container['nodes']>
parent: Document | undefined
raws: Root.RootRaws
type: 'root'
@@ -61,9 +62,9 @@ declare class Root_ extends Container {
constructor(defaults?: Root.RootProps)
assign(overrides: object | Root.RootProps): this
clone(overrides?: Partial<Root.RootProps>): Root
cloneAfter(overrides?: Partial<Root.RootProps>): Root
cloneBefore(overrides?: Partial<Root.RootProps>): Root
clone(overrides?: Partial<Root.RootProps>): this
cloneAfter(overrides?: Partial<Root.RootProps>): this
cloneBefore(overrides?: Partial<Root.RootProps>): this
/**
* Returns a `Result` instance representing the roots CSS.
@@ -75,7 +76,7 @@ declare class Root_ extends Container {
* const result = root1.toResult({ to: 'all.css', map: true })
* ```
*
* @param opts Options.
* @param options Options.
* @return Result with current roots CSS.
*/
toResult(options?: ProcessOptions): Result

43
node_modules/postcss/lib/rule.d.ts generated vendored
View File

@@ -1,4 +1,7 @@
import Container, { ContainerProps } from './container.js'
import Container, {
ContainerProps,
ContainerWithChildren
} from './container.js'
declare namespace Rule {
export interface RuleRaws extends Record<string, unknown> {
@@ -19,7 +22,7 @@ declare namespace Rule {
between?: string
/**
* Contains `true` if there is semicolon after rule.
* Contains the text of the semicolon after this rule.
*/
ownSemicolon?: string
@@ -37,14 +40,21 @@ declare namespace Rule {
semicolon?: boolean
}
export interface RuleProps extends ContainerProps {
export type RuleProps = {
/** Information used to generate byte-to-byte equal node string as it was in the origin input. */
raws?: RuleRaws
/** Selector or selectors of the rule. */
selector?: string
/** Selectors of the rule represented as an array of strings. */
selectors?: string[]
}
} & (
| {
/** Selector or selectors of the rule. */
selector: string
selectors?: never
}
| {
selector?: never
/** Selectors of the rule represented as an array of strings. */
selectors: readonly string[]
}
) & ContainerProps
// eslint-disable-next-line @typescript-eslint/no-use-before-define
export { Rule_ as default }
@@ -69,8 +79,10 @@ declare namespace Rule {
* ```
*/
declare class Rule_ extends Container {
parent: Container | undefined
nodes: NonNullable<Container['nodes']>
parent: ContainerWithChildren | undefined
raws: Rule.RuleRaws
type: 'rule'
/**
* The rules full selector represented as a string.
*
@@ -80,8 +92,9 @@ declare class Rule_ extends Container {
* rule.selector //=> 'a, b'
* ```
*/
selector: string
get selector(): string
set selector(value: string)
/**
* An array containing the rules individual selectors.
* Groups of selectors are split at commas.
@@ -97,15 +110,15 @@ declare class Rule_ extends Container {
* rule.selector //=> 'a, strong'
* ```
*/
selectors: string[]
get selectors(): string[]
type: 'rule'
set selectors(values: string[])
constructor(defaults?: Rule.RuleProps)
assign(overrides: object | Rule.RuleProps): this
clone(overrides?: Partial<Rule.RuleProps>): Rule
cloneAfter(overrides?: Partial<Rule.RuleProps>): Rule
cloneBefore(overrides?: Partial<Rule.RuleProps>): Rule
clone(overrides?: Partial<Rule.RuleProps>): this
cloneAfter(overrides?: Partial<Rule.RuleProps>): this
cloneBefore(overrides?: Partial<Rule.RuleProps>): this
}
declare class Rule extends Rule_ {}

12
node_modules/postcss/lib/rule.js generated vendored
View File

@@ -4,12 +4,6 @@ let Container = require('./container')
let list = require('./list')
class Rule extends Container {
constructor(defaults) {
super(defaults)
this.type = 'rule'
if (!this.nodes) this.nodes = []
}
get selectors() {
return list.comma(this.selector)
}
@@ -19,6 +13,12 @@ class Rule extends Container {
let sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen')
this.selector = values.join(sep)
}
constructor(defaults) {
super(defaults)
this.type = 'rule'
if (!this.nodes) this.nodes = []
}
}
module.exports = Rule

View File

@@ -29,8 +29,8 @@ module.exports = function tokenizer(input, options = {}) {
let css = input.css.valueOf()
let ignore = options.ignoreErrors
let code, next, quote, content, escape
let escaped, escapePos, prev, n, currentToken
let code, content, escape, next, quote
let currentToken, escaped, escapePos, n, prev
let length = css.length
let pos = 0

8
node_modules/postcss/package.json generated vendored Normal file → Executable file
View File

@@ -1,6 +1,6 @@
{
"name": "postcss",
"version": "8.4.33",
"version": "8.5.3",
"description": "Tool for transforming styles with JS plugins",
"engines": {
"node": "^10 || ^12 || >=14"
@@ -74,9 +74,9 @@
"url": "https://github.com/postcss/postcss/issues"
},
"dependencies": {
"nanoid": "^3.3.7",
"picocolors": "^1.0.0",
"source-map-js": "^1.0.2"
"nanoid": "^3.3.8",
"picocolors": "^1.1.1",
"source-map-js": "^1.2.1"
},
"browser": {
"./lib/terminal-highlight": false,