Fix async lifecycle ordering, add _spa_init boot phase, update to jqhtml _load_only/_load_render_only flags
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2
node_modules/css-tree/LICENSE
generated
vendored
2
node_modules/css-tree/LICENSE
generated
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (C) 2016-2024 by Roman Dvornov
|
||||
Copyright (C) 2016-2026 by Roman Dvornov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
88
node_modules/css-tree/cjs/definition-syntax/parse.cjs
generated
vendored
88
node_modules/css-tree/cjs/definition-syntax/parse.cjs
generated
vendored
@@ -162,6 +162,16 @@ function maybeMultiplied(scanner, node) {
|
||||
return maybeMultiplied(scanner, multiplier);
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-values-4/#component-multipliers
|
||||
// > the # and ? multipliers, {A} and ? multipliers, and {A,B} and ? multipliers
|
||||
// > may be stacked as #?, {A}?, and {A,B}?, respectively
|
||||
// Represent "{}?" as nested multipliers as well as "+#".
|
||||
// The "#?" case is already handled above, in maybeMultiplied()
|
||||
if (scanner.charCode() === QUESTIONMARK &&
|
||||
scanner.charCodeAt(scanner.pos - 1) === RIGHTCURLYBRACKET) {
|
||||
return maybeMultiplied(scanner, multiplier);
|
||||
}
|
||||
|
||||
return multiplier;
|
||||
}
|
||||
|
||||
@@ -378,35 +388,65 @@ function regroupTerms(terms, combinators) {
|
||||
return combinator;
|
||||
}
|
||||
|
||||
function readImplicitGroup(scanner, stopCharCode) {
|
||||
function readImplicitGroup(scanner, stopCharCode = -1) {
|
||||
const combinators = Object.create(null);
|
||||
const terms = [];
|
||||
let token;
|
||||
let prevToken = null;
|
||||
let prevTokenPos = scanner.pos;
|
||||
let prevTokenIsFunction = false;
|
||||
|
||||
while (scanner.charCode() !== stopCharCode && (token = peek(scanner, stopCharCode))) {
|
||||
if (token.type !== 'Spaces') {
|
||||
if (token.type === 'Combinator') {
|
||||
// check for combinator in group beginning and double combinator sequence
|
||||
if (prevToken === null || prevToken.type === 'Combinator') {
|
||||
scanner.pos = prevTokenPos;
|
||||
scanner.error('Unexpected combinator');
|
||||
}
|
||||
while (scanner.charCode() !== stopCharCode) {
|
||||
let token = prevTokenIsFunction
|
||||
? readImplicitGroup(scanner, RIGHTPARENTHESIS)
|
||||
: peek(scanner);
|
||||
|
||||
combinators[token.value] = true;
|
||||
} else if (prevToken !== null && prevToken.type !== 'Combinator') {
|
||||
combinators[' '] = true; // a b
|
||||
terms.push({
|
||||
type: 'Combinator',
|
||||
value: ' '
|
||||
});
|
||||
if (!token) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (token.type === 'Spaces') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (prevTokenIsFunction) {
|
||||
if (token.terms.length === 0) {
|
||||
prevTokenIsFunction = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
terms.push(token);
|
||||
prevToken = token;
|
||||
prevTokenPos = scanner.pos;
|
||||
if (token.combinator === ' ') {
|
||||
while (token.terms.length > 1) {
|
||||
combinators[' '] = true; // a b
|
||||
terms.push({
|
||||
type: 'Combinator',
|
||||
value: ' '
|
||||
}, token.terms.shift());
|
||||
}
|
||||
|
||||
token = token.terms[0];
|
||||
}
|
||||
}
|
||||
|
||||
if (token.type === 'Combinator') {
|
||||
// check for combinator in group beginning and double combinator sequence
|
||||
if (prevToken === null || prevToken.type === 'Combinator') {
|
||||
scanner.pos = prevTokenPos;
|
||||
scanner.error('Unexpected combinator');
|
||||
}
|
||||
|
||||
combinators[token.value] = true;
|
||||
} else if (prevToken !== null && prevToken.type !== 'Combinator') {
|
||||
combinators[' '] = true; // a b
|
||||
terms.push({
|
||||
type: 'Combinator',
|
||||
value: ' '
|
||||
});
|
||||
}
|
||||
|
||||
terms.push(token);
|
||||
prevToken = token;
|
||||
prevTokenPos = scanner.pos;
|
||||
prevTokenIsFunction = token.type === 'Function';
|
||||
}
|
||||
|
||||
// check for combinator in group ending
|
||||
@@ -424,11 +464,11 @@ function readImplicitGroup(scanner, stopCharCode) {
|
||||
};
|
||||
}
|
||||
|
||||
function readGroup(scanner, stopCharCode) {
|
||||
function readGroup(scanner) {
|
||||
let result;
|
||||
|
||||
scanner.eat(LEFTSQUAREBRACKET);
|
||||
result = readImplicitGroup(scanner, stopCharCode);
|
||||
result = readImplicitGroup(scanner, RIGHTSQUAREBRACKET);
|
||||
scanner.eat(RIGHTSQUAREBRACKET);
|
||||
|
||||
result.explicit = true;
|
||||
@@ -441,7 +481,7 @@ function readGroup(scanner, stopCharCode) {
|
||||
return result;
|
||||
}
|
||||
|
||||
function peek(scanner, stopCharCode) {
|
||||
function peek(scanner) {
|
||||
let code = scanner.charCode();
|
||||
|
||||
switch (code) {
|
||||
@@ -450,7 +490,7 @@ function peek(scanner, stopCharCode) {
|
||||
break;
|
||||
|
||||
case LEFTSQUAREBRACKET:
|
||||
return maybeMultiplied(scanner, readGroup(scanner, stopCharCode));
|
||||
return maybeMultiplied(scanner, readGroup(scanner));
|
||||
|
||||
case LESSTHANSIGN:
|
||||
return scanner.nextCharCode() === APOSTROPHE
|
||||
|
||||
59
node_modules/css-tree/cjs/definition-syntax/tokenizer.cjs
generated
vendored
59
node_modules/css-tree/cjs/definition-syntax/tokenizer.cjs
generated
vendored
@@ -1,59 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const SyntaxError = require('./SyntaxError.cjs');
|
||||
|
||||
const TAB = 9;
|
||||
const N = 10;
|
||||
const F = 12;
|
||||
const R = 13;
|
||||
const SPACE = 32;
|
||||
|
||||
class Tokenizer {
|
||||
constructor(str) {
|
||||
this.str = str;
|
||||
this.pos = 0;
|
||||
}
|
||||
charCodeAt(pos) {
|
||||
return pos < this.str.length ? this.str.charCodeAt(pos) : 0;
|
||||
}
|
||||
charCode() {
|
||||
return this.charCodeAt(this.pos);
|
||||
}
|
||||
nextCharCode() {
|
||||
return this.charCodeAt(this.pos + 1);
|
||||
}
|
||||
nextNonWsCode(pos) {
|
||||
return this.charCodeAt(this.findWsEnd(pos));
|
||||
}
|
||||
skipWs() {
|
||||
this.pos = this.findWsEnd(this.pos);
|
||||
}
|
||||
findWsEnd(pos) {
|
||||
for (; pos < this.str.length; pos++) {
|
||||
const code = this.str.charCodeAt(pos);
|
||||
if (code !== R && code !== N && code !== F && code !== SPACE && code !== TAB) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
substringToPos(end) {
|
||||
return this.str.substring(this.pos, this.pos = end);
|
||||
}
|
||||
eat(code) {
|
||||
if (this.charCode() !== code) {
|
||||
this.error('Expect `' + String.fromCharCode(code) + '`');
|
||||
}
|
||||
|
||||
this.pos++;
|
||||
}
|
||||
peek() {
|
||||
return this.pos < this.str.length ? this.str.charAt(this.pos++) : '';
|
||||
}
|
||||
error(message) {
|
||||
throw new SyntaxError.SyntaxError(message, this.str, this.pos);
|
||||
}
|
||||
}
|
||||
|
||||
exports.Tokenizer = Tokenizer;
|
||||
21
node_modules/css-tree/cjs/generator/create.cjs
generated
vendored
21
node_modules/css-tree/cjs/generator/create.cjs
generated
vendored
@@ -26,12 +26,6 @@ function processChildren(node, delimeter) {
|
||||
node.children.forEach(this.node, this);
|
||||
}
|
||||
|
||||
function processChunk(chunk) {
|
||||
index.tokenize(chunk, (type, start, end) => {
|
||||
this.token(type, chunk.slice(start, end));
|
||||
});
|
||||
}
|
||||
|
||||
function createGenerator(config) {
|
||||
const types$1 = new Map();
|
||||
|
||||
@@ -55,9 +49,13 @@ function createGenerator(config) {
|
||||
}
|
||||
},
|
||||
tokenBefore: tokenBefore.safe,
|
||||
token(type, value) {
|
||||
token(type, value, suppressAutoWhiteSpace) {
|
||||
prevCode = this.tokenBefore(prevCode, type, value);
|
||||
|
||||
if (!suppressAutoWhiteSpace && prevCode & 1) {
|
||||
this.emit(' ', types.WhiteSpace, true);
|
||||
}
|
||||
|
||||
this.emit(value, type, false);
|
||||
|
||||
if (type === types.Delim && value.charCodeAt(0) === REVERSESOLIDUS) {
|
||||
@@ -90,7 +88,14 @@ function createGenerator(config) {
|
||||
node: (node) => handlers.node(node),
|
||||
children: processChildren,
|
||||
token: (type, value) => handlers.token(type, value),
|
||||
tokenize: processChunk
|
||||
tokenize: (raw) =>
|
||||
index.tokenize(raw, (type, start, end) => {
|
||||
handlers.token(
|
||||
type,
|
||||
raw.slice(start, end),
|
||||
start !== 0 // suppress auto whitespace for internal value tokens
|
||||
);
|
||||
})
|
||||
};
|
||||
|
||||
handlers.node(node);
|
||||
|
||||
19
node_modules/css-tree/cjs/generator/token-before.cjs
generated
vendored
19
node_modules/css-tree/cjs/generator/token-before.cjs
generated
vendored
@@ -5,17 +5,20 @@ const types = require('../tokenizer/types.cjs');
|
||||
const PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
|
||||
const HYPHENMINUS = 0x002D; // U+002D HYPHEN-MINUS (-)
|
||||
|
||||
// code:
|
||||
// 0xxxxxxx x0000000 - char code (0x80 for non-ASCII) or delim value
|
||||
// 00000000 0xxxxxx0 - token type (0 for delim, 1 for token)
|
||||
// 00000000 0000000x - reserved for carriage emit flag (0 for no space, 1 for space)
|
||||
const code = (type, value) => {
|
||||
if (type === types.Delim) {
|
||||
type = value;
|
||||
}
|
||||
|
||||
if (typeof type === 'string') {
|
||||
const charCode = type.charCodeAt(0);
|
||||
return charCode > 0x7F ? 0x8000 : charCode << 8;
|
||||
type = Math.min(type.charCodeAt(0), 0x80) << 6; // replace non-ASCII with 0x80
|
||||
}
|
||||
|
||||
return type;
|
||||
return type << 1;
|
||||
};
|
||||
|
||||
// https://www.w3.org/TR/css-syntax-3/#serialization
|
||||
@@ -152,14 +155,10 @@ function createMap(pairs) {
|
||||
type !== types.Function &&
|
||||
type !== types.CDC) ||
|
||||
(nextCharCode === PLUSSIGN)
|
||||
? isWhiteSpaceRequired.has(prevCode << 16 | nextCharCode << 8)
|
||||
: isWhiteSpaceRequired.has(prevCode << 16 | nextCode);
|
||||
? isWhiteSpaceRequired.has((prevCode & 0xFFFE) << 16 | nextCharCode << 7)
|
||||
: isWhiteSpaceRequired.has((prevCode & 0xFFFE) << 16 | nextCode);
|
||||
|
||||
if (emitWs) {
|
||||
this.emit(' ', types.WhiteSpace, true);
|
||||
}
|
||||
|
||||
return nextCode;
|
||||
return nextCode | emitWs;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
160
node_modules/css-tree/cjs/lexer/generic.cjs
generated
vendored
160
node_modules/css-tree/cjs/lexer/generic.cjs
generated
vendored
@@ -7,7 +7,91 @@ const charCodeDefinitions = require('../tokenizer/char-code-definitions.cjs');
|
||||
const types = require('../tokenizer/types.cjs');
|
||||
const utils = require('../tokenizer/utils.cjs');
|
||||
|
||||
const calcFunctionNames = ['calc(', '-moz-calc(', '-webkit-calc('];
|
||||
// CSS mathematical functions categorized by return type behavior
|
||||
// See: https://www.w3.org/TR/css-values-4/#math
|
||||
|
||||
// Calculation functions that return different types depending on input
|
||||
const calcFunctionNames = [
|
||||
'calc(',
|
||||
'-moz-calc(',
|
||||
'-webkit-calc('
|
||||
];
|
||||
|
||||
// Comparison functions that return different types depending on input
|
||||
const comparisonFunctionNames = [
|
||||
'min(',
|
||||
'max(',
|
||||
'clamp('
|
||||
];
|
||||
|
||||
// Functions that return a stepped value, i.e. a value that is rounded to the nearest step
|
||||
const steppedValueFunctionNames = [
|
||||
'round(',
|
||||
'mod(',
|
||||
'rem('
|
||||
];
|
||||
|
||||
// Trigonometrical functions that return a <number>
|
||||
const trigNumberFunctionNames = [
|
||||
'sin(',
|
||||
'cos(',
|
||||
'tan('
|
||||
];
|
||||
|
||||
// Trigonometrical functions that return a <angle>
|
||||
const trigAngleFunctionNames = [
|
||||
'asin(',
|
||||
'acos(',
|
||||
'atan(',
|
||||
'atan2('
|
||||
];
|
||||
|
||||
// Other functions that return a <number>
|
||||
const otherNumberFunctionNames = [
|
||||
'pow(',
|
||||
'sqrt(',
|
||||
'log(',
|
||||
'exp(',
|
||||
'sign('
|
||||
];
|
||||
|
||||
// Exponential functions that return a <number> or <dimension> or <percentage>
|
||||
const expNumberDimensionPercentageFunctionNames = [
|
||||
'hypot('
|
||||
];
|
||||
|
||||
// Return the same type as the input
|
||||
const signFunctionNames = [
|
||||
'abs('
|
||||
];
|
||||
|
||||
const numberFunctionNames = [
|
||||
...calcFunctionNames,
|
||||
...comparisonFunctionNames,
|
||||
...steppedValueFunctionNames,
|
||||
...trigNumberFunctionNames,
|
||||
...otherNumberFunctionNames,
|
||||
...expNumberDimensionPercentageFunctionNames,
|
||||
...signFunctionNames
|
||||
];
|
||||
|
||||
const percentageFunctionNames = [
|
||||
...calcFunctionNames,
|
||||
...comparisonFunctionNames,
|
||||
...steppedValueFunctionNames,
|
||||
...expNumberDimensionPercentageFunctionNames,
|
||||
...signFunctionNames
|
||||
];
|
||||
|
||||
const dimensionFunctionNames = [
|
||||
...calcFunctionNames,
|
||||
...comparisonFunctionNames,
|
||||
...steppedValueFunctionNames,
|
||||
...trigAngleFunctionNames,
|
||||
...expNumberDimensionPercentageFunctionNames,
|
||||
...signFunctionNames
|
||||
];
|
||||
|
||||
const balancePair = new Map([
|
||||
[types.Function, types.RightParenthesis],
|
||||
[types.LeftParenthesis, types.RightParenthesis],
|
||||
@@ -114,16 +198,17 @@ function consumeFunction(token, getNextToken) {
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
// TODO: implement
|
||||
// can be used wherever <length>, <frequency>, <angle>, <time>, <percentage>, <number>, or <integer> values are allowed
|
||||
// https://drafts.csswg.org/css-values/#calc-notation
|
||||
function calc(next) {
|
||||
function math(next, functionNames) {
|
||||
return function(token, getNextToken, opts) {
|
||||
if (token === null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (token.type === types.Function && eqStrAny(token.value, calcFunctionNames)) {
|
||||
if (token.type === types.Function && eqStrAny(token.value, functionNames)) {
|
||||
return consumeFunction(token, getNextToken);
|
||||
}
|
||||
|
||||
@@ -530,12 +615,12 @@ const productionTypes = {
|
||||
'ident': tokenType(types.Ident),
|
||||
|
||||
// percentage
|
||||
'percentage': calc(percentage),
|
||||
'percentage': math(percentage, percentageFunctionNames),
|
||||
|
||||
// numeric
|
||||
'zero': zero(),
|
||||
'number': calc(number),
|
||||
'integer': calc(integer),
|
||||
'number': math(number, numberFunctionNames),
|
||||
'integer': math(integer, numberFunctionNames),
|
||||
|
||||
// complex types
|
||||
'custom-ident': customIdent,
|
||||
@@ -549,6 +634,17 @@ const productionTypes = {
|
||||
'any-value': anyValue
|
||||
};
|
||||
|
||||
const unitGroups = [
|
||||
'length',
|
||||
'angle',
|
||||
'time',
|
||||
'frequency',
|
||||
'resolution',
|
||||
'flex',
|
||||
'decibel',
|
||||
'semitones'
|
||||
];
|
||||
|
||||
// dimensions types depend on units set
|
||||
function createDemensionTypes(units) {
|
||||
const {
|
||||
@@ -563,15 +659,45 @@ function createDemensionTypes(units) {
|
||||
} = units || {};
|
||||
|
||||
return {
|
||||
'dimension': calc(dimension(null)),
|
||||
'angle': calc(dimension(angle)),
|
||||
'decibel': calc(dimension(decibel)),
|
||||
'frequency': calc(dimension(frequency)),
|
||||
'flex': calc(dimension(flex)),
|
||||
'length': calc(zero(dimension(length))),
|
||||
'resolution': calc(dimension(resolution)),
|
||||
'semitones': calc(dimension(semitones)),
|
||||
'time': calc(dimension(time))
|
||||
'dimension': math(dimension(null), dimensionFunctionNames),
|
||||
'angle': math(dimension(angle), dimensionFunctionNames),
|
||||
'decibel': math(dimension(decibel), dimensionFunctionNames),
|
||||
'frequency': math(dimension(frequency), dimensionFunctionNames),
|
||||
'flex': math(dimension(flex), dimensionFunctionNames),
|
||||
'length': math(zero(dimension(length)), dimensionFunctionNames),
|
||||
'resolution': math(dimension(resolution), dimensionFunctionNames),
|
||||
'semitones': math(dimension(semitones), dimensionFunctionNames),
|
||||
'time': math(dimension(time), dimensionFunctionNames)
|
||||
};
|
||||
}
|
||||
|
||||
// The <attr-unit> production matches any identifier that is an ASCII case-insensitive
|
||||
// match for the name of a CSS dimension unit, such as px, or the <delim-token> %.
|
||||
function createAttrUnit(units) {
|
||||
const unitSet = new Set();
|
||||
|
||||
for (const group of unitGroups) {
|
||||
if (Array.isArray(units[group])) {
|
||||
for (const unit of units[group]) {
|
||||
unitSet.add(unit.toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return function attrUnit(token) {
|
||||
if (token === null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (token.type === types.Delim && token.value === '%') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (token.type === types.Ident && unitSet.has(token.value.toLowerCase())) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -579,7 +705,8 @@ function createGenericTypes(units) {
|
||||
return {
|
||||
...tokenTypes,
|
||||
...productionTypes,
|
||||
...createDemensionTypes(units)
|
||||
...createDemensionTypes(units),
|
||||
'attr-unit': createAttrUnit(units)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -587,3 +714,4 @@ exports.createDemensionTypes = createDemensionTypes;
|
||||
exports.createGenericTypes = createGenericTypes;
|
||||
exports.productionTypes = productionTypes;
|
||||
exports.tokenTypes = tokenTypes;
|
||||
exports.unitGroups = unitGroups;
|
||||
|
||||
88
node_modules/css-tree/cjs/parser/create.cjs
generated
vendored
88
node_modules/css-tree/cjs/parser/create.cjs
generated
vendored
@@ -17,6 +17,36 @@ const SEMICOLON = 0x003B; // U+003B SEMICOLON (;)
|
||||
const LEFTCURLYBRACKET = 0x007B; // U+007B LEFT CURLY BRACKET ({)
|
||||
const NULL = 0;
|
||||
|
||||
const arrayMethods = {
|
||||
createList() {
|
||||
return [];
|
||||
},
|
||||
createSingleNodeList(node) {
|
||||
return [node];
|
||||
},
|
||||
getFirstListNode(list) {
|
||||
return list && list[0] || null;
|
||||
},
|
||||
getLastListNode(list) {
|
||||
return list && list.length > 0 ? list[list.length - 1] : null;
|
||||
}
|
||||
};
|
||||
|
||||
const listMethods = {
|
||||
createList() {
|
||||
return new List.List();
|
||||
},
|
||||
createSingleNodeList(node) {
|
||||
return new List.List().appendData(node);
|
||||
},
|
||||
getFirstListNode(list) {
|
||||
return list && list.first;
|
||||
},
|
||||
getLastListNode(list) {
|
||||
return list && list.last;
|
||||
}
|
||||
};
|
||||
|
||||
function createParseContext(name) {
|
||||
return function() {
|
||||
return this[name]();
|
||||
@@ -97,18 +127,10 @@ function createParser(config) {
|
||||
return code === SEMICOLON ? 2 : 0;
|
||||
},
|
||||
|
||||
createList() {
|
||||
return new List.List();
|
||||
},
|
||||
createSingleNodeList(node) {
|
||||
return new List.List().appendData(node);
|
||||
},
|
||||
getFirstListNode(list) {
|
||||
return list && list.first;
|
||||
},
|
||||
getLastListNode(list) {
|
||||
return list && list.last;
|
||||
},
|
||||
createList: NOOP,
|
||||
createSingleNodeList: NOOP,
|
||||
getFirstListNode: NOOP,
|
||||
getLastListNode: NOOP,
|
||||
|
||||
parseWithFallback(consumer, fallback) {
|
||||
const startIndex = this.tokenIndex;
|
||||
@@ -280,6 +302,36 @@ function createParser(config) {
|
||||
);
|
||||
}
|
||||
});
|
||||
const createTokenIterateAPI = () => ({
|
||||
filename,
|
||||
source,
|
||||
tokenCount: parser.tokenCount,
|
||||
|
||||
getTokenType: (index) =>
|
||||
parser.getTokenType(index),
|
||||
getTokenTypeName: (index) =>
|
||||
names[parser.getTokenType(index)],
|
||||
getTokenStart: (index) =>
|
||||
parser.getTokenStart(index),
|
||||
getTokenEnd: (index) =>
|
||||
parser.getTokenEnd(index),
|
||||
getTokenValue: (index) =>
|
||||
parser.source.substring(parser.getTokenStart(index), parser.getTokenEnd(index)),
|
||||
|
||||
substring: (start, end) =>
|
||||
parser.source.substring(start, end),
|
||||
|
||||
balance: parser.balance.subarray(0, parser.tokenCount + 1),
|
||||
isBlockOpenerTokenType: parser.isBlockOpenerTokenType,
|
||||
isBlockCloserTokenType: parser.isBlockCloserTokenType,
|
||||
getBlockTokenPairIndex: (index) =>
|
||||
parser.getBlockTokenPairIndex(index),
|
||||
|
||||
getLocation: (offset) =>
|
||||
locationMap.getLocation(offset, filename),
|
||||
getRangeLocation: (start, end) =>
|
||||
locationMap.getLocationRange(start, end, filename)
|
||||
});
|
||||
|
||||
const parse = function(source_, options) {
|
||||
source = source_;
|
||||
@@ -303,12 +355,22 @@ function createParser(config) {
|
||||
parser.parseValue = 'parseValue' in options ? Boolean(options.parseValue) : true;
|
||||
parser.parseCustomProperty = 'parseCustomProperty' in options ? Boolean(options.parseCustomProperty) : false;
|
||||
|
||||
const { context = 'default', onComment } = options;
|
||||
const { context = 'default', list = true, onComment, onToken } = options;
|
||||
|
||||
if (context in parser.context === false) {
|
||||
throw new Error('Unknown context `' + context + '`');
|
||||
}
|
||||
|
||||
Object.assign(parser, list ? listMethods : arrayMethods);
|
||||
|
||||
if (Array.isArray(onToken)) {
|
||||
parser.forEachToken((type, start, end) => {
|
||||
onToken.push({ type, start, end });
|
||||
});
|
||||
} else if (typeof onToken === 'function') {
|
||||
parser.forEachToken(onToken.bind(createTokenIterateAPI()));
|
||||
}
|
||||
|
||||
if (typeof onComment === 'function') {
|
||||
parser.forEachToken((type, start, end) => {
|
||||
if (type === types.Comment) {
|
||||
|
||||
49
node_modules/css-tree/cjs/syntax/config/mix.cjs
generated
vendored
49
node_modules/css-tree/cjs/syntax/config/mix.cjs
generated
vendored
@@ -10,23 +10,31 @@ function appendOrSet(a, b) {
|
||||
return b || null;
|
||||
}
|
||||
|
||||
function sliceProps(obj, props) {
|
||||
function extractProps(obj, props) {
|
||||
const result = Object.create(null);
|
||||
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
if (value) {
|
||||
result[key] = {};
|
||||
for (const prop of Object.keys(value)) {
|
||||
if (props.includes(prop)) {
|
||||
result[key][prop] = value[prop];
|
||||
}
|
||||
}
|
||||
for (const prop of Object.keys(obj)) {
|
||||
if (props.includes(prop)) {
|
||||
result[prop] = obj[prop];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function mergeDicts(base, ext, fields) {
|
||||
const result = { ...base };
|
||||
|
||||
for (const [key, props] of Object.entries(ext)) {
|
||||
result[key] = {
|
||||
...result[key],
|
||||
...fields ? extractProps(props, fields) : props
|
||||
};
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function mix(dest, src) {
|
||||
const result = { ...dest };
|
||||
|
||||
@@ -89,14 +97,6 @@ function mix(dest, src) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'scope':
|
||||
case 'features':
|
||||
result[prop] = { ...dest[prop] };
|
||||
for (const [name, props] of Object.entries(value)) {
|
||||
result[prop][name] = { ...result[prop][name], ...props };
|
||||
}
|
||||
break;
|
||||
|
||||
case 'parseContext':
|
||||
result[prop] = {
|
||||
...dest[prop],
|
||||
@@ -104,19 +104,18 @@ function mix(dest, src) {
|
||||
};
|
||||
break;
|
||||
|
||||
case 'scope':
|
||||
case 'features':
|
||||
result[prop] = mergeDicts(dest[prop], value);
|
||||
break;
|
||||
|
||||
case 'atrule':
|
||||
case 'pseudo':
|
||||
result[prop] = {
|
||||
...dest[prop],
|
||||
...sliceProps(value, ['parse'])
|
||||
};
|
||||
result[prop] = mergeDicts(dest[prop], value, ['parse']);
|
||||
break;
|
||||
|
||||
case 'node':
|
||||
result[prop] = {
|
||||
...dest[prop],
|
||||
...sliceProps(value, ['name', 'structure', 'parse', 'generate', 'walkContext'])
|
||||
};
|
||||
result[prop] = mergeDicts(dest[prop], value, ['name', 'structure', 'parse', 'generate', 'walkContext']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
34
node_modules/css-tree/cjs/syntax/node/LayerName.cjs
generated
vendored
34
node_modules/css-tree/cjs/syntax/node/LayerName.cjs
generated
vendored
@@ -1,34 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const types = require('../../tokenizer/types.cjs');
|
||||
|
||||
const FULLSTOP = 0x002E; // U+002E FULL STOP (.)
|
||||
|
||||
const name = 'LayerName';
|
||||
const structure = {
|
||||
name: String
|
||||
};
|
||||
|
||||
function parse() {
|
||||
let name = this.consume(types.Ident);
|
||||
|
||||
while (this.isDelim(FULLSTOP)) {
|
||||
this.eat(types.Delim);
|
||||
name += '.' + this.consume(types.Ident);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'LayerName',
|
||||
loc: this.getLocation(this.tokenStart, this.tokenEnd),
|
||||
name
|
||||
};
|
||||
}
|
||||
|
||||
function generate(node) {
|
||||
this.tokenize(node.name);
|
||||
}
|
||||
|
||||
exports.generate = generate;
|
||||
exports.name = name;
|
||||
exports.parse = parse;
|
||||
exports.structure = structure;
|
||||
42
node_modules/css-tree/cjs/syntax/node/LayerNameList.cjs
generated
vendored
42
node_modules/css-tree/cjs/syntax/node/LayerNameList.cjs
generated
vendored
@@ -1,42 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const types = require('../../tokenizer/types.cjs');
|
||||
|
||||
const name = 'LayerNameList';
|
||||
const structure = {
|
||||
children: [[
|
||||
'MediaQuery'
|
||||
]]
|
||||
};
|
||||
|
||||
function parse() {
|
||||
const children = this.createList();
|
||||
|
||||
this.skipSC();
|
||||
|
||||
while (!this.eof) {
|
||||
children.push(this.LayerName());
|
||||
|
||||
if (this.tokenType !== types.Comma) {
|
||||
break;
|
||||
}
|
||||
|
||||
this.next();
|
||||
this.skipSC();
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'LayerNameList',
|
||||
loc: this.getLocationFromList(children),
|
||||
children
|
||||
};
|
||||
}
|
||||
|
||||
function generate(node) {
|
||||
this.children(node, () => this.token(types.Comma, ','));
|
||||
}
|
||||
|
||||
exports.generate = generate;
|
||||
exports.name = name;
|
||||
exports.parse = parse;
|
||||
exports.structure = structure;
|
||||
70
node_modules/css-tree/cjs/syntax/node/MediaCondition.cjs
generated
vendored
70
node_modules/css-tree/cjs/syntax/node/MediaCondition.cjs
generated
vendored
@@ -1,70 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const types = require('../../tokenizer/types.cjs');
|
||||
|
||||
const MediaFeatureToken = new Set([types.Colon, types.RightParenthesis, types.EOF]);
|
||||
|
||||
const name = 'MediaCondition';
|
||||
const structure = {
|
||||
children: [[
|
||||
'Identifier',
|
||||
'MediaFeature',
|
||||
'MediaFeatureRange'
|
||||
]]
|
||||
};
|
||||
|
||||
function parse() {
|
||||
const children = this.createList();
|
||||
|
||||
scan: while (!this.eof) {
|
||||
switch (this.tokenType) {
|
||||
case types.Comment:
|
||||
case types.WhiteSpace:
|
||||
this.next();
|
||||
continue;
|
||||
|
||||
case types.Ident:
|
||||
children.push(this.Identifier());
|
||||
break;
|
||||
|
||||
case types.LeftParenthesis:
|
||||
if (this.lookupTypeNonSC(1) === types.Ident && MediaFeatureToken.has(this.lookupTypeNonSC(2))) {
|
||||
children.push(this.MediaFeature());
|
||||
} else if (this.lookupTypeNonSC(1) === types.LeftParenthesis || this.lookupTypeNonSC(2) === types.LeftParenthesis) {
|
||||
this.next();
|
||||
children.push(this.MediaCondition());
|
||||
this.eat(types.RightParenthesis);
|
||||
} else {
|
||||
children.push(this.MediaFeatureRange());
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break scan;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'MediaCondition',
|
||||
loc: this.getLocationFromList(children),
|
||||
children
|
||||
};
|
||||
}
|
||||
|
||||
function generate(node) {
|
||||
node.children.forEach(child => {
|
||||
if (child.type === 'MediaCondition') {
|
||||
this.token(types.LeftParenthesis, '(');
|
||||
this.node(child);
|
||||
this.token(types.RightParenthesis, ')');
|
||||
} else {
|
||||
this.node(child);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
exports.generate = generate;
|
||||
exports.name = name;
|
||||
exports.parse = parse;
|
||||
exports.structure = structure;
|
||||
76
node_modules/css-tree/cjs/syntax/node/MediaFeature.cjs
generated
vendored
76
node_modules/css-tree/cjs/syntax/node/MediaFeature.cjs
generated
vendored
@@ -1,76 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const types = require('../../tokenizer/types.cjs');
|
||||
|
||||
const name = 'MediaFeature';
|
||||
const structure = {
|
||||
name: String,
|
||||
value: ['Identifier', 'Number', 'Dimension', 'Ratio', null]
|
||||
};
|
||||
|
||||
function parse() {
|
||||
const start = this.tokenStart;
|
||||
let name;
|
||||
let value = null;
|
||||
|
||||
this.eat(types.LeftParenthesis);
|
||||
this.skipSC();
|
||||
|
||||
name = this.consume(types.Ident);
|
||||
this.skipSC();
|
||||
|
||||
if (this.tokenType !== types.RightParenthesis) {
|
||||
this.eat(types.Colon);
|
||||
this.skipSC();
|
||||
|
||||
switch (this.tokenType) {
|
||||
case types.Number:
|
||||
if (this.lookupNonWSType(1) === types.Delim) {
|
||||
value = this.Ratio();
|
||||
} else {
|
||||
value = this.Number();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case types.Dimension:
|
||||
value = this.Dimension();
|
||||
break;
|
||||
|
||||
case types.Ident:
|
||||
value = this.Identifier();
|
||||
break;
|
||||
|
||||
default:
|
||||
this.error('Number, dimension, ratio or identifier is expected');
|
||||
}
|
||||
|
||||
this.skipSC();
|
||||
}
|
||||
|
||||
this.eat(types.RightParenthesis);
|
||||
|
||||
return {
|
||||
type: 'MediaFeature',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
name,
|
||||
value
|
||||
};
|
||||
}
|
||||
|
||||
function generate(node) {
|
||||
this.token(types.LeftParenthesis, '(');
|
||||
this.token(types.Ident, node.name);
|
||||
|
||||
if (node.value !== null) {
|
||||
this.token(types.Colon, ':');
|
||||
this.node(node.value);
|
||||
}
|
||||
|
||||
this.token(types.RightParenthesis, ')');
|
||||
}
|
||||
|
||||
exports.generate = generate;
|
||||
exports.name = name;
|
||||
exports.parse = parse;
|
||||
exports.structure = structure;
|
||||
11
node_modules/css-tree/cjs/syntax/node/MediaFeatureRange.cjs
generated
vendored
11
node_modules/css-tree/cjs/syntax/node/MediaFeatureRange.cjs
generated
vendored
@@ -1,11 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const featureRange = require('./common/feature-range.cjs');
|
||||
|
||||
const name = 'MediaFeatureRange';
|
||||
const parse = featureRange.createParse(name);
|
||||
|
||||
exports.generate = featureRange.generate;
|
||||
exports.structure = featureRange.structure;
|
||||
exports.name = name;
|
||||
exports.parse = parse;
|
||||
69
node_modules/css-tree/cjs/syntax/node/SupportsFeature.cjs
generated
vendored
69
node_modules/css-tree/cjs/syntax/node/SupportsFeature.cjs
generated
vendored
@@ -1,69 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const types = require('../../tokenizer/types.cjs');
|
||||
|
||||
const name = 'SupportsDeclaration';
|
||||
const structure = {
|
||||
feature: String,
|
||||
value: 'Declaration'
|
||||
};
|
||||
|
||||
function parse() {
|
||||
const start = this.tokenStart;
|
||||
let featureName = 'declaration';
|
||||
let valueParser = this.Declaration;
|
||||
|
||||
if (this.tokenType === types.Function) {
|
||||
featureName = this.consumeFunctionName();
|
||||
valueParser = this.supportsFeature[featureName.toLowerCase()];
|
||||
if (!valueParser) {
|
||||
this.error(`Unknown supports feature ${featureName.toLowerCase()}()`);
|
||||
}
|
||||
} else {
|
||||
this.eat(types.LeftParenthesis);
|
||||
}
|
||||
|
||||
this.skipSC();
|
||||
|
||||
const value = this.parseWithFallback(
|
||||
() => {
|
||||
const startValueToken = this.tokenIndex;
|
||||
const value = valueParser.call(this);
|
||||
|
||||
if (this.eof === false &&
|
||||
this.isBalanceEdge(startValueToken) === false) {
|
||||
this.error();
|
||||
}
|
||||
|
||||
return value;
|
||||
},
|
||||
(startToken) => this.Raw(startToken, null, false)
|
||||
);
|
||||
|
||||
if (!this.eof) {
|
||||
this.eat(types.RightParenthesis);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'SupportsDeclaration',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
feature: featureName,
|
||||
value
|
||||
};
|
||||
}
|
||||
|
||||
function generate(node) {
|
||||
if (node.feature !== 'declaration') {
|
||||
this.token(types.Function, node.feature + '(');
|
||||
} else {
|
||||
this.token(types.LeftParenthesis, '(');
|
||||
}
|
||||
|
||||
this.node(node.value);
|
||||
this.token(types.RightParenthesis, ')');
|
||||
}
|
||||
|
||||
exports.generate = generate;
|
||||
exports.name = name;
|
||||
exports.parse = parse;
|
||||
exports.structure = structure;
|
||||
112
node_modules/css-tree/cjs/syntax/node/common/feature-range.cjs
generated
vendored
112
node_modules/css-tree/cjs/syntax/node/common/feature-range.cjs
generated
vendored
@@ -1,112 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const types = require('../../../tokenizer/types.cjs');
|
||||
|
||||
const LESSTHANSIGN = 60; // <
|
||||
const EQUALSIGN = 61; // =
|
||||
const GREATERTHANSIGN = 62; // >
|
||||
|
||||
const structure = {
|
||||
left: ['Identifier', 'Number', 'Dimension', 'Ratio'],
|
||||
leftComparison: String,
|
||||
middle: ['Identifier', 'Number', 'Dimension', 'Ratio'],
|
||||
rightComparison: [String, null],
|
||||
right: ['Identifier', 'Number', 'Dimension', 'Ratio', null]
|
||||
};
|
||||
|
||||
function readTerm() {
|
||||
this.skipSC();
|
||||
|
||||
switch (this.tokenType) {
|
||||
case types.Number:
|
||||
if (this.lookupNonWSType(1) === types.Delim) {
|
||||
return this.Ratio();
|
||||
} else {
|
||||
return this.Number();
|
||||
}
|
||||
|
||||
case types.Dimension:
|
||||
return this.Dimension();
|
||||
|
||||
case types.Ident:
|
||||
return this.Identifier();
|
||||
|
||||
default:
|
||||
this.error('Number, dimension, ratio or identifier is expected');
|
||||
}
|
||||
}
|
||||
|
||||
function readComparison(expectColon) {
|
||||
this.skipSC();
|
||||
|
||||
if (this.isDelim(LESSTHANSIGN) ||
|
||||
this.isDelim(GREATERTHANSIGN)) {
|
||||
const value = this.source[this.tokenStart];
|
||||
|
||||
this.next();
|
||||
|
||||
if (this.isDelim(EQUALSIGN)) {
|
||||
this.next();
|
||||
return value + '=';
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
if (this.isDelim(EQUALSIGN)) {
|
||||
return '=';
|
||||
}
|
||||
|
||||
this.error(`Expected ${expectColon ? '":", ' : ''}"<", ">", "=" or ")"`);
|
||||
}
|
||||
|
||||
function createParse(type) {
|
||||
return function parse() {
|
||||
const start = this.tokenStart;
|
||||
|
||||
this.skipSC();
|
||||
this.eat(types.LeftParenthesis);
|
||||
|
||||
const left = readTerm.call(this);
|
||||
const leftComparison = readComparison.call(this, left.type === 'Identifier');
|
||||
const middle = readTerm.call(this);
|
||||
let rightComparison = null;
|
||||
let right = null;
|
||||
|
||||
if (this.lookupNonWSType(0) !== types.RightParenthesis) {
|
||||
rightComparison = readComparison.call(this);
|
||||
right = readTerm.call(this);
|
||||
}
|
||||
|
||||
this.skipSC();
|
||||
this.eat(types.RightParenthesis);
|
||||
|
||||
return {
|
||||
type,
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
left,
|
||||
leftComparison,
|
||||
middle,
|
||||
rightComparison,
|
||||
right
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function generate(node) {
|
||||
this.token(types.LeftParenthesis, '(');
|
||||
this.node(node.left);
|
||||
this.tokenize(node.leftComparison);
|
||||
this.node(node.middle);
|
||||
|
||||
if (node.right) {
|
||||
this.tokenize(node.rightComparison);
|
||||
this.node(node.right);
|
||||
}
|
||||
|
||||
this.token(types.RightParenthesis, ')');
|
||||
}
|
||||
|
||||
exports.createParse = createParse;
|
||||
exports.generate = generate;
|
||||
exports.structure = structure;
|
||||
76
node_modules/css-tree/cjs/syntax/node/common/feature.cjs
generated
vendored
76
node_modules/css-tree/cjs/syntax/node/common/feature.cjs
generated
vendored
@@ -1,76 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const types = require('../../../tokenizer/types.cjs');
|
||||
|
||||
const structure = {
|
||||
name: String,
|
||||
value: ['Identifier', 'Number', 'Dimension', 'Ratio', null]
|
||||
};
|
||||
|
||||
function createParse(type) {
|
||||
return function parse() {
|
||||
const start = this.tokenStart;
|
||||
let name;
|
||||
let value = null;
|
||||
|
||||
this.eat(types.LeftParenthesis);
|
||||
this.skipSC();
|
||||
|
||||
name = this.consume(types.Ident);
|
||||
this.skipSC();
|
||||
|
||||
if (this.tokenType !== types.RightParenthesis) {
|
||||
this.eat(types.Colon);
|
||||
this.skipSC();
|
||||
|
||||
switch (this.tokenType) {
|
||||
case types.Number:
|
||||
if (this.lookupNonWSType(1) === types.Delim) {
|
||||
value = this.Ratio();
|
||||
} else {
|
||||
value = this.Number();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case types.Dimension:
|
||||
value = this.Dimension();
|
||||
break;
|
||||
|
||||
case types.Ident:
|
||||
value = this.Identifier();
|
||||
break;
|
||||
|
||||
default:
|
||||
this.error('Number, dimension, ratio or identifier is expected');
|
||||
}
|
||||
|
||||
this.skipSC();
|
||||
}
|
||||
|
||||
this.eat(types.RightParenthesis);
|
||||
|
||||
return {
|
||||
type,
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
name,
|
||||
value
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function generate(node) {
|
||||
this.token(types.LeftParenthesis, '(');
|
||||
this.token(types.Ident, node.name);
|
||||
|
||||
if (node.value !== null) {
|
||||
this.token(types.Colon, ':');
|
||||
this.node(node.value);
|
||||
}
|
||||
|
||||
this.token(types.RightParenthesis, ')');
|
||||
}
|
||||
|
||||
exports.createParse = createParse;
|
||||
exports.generate = generate;
|
||||
exports.structure = structure;
|
||||
64
node_modules/css-tree/cjs/tokenizer/TokenStream.cjs
generated
vendored
64
node_modules/css-tree/cjs/tokenizer/TokenStream.cjs
generated
vendored
@@ -7,14 +7,25 @@ const types = require('./types.cjs');
|
||||
|
||||
const OFFSET_MASK = 0x00FFFFFF;
|
||||
const TYPE_SHIFT = 24;
|
||||
const BLOCK_OPEN_TOKEN = 1;
|
||||
const BLOCK_CLOSE_TOKEN = 2;
|
||||
const balancePair = new Uint8Array(32); // 32b of memory ought to be enough for anyone (any number of tokens)
|
||||
balancePair[types.Function] = types.RightParenthesis;
|
||||
balancePair[types.LeftParenthesis] = types.RightParenthesis;
|
||||
balancePair[types.LeftSquareBracket] = types.RightSquareBracket;
|
||||
balancePair[types.LeftCurlyBracket] = types.RightCurlyBracket;
|
||||
|
||||
function isBlockOpenerToken(tokenType) {
|
||||
return balancePair[tokenType] !== 0;
|
||||
const blockTokens = new Uint8Array(32);
|
||||
blockTokens[types.Function] = BLOCK_OPEN_TOKEN;
|
||||
blockTokens[types.LeftParenthesis] = BLOCK_OPEN_TOKEN;
|
||||
blockTokens[types.LeftSquareBracket] = BLOCK_OPEN_TOKEN;
|
||||
blockTokens[types.LeftCurlyBracket] = BLOCK_OPEN_TOKEN;
|
||||
blockTokens[types.RightParenthesis] = BLOCK_CLOSE_TOKEN;
|
||||
blockTokens[types.RightSquareBracket] = BLOCK_CLOSE_TOKEN;
|
||||
blockTokens[types.RightCurlyBracket] = BLOCK_CLOSE_TOKEN;
|
||||
|
||||
function boundIndex(index, min, max) {
|
||||
return index < min ? min : index > max ? max : index;
|
||||
}
|
||||
|
||||
class TokenStream {
|
||||
@@ -66,7 +77,7 @@ class TokenStream {
|
||||
// pop state
|
||||
balanceStart = prevBalanceStart;
|
||||
balanceCloseType = balancePair[offsetAndType[prevBalanceStart] >> TYPE_SHIFT];
|
||||
} else if (isBlockOpenerToken(type)) { // check for FunctionToken, <(-token>, <[-token> and <{-token>
|
||||
} else if (this.isBlockOpenerTokenType(type)) { // check for FunctionToken, <(-token>, <[-token> and <{-token>
|
||||
// push state
|
||||
balanceStart = index;
|
||||
balanceCloseType = balancePair[type];
|
||||
@@ -184,14 +195,53 @@ class TokenStream {
|
||||
|
||||
return this.firstCharOffset;
|
||||
}
|
||||
getTokenEnd(tokenIndex) {
|
||||
if (tokenIndex === this.tokenIndex) {
|
||||
return this.tokenEnd;
|
||||
}
|
||||
|
||||
return this.offsetAndType[boundIndex(tokenIndex, 0, this.tokenCount)] & OFFSET_MASK;
|
||||
}
|
||||
getTokenType(tokenIndex) {
|
||||
if (tokenIndex === this.tokenIndex) {
|
||||
return this.tokenType;
|
||||
}
|
||||
|
||||
return this.offsetAndType[boundIndex(tokenIndex, 0, this.tokenCount)] >> TYPE_SHIFT;
|
||||
}
|
||||
substrToCursor(start) {
|
||||
return this.source.substring(start, this.tokenStart);
|
||||
}
|
||||
|
||||
isBalanceEdge(pos) {
|
||||
return this.balance[this.tokenIndex] < pos;
|
||||
// return this.balance[this.balance[pos]] !== this.tokenIndex;
|
||||
isBlockOpenerTokenType(tokenType) {
|
||||
return blockTokens[tokenType] === BLOCK_OPEN_TOKEN;
|
||||
}
|
||||
isBlockCloserTokenType(tokenType) {
|
||||
return blockTokens[tokenType] === BLOCK_CLOSE_TOKEN;
|
||||
}
|
||||
getBlockTokenPairIndex(tokenIndex) {
|
||||
const type = this.getTokenType(tokenIndex);
|
||||
|
||||
if (blockTokens[type] === 1) {
|
||||
// block open token
|
||||
const pairIndex = this.balance[tokenIndex];
|
||||
const closeType = this.getTokenType(pairIndex);
|
||||
|
||||
return balancePair[type] === closeType ? pairIndex : -1;
|
||||
} else if (blockTokens[type] === 2) {
|
||||
// block close token
|
||||
const pairIndex = this.balance[tokenIndex];
|
||||
const openType = this.getTokenType(pairIndex);
|
||||
|
||||
return balancePair[openType] === type ? pairIndex : -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
isBalanceEdge(tokenIndex) {
|
||||
return this.balance[this.tokenIndex] < tokenIndex;
|
||||
}
|
||||
|
||||
isDelim(code, offset) {
|
||||
if (offset) {
|
||||
return (
|
||||
@@ -268,7 +318,7 @@ class TokenStream {
|
||||
|
||||
default:
|
||||
// fast forward to the end of balanced block for an open block tokens
|
||||
if (isBlockOpenerToken(this.offsetAndType[cursor] >> TYPE_SHIFT)) {
|
||||
if (this.isBlockOpenerTokenType(this.offsetAndType[cursor] >> TYPE_SHIFT)) {
|
||||
cursor = balanceEnd;
|
||||
}
|
||||
}
|
||||
|
||||
235
node_modules/css-tree/data/patch.json
generated
vendored
235
node_modules/css-tree/data/patch.json
generated
vendored
@@ -14,8 +14,12 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"nest": {
|
||||
"prelude": "<complex-selector-list>"
|
||||
"font-features-values": {
|
||||
"comment": "The features values syntax is defined in https://www.w3.org/TR/css-fonts-4/#at-ruledef-font-feature-values",
|
||||
"prelude": "[<string> | <custom-ident>]+",
|
||||
"descriptors": {
|
||||
"font-display": "auto | block | swap | fallback | optional"
|
||||
}
|
||||
},
|
||||
"scope": {
|
||||
"prelude": "[ ( <scope-start> ) ]? [ to ( <scope-end> ) ]?"
|
||||
@@ -152,7 +156,7 @@
|
||||
},
|
||||
"-webkit-background-clip": {
|
||||
"comment": "https://developer.mozilla.org/en/docs/Web/CSS/background-clip",
|
||||
"syntax": "[ <box> | border | padding | content | text ]#"
|
||||
"syntax": "[ <visual-box> | border | padding | content | text ]#"
|
||||
},
|
||||
"-webkit-column-break-after": {
|
||||
"comment": "added, http://help.dottoro.com/lcrthhhv.php",
|
||||
@@ -200,13 +204,6 @@
|
||||
],
|
||||
"syntax": "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical"
|
||||
},
|
||||
"background-clip": {
|
||||
"comment": "used <bg-clip> from CSS Backgrounds and Borders 4 since it adds new values",
|
||||
"references": [
|
||||
"https://github.com/csstree/csstree/issues/190"
|
||||
],
|
||||
"syntax": "<bg-clip>#"
|
||||
},
|
||||
"baseline-shift": {
|
||||
"comment": "added SVG property",
|
||||
"references": [
|
||||
@@ -264,19 +261,13 @@
|
||||
],
|
||||
"syntax": "| optimizeSpeed | optimizeQuality | <-non-standard-image-rendering>"
|
||||
},
|
||||
"fill": {
|
||||
"comment": "added SVG property",
|
||||
"references": [
|
||||
"https://www.w3.org/TR/SVG/painting.html#FillProperty"
|
||||
],
|
||||
"syntax": "<paint>"
|
||||
},
|
||||
"fill-opacity": {
|
||||
"comment": "added SVG property",
|
||||
"references": [
|
||||
"https://developer.mozilla.org/en-US/docs/Web/CSS/fill-opacity",
|
||||
"https://www.w3.org/TR/SVG/painting.html#FillProperty"
|
||||
],
|
||||
"syntax": "<number-zero-one>"
|
||||
"syntax": "<number-zero-one> | <percentage>"
|
||||
},
|
||||
"filter": {
|
||||
"comment": "extend with IE legacy syntaxes",
|
||||
@@ -348,6 +339,22 @@
|
||||
"comment": "extend by vendor keywords https://developer.mozilla.org/en-US/docs/Web/CSS/overflow",
|
||||
"syntax": "| <-non-standard-overflow>"
|
||||
},
|
||||
"overflow-x": {
|
||||
"comment": "extend by vendor keywords https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-x",
|
||||
"syntax": "| <-non-standard-overflow>"
|
||||
},
|
||||
"overflow-y": {
|
||||
"comment": "extend by vendor keywords https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-y",
|
||||
"syntax": "| <-non-standard-overflow>"
|
||||
},
|
||||
"overflow-block": {
|
||||
"comment": "extend by vendor keywords https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-y",
|
||||
"syntax": "| <-non-standard-overflow>"
|
||||
},
|
||||
"overflow-inline": {
|
||||
"comment": "extend by vendor keywords https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-x",
|
||||
"syntax": "| <-non-standard-overflow>"
|
||||
},
|
||||
"pause": {
|
||||
"comment": "https://www.w3.org/TR/css3-speech/#property-index",
|
||||
"syntax": "<'pause-before'> <'pause-after'>?"
|
||||
@@ -360,6 +367,10 @@
|
||||
"comment": "https://www.w3.org/TR/css3-speech/#property-index",
|
||||
"syntax": "<time> | none | x-weak | weak | medium | strong | x-strong"
|
||||
},
|
||||
"position-try-options": {
|
||||
"comment": "https://developer.mozilla.org/en-US/docs/Web/CSS/position-try-fallbacks",
|
||||
"syntax": "<'position-try-fallbacks'>"
|
||||
},
|
||||
"rest": {
|
||||
"comment": "https://www.w3.org/TR/css3-speech/#property-index",
|
||||
"syntax": "<'rest-before'> <'rest-after'>?"
|
||||
@@ -372,39 +383,10 @@
|
||||
"comment": "https://www.w3.org/TR/css3-speech/#property-index",
|
||||
"syntax": "<time> | none | x-weak | weak | medium | strong | x-strong"
|
||||
},
|
||||
"scroll-timeline": {
|
||||
"comment": "fix according to spec",
|
||||
"references": [
|
||||
"https://www.w3.org/TR/scroll-animations-1/#scroll-timeline-shorthand"
|
||||
],
|
||||
"syntax": "[ <'scroll-timeline-name'> || <'scroll-timeline-axis'> ]#"
|
||||
},
|
||||
"scroll-timeline-name": {
|
||||
"comment": "fix according to spec",
|
||||
"references": [
|
||||
"https://w3c.github.io/csswg-drafts/scroll-animations/#propdef-scroll-timeline-name"
|
||||
],
|
||||
"syntax": "[ none | <dashed-ident> ]#"
|
||||
},
|
||||
"src": {
|
||||
"comment": "added @font-face's src property https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src",
|
||||
"syntax": "[ <url> [ format( <string># ) ]? | local( <family-name> ) ]#"
|
||||
},
|
||||
"speak": {
|
||||
"comment": "https://www.w3.org/TR/css3-speech/#property-index",
|
||||
"syntax": "auto | never | always"
|
||||
},
|
||||
"speak-as": {
|
||||
"comment": "https://www.w3.org/TR/css3-speech/#property-index",
|
||||
"syntax": "normal | spell-out || digits || [ literal-punctuation | no-punctuation ]"
|
||||
},
|
||||
"stroke": {
|
||||
"comment": "added SVG property",
|
||||
"references": [
|
||||
"https://www.w3.org/TR/SVG/painting.html#StrokeProperties"
|
||||
],
|
||||
"syntax": "<paint>"
|
||||
},
|
||||
"stroke-dasharray": {
|
||||
"comment": "added SVG property; a list of comma and/or white space separated <length>s and <percentage>s",
|
||||
"references": [
|
||||
@@ -440,18 +422,10 @@
|
||||
],
|
||||
"syntax": "<svg-length>"
|
||||
},
|
||||
"text-wrap": {
|
||||
"comment": "broken in mdn/data",
|
||||
"syntax": "<'text-wrap-mode'> || <'text-wrap-style'>"
|
||||
},
|
||||
"unicode-bidi": {
|
||||
"comment": "added prefixed keywords https://developer.mozilla.org/en-US/docs/Web/CSS/unicode-bidi",
|
||||
"syntax": "| -moz-isolate | -moz-isolate-override | -moz-plaintext | -webkit-isolate | -webkit-isolate-override | -webkit-plaintext"
|
||||
},
|
||||
"unicode-range": {
|
||||
"comment": "added missed property https://developer.mozilla.org/en-US/docs/Web/CSS/%40font-face/unicode-range",
|
||||
"syntax": "<urange>#"
|
||||
},
|
||||
"voice-balance": {
|
||||
"comment": "https://www.w3.org/TR/css3-speech/#property-index",
|
||||
"syntax": "<number> | left | center | right | leftwards | rightwards"
|
||||
@@ -491,13 +465,6 @@
|
||||
"white-space-trim": {
|
||||
"syntax": "none | discard-before || discard-after || discard-inner",
|
||||
"comment": "missed, https://www.w3.org/TR/css-text-4/#white-space-trim"
|
||||
},
|
||||
"word-break": {
|
||||
"syntax": "normal | break-all | keep-all | break-word | auto-phrase",
|
||||
"comment": "added in Chrome/Edge 119, not covered by a spec currently (2024-09-02)",
|
||||
"references": [
|
||||
"https://developer.mozilla.org/en-US/docs/Web/CSS/word-break"
|
||||
]
|
||||
}
|
||||
},
|
||||
"types": {
|
||||
@@ -604,31 +571,18 @@
|
||||
"comment": "https://developer.mozilla.org/en-US/docs/Web/CSS/-ms-filter",
|
||||
"syntax": "<ident-token> | <function-token> <any-value>? )"
|
||||
},
|
||||
"absolute-color-base": {
|
||||
"comment": "https://www.w3.org/TR/css-color-4/#color-syntax",
|
||||
"syntax": "<hex-color> | <absolute-color-function> | <named-color> | transparent"
|
||||
},
|
||||
"absolute-color-function": {
|
||||
"comment": "https://www.w3.org/TR/css-color-4/#color-syntax",
|
||||
"syntax": "<rgb()> | <rgba()> | <hsl()> | <hsla()> | <hwb()> | <lab()> | <lch()> | <oklab()> | <oklch()> | <color()>"
|
||||
},
|
||||
"age": {
|
||||
"comment": "https://www.w3.org/TR/css3-speech/#voice-family",
|
||||
"syntax": "child | young | old"
|
||||
},
|
||||
"anchor-name": {
|
||||
"comment": "missed in mdn/data",
|
||||
"syntax": "<dashed-ident>"
|
||||
},
|
||||
"attr-name": {
|
||||
"syntax": "<wq-name>"
|
||||
},
|
||||
"attr-fallback": {
|
||||
"syntax": "<any-value>"
|
||||
},
|
||||
"bg-clip": {
|
||||
"comment": "missed, https://drafts.csswg.org/css-backgrounds-4/#typedef-bg-clip",
|
||||
"syntax": "<box> | border | text"
|
||||
"autospace": {
|
||||
"syntax": "no-autospace | [ ideograph-alpha || ideograph-numeric || punctuation ] || [ insert | replace ]"
|
||||
},
|
||||
"bottom": {
|
||||
"comment": "missed; not sure we should add it, but no others except `shape` is using it so it's ok for now; https://drafts.fxtf.org/css-masking-1/#funcdef-clip-rect",
|
||||
@@ -638,10 +592,6 @@
|
||||
"comment": "added attr(), see https://github.com/csstree/csstree/issues/201",
|
||||
"syntax": "[ <string> | contents | <image> | <counter> | <quote> | <target> | <leader()> | <attr()> ]+"
|
||||
},
|
||||
"container-name": {
|
||||
"comment": "missed, https://drafts.csswg.org/css-contain-3/#container-rule",
|
||||
"syntax": "<custom-ident>"
|
||||
},
|
||||
"container-condition": {
|
||||
"comment": "missed, https://drafts.csswg.org/css-contain-3/#container-rule",
|
||||
"syntax": "not <query-in-parens> | <query-in-parens> [ [ and <query-in-parens> ]* | [ or <query-in-parens> ]* ]"
|
||||
@@ -649,6 +599,10 @@
|
||||
"coord-box": {
|
||||
"syntax": "content-box | padding-box | border-box | fill-box | stroke-box | view-box"
|
||||
},
|
||||
"cubic-bezier-easing-function": {
|
||||
"comment": "missed, https://drafts.csswg.org/css-easing-1/#cubic-bezier-easing-function",
|
||||
"syntax": "ease | ease-in | ease-out | ease-in-out | cubic-bezier( <number [0,1]> , <number> , <number [0,1]> , <number> )"
|
||||
},
|
||||
"element()": {
|
||||
"comment": "https://drafts.csswg.org/css-gcpm/#element-syntax & https://drafts.csswg.org/css-images-4/#element-notation",
|
||||
"syntax": "element( <custom-ident> , [ first | start | last | first-except ]? ) | element( <id-selector> )"
|
||||
@@ -672,12 +626,6 @@
|
||||
"generic-script-specific": {
|
||||
"syntax": "generic(kai) | generic(fangsong) | generic(nastaliq)"
|
||||
},
|
||||
"generic-complete": {
|
||||
"syntax": "serif | sans-serif | system-ui | cursive | fantasy | math | monospace"
|
||||
},
|
||||
"generic-incomplete": {
|
||||
"syntax": "ui-serif | ui-sans-serif | ui-monospace | ui-rounded"
|
||||
},
|
||||
"-non-standard-generic-family": {
|
||||
"syntax": "-apple-system | BlinkMacSystemFont",
|
||||
"references": [
|
||||
@@ -689,6 +637,10 @@
|
||||
"comment": "added legacy syntaxes support",
|
||||
"syntax": "| <-legacy-gradient>"
|
||||
},
|
||||
"intrinsic-size-keyword": {
|
||||
"comment": "Missing from mdn-data. 4.3. Intrinsic Size Keywords https://www.w3.org/TR/css-sizing-4/#intrinsic-size-keywords",
|
||||
"syntax": "min-content | max-content | fit-content"
|
||||
},
|
||||
"left": {
|
||||
"comment": "missed; not sure we should add it, but no others except `shape` is using it so it's ok for now; https://drafts.fxtf.org/css-masking-1/#funcdef-clip-rect",
|
||||
"syntax": "<length> | auto"
|
||||
@@ -697,12 +649,6 @@
|
||||
"comment": "css-color-5, added non standard color names",
|
||||
"syntax": "<color-base> | currentColor | <system-color> | <device-cmyk()> | <light-dark()> | <-non-standard-color>"
|
||||
},
|
||||
"color-base": {
|
||||
"syntax": "<hex-color> | <color-function> | <named-color> | <color-mix()> | transparent"
|
||||
},
|
||||
"color-function": {
|
||||
"syntax": "<rgb()> | <rgba()> | <hsl()> | <hsla()> | <hwb()> | <lab()> | <lch()> | <oklab()> | <oklch()> | <color()>"
|
||||
},
|
||||
"device-cmyk()": {
|
||||
"syntax": "<legacy-device-cmyk-syntax> | <modern-device-cmyk-syntax>"
|
||||
},
|
||||
@@ -718,23 +664,13 @@
|
||||
"color-mix()": {
|
||||
"syntax": "color-mix( <color-interpolation-method> , [ <color> && <percentage [0,100]>? ]#{2} )"
|
||||
},
|
||||
"color-interpolation-method": {
|
||||
"syntax": "in [ <rectangular-color-space> | <polar-color-space> <hue-interpolation-method>? | <custom-color-space> ]"
|
||||
},
|
||||
"color-space": {
|
||||
"syntax": "<rectangular-color-space> | <polar-color-space> | <custom-color-space>"
|
||||
},
|
||||
"custom-color-space": {
|
||||
"syntax": "<dashed-ident>"
|
||||
},
|
||||
"paint": {
|
||||
"comment": "used by SVG https://www.w3.org/TR/SVG/painting.html#SpecifyingPaint",
|
||||
"syntax": "none | <color> | <url> [ none | <color> ]? | context-fill | context-stroke"
|
||||
},
|
||||
"palette-identifier": {
|
||||
"comment": "<palette-identifier> is parsed as a <dashed-ident> (https://drafts.csswg.org/css-fonts/#typedef-font-palette-palette-identifier)",
|
||||
"syntax": "<dashed-ident>"
|
||||
},
|
||||
"right": {
|
||||
"comment": "missed; not sure we should add it, but no others except `shape` is using it so it's ok for now; https://drafts.fxtf.org/css-masking-1/#funcdef-clip-rect",
|
||||
"syntax": "<length> | auto"
|
||||
@@ -755,9 +691,6 @@
|
||||
"forgiving-relative-selector-list": {
|
||||
"syntax": "<relative-real-selector-list>"
|
||||
},
|
||||
"selector-list": {
|
||||
"syntax": "<complex-selector-list>"
|
||||
},
|
||||
"complex-real-selector-list": {
|
||||
"syntax": "<complex-real-selector>#"
|
||||
},
|
||||
@@ -797,13 +730,6 @@
|
||||
"legacy-pseudo-element-selector": {
|
||||
"syntax": " ':' [before | after | first-line | first-letter]"
|
||||
},
|
||||
"single-animation-composition": {
|
||||
"comment": "missed definition",
|
||||
"references": [
|
||||
"https://w3c.github.io/csswg-drafts/css-animations-2/#typedef-single-animation-composition"
|
||||
],
|
||||
"syntax": "replace | add | accumulate"
|
||||
},
|
||||
"svg-length": {
|
||||
"comment": "All coordinates and lengths in SVG can be specified with or without a unit identifier",
|
||||
"references": [
|
||||
@@ -859,40 +785,12 @@
|
||||
"colorspace-params": {
|
||||
"syntax": "[ <predefined-rgb-params> | <xyz-params>]"
|
||||
},
|
||||
"predefined-rgb-params": {
|
||||
"syntax": "<predefined-rgb> [ <number> | <percentage> | none ]{3}"
|
||||
},
|
||||
"predefined-rgb": {
|
||||
"syntax": "srgb | srgb-linear | display-p3 | a98-rgb | prophoto-rgb | rec2020"
|
||||
},
|
||||
"xyz-params": {
|
||||
"syntax": "<xyz-space> [ <number> | <percentage> | none ]{3}"
|
||||
},
|
||||
"xyz-space": {
|
||||
"syntax": "xyz | xyz-d50 | xyz-d65"
|
||||
},
|
||||
"oklab()": {
|
||||
"comment": "https://www.w3.org/TR/css-color-4/#specifying-oklab-oklch",
|
||||
"syntax": "oklab( [ <percentage> | <number> | none] [ <percentage> | <number> | none] [ <percentage> | <number> | none] [ / [<alpha-value> | none] ]? )"
|
||||
},
|
||||
"oklch()": {
|
||||
"comment": "https://www.w3.org/TR/css-color-4/#specifying-oklab-oklch",
|
||||
"syntax": "oklch( [ <percentage> | <number> | none] [ <percentage> | <number> | none] [ <hue> | none] [ / [<alpha-value> | none] ]? )"
|
||||
},
|
||||
"offset-path": {
|
||||
"syntax": "<ray()> | <url> | <basic-shape>"
|
||||
},
|
||||
"basic-shape": {
|
||||
"syntax": "<inset()> | <xywh()> | <rect()> | <circle()> | <ellipse()> | <polygon()> | <path()>"
|
||||
},
|
||||
"rect()": {
|
||||
"comment": "missed, https://drafts.csswg.org/css-shapes/#supported-basic-shapes",
|
||||
"syntax": "rect( [ <length-percentage> | auto ]{4} [ round <'border-radius'> ]? )"
|
||||
},
|
||||
"xywh()": {
|
||||
"comment": "missed, https://drafts.csswg.org/css-shapes/#supported-basic-shapes",
|
||||
"syntax": "xywh( <length-percentage>{2} <length-percentage [0,∞]>{2} [ round <'border-radius'> ]? )"
|
||||
},
|
||||
"query-in-parens": {
|
||||
"comment": "missed, https://drafts.csswg.org/css-contain-3/#container-rule",
|
||||
"syntax": "( <container-condition> ) | ( <size-feature> ) | style( <style-query> ) | <general-enclosed>"
|
||||
@@ -901,10 +799,6 @@
|
||||
"comment": "missed, https://drafts.csswg.org/css-contain-3/#typedef-size-feature",
|
||||
"syntax": "<mf-plain> | <mf-boolean> | <mf-range>"
|
||||
},
|
||||
"style-feature": {
|
||||
"comment": "missed, https://drafts.csswg.org/css-contain-3/#typedef-style-feature",
|
||||
"syntax": "<declaration>"
|
||||
},
|
||||
"style-query": {
|
||||
"comment": "missed, https://drafts.csswg.org/css-contain-3/#container-rule",
|
||||
"syntax": "<style-condition> | <style-feature>"
|
||||
@@ -934,49 +828,26 @@
|
||||
"https://drafts.csswg.org/css-anchor-position-1/#typedef-position-area"
|
||||
]
|
||||
},
|
||||
"anchor()": {
|
||||
"syntax": "anchor( <anchor-element>? && <anchor-side>, <length-percentage>? )",
|
||||
"comment": "missed",
|
||||
"references": [
|
||||
"https://drafts.csswg.org/css-anchor-position-1/#anchor-pos"
|
||||
]
|
||||
"syntax": {
|
||||
"syntax": "'*' | <syntax-component> [ <syntax-combinator> <syntax-component> ]* | <syntax-string>"
|
||||
},
|
||||
"anchor-side": {
|
||||
"syntax": "inside | outside | top | left | right | bottom | start | end | self-start | self-end | <percentage> | center"
|
||||
"syntax-component": {
|
||||
"syntax": "<syntax-single-component> <syntax-multiplier>? | '<' transform-list '>'"
|
||||
},
|
||||
"anchor-size()": {
|
||||
"syntax": "anchor-size( [ <anchor-element> || <anchor-size> ]? , <length-percentage>? )",
|
||||
"comment": "missed",
|
||||
"references": [
|
||||
"https://drafts.csswg.org/css-anchor-position-1/#funcdef-anchor-size"
|
||||
]
|
||||
"syntax-single-component": {
|
||||
"syntax": "'<' <syntax-type-name> '>' | <ident>"
|
||||
},
|
||||
"anchor-size": {
|
||||
"syntax": "width | height | block | inline | self-block | self-inline"
|
||||
"syntax-type-name": {
|
||||
"syntax": "angle | color | custom-ident | image | integer | length | length-percentage | number | percentage | resolution | string | time | url | transform-function"
|
||||
},
|
||||
"anchor-element": {
|
||||
"syntax": "<dashed-ident>",
|
||||
"comment": "missed, https://drafts.csswg.org/css-anchor-position-1/#typedef-anchor-element"
|
||||
"syntax-combinator": {
|
||||
"syntax": "'|'"
|
||||
},
|
||||
"try-size": {
|
||||
"syntax": "most-width | most-height | most-block-size | most-inline-size",
|
||||
"comment": "missed, https://drafts.csswg.org/css-anchor-position-1/#typedef-try-size"
|
||||
"syntax-multiplier": {
|
||||
"syntax": "'#' | '+'"
|
||||
},
|
||||
"try-tactic": {
|
||||
"syntax": "flip-block || flip-inline || flip-start",
|
||||
"comment": "missed, https://drafts.csswg.org/css-anchor-position-1/#typedef-position-try-fallbacks-try-tactic"
|
||||
},
|
||||
"font-variant-css2": {
|
||||
"syntax": "normal | small-caps",
|
||||
"comment": "new definition on font-4, https://drafts.csswg.org/css-fonts-4/#font-variant-css21-values"
|
||||
},
|
||||
"font-width-css3": {
|
||||
"syntax": "normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded",
|
||||
"comment": "new definition on font-4, https://drafts.csswg.org/css-fonts-4/#font-width-css3-values"
|
||||
},
|
||||
"system-family-name": {
|
||||
"syntax": "caption | icon | menu | message-box | small-caption | status-bar",
|
||||
"comment": "new definition on font-4, https://drafts.csswg.org/css-fonts-4/#system-family-name-value"
|
||||
"syntax-string": {
|
||||
"syntax": "<string>"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
18
node_modules/css-tree/dist/csstree.esm.js
generated
vendored
18
node_modules/css-tree/dist/csstree.esm.js
generated
vendored
File diff suppressed because one or more lines are too long
18
node_modules/css-tree/dist/csstree.js
generated
vendored
18
node_modules/css-tree/dist/csstree.js
generated
vendored
File diff suppressed because one or more lines are too long
636
node_modules/css-tree/dist/data.cjs
generated
vendored
636
node_modules/css-tree/dist/data.cjs
generated
vendored
File diff suppressed because it is too large
Load Diff
636
node_modules/css-tree/dist/data.js
generated
vendored
636
node_modules/css-tree/dist/data.js
generated
vendored
File diff suppressed because it is too large
Load Diff
2
node_modules/css-tree/dist/version.cjs
generated
vendored
2
node_modules/css-tree/dist/version.cjs
generated
vendored
@@ -1 +1 @@
|
||||
module.exports = "3.1.0";
|
||||
module.exports = "3.2.1";
|
||||
2
node_modules/css-tree/dist/version.js
generated
vendored
2
node_modules/css-tree/dist/version.js
generated
vendored
@@ -1 +1 @@
|
||||
export const version = "3.1.0";
|
||||
export const version = "3.2.1";
|
||||
88
node_modules/css-tree/lib/definition-syntax/parse.js
generated
vendored
88
node_modules/css-tree/lib/definition-syntax/parse.js
generated
vendored
@@ -160,6 +160,16 @@ function maybeMultiplied(scanner, node) {
|
||||
return maybeMultiplied(scanner, multiplier);
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-values-4/#component-multipliers
|
||||
// > the # and ? multipliers, {A} and ? multipliers, and {A,B} and ? multipliers
|
||||
// > may be stacked as #?, {A}?, and {A,B}?, respectively
|
||||
// Represent "{}?" as nested multipliers as well as "+#".
|
||||
// The "#?" case is already handled above, in maybeMultiplied()
|
||||
if (scanner.charCode() === QUESTIONMARK &&
|
||||
scanner.charCodeAt(scanner.pos - 1) === RIGHTCURLYBRACKET) {
|
||||
return maybeMultiplied(scanner, multiplier);
|
||||
}
|
||||
|
||||
return multiplier;
|
||||
}
|
||||
|
||||
@@ -376,35 +386,65 @@ function regroupTerms(terms, combinators) {
|
||||
return combinator;
|
||||
}
|
||||
|
||||
function readImplicitGroup(scanner, stopCharCode) {
|
||||
function readImplicitGroup(scanner, stopCharCode = -1) {
|
||||
const combinators = Object.create(null);
|
||||
const terms = [];
|
||||
let token;
|
||||
let prevToken = null;
|
||||
let prevTokenPos = scanner.pos;
|
||||
let prevTokenIsFunction = false;
|
||||
|
||||
while (scanner.charCode() !== stopCharCode && (token = peek(scanner, stopCharCode))) {
|
||||
if (token.type !== 'Spaces') {
|
||||
if (token.type === 'Combinator') {
|
||||
// check for combinator in group beginning and double combinator sequence
|
||||
if (prevToken === null || prevToken.type === 'Combinator') {
|
||||
scanner.pos = prevTokenPos;
|
||||
scanner.error('Unexpected combinator');
|
||||
}
|
||||
while (scanner.charCode() !== stopCharCode) {
|
||||
let token = prevTokenIsFunction
|
||||
? readImplicitGroup(scanner, RIGHTPARENTHESIS)
|
||||
: peek(scanner);
|
||||
|
||||
combinators[token.value] = true;
|
||||
} else if (prevToken !== null && prevToken.type !== 'Combinator') {
|
||||
combinators[' '] = true; // a b
|
||||
terms.push({
|
||||
type: 'Combinator',
|
||||
value: ' '
|
||||
});
|
||||
if (!token) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (token.type === 'Spaces') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (prevTokenIsFunction) {
|
||||
if (token.terms.length === 0) {
|
||||
prevTokenIsFunction = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
terms.push(token);
|
||||
prevToken = token;
|
||||
prevTokenPos = scanner.pos;
|
||||
if (token.combinator === ' ') {
|
||||
while (token.terms.length > 1) {
|
||||
combinators[' '] = true; // a b
|
||||
terms.push({
|
||||
type: 'Combinator',
|
||||
value: ' '
|
||||
}, token.terms.shift());
|
||||
}
|
||||
|
||||
token = token.terms[0];
|
||||
}
|
||||
}
|
||||
|
||||
if (token.type === 'Combinator') {
|
||||
// check for combinator in group beginning and double combinator sequence
|
||||
if (prevToken === null || prevToken.type === 'Combinator') {
|
||||
scanner.pos = prevTokenPos;
|
||||
scanner.error('Unexpected combinator');
|
||||
}
|
||||
|
||||
combinators[token.value] = true;
|
||||
} else if (prevToken !== null && prevToken.type !== 'Combinator') {
|
||||
combinators[' '] = true; // a b
|
||||
terms.push({
|
||||
type: 'Combinator',
|
||||
value: ' '
|
||||
});
|
||||
}
|
||||
|
||||
terms.push(token);
|
||||
prevToken = token;
|
||||
prevTokenPos = scanner.pos;
|
||||
prevTokenIsFunction = token.type === 'Function';
|
||||
}
|
||||
|
||||
// check for combinator in group ending
|
||||
@@ -422,11 +462,11 @@ function readImplicitGroup(scanner, stopCharCode) {
|
||||
};
|
||||
}
|
||||
|
||||
function readGroup(scanner, stopCharCode) {
|
||||
function readGroup(scanner) {
|
||||
let result;
|
||||
|
||||
scanner.eat(LEFTSQUAREBRACKET);
|
||||
result = readImplicitGroup(scanner, stopCharCode);
|
||||
result = readImplicitGroup(scanner, RIGHTSQUAREBRACKET);
|
||||
scanner.eat(RIGHTSQUAREBRACKET);
|
||||
|
||||
result.explicit = true;
|
||||
@@ -439,7 +479,7 @@ function readGroup(scanner, stopCharCode) {
|
||||
return result;
|
||||
}
|
||||
|
||||
function peek(scanner, stopCharCode) {
|
||||
function peek(scanner) {
|
||||
let code = scanner.charCode();
|
||||
|
||||
switch (code) {
|
||||
@@ -448,7 +488,7 @@ function peek(scanner, stopCharCode) {
|
||||
break;
|
||||
|
||||
case LEFTSQUAREBRACKET:
|
||||
return maybeMultiplied(scanner, readGroup(scanner, stopCharCode));
|
||||
return maybeMultiplied(scanner, readGroup(scanner));
|
||||
|
||||
case LESSTHANSIGN:
|
||||
return scanner.nextCharCode() === APOSTROPHE
|
||||
|
||||
21
node_modules/css-tree/lib/generator/create.js
generated
vendored
21
node_modules/css-tree/lib/generator/create.js
generated
vendored
@@ -23,12 +23,6 @@ function processChildren(node, delimeter) {
|
||||
node.children.forEach(this.node, this);
|
||||
}
|
||||
|
||||
function processChunk(chunk) {
|
||||
tokenize(chunk, (type, start, end) => {
|
||||
this.token(type, chunk.slice(start, end));
|
||||
});
|
||||
}
|
||||
|
||||
export function createGenerator(config) {
|
||||
const types = new Map();
|
||||
|
||||
@@ -52,9 +46,13 @@ export function createGenerator(config) {
|
||||
}
|
||||
},
|
||||
tokenBefore: tokenBefore.safe,
|
||||
token(type, value) {
|
||||
token(type, value, suppressAutoWhiteSpace) {
|
||||
prevCode = this.tokenBefore(prevCode, type, value);
|
||||
|
||||
if (!suppressAutoWhiteSpace && prevCode & 1) {
|
||||
this.emit(' ', WhiteSpace, true);
|
||||
}
|
||||
|
||||
this.emit(value, type, false);
|
||||
|
||||
if (type === Delim && value.charCodeAt(0) === REVERSESOLIDUS) {
|
||||
@@ -87,7 +85,14 @@ export function createGenerator(config) {
|
||||
node: (node) => handlers.node(node),
|
||||
children: processChildren,
|
||||
token: (type, value) => handlers.token(type, value),
|
||||
tokenize: processChunk
|
||||
tokenize: (raw) =>
|
||||
tokenize(raw, (type, start, end) => {
|
||||
handlers.token(
|
||||
type,
|
||||
raw.slice(start, end),
|
||||
start !== 0 // suppress auto whitespace for internal value tokens
|
||||
);
|
||||
})
|
||||
};
|
||||
|
||||
handlers.node(node);
|
||||
|
||||
20
node_modules/css-tree/lib/generator/token-before.js
generated
vendored
20
node_modules/css-tree/lib/generator/token-before.js
generated
vendored
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
WhiteSpace,
|
||||
Delim,
|
||||
Ident,
|
||||
Function as FunctionToken,
|
||||
@@ -20,17 +19,20 @@ import {
|
||||
const PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
|
||||
const HYPHENMINUS = 0x002D; // U+002D HYPHEN-MINUS (-)
|
||||
|
||||
// code:
|
||||
// 0xxxxxxx x0000000 - char code (0x80 for non-ASCII) or delim value
|
||||
// 00000000 0xxxxxx0 - token type (0 for delim, 1 for token)
|
||||
// 00000000 0000000x - reserved for carriage emit flag (0 for no space, 1 for space)
|
||||
const code = (type, value) => {
|
||||
if (type === Delim) {
|
||||
type = value;
|
||||
}
|
||||
|
||||
if (typeof type === 'string') {
|
||||
const charCode = type.charCodeAt(0);
|
||||
return charCode > 0x7F ? 0x8000 : charCode << 8;
|
||||
type = Math.min(type.charCodeAt(0), 0x80) << 6; // replace non-ASCII with 0x80
|
||||
}
|
||||
|
||||
return type;
|
||||
return type << 1;
|
||||
};
|
||||
|
||||
// https://www.w3.org/TR/css-syntax-3/#serialization
|
||||
@@ -167,14 +169,10 @@ function createMap(pairs) {
|
||||
type !== FunctionToken &&
|
||||
type !== CDC) ||
|
||||
(nextCharCode === PLUSSIGN)
|
||||
? isWhiteSpaceRequired.has(prevCode << 16 | nextCharCode << 8)
|
||||
: isWhiteSpaceRequired.has(prevCode << 16 | nextCode);
|
||||
? isWhiteSpaceRequired.has((prevCode & 0xFFFE) << 16 | nextCharCode << 7)
|
||||
: isWhiteSpaceRequired.has((prevCode & 0xFFFE) << 16 | nextCode);
|
||||
|
||||
if (emitWs) {
|
||||
this.emit(' ', WhiteSpace, true);
|
||||
}
|
||||
|
||||
return nextCode;
|
||||
return nextCode | emitWs;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
148
node_modules/css-tree/lib/lexer/generic.js
generated
vendored
148
node_modules/css-tree/lib/lexer/generic.js
generated
vendored
@@ -34,7 +34,91 @@ import {
|
||||
RightCurlyBracket
|
||||
} from '../tokenizer/index.js';
|
||||
|
||||
const calcFunctionNames = ['calc(', '-moz-calc(', '-webkit-calc('];
|
||||
// CSS mathematical functions categorized by return type behavior
|
||||
// See: https://www.w3.org/TR/css-values-4/#math
|
||||
|
||||
// Calculation functions that return different types depending on input
|
||||
const calcFunctionNames = [
|
||||
'calc(',
|
||||
'-moz-calc(',
|
||||
'-webkit-calc('
|
||||
];
|
||||
|
||||
// Comparison functions that return different types depending on input
|
||||
const comparisonFunctionNames = [
|
||||
'min(',
|
||||
'max(',
|
||||
'clamp('
|
||||
];
|
||||
|
||||
// Functions that return a stepped value, i.e. a value that is rounded to the nearest step
|
||||
const steppedValueFunctionNames = [
|
||||
'round(',
|
||||
'mod(',
|
||||
'rem('
|
||||
];
|
||||
|
||||
// Trigonometrical functions that return a <number>
|
||||
const trigNumberFunctionNames = [
|
||||
'sin(',
|
||||
'cos(',
|
||||
'tan('
|
||||
];
|
||||
|
||||
// Trigonometrical functions that return a <angle>
|
||||
const trigAngleFunctionNames = [
|
||||
'asin(',
|
||||
'acos(',
|
||||
'atan(',
|
||||
'atan2('
|
||||
];
|
||||
|
||||
// Other functions that return a <number>
|
||||
const otherNumberFunctionNames = [
|
||||
'pow(',
|
||||
'sqrt(',
|
||||
'log(',
|
||||
'exp(',
|
||||
'sign('
|
||||
];
|
||||
|
||||
// Exponential functions that return a <number> or <dimension> or <percentage>
|
||||
const expNumberDimensionPercentageFunctionNames = [
|
||||
'hypot('
|
||||
];
|
||||
|
||||
// Return the same type as the input
|
||||
const signFunctionNames = [
|
||||
'abs('
|
||||
];
|
||||
|
||||
const numberFunctionNames = [
|
||||
...calcFunctionNames,
|
||||
...comparisonFunctionNames,
|
||||
...steppedValueFunctionNames,
|
||||
...trigNumberFunctionNames,
|
||||
...otherNumberFunctionNames,
|
||||
...expNumberDimensionPercentageFunctionNames,
|
||||
...signFunctionNames
|
||||
];
|
||||
|
||||
const percentageFunctionNames = [
|
||||
...calcFunctionNames,
|
||||
...comparisonFunctionNames,
|
||||
...steppedValueFunctionNames,
|
||||
...expNumberDimensionPercentageFunctionNames,
|
||||
...signFunctionNames
|
||||
];
|
||||
|
||||
const dimensionFunctionNames = [
|
||||
...calcFunctionNames,
|
||||
...comparisonFunctionNames,
|
||||
...steppedValueFunctionNames,
|
||||
...trigAngleFunctionNames,
|
||||
...expNumberDimensionPercentageFunctionNames,
|
||||
...signFunctionNames
|
||||
];
|
||||
|
||||
const balancePair = new Map([
|
||||
[FunctionToken, RightParenthesis],
|
||||
[LeftParenthesis, RightParenthesis],
|
||||
@@ -141,16 +225,17 @@ function consumeFunction(token, getNextToken) {
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
// TODO: implement
|
||||
// can be used wherever <length>, <frequency>, <angle>, <time>, <percentage>, <number>, or <integer> values are allowed
|
||||
// https://drafts.csswg.org/css-values/#calc-notation
|
||||
function calc(next) {
|
||||
function math(next, functionNames) {
|
||||
return function(token, getNextToken, opts) {
|
||||
if (token === null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (token.type === FunctionToken && eqStrAny(token.value, calcFunctionNames)) {
|
||||
if (token.type === FunctionToken && eqStrAny(token.value, functionNames)) {
|
||||
return consumeFunction(token, getNextToken);
|
||||
}
|
||||
|
||||
@@ -557,12 +642,12 @@ export const productionTypes = {
|
||||
'ident': tokenType(Ident),
|
||||
|
||||
// percentage
|
||||
'percentage': calc(percentage),
|
||||
'percentage': math(percentage, percentageFunctionNames),
|
||||
|
||||
// numeric
|
||||
'zero': zero(),
|
||||
'number': calc(number),
|
||||
'integer': calc(integer),
|
||||
'number': math(number, numberFunctionNames),
|
||||
'integer': math(integer, numberFunctionNames),
|
||||
|
||||
// complex types
|
||||
'custom-ident': customIdent,
|
||||
@@ -601,15 +686,45 @@ export function createDemensionTypes(units) {
|
||||
} = units || {};
|
||||
|
||||
return {
|
||||
'dimension': calc(dimension(null)),
|
||||
'angle': calc(dimension(angle)),
|
||||
'decibel': calc(dimension(decibel)),
|
||||
'frequency': calc(dimension(frequency)),
|
||||
'flex': calc(dimension(flex)),
|
||||
'length': calc(zero(dimension(length))),
|
||||
'resolution': calc(dimension(resolution)),
|
||||
'semitones': calc(dimension(semitones)),
|
||||
'time': calc(dimension(time))
|
||||
'dimension': math(dimension(null), dimensionFunctionNames),
|
||||
'angle': math(dimension(angle), dimensionFunctionNames),
|
||||
'decibel': math(dimension(decibel), dimensionFunctionNames),
|
||||
'frequency': math(dimension(frequency), dimensionFunctionNames),
|
||||
'flex': math(dimension(flex), dimensionFunctionNames),
|
||||
'length': math(zero(dimension(length)), dimensionFunctionNames),
|
||||
'resolution': math(dimension(resolution), dimensionFunctionNames),
|
||||
'semitones': math(dimension(semitones), dimensionFunctionNames),
|
||||
'time': math(dimension(time), dimensionFunctionNames)
|
||||
};
|
||||
}
|
||||
|
||||
// The <attr-unit> production matches any identifier that is an ASCII case-insensitive
|
||||
// match for the name of a CSS dimension unit, such as px, or the <delim-token> %.
|
||||
function createAttrUnit(units) {
|
||||
const unitSet = new Set();
|
||||
|
||||
for (const group of unitGroups) {
|
||||
if (Array.isArray(units[group])) {
|
||||
for (const unit of units[group]) {
|
||||
unitSet.add(unit.toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return function attrUnit(token) {
|
||||
if (token === null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (token.type === Delim && token.value === '%') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (token.type === Ident && unitSet.has(token.value.toLowerCase())) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -617,6 +732,7 @@ export function createGenericTypes(units) {
|
||||
return {
|
||||
...tokenTypes,
|
||||
...productionTypes,
|
||||
...createDemensionTypes(units)
|
||||
...createDemensionTypes(units),
|
||||
'attr-unit': createAttrUnit(units)
|
||||
};
|
||||
};
|
||||
|
||||
88
node_modules/css-tree/lib/parser/create.js
generated
vendored
88
node_modules/css-tree/lib/parser/create.js
generated
vendored
@@ -29,6 +29,36 @@ const SEMICOLON = 0x003B; // U+003B SEMICOLON (;)
|
||||
const LEFTCURLYBRACKET = 0x007B; // U+007B LEFT CURLY BRACKET ({)
|
||||
const NULL = 0;
|
||||
|
||||
const arrayMethods = {
|
||||
createList() {
|
||||
return [];
|
||||
},
|
||||
createSingleNodeList(node) {
|
||||
return [node];
|
||||
},
|
||||
getFirstListNode(list) {
|
||||
return list && list[0] || null;
|
||||
},
|
||||
getLastListNode(list) {
|
||||
return list && list.length > 0 ? list[list.length - 1] : null;
|
||||
}
|
||||
};
|
||||
|
||||
const listMethods = {
|
||||
createList() {
|
||||
return new List();
|
||||
},
|
||||
createSingleNodeList(node) {
|
||||
return new List().appendData(node);
|
||||
},
|
||||
getFirstListNode(list) {
|
||||
return list && list.first;
|
||||
},
|
||||
getLastListNode(list) {
|
||||
return list && list.last;
|
||||
}
|
||||
};
|
||||
|
||||
function createParseContext(name) {
|
||||
return function() {
|
||||
return this[name]();
|
||||
@@ -109,18 +139,10 @@ export function createParser(config) {
|
||||
return code === SEMICOLON ? 2 : 0;
|
||||
},
|
||||
|
||||
createList() {
|
||||
return new List();
|
||||
},
|
||||
createSingleNodeList(node) {
|
||||
return new List().appendData(node);
|
||||
},
|
||||
getFirstListNode(list) {
|
||||
return list && list.first;
|
||||
},
|
||||
getLastListNode(list) {
|
||||
return list && list.last;
|
||||
},
|
||||
createList: NOOP,
|
||||
createSingleNodeList: NOOP,
|
||||
getFirstListNode: NOOP,
|
||||
getLastListNode: NOOP,
|
||||
|
||||
parseWithFallback(consumer, fallback) {
|
||||
const startIndex = this.tokenIndex;
|
||||
@@ -292,6 +314,36 @@ export function createParser(config) {
|
||||
);
|
||||
}
|
||||
});
|
||||
const createTokenIterateAPI = () => ({
|
||||
filename,
|
||||
source,
|
||||
tokenCount: parser.tokenCount,
|
||||
|
||||
getTokenType: (index) =>
|
||||
parser.getTokenType(index),
|
||||
getTokenTypeName: (index) =>
|
||||
tokenNames[parser.getTokenType(index)],
|
||||
getTokenStart: (index) =>
|
||||
parser.getTokenStart(index),
|
||||
getTokenEnd: (index) =>
|
||||
parser.getTokenEnd(index),
|
||||
getTokenValue: (index) =>
|
||||
parser.source.substring(parser.getTokenStart(index), parser.getTokenEnd(index)),
|
||||
|
||||
substring: (start, end) =>
|
||||
parser.source.substring(start, end),
|
||||
|
||||
balance: parser.balance.subarray(0, parser.tokenCount + 1),
|
||||
isBlockOpenerTokenType: parser.isBlockOpenerTokenType,
|
||||
isBlockCloserTokenType: parser.isBlockCloserTokenType,
|
||||
getBlockTokenPairIndex: (index) =>
|
||||
parser.getBlockTokenPairIndex(index),
|
||||
|
||||
getLocation: (offset) =>
|
||||
locationMap.getLocation(offset, filename),
|
||||
getRangeLocation: (start, end) =>
|
||||
locationMap.getLocationRange(start, end, filename)
|
||||
});
|
||||
|
||||
const parse = function(source_, options) {
|
||||
source = source_;
|
||||
@@ -315,12 +367,22 @@ export function createParser(config) {
|
||||
parser.parseValue = 'parseValue' in options ? Boolean(options.parseValue) : true;
|
||||
parser.parseCustomProperty = 'parseCustomProperty' in options ? Boolean(options.parseCustomProperty) : false;
|
||||
|
||||
const { context = 'default', onComment } = options;
|
||||
const { context = 'default', list = true, onComment, onToken } = options;
|
||||
|
||||
if (context in parser.context === false) {
|
||||
throw new Error('Unknown context `' + context + '`');
|
||||
}
|
||||
|
||||
Object.assign(parser, list ? listMethods : arrayMethods);
|
||||
|
||||
if (Array.isArray(onToken)) {
|
||||
parser.forEachToken((type, start, end) => {
|
||||
onToken.push({ type, start, end });
|
||||
});
|
||||
} else if (typeof onToken === 'function') {
|
||||
parser.forEachToken(onToken.bind(createTokenIterateAPI()));
|
||||
}
|
||||
|
||||
if (typeof onComment === 'function') {
|
||||
parser.forEachToken((type, start, end) => {
|
||||
if (type === Comment) {
|
||||
|
||||
49
node_modules/css-tree/lib/syntax/config/mix.js
generated
vendored
49
node_modules/css-tree/lib/syntax/config/mix.js
generated
vendored
@@ -8,23 +8,31 @@ function appendOrSet(a, b) {
|
||||
return b || null;
|
||||
}
|
||||
|
||||
function sliceProps(obj, props) {
|
||||
function extractProps(obj, props) {
|
||||
const result = Object.create(null);
|
||||
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
if (value) {
|
||||
result[key] = {};
|
||||
for (const prop of Object.keys(value)) {
|
||||
if (props.includes(prop)) {
|
||||
result[key][prop] = value[prop];
|
||||
}
|
||||
}
|
||||
for (const prop of Object.keys(obj)) {
|
||||
if (props.includes(prop)) {
|
||||
result[prop] = obj[prop];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function mergeDicts(base, ext, fields) {
|
||||
const result = { ...base };
|
||||
|
||||
for (const [key, props] of Object.entries(ext)) {
|
||||
result[key] = {
|
||||
...result[key],
|
||||
...fields ? extractProps(props, fields) : props
|
||||
};
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export default function mix(dest, src) {
|
||||
const result = { ...dest };
|
||||
|
||||
@@ -87,14 +95,6 @@ export default function mix(dest, src) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'scope':
|
||||
case 'features':
|
||||
result[prop] = { ...dest[prop] };
|
||||
for (const [name, props] of Object.entries(value)) {
|
||||
result[prop][name] = { ...result[prop][name], ...props };
|
||||
}
|
||||
break;
|
||||
|
||||
case 'parseContext':
|
||||
result[prop] = {
|
||||
...dest[prop],
|
||||
@@ -102,19 +102,18 @@ export default function mix(dest, src) {
|
||||
};
|
||||
break;
|
||||
|
||||
case 'scope':
|
||||
case 'features':
|
||||
result[prop] = mergeDicts(dest[prop], value);
|
||||
break;
|
||||
|
||||
case 'atrule':
|
||||
case 'pseudo':
|
||||
result[prop] = {
|
||||
...dest[prop],
|
||||
...sliceProps(value, ['parse'])
|
||||
};
|
||||
result[prop] = mergeDicts(dest[prop], value, ['parse']);
|
||||
break;
|
||||
|
||||
case 'node':
|
||||
result[prop] = {
|
||||
...dest[prop],
|
||||
...sliceProps(value, ['name', 'structure', 'parse', 'generate', 'walkContext'])
|
||||
};
|
||||
result[prop] = mergeDicts(dest[prop], value, ['name', 'structure', 'parse', 'generate', 'walkContext']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
64
node_modules/css-tree/lib/tokenizer/TokenStream.js
generated
vendored
64
node_modules/css-tree/lib/tokenizer/TokenStream.js
generated
vendored
@@ -17,14 +17,25 @@ import {
|
||||
|
||||
const OFFSET_MASK = 0x00FFFFFF;
|
||||
const TYPE_SHIFT = 24;
|
||||
const BLOCK_OPEN_TOKEN = 1;
|
||||
const BLOCK_CLOSE_TOKEN = 2;
|
||||
const balancePair = new Uint8Array(32); // 32b of memory ought to be enough for anyone (any number of tokens)
|
||||
balancePair[FunctionToken] = RightParenthesis;
|
||||
balancePair[LeftParenthesis] = RightParenthesis;
|
||||
balancePair[LeftSquareBracket] = RightSquareBracket;
|
||||
balancePair[LeftCurlyBracket] = RightCurlyBracket;
|
||||
|
||||
function isBlockOpenerToken(tokenType) {
|
||||
return balancePair[tokenType] !== 0;
|
||||
const blockTokens = new Uint8Array(32);
|
||||
blockTokens[FunctionToken] = BLOCK_OPEN_TOKEN;
|
||||
blockTokens[LeftParenthesis] = BLOCK_OPEN_TOKEN;
|
||||
blockTokens[LeftSquareBracket] = BLOCK_OPEN_TOKEN;
|
||||
blockTokens[LeftCurlyBracket] = BLOCK_OPEN_TOKEN;
|
||||
blockTokens[RightParenthesis] = BLOCK_CLOSE_TOKEN;
|
||||
blockTokens[RightSquareBracket] = BLOCK_CLOSE_TOKEN;
|
||||
blockTokens[RightCurlyBracket] = BLOCK_CLOSE_TOKEN;
|
||||
|
||||
function boundIndex(index, min, max) {
|
||||
return index < min ? min : index > max ? max : index;
|
||||
}
|
||||
|
||||
export class TokenStream {
|
||||
@@ -76,7 +87,7 @@ export class TokenStream {
|
||||
// pop state
|
||||
balanceStart = prevBalanceStart;
|
||||
balanceCloseType = balancePair[offsetAndType[prevBalanceStart] >> TYPE_SHIFT];
|
||||
} else if (isBlockOpenerToken(type)) { // check for FunctionToken, <(-token>, <[-token> and <{-token>
|
||||
} else if (this.isBlockOpenerTokenType(type)) { // check for FunctionToken, <(-token>, <[-token> and <{-token>
|
||||
// push state
|
||||
balanceStart = index;
|
||||
balanceCloseType = balancePair[type];
|
||||
@@ -194,14 +205,53 @@ export class TokenStream {
|
||||
|
||||
return this.firstCharOffset;
|
||||
}
|
||||
getTokenEnd(tokenIndex) {
|
||||
if (tokenIndex === this.tokenIndex) {
|
||||
return this.tokenEnd;
|
||||
}
|
||||
|
||||
return this.offsetAndType[boundIndex(tokenIndex, 0, this.tokenCount)] & OFFSET_MASK;
|
||||
}
|
||||
getTokenType(tokenIndex) {
|
||||
if (tokenIndex === this.tokenIndex) {
|
||||
return this.tokenType;
|
||||
}
|
||||
|
||||
return this.offsetAndType[boundIndex(tokenIndex, 0, this.tokenCount)] >> TYPE_SHIFT;
|
||||
}
|
||||
substrToCursor(start) {
|
||||
return this.source.substring(start, this.tokenStart);
|
||||
}
|
||||
|
||||
isBalanceEdge(pos) {
|
||||
return this.balance[this.tokenIndex] < pos;
|
||||
// return this.balance[this.balance[pos]] !== this.tokenIndex;
|
||||
isBlockOpenerTokenType(tokenType) {
|
||||
return blockTokens[tokenType] === BLOCK_OPEN_TOKEN;
|
||||
}
|
||||
isBlockCloserTokenType(tokenType) {
|
||||
return blockTokens[tokenType] === BLOCK_CLOSE_TOKEN;
|
||||
}
|
||||
getBlockTokenPairIndex(tokenIndex) {
|
||||
const type = this.getTokenType(tokenIndex);
|
||||
|
||||
if (blockTokens[type] === 1) {
|
||||
// block open token
|
||||
const pairIndex = this.balance[tokenIndex];
|
||||
const closeType = this.getTokenType(pairIndex);
|
||||
|
||||
return balancePair[type] === closeType ? pairIndex : -1;
|
||||
} else if (blockTokens[type] === 2) {
|
||||
// block close token
|
||||
const pairIndex = this.balance[tokenIndex];
|
||||
const openType = this.getTokenType(pairIndex);
|
||||
|
||||
return balancePair[openType] === type ? pairIndex : -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
isBalanceEdge(tokenIndex) {
|
||||
return this.balance[this.tokenIndex] < tokenIndex;
|
||||
}
|
||||
|
||||
isDelim(code, offset) {
|
||||
if (offset) {
|
||||
return (
|
||||
@@ -278,7 +328,7 @@ export class TokenStream {
|
||||
|
||||
default:
|
||||
// fast forward to the end of balanced block for an open block tokens
|
||||
if (isBlockOpenerToken(this.offsetAndType[cursor] >> TYPE_SHIFT)) {
|
||||
if (this.isBlockOpenerTokenType(this.offsetAndType[cursor] >> TYPE_SHIFT)) {
|
||||
cursor = balanceEnd;
|
||||
}
|
||||
}
|
||||
|
||||
15
node_modules/css-tree/package.json
generated
vendored
15
node_modules/css-tree/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "css-tree",
|
||||
"version": "3.1.0",
|
||||
"version": "3.2.1",
|
||||
"description": "A tool set for CSS: fast detailed parser (CSS → AST), walker (AST traversal), generator (AST → CSS) and lexer (validation and matching) based on specs and browser implementations",
|
||||
"author": "Roman Dvornov <rdvornov@gmail.com> (https://github.com/lahmatiy)",
|
||||
"license": "MIT",
|
||||
@@ -19,6 +19,7 @@
|
||||
],
|
||||
"type": "module",
|
||||
"module": "./lib/index.js",
|
||||
"sideEffects": false,
|
||||
"main": "./cjs/index.cjs",
|
||||
"exports": {
|
||||
".": {
|
||||
@@ -99,17 +100,17 @@
|
||||
"prepublishOnly": "npm run lint-and-test && npm run build-and-test"
|
||||
},
|
||||
"dependencies": {
|
||||
"mdn-data": "2.12.2",
|
||||
"source-map-js": "^1.0.1"
|
||||
"mdn-data": "2.27.1",
|
||||
"source-map-js": "^1.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"c8": "^7.12.0",
|
||||
"c8": "^11.0.0",
|
||||
"clap": "^2.0.1",
|
||||
"esbuild": "^0.24.0",
|
||||
"eslint": "^8.4.1",
|
||||
"esbuild": "^0.27.3",
|
||||
"eslint": "^8.50.0",
|
||||
"json-to-ast": "^2.1.0",
|
||||
"mocha": "^9.2.2",
|
||||
"rollup": "^2.79.2"
|
||||
"rollup": "^2.80.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0"
|
||||
|
||||
Reference in New Issue
Block a user