完成世界书、骰子、apiconfig页面处理
This commit is contained in:
13
frontend/node_modules/postcss/lib/comment.js
generated
vendored
Normal file
13
frontend/node_modules/postcss/lib/comment.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
'use strict'
|
||||
|
||||
let Node = require('./node')
|
||||
|
||||
class Comment extends Node {
|
||||
constructor(defaults) {
|
||||
super(defaults)
|
||||
this.type = 'comment'
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Comment
|
||||
Comment.default = Comment
|
||||
447
frontend/node_modules/postcss/lib/container.js
generated
vendored
Normal file
447
frontend/node_modules/postcss/lib/container.js
generated
vendored
Normal file
@@ -0,0 +1,447 @@
|
||||
'use strict'
|
||||
|
||||
let Comment = require('./comment')
|
||||
let Declaration = require('./declaration')
|
||||
let Node = require('./node')
|
||||
let { isClean, my } = require('./symbols')
|
||||
|
||||
let AtRule, parse, Root, Rule
|
||||
|
||||
function cleanSource(nodes) {
|
||||
return nodes.map(i => {
|
||||
if (i.nodes) i.nodes = cleanSource(i.nodes)
|
||||
delete i.source
|
||||
return i
|
||||
})
|
||||
}
|
||||
|
||||
function markTreeDirty(node) {
|
||||
node[isClean] = false
|
||||
if (node.proxyOf.nodes) {
|
||||
for (let i of node.proxyOf.nodes) {
|
||||
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)
|
||||
for (let node of nodes) this.proxyOf.nodes.push(node)
|
||||
}
|
||||
|
||||
this.markDirty()
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
cleanRaws(keepBetween) {
|
||||
super.cleanRaws(keepBetween)
|
||||
if (this.nodes) {
|
||||
for (let node of this.nodes) node.cleanRaws(keepBetween)
|
||||
}
|
||||
}
|
||||
|
||||
each(callback) {
|
||||
if (!this.proxyOf.nodes) return undefined
|
||||
let iterator = this.getIterator()
|
||||
|
||||
let index, result
|
||||
while (this.indexes[iterator] < this.proxyOf.nodes.length) {
|
||||
index = this.indexes[iterator]
|
||||
result = callback(this.proxyOf.nodes[index], index)
|
||||
if (result === false) break
|
||||
|
||||
this.indexes[iterator] += 1
|
||||
}
|
||||
|
||||
delete this.indexes[iterator]
|
||||
return result
|
||||
}
|
||||
|
||||
every(condition) {
|
||||
return this.nodes.every(condition)
|
||||
}
|
||||
|
||||
getIterator() {
|
||||
if (!this.lastEach) this.lastEach = 0
|
||||
if (!this.indexes) this.indexes = {}
|
||||
|
||||
this.lastEach += 1
|
||||
let iterator = this.lastEach
|
||||
this.indexes[iterator] = 0
|
||||
|
||||
return iterator
|
||||
}
|
||||
|
||||
getProxyProcessor() {
|
||||
return {
|
||||
get(node, prop) {
|
||||
if (prop === 'proxyOf') {
|
||||
return node
|
||||
} else if (!node[prop]) {
|
||||
return node[prop]
|
||||
} else if (
|
||||
prop === 'each' ||
|
||||
(typeof prop === 'string' && prop.startsWith('walk'))
|
||||
) {
|
||||
return (...args) => {
|
||||
return node[prop](
|
||||
...args.map(i => {
|
||||
if (typeof i === 'function') {
|
||||
return (child, index) => i(child.toProxy(), index)
|
||||
} else {
|
||||
return i
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
} else if (prop === 'every' || prop === 'some') {
|
||||
return cb => {
|
||||
return node[prop]((child, ...other) =>
|
||||
cb(child.toProxy(), ...other)
|
||||
)
|
||||
}
|
||||
} else if (prop === 'root') {
|
||||
return () => node.root().toProxy()
|
||||
} else if (prop === 'nodes') {
|
||||
return node.nodes.map(i => i.toProxy())
|
||||
} else if (prop === 'first' || prop === 'last') {
|
||||
return node[prop].toProxy()
|
||||
} else {
|
||||
return node[prop]
|
||||
}
|
||||
},
|
||||
|
||||
set(node, prop, value) {
|
||||
if (node[prop] === value) return true
|
||||
node[prop] = value
|
||||
if (prop === 'name' || prop === 'params' || prop === 'selector') {
|
||||
node.markDirty()
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
index(child) {
|
||||
if (typeof child === 'number') return child
|
||||
if (child.proxyOf) child = child.proxyOf
|
||||
return this.proxyOf.nodes.indexOf(child)
|
||||
}
|
||||
|
||||
insertAfter(exist, add) {
|
||||
let existIndex = this.index(exist)
|
||||
let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse()
|
||||
existIndex = this.index(exist)
|
||||
for (let node of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node)
|
||||
|
||||
let index
|
||||
for (let id in this.indexes) {
|
||||
index = this.indexes[id]
|
||||
if (existIndex < index) {
|
||||
this.indexes[id] = index + nodes.length
|
||||
}
|
||||
}
|
||||
|
||||
this.markDirty()
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
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()
|
||||
existIndex = this.index(exist)
|
||||
for (let node of nodes) this.proxyOf.nodes.splice(existIndex, 0, node)
|
||||
|
||||
let index
|
||||
for (let id in this.indexes) {
|
||||
index = this.indexes[id]
|
||||
if (existIndex <= index) {
|
||||
this.indexes[id] = index + nodes.length
|
||||
}
|
||||
}
|
||||
|
||||
this.markDirty()
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
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) {
|
||||
if (i.parent) i.parent.removeChild(i, 'ignore')
|
||||
}
|
||||
} else if (nodes.type === 'root' && this.type !== 'document') {
|
||||
nodes = nodes.nodes.slice(0)
|
||||
for (let i of nodes) {
|
||||
if (i.parent) i.parent.removeChild(i, 'ignore')
|
||||
}
|
||||
} else if (nodes.type) {
|
||||
nodes = [nodes]
|
||||
} else if (nodes.prop) {
|
||||
if (typeof nodes.value === 'undefined') {
|
||||
throw new Error('Value field is missed in node creation')
|
||||
} else if (typeof nodes.value !== 'string') {
|
||||
nodes.value = String(nodes.value)
|
||||
}
|
||||
nodes = [new Declaration(nodes)]
|
||||
} else if (nodes.selector || nodes.selectors) {
|
||||
nodes = [new Rule(nodes)]
|
||||
} else if (nodes.name) {
|
||||
nodes = [new AtRule(nodes)]
|
||||
} else if (nodes.text) {
|
||||
nodes = [new Comment(nodes)]
|
||||
} else {
|
||||
throw new Error('Unknown node type in node creation')
|
||||
}
|
||||
|
||||
let processed = nodes.map(i => {
|
||||
/* c8 ignore next */
|
||||
if (!i[my]) Container.rebuild(i)
|
||||
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, '')
|
||||
}
|
||||
}
|
||||
i.parent = this.proxyOf
|
||||
return i
|
||||
})
|
||||
|
||||
return processed
|
||||
}
|
||||
|
||||
prepend(...children) {
|
||||
children = children.reverse()
|
||||
for (let child of children) {
|
||||
let nodes = this.normalize(child, this.first, 'prepend').reverse()
|
||||
for (let node of nodes) this.proxyOf.nodes.unshift(node)
|
||||
for (let id in this.indexes) {
|
||||
this.indexes[id] = this.indexes[id] + nodes.length
|
||||
}
|
||||
}
|
||||
|
||||
this.markDirty()
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
push(child) {
|
||||
child.parent = this
|
||||
this.proxyOf.nodes.push(child)
|
||||
return this
|
||||
}
|
||||
|
||||
removeAll() {
|
||||
for (let node of this.proxyOf.nodes) node.parent = undefined
|
||||
this.proxyOf.nodes = []
|
||||
|
||||
this.markDirty()
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
removeChild(child) {
|
||||
child = this.index(child)
|
||||
this.proxyOf.nodes[child].parent = undefined
|
||||
this.proxyOf.nodes.splice(child, 1)
|
||||
|
||||
let index
|
||||
for (let id in this.indexes) {
|
||||
index = this.indexes[id]
|
||||
if (index >= child) {
|
||||
this.indexes[id] = index - 1
|
||||
}
|
||||
}
|
||||
|
||||
this.markDirty()
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
replaceValues(pattern, opts, callback) {
|
||||
if (!callback) {
|
||||
callback = opts
|
||||
opts = {}
|
||||
}
|
||||
|
||||
this.walkDecls(decl => {
|
||||
if (opts.props && !opts.props.includes(decl.prop)) return
|
||||
if (opts.fast && !decl.value.includes(opts.fast)) return
|
||||
|
||||
decl.value = decl.value.replace(pattern, callback)
|
||||
})
|
||||
|
||||
this.markDirty()
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
some(condition) {
|
||||
return this.nodes.some(condition)
|
||||
}
|
||||
|
||||
walk(callback) {
|
||||
return this.each((child, i) => {
|
||||
let result
|
||||
try {
|
||||
result = callback(child, i)
|
||||
} catch (e) {
|
||||
throw child.addToError(e)
|
||||
}
|
||||
if (result !== false && child.walk) {
|
||||
result = child.walk(callback)
|
||||
}
|
||||
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
||||
walkAtRules(name, callback) {
|
||||
if (!callback) {
|
||||
callback = name
|
||||
return this.walk((child, i) => {
|
||||
if (child.type === 'atrule') {
|
||||
return callback(child, i)
|
||||
}
|
||||
})
|
||||
}
|
||||
if (name instanceof RegExp) {
|
||||
return this.walk((child, i) => {
|
||||
if (child.type === 'atrule' && name.test(child.name)) {
|
||||
return callback(child, i)
|
||||
}
|
||||
})
|
||||
}
|
||||
return this.walk((child, i) => {
|
||||
if (child.type === 'atrule' && child.name === name) {
|
||||
return callback(child, i)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
walkComments(callback) {
|
||||
return this.walk((child, i) => {
|
||||
if (child.type === 'comment') {
|
||||
return callback(child, i)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
walkDecls(prop, callback) {
|
||||
if (!callback) {
|
||||
callback = prop
|
||||
return this.walk((child, i) => {
|
||||
if (child.type === 'decl') {
|
||||
return callback(child, i)
|
||||
}
|
||||
})
|
||||
}
|
||||
if (prop instanceof RegExp) {
|
||||
return this.walk((child, i) => {
|
||||
if (child.type === 'decl' && prop.test(child.prop)) {
|
||||
return callback(child, i)
|
||||
}
|
||||
})
|
||||
}
|
||||
return this.walk((child, i) => {
|
||||
if (child.type === 'decl' && child.prop === prop) {
|
||||
return callback(child, i)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
walkRules(selector, callback) {
|
||||
if (!callback) {
|
||||
callback = selector
|
||||
|
||||
return this.walk((child, i) => {
|
||||
if (child.type === 'rule') {
|
||||
return callback(child, i)
|
||||
}
|
||||
})
|
||||
}
|
||||
if (selector instanceof RegExp) {
|
||||
return this.walk((child, i) => {
|
||||
if (child.type === 'rule' && selector.test(child.selector)) {
|
||||
return callback(child, i)
|
||||
}
|
||||
})
|
||||
}
|
||||
return this.walk((child, i) => {
|
||||
if (child.type === 'rule' && child.selector === selector) {
|
||||
return callback(child, i)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Container.registerParse = dependant => {
|
||||
parse = dependant
|
||||
}
|
||||
|
||||
Container.registerRule = dependant => {
|
||||
Rule = dependant
|
||||
}
|
||||
|
||||
Container.registerAtRule = dependant => {
|
||||
AtRule = dependant
|
||||
}
|
||||
|
||||
Container.registerRoot = dependant => {
|
||||
Root = dependant
|
||||
}
|
||||
|
||||
module.exports = Container
|
||||
Container.default = Container
|
||||
|
||||
/* c8 ignore start */
|
||||
Container.rebuild = node => {
|
||||
if (node.type === 'atrule') {
|
||||
Object.setPrototypeOf(node, AtRule.prototype)
|
||||
} else if (node.type === 'rule') {
|
||||
Object.setPrototypeOf(node, Rule.prototype)
|
||||
} else if (node.type === 'decl') {
|
||||
Object.setPrototypeOf(node, Declaration.prototype)
|
||||
} else if (node.type === 'comment') {
|
||||
Object.setPrototypeOf(node, Comment.prototype)
|
||||
} else if (node.type === 'root') {
|
||||
Object.setPrototypeOf(node, Root.prototype)
|
||||
}
|
||||
|
||||
node[my] = true
|
||||
|
||||
if (node.nodes) {
|
||||
node.nodes.forEach(child => {
|
||||
Container.rebuild(child)
|
||||
})
|
||||
}
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
248
frontend/node_modules/postcss/lib/css-syntax-error.d.ts
generated
vendored
Normal file
248
frontend/node_modules/postcss/lib/css-syntax-error.d.ts
generated
vendored
Normal file
@@ -0,0 +1,248 @@
|
||||
import { FilePosition } from './input.js'
|
||||
|
||||
declare namespace CssSyntaxError {
|
||||
/**
|
||||
* A position that is part of a range.
|
||||
*/
|
||||
export interface RangePosition {
|
||||
/**
|
||||
* The column number in the input.
|
||||
*/
|
||||
column: number
|
||||
|
||||
/**
|
||||
* The line number in the input.
|
||||
*/
|
||||
line: number
|
||||
}
|
||||
|
||||
|
||||
export { CssSyntaxError_ as default }
|
||||
}
|
||||
|
||||
/**
|
||||
* The CSS parser throws this error for broken CSS.
|
||||
*
|
||||
* Custom parsers can throw this error for broken custom syntax using
|
||||
* the `Node#error` method.
|
||||
*
|
||||
* PostCSS will use the input source map to detect the original error location.
|
||||
* If you wrote a Sass file, compiled it to CSS and then parsed it with PostCSS,
|
||||
* PostCSS will show the original position in the Sass file.
|
||||
*
|
||||
* If you need the position in the PostCSS input
|
||||
* (e.g., to debug the previous compiler), use `error.input.file`.
|
||||
*
|
||||
* ```js
|
||||
* // Raising error from plugin
|
||||
* throw node.error('Unknown variable', { plugin: 'postcss-vars' })
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* // Catching and checking syntax error
|
||||
* try {
|
||||
* postcss.parse('a{')
|
||||
* } catch (error) {
|
||||
* if (error.name === 'CssSyntaxError') {
|
||||
* error //=> CssSyntaxError
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
declare class CssSyntaxError_ extends Error {
|
||||
/**
|
||||
* Source column of the error.
|
||||
*
|
||||
* ```js
|
||||
* error.column //=> 1
|
||||
* error.input.column //=> 4
|
||||
* ```
|
||||
*
|
||||
* PostCSS will use the input source map to detect the original location.
|
||||
* If you need the position in the PostCSS input, use `error.input.column`.
|
||||
*/
|
||||
column?: number
|
||||
|
||||
/**
|
||||
* Source column of the error's end, exclusive. Provided if the error pertains
|
||||
* to a range.
|
||||
*
|
||||
* ```js
|
||||
* error.endColumn //=> 1
|
||||
* error.input.endColumn //=> 4
|
||||
* ```
|
||||
*
|
||||
* PostCSS will use the input source map to detect the original location.
|
||||
* If you need the position in the PostCSS input, use `error.input.endColumn`.
|
||||
*/
|
||||
endColumn?: number
|
||||
|
||||
/**
|
||||
* Source line of the error's end, exclusive. Provided if the error pertains
|
||||
* to a range.
|
||||
*
|
||||
* ```js
|
||||
* error.endLine //=> 3
|
||||
* error.input.endLine //=> 4
|
||||
* ```
|
||||
*
|
||||
* PostCSS will use the input source map to detect the original location.
|
||||
* If you need the position in the PostCSS input, use `error.input.endLine`.
|
||||
*/
|
||||
endLine?: number
|
||||
|
||||
/**
|
||||
* Absolute path to the broken file.
|
||||
*
|
||||
* ```js
|
||||
* error.file //=> 'a.sass'
|
||||
* error.input.file //=> 'a.css'
|
||||
* ```
|
||||
*
|
||||
* PostCSS will use the input source map to detect the original location.
|
||||
* If you need the position in the PostCSS input, use `error.input.file`.
|
||||
*/
|
||||
file?: string
|
||||
|
||||
/**
|
||||
* Input object with PostCSS internal information
|
||||
* about input file. If input has source map
|
||||
* from previous tool, PostCSS will use origin
|
||||
* (for example, Sass) source. You can use this
|
||||
* object to get PostCSS input source.
|
||||
*
|
||||
* ```js
|
||||
* error.input.file //=> 'a.css'
|
||||
* error.file //=> 'a.sass'
|
||||
* ```
|
||||
*/
|
||||
input?: FilePosition
|
||||
|
||||
/**
|
||||
* Source line of the error.
|
||||
*
|
||||
* ```js
|
||||
* error.line //=> 2
|
||||
* error.input.line //=> 4
|
||||
* ```
|
||||
*
|
||||
* PostCSS will use the input source map to detect the original location.
|
||||
* If you need the position in the PostCSS input, use `error.input.line`.
|
||||
*/
|
||||
line?: number
|
||||
|
||||
/**
|
||||
* Full error text in the GNU error format
|
||||
* with plugin, file, line and column.
|
||||
*
|
||||
* ```js
|
||||
* error.message //=> 'a.css:1:1: Unclosed block'
|
||||
* ```
|
||||
*/
|
||||
message: string
|
||||
|
||||
/**
|
||||
* Always equal to `'CssSyntaxError'`. You should always check error type
|
||||
* by `error.name === 'CssSyntaxError'`
|
||||
* instead of `error instanceof CssSyntaxError`,
|
||||
* because npm could have several PostCSS versions.
|
||||
*
|
||||
* ```js
|
||||
* if (error.name === 'CssSyntaxError') {
|
||||
* error //=> CssSyntaxError
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
name: 'CssSyntaxError'
|
||||
|
||||
/**
|
||||
* Plugin name, if error came from plugin.
|
||||
*
|
||||
* ```js
|
||||
* error.plugin //=> 'postcss-vars'
|
||||
* ```
|
||||
*/
|
||||
plugin?: string
|
||||
|
||||
/**
|
||||
* Error message.
|
||||
*
|
||||
* ```js
|
||||
* error.message //=> 'Unclosed block'
|
||||
* ```
|
||||
*/
|
||||
reason: string
|
||||
|
||||
/**
|
||||
* Source code of the broken file.
|
||||
*
|
||||
* ```js
|
||||
* error.source //=> 'a { b {} }'
|
||||
* error.input.source //=> 'a b { }'
|
||||
* ```
|
||||
*/
|
||||
source?: string
|
||||
|
||||
stack: string
|
||||
|
||||
/**
|
||||
* Instantiates a CSS syntax error. Can be instantiated for a single position
|
||||
* or for a range.
|
||||
* @param message Error message.
|
||||
* @param lineOrStartPos If for a single position, the line number, or if for
|
||||
* a range, the inclusive start position of the error.
|
||||
* @param columnOrEndPos If for a single position, the column number, or if for
|
||||
* a range, the exclusive end position of the error.
|
||||
* @param source Source code of the broken file.
|
||||
* @param file Absolute path to the broken file.
|
||||
* @param plugin PostCSS plugin name, if error came from plugin.
|
||||
*/
|
||||
constructor(
|
||||
message: string,
|
||||
lineOrStartPos?: CssSyntaxError.RangePosition | number,
|
||||
columnOrEndPos?: CssSyntaxError.RangePosition | number,
|
||||
source?: string,
|
||||
file?: string,
|
||||
plugin?: string
|
||||
)
|
||||
|
||||
/**
|
||||
* Returns a few lines of CSS source that caused the error.
|
||||
*
|
||||
* If the CSS has an input source map without `sourceContent`,
|
||||
* this method will return an empty string.
|
||||
*
|
||||
* ```js
|
||||
* error.showSourceCode() //=> " 4 | }
|
||||
* // 5 | a {
|
||||
* // > 6 | bad
|
||||
* // | ^
|
||||
* // 7 | }
|
||||
* // 8 | b {"
|
||||
* ```
|
||||
*
|
||||
* @param color Whether arrow will be colored red by terminal
|
||||
* color codes. By default, PostCSS will detect
|
||||
* color support by `process.stdout.isTTY`
|
||||
* and `process.env.NODE_DISABLE_COLORS`.
|
||||
* @return Few lines of CSS source that caused the error.
|
||||
*/
|
||||
showSourceCode(color?: boolean): string
|
||||
|
||||
/**
|
||||
* Returns error position, message and source code of the broken part.
|
||||
*
|
||||
* ```js
|
||||
* error.toString() //=> "CssSyntaxError: app.css:1:1: Unclosed block
|
||||
* // > 1 | a {
|
||||
* // | ^"
|
||||
* ```
|
||||
*
|
||||
* @return Error position, message and source code.
|
||||
*/
|
||||
toString(): string
|
||||
}
|
||||
|
||||
declare class CssSyntaxError extends CssSyntaxError_ {}
|
||||
|
||||
export = CssSyntaxError
|
||||
54
frontend/node_modules/postcss/lib/fromJSON.js
generated
vendored
Normal file
54
frontend/node_modules/postcss/lib/fromJSON.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
'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 Root = require('./root')
|
||||
let Rule = require('./rule')
|
||||
|
||||
function fromJSON(json, inputs) {
|
||||
if (Array.isArray(json)) return json.map(n => fromJSON(n))
|
||||
|
||||
let { inputs: ownInputs, ...defaults } = json
|
||||
if (ownInputs) {
|
||||
inputs = []
|
||||
for (let input of ownInputs) {
|
||||
let inputHydrated = { ...input, __proto__: Input.prototype }
|
||||
if (inputHydrated.map) {
|
||||
inputHydrated.map = {
|
||||
...inputHydrated.map,
|
||||
__proto__: PreviousMap.prototype
|
||||
}
|
||||
}
|
||||
inputs.push(inputHydrated)
|
||||
}
|
||||
}
|
||||
if (defaults.nodes) {
|
||||
defaults.nodes = json.nodes.map(n => fromJSON(n, inputs))
|
||||
}
|
||||
if (defaults.source) {
|
||||
let { inputId, ...source } = defaults.source
|
||||
defaults.source = source
|
||||
if (inputId != null) {
|
||||
defaults.source.input = inputs[inputId]
|
||||
}
|
||||
}
|
||||
if (defaults.type === 'root') {
|
||||
return new Root(defaults)
|
||||
} else if (defaults.type === 'decl') {
|
||||
return new Declaration(defaults)
|
||||
} else if (defaults.type === 'rule') {
|
||||
return new Rule(defaults)
|
||||
} else if (defaults.type === 'comment') {
|
||||
return new Comment(defaults)
|
||||
} else if (defaults.type === 'atrule') {
|
||||
return new AtRule(defaults)
|
||||
} else {
|
||||
throw new Error('Unknown node type: ' + json.type)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = fromJSON
|
||||
fromJSON.default = fromJSON
|
||||
190
frontend/node_modules/postcss/lib/lazy-result.d.ts
generated
vendored
Normal file
190
frontend/node_modules/postcss/lib/lazy-result.d.ts
generated
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
import Document from './document.js'
|
||||
import { SourceMap } from './postcss.js'
|
||||
import Processor from './processor.js'
|
||||
import Result, { Message, ResultOptions } from './result.js'
|
||||
import Root from './root.js'
|
||||
import Warning from './warning.js'
|
||||
|
||||
declare namespace LazyResult {
|
||||
|
||||
export { LazyResult_ as default }
|
||||
}
|
||||
|
||||
/**
|
||||
* A Promise proxy for the result of PostCSS transformations.
|
||||
*
|
||||
* A `LazyResult` instance is returned by `Processor#process`.
|
||||
*
|
||||
* ```js
|
||||
* const lazy = postcss([autoprefixer]).process(css)
|
||||
* ```
|
||||
*/
|
||||
declare class LazyResult_<RootNode = Document | Root>
|
||||
implements PromiseLike<Result<RootNode>>
|
||||
{
|
||||
/**
|
||||
* Processes input CSS through synchronous and asynchronous plugins
|
||||
* and calls onRejected for each error thrown in any plugin.
|
||||
*
|
||||
* It implements standard Promise API.
|
||||
*
|
||||
* ```js
|
||||
* postcss([autoprefixer]).process(css).then(result => {
|
||||
* console.log(result.css)
|
||||
* }).catch(error => {
|
||||
* console.error(error)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
catch: Promise<Result<RootNode>>['catch']
|
||||
|
||||
/**
|
||||
* Processes input CSS through synchronous and asynchronous plugins
|
||||
* and calls onFinally on any error or when all plugins will finish work.
|
||||
*
|
||||
* It implements standard Promise API.
|
||||
*
|
||||
* ```js
|
||||
* postcss([autoprefixer]).process(css).finally(() => {
|
||||
* console.log('processing ended')
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
finally: Promise<Result<RootNode>>['finally']
|
||||
|
||||
/**
|
||||
* Processes input CSS through synchronous and asynchronous plugins
|
||||
* and calls `onFulfilled` with a Result instance. If a plugin throws
|
||||
* an error, the `onRejected` callback will be executed.
|
||||
*
|
||||
* It implements standard Promise API.
|
||||
*
|
||||
* ```js
|
||||
* postcss([autoprefixer]).process(css, { from: cssPath }).then(result => {
|
||||
* console.log(result.css)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
then: Promise<Result<RootNode>>['then']
|
||||
|
||||
/**
|
||||
* An alias for the `css` property. Use it with syntaxes
|
||||
* that generate non-CSS output.
|
||||
*
|
||||
* This property will only work with synchronous plugins.
|
||||
* If the processor contains any asynchronous plugins
|
||||
* it will throw an error.
|
||||
*
|
||||
* PostCSS runners should always use `LazyResult#then`.
|
||||
*/
|
||||
get content(): string
|
||||
|
||||
/**
|
||||
* Processes input CSS through synchronous plugins, converts `Root`
|
||||
* to a CSS string and returns `Result#css`.
|
||||
*
|
||||
* This property will only work with synchronous plugins.
|
||||
* If the processor contains any asynchronous plugins
|
||||
* it will throw an error.
|
||||
*
|
||||
* PostCSS runners should always use `LazyResult#then`.
|
||||
*/
|
||||
get css(): string
|
||||
|
||||
/**
|
||||
* Processes input CSS through synchronous plugins
|
||||
* and returns `Result#map`.
|
||||
*
|
||||
* This property will only work with synchronous plugins.
|
||||
* If the processor contains any asynchronous plugins
|
||||
* it will throw an error.
|
||||
*
|
||||
* PostCSS runners should always use `LazyResult#then`.
|
||||
*/
|
||||
get map(): SourceMap
|
||||
|
||||
/**
|
||||
* Processes input CSS through synchronous plugins
|
||||
* and returns `Result#messages`.
|
||||
*
|
||||
* This property will only work with synchronous plugins. If the processor
|
||||
* contains any asynchronous plugins it will throw an error.
|
||||
*
|
||||
* PostCSS runners should always use `LazyResult#then`.
|
||||
*/
|
||||
get messages(): Message[]
|
||||
|
||||
/**
|
||||
* Options from the `Processor#process` call.
|
||||
*/
|
||||
get opts(): ResultOptions
|
||||
|
||||
/**
|
||||
* Returns a `Processor` instance, which will be used
|
||||
* for CSS transformations.
|
||||
*/
|
||||
get processor(): Processor
|
||||
|
||||
/**
|
||||
* Processes input CSS through synchronous plugins
|
||||
* and returns `Result#root`.
|
||||
*
|
||||
* This property will only work with synchronous plugins. If the processor
|
||||
* contains any asynchronous plugins it will throw an error.
|
||||
*
|
||||
* PostCSS runners should always use `LazyResult#then`.
|
||||
*/
|
||||
get root(): RootNode
|
||||
|
||||
/**
|
||||
* Returns the default string description of an object.
|
||||
* 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<
|
||||
RootNode = Document | Root
|
||||
> extends LazyResult_<RootNode> {}
|
||||
|
||||
export = LazyResult
|
||||
60
frontend/node_modules/postcss/lib/list.d.ts
generated
vendored
Normal file
60
frontend/node_modules/postcss/lib/list.d.ts
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
declare namespace list {
|
||||
type List = {
|
||||
/**
|
||||
* Safely splits comma-separated values (such as those for `transition-*`
|
||||
* and `background` properties).
|
||||
*
|
||||
* ```js
|
||||
* Once (root, { list }) {
|
||||
* list.comma('black, linear-gradient(white, black)')
|
||||
* //=> ['black', 'linear-gradient(white, black)']
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @param str Comma-separated values.
|
||||
* @return Split values.
|
||||
*/
|
||||
comma(str: string): string[]
|
||||
|
||||
default: List
|
||||
|
||||
/**
|
||||
* Safely splits space-separated values (such as those for `background`,
|
||||
* `border-radius`, and other shorthand properties).
|
||||
*
|
||||
* ```js
|
||||
* Once (root, { list }) {
|
||||
* list.space('1px calc(10% + 1px)') //=> ['1px', 'calc(10% + 1px)']
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @param str Space-separated values.
|
||||
* @return Split values.
|
||||
*/
|
||||
space(str: string): string[]
|
||||
|
||||
/**
|
||||
* Safely splits values.
|
||||
*
|
||||
* ```js
|
||||
* Once (root, { list }) {
|
||||
* list.split('1px calc(10% + 1px)', [' ', '\n', '\t']) //=> ['1px', 'calc(10% + 1px)']
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @param string separated values.
|
||||
* @param separators array of separators.
|
||||
* @param last boolean indicator.
|
||||
* @return Split values.
|
||||
*/
|
||||
split(
|
||||
string: string,
|
||||
separators: readonly string[],
|
||||
last: boolean
|
||||
): string[]
|
||||
}
|
||||
}
|
||||
|
||||
declare const list: list.List
|
||||
|
||||
export = list
|
||||
46
frontend/node_modules/postcss/lib/no-work-result.d.ts
generated
vendored
Normal file
46
frontend/node_modules/postcss/lib/no-work-result.d.ts
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import LazyResult from './lazy-result.js'
|
||||
import { SourceMap } from './postcss.js'
|
||||
import Processor from './processor.js'
|
||||
import Result, { Message, ResultOptions } from './result.js'
|
||||
import Root from './root.js'
|
||||
import Warning from './warning.js'
|
||||
|
||||
declare namespace NoWorkResult {
|
||||
|
||||
export { NoWorkResult_ as default }
|
||||
}
|
||||
|
||||
/**
|
||||
* A Promise proxy for the result of PostCSS transformations.
|
||||
* This lazy result instance doesn't parse css unless `NoWorkResult#root` or `Result#root`
|
||||
* are accessed. See the example below for details.
|
||||
* A `NoWork` instance is returned by `Processor#process` ONLY when no plugins defined.
|
||||
*
|
||||
* ```js
|
||||
* const noWorkResult = postcss().process(css) // No plugins are defined.
|
||||
* // CSS is not parsed
|
||||
* let root = noWorkResult.root // now css is parsed because we accessed the root
|
||||
* ```
|
||||
*/
|
||||
declare class NoWorkResult_ implements LazyResult<Root> {
|
||||
catch: Promise<Result<Root>>['catch']
|
||||
finally: Promise<Result<Root>>['finally']
|
||||
then: Promise<Result<Root>>['then']
|
||||
get content(): string
|
||||
get css(): string
|
||||
get map(): SourceMap
|
||||
get messages(): Message[]
|
||||
get opts(): ResultOptions
|
||||
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_ {}
|
||||
|
||||
export = NoWorkResult
|
||||
9
frontend/node_modules/postcss/lib/parse.d.ts
generated
vendored
Normal file
9
frontend/node_modules/postcss/lib/parse.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Parser } from './postcss.js'
|
||||
|
||||
interface Parse extends Parser {
|
||||
default: Parse
|
||||
}
|
||||
|
||||
declare const parse: Parse
|
||||
|
||||
export = parse
|
||||
42
frontend/node_modules/postcss/lib/parse.js
generated
vendored
Normal file
42
frontend/node_modules/postcss/lib/parse.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
'use strict'
|
||||
|
||||
let Container = require('./container')
|
||||
let Input = require('./input')
|
||||
let Parser = require('./parser')
|
||||
|
||||
function parse(css, opts) {
|
||||
let input = new Input(css, opts)
|
||||
let parser = new Parser(input)
|
||||
try {
|
||||
parser.parse()
|
||||
} catch (e) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (e.name === 'CssSyntaxError' && opts && opts.from) {
|
||||
if (/\.scss$/i.test(opts.from)) {
|
||||
e.message +=
|
||||
'\nYou tried to parse SCSS with ' +
|
||||
'the standard CSS parser; ' +
|
||||
'try again with the postcss-scss parser'
|
||||
} else if (/\.sass/i.test(opts.from)) {
|
||||
e.message +=
|
||||
'\nYou tried to parse Sass with ' +
|
||||
'the standard CSS parser; ' +
|
||||
'try again with the postcss-sass parser'
|
||||
} else if (/\.less$/i.test(opts.from)) {
|
||||
e.message +=
|
||||
'\nYou tried to parse Less with ' +
|
||||
'the standard CSS parser; ' +
|
||||
'try again with the postcss-less parser'
|
||||
}
|
||||
}
|
||||
}
|
||||
throw e
|
||||
}
|
||||
|
||||
return parser.root
|
||||
}
|
||||
|
||||
module.exports = parse
|
||||
parse.default = parse
|
||||
|
||||
Container.registerParse(parse)
|
||||
30
frontend/node_modules/postcss/lib/postcss.mjs
generated
vendored
Normal file
30
frontend/node_modules/postcss/lib/postcss.mjs
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import postcss from './postcss.js'
|
||||
|
||||
export default postcss
|
||||
|
||||
export const stringify = postcss.stringify
|
||||
export const fromJSON = postcss.fromJSON
|
||||
export const plugin = postcss.plugin
|
||||
export const parse = postcss.parse
|
||||
export const list = postcss.list
|
||||
|
||||
export const document = postcss.document
|
||||
export const comment = postcss.comment
|
||||
export const atRule = postcss.atRule
|
||||
export const rule = postcss.rule
|
||||
export const decl = postcss.decl
|
||||
export const root = postcss.root
|
||||
|
||||
export const CssSyntaxError = postcss.CssSyntaxError
|
||||
export const Declaration = postcss.Declaration
|
||||
export const Container = postcss.Container
|
||||
export const Processor = postcss.Processor
|
||||
export const Document = postcss.Document
|
||||
export const Comment = postcss.Comment
|
||||
export const Warning = postcss.Warning
|
||||
export const AtRule = postcss.AtRule
|
||||
export const Result = postcss.Result
|
||||
export const Input = postcss.Input
|
||||
export const Rule = postcss.Rule
|
||||
export const Root = postcss.Root
|
||||
export const Node = postcss.Node
|
||||
67
frontend/node_modules/postcss/lib/processor.js
generated
vendored
Normal file
67
frontend/node_modules/postcss/lib/processor.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
'use strict'
|
||||
|
||||
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.5.8'
|
||||
this.plugins = this.normalize(plugins)
|
||||
}
|
||||
|
||||
normalize(plugins) {
|
||||
let normalized = []
|
||||
for (let i of plugins) {
|
||||
if (i.postcss === true) {
|
||||
i = i()
|
||||
} else if (i.postcss) {
|
||||
i = i.postcss
|
||||
}
|
||||
|
||||
if (typeof i === 'object' && Array.isArray(i.plugins)) {
|
||||
normalized = normalized.concat(i.plugins)
|
||||
} else if (typeof i === 'object' && i.postcssPlugin) {
|
||||
normalized.push(i)
|
||||
} else if (typeof i === 'function') {
|
||||
normalized.push(i)
|
||||
} else if (typeof i === 'object' && (i.parse || i.stringify)) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
throw new Error(
|
||||
'PostCSS syntaxes cannot be used as plugins. Instead, please use ' +
|
||||
'one of the syntax/parser/stringifier options as outlined ' +
|
||||
'in your PostCSS runner documentation.'
|
||||
)
|
||||
}
|
||||
} else {
|
||||
throw new Error(i + ' is not a PostCSS plugin')
|
||||
}
|
||||
}
|
||||
return normalized
|
||||
}
|
||||
|
||||
process(css, opts = {}) {
|
||||
if (
|
||||
!this.plugins.length &&
|
||||
!opts.parser &&
|
||||
!opts.stringifier &&
|
||||
!opts.syntax
|
||||
) {
|
||||
return new NoWorkResult(this, css, opts)
|
||||
} else {
|
||||
return new LazyResult(this, css, opts)
|
||||
}
|
||||
}
|
||||
|
||||
use(plugin) {
|
||||
this.plugins = this.plugins.concat(this.normalize([plugin]))
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Processor
|
||||
Processor.default = Processor
|
||||
|
||||
Root.registerProcessor(Processor)
|
||||
Document.registerProcessor(Processor)
|
||||
205
frontend/node_modules/postcss/lib/result.d.ts
generated
vendored
Normal file
205
frontend/node_modules/postcss/lib/result.d.ts
generated
vendored
Normal file
@@ -0,0 +1,205 @@
|
||||
import {
|
||||
Document,
|
||||
Node,
|
||||
Plugin,
|
||||
ProcessOptions,
|
||||
Root,
|
||||
SourceMap,
|
||||
TransformCallback,
|
||||
Warning,
|
||||
WarningOptions
|
||||
} from './postcss.js'
|
||||
import Processor from './processor.js'
|
||||
|
||||
declare namespace Result {
|
||||
export interface Message {
|
||||
[others: string]: any
|
||||
|
||||
/**
|
||||
* Source PostCSS plugin name.
|
||||
*/
|
||||
plugin?: string
|
||||
|
||||
/**
|
||||
* Message type.
|
||||
*/
|
||||
type: string
|
||||
}
|
||||
|
||||
export interface ResultOptions extends ProcessOptions {
|
||||
/**
|
||||
* The CSS node that was the source of the warning.
|
||||
*/
|
||||
node?: Node
|
||||
|
||||
/**
|
||||
* Name of plugin that created this warning. `Result#warn` will fill it
|
||||
* automatically with `Plugin#postcssPlugin` value.
|
||||
*/
|
||||
plugin?: string
|
||||
}
|
||||
|
||||
|
||||
export { Result_ as default }
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the result of the PostCSS transformations.
|
||||
*
|
||||
* A Result instance is returned by `LazyResult#then`
|
||||
* or `Root#toResult` methods.
|
||||
*
|
||||
* ```js
|
||||
* postcss([autoprefixer]).process(css).then(result => {
|
||||
* console.log(result.css)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* const result2 = postcss.parse(css).toResult()
|
||||
* ```
|
||||
*/
|
||||
declare class Result_<RootNode = Document | Root> {
|
||||
/**
|
||||
* A CSS string representing of `Result#root`.
|
||||
*
|
||||
* ```js
|
||||
* postcss.parse('a{}').toResult().css //=> "a{}"
|
||||
* ```
|
||||
*/
|
||||
css: string
|
||||
|
||||
/**
|
||||
* Last runned PostCSS plugin.
|
||||
*/
|
||||
lastPlugin: Plugin | TransformCallback
|
||||
|
||||
/**
|
||||
* An instance of `SourceMapGenerator` class from the `source-map` library,
|
||||
* representing changes to the `Result#root` instance.
|
||||
*
|
||||
* ```js
|
||||
* result.map.toJSON() //=> { version: 3, file: 'a.css', … }
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* if (result.map) {
|
||||
* fs.writeFileSync(result.opts.to + '.map', result.map.toString())
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
map: SourceMap
|
||||
|
||||
/**
|
||||
* Contains messages from plugins (e.g., warnings or custom messages).
|
||||
* Each message should have type and plugin properties.
|
||||
*
|
||||
* ```js
|
||||
* AtRule: {
|
||||
* import: (atRule, { result }) {
|
||||
* const importedFile = parseImport(atRule)
|
||||
* result.messages.push({
|
||||
* type: 'dependency',
|
||||
* plugin: 'postcss-import',
|
||||
* file: importedFile,
|
||||
* parent: result.opts.from
|
||||
* })
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
messages: Result.Message[]
|
||||
|
||||
/**
|
||||
* Options from the `Processor#process` or `Root#toResult` call
|
||||
* that produced this Result instance.]
|
||||
*
|
||||
* ```js
|
||||
* root.toResult(opts).opts === opts
|
||||
* ```
|
||||
*/
|
||||
opts: Result.ResultOptions
|
||||
|
||||
/**
|
||||
* The Processor instance used for this transformation.
|
||||
*
|
||||
* ```js
|
||||
* for (const plugin of result.processor.plugins) {
|
||||
* if (plugin.postcssPlugin === 'postcss-bad') {
|
||||
* throw 'postcss-good is incompatible with postcss-bad'
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
processor: Processor
|
||||
|
||||
/**
|
||||
* Root node after all transformations.
|
||||
*
|
||||
* ```js
|
||||
* root.toResult().root === 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.
|
||||
* @param opts Options from the `Processor#process` or `Root#toResult`.
|
||||
*/
|
||||
constructor(processor: Processor, root: RootNode, opts: Result.ResultOptions)
|
||||
|
||||
/**
|
||||
* Returns for `Result#css` content.
|
||||
*
|
||||
* ```js
|
||||
* result + '' === result.css
|
||||
* ```
|
||||
*
|
||||
* @return String representing of `Result#root`.
|
||||
*/
|
||||
toString(): string
|
||||
|
||||
/**
|
||||
* Creates an instance of `Warning` and adds it to `Result#messages`.
|
||||
*
|
||||
* ```js
|
||||
* if (decl.important) {
|
||||
* result.warn('Avoid !important', { node: decl, word: '!important' })
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @param text Warning message.
|
||||
* @param opts Warning options.
|
||||
* @return Created warning.
|
||||
*/
|
||||
warn(message: string, options?: WarningOptions): Warning
|
||||
|
||||
/**
|
||||
* Returns warnings from plugins. Filters `Warning` instances
|
||||
* from `Result#messages`.
|
||||
*
|
||||
* ```js
|
||||
* result.warnings().forEach(warn => {
|
||||
* console.warn(warn.toString())
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* @return Warnings from plugins.
|
||||
*/
|
||||
warnings(): Warning[]
|
||||
}
|
||||
|
||||
declare class Result<RootNode = Document | Root> extends Result_<RootNode> {}
|
||||
|
||||
export = Result
|
||||
42
frontend/node_modules/postcss/lib/result.js
generated
vendored
Normal file
42
frontend/node_modules/postcss/lib/result.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
'use strict'
|
||||
|
||||
let Warning = require('./warning')
|
||||
|
||||
class Result {
|
||||
get content() {
|
||||
return this.css
|
||||
}
|
||||
|
||||
constructor(processor, root, opts) {
|
||||
this.processor = processor
|
||||
this.messages = []
|
||||
this.root = root
|
||||
this.opts = opts
|
||||
this.css = ''
|
||||
this.map = undefined
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.css
|
||||
}
|
||||
|
||||
warn(text, opts = {}) {
|
||||
if (!opts.plugin) {
|
||||
if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
|
||||
opts.plugin = this.lastPlugin.postcssPlugin
|
||||
}
|
||||
}
|
||||
|
||||
let warning = new Warning(text, opts)
|
||||
this.messages.push(warning)
|
||||
|
||||
return warning
|
||||
}
|
||||
|
||||
warnings() {
|
||||
return this.messages.filter(i => i.type === 'warning')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Result
|
||||
Result.default = Result
|
||||
87
frontend/node_modules/postcss/lib/root.d.ts
generated
vendored
Normal file
87
frontend/node_modules/postcss/lib/root.d.ts
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
import Container, { ContainerProps } from './container.js'
|
||||
import Document from './document.js'
|
||||
import { ProcessOptions } from './postcss.js'
|
||||
import Result from './result.js'
|
||||
|
||||
declare namespace Root {
|
||||
export interface RootRaws extends Record<string, any> {
|
||||
/**
|
||||
* The space symbols after the last child to the end of file.
|
||||
*/
|
||||
after?: string
|
||||
|
||||
/**
|
||||
* Non-CSS code after `Root`, when `Root` is inside `Document`.
|
||||
*
|
||||
* **Experimental:** some aspects of this node could change within minor
|
||||
* or patch version releases.
|
||||
*/
|
||||
codeAfter?: string
|
||||
|
||||
/**
|
||||
* Non-CSS code before `Root`, when `Root` is inside `Document`.
|
||||
*
|
||||
* **Experimental:** some aspects of this node could change within minor
|
||||
* or patch version releases.
|
||||
*/
|
||||
codeBefore?: string
|
||||
|
||||
/**
|
||||
* Is the last child has an (optional) semicolon.
|
||||
*/
|
||||
semicolon?: boolean
|
||||
}
|
||||
|
||||
export interface RootProps extends ContainerProps {
|
||||
/**
|
||||
* Information used to generate byte-to-byte equal node string
|
||||
* as it was in the origin input.
|
||||
* */
|
||||
raws?: RootRaws
|
||||
}
|
||||
|
||||
|
||||
export { Root_ as default }
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a CSS file and contains all its parsed nodes.
|
||||
*
|
||||
* ```js
|
||||
* const root = postcss.parse('a{color:black} b{z-index:2}')
|
||||
* root.type //=> 'root'
|
||||
* root.nodes.length //=> 2
|
||||
* ```
|
||||
*/
|
||||
declare class Root_ extends Container {
|
||||
nodes: NonNullable<Container['nodes']>
|
||||
parent: Document | undefined
|
||||
raws: Root.RootRaws
|
||||
type: 'root'
|
||||
|
||||
constructor(defaults?: Root.RootProps)
|
||||
|
||||
assign(overrides: object | Root.RootProps): this
|
||||
clone(overrides?: Partial<Root.RootProps>): this
|
||||
cloneAfter(overrides?: Partial<Root.RootProps>): this
|
||||
cloneBefore(overrides?: Partial<Root.RootProps>): this
|
||||
|
||||
/**
|
||||
* Returns a `Result` instance representing the root’s CSS.
|
||||
*
|
||||
* ```js
|
||||
* const root1 = postcss.parse(css1, { from: 'a.css' })
|
||||
* const root2 = postcss.parse(css2, { from: 'b.css' })
|
||||
* root1.append(root2)
|
||||
* const result = root1.toResult({ to: 'all.css', map: true })
|
||||
* ```
|
||||
*
|
||||
* @param options Options.
|
||||
* @return Result with current root’s CSS.
|
||||
*/
|
||||
toResult(options?: ProcessOptions): Result
|
||||
}
|
||||
|
||||
declare class Root extends Root_ {}
|
||||
|
||||
export = Root
|
||||
61
frontend/node_modules/postcss/lib/root.js
generated
vendored
Normal file
61
frontend/node_modules/postcss/lib/root.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
'use strict'
|
||||
|
||||
let Container = require('./container')
|
||||
|
||||
let LazyResult, Processor
|
||||
|
||||
class Root extends Container {
|
||||
constructor(defaults) {
|
||||
super(defaults)
|
||||
this.type = 'root'
|
||||
if (!this.nodes) this.nodes = []
|
||||
}
|
||||
|
||||
normalize(child, sample, type) {
|
||||
let nodes = super.normalize(child)
|
||||
|
||||
if (sample) {
|
||||
if (type === 'prepend') {
|
||||
if (this.nodes.length > 1) {
|
||||
sample.raws.before = this.nodes[1].raws.before
|
||||
} else {
|
||||
delete sample.raws.before
|
||||
}
|
||||
} else if (this.first !== sample) {
|
||||
for (let node of nodes) {
|
||||
node.raws.before = sample.raws.before
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nodes
|
||||
}
|
||||
|
||||
removeChild(child, ignore) {
|
||||
let index = this.index(child)
|
||||
|
||||
if (!ignore && index === 0 && this.nodes.length > 1) {
|
||||
this.nodes[1].raws.before = this.nodes[index].raws.before
|
||||
}
|
||||
|
||||
return super.removeChild(child)
|
||||
}
|
||||
|
||||
toResult(opts = {}) {
|
||||
let lazy = new LazyResult(new Processor(), this, opts)
|
||||
return lazy.stringify()
|
||||
}
|
||||
}
|
||||
|
||||
Root.registerLazyResult = dependant => {
|
||||
LazyResult = dependant
|
||||
}
|
||||
|
||||
Root.registerProcessor = dependant => {
|
||||
Processor = dependant
|
||||
}
|
||||
|
||||
module.exports = Root
|
||||
Root.default = Root
|
||||
|
||||
Container.registerRoot(Root)
|
||||
353
frontend/node_modules/postcss/lib/stringifier.js
generated
vendored
Normal file
353
frontend/node_modules/postcss/lib/stringifier.js
generated
vendored
Normal file
@@ -0,0 +1,353 @@
|
||||
'use strict'
|
||||
|
||||
const DEFAULT_RAW = {
|
||||
after: '\n',
|
||||
beforeClose: '\n',
|
||||
beforeComment: '\n',
|
||||
beforeDecl: '\n',
|
||||
beforeOpen: ' ',
|
||||
beforeRule: '\n',
|
||||
colon: ': ',
|
||||
commentLeft: ' ',
|
||||
commentRight: ' ',
|
||||
emptyBody: '',
|
||||
indent: ' ',
|
||||
semicolon: false
|
||||
}
|
||||
|
||||
function capitalize(str) {
|
||||
return str[0].toUpperCase() + str.slice(1)
|
||||
}
|
||||
|
||||
class Stringifier {
|
||||
constructor(builder) {
|
||||
this.builder = builder
|
||||
}
|
||||
|
||||
atrule(node, semicolon) {
|
||||
let name = '@' + node.name
|
||||
let params = node.params ? this.rawValue(node, 'params') : ''
|
||||
|
||||
if (typeof node.raws.afterName !== 'undefined') {
|
||||
name += node.raws.afterName
|
||||
} else if (params) {
|
||||
name += ' '
|
||||
}
|
||||
|
||||
if (node.nodes) {
|
||||
this.block(node, name + params)
|
||||
} else {
|
||||
let end = (node.raws.between || '') + (semicolon ? ';' : '')
|
||||
this.builder(name + params + end, node)
|
||||
}
|
||||
}
|
||||
|
||||
beforeAfter(node, detect) {
|
||||
let value
|
||||
if (node.type === 'decl') {
|
||||
value = this.raw(node, null, 'beforeDecl')
|
||||
} else if (node.type === 'comment') {
|
||||
value = this.raw(node, null, 'beforeComment')
|
||||
} else if (detect === 'before') {
|
||||
value = this.raw(node, null, 'beforeRule')
|
||||
} else {
|
||||
value = this.raw(node, null, 'beforeClose')
|
||||
}
|
||||
|
||||
let buf = node.parent
|
||||
let depth = 0
|
||||
while (buf && buf.type !== 'root') {
|
||||
depth += 1
|
||||
buf = buf.parent
|
||||
}
|
||||
|
||||
if (value.includes('\n')) {
|
||||
let indent = this.raw(node, null, 'indent')
|
||||
if (indent.length) {
|
||||
for (let step = 0; step < depth; step++) value += indent
|
||||
}
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
block(node, start) {
|
||||
let between = this.raw(node, 'between', 'beforeOpen')
|
||||
this.builder(start + between + '{', node, 'start')
|
||||
|
||||
let after
|
||||
if (node.nodes && node.nodes.length) {
|
||||
this.body(node)
|
||||
after = this.raw(node, 'after')
|
||||
} else {
|
||||
after = this.raw(node, 'after', 'emptyBody')
|
||||
}
|
||||
|
||||
if (after) this.builder(after)
|
||||
this.builder('}', node, 'end')
|
||||
}
|
||||
|
||||
body(node) {
|
||||
let last = node.nodes.length - 1
|
||||
while (last > 0) {
|
||||
if (node.nodes[last].type !== 'comment') break
|
||||
last -= 1
|
||||
}
|
||||
|
||||
let semicolon = this.raw(node, 'semicolon')
|
||||
for (let i = 0; i < node.nodes.length; i++) {
|
||||
let child = node.nodes[i]
|
||||
let before = this.raw(child, 'before')
|
||||
if (before) this.builder(before)
|
||||
this.stringify(child, last !== i || semicolon)
|
||||
}
|
||||
}
|
||||
|
||||
comment(node) {
|
||||
let left = this.raw(node, 'left', 'commentLeft')
|
||||
let right = this.raw(node, 'right', 'commentRight')
|
||||
this.builder('/*' + left + node.text + right + '*/', node)
|
||||
}
|
||||
|
||||
decl(node, semicolon) {
|
||||
let between = this.raw(node, 'between', 'colon')
|
||||
let string = node.prop + between + this.rawValue(node, 'value')
|
||||
|
||||
if (node.important) {
|
||||
string += node.raws.important || ' !important'
|
||||
}
|
||||
|
||||
if (semicolon) string += ';'
|
||||
this.builder(string, node)
|
||||
}
|
||||
|
||||
document(node) {
|
||||
this.body(node)
|
||||
}
|
||||
|
||||
raw(node, own, detect) {
|
||||
let value
|
||||
if (!detect) detect = own
|
||||
|
||||
// Already had
|
||||
if (own) {
|
||||
value = node.raws[own]
|
||||
if (typeof value !== 'undefined') return value
|
||||
}
|
||||
|
||||
let parent = node.parent
|
||||
|
||||
if (detect === 'before') {
|
||||
// Hack for first rule in CSS
|
||||
if (!parent || (parent.type === 'root' && parent.first === node)) {
|
||||
return ''
|
||||
}
|
||||
|
||||
// `root` nodes in `document` should use only their own raws
|
||||
if (parent && parent.type === 'document') {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
// Floating child without parent
|
||||
if (!parent) return DEFAULT_RAW[detect]
|
||||
|
||||
// Detect style by other nodes
|
||||
let root = node.root()
|
||||
if (!root.rawCache) root.rawCache = {}
|
||||
if (typeof root.rawCache[detect] !== 'undefined') {
|
||||
return root.rawCache[detect]
|
||||
}
|
||||
|
||||
if (detect === 'before' || detect === 'after') {
|
||||
return this.beforeAfter(node, detect)
|
||||
} else {
|
||||
let method = 'raw' + capitalize(detect)
|
||||
if (this[method]) {
|
||||
value = this[method](root, node)
|
||||
} else {
|
||||
root.walk(i => {
|
||||
value = i.raws[own]
|
||||
if (typeof value !== 'undefined') return false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof value === 'undefined') value = DEFAULT_RAW[detect]
|
||||
|
||||
root.rawCache[detect] = value
|
||||
return value
|
||||
}
|
||||
|
||||
rawBeforeClose(root) {
|
||||
let value
|
||||
root.walk(i => {
|
||||
if (i.nodes && i.nodes.length > 0) {
|
||||
if (typeof i.raws.after !== 'undefined') {
|
||||
value = i.raws.after
|
||||
if (value.includes('\n')) {
|
||||
value = value.replace(/[^\n]+$/, '')
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
})
|
||||
if (value) value = value.replace(/\S/g, '')
|
||||
return value
|
||||
}
|
||||
|
||||
rawBeforeComment(root, node) {
|
||||
let value
|
||||
root.walkComments(i => {
|
||||
if (typeof i.raws.before !== 'undefined') {
|
||||
value = i.raws.before
|
||||
if (value.includes('\n')) {
|
||||
value = value.replace(/[^\n]+$/, '')
|
||||
}
|
||||
return false
|
||||
}
|
||||
})
|
||||
if (typeof value === 'undefined') {
|
||||
value = this.raw(node, null, 'beforeDecl')
|
||||
} else if (value) {
|
||||
value = value.replace(/\S/g, '')
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
rawBeforeDecl(root, node) {
|
||||
let value
|
||||
root.walkDecls(i => {
|
||||
if (typeof i.raws.before !== 'undefined') {
|
||||
value = i.raws.before
|
||||
if (value.includes('\n')) {
|
||||
value = value.replace(/[^\n]+$/, '')
|
||||
}
|
||||
return false
|
||||
}
|
||||
})
|
||||
if (typeof value === 'undefined') {
|
||||
value = this.raw(node, null, 'beforeRule')
|
||||
} else if (value) {
|
||||
value = value.replace(/\S/g, '')
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
rawBeforeOpen(root) {
|
||||
let value
|
||||
root.walk(i => {
|
||||
if (i.type !== 'decl') {
|
||||
value = i.raws.between
|
||||
if (typeof value !== 'undefined') return false
|
||||
}
|
||||
})
|
||||
return value
|
||||
}
|
||||
|
||||
rawBeforeRule(root) {
|
||||
let value
|
||||
root.walk(i => {
|
||||
if (i.nodes && (i.parent !== root || root.first !== i)) {
|
||||
if (typeof i.raws.before !== 'undefined') {
|
||||
value = i.raws.before
|
||||
if (value.includes('\n')) {
|
||||
value = value.replace(/[^\n]+$/, '')
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
})
|
||||
if (value) value = value.replace(/\S/g, '')
|
||||
return value
|
||||
}
|
||||
|
||||
rawColon(root) {
|
||||
let value
|
||||
root.walkDecls(i => {
|
||||
if (typeof i.raws.between !== 'undefined') {
|
||||
value = i.raws.between.replace(/[^\s:]/g, '')
|
||||
return false
|
||||
}
|
||||
})
|
||||
return value
|
||||
}
|
||||
|
||||
rawEmptyBody(root) {
|
||||
let value
|
||||
root.walk(i => {
|
||||
if (i.nodes && i.nodes.length === 0) {
|
||||
value = i.raws.after
|
||||
if (typeof value !== 'undefined') return false
|
||||
}
|
||||
})
|
||||
return value
|
||||
}
|
||||
|
||||
rawIndent(root) {
|
||||
if (root.raws.indent) return root.raws.indent
|
||||
let value
|
||||
root.walk(i => {
|
||||
let p = i.parent
|
||||
if (p && p !== root && p.parent && p.parent === root) {
|
||||
if (typeof i.raws.before !== 'undefined') {
|
||||
let parts = i.raws.before.split('\n')
|
||||
value = parts[parts.length - 1]
|
||||
value = value.replace(/\S/g, '')
|
||||
return false
|
||||
}
|
||||
}
|
||||
})
|
||||
return value
|
||||
}
|
||||
|
||||
rawSemicolon(root) {
|
||||
let value
|
||||
root.walk(i => {
|
||||
if (i.nodes && i.nodes.length && i.last.type === 'decl') {
|
||||
value = i.raws.semicolon
|
||||
if (typeof value !== 'undefined') return false
|
||||
}
|
||||
})
|
||||
return value
|
||||
}
|
||||
|
||||
rawValue(node, prop) {
|
||||
let value = node[prop]
|
||||
let raw = node.raws[prop]
|
||||
if (raw && raw.value === value) {
|
||||
return raw.raw
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
root(node) {
|
||||
this.body(node)
|
||||
if (node.raws.after) this.builder(node.raws.after)
|
||||
}
|
||||
|
||||
rule(node) {
|
||||
this.block(node, this.rawValue(node, 'selector'))
|
||||
if (node.raws.ownSemicolon) {
|
||||
this.builder(node.raws.ownSemicolon, node, 'end')
|
||||
}
|
||||
}
|
||||
|
||||
stringify(node, semicolon) {
|
||||
/* c8 ignore start */
|
||||
if (!this[node.type]) {
|
||||
throw new Error(
|
||||
'Unknown AST node type ' +
|
||||
node.type +
|
||||
'. ' +
|
||||
'Maybe you need to change PostCSS stringifier.'
|
||||
)
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
this[node.type](node, semicolon)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Stringifier
|
||||
Stringifier.default = Stringifier
|
||||
37
frontend/node_modules/postcss/lib/warning.js
generated
vendored
Normal file
37
frontend/node_modules/postcss/lib/warning.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
'use strict'
|
||||
|
||||
class Warning {
|
||||
constructor(text, opts = {}) {
|
||||
this.type = 'warning'
|
||||
this.text = text
|
||||
|
||||
if (opts.node && opts.node.source) {
|
||||
let range = opts.node.rangeBy(opts)
|
||||
this.line = range.start.line
|
||||
this.column = range.start.column
|
||||
this.endLine = range.end.line
|
||||
this.endColumn = range.end.column
|
||||
}
|
||||
|
||||
for (let opt in opts) this[opt] = opts[opt]
|
||||
}
|
||||
|
||||
toString() {
|
||||
if (this.node) {
|
||||
return this.node.error(this.text, {
|
||||
index: this.index,
|
||||
plugin: this.plugin,
|
||||
word: this.word
|
||||
}).message
|
||||
}
|
||||
|
||||
if (this.plugin) {
|
||||
return this.plugin + ': ' + this.text
|
||||
}
|
||||
|
||||
return this.text
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Warning
|
||||
Warning.default = Warning
|
||||
Reference in New Issue
Block a user