diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2024-10-13 10:37:19 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2024-10-13 10:37:19 +0800 |
| commit | e29b244aeab08ea36fb385c7beb2ad0560217039 (patch) | |
| tree | c66b744dc29573f1acc871862937a23f1b80e6bf /node_modules/postcss | |
| parent | 62c2881629e6413a8fec6d3dd092e4568e2a81dc (diff) | |
bump: @babel/cli 7.25.6 → 7.25.7, @babel/core 7.25.2 → 7.25.8, @babel/preset-env 7.25.4 → 7.25.8, postcss 8.4.41 → 8.4.47, swup 4.7.0 → 4.8.1
Diffstat (limited to 'node_modules/postcss')
31 files changed, 580 insertions, 145 deletions
diff --git a/node_modules/postcss/lib/container.d.ts b/node_modules/postcss/lib/container.d.ts index dfe55f20..692bd696 100644 --- a/node_modules/postcss/lib/container.d.ts +++ b/node_modules/postcss/lib/container.d.ts @@ -20,13 +20,26 @@ declare namespace Container { /** * An array of property names. */ - 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 export { Container_ as default } } @@ -52,6 +65,26 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node { nodes: Child[] | undefined /** + * 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. * * ```js @@ -71,21 +104,11 @@ 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[] - | 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 /** @@ -124,7 +147,6 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node { each( callback: (node: Child, index: number) => false | void ): false | undefined - /** * Returns `true` if callback returns `true` * for all of the container’s children. @@ -139,6 +161,7 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node { every( condition: (node: Child, index: number, nodes: Child[]) => boolean ): boolean + /** * Returns a `child`’s index within the `Container#nodes` array. * @@ -150,7 +173,6 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node { * @return Child index. */ index(child: Child | number): number - /** * Insert new node after old node within the container. * @@ -158,17 +180,8 @@ 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: - | Node - | Node[] - | ChildProps - | ChildProps[] - | string - | string[] - | undefined - ): this + insertAfter(oldNode: Child | number, newNode: Container.NewChild): this + /** * Insert new node before old node within the container. * @@ -180,17 +193,7 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node { * @param newNode New node. * @return This node for methods chain. */ - insertBefore( - oldNode: Child | number, - newNode: - | Node - | Node[] - | ChildProps - | ChildProps[] - | string - | string[] - | undefined - ): this + insertBefore(oldNode: Child | number, newNode: Container.NewChild): this /** * Traverses the container’s descendant nodes, calling callback @@ -229,17 +232,7 @@ 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[] - | undefined - )[] - ): this + prepend(...nodes: Container.NewChild[]): this /** * Add child to the end of the node. * @@ -301,8 +294,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 diff --git a/node_modules/postcss/lib/container.js b/node_modules/postcss/lib/container.js index 8a182071..8b9e1ef8 100644 --- a/node_modules/postcss/lib/container.js +++ b/node_modules/postcss/lib/container.js @@ -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 => { @@ -214,6 +214,8 @@ class Container extends Node { i = i.proxyOf if (i.parent) i.parent.removeChild(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, '') diff --git a/node_modules/postcss/lib/css-syntax-error.js b/node_modules/postcss/lib/css-syntax-error.js index 16930332..275a4f64 100644 --- a/node_modules/postcss/lib/css-syntax-error.js +++ b/node_modules/postcss/lib/css-syntax-error.js @@ -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 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 + 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) - } else { - mark = aside = str => str + 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 + 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') } diff --git a/node_modules/postcss/lib/document.d.ts b/node_modules/postcss/lib/document.d.ts index 79f948af..f9e80634 100644 --- a/node_modules/postcss/lib/document.d.ts +++ b/node_modules/postcss/lib/document.d.ts @@ -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 diff --git a/node_modules/postcss/lib/fromJSON.js b/node_modules/postcss/lib/fromJSON.js index 09f2b89a..c9ac1a86 100644 --- a/node_modules/postcss/lib/fromJSON.js +++ b/node_modules/postcss/lib/fromJSON.js @@ -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') diff --git a/node_modules/postcss/lib/input.d.ts b/node_modules/postcss/lib/input.d.ts index ce8e463a..46ded098 100644 --- a/node_modules/postcss/lib/input.d.ts +++ b/node_modules/postcss/lib/input.d.ts @@ -174,6 +174,9 @@ declare class Input_ { endLine?: number, endColumn?: number ): 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. @@ -187,9 +190,6 @@ declare class Input_ { * ``` */ get from(): string - - /** Converts this to a JSON-friendly object representation. */ - toJSON(): object } declare class Input extends Input_ {} diff --git a/node_modules/postcss/lib/input.js b/node_modules/postcss/lib/input.js index 4b5ee5e0..685bce74 100644 --- a/node_modules/postcss/lib/input.js +++ b/node_modules/postcss/lib/input.js @@ -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') @@ -61,7 +61,7 @@ class Input { } error(message, line, column, opts = {}) { - let result, endLine, endColumn + let endColumn, endLine, result if (line && typeof line === 'object') { let start = line diff --git a/node_modules/postcss/lib/lazy-result.js b/node_modules/postcss/lib/lazy-result.js index 126f40c7..e27701dd 100644 --- a/node_modules/postcss/lib/lazy-result.js +++ b/node_modules/postcss/lib/lazy-result.js @@ -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', diff --git a/node_modules/postcss/lib/list.d.ts b/node_modules/postcss/lib/list.d.ts index d77e181b..e262ad3f 100644 --- a/node_modules/postcss/lib/list.d.ts +++ b/node_modules/postcss/lib/list.d.ts @@ -47,7 +47,11 @@ 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[] } } diff --git a/node_modules/postcss/lib/map-generator.js b/node_modules/postcss/lib/map-generator.js index fd93b060..89069d3e 100644 --- a/node_modules/postcss/lib/map-generator.js +++ b/node_modules/postcss/lib/map-generator.js @@ -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') @@ -70,7 +70,7 @@ 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) } } @@ -143,7 +143,7 @@ class MapGenerator { source: '' } - let lines, last + let last, lines this.stringify(this.root, (str, node, type) => { this.css += str diff --git a/node_modules/postcss/lib/no-work-result.js b/node_modules/postcss/lib/no-work-result.js index 05821b7a..a84d8438 100644 --- a/node_modules/postcss/lib/no-work-result.js +++ b/node_modules/postcss/lib/no-work-result.js @@ -1,10 +1,10 @@ '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) { diff --git a/node_modules/postcss/lib/node.d.ts b/node_modules/postcss/lib/node.d.ts index 8cc3cdbe..35976702 100644 --- a/node_modules/postcss/lib/node.d.ts +++ b/node_modules/postcss/lib/node.d.ts @@ -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' @@ -235,6 +235,14 @@ declare abstract class Node_ { constructor(defaults?: object) /** + * 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. * * Just alias for `node.parent.insertAfter(node, add)`. @@ -246,7 +254,9 @@ declare abstract class Node_ { * @param newNode New node. * @return This node for methods chain. */ - after(newNode: Node | Node.ChildProps | Node[] | string | undefined): this + after( + newNode: Node | Node.ChildProps | readonly Node[] | string | undefined + ): this /** * It assigns properties to an existing node instance. @@ -273,7 +283,9 @@ declare abstract class Node_ { * @param newNode New node. * @return This node for methods chain. */ - before(newNode: Node | Node.ChildProps | Node[] | string | undefined): this + before( + newNode: Node | Node.ChildProps | readonly Node[] | string | undefined + ): this /** * Clear the code style properties for the node and its children. @@ -470,14 +482,7 @@ declare abstract class Node_ { * @param nodes Mode(s) to replace current one. * @return Current node to methods chain. */ - replaceWith( - ...nodes: ( - | Node - | Node[] - | Node.ChildProps - | Node.ChildProps[] - )[] - ): this + replaceWith(...nodes: NewChild[]): this /** * Finds the Root instance of the node’s tree. diff --git a/node_modules/postcss/lib/node.js b/node_modules/postcss/lib/node.js index 9e747ca7..88f382a1 100644 --- a/node_modules/postcss/lib/node.js +++ b/node_modules/postcss/lib/node.js @@ -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() @@ -153,6 +153,11 @@ class Node { } } + /* c8 ignore next 3 */ + markClean() { + this[isClean] = true + } + markDirty() { if (this[isClean]) { this[isClean] = false @@ -211,20 +216,23 @@ 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 index = stringRepresentation.indexOf(opts.word) if (index !== -1) { start = this.positionInside(index, stringRepresentation) - end = this.positionInside(index + opts.word.length, stringRepresentation) + end = this.positionInside( + index + opts.word.length, + stringRepresentation + ) } } else { if (opts.start) { diff --git a/node_modules/postcss/lib/parse.js b/node_modules/postcss/lib/parse.js index 971431f2..00a1037a 100644 --- a/node_modules/postcss/lib/parse.js +++ b/node_modules/postcss/lib/parse.js @@ -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) diff --git a/node_modules/postcss/lib/parser.js b/node_modules/postcss/lib/parser.js index bc761ded..8a044117 100644 --- a/node_modules/postcss/lib/parser.js +++ b/node_modules/postcss/lib/parser.js @@ -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, @@ -143,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] @@ -267,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 diff --git a/node_modules/postcss/lib/postcss.d.ts b/node_modules/postcss/lib/postcss.d.ts index 603fdfdb..d0b8b53d 100644 --- a/node_modules/postcss/lib/postcss.d.ts +++ b/node_modules/postcss/lib/postcss.d.ts @@ -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' @@ -170,6 +170,7 @@ declare namespace postcss { LazyResult, list, Message, + NewChild, Node, NodeErrorOptions, NodeProps, @@ -444,7 +445,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 diff --git a/node_modules/postcss/lib/postcss.js b/node_modules/postcss/lib/postcss.js index 080ee837..8f0773b2 100644 --- a/node_modules/postcss/lib/postcss.js +++ b/node_modules/postcss/lib/postcss.js @@ -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])) { diff --git a/node_modules/postcss/lib/previous-map.js b/node_modules/postcss/lib/previous-map.js index 8eba9ad7..b123dcdc 100644 --- a/node_modules/postcss/lib/previous-map.js +++ b/node_modules/postcss/lib/previous-map.js @@ -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) { diff --git a/node_modules/postcss/lib/processor.d.ts b/node_modules/postcss/lib/processor.d.ts index 50c9a07d..aa2942c6 100644 --- a/node_modules/postcss/lib/processor.d.ts +++ b/node_modules/postcss/lib/processor.d.ts @@ -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. diff --git a/node_modules/postcss/lib/processor.js b/node_modules/postcss/lib/processor.js index 08a40955..729f725b 100644 --- a/node_modules/postcss/lib/processor.js +++ b/node_modules/postcss/lib/processor.js @@ -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.41' + this.version = '8.4.47' this.plugins = this.normalize(plugins) } diff --git a/node_modules/postcss/lib/root.d.ts b/node_modules/postcss/lib/root.d.ts index 248b7042..5c911396 100644 --- a/node_modules/postcss/lib/root.d.ts +++ b/node_modules/postcss/lib/root.d.ts @@ -76,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 root’s CSS. */ toResult(options?: ProcessOptions): Result diff --git a/node_modules/postcss/lib/rule.d.ts b/node_modules/postcss/lib/rule.d.ts index 5e873b4f..da8aae74 100644 --- a/node_modules/postcss/lib/rule.d.ts +++ b/node_modules/postcss/lib/rule.d.ts @@ -40,7 +40,7 @@ declare namespace Rule { semicolon?: boolean } - export type RuleProps = ContainerProps & { + export type RuleProps = { /** Information used to generate byte-to-byte equal node string as it was in the origin input. */ raws?: RuleRaws } & ( @@ -50,11 +50,11 @@ declare namespace Rule { selectors?: never } | { - /** Selectors of the rule represented as an array of strings. */ - selectors: string[] 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 } diff --git a/node_modules/postcss/lib/tokenize.js b/node_modules/postcss/lib/tokenize.js index 39a20a37..1d412845 100644 --- a/node_modules/postcss/lib/tokenize.js +++ b/node_modules/postcss/lib/tokenize.js @@ -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 diff --git a/node_modules/postcss/node_modules/picocolors/LICENSE b/node_modules/postcss/node_modules/picocolors/LICENSE new file mode 100644 index 00000000..46c9b95d --- /dev/null +++ b/node_modules/postcss/node_modules/picocolors/LICENSE @@ -0,0 +1,15 @@ +ISC License + +Copyright (c) 2021-2024 Oleksii Raspopov, Kostiantyn Denysov, Anton Verinov + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/postcss/node_modules/picocolors/README.md b/node_modules/postcss/node_modules/picocolors/README.md new file mode 100644 index 00000000..54e3aa3b --- /dev/null +++ b/node_modules/postcss/node_modules/picocolors/README.md @@ -0,0 +1,177 @@ +# picocolors + +The tiniest and the fastest library for terminal output formatting with ANSI colors. + +```javascript +import pc from "picocolors" + +console.log( + pc.green(`How are ${pc.italic(`you`)} doing?`) +) +``` + +- **No dependencies.** +- **14 times** smaller and **2 times** faster than chalk. +- Used by popular tools like PostCSS, SVGO, Stylelint, and Browserslist. +- Node.js v6+ & browsers support. Support for both CJS and ESM projects. +- TypeScript type declarations included. +- [`NO_COLOR`](https://no-color.org/) friendly. + +## Motivation + +With `picocolors` we are trying to draw attention to the `node_modules` size +problem and promote performance-first culture. + +## Prior Art + +Credits go to the following projects: + +- [Nanocolors](https://github.com/ai/nanocolors) by [@ai](https://github.com/ai) +- [Colorette](https://github.com/jorgebucaran/colorette) by [@jorgebucaran](https://github.com/jorgebucaran) +- [Kleur](https://github.com/lukeed/kleur) by [@lukeed](https://github.com/lukeed) +- [Colors.js](https://github.com/Marak/colors.js) by [@Marak](https://github.com/Marak) +- [Chalk](https://github.com/chalk/chalk) by [@sindresorhus](https://github.com/sindresorhus) + +## Benchmarks + +The space in node_modules including sub-dependencies: + +```diff +$ node ./benchmarks/size.js +Data from packagephobia.com + chalk 101 kB + cli-color 1249 kB + ansi-colors 25 kB + kleur 21 kB + colorette 17 kB + nanocolors 16 kB ++ picocolors 7 kB +``` + +Library loading time: + +```diff +$ node ./benchmarks/loading.js + chalk 6.167 ms + cli-color 31.431 ms + ansi-colors 1.585 ms + kleur 2.008 ms + kleur/colors 0.773 ms + colorette 2.476 ms + nanocolors 0.833 ms ++ picocolors 0.466 ms +``` + +Benchmark for simple use case: + +```diff +$ node ./benchmarks/simple.js + chalk 24,066,342 ops/sec + cli-color 938,700 ops/sec + ansi-colors 4,532,542 ops/sec + kleur 20,343,122 ops/sec + kleur/colors 35,415,770 ops/sec + colorette 34,244,834 ops/sec + nanocolors 33,443,265 ops/sec ++ picocolors 33,271,645 ops/sec +``` + +Benchmark for complex use cases: + +```diff +$ node ./benchmarks/complex.js + chalk 969,915 ops/sec + cli-color 131,639 ops/sec + ansi-colors 342,250 ops/sec + kleur 611,880 ops/sec + kleur/colors 1,129,526 ops/sec + colorette 1,747,277 ops/sec + nanocolors 1,251,312 ops/sec ++ picocolors 2,024,086 ops/sec +``` + +## Usage + +Picocolors provides an object which includes a variety of text coloring and formatting functions + +```javascript +import pc from "picocolors" +``` + +The object includes following coloring functions: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, `gray`. + +```javascript +console.log(`I see a ${pc.red("red door")} and I want it painted ${pc.black("black")}`) +``` + +The object also includes following background color modifier functions: `bgBlack`, `bgRed`, `bgGreen`, `bgYellow`, `bgBlue`, `bgMagenta`, `bgCyan`, `bgWhite` and bright variants `bgBlackBright`, `bgRedBright`, `bgGreenBright`, `bgYellowBright`, `bgBlueBright`, `bgMagentaBright`, `bgCyanBright`, `bgWhiteBright`. + +```javascript +console.log( + pc.bgBlack( + pc.white(`Tom appeared on the sidewalk with a bucket of whitewash and a long-handled brush.`) + ) +) +``` + +Besides colors, the object includes following formatting functions: `dim`, `bold`, `hidden`, `italic`, `underline`, `strikethrough`, `reset`, `inverse` and bright variants `blackBright`, `redBright`, `greenBright`, `yellowBright`, `blueBright`, `magentaBright`, `cyanBright`, `whiteBright`. + +```javascript +for (let task of tasks) { + console.log(`${pc.bold(task.name)} ${pc.dim(task.durationMs + "ms")}`) +} +``` + +The library provides additional utilities to ensure the best results for the task: + +- `isColorSupported` — boolean, explicitly tells whether or not the colors or formatting appear on the screen + + ```javascript + import pc from "picocolors" + + if (pc.isColorSupported) { + console.log("Yay! This script can use colors and formatters") + } + ``` + +- `createColors(enabled)` — a function that returns a new API object with manually defined color support configuration + + ```javascript + import pc from "picocolors" + + let { red, bgWhite } = pc.createColors(options.enableColors) + ``` + +## Replacing `chalk` + +1. Replace package name in import: + + ```diff + - import chalk from 'chalk' + + import pico from 'picocolors' + ``` + +2. Replace variable: + + ```diff + - chalk.red(text) + + pico.red(text) + ``` + +3. Replace chains to nested calls: + + ```diff + - chalk.red.bold(text) + + pico.red(pico.bold(text)) + ``` + +4. You can use [`colorize-template`](https://github.com/usmanyunusov/colorize-template) + to replace chalk’s tagged template literal. + + ```diff + + import { createColorize } from 'colorize-template' + + + let colorize = createColorize(pico) + - chalk.red.bold`full {yellow ${"text"}}` + + colorize`{red.bold full {yellow ${"text"}}}` + ``` diff --git a/node_modules/postcss/node_modules/picocolors/package.json b/node_modules/postcss/node_modules/picocolors/package.json new file mode 100644 index 00000000..fd781f4b --- /dev/null +++ b/node_modules/postcss/node_modules/picocolors/package.json @@ -0,0 +1,49 @@ +{ + "name": "picocolors", + "version": "1.1.0", + "main": "./picocolors.js", + "types": "./picocolors.d.ts", + "browser": { + "./picocolors.js": "./picocolors.browser.js" + }, + "sideEffects": false, + "description": "The tiniest and the fastest library for terminal output formatting with ANSI colors", + "scripts": { + "test": "node tests/test.js" + }, + "files": [ + "picocolors.*", + "types.ts" + ], + "keywords": [ + "terminal", + "colors", + "formatting", + "cli", + "console" + ], + "author": "Alexey Raspopov", + "repository": "alexeyraspopov/picocolors", + "license": "ISC", + "devDependencies": { + "ansi-colors": "^4.1.1", + "benchmark": "^2.1.4", + "chalk": "^4.1.2", + "clean-publish": "^3.0.3", + "cli-color": "^2.0.0", + "colorette": "^2.0.12", + "kleur": "^4.1.4", + "nanocolors": "^0.2.12", + "prettier": "^2.4.1" + }, + "prettier": { + "printWidth": 100, + "useTabs": true, + "tabWidth": 2, + "semi": false, + "arrowParens": "avoid" + }, + "clean-publish": { + "cleanDocs": true + } +} diff --git a/node_modules/postcss/node_modules/picocolors/picocolors.browser.js b/node_modules/postcss/node_modules/picocolors/picocolors.browser.js new file mode 100644 index 00000000..9dcf637c --- /dev/null +++ b/node_modules/postcss/node_modules/picocolors/picocolors.browser.js @@ -0,0 +1,4 @@ +var x=String; +var create=function() {return {isColorSupported:false,reset:x,bold:x,dim:x,italic:x,underline:x,inverse:x,hidden:x,strikethrough:x,black:x,red:x,green:x,yellow:x,blue:x,magenta:x,cyan:x,white:x,gray:x,bgBlack:x,bgRed:x,bgGreen:x,bgYellow:x,bgBlue:x,bgMagenta:x,bgCyan:x,bgWhite:x,blackBright:x,redBright:x,greenBright:x,yellowBright:x,blueBright:x,magentaBright:x,cyanBright:x,whiteBright:x,bgBlackBright:x,bgRedBright:x,bgGreenBright:x,bgYellowBright:x,bgBlueBright:x,bgMagentaBright:x,bgCyanBright:x,bgWhiteBright:x}}; +module.exports=create(); +module.exports.createColors = create; diff --git a/node_modules/postcss/node_modules/picocolors/picocolors.d.ts b/node_modules/postcss/node_modules/picocolors/picocolors.d.ts new file mode 100644 index 00000000..94e146a8 --- /dev/null +++ b/node_modules/postcss/node_modules/picocolors/picocolors.d.ts @@ -0,0 +1,5 @@ +import { Colors } from "./types" + +declare const picocolors: Colors & { createColors: (enabled?: boolean) => Colors } + +export = picocolors diff --git a/node_modules/postcss/node_modules/picocolors/picocolors.js b/node_modules/postcss/node_modules/picocolors/picocolors.js new file mode 100644 index 00000000..f5ea2a18 --- /dev/null +++ b/node_modules/postcss/node_modules/picocolors/picocolors.js @@ -0,0 +1,85 @@ +let argv = process.argv || [], + env = process.env +let isColorSupported = + !("NO_COLOR" in env || argv.includes("--no-color")) && + ("FORCE_COLOR" in env || + argv.includes("--color") || + process.platform === "win32" || + (require != null && require("tty").isatty(1) && env.TERM !== "dumb") || + "CI" in env) + +let formatter = + (open, close, replace = open) => + input => { + let string = "" + input + let index = string.indexOf(close, open.length) + return ~index + ? open + replaceClose(string, close, replace, index) + close + : open + string + close + } + +let replaceClose = (string, close, replace, index) => { + let result = "" + let cursor = 0 + do { + result += string.substring(cursor, index) + replace + cursor = index + close.length + index = string.indexOf(close, cursor) + } while (~index) + return result + string.substring(cursor) +} + +let createColors = (enabled = isColorSupported) => { + let init = enabled ? formatter : () => String + return { + isColorSupported: enabled, + reset: init("\x1b[0m", "\x1b[0m"), + bold: init("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"), + dim: init("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"), + italic: init("\x1b[3m", "\x1b[23m"), + underline: init("\x1b[4m", "\x1b[24m"), + inverse: init("\x1b[7m", "\x1b[27m"), + hidden: init("\x1b[8m", "\x1b[28m"), + strikethrough: init("\x1b[9m", "\x1b[29m"), + + black: init("\x1b[30m", "\x1b[39m"), + red: init("\x1b[31m", "\x1b[39m"), + green: init("\x1b[32m", "\x1b[39m"), + yellow: init("\x1b[33m", "\x1b[39m"), + blue: init("\x1b[34m", "\x1b[39m"), + magenta: init("\x1b[35m", "\x1b[39m"), + cyan: init("\x1b[36m", "\x1b[39m"), + white: init("\x1b[37m", "\x1b[39m"), + gray: init("\x1b[90m", "\x1b[39m"), + + bgBlack: init("\x1b[40m", "\x1b[49m"), + bgRed: init("\x1b[41m", "\x1b[49m"), + bgGreen: init("\x1b[42m", "\x1b[49m"), + bgYellow: init("\x1b[43m", "\x1b[49m"), + bgBlue: init("\x1b[44m", "\x1b[49m"), + bgMagenta: init("\x1b[45m", "\x1b[49m"), + bgCyan: init("\x1b[46m", "\x1b[49m"), + bgWhite: init("\x1b[47m", "\x1b[49m"), + + blackBright: init("\x1b[90m", "\x1b[39m"), + redBright: init("\x1b[91m", "\x1b[39m"), + greenBright: init("\x1b[92m", "\x1b[39m"), + yellowBright: init("\x1b[93m", "\x1b[39m"), + blueBright: init("\x1b[94m", "\x1b[39m"), + magentaBright: init("\x1b[95m", "\x1b[39m"), + cyanBright: init("\x1b[96m", "\x1b[39m"), + whiteBright: init("\x1b[97m", "\x1b[39m"), + + bgBlackBright: init("\x1b[100m","\x1b[49m"), + bgRedBright: init("\x1b[101m","\x1b[49m"), + bgGreenBright: init("\x1b[102m","\x1b[49m"), + bgYellowBright: init("\x1b[103m","\x1b[49m"), + bgBlueBright: init("\x1b[104m","\x1b[49m"), + bgMagentaBright: init("\x1b[105m","\x1b[49m"), + bgCyanBright: init("\x1b[106m","\x1b[49m"), + bgWhiteBright: init("\x1b[107m","\x1b[49m"), + } +} + +module.exports = createColors() +module.exports.createColors = createColors diff --git a/node_modules/postcss/node_modules/picocolors/types.ts b/node_modules/postcss/node_modules/picocolors/types.ts new file mode 100644 index 00000000..8046e270 --- /dev/null +++ b/node_modules/postcss/node_modules/picocolors/types.ts @@ -0,0 +1,52 @@ +export type Formatter = (input: string | number | null | undefined) => string + +export interface Colors { + isColorSupported: boolean + + reset: Formatter + bold: Formatter + dim: Formatter + italic: Formatter + underline: Formatter + inverse: Formatter + hidden: Formatter + strikethrough: Formatter + + black: Formatter + red: Formatter + green: Formatter + yellow: Formatter + blue: Formatter + magenta: Formatter + cyan: Formatter + white: Formatter + gray: Formatter + + bgBlack: Formatter + bgRed: Formatter + bgGreen: Formatter + bgYellow: Formatter + bgBlue: Formatter + bgMagenta: Formatter + bgCyan: Formatter + bgWhite: Formatter + + blackBright: Formatter + redBright: Formatter + greenBright: Formatter + yellowBright: Formatter + blueBright: Formatter + magentaBright: Formatter + cyanBright: Formatter + whiteBright: Formatter + + bgBlackBright: Formatter + bgRedBright: Formatter + bgGreenBright: Formatter + bgYellowBright: Formatter + bgBlueBright: Formatter + bgMagentaBright: Formatter + bgCyanBright: Formatter + bgWhiteBright: Formatter + +} diff --git a/node_modules/postcss/package.json b/node_modules/postcss/package.json index 991d040d..bd8992a1 100755 --- a/node_modules/postcss/package.json +++ b/node_modules/postcss/package.json @@ -1,6 +1,6 @@ { "name": "postcss", - "version": "8.4.41", + "version": "8.4.47", "description": "Tool for transforming styles with JS plugins", "engines": { "node": "^10 || ^12 || >=14" @@ -75,8 +75,8 @@ }, "dependencies": { "nanoid": "^3.3.7", - "picocolors": "^1.0.1", - "source-map-js": "^1.2.0" + "picocolors": "^1.1.0", + "source-map-js": "^1.2.1" }, "browser": { "./lib/terminal-highlight": false, |
