Начат фронтенд

This commit is contained in:
Georgiy Syralev
2025-09-16 14:47:30 +03:00
parent f37e85e2e0
commit 40de29041d
2100 changed files with 305701 additions and 11807 deletions

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

@@ -1,39 +1,20 @@
'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 { resolve, isAbsolute } = 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 lineToIndexCache = Symbol('lineToIndexCache')
let fromOffsetCache = Symbol('fromOffsetCache')
let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator)
let pathAvailable = Boolean(resolve && isAbsolute)
function getLineToIndex(input) {
if (input[lineToIndexCache]) return input[lineToIndexCache]
let lines = input.css.split('\n')
let lineToIndex = new Array(lines.length)
let prevIndex = 0
for (let i = 0, l = lines.length; i < l; i++) {
lineToIndex[i] = prevIndex
prevIndex += lines[i].length + 1
}
input[lineToIndexCache] = lineToIndex
return lineToIndex
}
class Input {
get from() {
return this.file || this.id
}
constructor(css, opts = {}) {
if (
css === null ||
@@ -52,9 +33,6 @@ class Input {
this.hasBOM = false
}
this.document = this.css
if (opts.document) this.document = opts.document.toString()
if (opts.from) {
if (
!pathAvailable ||
@@ -82,86 +60,23 @@ class Input {
if (this.map) this.map.file = this.from
}
error(message, line, column, opts = {}) {
let endColumn, endLine, endOffset, offset, result
if (line && typeof line === 'object') {
let start = line
let end = column
if (typeof start.offset === 'number') {
offset = start.offset
let pos = this.fromOffset(offset)
line = pos.line
column = pos.col
} else {
line = start.line
column = start.column
offset = this.fromLineAndColumn(line, column)
}
if (typeof end.offset === 'number') {
endOffset = end.offset
let pos = this.fromOffset(endOffset)
endLine = pos.line
endColumn = pos.col
} else {
endLine = end.line
endColumn = end.column
endOffset = this.fromLineAndColumn(end.line, end.column)
}
} else if (!column) {
offset = line
let pos = this.fromOffset(offset)
line = pos.line
column = pos.col
} else {
offset = this.fromLineAndColumn(line, column)
}
let origin = this.origin(line, column, endLine, endColumn)
if (origin) {
result = new CssSyntaxError(
message,
origin.endLine === undefined
? origin.line
: { column: origin.column, line: origin.line },
origin.endLine === undefined
? origin.column
: { column: origin.endColumn, line: origin.endLine },
origin.source,
origin.file,
opts.plugin
)
} else {
result = new CssSyntaxError(
message,
endLine === undefined ? line : { column, line },
endLine === undefined ? column : { column: endColumn, line: endLine },
this.css,
this.file,
opts.plugin
)
}
result.input = { column, endColumn, endLine, endOffset, line, offset, source: this.css }
if (this.file) {
if (pathToFileURL) {
result.input.url = pathToFileURL(this.file).toString()
}
result.input.file = this.file
}
return result
}
fromLineAndColumn(line, column) {
let lineToIndex = getLineToIndex(this)
let index = lineToIndex[line - 1]
return index + column - 1
}
fromOffset(offset) {
let lineToIndex = getLineToIndex(this)
let lastLine = lineToIndex[lineToIndex.length - 1]
let lastLine, lineToIndex
if (!this[fromOffsetCache]) {
let lines = this.css.split('\n')
lineToIndex = new Array(lines.length)
let prevIndex = 0
for (let i = 0, l = lines.length; i < l; i++) {
lineToIndex[i] = prevIndex
prevIndex += lines[i].length + 1
}
this[fromOffsetCache] = lineToIndex
} else {
lineToIndex = this[fromOffsetCache]
}
lastLine = lineToIndex[lineToIndex.length - 1]
let min = 0
if (offset >= lastLine) {
@@ -182,28 +97,85 @@ class Input {
}
}
return {
col: offset - lineToIndex[min] + 1,
line: min + 1
line: min + 1,
col: offset - lineToIndex[min] + 1
}
}
mapResolve(file) {
if (/^\w+:\/\//.test(file)) {
return file
error(message, line, column, opts = {}) {
let result, endLine, endColumn
if (line && typeof line === 'object') {
let start = line
let end = column
if (typeof start.offset === 'number') {
let pos = this.fromOffset(start.offset)
line = pos.line
column = pos.col
} else {
line = start.line
column = start.column
}
if (typeof end.offset === 'number') {
let pos = this.fromOffset(end.offset)
endLine = pos.line
endColumn = pos.col
} else {
endLine = end.line
endColumn = end.column
}
} else if (!column) {
let pos = this.fromOffset(line)
line = pos.line
column = pos.col
}
return resolve(this.map.consumer().sourceRoot || this.map.root || '.', file)
let origin = this.origin(line, column, endLine, endColumn)
if (origin) {
result = new CssSyntaxError(
message,
origin.endLine === undefined
? origin.line
: { line: origin.line, column: origin.column },
origin.endLine === undefined
? origin.column
: { line: origin.endLine, column: origin.endColumn },
origin.source,
origin.file,
opts.plugin
)
} else {
result = new CssSyntaxError(
message,
endLine === undefined ? line : { line, column },
endLine === undefined ? column : { line: endLine, column: endColumn },
this.css,
this.file,
opts.plugin
)
}
result.input = { line, column, endLine, endColumn, source: this.css }
if (this.file) {
if (pathToFileURL) {
result.input.url = pathToFileURL(this.file).toString()
}
result.input.file = this.file
}
return result
}
origin(line, column, endLine, endColumn) {
if (!this.map) return false
let consumer = this.map.consumer()
let from = consumer.originalPositionFor({ column, line })
let from = consumer.originalPositionFor({ line, column })
if (!from.source) return false
let to
if (typeof endLine === 'number') {
to = consumer.originalPositionFor({ column: endColumn, line: endLine })
to = consumer.originalPositionFor({ line: endLine, column: endColumn })
}
let fromUrl
@@ -218,11 +190,11 @@ class Input {
}
let result = {
column: from.column,
endColumn: to && to.column,
endLine: to && to.line,
url: fromUrl.toString(),
line: from.line,
url: fromUrl.toString()
column: from.column,
endLine: to && to.line,
endColumn: to && to.column
}
if (fromUrl.protocol === 'file:') {
@@ -240,6 +212,17 @@ class Input {
return result
}
mapResolve(file) {
if (/^\w+:\/\//.test(file)) {
return file
}
return resolve(this.map.consumer().sourceRoot || this.map.root || '.', file)
}
get from() {
return this.file || this.id
}
toJSON() {
let json = {}
for (let name of ['hasBOM', 'css', 'file', 'id']) {