first commit

This commit is contained in:
becarta
2025-05-16 00:17:42 +02:00
parent ea5c866137
commit bacf566ec9
6020 changed files with 1715262 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
import getNode from './default.js';
export default {
getNode
};

85
node_modules/css-tree/lib/syntax/scope/default.js generated vendored Normal file
View File

@@ -0,0 +1,85 @@
import {
Ident,
String as StringToken,
Number as NumberToken,
Function as FunctionToken,
Url,
Hash,
Dimension,
Percentage,
LeftParenthesis,
LeftSquareBracket,
Comma,
Delim
} from '../../tokenizer/index.js';
const NUMBERSIGN = 0x0023; // U+0023 NUMBER SIGN (#)
const ASTERISK = 0x002A; // U+002A ASTERISK (*)
const PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
const HYPHENMINUS = 0x002D; // U+002D HYPHEN-MINUS (-)
const SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
const U = 0x0075; // U+0075 LATIN SMALL LETTER U (u)
export default function defaultRecognizer(context) {
switch (this.tokenType) {
case Hash:
return this.Hash();
case Comma:
return this.Operator();
case LeftParenthesis:
return this.Parentheses(this.readSequence, context.recognizer);
case LeftSquareBracket:
return this.Brackets(this.readSequence, context.recognizer);
case StringToken:
return this.String();
case Dimension:
return this.Dimension();
case Percentage:
return this.Percentage();
case NumberToken:
return this.Number();
case FunctionToken:
return this.cmpStr(this.tokenStart, this.tokenEnd, 'url(')
? this.Url()
: this.Function(this.readSequence, context.recognizer);
case Url:
return this.Url();
case Ident:
// check for unicode range, it should start with u+ or U+
if (this.cmpChar(this.tokenStart, U) &&
this.cmpChar(this.tokenStart + 1, PLUSSIGN)) {
return this.UnicodeRange();
} else {
return this.Identifier();
}
case Delim: {
const code = this.charCodeAt(this.tokenStart);
if (code === SOLIDUS ||
code === ASTERISK ||
code === PLUSSIGN ||
code === HYPHENMINUS) {
return this.Operator(); // TODO: replace with Delim
}
// TODO: produce a node with Delim node type
if (code === NUMBERSIGN) {
this.error('Hex or identifier is expected', this.tokenStart + 1);
}
break;
}
}
};

3
node_modules/css-tree/lib/syntax/scope/index.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export { default as AtrulePrelude } from './atrulePrelude.js';
export { default as Selector } from './selector.js';
export { default as Value } from './value.js';

94
node_modules/css-tree/lib/syntax/scope/selector.js generated vendored Normal file
View File

@@ -0,0 +1,94 @@
import {
Delim,
Ident,
Dimension,
Percentage,
Number as NumberToken,
Hash,
Colon,
LeftSquareBracket
} from '../../tokenizer/index.js';
const NUMBERSIGN = 0x0023; // U+0023 NUMBER SIGN (#)
const AMPERSAND = 0x0026; // U+0026 AMPERSAND (&)
const ASTERISK = 0x002A; // U+002A ASTERISK (*)
const PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
const SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
const FULLSTOP = 0x002E; // U+002E FULL STOP (.)
const GREATERTHANSIGN = 0x003E; // U+003E GREATER-THAN SIGN (>)
const VERTICALLINE = 0x007C; // U+007C VERTICAL LINE (|)
const TILDE = 0x007E; // U+007E TILDE (~)
function onWhiteSpace(next, children) {
if (children.last !== null && children.last.type !== 'Combinator' &&
next !== null && next.type !== 'Combinator') {
children.push({ // FIXME: this.Combinator() should be used instead
type: 'Combinator',
loc: null,
name: ' '
});
}
}
function getNode() {
switch (this.tokenType) {
case LeftSquareBracket:
return this.AttributeSelector();
case Hash:
return this.IdSelector();
case Colon:
if (this.lookupType(1) === Colon) {
return this.PseudoElementSelector();
} else {
return this.PseudoClassSelector();
}
case Ident:
return this.TypeSelector();
case NumberToken:
case Percentage:
return this.Percentage();
case Dimension:
// throws when .123ident
if (this.charCodeAt(this.tokenStart) === FULLSTOP) {
this.error('Identifier is expected', this.tokenStart + 1);
}
break;
case Delim: {
const code = this.charCodeAt(this.tokenStart);
switch (code) {
case PLUSSIGN:
case GREATERTHANSIGN:
case TILDE:
case SOLIDUS: // /deep/
return this.Combinator();
case FULLSTOP:
return this.ClassSelector();
case ASTERISK:
case VERTICALLINE:
return this.TypeSelector();
case NUMBERSIGN:
return this.IdSelector();
case AMPERSAND:
return this.NestingSelector();
}
break;
}
}
};
export default {
onWhiteSpace,
getNode
};

25
node_modules/css-tree/lib/syntax/scope/value.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
import getNode from './default.js';
import expressionFn from '../function/expression.js';
import varFn from '../function/var.js';
function isPlusMinusOperator(node) {
return (
node !== null &&
node.type === 'Operator' &&
(node.value[node.value.length - 1] === '-' || node.value[node.value.length - 1] === '+')
);
}
export default {
getNode,
onWhiteSpace(next, children) {
if (isPlusMinusOperator(next)) {
next.value = ' ' + next.value;
}
if (isPlusMinusOperator(children.last)) {
children.last.value += ' ';
}
},
'expression': expressionFn,
'var': varFn
};