feat: refactoring project
This commit is contained in:
95
node_modules/postcss/lib/container.d.ts
generated
vendored
95
node_modules/postcss/lib/container.d.ts
generated
vendored
@@ -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 }
|
||||
}
|
||||
@@ -51,6 +64,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.
|
||||
*
|
||||
@@ -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
|
||||
|
||||
8
node_modules/postcss/lib/container.js
generated
vendored
8
node_modules/postcss/lib/container.js
generated
vendored
@@ -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, '')
|
||||
|
||||
61
node_modules/postcss/lib/css-syntax-error.js
generated
vendored
61
node_modules/postcss/lib/css-syntax-error.js
generated
vendored
@@ -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')
|
||||
}
|
||||
|
||||
2
node_modules/postcss/lib/document.d.ts
generated
vendored
2
node_modules/postcss/lib/document.d.ts
generated
vendored
@@ -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
|
||||
|
||||
6
node_modules/postcss/lib/fromJSON.js
generated
vendored
6
node_modules/postcss/lib/fromJSON.js
generated
vendored
@@ -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')
|
||||
|
||||
|
||||
6
node_modules/postcss/lib/input.d.ts
generated
vendored
6
node_modules/postcss/lib/input.d.ts
generated
vendored
@@ -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_ {}
|
||||
|
||||
8
node_modules/postcss/lib/input.js
generated
vendored
8
node_modules/postcss/lib/input.js
generated
vendored
@@ -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
|
||||
|
||||
10
node_modules/postcss/lib/lazy-result.js
generated
vendored
10
node_modules/postcss/lib/lazy-result.js
generated
vendored
@@ -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',
|
||||
|
||||
6
node_modules/postcss/lib/list.d.ts
generated
vendored
6
node_modules/postcss/lib/list.d.ts
generated
vendored
@@ -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[]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
6
node_modules/postcss/lib/map-generator.js
generated
vendored
6
node_modules/postcss/lib/map-generator.js
generated
vendored
@@ -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
|
||||
|
||||
|
||||
4
node_modules/postcss/lib/no-work-result.js
generated
vendored
4
node_modules/postcss/lib/no-work-result.js
generated
vendored
@@ -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) {
|
||||
|
||||
27
node_modules/postcss/lib/node.d.ts
generated
vendored
27
node_modules/postcss/lib/node.d.ts
generated
vendored
@@ -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'
|
||||
@@ -234,6 +234,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.
|
||||
*
|
||||
@@ -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.
|
||||
|
||||
80
node_modules/postcss/lib/node.js
generated
vendored
80
node_modules/postcss/lib/node.js
generated
vendored
@@ -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,6 +32,36 @@ 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 {
|
||||
constructor(defaults = {}) {
|
||||
this.raws = {}
|
||||
@@ -153,6 +183,11 @@ class Node {
|
||||
}
|
||||
}
|
||||
|
||||
/* c8 ignore next 3 */
|
||||
markClean() {
|
||||
this[isClean] = true
|
||||
}
|
||||
|
||||
markDirty() {
|
||||
if (this[isClean]) {
|
||||
this[isClean] = false
|
||||
@@ -169,25 +204,29 @@ 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 stringRepresentation = this.source.input.css.slice(
|
||||
sourceOffset(this.source.input.css, this.source.start),
|
||||
sourceOffset(this.source.input.css, 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 offset = sourceOffset(this.source.input.css, 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 (this.source.input.css[i] === '\n') {
|
||||
column = 1
|
||||
line += 1
|
||||
} else {
|
||||
@@ -211,20 +250,25 @@ 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 stringRepresentation = this.source.input.css.slice(
|
||||
sourceOffset(this.source.input.css, this.source.start),
|
||||
sourceOffset(this.source.input.css, 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) {
|
||||
|
||||
2
node_modules/postcss/lib/parse.js
generated
vendored
2
node_modules/postcss/lib/parse.js
generated
vendored
@@ -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)
|
||||
|
||||
12
node_modules/postcss/lib/parser.js
generated
vendored
12
node_modules/postcss/lib/parser.js
generated
vendored
@@ -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
|
||||
|
||||
7
node_modules/postcss/lib/postcss.d.ts
generated
vendored
7
node_modules/postcss/lib/postcss.d.ts
generated
vendored
@@ -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
|
||||
|
||||
24
node_modules/postcss/lib/postcss.js
generated
vendored
24
node_modules/postcss/lib/postcss.js
generated
vendored
@@ -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])) {
|
||||
|
||||
2
node_modules/postcss/lib/previous-map.js
generated
vendored
2
node_modules/postcss/lib/previous-map.js
generated
vendored
@@ -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) {
|
||||
|
||||
2
node_modules/postcss/lib/processor.d.ts
generated
vendored
2
node_modules/postcss/lib/processor.d.ts
generated
vendored
@@ -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.
|
||||
|
||||
6
node_modules/postcss/lib/processor.js
generated
vendored
6
node_modules/postcss/lib/processor.js
generated
vendored
@@ -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.49'
|
||||
this.plugins = this.normalize(plugins)
|
||||
}
|
||||
|
||||
|
||||
2
node_modules/postcss/lib/root.d.ts
generated
vendored
2
node_modules/postcss/lib/root.d.ts
generated
vendored
@@ -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
|
||||
|
||||
8
node_modules/postcss/lib/rule.d.ts
generated
vendored
8
node_modules/postcss/lib/rule.d.ts
generated
vendored
@@ -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 }
|
||||
|
||||
4
node_modules/postcss/lib/tokenize.js
generated
vendored
4
node_modules/postcss/lib/tokenize.js
generated
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user