Socket
Socket
Sign inDemoInstall

postcss

Package Overview
Dependencies
Maintainers
0
Versions
261
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss - npm Package Compare versions

Comparing version 8.4.41 to 8.4.42

95

lib/container.d.ts

@@ -23,9 +23,22 @@ import AtRule from './at-rule.js'

*/
props?: string[]
props?: readonly string[]
}
export interface ContainerProps extends NodeProps {
nodes?: (Node | 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

@@ -56,2 +69,22 @@ export { Container_ as default }

/**
* An internal method that converts a {@link NewChild} into a list of actual
* child nodes that can then be added to this container.
*
* 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
*/
protected normalize(
nodes: Container.NewChild,
sample: Node | undefined,
type?: 'prepend' | false
): Child[]
/**
* Inserts new nodes to the end of the container.

@@ -76,17 +109,7 @@ *

*/
append(
...nodes: (
| ChildProps
| ChildProps[]
| Node
| Node[]
| string
| string[]
| undefined
)[]
): this
append(...nodes: Container.NewChild[]): this
assign(overrides: Container.ContainerProps | object): this
clone(overrides?: Partial<Container.ContainerProps>): this
cloneAfter(overrides?: Partial<Container.ContainerProps>): this
cloneBefore(overrides?: Partial<Container.ContainerProps>): this

@@ -130,3 +153,2 @@

): false | undefined
/**

@@ -146,2 +168,3 @@ * Returns `true` if callback returns `true`

): boolean
/**

@@ -158,3 +181,2 @@ * Returns a `child`’s index within the `Container#nodes` array.

index(child: Child | number): number
/**

@@ -167,13 +189,4 @@ * Insert new node after old node within the container.

*/
insertAfter(
oldNode: Child | number,
newNode:
| Node
| Node[]
| ChildProps
| ChildProps[]
| string
| string[]
| undefined
): this
insertAfter(oldNode: Child | number, newNode: Container.NewChild): this
/**

@@ -190,13 +203,3 @@ * Insert new node before old node within the container.

*/
insertBefore(
oldNode: Child | number,
newNode:
| Node
| Node[]
| ChildProps
| ChildProps[]
| string
| string[]
| undefined
): this
insertBefore(oldNode: Child | number, newNode: Container.NewChild): this

@@ -240,13 +243,3 @@ /**

*/
prepend(
...nodes: (
| ChildProps
| ChildProps[]
| Node
| Node[]
| string
| string[]
| undefined
)[]
): this
prepend(...nodes: Container.NewChild[]): this
/**

@@ -313,4 +306,4 @@ * Add child to the end of the 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

@@ -317,0 +310,0 @@ * will receive the same arguments

'use strict'
let { isClean, my } = require('./symbols')
let Comment = require('./comment')
let Declaration = require('./declaration')
let Comment = require('./comment')
let Node = require('./node')
let { isClean, my } = require('./symbols')
let parse, Rule, AtRule, Root
let AtRule, parse, Root, Rule

@@ -10,0 +10,0 @@ function cleanSource(nodes) {

@@ -55,4 +55,13 @@ 'use strict'

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)
}
}

@@ -63,14 +72,4 @@

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

@@ -82,8 +81,42 @@ .slice(start, end)

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)
})

@@ -90,0 +123,0 @@ .join('\n')

@@ -8,3 +8,3 @@ import Container, { ContainerProps } from './container.js'

export interface DocumentProps extends ContainerProps {
nodes?: Root[]
nodes?: readonly Root[]

@@ -11,0 +11,0 @@ /**

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

@@ -9,0 +9,0 @@ let Rule = require('./rule')

@@ -177,2 +177,5 @@ import { CssSyntaxError, ProcessOptions } from './postcss.js'

): false | Input.FilePosition
/** Converts this to a JSON-friendly object representation. */
toJSON(): object
/**

@@ -191,5 +194,2 @@ * The CSS source identifier. Contains `Input#file` if the user

get from(): string
/** Converts this to a JSON-friendly object representation. */
toJSON(): object
}

@@ -196,0 +196,0 @@

'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')

@@ -64,3 +64,3 @@ let fromOffsetCache = Symbol('fromOffsetCache')

error(message, line, column, opts = {}) {
let result, endLine, endColumn
let endColumn, endLine, result

@@ -67,0 +67,0 @@ if (line && typeof line === 'object') {

'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 MapGenerator = require('./map-generator')
let parse = require('./parse')
let Result = require('./result')
let parse = require('./parse')
let Root = require('./root')
let stringify = require('./stringify')
let { isClean, my } = require('./symbols')
let warnOnce = require('./warn-once')

@@ -272,3 +272,3 @@ const TYPE_TO_CLASS_NAME = {

while (!root[isClean]) {
root[isClean] = true
root.markClean()
let stack = [toStack(root)]

@@ -378,3 +378,3 @@ while (stack.length > 0) {

while (!root[isClean]) {
root[isClean] = true
root.markClean()
this.walkSync(root)

@@ -461,3 +461,3 @@ }

if (!child[isClean]) {
child[isClean] = true
child.markClean()
stack.push(toStack(child))

@@ -477,3 +477,3 @@ return

if (node.nodes && node.nodes.length) {
node[isClean] = true
node.markClean()
visit.iterator = node.getIterator()

@@ -491,3 +491,3 @@ }

walkSync(node) {
node[isClean] = true
node.markClean()
let events = getEvents(node)

@@ -494,0 +494,0 @@ for (let event of events) {

@@ -50,3 +50,7 @@ declare namespace list {

*/
split(string: string, separators: string[], last: boolean): string[]
split(
string: string,
separators: readonly string[],
last: boolean
): string[]
}

@@ -53,0 +57,0 @@ }

'use strict'
let { dirname, relative, resolve, sep } = require('path')
let { SourceMapConsumer, SourceMapGenerator } = require('source-map-js')
let { dirname, relative, resolve, sep } = require('path')
let { pathToFileURL } = require('url')

@@ -73,3 +73,3 @@

if (node.type !== 'comment') continue
if (node.text.indexOf('# sourceMappingURL=') === 0) {
if (node.text.startsWith('# sourceMappingURL=')) {
this.root.removeChild(i)

@@ -147,3 +147,3 @@ }

let lines, last
let last, lines
this.stringify(this.root, (str, node, type) => {

@@ -150,0 +150,0 @@ this.css += str

'use strict'
let MapGenerator = require('./map-generator')
let parse = require('./parse')
const Result = require('./result')
let stringify = require('./stringify')
let warnOnce = require('./warn-once')
let parse = require('./parse')
const Result = require('./result')

@@ -9,0 +9,0 @@ class NoWorkResult {

@@ -5,3 +5,3 @@ import AtRule = require('./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'

@@ -239,2 +239,10 @@ import Declaration, { DeclarationProps } from './declaration.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.

@@ -251,3 +259,5 @@ *

*/
after(newNode: Node | Node.ChildProps | Node[] | string | undefined): this
after(
newNode: Node | Node.ChildProps | readonly Node[] | string | undefined
): this

@@ -279,3 +289,5 @@ /**

*/
before(newNode: Node | Node.ChildProps | Node[] | string | undefined): this
before(
newNode: Node | Node.ChildProps | readonly Node[] | string | undefined
): this

@@ -477,10 +489,3 @@ /**

*/
replaceWith(
...nodes: (
| Node
| Node[]
| Node.ChildProps
| Node.ChildProps[]
)[]
): this
replaceWith(...nodes: NewChild[]): this

@@ -487,0 +492,0 @@ /**

'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')

@@ -156,2 +156,6 @@ function cloneNode(obj, parent) {

markClean() {
this[isClean] = true;
}
markDirty() {

@@ -158,0 +162,0 @@ if (this[isClean]) {

'use strict'
let Container = require('./container')
let Input = require('./input')
let Parser = require('./parser')
let Input = require('./input')

@@ -7,0 +7,0 @@ function parse(css, opts) {

'use strict'
let AtRule = require('./at-rule')
let Comment = require('./comment')
let Declaration = require('./declaration')
let tokenizer = require('./tokenize')
let Comment = require('./comment')
let AtRule = require('./at-rule')
let Root = require('./root')
let Rule = require('./rule')
let tokenizer = require('./tokenize')

@@ -146,3 +146,3 @@ const SAFE_COMMENT_NEIGHBOR = {

let brackets = 0
let token, type, prev
let prev, token, type
for (let [i, element] of tokens.entries()) {

@@ -271,3 +271,3 @@ token = element

let type = cache[j][0]
if (str.trim().indexOf('!') === 0 && type !== 'space') {
if (str.trim().startsWith('!') && type !== 'space') {
break

@@ -277,3 +277,3 @@ }

}
if (str.trim().indexOf('!') === 0) {
if (str.trim().startsWith('!')) {
node.important = true

@@ -280,0 +280,0 @@ node.raws.important = str

@@ -5,3 +5,3 @@ import { RawSourceMap, SourceMapGenerator } from 'source-map-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'

@@ -174,2 +174,3 @@ import Declaration, { DeclarationProps } from './declaration.js'

Message,
NewChild,
Node,

@@ -449,5 +450,7 @@ NodeErrorOptions,

*/
declare function postcss(plugins?: postcss.AcceptedPlugin[]): Processor
declare function postcss(
plugins?: readonly postcss.AcceptedPlugin[]
): Processor
declare function postcss(...plugins: postcss.AcceptedPlugin[]): Processor
export = postcss
'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 Document = require('./document')
let fromJSON = require('./fromJSON')
let Input = require('./input')
let LazyResult = require('./lazy-result')
let Container = require('./container')
let list = require('./list')
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 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 Input = require('./input')
let parse = require('./parse')
let list = require('./list')
let Rule = require('./rule')
let Root = require('./root')
let Node = require('./node')

@@ -22,0 +22,0 @@ function postcss(...plugins) {

'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')

@@ -7,0 +7,0 @@ function fromBase64(str) {

@@ -54,3 +54,3 @@ import Document from './document.js'

*/
constructor(plugins?: AcceptedPlugin[])
constructor(plugins?: readonly AcceptedPlugin[])

@@ -57,0 +57,0 @@ /**

'use strict'
let Document = require('./document')
let LazyResult = require('./lazy-result')
let NoWorkResult = require('./no-work-result')
let LazyResult = require('./lazy-result')
let Document = require('./document')
let Root = require('./root')

@@ -10,3 +10,3 @@

constructor(plugins = []) {
this.version = '8.4.41'
this.version = '8.4.42'
this.plugins = this.normalize(plugins)

@@ -13,0 +13,0 @@ }

@@ -79,3 +79,3 @@ import Container, { ContainerProps } from './container.js'

*
* @param opts Options.
* @param options Options.
* @return Result with current root’s CSS.

@@ -82,0 +82,0 @@ */

@@ -43,3 +43,3 @@ import Container, {

export type RuleProps = ContainerProps & {
export type RuleProps = {
/** Information used to generate byte-to-byte equal node string as it was in the origin input. */

@@ -54,7 +54,7 @@ raws?: RuleRaws

| {
selector?: never
/** Selectors of the rule represented as an array of strings. */
selectors: string[]
selector?: never
selectors: readonly string[]
}
)
) & ContainerProps

@@ -61,0 +61,0 @@ // eslint-disable-next-line @typescript-eslint/no-use-before-define

@@ -32,4 +32,4 @@ 'use strict'

let code, next, quote, content, escape
let escaped, escapePos, prev, n, currentToken
let code, content, escape, next, quote
let currentToken, escaped, escapePos, n, prev

@@ -36,0 +36,0 @@ let length = css.length

{
"name": "postcss",
"version": "8.4.41",
"version": "8.4.42",
"description": "Tool for transforming styles with JS plugins",

@@ -5,0 +5,0 @@ "engines": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc