summaryrefslogtreecommitdiff
path: root/node_modules/css-tree/cjs/parser/SyntaxError.cjs
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2026-05-18 23:10:59 +0800
committerlittleblack111 <littleblack11111@gmail.com>2026-05-18 23:41:44 +0800
commitfc87c009806dcc98867f6b58efe29b042aa01dee (patch)
tree8f59b3f4a5b66e9dfef2d40c8d318e258a521228 /node_modules/css-tree/cjs/parser/SyntaxError.cjs
parent3336b2356ee6152d9c6ae59bd9b87ccbc0958407 (diff)
node: updatemain
Diffstat (limited to 'node_modules/css-tree/cjs/parser/SyntaxError.cjs')
-rw-r--r--node_modules/css-tree/cjs/parser/SyntaxError.cjs69
1 files changed, 0 insertions, 69 deletions
diff --git a/node_modules/css-tree/cjs/parser/SyntaxError.cjs b/node_modules/css-tree/cjs/parser/SyntaxError.cjs
deleted file mode 100644
index 63dd44b5..00000000
--- a/node_modules/css-tree/cjs/parser/SyntaxError.cjs
+++ /dev/null
@@ -1,69 +0,0 @@
-'use strict';
-
-const createCustomError = require('../utils/create-custom-error.cjs');
-
-const MAX_LINE_LENGTH = 100;
-const OFFSET_CORRECTION = 60;
-const TAB_REPLACEMENT = ' ';
-
-function sourceFragment({ source, line, column }, extraLines) {
- function processLines(start, end) {
- return lines
- .slice(start, end)
- .map((line, idx) =>
- String(start + idx + 1).padStart(maxNumLength) + ' |' + line
- ).join('\n');
- }
-
- const lines = source.split(/\r\n?|\n|\f/);
- const startLine = Math.max(1, line - extraLines) - 1;
- const endLine = Math.min(line + extraLines, lines.length + 1);
- const maxNumLength = Math.max(4, String(endLine).length) + 1;
- let cutLeft = 0;
-
- // column correction according to replaced tab before column
- column += (TAB_REPLACEMENT.length - 1) * (lines[line - 1].substr(0, column - 1).match(/\t/g) || []).length;
-
- if (column > MAX_LINE_LENGTH) {
- cutLeft = column - OFFSET_CORRECTION + 3;
- column = OFFSET_CORRECTION - 2;
- }
-
- for (let i = startLine; i <= endLine; i++) {
- if (i >= 0 && i < lines.length) {
- lines[i] = lines[i].replace(/\t/g, TAB_REPLACEMENT);
- lines[i] =
- (cutLeft > 0 && lines[i].length > cutLeft ? '\u2026' : '') +
- lines[i].substr(cutLeft, MAX_LINE_LENGTH - 2) +
- (lines[i].length > cutLeft + MAX_LINE_LENGTH - 1 ? '\u2026' : '');
- }
- }
-
- return [
- processLines(startLine, line),
- new Array(column + maxNumLength + 2).join('-') + '^',
- processLines(line, endLine)
- ].filter(Boolean).join('\n');
-}
-
-function SyntaxError(message, source, offset, line, column) {
- const error = Object.assign(createCustomError.createCustomError('SyntaxError', message), {
- source,
- offset,
- line,
- column,
- sourceFragment(extraLines) {
- return sourceFragment({ source, line, column }, isNaN(extraLines) ? 0 : extraLines);
- },
- get formattedMessage() {
- return (
- `Parse error: ${message}\n` +
- sourceFragment({ source, line, column }, 2)
- );
- }
- });
-
- return error;
-}
-
-exports.SyntaxError = SyntaxError;