Fix code quality violations and exclude Manifest from checks
Document application modes (development/debug/production) Add global file drop handler, order column normalization, SPA hash fix Serve CDN assets via /_vendor/ URLs instead of merging into bundles Add production minification with license preservation Improve JSON formatting for debugging and production optimization Add CDN asset caching with CSS URL inlining for production builds Add three-mode system (development, debug, production) Update Manifest CLAUDE.md to reflect helper class architecture Refactor Manifest.php into helper classes for better organization Pre-manifest-refactor checkpoint: Add app_mode documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
415
node_modules/css-tree/lib/syntax/node/AnPlusB.js
generated
vendored
415
node_modules/css-tree/lib/syntax/node/AnPlusB.js
generated
vendored
@@ -1,21 +1,21 @@
|
||||
var cmpChar = require('../../tokenizer').cmpChar;
|
||||
var isDigit = require('../../tokenizer').isDigit;
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import {
|
||||
isDigit,
|
||||
WhiteSpace,
|
||||
Comment,
|
||||
Ident,
|
||||
Number,
|
||||
Dimension
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
var WHITESPACE = TYPE.WhiteSpace;
|
||||
var COMMENT = TYPE.Comment;
|
||||
var IDENT = TYPE.Ident;
|
||||
var NUMBER = TYPE.Number;
|
||||
var DIMENSION = TYPE.Dimension;
|
||||
var PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
|
||||
var HYPHENMINUS = 0x002D; // U+002D HYPHEN-MINUS (-)
|
||||
var N = 0x006E; // U+006E LATIN SMALL LETTER N (n)
|
||||
var DISALLOW_SIGN = true;
|
||||
var ALLOW_SIGN = false;
|
||||
const PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
|
||||
const HYPHENMINUS = 0x002D; // U+002D HYPHEN-MINUS (-)
|
||||
const N = 0x006E; // U+006E LATIN SMALL LETTER N (n)
|
||||
const DISALLOW_SIGN = true;
|
||||
const ALLOW_SIGN = false;
|
||||
|
||||
function checkInteger(offset, disallowSign) {
|
||||
var pos = this.scanner.tokenStart + offset;
|
||||
var code = this.scanner.source.charCodeAt(pos);
|
||||
let pos = this.tokenStart + offset;
|
||||
const code = this.charCodeAt(pos);
|
||||
|
||||
if (code === PLUSSIGN || code === HYPHENMINUS) {
|
||||
if (disallowSign) {
|
||||
@@ -24,8 +24,8 @@ function checkInteger(offset, disallowSign) {
|
||||
pos++;
|
||||
}
|
||||
|
||||
for (; pos < this.scanner.tokenEnd; pos++) {
|
||||
if (!isDigit(this.scanner.source.charCodeAt(pos))) {
|
||||
for (; pos < this.tokenEnd; pos++) {
|
||||
if (!isDigit(this.charCodeAt(pos))) {
|
||||
this.error('Integer is expected', pos);
|
||||
}
|
||||
}
|
||||
@@ -36,8 +36,8 @@ function checkTokenIsInteger(disallowSign) {
|
||||
}
|
||||
|
||||
function expectCharCode(offset, code) {
|
||||
if (!cmpChar(this.scanner.source, this.scanner.tokenStart + offset, code)) {
|
||||
var msg = '';
|
||||
if (!this.cmpChar(this.tokenStart + offset, code)) {
|
||||
let msg = '';
|
||||
|
||||
switch (code) {
|
||||
case N:
|
||||
@@ -48,32 +48,32 @@ function expectCharCode(offset, code) {
|
||||
break;
|
||||
}
|
||||
|
||||
this.error(msg, this.scanner.tokenStart + offset);
|
||||
this.error(msg, this.tokenStart + offset);
|
||||
}
|
||||
}
|
||||
|
||||
// ... <signed-integer>
|
||||
// ... ['+' | '-'] <signless-integer>
|
||||
function consumeB() {
|
||||
var offset = 0;
|
||||
var sign = 0;
|
||||
var type = this.scanner.tokenType;
|
||||
let offset = 0;
|
||||
let sign = 0;
|
||||
let type = this.tokenType;
|
||||
|
||||
while (type === WHITESPACE || type === COMMENT) {
|
||||
type = this.scanner.lookupType(++offset);
|
||||
while (type === WhiteSpace || type === Comment) {
|
||||
type = this.lookupType(++offset);
|
||||
}
|
||||
|
||||
if (type !== NUMBER) {
|
||||
if (this.scanner.isDelim(PLUSSIGN, offset) ||
|
||||
this.scanner.isDelim(HYPHENMINUS, offset)) {
|
||||
sign = this.scanner.isDelim(PLUSSIGN, offset) ? PLUSSIGN : HYPHENMINUS;
|
||||
if (type !== Number) {
|
||||
if (this.isDelim(PLUSSIGN, offset) ||
|
||||
this.isDelim(HYPHENMINUS, offset)) {
|
||||
sign = this.isDelim(PLUSSIGN, offset) ? PLUSSIGN : HYPHENMINUS;
|
||||
|
||||
do {
|
||||
type = this.scanner.lookupType(++offset);
|
||||
} while (type === WHITESPACE || type === COMMENT);
|
||||
type = this.lookupType(++offset);
|
||||
} while (type === WhiteSpace || type === Comment);
|
||||
|
||||
if (type !== NUMBER) {
|
||||
this.scanner.skip(offset);
|
||||
if (type !== Number) {
|
||||
this.skip(offset);
|
||||
checkTokenIsInteger.call(this, DISALLOW_SIGN);
|
||||
}
|
||||
} else {
|
||||
@@ -82,216 +82,211 @@ function consumeB() {
|
||||
}
|
||||
|
||||
if (offset > 0) {
|
||||
this.scanner.skip(offset);
|
||||
this.skip(offset);
|
||||
}
|
||||
|
||||
if (sign === 0) {
|
||||
type = this.scanner.source.charCodeAt(this.scanner.tokenStart);
|
||||
type = this.charCodeAt(this.tokenStart);
|
||||
if (type !== PLUSSIGN && type !== HYPHENMINUS) {
|
||||
this.error('Number sign is expected');
|
||||
}
|
||||
}
|
||||
|
||||
checkTokenIsInteger.call(this, sign !== 0);
|
||||
return sign === HYPHENMINUS ? '-' + this.consume(NUMBER) : this.consume(NUMBER);
|
||||
return sign === HYPHENMINUS ? '-' + this.consume(Number) : this.consume(Number);
|
||||
}
|
||||
|
||||
// An+B microsyntax https://www.w3.org/TR/css-syntax-3/#anb
|
||||
module.exports = {
|
||||
name: 'AnPlusB',
|
||||
structure: {
|
||||
a: [String, null],
|
||||
b: [String, null]
|
||||
},
|
||||
parse: function() {
|
||||
/* eslint-disable brace-style*/
|
||||
var start = this.scanner.tokenStart;
|
||||
var a = null;
|
||||
var b = null;
|
||||
export const name = 'AnPlusB';
|
||||
export const structure = {
|
||||
a: [String, null],
|
||||
b: [String, null]
|
||||
};
|
||||
|
||||
// <integer>
|
||||
if (this.scanner.tokenType === NUMBER) {
|
||||
checkTokenIsInteger.call(this, ALLOW_SIGN);
|
||||
b = this.consume(NUMBER);
|
||||
export function parse() {
|
||||
/* eslint-disable brace-style*/
|
||||
const start = this.tokenStart;
|
||||
let a = null;
|
||||
let b = null;
|
||||
|
||||
// <integer>
|
||||
if (this.tokenType === Number) {
|
||||
checkTokenIsInteger.call(this, ALLOW_SIGN);
|
||||
b = this.consume(Number);
|
||||
}
|
||||
|
||||
// -n
|
||||
// -n <signed-integer>
|
||||
// -n ['+' | '-'] <signless-integer>
|
||||
// -n- <signless-integer>
|
||||
// <dashndashdigit-ident>
|
||||
else if (this.tokenType === Ident && this.cmpChar(this.tokenStart, HYPHENMINUS)) {
|
||||
a = '-1';
|
||||
|
||||
expectCharCode.call(this, 1, N);
|
||||
|
||||
switch (this.tokenEnd - this.tokenStart) {
|
||||
// -n
|
||||
// -n <signed-integer>
|
||||
// -n ['+' | '-'] <signless-integer>
|
||||
case 2:
|
||||
this.next();
|
||||
b = consumeB.call(this);
|
||||
break;
|
||||
|
||||
// -n- <signless-integer>
|
||||
case 3:
|
||||
expectCharCode.call(this, 2, HYPHENMINUS);
|
||||
|
||||
this.next();
|
||||
this.skipSC();
|
||||
|
||||
checkTokenIsInteger.call(this, DISALLOW_SIGN);
|
||||
|
||||
b = '-' + this.consume(Number);
|
||||
break;
|
||||
|
||||
// <dashndashdigit-ident>
|
||||
default:
|
||||
expectCharCode.call(this, 2, HYPHENMINUS);
|
||||
checkInteger.call(this, 3, DISALLOW_SIGN);
|
||||
this.next();
|
||||
|
||||
b = this.substrToCursor(start + 2);
|
||||
}
|
||||
}
|
||||
|
||||
// '+'? n
|
||||
// '+'? n <signed-integer>
|
||||
// '+'? n ['+' | '-'] <signless-integer>
|
||||
// '+'? n- <signless-integer>
|
||||
// '+'? <ndashdigit-ident>
|
||||
else if (this.tokenType === Ident || (this.isDelim(PLUSSIGN) && this.lookupType(1) === Ident)) {
|
||||
let sign = 0;
|
||||
a = '1';
|
||||
|
||||
// just ignore a plus
|
||||
if (this.isDelim(PLUSSIGN)) {
|
||||
sign = 1;
|
||||
this.next();
|
||||
}
|
||||
|
||||
// -n
|
||||
// -n <signed-integer>
|
||||
// -n ['+' | '-'] <signless-integer>
|
||||
// -n- <signless-integer>
|
||||
// <dashndashdigit-ident>
|
||||
else if (this.scanner.tokenType === IDENT && cmpChar(this.scanner.source, this.scanner.tokenStart, HYPHENMINUS)) {
|
||||
a = '-1';
|
||||
expectCharCode.call(this, 0, N);
|
||||
|
||||
expectCharCode.call(this, 1, N);
|
||||
switch (this.tokenEnd - this.tokenStart) {
|
||||
// '+'? n
|
||||
// '+'? n <signed-integer>
|
||||
// '+'? n ['+' | '-'] <signless-integer>
|
||||
case 1:
|
||||
this.next();
|
||||
b = consumeB.call(this);
|
||||
break;
|
||||
|
||||
switch (this.scanner.getTokenLength()) {
|
||||
// -n
|
||||
// -n <signed-integer>
|
||||
// -n ['+' | '-'] <signless-integer>
|
||||
case 2:
|
||||
this.scanner.next();
|
||||
b = consumeB.call(this);
|
||||
break;
|
||||
// '+'? n- <signless-integer>
|
||||
case 2:
|
||||
expectCharCode.call(this, 1, HYPHENMINUS);
|
||||
|
||||
// -n- <signless-integer>
|
||||
case 3:
|
||||
expectCharCode.call(this, 2, HYPHENMINUS);
|
||||
this.next();
|
||||
this.skipSC();
|
||||
|
||||
this.scanner.next();
|
||||
this.scanner.skipSC();
|
||||
checkTokenIsInteger.call(this, DISALLOW_SIGN);
|
||||
|
||||
checkTokenIsInteger.call(this, DISALLOW_SIGN);
|
||||
b = '-' + this.consume(Number);
|
||||
break;
|
||||
|
||||
b = '-' + this.consume(NUMBER);
|
||||
break;
|
||||
// '+'? <ndashdigit-ident>
|
||||
default:
|
||||
expectCharCode.call(this, 1, HYPHENMINUS);
|
||||
checkInteger.call(this, 2, DISALLOW_SIGN);
|
||||
this.next();
|
||||
|
||||
// <dashndashdigit-ident>
|
||||
default:
|
||||
expectCharCode.call(this, 2, HYPHENMINUS);
|
||||
checkInteger.call(this, 3, DISALLOW_SIGN);
|
||||
this.scanner.next();
|
||||
b = this.substrToCursor(start + sign + 1);
|
||||
}
|
||||
}
|
||||
|
||||
b = this.scanner.substrToCursor(start + 2);
|
||||
// <ndashdigit-dimension>
|
||||
// <ndash-dimension> <signless-integer>
|
||||
// <n-dimension>
|
||||
// <n-dimension> <signed-integer>
|
||||
// <n-dimension> ['+' | '-'] <signless-integer>
|
||||
else if (this.tokenType === Dimension) {
|
||||
const code = this.charCodeAt(this.tokenStart);
|
||||
const sign = code === PLUSSIGN || code === HYPHENMINUS;
|
||||
let i = this.tokenStart + sign;
|
||||
|
||||
for (; i < this.tokenEnd; i++) {
|
||||
if (!isDigit(this.charCodeAt(i))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// '+'? n
|
||||
// '+'? n <signed-integer>
|
||||
// '+'? n ['+' | '-'] <signless-integer>
|
||||
// '+'? n- <signless-integer>
|
||||
// '+'? <ndashdigit-ident>
|
||||
else if (this.scanner.tokenType === IDENT || (this.scanner.isDelim(PLUSSIGN) && this.scanner.lookupType(1) === IDENT)) {
|
||||
var sign = 0;
|
||||
a = '1';
|
||||
|
||||
// just ignore a plus
|
||||
if (this.scanner.isDelim(PLUSSIGN)) {
|
||||
sign = 1;
|
||||
this.scanner.next();
|
||||
}
|
||||
|
||||
expectCharCode.call(this, 0, N);
|
||||
|
||||
switch (this.scanner.getTokenLength()) {
|
||||
// '+'? n
|
||||
// '+'? n <signed-integer>
|
||||
// '+'? n ['+' | '-'] <signless-integer>
|
||||
case 1:
|
||||
this.scanner.next();
|
||||
b = consumeB.call(this);
|
||||
break;
|
||||
|
||||
// '+'? n- <signless-integer>
|
||||
case 2:
|
||||
expectCharCode.call(this, 1, HYPHENMINUS);
|
||||
|
||||
this.scanner.next();
|
||||
this.scanner.skipSC();
|
||||
|
||||
checkTokenIsInteger.call(this, DISALLOW_SIGN);
|
||||
|
||||
b = '-' + this.consume(NUMBER);
|
||||
break;
|
||||
|
||||
// '+'? <ndashdigit-ident>
|
||||
default:
|
||||
expectCharCode.call(this, 1, HYPHENMINUS);
|
||||
checkInteger.call(this, 2, DISALLOW_SIGN);
|
||||
this.scanner.next();
|
||||
|
||||
b = this.scanner.substrToCursor(start + sign + 1);
|
||||
}
|
||||
if (i === this.tokenStart + sign) {
|
||||
this.error('Integer is expected', this.tokenStart + sign);
|
||||
}
|
||||
|
||||
// <ndashdigit-dimension>
|
||||
// <ndash-dimension> <signless-integer>
|
||||
expectCharCode.call(this, i - this.tokenStart, N);
|
||||
a = this.substring(start, i);
|
||||
|
||||
// <n-dimension>
|
||||
// <n-dimension> <signed-integer>
|
||||
// <n-dimension> ['+' | '-'] <signless-integer>
|
||||
else if (this.scanner.tokenType === DIMENSION) {
|
||||
var code = this.scanner.source.charCodeAt(this.scanner.tokenStart);
|
||||
var sign = code === PLUSSIGN || code === HYPHENMINUS;
|
||||
|
||||
for (var i = this.scanner.tokenStart + sign; i < this.scanner.tokenEnd; i++) {
|
||||
if (!isDigit(this.scanner.source.charCodeAt(i))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i === this.scanner.tokenStart + sign) {
|
||||
this.error('Integer is expected', this.scanner.tokenStart + sign);
|
||||
}
|
||||
|
||||
expectCharCode.call(this, i - this.scanner.tokenStart, N);
|
||||
a = this.scanner.source.substring(start, i);
|
||||
|
||||
// <n-dimension>
|
||||
// <n-dimension> <signed-integer>
|
||||
// <n-dimension> ['+' | '-'] <signless-integer>
|
||||
if (i + 1 === this.scanner.tokenEnd) {
|
||||
this.scanner.next();
|
||||
b = consumeB.call(this);
|
||||
} else {
|
||||
expectCharCode.call(this, i - this.scanner.tokenStart + 1, HYPHENMINUS);
|
||||
|
||||
// <ndash-dimension> <signless-integer>
|
||||
if (i + 2 === this.scanner.tokenEnd) {
|
||||
this.scanner.next();
|
||||
this.scanner.skipSC();
|
||||
checkTokenIsInteger.call(this, DISALLOW_SIGN);
|
||||
b = '-' + this.consume(NUMBER);
|
||||
}
|
||||
// <ndashdigit-dimension>
|
||||
else {
|
||||
checkInteger.call(this, i - this.scanner.tokenStart + 2, DISALLOW_SIGN);
|
||||
this.scanner.next();
|
||||
b = this.scanner.substrToCursor(i + 1);
|
||||
}
|
||||
}
|
||||
if (i + 1 === this.tokenEnd) {
|
||||
this.next();
|
||||
b = consumeB.call(this);
|
||||
} else {
|
||||
this.error();
|
||||
}
|
||||
expectCharCode.call(this, i - this.tokenStart + 1, HYPHENMINUS);
|
||||
|
||||
if (a !== null && a.charCodeAt(0) === PLUSSIGN) {
|
||||
a = a.substr(1);
|
||||
}
|
||||
|
||||
if (b !== null && b.charCodeAt(0) === PLUSSIGN) {
|
||||
b = b.substr(1);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'AnPlusB',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
a: a,
|
||||
b: b
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
var a = node.a !== null && node.a !== undefined;
|
||||
var b = node.b !== null && node.b !== undefined;
|
||||
|
||||
if (a) {
|
||||
this.chunk(
|
||||
node.a === '+1' ? '+n' : // eslint-disable-line operator-linebreak, indent
|
||||
node.a === '1' ? 'n' : // eslint-disable-line operator-linebreak, indent
|
||||
node.a === '-1' ? '-n' : // eslint-disable-line operator-linebreak, indent
|
||||
node.a + 'n' // eslint-disable-line operator-linebreak, indent
|
||||
);
|
||||
|
||||
if (b) {
|
||||
b = String(node.b);
|
||||
if (b.charAt(0) === '-' || b.charAt(0) === '+') {
|
||||
this.chunk(b.charAt(0));
|
||||
this.chunk(b.substr(1));
|
||||
} else {
|
||||
this.chunk('+');
|
||||
this.chunk(b);
|
||||
}
|
||||
// <ndash-dimension> <signless-integer>
|
||||
if (i + 2 === this.tokenEnd) {
|
||||
this.next();
|
||||
this.skipSC();
|
||||
checkTokenIsInteger.call(this, DISALLOW_SIGN);
|
||||
b = '-' + this.consume(Number);
|
||||
}
|
||||
// <ndashdigit-dimension>
|
||||
else {
|
||||
checkInteger.call(this, i - this.tokenStart + 2, DISALLOW_SIGN);
|
||||
this.next();
|
||||
b = this.substrToCursor(i + 1);
|
||||
}
|
||||
} else {
|
||||
this.chunk(String(node.b));
|
||||
}
|
||||
} else {
|
||||
this.error();
|
||||
}
|
||||
};
|
||||
|
||||
if (a !== null && a.charCodeAt(0) === PLUSSIGN) {
|
||||
a = a.substr(1);
|
||||
}
|
||||
|
||||
if (b !== null && b.charCodeAt(0) === PLUSSIGN) {
|
||||
b = b.substr(1);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'AnPlusB',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
a,
|
||||
b
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
if (node.a) {
|
||||
const a =
|
||||
node.a === '+1' && 'n' ||
|
||||
node.a === '1' && 'n' ||
|
||||
node.a === '-1' && '-n' ||
|
||||
node.a + 'n';
|
||||
|
||||
if (node.b) {
|
||||
const b = node.b[0] === '-' || node.b[0] === '+'
|
||||
? node.b
|
||||
: '+' + node.b;
|
||||
this.tokenize(a + b);
|
||||
} else {
|
||||
this.tokenize(a);
|
||||
}
|
||||
} else {
|
||||
this.tokenize(node.b);
|
||||
}
|
||||
}
|
||||
|
||||
157
node_modules/css-tree/lib/syntax/node/Atrule.js
generated
vendored
157
node_modules/css-tree/lib/syntax/node/Atrule.js
generated
vendored
@@ -1,23 +1,22 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
var rawMode = require('./Raw').mode;
|
||||
import {
|
||||
AtKeyword,
|
||||
Semicolon,
|
||||
LeftCurlyBracket,
|
||||
RightCurlyBracket
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
var ATKEYWORD = TYPE.AtKeyword;
|
||||
var SEMICOLON = TYPE.Semicolon;
|
||||
var LEFTCURLYBRACKET = TYPE.LeftCurlyBracket;
|
||||
var RIGHTCURLYBRACKET = TYPE.RightCurlyBracket;
|
||||
|
||||
function consumeRaw(startToken) {
|
||||
return this.Raw(startToken, rawMode.leftCurlyBracketOrSemicolon, true);
|
||||
function consumeRaw() {
|
||||
return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon, true);
|
||||
}
|
||||
|
||||
function isDeclarationBlockAtrule() {
|
||||
for (var offset = 1, type; type = this.scanner.lookupType(offset); offset++) {
|
||||
if (type === RIGHTCURLYBRACKET) {
|
||||
for (let offset = 1, type; type = this.lookupType(offset); offset++) {
|
||||
if (type === RightCurlyBracket) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (type === LEFTCURLYBRACKET ||
|
||||
type === ATKEYWORD) {
|
||||
if (type === LeftCurlyBracket ||
|
||||
type === AtKeyword) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -25,83 +24,77 @@ function isDeclarationBlockAtrule() {
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'Atrule',
|
||||
structure: {
|
||||
name: String,
|
||||
prelude: ['AtrulePrelude', 'Raw', null],
|
||||
block: ['Block', null]
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
var name;
|
||||
var nameLowerCase;
|
||||
var prelude = null;
|
||||
var block = null;
|
||||
|
||||
this.eat(ATKEYWORD);
|
||||
export const name = 'Atrule';
|
||||
export const walkContext = 'atrule';
|
||||
export const structure = {
|
||||
name: String,
|
||||
prelude: ['AtrulePrelude', 'Raw', null],
|
||||
block: ['Block', null]
|
||||
};
|
||||
|
||||
name = this.scanner.substrToCursor(start + 1);
|
||||
nameLowerCase = name.toLowerCase();
|
||||
this.scanner.skipSC();
|
||||
export function parse(isDeclaration = false) {
|
||||
const start = this.tokenStart;
|
||||
let name;
|
||||
let nameLowerCase;
|
||||
let prelude = null;
|
||||
let block = null;
|
||||
|
||||
// parse prelude
|
||||
if (this.scanner.eof === false &&
|
||||
this.scanner.tokenType !== LEFTCURLYBRACKET &&
|
||||
this.scanner.tokenType !== SEMICOLON) {
|
||||
if (this.parseAtrulePrelude) {
|
||||
prelude = this.parseWithFallback(this.AtrulePrelude.bind(this, name), consumeRaw);
|
||||
this.eat(AtKeyword);
|
||||
|
||||
// turn empty AtrulePrelude into null
|
||||
if (prelude.type === 'AtrulePrelude' && prelude.children.head === null) {
|
||||
prelude = null;
|
||||
}
|
||||
name = this.substrToCursor(start + 1);
|
||||
nameLowerCase = name.toLowerCase();
|
||||
this.skipSC();
|
||||
|
||||
// parse prelude
|
||||
if (this.eof === false &&
|
||||
this.tokenType !== LeftCurlyBracket &&
|
||||
this.tokenType !== Semicolon) {
|
||||
if (this.parseAtrulePrelude) {
|
||||
prelude = this.parseWithFallback(this.AtrulePrelude.bind(this, name, isDeclaration), consumeRaw);
|
||||
} else {
|
||||
prelude = consumeRaw.call(this, this.tokenIndex);
|
||||
}
|
||||
|
||||
this.skipSC();
|
||||
}
|
||||
|
||||
switch (this.tokenType) {
|
||||
case Semicolon:
|
||||
this.next();
|
||||
break;
|
||||
|
||||
case LeftCurlyBracket:
|
||||
if (hasOwnProperty.call(this.atrule, nameLowerCase) &&
|
||||
typeof this.atrule[nameLowerCase].block === 'function') {
|
||||
block = this.atrule[nameLowerCase].block.call(this, isDeclaration);
|
||||
} else {
|
||||
prelude = consumeRaw.call(this, this.scanner.tokenIndex);
|
||||
// TODO: should consume block content as Raw?
|
||||
block = this.Block(isDeclarationBlockAtrule.call(this));
|
||||
}
|
||||
|
||||
this.scanner.skipSC();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
switch (this.scanner.tokenType) {
|
||||
case SEMICOLON:
|
||||
this.scanner.next();
|
||||
break;
|
||||
return {
|
||||
type: 'Atrule',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
name,
|
||||
prelude,
|
||||
block
|
||||
};
|
||||
}
|
||||
|
||||
case LEFTCURLYBRACKET:
|
||||
if (this.atrule.hasOwnProperty(nameLowerCase) &&
|
||||
typeof this.atrule[nameLowerCase].block === 'function') {
|
||||
block = this.atrule[nameLowerCase].block.call(this);
|
||||
} else {
|
||||
// TODO: should consume block content as Raw?
|
||||
block = this.Block(isDeclarationBlockAtrule.call(this));
|
||||
}
|
||||
export function generate(node) {
|
||||
this.token(AtKeyword, '@' + node.name);
|
||||
|
||||
break;
|
||||
}
|
||||
if (node.prelude !== null) {
|
||||
this.node(node.prelude);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Atrule',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
name: name,
|
||||
prelude: prelude,
|
||||
block: block
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk('@');
|
||||
this.chunk(node.name);
|
||||
|
||||
if (node.prelude !== null) {
|
||||
this.chunk(' ');
|
||||
this.node(node.prelude);
|
||||
}
|
||||
|
||||
if (node.block) {
|
||||
this.node(node.block);
|
||||
} else {
|
||||
this.chunk(';');
|
||||
}
|
||||
},
|
||||
walkContext: 'atrule'
|
||||
};
|
||||
if (node.block) {
|
||||
this.node(node.block);
|
||||
} else {
|
||||
this.token(Semicolon, ';');
|
||||
}
|
||||
}
|
||||
|
||||
94
node_modules/css-tree/lib/syntax/node/AtrulePrelude.js
generated
vendored
94
node_modules/css-tree/lib/syntax/node/AtrulePrelude.js
generated
vendored
@@ -1,51 +1,47 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import {
|
||||
Semicolon,
|
||||
LeftCurlyBracket
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
var SEMICOLON = TYPE.Semicolon;
|
||||
var LEFTCURLYBRACKET = TYPE.LeftCurlyBracket;
|
||||
|
||||
module.exports = {
|
||||
name: 'AtrulePrelude',
|
||||
structure: {
|
||||
children: [[]]
|
||||
},
|
||||
parse: function(name) {
|
||||
var children = null;
|
||||
|
||||
if (name !== null) {
|
||||
name = name.toLowerCase();
|
||||
}
|
||||
|
||||
this.scanner.skipSC();
|
||||
|
||||
if (this.atrule.hasOwnProperty(name) &&
|
||||
typeof this.atrule[name].prelude === 'function') {
|
||||
// custom consumer
|
||||
children = this.atrule[name].prelude.call(this);
|
||||
} else {
|
||||
// default consumer
|
||||
children = this.readSequence(this.scope.AtrulePrelude);
|
||||
}
|
||||
|
||||
this.scanner.skipSC();
|
||||
|
||||
if (this.scanner.eof !== true &&
|
||||
this.scanner.tokenType !== LEFTCURLYBRACKET &&
|
||||
this.scanner.tokenType !== SEMICOLON) {
|
||||
this.error('Semicolon or block is expected');
|
||||
}
|
||||
|
||||
if (children === null) {
|
||||
children = this.createList();
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'AtrulePrelude',
|
||||
loc: this.getLocationFromList(children),
|
||||
children: children
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.children(node);
|
||||
},
|
||||
walkContext: 'atrulePrelude'
|
||||
export const name = 'AtrulePrelude';
|
||||
export const walkContext = 'atrulePrelude';
|
||||
export const structure = {
|
||||
children: [[]]
|
||||
};
|
||||
|
||||
export function parse(name) {
|
||||
let children = null;
|
||||
|
||||
if (name !== null) {
|
||||
name = name.toLowerCase();
|
||||
}
|
||||
|
||||
this.skipSC();
|
||||
|
||||
if (hasOwnProperty.call(this.atrule, name) &&
|
||||
typeof this.atrule[name].prelude === 'function') {
|
||||
// custom consumer
|
||||
children = this.atrule[name].prelude.call(this);
|
||||
} else {
|
||||
// default consumer
|
||||
children = this.readSequence(this.scope.AtrulePrelude);
|
||||
}
|
||||
|
||||
this.skipSC();
|
||||
|
||||
if (this.eof !== true &&
|
||||
this.tokenType !== LeftCurlyBracket &&
|
||||
this.tokenType !== Semicolon) {
|
||||
this.error('Semicolon or block is expected');
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'AtrulePrelude',
|
||||
loc: this.getLocationFromList(children),
|
||||
children
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.children(node);
|
||||
}
|
||||
|
||||
222
node_modules/css-tree/lib/syntax/node/AttributeSelector.js
generated
vendored
222
node_modules/css-tree/lib/syntax/node/AttributeSelector.js
generated
vendored
@@ -1,60 +1,54 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import {
|
||||
Ident,
|
||||
String as StringToken,
|
||||
Delim,
|
||||
LeftSquareBracket,
|
||||
RightSquareBracket
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
var IDENT = TYPE.Ident;
|
||||
var STRING = TYPE.String;
|
||||
var COLON = TYPE.Colon;
|
||||
var LEFTSQUAREBRACKET = TYPE.LeftSquareBracket;
|
||||
var RIGHTSQUAREBRACKET = TYPE.RightSquareBracket;
|
||||
var DOLLARSIGN = 0x0024; // U+0024 DOLLAR SIGN ($)
|
||||
var ASTERISK = 0x002A; // U+002A ASTERISK (*)
|
||||
var EQUALSSIGN = 0x003D; // U+003D EQUALS SIGN (=)
|
||||
var CIRCUMFLEXACCENT = 0x005E; // U+005E (^)
|
||||
var VERTICALLINE = 0x007C; // U+007C VERTICAL LINE (|)
|
||||
var TILDE = 0x007E; // U+007E TILDE (~)
|
||||
const DOLLARSIGN = 0x0024; // U+0024 DOLLAR SIGN ($)
|
||||
const ASTERISK = 0x002A; // U+002A ASTERISK (*)
|
||||
const EQUALSSIGN = 0x003D; // U+003D EQUALS SIGN (=)
|
||||
const CIRCUMFLEXACCENT = 0x005E; // U+005E (^)
|
||||
const VERTICALLINE = 0x007C; // U+007C VERTICAL LINE (|)
|
||||
const TILDE = 0x007E; // U+007E TILDE (~)
|
||||
|
||||
function getAttributeName() {
|
||||
if (this.scanner.eof) {
|
||||
if (this.eof) {
|
||||
this.error('Unexpected end of input');
|
||||
}
|
||||
|
||||
var start = this.scanner.tokenStart;
|
||||
var expectIdent = false;
|
||||
var checkColon = true;
|
||||
const start = this.tokenStart;
|
||||
let expectIdent = false;
|
||||
|
||||
if (this.scanner.isDelim(ASTERISK)) {
|
||||
if (this.isDelim(ASTERISK)) {
|
||||
expectIdent = true;
|
||||
checkColon = false;
|
||||
this.scanner.next();
|
||||
} else if (!this.scanner.isDelim(VERTICALLINE)) {
|
||||
this.eat(IDENT);
|
||||
this.next();
|
||||
} else if (!this.isDelim(VERTICALLINE)) {
|
||||
this.eat(Ident);
|
||||
}
|
||||
|
||||
if (this.scanner.isDelim(VERTICALLINE)) {
|
||||
if (this.scanner.source.charCodeAt(this.scanner.tokenStart + 1) !== EQUALSSIGN) {
|
||||
this.scanner.next();
|
||||
this.eat(IDENT);
|
||||
if (this.isDelim(VERTICALLINE)) {
|
||||
if (this.charCodeAt(this.tokenStart + 1) !== EQUALSSIGN) {
|
||||
this.next();
|
||||
this.eat(Ident);
|
||||
} else if (expectIdent) {
|
||||
this.error('Identifier is expected', this.scanner.tokenEnd);
|
||||
this.error('Identifier is expected', this.tokenEnd);
|
||||
}
|
||||
} else if (expectIdent) {
|
||||
this.error('Vertical line is expected');
|
||||
}
|
||||
|
||||
if (checkColon && this.scanner.tokenType === COLON) {
|
||||
this.scanner.next();
|
||||
this.eat(IDENT);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Identifier',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
name: this.scanner.substrToCursor(start)
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
name: this.substrToCursor(start)
|
||||
};
|
||||
}
|
||||
|
||||
function getOperator() {
|
||||
var start = this.scanner.tokenStart;
|
||||
var code = this.scanner.source.charCodeAt(start);
|
||||
const start = this.tokenStart;
|
||||
const code = this.charCodeAt(start);
|
||||
|
||||
if (code !== EQUALSSIGN && // =
|
||||
code !== TILDE && // ~=
|
||||
@@ -66,100 +60,88 @@ function getOperator() {
|
||||
this.error('Attribute selector (=, ~=, ^=, $=, *=, |=) is expected');
|
||||
}
|
||||
|
||||
this.scanner.next();
|
||||
this.next();
|
||||
|
||||
if (code !== EQUALSSIGN) {
|
||||
if (!this.scanner.isDelim(EQUALSSIGN)) {
|
||||
if (!this.isDelim(EQUALSSIGN)) {
|
||||
this.error('Equal sign is expected');
|
||||
}
|
||||
|
||||
this.scanner.next();
|
||||
this.next();
|
||||
}
|
||||
|
||||
return this.scanner.substrToCursor(start);
|
||||
return this.substrToCursor(start);
|
||||
}
|
||||
|
||||
// '[' <wq-name> ']'
|
||||
// '[' <wq-name> <attr-matcher> [ <string-token> | <ident-token> ] <attr-modifier>? ']'
|
||||
module.exports = {
|
||||
name: 'AttributeSelector',
|
||||
structure: {
|
||||
name: 'Identifier',
|
||||
matcher: [String, null],
|
||||
value: ['String', 'Identifier', null],
|
||||
flags: [String, null]
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
var name;
|
||||
var matcher = null;
|
||||
var value = null;
|
||||
var flags = null;
|
||||
|
||||
this.eat(LEFTSQUAREBRACKET);
|
||||
this.scanner.skipSC();
|
||||
|
||||
name = getAttributeName.call(this);
|
||||
this.scanner.skipSC();
|
||||
|
||||
if (this.scanner.tokenType !== RIGHTSQUAREBRACKET) {
|
||||
// avoid case `[name i]`
|
||||
if (this.scanner.tokenType !== IDENT) {
|
||||
matcher = getOperator.call(this);
|
||||
|
||||
this.scanner.skipSC();
|
||||
|
||||
value = this.scanner.tokenType === STRING
|
||||
? this.String()
|
||||
: this.Identifier();
|
||||
|
||||
this.scanner.skipSC();
|
||||
}
|
||||
|
||||
// attribute flags
|
||||
if (this.scanner.tokenType === IDENT) {
|
||||
flags = this.scanner.getTokenValue();
|
||||
this.scanner.next();
|
||||
|
||||
this.scanner.skipSC();
|
||||
}
|
||||
}
|
||||
|
||||
this.eat(RIGHTSQUAREBRACKET);
|
||||
|
||||
return {
|
||||
type: 'AttributeSelector',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
name: name,
|
||||
matcher: matcher,
|
||||
value: value,
|
||||
flags: flags
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
var flagsPrefix = ' ';
|
||||
|
||||
this.chunk('[');
|
||||
this.node(node.name);
|
||||
|
||||
if (node.matcher !== null) {
|
||||
this.chunk(node.matcher);
|
||||
|
||||
if (node.value !== null) {
|
||||
this.node(node.value);
|
||||
|
||||
// space between string and flags is not required
|
||||
if (node.value.type === 'String') {
|
||||
flagsPrefix = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (node.flags !== null) {
|
||||
this.chunk(flagsPrefix);
|
||||
this.chunk(node.flags);
|
||||
}
|
||||
|
||||
this.chunk(']');
|
||||
}
|
||||
export const name = 'AttributeSelector';
|
||||
export const structure = {
|
||||
name: 'Identifier',
|
||||
matcher: [String, null],
|
||||
value: ['String', 'Identifier', null],
|
||||
flags: [String, null]
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
let name;
|
||||
let matcher = null;
|
||||
let value = null;
|
||||
let flags = null;
|
||||
|
||||
this.eat(LeftSquareBracket);
|
||||
this.skipSC();
|
||||
|
||||
name = getAttributeName.call(this);
|
||||
this.skipSC();
|
||||
|
||||
if (this.tokenType !== RightSquareBracket) {
|
||||
// avoid case `[name i]`
|
||||
if (this.tokenType !== Ident) {
|
||||
matcher = getOperator.call(this);
|
||||
|
||||
this.skipSC();
|
||||
|
||||
value = this.tokenType === StringToken
|
||||
? this.String()
|
||||
: this.Identifier();
|
||||
|
||||
this.skipSC();
|
||||
}
|
||||
|
||||
// attribute flags
|
||||
if (this.tokenType === Ident) {
|
||||
flags = this.consume(Ident);
|
||||
|
||||
this.skipSC();
|
||||
}
|
||||
}
|
||||
|
||||
this.eat(RightSquareBracket);
|
||||
|
||||
return {
|
||||
type: 'AttributeSelector',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
name,
|
||||
matcher,
|
||||
value,
|
||||
flags
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(Delim, '[');
|
||||
this.node(node.name);
|
||||
|
||||
if (node.matcher !== null) {
|
||||
this.tokenize(node.matcher);
|
||||
this.node(node.value);
|
||||
}
|
||||
|
||||
if (node.flags !== null) {
|
||||
this.token(Ident, node.flags);
|
||||
}
|
||||
|
||||
this.token(Delim, ']');
|
||||
}
|
||||
|
||||
152
node_modules/css-tree/lib/syntax/node/Block.js
generated
vendored
152
node_modules/css-tree/lib/syntax/node/Block.js
generated
vendored
@@ -1,91 +1,95 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
var rawMode = require('./Raw').mode;
|
||||
import {
|
||||
WhiteSpace,
|
||||
Comment,
|
||||
Semicolon,
|
||||
AtKeyword,
|
||||
LeftCurlyBracket,
|
||||
RightCurlyBracket
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
var WHITESPACE = TYPE.WhiteSpace;
|
||||
var COMMENT = TYPE.Comment;
|
||||
var SEMICOLON = TYPE.Semicolon;
|
||||
var ATKEYWORD = TYPE.AtKeyword;
|
||||
var LEFTCURLYBRACKET = TYPE.LeftCurlyBracket;
|
||||
var RIGHTCURLYBRACKET = TYPE.RightCurlyBracket;
|
||||
const AMPERSAND = 0x0026; // U+0026 AMPERSAND (&)
|
||||
|
||||
function consumeRaw(startToken) {
|
||||
return this.Raw(startToken, null, true);
|
||||
function consumeRaw() {
|
||||
return this.Raw(null, true);
|
||||
}
|
||||
function consumeRule() {
|
||||
return this.parseWithFallback(this.Rule, consumeRaw);
|
||||
}
|
||||
function consumeRawDeclaration(startToken) {
|
||||
return this.Raw(startToken, rawMode.semicolonIncluded, true);
|
||||
function consumeRawDeclaration() {
|
||||
return this.Raw(this.consumeUntilSemicolonIncluded, true);
|
||||
}
|
||||
function consumeDeclaration() {
|
||||
if (this.scanner.tokenType === SEMICOLON) {
|
||||
return consumeRawDeclaration.call(this, this.scanner.tokenIndex);
|
||||
if (this.tokenType === Semicolon) {
|
||||
return consumeRawDeclaration.call(this, this.tokenIndex);
|
||||
}
|
||||
|
||||
var node = this.parseWithFallback(this.Declaration, consumeRawDeclaration);
|
||||
const node = this.parseWithFallback(this.Declaration, consumeRawDeclaration);
|
||||
|
||||
if (this.scanner.tokenType === SEMICOLON) {
|
||||
this.scanner.next();
|
||||
if (this.tokenType === Semicolon) {
|
||||
this.next();
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'Block',
|
||||
structure: {
|
||||
children: [[
|
||||
'Atrule',
|
||||
'Rule',
|
||||
'Declaration'
|
||||
]]
|
||||
},
|
||||
parse: function(isDeclaration) {
|
||||
var consumer = isDeclaration ? consumeDeclaration : consumeRule;
|
||||
|
||||
var start = this.scanner.tokenStart;
|
||||
var children = this.createList();
|
||||
|
||||
this.eat(LEFTCURLYBRACKET);
|
||||
|
||||
scan:
|
||||
while (!this.scanner.eof) {
|
||||
switch (this.scanner.tokenType) {
|
||||
case RIGHTCURLYBRACKET:
|
||||
break scan;
|
||||
|
||||
case WHITESPACE:
|
||||
case COMMENT:
|
||||
this.scanner.next();
|
||||
break;
|
||||
|
||||
case ATKEYWORD:
|
||||
children.push(this.parseWithFallback(this.Atrule, consumeRaw));
|
||||
break;
|
||||
|
||||
default:
|
||||
children.push(consumer.call(this));
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.scanner.eof) {
|
||||
this.eat(RIGHTCURLYBRACKET);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Block',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
children: children
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk('{');
|
||||
this.children(node, function(prev) {
|
||||
if (prev.type === 'Declaration') {
|
||||
this.chunk(';');
|
||||
}
|
||||
});
|
||||
this.chunk('}');
|
||||
},
|
||||
walkContext: 'block'
|
||||
export const name = 'Block';
|
||||
export const walkContext = 'block';
|
||||
export const structure = {
|
||||
children: [[
|
||||
'Atrule',
|
||||
'Rule',
|
||||
'Declaration'
|
||||
]]
|
||||
};
|
||||
|
||||
export function parse(isStyleBlock) {
|
||||
const consumer = isStyleBlock ? consumeDeclaration : consumeRule;
|
||||
const start = this.tokenStart;
|
||||
let children = this.createList();
|
||||
|
||||
this.eat(LeftCurlyBracket);
|
||||
|
||||
scan:
|
||||
while (!this.eof) {
|
||||
switch (this.tokenType) {
|
||||
case RightCurlyBracket:
|
||||
break scan;
|
||||
|
||||
case WhiteSpace:
|
||||
case Comment:
|
||||
this.next();
|
||||
break;
|
||||
|
||||
case AtKeyword:
|
||||
children.push(this.parseWithFallback(this.Atrule.bind(this, isStyleBlock), consumeRaw));
|
||||
break;
|
||||
|
||||
default:
|
||||
if (isStyleBlock && this.isDelim(AMPERSAND)) {
|
||||
children.push(consumeRule.call(this));
|
||||
} else {
|
||||
children.push(consumer.call(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.eof) {
|
||||
this.eat(RightCurlyBracket);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Block',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
children
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(LeftCurlyBracket, '{');
|
||||
this.children(node, prev => {
|
||||
if (prev.type === 'Declaration') {
|
||||
this.token(Semicolon, ';');
|
||||
}
|
||||
});
|
||||
this.token(RightCurlyBracket, '}');
|
||||
}
|
||||
|
||||
65
node_modules/css-tree/lib/syntax/node/Brackets.js
generated
vendored
65
node_modules/css-tree/lib/syntax/node/Brackets.js
generated
vendored
@@ -1,34 +1,35 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import {
|
||||
Delim,
|
||||
LeftSquareBracket,
|
||||
RightSquareBracket
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
var LEFTSQUAREBRACKET = TYPE.LeftSquareBracket;
|
||||
var RIGHTSQUAREBRACKET = TYPE.RightSquareBracket;
|
||||
|
||||
module.exports = {
|
||||
name: 'Brackets',
|
||||
structure: {
|
||||
children: [[]]
|
||||
},
|
||||
parse: function(readSequence, recognizer) {
|
||||
var start = this.scanner.tokenStart;
|
||||
var children = null;
|
||||
|
||||
this.eat(LEFTSQUAREBRACKET);
|
||||
|
||||
children = readSequence.call(this, recognizer);
|
||||
|
||||
if (!this.scanner.eof) {
|
||||
this.eat(RIGHTSQUAREBRACKET);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Brackets',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
children: children
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk('[');
|
||||
this.children(node);
|
||||
this.chunk(']');
|
||||
}
|
||||
export const name = 'Brackets';
|
||||
export const structure = {
|
||||
children: [[]]
|
||||
};
|
||||
|
||||
export function parse(readSequence, recognizer) {
|
||||
const start = this.tokenStart;
|
||||
let children = null;
|
||||
|
||||
this.eat(LeftSquareBracket);
|
||||
|
||||
children = readSequence.call(this, recognizer);
|
||||
|
||||
if (!this.eof) {
|
||||
this.eat(RightSquareBracket);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Brackets',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
children
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(Delim, '[');
|
||||
this.children(node);
|
||||
this.token(Delim, ']');
|
||||
}
|
||||
|
||||
32
node_modules/css-tree/lib/syntax/node/CDC.js
generated
vendored
32
node_modules/css-tree/lib/syntax/node/CDC.js
generated
vendored
@@ -1,19 +1,19 @@
|
||||
var CDC = require('../../tokenizer').TYPE.CDC;
|
||||
import { CDC } from '../../tokenizer/index.js';
|
||||
|
||||
module.exports = {
|
||||
name: 'CDC',
|
||||
structure: [],
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
export const name = 'CDC';
|
||||
export const structure = [];
|
||||
|
||||
this.eat(CDC); // -->
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
|
||||
return {
|
||||
type: 'CDC',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart)
|
||||
};
|
||||
},
|
||||
generate: function() {
|
||||
this.chunk('-->');
|
||||
}
|
||||
};
|
||||
this.eat(CDC); // -->
|
||||
|
||||
return {
|
||||
type: 'CDC',
|
||||
loc: this.getLocation(start, this.tokenStart)
|
||||
};
|
||||
}
|
||||
|
||||
export function generate() {
|
||||
this.token(CDC, '-->');
|
||||
}
|
||||
|
||||
32
node_modules/css-tree/lib/syntax/node/CDO.js
generated
vendored
32
node_modules/css-tree/lib/syntax/node/CDO.js
generated
vendored
@@ -1,19 +1,19 @@
|
||||
var CDO = require('../../tokenizer').TYPE.CDO;
|
||||
import { CDO } from '../../tokenizer/index.js';
|
||||
|
||||
module.exports = {
|
||||
name: 'CDO',
|
||||
structure: [],
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
export const name = 'CDO';
|
||||
export const structure = [];
|
||||
|
||||
this.eat(CDO); // <!--
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
|
||||
return {
|
||||
type: 'CDO',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart)
|
||||
};
|
||||
},
|
||||
generate: function() {
|
||||
this.chunk('<!--');
|
||||
}
|
||||
};
|
||||
this.eat(CDO); // <!--
|
||||
|
||||
return {
|
||||
type: 'CDO',
|
||||
loc: this.getLocation(start, this.tokenStart)
|
||||
};
|
||||
}
|
||||
|
||||
export function generate() {
|
||||
this.token(CDO, '<!--');
|
||||
}
|
||||
|
||||
45
node_modules/css-tree/lib/syntax/node/ClassSelector.js
generated
vendored
45
node_modules/css-tree/lib/syntax/node/ClassSelector.js
generated
vendored
@@ -1,29 +1,24 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import { Delim, Ident } from '../../tokenizer/index.js';
|
||||
|
||||
var IDENT = TYPE.Ident;
|
||||
var FULLSTOP = 0x002E; // U+002E FULL STOP (.)
|
||||
const FULLSTOP = 0x002E; // U+002E FULL STOP (.)
|
||||
|
||||
// '.' ident
|
||||
module.exports = {
|
||||
name: 'ClassSelector',
|
||||
structure: {
|
||||
name: String
|
||||
},
|
||||
parse: function() {
|
||||
if (!this.scanner.isDelim(FULLSTOP)) {
|
||||
this.error('Full stop is expected');
|
||||
}
|
||||
|
||||
this.scanner.next();
|
||||
|
||||
return {
|
||||
type: 'ClassSelector',
|
||||
loc: this.getLocation(this.scanner.tokenStart - 1, this.scanner.tokenEnd),
|
||||
name: this.consume(IDENT)
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk('.');
|
||||
this.chunk(node.name);
|
||||
}
|
||||
export const name = 'ClassSelector';
|
||||
export const structure = {
|
||||
name: String
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
this.eatDelim(FULLSTOP);
|
||||
|
||||
return {
|
||||
type: 'ClassSelector',
|
||||
loc: this.getLocation(this.tokenStart - 1, this.tokenEnd),
|
||||
name: this.consume(Ident)
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(Delim, '.');
|
||||
this.token(Ident, node.name);
|
||||
}
|
||||
|
||||
91
node_modules/css-tree/lib/syntax/node/Combinator.js
generated
vendored
91
node_modules/css-tree/lib/syntax/node/Combinator.js
generated
vendored
@@ -1,55 +1,54 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import { WhiteSpace, Delim } from '../../tokenizer/index.js';
|
||||
|
||||
var IDENT = TYPE.Ident;
|
||||
var PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
|
||||
var SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
|
||||
var GREATERTHANSIGN = 0x003E; // U+003E GREATER-THAN SIGN (>)
|
||||
var TILDE = 0x007E; // U+007E TILDE (~)
|
||||
const PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
|
||||
const SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
|
||||
const GREATERTHANSIGN = 0x003E; // U+003E GREATER-THAN SIGN (>)
|
||||
const TILDE = 0x007E; // U+007E TILDE (~)
|
||||
|
||||
export const name = 'Combinator';
|
||||
export const structure = {
|
||||
name: String
|
||||
};
|
||||
|
||||
// + | > | ~ | /deep/
|
||||
module.exports = {
|
||||
name: 'Combinator',
|
||||
structure: {
|
||||
name: String
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
var code = this.scanner.source.charCodeAt(this.scanner.tokenStart);
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
let name;
|
||||
|
||||
switch (code) {
|
||||
case GREATERTHANSIGN:
|
||||
case PLUSSIGN:
|
||||
case TILDE:
|
||||
this.scanner.next();
|
||||
break;
|
||||
switch (this.tokenType) {
|
||||
case WhiteSpace:
|
||||
name = ' ';
|
||||
break;
|
||||
|
||||
case SOLIDUS:
|
||||
this.scanner.next();
|
||||
case Delim:
|
||||
switch (this.charCodeAt(this.tokenStart)) {
|
||||
case GREATERTHANSIGN:
|
||||
case PLUSSIGN:
|
||||
case TILDE:
|
||||
this.next();
|
||||
break;
|
||||
|
||||
if (this.scanner.tokenType !== IDENT || this.scanner.lookupValue(0, 'deep') === false) {
|
||||
this.error('Identifier `deep` is expected');
|
||||
}
|
||||
case SOLIDUS:
|
||||
this.next();
|
||||
this.eatIdent('deep');
|
||||
this.eatDelim(SOLIDUS);
|
||||
break;
|
||||
|
||||
this.scanner.next();
|
||||
default:
|
||||
this.error('Combinator is expected');
|
||||
}
|
||||
|
||||
if (!this.scanner.isDelim(SOLIDUS)) {
|
||||
this.error('Solidus is expected');
|
||||
}
|
||||
|
||||
this.scanner.next();
|
||||
break;
|
||||
|
||||
default:
|
||||
this.error('Combinator is expected');
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Combinator',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
name: this.scanner.substrToCursor(start)
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk(node.name);
|
||||
name = this.substrToCursor(start);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
type: 'Combinator',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
name
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.tokenize(node.name);
|
||||
}
|
||||
|
||||
61
node_modules/css-tree/lib/syntax/node/Comment.js
generated
vendored
61
node_modules/css-tree/lib/syntax/node/Comment.js
generated
vendored
@@ -1,36 +1,33 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import { Comment } from '../../tokenizer/index.js';
|
||||
|
||||
var COMMENT = TYPE.Comment;
|
||||
var ASTERISK = 0x002A; // U+002A ASTERISK (*)
|
||||
var SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
|
||||
const ASTERISK = 0x002A; // U+002A ASTERISK (*)
|
||||
const SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
|
||||
|
||||
// '/*' .* '*/'
|
||||
module.exports = {
|
||||
name: 'Comment',
|
||||
structure: {
|
||||
value: String
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
var end = this.scanner.tokenEnd;
|
||||
|
||||
this.eat(COMMENT);
|
||||
|
||||
if ((end - start + 2) >= 2 &&
|
||||
this.scanner.source.charCodeAt(end - 2) === ASTERISK &&
|
||||
this.scanner.source.charCodeAt(end - 1) === SOLIDUS) {
|
||||
end -= 2;
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Comment',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
value: this.scanner.source.substring(start + 2, end)
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk('/*');
|
||||
this.chunk(node.value);
|
||||
this.chunk('*/');
|
||||
}
|
||||
export const name = 'Comment';
|
||||
export const structure = {
|
||||
value: String
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
let end = this.tokenEnd;
|
||||
|
||||
this.eat(Comment);
|
||||
|
||||
if ((end - start + 2) >= 2 &&
|
||||
this.charCodeAt(end - 2) === ASTERISK &&
|
||||
this.charCodeAt(end - 1) === SOLIDUS) {
|
||||
end -= 2;
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Comment',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
value: this.substring(start + 2, end)
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(Comment, '/*' + node.value + '*/');
|
||||
}
|
||||
|
||||
123
node_modules/css-tree/lib/syntax/node/Condition.js
generated
vendored
Normal file
123
node_modules/css-tree/lib/syntax/node/Condition.js
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
import {
|
||||
WhiteSpace,
|
||||
Comment,
|
||||
Ident,
|
||||
LeftParenthesis,
|
||||
RightParenthesis,
|
||||
Function as FunctionToken,
|
||||
Colon,
|
||||
EOF
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
const likelyFeatureToken = new Set([Colon, RightParenthesis, EOF]);
|
||||
|
||||
export const name = 'Condition';
|
||||
export const structure = {
|
||||
kind: String,
|
||||
children: [[
|
||||
'Identifier',
|
||||
'Feature',
|
||||
'FeatureFunction',
|
||||
'FeatureRange',
|
||||
'SupportsDeclaration'
|
||||
]]
|
||||
};
|
||||
|
||||
function featureOrRange(kind) {
|
||||
if (this.lookupTypeNonSC(1) === Ident &&
|
||||
likelyFeatureToken.has(this.lookupTypeNonSC(2))) {
|
||||
return this.Feature(kind);
|
||||
}
|
||||
|
||||
return this.FeatureRange(kind);
|
||||
}
|
||||
|
||||
const parentheses = {
|
||||
media: featureOrRange,
|
||||
container: featureOrRange,
|
||||
supports() {
|
||||
return this.SupportsDeclaration();
|
||||
}
|
||||
};
|
||||
|
||||
export function parse(kind = 'media') {
|
||||
const children = this.createList();
|
||||
|
||||
scan: while (!this.eof) {
|
||||
switch (this.tokenType) {
|
||||
case Comment:
|
||||
case WhiteSpace:
|
||||
this.next();
|
||||
continue;
|
||||
|
||||
case Ident:
|
||||
children.push(this.Identifier());
|
||||
break;
|
||||
|
||||
case LeftParenthesis: {
|
||||
let term = this.parseWithFallback(
|
||||
() => parentheses[kind].call(this, kind),
|
||||
() => null
|
||||
);
|
||||
|
||||
if (!term) {
|
||||
term = this.parseWithFallback(
|
||||
() => {
|
||||
this.eat(LeftParenthesis);
|
||||
const res = this.Condition(kind);
|
||||
this.eat(RightParenthesis);
|
||||
return res;
|
||||
},
|
||||
() => {
|
||||
return this.GeneralEnclosed(kind);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
children.push(term);
|
||||
break;
|
||||
}
|
||||
|
||||
case FunctionToken: {
|
||||
let term = this.parseWithFallback(
|
||||
() => this.FeatureFunction(kind),
|
||||
() => null
|
||||
);
|
||||
|
||||
if (!term) {
|
||||
term = this.GeneralEnclosed(kind);
|
||||
}
|
||||
|
||||
children.push(term);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break scan;
|
||||
}
|
||||
}
|
||||
|
||||
if (children.isEmpty) {
|
||||
this.error('Condition is expected');
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Condition',
|
||||
loc: this.getLocationFromList(children),
|
||||
kind,
|
||||
children
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
node.children.forEach(child => {
|
||||
if (child.type === 'Condition') {
|
||||
this.token(LeftParenthesis, '(');
|
||||
this.node(child);
|
||||
this.token(RightParenthesis, ')');
|
||||
} else {
|
||||
this.node(child);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
240
node_modules/css-tree/lib/syntax/node/Declaration.js
generated
vendored
240
node_modules/css-tree/lib/syntax/node/Declaration.js
generated
vendored
@@ -1,167 +1,163 @@
|
||||
var isCustomProperty = require('../../utils/names').isCustomProperty;
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
var rawMode = require('./Raw').mode;
|
||||
import { isCustomProperty } from '../../utils/names.js';
|
||||
import {
|
||||
Ident,
|
||||
Hash,
|
||||
Colon,
|
||||
Semicolon,
|
||||
Delim,
|
||||
WhiteSpace
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
var IDENT = TYPE.Ident;
|
||||
var HASH = TYPE.Hash;
|
||||
var COLON = TYPE.Colon;
|
||||
var SEMICOLON = TYPE.Semicolon;
|
||||
var DELIM = TYPE.Delim;
|
||||
var WHITESPACE = TYPE.WhiteSpace;
|
||||
var EXCLAMATIONMARK = 0x0021; // U+0021 EXCLAMATION MARK (!)
|
||||
var NUMBERSIGN = 0x0023; // U+0023 NUMBER SIGN (#)
|
||||
var DOLLARSIGN = 0x0024; // U+0024 DOLLAR SIGN ($)
|
||||
var AMPERSAND = 0x0026; // U+0026 ANPERSAND (&)
|
||||
var ASTERISK = 0x002A; // U+002A ASTERISK (*)
|
||||
var PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
|
||||
var SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
|
||||
const EXCLAMATIONMARK = 0x0021; // U+0021 EXCLAMATION MARK (!)
|
||||
const NUMBERSIGN = 0x0023; // U+0023 NUMBER SIGN (#)
|
||||
const DOLLARSIGN = 0x0024; // U+0024 DOLLAR 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 (/)
|
||||
|
||||
function consumeValueRaw(startToken) {
|
||||
return this.Raw(startToken, rawMode.exclamationMarkOrSemicolon, true);
|
||||
function consumeValueRaw() {
|
||||
return this.Raw(this.consumeUntilExclamationMarkOrSemicolon, true);
|
||||
}
|
||||
|
||||
function consumeCustomPropertyRaw(startToken) {
|
||||
return this.Raw(startToken, rawMode.exclamationMarkOrSemicolon, false);
|
||||
function consumeCustomPropertyRaw() {
|
||||
return this.Raw(this.consumeUntilExclamationMarkOrSemicolon, false);
|
||||
}
|
||||
|
||||
function consumeValue() {
|
||||
var startValueToken = this.scanner.tokenIndex;
|
||||
var value = this.Value();
|
||||
const startValueToken = this.tokenIndex;
|
||||
const value = this.Value();
|
||||
|
||||
if (value.type !== 'Raw' &&
|
||||
this.scanner.eof === false &&
|
||||
this.scanner.tokenType !== SEMICOLON &&
|
||||
this.scanner.isDelim(EXCLAMATIONMARK) === false &&
|
||||
this.scanner.isBalanceEdge(startValueToken) === false) {
|
||||
this.eof === false &&
|
||||
this.tokenType !== Semicolon &&
|
||||
this.isDelim(EXCLAMATIONMARK) === false &&
|
||||
this.isBalanceEdge(startValueToken) === false) {
|
||||
this.error();
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'Declaration',
|
||||
structure: {
|
||||
important: [Boolean, String],
|
||||
property: String,
|
||||
value: ['Value', 'Raw']
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
var startToken = this.scanner.tokenIndex;
|
||||
var property = readProperty.call(this);
|
||||
var customProperty = isCustomProperty(property);
|
||||
var parseValue = customProperty ? this.parseCustomProperty : this.parseValue;
|
||||
var consumeRaw = customProperty ? consumeCustomPropertyRaw : consumeValueRaw;
|
||||
var important = false;
|
||||
var value;
|
||||
|
||||
this.scanner.skipSC();
|
||||
this.eat(COLON);
|
||||
|
||||
const valueStart = this.scanner.tokenIndex;
|
||||
|
||||
if (!customProperty) {
|
||||
this.scanner.skipSC();
|
||||
}
|
||||
|
||||
if (parseValue) {
|
||||
value = this.parseWithFallback(consumeValue, consumeRaw);
|
||||
} else {
|
||||
value = consumeRaw.call(this, this.scanner.tokenIndex);
|
||||
}
|
||||
|
||||
if (customProperty && value.type === 'Value' && value.children.isEmpty()) {
|
||||
for (let offset = valueStart - this.scanner.tokenIndex; offset <= 0; offset++) {
|
||||
if (this.scanner.lookupType(offset) === WHITESPACE) {
|
||||
value.children.appendData({
|
||||
type: 'WhiteSpace',
|
||||
loc: null,
|
||||
value: ' '
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.scanner.isDelim(EXCLAMATIONMARK)) {
|
||||
important = getImportant.call(this);
|
||||
this.scanner.skipSC();
|
||||
}
|
||||
|
||||
// Do not include semicolon to range per spec
|
||||
// https://drafts.csswg.org/css-syntax/#declaration-diagram
|
||||
|
||||
if (this.scanner.eof === false &&
|
||||
this.scanner.tokenType !== SEMICOLON &&
|
||||
this.scanner.isBalanceEdge(startToken) === false) {
|
||||
this.error();
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Declaration',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
important: important,
|
||||
property: property,
|
||||
value: value
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk(node.property);
|
||||
this.chunk(':');
|
||||
this.node(node.value);
|
||||
|
||||
if (node.important) {
|
||||
this.chunk(node.important === true ? '!important' : '!' + node.important);
|
||||
}
|
||||
},
|
||||
walkContext: 'declaration'
|
||||
export const name = 'Declaration';
|
||||
export const walkContext = 'declaration';
|
||||
export const structure = {
|
||||
important: [Boolean, String],
|
||||
property: String,
|
||||
value: ['Value', 'Raw']
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
const startToken = this.tokenIndex;
|
||||
const property = readProperty.call(this);
|
||||
const customProperty = isCustomProperty(property);
|
||||
const parseValue = customProperty ? this.parseCustomProperty : this.parseValue;
|
||||
const consumeRaw = customProperty ? consumeCustomPropertyRaw : consumeValueRaw;
|
||||
let important = false;
|
||||
let value;
|
||||
|
||||
this.skipSC();
|
||||
this.eat(Colon);
|
||||
|
||||
const valueStart = this.tokenIndex;
|
||||
|
||||
if (!customProperty) {
|
||||
this.skipSC();
|
||||
}
|
||||
|
||||
if (parseValue) {
|
||||
value = this.parseWithFallback(consumeValue, consumeRaw);
|
||||
} else {
|
||||
value = consumeRaw.call(this, this.tokenIndex);
|
||||
}
|
||||
|
||||
if (customProperty && value.type === 'Value' && value.children.isEmpty) {
|
||||
for (let offset = valueStart - this.tokenIndex; offset <= 0; offset++) {
|
||||
if (this.lookupType(offset) === WhiteSpace) {
|
||||
value.children.appendData({
|
||||
type: 'WhiteSpace',
|
||||
loc: null,
|
||||
value: ' '
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isDelim(EXCLAMATIONMARK)) {
|
||||
important = getImportant.call(this);
|
||||
this.skipSC();
|
||||
}
|
||||
|
||||
// Do not include semicolon to range per spec
|
||||
// https://drafts.csswg.org/css-syntax/#declaration-diagram
|
||||
|
||||
if (this.eof === false &&
|
||||
this.tokenType !== Semicolon &&
|
||||
this.isBalanceEdge(startToken) === false) {
|
||||
this.error();
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Declaration',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
important,
|
||||
property,
|
||||
value
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(Ident, node.property);
|
||||
this.token(Colon, ':');
|
||||
this.node(node.value);
|
||||
|
||||
if (node.important) {
|
||||
this.token(Delim, '!');
|
||||
this.token(Ident, node.important === true ? 'important' : node.important);
|
||||
}
|
||||
}
|
||||
|
||||
function readProperty() {
|
||||
var start = this.scanner.tokenStart;
|
||||
var prefix = 0;
|
||||
const start = this.tokenStart;
|
||||
|
||||
// hacks
|
||||
if (this.scanner.tokenType === DELIM) {
|
||||
switch (this.scanner.source.charCodeAt(this.scanner.tokenStart)) {
|
||||
if (this.tokenType === Delim) {
|
||||
switch (this.charCodeAt(this.tokenStart)) {
|
||||
case ASTERISK:
|
||||
case DOLLARSIGN:
|
||||
case PLUSSIGN:
|
||||
case NUMBERSIGN:
|
||||
case AMPERSAND:
|
||||
this.scanner.next();
|
||||
this.next();
|
||||
break;
|
||||
|
||||
// TODO: not sure we should support this hack
|
||||
case SOLIDUS:
|
||||
this.scanner.next();
|
||||
if (this.scanner.isDelim(SOLIDUS)) {
|
||||
this.scanner.next();
|
||||
this.next();
|
||||
if (this.isDelim(SOLIDUS)) {
|
||||
this.next();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (prefix) {
|
||||
this.scanner.skip(prefix);
|
||||
}
|
||||
|
||||
if (this.scanner.tokenType === HASH) {
|
||||
this.eat(HASH);
|
||||
if (this.tokenType === Hash) {
|
||||
this.eat(Hash);
|
||||
} else {
|
||||
this.eat(IDENT);
|
||||
this.eat(Ident);
|
||||
}
|
||||
|
||||
return this.scanner.substrToCursor(start);
|
||||
return this.substrToCursor(start);
|
||||
}
|
||||
|
||||
// ! ws* important
|
||||
function getImportant() {
|
||||
this.eat(DELIM);
|
||||
this.scanner.skipSC();
|
||||
this.eat(Delim);
|
||||
this.skipSC();
|
||||
|
||||
var important = this.consume(IDENT);
|
||||
const important = this.consume(Ident);
|
||||
|
||||
// store original value in case it differ from `important`
|
||||
// for better original source restoring and hacks like `!ie` support
|
||||
|
||||
101
node_modules/css-tree/lib/syntax/node/DeclarationList.js
generated
vendored
101
node_modules/css-tree/lib/syntax/node/DeclarationList.js
generated
vendored
@@ -1,49 +1,62 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
var rawMode = require('./Raw').mode;
|
||||
import {
|
||||
WhiteSpace,
|
||||
Comment,
|
||||
Semicolon,
|
||||
AtKeyword
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
var WHITESPACE = TYPE.WhiteSpace;
|
||||
var COMMENT = TYPE.Comment;
|
||||
var SEMICOLON = TYPE.Semicolon;
|
||||
const AMPERSAND = 0x0026; // U+0026 AMPERSAND (&)
|
||||
|
||||
function consumeRaw(startToken) {
|
||||
return this.Raw(startToken, rawMode.semicolonIncluded, true);
|
||||
function consumeRaw() {
|
||||
return this.Raw(this.consumeUntilSemicolonIncluded, true);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'DeclarationList',
|
||||
structure: {
|
||||
children: [[
|
||||
'Declaration'
|
||||
]]
|
||||
},
|
||||
parse: function() {
|
||||
var children = this.createList();
|
||||
|
||||
scan:
|
||||
while (!this.scanner.eof) {
|
||||
switch (this.scanner.tokenType) {
|
||||
case WHITESPACE:
|
||||
case COMMENT:
|
||||
case SEMICOLON:
|
||||
this.scanner.next();
|
||||
break;
|
||||
|
||||
default:
|
||||
children.push(this.parseWithFallback(this.Declaration, consumeRaw));
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'DeclarationList',
|
||||
loc: this.getLocationFromList(children),
|
||||
children: children
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.children(node, function(prev) {
|
||||
if (prev.type === 'Declaration') {
|
||||
this.chunk(';');
|
||||
}
|
||||
});
|
||||
}
|
||||
export const name = 'DeclarationList';
|
||||
export const structure = {
|
||||
children: [[
|
||||
'Declaration',
|
||||
'Atrule',
|
||||
'Rule'
|
||||
]]
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
const children = this.createList();
|
||||
|
||||
scan:
|
||||
while (!this.eof) {
|
||||
switch (this.tokenType) {
|
||||
case WhiteSpace:
|
||||
case Comment:
|
||||
case Semicolon:
|
||||
this.next();
|
||||
break;
|
||||
|
||||
case AtKeyword:
|
||||
children.push(this.parseWithFallback(this.Atrule.bind(this, true), consumeRaw));
|
||||
break;
|
||||
|
||||
default:
|
||||
if (this.isDelim(AMPERSAND)) {
|
||||
children.push(this.parseWithFallback(this.Rule, consumeRaw));
|
||||
} else {
|
||||
children.push(this.parseWithFallback(this.Declaration, consumeRaw));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'DeclarationList',
|
||||
loc: this.getLocationFromList(children),
|
||||
children
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.children(node, prev => {
|
||||
if (prev.type === 'Declaration') {
|
||||
this.token(Semicolon, ';');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
48
node_modules/css-tree/lib/syntax/node/Dimension.js
generated
vendored
48
node_modules/css-tree/lib/syntax/node/Dimension.js
generated
vendored
@@ -1,29 +1,23 @@
|
||||
var consumeNumber = require('../../tokenizer/utils').consumeNumber;
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import { Dimension } from '../../tokenizer/index.js';
|
||||
|
||||
var DIMENSION = TYPE.Dimension;
|
||||
|
||||
module.exports = {
|
||||
name: 'Dimension',
|
||||
structure: {
|
||||
value: String,
|
||||
unit: String
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
var numberEnd = consumeNumber(this.scanner.source, start);
|
||||
|
||||
this.eat(DIMENSION);
|
||||
|
||||
return {
|
||||
type: 'Dimension',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
value: this.scanner.source.substring(start, numberEnd),
|
||||
unit: this.scanner.source.substring(numberEnd, this.scanner.tokenStart)
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk(node.value);
|
||||
this.chunk(node.unit);
|
||||
}
|
||||
export const name = 'Dimension';
|
||||
export const structure = {
|
||||
value: String,
|
||||
unit: String
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
const value = this.consumeNumber(Dimension);
|
||||
|
||||
return {
|
||||
type: 'Dimension',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
value,
|
||||
unit: this.substring(start + value.length, this.tokenStart)
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(Dimension, node.value + node.unit);
|
||||
}
|
||||
|
||||
103
node_modules/css-tree/lib/syntax/node/Feature.js
generated
vendored
Normal file
103
node_modules/css-tree/lib/syntax/node/Feature.js
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
import {
|
||||
Ident,
|
||||
Number,
|
||||
Dimension,
|
||||
Function as FunctionToken,
|
||||
LeftParenthesis,
|
||||
RightParenthesis,
|
||||
Colon,
|
||||
Delim
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
const SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
|
||||
|
||||
export const name = 'Feature';
|
||||
export const structure = {
|
||||
kind: String,
|
||||
name: String,
|
||||
value: ['Identifier', 'Number', 'Dimension', 'Ratio', 'Function', null]
|
||||
};
|
||||
|
||||
export function parse(kind) {
|
||||
const start = this.tokenStart;
|
||||
let name;
|
||||
let value = null;
|
||||
|
||||
this.eat(LeftParenthesis);
|
||||
this.skipSC();
|
||||
|
||||
name = this.consume(Ident);
|
||||
this.skipSC();
|
||||
|
||||
if (this.tokenType !== RightParenthesis) {
|
||||
this.eat(Colon);
|
||||
this.skipSC();
|
||||
|
||||
switch (this.tokenType) {
|
||||
case Number:
|
||||
if (this.lookupNonWSType(1) === Delim) {
|
||||
value = this.Ratio();
|
||||
} else {
|
||||
value = this.Number();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Dimension:
|
||||
value = this.Dimension();
|
||||
break;
|
||||
|
||||
case Ident:
|
||||
value = this.Identifier();
|
||||
break;
|
||||
|
||||
case FunctionToken:
|
||||
value = this.parseWithFallback(
|
||||
() => {
|
||||
const res = this.Function(this.readSequence, this.scope.Value);
|
||||
|
||||
this.skipSC();
|
||||
|
||||
if (this.isDelim(SOLIDUS)) {
|
||||
this.error();
|
||||
}
|
||||
|
||||
return res;
|
||||
},
|
||||
() => {
|
||||
return this.Ratio();
|
||||
}
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
this.error('Number, dimension, ratio or identifier is expected');
|
||||
}
|
||||
|
||||
this.skipSC();
|
||||
}
|
||||
|
||||
if (!this.eof) {
|
||||
this.eat(RightParenthesis);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Feature',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
kind,
|
||||
name,
|
||||
value
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(LeftParenthesis, '(');
|
||||
this.token(Ident, node.name);
|
||||
|
||||
if (node.value !== null) {
|
||||
this.token(Colon, ':');
|
||||
this.node(node.value);
|
||||
}
|
||||
|
||||
this.token(RightParenthesis, ')');
|
||||
}
|
||||
63
node_modules/css-tree/lib/syntax/node/FeatureFunction.js
generated
vendored
Normal file
63
node_modules/css-tree/lib/syntax/node/FeatureFunction.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
import {
|
||||
Function as FunctionToken,
|
||||
RightParenthesis
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
export const name = 'FeatureFunction';
|
||||
export const structure = {
|
||||
kind: String,
|
||||
feature: String,
|
||||
value: ['Declaration', 'Selector']
|
||||
};
|
||||
|
||||
function getFeatureParser(kind, name) {
|
||||
const featuresOfKind = this.features[kind] || {};
|
||||
const parser = featuresOfKind[name];
|
||||
|
||||
if (typeof parser !== 'function') {
|
||||
this.error(`Unknown feature ${name}()`);
|
||||
}
|
||||
|
||||
return parser;
|
||||
}
|
||||
|
||||
export function parse(kind = 'unknown') {
|
||||
const start = this.tokenStart;
|
||||
const functionName = this.consumeFunctionName();
|
||||
const valueParser = getFeatureParser.call(this, kind, functionName.toLowerCase());
|
||||
|
||||
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;
|
||||
},
|
||||
() => this.Raw(null, false)
|
||||
);
|
||||
|
||||
if (!this.eof) {
|
||||
this.eat(RightParenthesis);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'FeatureFunction',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
kind,
|
||||
feature: functionName,
|
||||
value
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(FunctionToken, node.feature + '(');
|
||||
this.node(node.value);
|
||||
this.token(RightParenthesis, ')');
|
||||
}
|
||||
133
node_modules/css-tree/lib/syntax/node/FeatureRange.js
generated
vendored
Normal file
133
node_modules/css-tree/lib/syntax/node/FeatureRange.js
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
import {
|
||||
Ident,
|
||||
Number,
|
||||
Dimension,
|
||||
Function as FunctionToken,
|
||||
LeftParenthesis,
|
||||
RightParenthesis
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
const SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
|
||||
const LESSTHANSIGN = 0x003C; // U+003C LESS-THAN SIGN (<)
|
||||
const EQUALSSIGN = 0x003D; // U+003D EQUALS SIGN (=)
|
||||
const GREATERTHANSIGN = 0x003E; // U+003E GREATER-THAN SIGN (>)
|
||||
|
||||
export const name = 'FeatureRange';
|
||||
export const structure = {
|
||||
kind: String,
|
||||
left: ['Identifier', 'Number', 'Dimension', 'Ratio', 'Function'],
|
||||
leftComparison: String,
|
||||
middle: ['Identifier', 'Number', 'Dimension', 'Ratio', 'Function'],
|
||||
rightComparison: [String, null],
|
||||
right: ['Identifier', 'Number', 'Dimension', 'Ratio', 'Function', null]
|
||||
};
|
||||
|
||||
function readTerm() {
|
||||
this.skipSC();
|
||||
|
||||
switch (this.tokenType) {
|
||||
case Number:
|
||||
if (this.isDelim(SOLIDUS, this.lookupOffsetNonSC(1))) {
|
||||
return this.Ratio();
|
||||
} else {
|
||||
return this.Number();
|
||||
}
|
||||
|
||||
case Dimension:
|
||||
return this.Dimension();
|
||||
|
||||
case Ident:
|
||||
return this.Identifier();
|
||||
|
||||
case FunctionToken:
|
||||
return this.parseWithFallback(
|
||||
() => {
|
||||
const res = this.Function(this.readSequence, this.scope.Value);
|
||||
|
||||
this.skipSC();
|
||||
|
||||
if (this.isDelim(SOLIDUS)) {
|
||||
this.error();
|
||||
}
|
||||
|
||||
return res;
|
||||
},
|
||||
() => {
|
||||
return this.Ratio();
|
||||
}
|
||||
);
|
||||
|
||||
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(EQUALSSIGN)) {
|
||||
this.next();
|
||||
return value + '=';
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
if (this.isDelim(EQUALSSIGN)) {
|
||||
return '=';
|
||||
}
|
||||
|
||||
this.error(`Expected ${expectColon ? '":", ' : ''}"<", ">", "=" or ")"`);
|
||||
}
|
||||
|
||||
export function parse(kind = 'unknown') {
|
||||
const start = this.tokenStart;
|
||||
|
||||
this.skipSC();
|
||||
this.eat(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) !== RightParenthesis) {
|
||||
rightComparison = readComparison.call(this);
|
||||
right = readTerm.call(this);
|
||||
}
|
||||
|
||||
this.skipSC();
|
||||
this.eat(RightParenthesis);
|
||||
|
||||
return {
|
||||
type: 'FeatureRange',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
kind,
|
||||
left,
|
||||
leftComparison,
|
||||
middle,
|
||||
rightComparison,
|
||||
right
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(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(RightParenthesis, ')');
|
||||
}
|
||||
69
node_modules/css-tree/lib/syntax/node/Function.js
generated
vendored
69
node_modules/css-tree/lib/syntax/node/Function.js
generated
vendored
@@ -1,40 +1,41 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import {
|
||||
Function as FunctionToken,
|
||||
RightParenthesis
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
var RIGHTPARENTHESIS = TYPE.RightParenthesis;
|
||||
|
||||
export const name = 'Function';
|
||||
export const walkContext = 'function';
|
||||
export const structure = {
|
||||
name: String,
|
||||
children: [[]]
|
||||
};
|
||||
|
||||
// <function-token> <sequence> )
|
||||
module.exports = {
|
||||
name: 'Function',
|
||||
structure: {
|
||||
name: String,
|
||||
children: [[]]
|
||||
},
|
||||
parse: function(readSequence, recognizer) {
|
||||
var start = this.scanner.tokenStart;
|
||||
var name = this.consumeFunctionName();
|
||||
var nameLowerCase = name.toLowerCase();
|
||||
var children;
|
||||
export function parse(readSequence, recognizer) {
|
||||
const start = this.tokenStart;
|
||||
const name = this.consumeFunctionName();
|
||||
const nameLowerCase = name.toLowerCase();
|
||||
let children;
|
||||
|
||||
children = recognizer.hasOwnProperty(nameLowerCase)
|
||||
? recognizer[nameLowerCase].call(this, recognizer)
|
||||
: readSequence.call(this, recognizer);
|
||||
children = recognizer.hasOwnProperty(nameLowerCase)
|
||||
? recognizer[nameLowerCase].call(this, recognizer)
|
||||
: readSequence.call(this, recognizer);
|
||||
|
||||
if (!this.scanner.eof) {
|
||||
this.eat(RIGHTPARENTHESIS);
|
||||
}
|
||||
if (!this.eof) {
|
||||
this.eat(RightParenthesis);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Function',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
name: name,
|
||||
children: children
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk(node.name);
|
||||
this.chunk('(');
|
||||
this.children(node);
|
||||
this.chunk(')');
|
||||
},
|
||||
walkContext: 'function'
|
||||
};
|
||||
return {
|
||||
type: 'Function',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
name,
|
||||
children
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(FunctionToken, node.name + '(');
|
||||
this.children(node);
|
||||
this.token(RightParenthesis, ')');
|
||||
}
|
||||
|
||||
66
node_modules/css-tree/lib/syntax/node/GeneralEnclosed.js
generated
vendored
Normal file
66
node_modules/css-tree/lib/syntax/node/GeneralEnclosed.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
import {
|
||||
Function as FunctionToken,
|
||||
LeftParenthesis,
|
||||
RightParenthesis
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
|
||||
export const name = 'GeneralEnclosed';
|
||||
export const structure = {
|
||||
kind: String,
|
||||
function: [String, null],
|
||||
children: [[]]
|
||||
};
|
||||
|
||||
// <function-token> <any-value> )
|
||||
// ( <any-value> )
|
||||
export function parse(kind) {
|
||||
const start = this.tokenStart;
|
||||
let functionName = null;
|
||||
|
||||
if (this.tokenType === FunctionToken) {
|
||||
functionName = this.consumeFunctionName();
|
||||
} else {
|
||||
this.eat(LeftParenthesis);
|
||||
}
|
||||
|
||||
const children = this.parseWithFallback(
|
||||
() => {
|
||||
const startValueToken = this.tokenIndex;
|
||||
const children = this.readSequence(this.scope.Value);
|
||||
|
||||
if (this.eof === false &&
|
||||
this.isBalanceEdge(startValueToken) === false) {
|
||||
this.error();
|
||||
}
|
||||
|
||||
return children;
|
||||
},
|
||||
() => this.createSingleNodeList(
|
||||
this.Raw(null, false)
|
||||
)
|
||||
);
|
||||
|
||||
if (!this.eof) {
|
||||
this.eat(RightParenthesis);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'GeneralEnclosed',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
kind,
|
||||
function: functionName,
|
||||
children
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
if (node.function) {
|
||||
this.token(FunctionToken, node.function + '(');
|
||||
} else {
|
||||
this.token(LeftParenthesis, '(');
|
||||
}
|
||||
|
||||
this.children(node);
|
||||
this.token(RightParenthesis, ')');
|
||||
}
|
||||
43
node_modules/css-tree/lib/syntax/node/Hash.js
generated
vendored
43
node_modules/css-tree/lib/syntax/node/Hash.js
generated
vendored
@@ -1,26 +1,23 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
|
||||
var HASH = TYPE.Hash;
|
||||
import { Hash } from '../../tokenizer/index.js';
|
||||
|
||||
// '#' ident
|
||||
module.exports = {
|
||||
name: 'Hash',
|
||||
structure: {
|
||||
value: String
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
|
||||
this.eat(HASH);
|
||||
|
||||
return {
|
||||
type: 'Hash',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
value: this.scanner.substrToCursor(start + 1)
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk('#');
|
||||
this.chunk(node.value);
|
||||
}
|
||||
export const xxx = 'XXX';
|
||||
export const name = 'Hash';
|
||||
export const structure = {
|
||||
value: String
|
||||
};
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
|
||||
this.eat(Hash);
|
||||
|
||||
return {
|
||||
type: 'Hash',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
value: this.substrToCursor(start + 1)
|
||||
};
|
||||
}
|
||||
export function generate(node) {
|
||||
this.token(Hash, '#' + node.value);
|
||||
}
|
||||
|
||||
|
||||
49
node_modules/css-tree/lib/syntax/node/IdSelector.js
generated
vendored
49
node_modules/css-tree/lib/syntax/node/IdSelector.js
generated
vendored
@@ -1,27 +1,26 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import { Hash, Delim } from '../../tokenizer/index.js';
|
||||
|
||||
var HASH = TYPE.Hash;
|
||||
|
||||
// <hash-token>
|
||||
module.exports = {
|
||||
name: 'IdSelector',
|
||||
structure: {
|
||||
name: String
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
|
||||
// TODO: check value is an ident
|
||||
this.eat(HASH);
|
||||
|
||||
return {
|
||||
type: 'IdSelector',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
name: this.scanner.substrToCursor(start + 1)
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk('#');
|
||||
this.chunk(node.name);
|
||||
}
|
||||
export const name = 'IdSelector';
|
||||
export const structure = {
|
||||
name: String
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
|
||||
// TODO: check value is an ident
|
||||
this.eat(Hash);
|
||||
|
||||
return {
|
||||
type: 'IdSelector',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
name: this.substrToCursor(start + 1)
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
// Using Delim instead of Hash is a hack to avoid for a whitespace between ident and id-selector
|
||||
// in safe mode (e.g. "a#id"), because IE11 doesn't allow a sequence <ident-token> <hash-token>
|
||||
// without a whitespace in values (e.g. "1px solid#000")
|
||||
this.token(Delim, '#' + node.name);
|
||||
}
|
||||
|
||||
34
node_modules/css-tree/lib/syntax/node/Identifier.js
generated
vendored
34
node_modules/css-tree/lib/syntax/node/Identifier.js
generated
vendored
@@ -1,20 +1,18 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import { Ident } from '../../tokenizer/index.js';
|
||||
|
||||
var IDENT = TYPE.Ident;
|
||||
|
||||
module.exports = {
|
||||
name: 'Identifier',
|
||||
structure: {
|
||||
name: String
|
||||
},
|
||||
parse: function() {
|
||||
return {
|
||||
type: 'Identifier',
|
||||
loc: this.getLocation(this.scanner.tokenStart, this.scanner.tokenEnd),
|
||||
name: this.consume(IDENT)
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk(node.name);
|
||||
}
|
||||
export const name = 'Identifier';
|
||||
export const structure = {
|
||||
name: String
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
return {
|
||||
type: 'Identifier',
|
||||
loc: this.getLocation(this.tokenStart, this.tokenEnd),
|
||||
name: this.consume(Ident)
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(Ident, node.name);
|
||||
}
|
||||
|
||||
28
node_modules/css-tree/lib/syntax/node/Layer.js
generated
vendored
Normal file
28
node_modules/css-tree/lib/syntax/node/Layer.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { Ident, Delim } from '../../tokenizer/index.js';
|
||||
|
||||
const FULLSTOP = 0x002E; // U+002E FULL STOP (.)
|
||||
|
||||
export const name = 'Layer';
|
||||
export const structure = {
|
||||
name: String
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
let tokenStart = this.tokenStart;
|
||||
let name = this.consume(Ident);
|
||||
|
||||
while (this.isDelim(FULLSTOP)) {
|
||||
this.eat(Delim);
|
||||
name += '.' + this.consume(Ident);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Layer',
|
||||
loc: this.getLocation(tokenStart, this.tokenStart),
|
||||
name
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.tokenize(node.name);
|
||||
}
|
||||
36
node_modules/css-tree/lib/syntax/node/LayerList.js
generated
vendored
Normal file
36
node_modules/css-tree/lib/syntax/node/LayerList.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Comma } from '../../tokenizer/index.js';
|
||||
|
||||
export const name = 'LayerList';
|
||||
export const structure = {
|
||||
children: [[
|
||||
'Layer'
|
||||
]]
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
const children = this.createList();
|
||||
|
||||
this.skipSC();
|
||||
|
||||
while (!this.eof) {
|
||||
children.push(this.Layer());
|
||||
|
||||
if (this.lookupTypeNonSC(0) !== Comma) {
|
||||
break;
|
||||
}
|
||||
|
||||
this.skipSC();
|
||||
this.next();
|
||||
this.skipSC();
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'LayerList',
|
||||
loc: this.getLocationFromList(children),
|
||||
children
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.children(node, () => this.token(Comma, ','));
|
||||
}
|
||||
76
node_modules/css-tree/lib/syntax/node/MediaFeature.js
generated
vendored
76
node_modules/css-tree/lib/syntax/node/MediaFeature.js
generated
vendored
@@ -1,76 +0,0 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
|
||||
var IDENT = TYPE.Ident;
|
||||
var NUMBER = TYPE.Number;
|
||||
var DIMENSION = TYPE.Dimension;
|
||||
var LEFTPARENTHESIS = TYPE.LeftParenthesis;
|
||||
var RIGHTPARENTHESIS = TYPE.RightParenthesis;
|
||||
var COLON = TYPE.Colon;
|
||||
var DELIM = TYPE.Delim;
|
||||
|
||||
module.exports = {
|
||||
name: 'MediaFeature',
|
||||
structure: {
|
||||
name: String,
|
||||
value: ['Identifier', 'Number', 'Dimension', 'Ratio', null]
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
var name;
|
||||
var value = null;
|
||||
|
||||
this.eat(LEFTPARENTHESIS);
|
||||
this.scanner.skipSC();
|
||||
|
||||
name = this.consume(IDENT);
|
||||
this.scanner.skipSC();
|
||||
|
||||
if (this.scanner.tokenType !== RIGHTPARENTHESIS) {
|
||||
this.eat(COLON);
|
||||
this.scanner.skipSC();
|
||||
|
||||
switch (this.scanner.tokenType) {
|
||||
case NUMBER:
|
||||
if (this.lookupNonWSType(1) === DELIM) {
|
||||
value = this.Ratio();
|
||||
} else {
|
||||
value = this.Number();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case DIMENSION:
|
||||
value = this.Dimension();
|
||||
break;
|
||||
|
||||
case IDENT:
|
||||
value = this.Identifier();
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
this.error('Number, dimension, ratio or identifier is expected');
|
||||
}
|
||||
|
||||
this.scanner.skipSC();
|
||||
}
|
||||
|
||||
this.eat(RIGHTPARENTHESIS);
|
||||
|
||||
return {
|
||||
type: 'MediaFeature',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
name: name,
|
||||
value: value
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk('(');
|
||||
this.chunk(node.name);
|
||||
if (node.value !== null) {
|
||||
this.chunk(':');
|
||||
this.node(node.value);
|
||||
}
|
||||
this.chunk(')');
|
||||
}
|
||||
};
|
||||
166
node_modules/css-tree/lib/syntax/node/MediaQuery.js
generated
vendored
166
node_modules/css-tree/lib/syntax/node/MediaQuery.js
generated
vendored
@@ -1,68 +1,102 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import {
|
||||
Comma,
|
||||
EOF,
|
||||
Ident,
|
||||
LeftCurlyBracket,
|
||||
LeftParenthesis,
|
||||
Function as FunctionToken,
|
||||
Semicolon
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
var WHITESPACE = TYPE.WhiteSpace;
|
||||
var COMMENT = TYPE.Comment;
|
||||
var IDENT = TYPE.Ident;
|
||||
var LEFTPARENTHESIS = TYPE.LeftParenthesis;
|
||||
|
||||
module.exports = {
|
||||
name: 'MediaQuery',
|
||||
structure: {
|
||||
children: [[
|
||||
'Identifier',
|
||||
'MediaFeature',
|
||||
'WhiteSpace'
|
||||
]]
|
||||
},
|
||||
parse: function() {
|
||||
this.scanner.skipSC();
|
||||
|
||||
var children = this.createList();
|
||||
var child = null;
|
||||
var space = null;
|
||||
|
||||
scan:
|
||||
while (!this.scanner.eof) {
|
||||
switch (this.scanner.tokenType) {
|
||||
case COMMENT:
|
||||
this.scanner.next();
|
||||
continue;
|
||||
|
||||
case WHITESPACE:
|
||||
space = this.WhiteSpace();
|
||||
continue;
|
||||
|
||||
case IDENT:
|
||||
child = this.Identifier();
|
||||
break;
|
||||
|
||||
case LEFTPARENTHESIS:
|
||||
child = this.MediaFeature();
|
||||
break;
|
||||
|
||||
default:
|
||||
break scan;
|
||||
}
|
||||
|
||||
if (space !== null) {
|
||||
children.push(space);
|
||||
space = null;
|
||||
}
|
||||
|
||||
children.push(child);
|
||||
}
|
||||
|
||||
if (child === null) {
|
||||
this.error('Identifier or parenthesis is expected');
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'MediaQuery',
|
||||
loc: this.getLocationFromList(children),
|
||||
children: children
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.children(node);
|
||||
}
|
||||
export const name = 'MediaQuery';
|
||||
export const structure = {
|
||||
modifier: [String, null],
|
||||
mediaType: [String, null],
|
||||
condition: ['Condition', null]
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
let modifier = null;
|
||||
let mediaType = null;
|
||||
let condition = null;
|
||||
|
||||
this.skipSC();
|
||||
|
||||
if (this.tokenType === Ident && this.lookupTypeNonSC(1) !== LeftParenthesis) {
|
||||
// [ not | only ]? <media-type>
|
||||
const ident = this.consume(Ident);
|
||||
const identLowerCase = ident.toLowerCase();
|
||||
|
||||
if (identLowerCase === 'not' || identLowerCase === 'only') {
|
||||
this.skipSC();
|
||||
modifier = identLowerCase;
|
||||
mediaType = this.consume(Ident);
|
||||
} else {
|
||||
mediaType = ident;
|
||||
}
|
||||
|
||||
switch (this.lookupTypeNonSC(0)) {
|
||||
case Ident: {
|
||||
// and <media-condition-without-or>
|
||||
this.skipSC();
|
||||
this.eatIdent('and');
|
||||
condition = this.Condition('media');
|
||||
break;
|
||||
}
|
||||
|
||||
case LeftCurlyBracket:
|
||||
case Semicolon:
|
||||
case Comma:
|
||||
case EOF:
|
||||
break;
|
||||
|
||||
default:
|
||||
this.error('Identifier or parenthesis is expected');
|
||||
}
|
||||
} else {
|
||||
switch (this.tokenType) {
|
||||
case Ident:
|
||||
case LeftParenthesis:
|
||||
case FunctionToken: {
|
||||
// <media-condition>
|
||||
condition = this.Condition('media');
|
||||
break;
|
||||
}
|
||||
|
||||
case LeftCurlyBracket:
|
||||
case Semicolon:
|
||||
case EOF:
|
||||
break;
|
||||
|
||||
default:
|
||||
this.error('Identifier or parenthesis is expected');
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'MediaQuery',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
modifier,
|
||||
mediaType,
|
||||
condition
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
if (node.mediaType) {
|
||||
if (node.modifier) {
|
||||
this.token(Ident, node.modifier);
|
||||
}
|
||||
|
||||
this.token(Ident, node.mediaType);
|
||||
|
||||
if (node.condition) {
|
||||
this.token(Ident, 'and');
|
||||
this.node(node.condition);
|
||||
}
|
||||
} else if (node.condition) {
|
||||
this.node(node.condition);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
54
node_modules/css-tree/lib/syntax/node/MediaQueryList.js
generated
vendored
54
node_modules/css-tree/lib/syntax/node/MediaQueryList.js
generated
vendored
@@ -1,36 +1,34 @@
|
||||
var COMMA = require('../../tokenizer').TYPE.Comma;
|
||||
import { Comma } from '../../tokenizer/index.js';
|
||||
|
||||
module.exports = {
|
||||
name: 'MediaQueryList',
|
||||
structure: {
|
||||
children: [[
|
||||
'MediaQuery'
|
||||
]]
|
||||
},
|
||||
parse: function(relative) {
|
||||
var children = this.createList();
|
||||
export const name = 'MediaQueryList';
|
||||
export const structure = {
|
||||
children: [[
|
||||
'MediaQuery'
|
||||
]]
|
||||
};
|
||||
|
||||
this.scanner.skipSC();
|
||||
export function parse() {
|
||||
const children = this.createList();
|
||||
|
||||
while (!this.scanner.eof) {
|
||||
children.push(this.MediaQuery(relative));
|
||||
this.skipSC();
|
||||
|
||||
if (this.scanner.tokenType !== COMMA) {
|
||||
break;
|
||||
}
|
||||
while (!this.eof) {
|
||||
children.push(this.MediaQuery());
|
||||
|
||||
this.scanner.next();
|
||||
if (this.tokenType !== Comma) {
|
||||
break;
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'MediaQueryList',
|
||||
loc: this.getLocationFromList(children),
|
||||
children: children
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.children(node, function() {
|
||||
this.chunk(',');
|
||||
});
|
||||
this.next();
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
type: 'MediaQueryList',
|
||||
loc: this.getLocationFromList(children),
|
||||
children
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.children(node, () => this.token(Comma, ','));
|
||||
}
|
||||
|
||||
22
node_modules/css-tree/lib/syntax/node/NestingSelector.js
generated
vendored
Normal file
22
node_modules/css-tree/lib/syntax/node/NestingSelector.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Delim } from '../../tokenizer/index.js';
|
||||
|
||||
const AMPERSAND = 0x0026; // U+0026 AMPERSAND (&)
|
||||
|
||||
export const name = 'NestingSelector';
|
||||
export const structure = {
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
|
||||
this.eatDelim(AMPERSAND);
|
||||
|
||||
return {
|
||||
type: 'NestingSelector',
|
||||
loc: this.getLocation(start, this.tokenStart)
|
||||
};
|
||||
}
|
||||
|
||||
export function generate() {
|
||||
this.token(Delim, '&');
|
||||
}
|
||||
94
node_modules/css-tree/lib/syntax/node/Nth.js
generated
vendored
94
node_modules/css-tree/lib/syntax/node/Nth.js
generated
vendored
@@ -1,51 +1,47 @@
|
||||
module.exports = {
|
||||
name: 'Nth',
|
||||
structure: {
|
||||
nth: ['AnPlusB', 'Identifier'],
|
||||
selector: ['SelectorList', null]
|
||||
},
|
||||
parse: function(allowOfClause) {
|
||||
this.scanner.skipSC();
|
||||
import { Ident } from '../../tokenizer/index.js';
|
||||
|
||||
var start = this.scanner.tokenStart;
|
||||
var end = start;
|
||||
var selector = null;
|
||||
var query;
|
||||
|
||||
if (this.scanner.lookupValue(0, 'odd') || this.scanner.lookupValue(0, 'even')) {
|
||||
query = this.Identifier();
|
||||
} else {
|
||||
query = this.AnPlusB();
|
||||
}
|
||||
|
||||
this.scanner.skipSC();
|
||||
|
||||
if (allowOfClause && this.scanner.lookupValue(0, 'of')) {
|
||||
this.scanner.next();
|
||||
|
||||
selector = this.SelectorList();
|
||||
|
||||
if (this.needPositions) {
|
||||
end = this.getLastListNode(selector.children).loc.end.offset;
|
||||
}
|
||||
} else {
|
||||
if (this.needPositions) {
|
||||
end = query.loc.end.offset;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Nth',
|
||||
loc: this.getLocation(start, end),
|
||||
nth: query,
|
||||
selector: selector
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.node(node.nth);
|
||||
if (node.selector !== null) {
|
||||
this.chunk(' of ');
|
||||
this.node(node.selector);
|
||||
}
|
||||
}
|
||||
export const name = 'Nth';
|
||||
export const structure = {
|
||||
nth: ['AnPlusB', 'Identifier'],
|
||||
selector: ['SelectorList', null]
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
this.skipSC();
|
||||
|
||||
const start = this.tokenStart;
|
||||
let end = start;
|
||||
let selector = null;
|
||||
let nth;
|
||||
|
||||
if (this.lookupValue(0, 'odd') || this.lookupValue(0, 'even')) {
|
||||
nth = this.Identifier();
|
||||
} else {
|
||||
nth = this.AnPlusB();
|
||||
}
|
||||
|
||||
end = this.tokenStart;
|
||||
this.skipSC();
|
||||
|
||||
if (this.lookupValue(0, 'of')) {
|
||||
this.next();
|
||||
|
||||
selector = this.SelectorList();
|
||||
end = this.tokenStart;
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Nth',
|
||||
loc: this.getLocation(start, end),
|
||||
nth,
|
||||
selector
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.node(node.nth);
|
||||
if (node.selector !== null) {
|
||||
this.token(Ident, 'of');
|
||||
this.node(node.selector);
|
||||
}
|
||||
}
|
||||
|
||||
32
node_modules/css-tree/lib/syntax/node/Number.js
generated
vendored
32
node_modules/css-tree/lib/syntax/node/Number.js
generated
vendored
@@ -1,18 +1,18 @@
|
||||
var NUMBER = require('../../tokenizer').TYPE.Number;
|
||||
import { Number as NumberToken } from '../../tokenizer/index.js';
|
||||
|
||||
module.exports = {
|
||||
name: 'Number',
|
||||
structure: {
|
||||
value: String
|
||||
},
|
||||
parse: function() {
|
||||
return {
|
||||
type: 'Number',
|
||||
loc: this.getLocation(this.scanner.tokenStart, this.scanner.tokenEnd),
|
||||
value: this.consume(NUMBER)
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk(node.value);
|
||||
}
|
||||
export const name = 'Number';
|
||||
export const structure = {
|
||||
value: String
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
return {
|
||||
type: 'Number',
|
||||
loc: this.getLocation(this.tokenStart, this.tokenEnd),
|
||||
value: this.consume(NumberToken)
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(NumberToken, node.value);
|
||||
}
|
||||
|
||||
38
node_modules/css-tree/lib/syntax/node/Operator.js
generated
vendored
38
node_modules/css-tree/lib/syntax/node/Operator.js
generated
vendored
@@ -1,21 +1,21 @@
|
||||
// '/' | '*' | ',' | ':' | '+' | '-'
|
||||
module.exports = {
|
||||
name: 'Operator',
|
||||
structure: {
|
||||
value: String
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
|
||||
this.scanner.next();
|
||||
|
||||
return {
|
||||
type: 'Operator',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
value: this.scanner.substrToCursor(start)
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk(node.value);
|
||||
}
|
||||
export const name = 'Operator';
|
||||
export const structure = {
|
||||
value: String
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
|
||||
this.next();
|
||||
|
||||
return {
|
||||
type: 'Operator',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
value: this.substrToCursor(start)
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.tokenize(node.value);
|
||||
}
|
||||
|
||||
64
node_modules/css-tree/lib/syntax/node/Parentheses.js
generated
vendored
64
node_modules/css-tree/lib/syntax/node/Parentheses.js
generated
vendored
@@ -1,34 +1,34 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import {
|
||||
LeftParenthesis,
|
||||
RightParenthesis
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
var LEFTPARENTHESIS = TYPE.LeftParenthesis;
|
||||
var RIGHTPARENTHESIS = TYPE.RightParenthesis;
|
||||
|
||||
module.exports = {
|
||||
name: 'Parentheses',
|
||||
structure: {
|
||||
children: [[]]
|
||||
},
|
||||
parse: function(readSequence, recognizer) {
|
||||
var start = this.scanner.tokenStart;
|
||||
var children = null;
|
||||
|
||||
this.eat(LEFTPARENTHESIS);
|
||||
|
||||
children = readSequence.call(this, recognizer);
|
||||
|
||||
if (!this.scanner.eof) {
|
||||
this.eat(RIGHTPARENTHESIS);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Parentheses',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
children: children
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk('(');
|
||||
this.children(node);
|
||||
this.chunk(')');
|
||||
}
|
||||
export const name = 'Parentheses';
|
||||
export const structure = {
|
||||
children: [[]]
|
||||
};
|
||||
|
||||
export function parse(readSequence, recognizer) {
|
||||
const start = this.tokenStart;
|
||||
let children = null;
|
||||
|
||||
this.eat(LeftParenthesis);
|
||||
|
||||
children = readSequence.call(this, recognizer);
|
||||
|
||||
if (!this.eof) {
|
||||
this.eat(RightParenthesis);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Parentheses',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
children
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(LeftParenthesis, '(');
|
||||
this.children(node);
|
||||
this.token(RightParenthesis, ')');
|
||||
}
|
||||
|
||||
41
node_modules/css-tree/lib/syntax/node/Percentage.js
generated
vendored
41
node_modules/css-tree/lib/syntax/node/Percentage.js
generated
vendored
@@ -1,27 +1,18 @@
|
||||
var consumeNumber = require('../../tokenizer/utils').consumeNumber;
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import { Percentage } from '../../tokenizer/index.js';
|
||||
|
||||
var PERCENTAGE = TYPE.Percentage;
|
||||
|
||||
module.exports = {
|
||||
name: 'Percentage',
|
||||
structure: {
|
||||
value: String
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
var numberEnd = consumeNumber(this.scanner.source, start);
|
||||
|
||||
this.eat(PERCENTAGE);
|
||||
|
||||
return {
|
||||
type: 'Percentage',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
value: this.scanner.source.substring(start, numberEnd)
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk(node.value);
|
||||
this.chunk('%');
|
||||
}
|
||||
export const name = 'Percentage';
|
||||
export const structure = {
|
||||
value: String
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
return {
|
||||
type: 'Percentage',
|
||||
loc: this.getLocation(this.tokenStart, this.tokenEnd),
|
||||
value: this.consumeNumber(Percentage)
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(Percentage, node.value + '%');
|
||||
}
|
||||
|
||||
106
node_modules/css-tree/lib/syntax/node/PseudoClassSelector.js
generated
vendored
106
node_modules/css-tree/lib/syntax/node/PseudoClassSelector.js
generated
vendored
@@ -1,61 +1,65 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import {
|
||||
Ident,
|
||||
Function as FunctionToken,
|
||||
Colon,
|
||||
RightParenthesis
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
var IDENT = TYPE.Ident;
|
||||
var FUNCTION = TYPE.Function;
|
||||
var COLON = TYPE.Colon;
|
||||
var RIGHTPARENTHESIS = TYPE.RightParenthesis;
|
||||
|
||||
export const name = 'PseudoClassSelector';
|
||||
export const walkContext = 'function';
|
||||
export const structure = {
|
||||
name: String,
|
||||
children: [['Raw'], null]
|
||||
};
|
||||
|
||||
// : [ <ident> | <function-token> <any-value>? ) ]
|
||||
module.exports = {
|
||||
name: 'PseudoClassSelector',
|
||||
structure: {
|
||||
name: String,
|
||||
children: [['Raw'], null]
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
var children = null;
|
||||
var name;
|
||||
var nameLowerCase;
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
let children = null;
|
||||
let name;
|
||||
let nameLowerCase;
|
||||
|
||||
this.eat(COLON);
|
||||
this.eat(Colon);
|
||||
|
||||
if (this.scanner.tokenType === FUNCTION) {
|
||||
name = this.consumeFunctionName();
|
||||
nameLowerCase = name.toLowerCase();
|
||||
if (this.tokenType === FunctionToken) {
|
||||
name = this.consumeFunctionName();
|
||||
nameLowerCase = name.toLowerCase();
|
||||
|
||||
if (this.pseudo.hasOwnProperty(nameLowerCase)) {
|
||||
this.scanner.skipSC();
|
||||
children = this.pseudo[nameLowerCase].call(this);
|
||||
this.scanner.skipSC();
|
||||
} else {
|
||||
children = this.createList();
|
||||
children.push(
|
||||
this.Raw(this.scanner.tokenIndex, null, false)
|
||||
);
|
||||
}
|
||||
|
||||
this.eat(RIGHTPARENTHESIS);
|
||||
if (this.lookupNonWSType(0) == RightParenthesis) {
|
||||
children = this.createList();
|
||||
} else if (hasOwnProperty.call(this.pseudo, nameLowerCase)) {
|
||||
this.skipSC();
|
||||
children = this.pseudo[nameLowerCase].call(this);
|
||||
this.skipSC();
|
||||
} else {
|
||||
name = this.consume(IDENT);
|
||||
children = this.createList();
|
||||
children.push(
|
||||
this.Raw(null, false)
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'PseudoClassSelector',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
name: name,
|
||||
children: children
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk(':');
|
||||
this.chunk(node.name);
|
||||
this.eat(RightParenthesis);
|
||||
} else {
|
||||
name = this.consume(Ident);
|
||||
}
|
||||
|
||||
if (node.children !== null) {
|
||||
this.chunk('(');
|
||||
this.children(node);
|
||||
this.chunk(')');
|
||||
}
|
||||
},
|
||||
walkContext: 'function'
|
||||
};
|
||||
return {
|
||||
type: 'PseudoClassSelector',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
name,
|
||||
children
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(Colon, ':');
|
||||
|
||||
if (node.children === null) {
|
||||
this.token(Ident, node.name);
|
||||
} else {
|
||||
this.token(FunctionToken, node.name + '(');
|
||||
this.children(node);
|
||||
this.token(RightParenthesis, ')');
|
||||
}
|
||||
}
|
||||
|
||||
108
node_modules/css-tree/lib/syntax/node/PseudoElementSelector.js
generated
vendored
108
node_modules/css-tree/lib/syntax/node/PseudoElementSelector.js
generated
vendored
@@ -1,62 +1,66 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import {
|
||||
Ident,
|
||||
Function as FunctionToken,
|
||||
Colon,
|
||||
RightParenthesis
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
var IDENT = TYPE.Ident;
|
||||
var FUNCTION = TYPE.Function;
|
||||
var COLON = TYPE.Colon;
|
||||
var RIGHTPARENTHESIS = TYPE.RightParenthesis;
|
||||
export const name = 'PseudoElementSelector';
|
||||
export const walkContext = 'function';
|
||||
export const structure = {
|
||||
name: String,
|
||||
children: [['Raw'], null]
|
||||
};
|
||||
|
||||
// :: [ <ident> | <function-token> <any-value>? ) ]
|
||||
module.exports = {
|
||||
name: 'PseudoElementSelector',
|
||||
structure: {
|
||||
name: String,
|
||||
children: [['Raw'], null]
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
var children = null;
|
||||
var name;
|
||||
var nameLowerCase;
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
let children = null;
|
||||
let name;
|
||||
let nameLowerCase;
|
||||
|
||||
this.eat(COLON);
|
||||
this.eat(COLON);
|
||||
this.eat(Colon);
|
||||
this.eat(Colon);
|
||||
|
||||
if (this.scanner.tokenType === FUNCTION) {
|
||||
name = this.consumeFunctionName();
|
||||
nameLowerCase = name.toLowerCase();
|
||||
if (this.tokenType === FunctionToken) {
|
||||
name = this.consumeFunctionName();
|
||||
nameLowerCase = name.toLowerCase();
|
||||
|
||||
if (this.pseudo.hasOwnProperty(nameLowerCase)) {
|
||||
this.scanner.skipSC();
|
||||
children = this.pseudo[nameLowerCase].call(this);
|
||||
this.scanner.skipSC();
|
||||
} else {
|
||||
children = this.createList();
|
||||
children.push(
|
||||
this.Raw(this.scanner.tokenIndex, null, false)
|
||||
);
|
||||
}
|
||||
|
||||
this.eat(RIGHTPARENTHESIS);
|
||||
if (this.lookupNonWSType(0) == RightParenthesis) {
|
||||
children = this.createList();
|
||||
} else if (hasOwnProperty.call(this.pseudo, nameLowerCase)) {
|
||||
this.skipSC();
|
||||
children = this.pseudo[nameLowerCase].call(this);
|
||||
this.skipSC();
|
||||
} else {
|
||||
name = this.consume(IDENT);
|
||||
children = this.createList();
|
||||
children.push(
|
||||
this.Raw(null, false)
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'PseudoElementSelector',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
name: name,
|
||||
children: children
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk('::');
|
||||
this.chunk(node.name);
|
||||
this.eat(RightParenthesis);
|
||||
} else {
|
||||
name = this.consume(Ident);
|
||||
}
|
||||
|
||||
if (node.children !== null) {
|
||||
this.chunk('(');
|
||||
this.children(node);
|
||||
this.chunk(')');
|
||||
}
|
||||
},
|
||||
walkContext: 'function'
|
||||
};
|
||||
return {
|
||||
type: 'PseudoElementSelector',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
name,
|
||||
children
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(Colon, ':');
|
||||
this.token(Colon, ':');
|
||||
|
||||
if (node.children === null) {
|
||||
this.token(Ident, node.name);
|
||||
} else {
|
||||
this.token(FunctionToken, node.name + '(');
|
||||
this.children(node);
|
||||
this.token(RightParenthesis, ')');
|
||||
}
|
||||
}
|
||||
|
||||
118
node_modules/css-tree/lib/syntax/node/Ratio.js
generated
vendored
118
node_modules/css-tree/lib/syntax/node/Ratio.js
generated
vendored
@@ -1,66 +1,68 @@
|
||||
var isDigit = require('../../tokenizer').isDigit;
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import {
|
||||
Delim,
|
||||
Number as NumberToken,
|
||||
Function as FunctionToken
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
var NUMBER = TYPE.Number;
|
||||
var DELIM = TYPE.Delim;
|
||||
var SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
|
||||
var FULLSTOP = 0x002E; // U+002E FULL STOP (.)
|
||||
const SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
|
||||
|
||||
// Terms of <ratio> should be a positive numbers (not zero or negative)
|
||||
// (see https://drafts.csswg.org/mediaqueries-3/#values)
|
||||
// However, -o-min-device-pixel-ratio takes fractional values as a ratio's term
|
||||
// and this is using by various sites. Therefore we relax checking on parse
|
||||
// to test a term is unsigned number without an exponent part.
|
||||
// Additional checking may be applied on lexer validation.
|
||||
function consumeNumber() {
|
||||
this.scanner.skipWS();
|
||||
// Media Queries Level 3 defines terms of <ratio> as a positive (not zero or negative)
|
||||
// integers (see https://drafts.csswg.org/mediaqueries-3/#values)
|
||||
// However, Media Queries Level 4 removes any definition of values
|
||||
// (see https://drafts.csswg.org/mediaqueries-4/#values) and refers to
|
||||
// CSS Values and Units for detail. In CSS Values and Units Level 4 a <ratio>
|
||||
// definition was added (see https://drafts.csswg.org/css-values-4/#ratios) which
|
||||
// defines ratio as "<number [0,∞]> [ / <number [0,∞]> ]?" and based on it
|
||||
// any constrains on terms were removed. Parser also doesn't test numbers
|
||||
// in any way to make possible for linting and fixing them by the tools using CSSTree.
|
||||
// An additional syntax examination may be applied by a lexer.
|
||||
function consumeTerm() {
|
||||
this.skipSC();
|
||||
|
||||
var value = this.consume(NUMBER);
|
||||
switch (this.tokenType) {
|
||||
case NumberToken:
|
||||
return this.Number();
|
||||
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
var code = value.charCodeAt(i);
|
||||
if (!isDigit(code) && code !== FULLSTOP) {
|
||||
this.error('Unsigned number is expected', this.scanner.tokenStart - value.length + i);
|
||||
}
|
||||
case FunctionToken:
|
||||
return this.Function(this.readSequence, this.scope.Value);
|
||||
|
||||
default:
|
||||
this.error('Number of function is expected');
|
||||
}
|
||||
|
||||
if (Number(value) === 0) {
|
||||
this.error('Zero number is not allowed', this.scanner.tokenStart - value.length);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
// <positive-integer> S* '/' S* <positive-integer>
|
||||
module.exports = {
|
||||
name: 'Ratio',
|
||||
structure: {
|
||||
left: String,
|
||||
right: String
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
var left = consumeNumber.call(this);
|
||||
var right;
|
||||
|
||||
this.scanner.skipWS();
|
||||
|
||||
if (!this.scanner.isDelim(SOLIDUS)) {
|
||||
this.error('Solidus is expected');
|
||||
}
|
||||
this.eat(DELIM);
|
||||
right = consumeNumber.call(this);
|
||||
|
||||
return {
|
||||
type: 'Ratio',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
left: left,
|
||||
right: right
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk(node.left);
|
||||
this.chunk('/');
|
||||
this.chunk(node.right);
|
||||
}
|
||||
export const name = 'Ratio';
|
||||
export const structure = {
|
||||
left: ['Number', 'Function'],
|
||||
right: ['Number', 'Function', null]
|
||||
};
|
||||
|
||||
// <number [0,∞]> [ / <number [0,∞]> ]?
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
const left = consumeTerm.call(this);
|
||||
let right = null;
|
||||
|
||||
this.skipSC();
|
||||
if (this.isDelim(SOLIDUS)) {
|
||||
this.eatDelim(SOLIDUS);
|
||||
right = consumeTerm.call(this);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Ratio',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
left,
|
||||
right
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.node(node.left);
|
||||
this.token(Delim, '/');
|
||||
if (node.right) {
|
||||
this.node(node.right);
|
||||
} else {
|
||||
this.node(NumberToken, 1);
|
||||
}
|
||||
}
|
||||
|
||||
112
node_modules/css-tree/lib/syntax/node/Raw.js
generated
vendored
112
node_modules/css-tree/lib/syntax/node/Raw.js
generated
vendored
@@ -1,87 +1,41 @@
|
||||
var tokenizer = require('../../tokenizer');
|
||||
var TYPE = tokenizer.TYPE;
|
||||
|
||||
var WhiteSpace = TYPE.WhiteSpace;
|
||||
var Semicolon = TYPE.Semicolon;
|
||||
var LeftCurlyBracket = TYPE.LeftCurlyBracket;
|
||||
var Delim = TYPE.Delim;
|
||||
var EXCLAMATIONMARK = 0x0021; // U+0021 EXCLAMATION MARK (!)
|
||||
import { WhiteSpace } from '../../tokenizer/index.js';
|
||||
|
||||
function getOffsetExcludeWS() {
|
||||
if (this.scanner.tokenIndex > 0) {
|
||||
if (this.scanner.lookupType(-1) === WhiteSpace) {
|
||||
return this.scanner.tokenIndex > 1
|
||||
? this.scanner.getTokenStart(this.scanner.tokenIndex - 1)
|
||||
: this.scanner.firstCharOffset;
|
||||
if (this.tokenIndex > 0) {
|
||||
if (this.lookupType(-1) === WhiteSpace) {
|
||||
return this.tokenIndex > 1
|
||||
? this.getTokenStart(this.tokenIndex - 1)
|
||||
: this.firstCharOffset;
|
||||
}
|
||||
}
|
||||
|
||||
return this.scanner.tokenStart;
|
||||
return this.tokenStart;
|
||||
}
|
||||
|
||||
// 0, 0, false
|
||||
function balanceEnd() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// LEFTCURLYBRACKET, 0, false
|
||||
function leftCurlyBracket(tokenType) {
|
||||
return tokenType === LeftCurlyBracket ? 1 : 0;
|
||||
}
|
||||
|
||||
// LEFTCURLYBRACKET, SEMICOLON, false
|
||||
function leftCurlyBracketOrSemicolon(tokenType) {
|
||||
return tokenType === LeftCurlyBracket || tokenType === Semicolon ? 1 : 0;
|
||||
}
|
||||
|
||||
// EXCLAMATIONMARK, SEMICOLON, false
|
||||
function exclamationMarkOrSemicolon(tokenType, source, offset) {
|
||||
if (tokenType === Delim && source.charCodeAt(offset) === EXCLAMATIONMARK) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return tokenType === Semicolon ? 1 : 0;
|
||||
}
|
||||
|
||||
// 0, SEMICOLON, true
|
||||
function semicolonIncluded(tokenType) {
|
||||
return tokenType === Semicolon ? 2 : 0;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'Raw',
|
||||
structure: {
|
||||
value: String
|
||||
},
|
||||
parse: function(startToken, mode, excludeWhiteSpace) {
|
||||
var startOffset = this.scanner.getTokenStart(startToken);
|
||||
var endOffset;
|
||||
|
||||
this.scanner.skip(
|
||||
this.scanner.getRawLength(startToken, mode || balanceEnd)
|
||||
);
|
||||
|
||||
if (excludeWhiteSpace && this.scanner.tokenStart > startOffset) {
|
||||
endOffset = getOffsetExcludeWS.call(this);
|
||||
} else {
|
||||
endOffset = this.scanner.tokenStart;
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Raw',
|
||||
loc: this.getLocation(startOffset, endOffset),
|
||||
value: this.scanner.source.substring(startOffset, endOffset)
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk(node.value);
|
||||
},
|
||||
|
||||
mode: {
|
||||
default: balanceEnd,
|
||||
leftCurlyBracket: leftCurlyBracket,
|
||||
leftCurlyBracketOrSemicolon: leftCurlyBracketOrSemicolon,
|
||||
exclamationMarkOrSemicolon: exclamationMarkOrSemicolon,
|
||||
semicolonIncluded: semicolonIncluded
|
||||
}
|
||||
export const name = 'Raw';
|
||||
export const structure = {
|
||||
value: String
|
||||
};
|
||||
|
||||
export function parse(consumeUntil, excludeWhiteSpace) {
|
||||
const startOffset = this.getTokenStart(this.tokenIndex);
|
||||
let endOffset;
|
||||
|
||||
this.skipUntilBalanced(this.tokenIndex, consumeUntil || this.consumeUntilBalanceEnd);
|
||||
|
||||
if (excludeWhiteSpace && this.tokenStart > startOffset) {
|
||||
endOffset = getOffsetExcludeWS.call(this);
|
||||
} else {
|
||||
endOffset = this.tokenStart;
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Raw',
|
||||
loc: this.getLocation(startOffset, endOffset),
|
||||
value: this.substring(startOffset, endOffset)
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.tokenize(node.value);
|
||||
}
|
||||
|
||||
79
node_modules/css-tree/lib/syntax/node/Rule.js
generated
vendored
79
node_modules/css-tree/lib/syntax/node/Rule.js
generated
vendored
@@ -1,54 +1,51 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
var rawMode = require('./Raw').mode;
|
||||
import { LeftCurlyBracket } from '../../tokenizer/index.js';
|
||||
|
||||
var LEFTCURLYBRACKET = TYPE.LeftCurlyBracket;
|
||||
|
||||
function consumeRaw(startToken) {
|
||||
return this.Raw(startToken, rawMode.leftCurlyBracket, true);
|
||||
function consumeRaw() {
|
||||
return this.Raw(this.consumeUntilLeftCurlyBracket, true);
|
||||
}
|
||||
|
||||
function consumePrelude() {
|
||||
var prelude = this.SelectorList();
|
||||
const prelude = this.SelectorList();
|
||||
|
||||
if (prelude.type !== 'Raw' &&
|
||||
this.scanner.eof === false &&
|
||||
this.scanner.tokenType !== LEFTCURLYBRACKET) {
|
||||
this.eof === false &&
|
||||
this.tokenType !== LeftCurlyBracket) {
|
||||
this.error();
|
||||
}
|
||||
|
||||
return prelude;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'Rule',
|
||||
structure: {
|
||||
prelude: ['SelectorList', 'Raw'],
|
||||
block: ['Block']
|
||||
},
|
||||
parse: function() {
|
||||
var startToken = this.scanner.tokenIndex;
|
||||
var startOffset = this.scanner.tokenStart;
|
||||
var prelude;
|
||||
var block;
|
||||
|
||||
if (this.parseRulePrelude) {
|
||||
prelude = this.parseWithFallback(consumePrelude, consumeRaw);
|
||||
} else {
|
||||
prelude = consumeRaw.call(this, startToken);
|
||||
}
|
||||
|
||||
block = this.Block(true);
|
||||
|
||||
return {
|
||||
type: 'Rule',
|
||||
loc: this.getLocation(startOffset, this.scanner.tokenStart),
|
||||
prelude: prelude,
|
||||
block: block
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.node(node.prelude);
|
||||
this.node(node.block);
|
||||
},
|
||||
walkContext: 'rule'
|
||||
export const name = 'Rule';
|
||||
export const walkContext = 'rule';
|
||||
export const structure = {
|
||||
prelude: ['SelectorList', 'Raw'],
|
||||
block: ['Block']
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
const startToken = this.tokenIndex;
|
||||
const startOffset = this.tokenStart;
|
||||
let prelude;
|
||||
let block;
|
||||
|
||||
if (this.parseRulePrelude) {
|
||||
prelude = this.parseWithFallback(consumePrelude, consumeRaw);
|
||||
} else {
|
||||
prelude = consumeRaw.call(this, startToken);
|
||||
}
|
||||
|
||||
block = this.Block(true);
|
||||
|
||||
return {
|
||||
type: 'Rule',
|
||||
loc: this.getLocation(startOffset, this.tokenStart),
|
||||
prelude,
|
||||
block
|
||||
};
|
||||
}
|
||||
export function generate(node) {
|
||||
this.node(node.prelude);
|
||||
this.node(node.block);
|
||||
}
|
||||
|
||||
|
||||
66
node_modules/css-tree/lib/syntax/node/Scope.js
generated
vendored
Normal file
66
node_modules/css-tree/lib/syntax/node/Scope.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
import {
|
||||
Ident,
|
||||
LeftParenthesis,
|
||||
RightParenthesis
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
export const name = 'Scope';
|
||||
export const structure = {
|
||||
root: ['SelectorList', 'Raw', null],
|
||||
limit: ['SelectorList', 'Raw', null]
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
let root = null;
|
||||
let limit = null;
|
||||
|
||||
this.skipSC();
|
||||
|
||||
const startOffset = this.tokenStart;
|
||||
if (this.tokenType === LeftParenthesis) {
|
||||
this.next();
|
||||
this.skipSC();
|
||||
root = this.parseWithFallback(
|
||||
this.SelectorList,
|
||||
() => this.Raw(false, true)
|
||||
);
|
||||
this.skipSC();
|
||||
this.eat(RightParenthesis);
|
||||
}
|
||||
|
||||
if (this.lookupNonWSType(0) === Ident) {
|
||||
this.skipSC();
|
||||
this.eatIdent('to');
|
||||
this.skipSC();
|
||||
this.eat(LeftParenthesis);
|
||||
this.skipSC();
|
||||
limit = this.parseWithFallback(
|
||||
this.SelectorList,
|
||||
() => this.Raw(false, true)
|
||||
);
|
||||
this.skipSC();
|
||||
this.eat(RightParenthesis);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Scope',
|
||||
loc: this.getLocation(startOffset, this.tokenStart),
|
||||
root,
|
||||
limit
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
if (node.root) {
|
||||
this.token(LeftParenthesis, '(');
|
||||
this.node(node.root);
|
||||
this.token(RightParenthesis, ')');
|
||||
}
|
||||
|
||||
if (node.limit) {
|
||||
this.token(Ident, 'to');
|
||||
this.token(LeftParenthesis, '(');
|
||||
this.node(node.limit);
|
||||
this.token(RightParenthesis, ')');
|
||||
}
|
||||
}
|
||||
61
node_modules/css-tree/lib/syntax/node/Selector.js
generated
vendored
61
node_modules/css-tree/lib/syntax/node/Selector.js
generated
vendored
@@ -1,32 +1,31 @@
|
||||
module.exports = {
|
||||
name: 'Selector',
|
||||
structure: {
|
||||
children: [[
|
||||
'TypeSelector',
|
||||
'IdSelector',
|
||||
'ClassSelector',
|
||||
'AttributeSelector',
|
||||
'PseudoClassSelector',
|
||||
'PseudoElementSelector',
|
||||
'Combinator',
|
||||
'WhiteSpace'
|
||||
]]
|
||||
},
|
||||
parse: function() {
|
||||
var children = this.readSequence(this.scope.Selector);
|
||||
|
||||
// nothing were consumed
|
||||
if (this.getFirstListNode(children) === null) {
|
||||
this.error('Selector is expected');
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Selector',
|
||||
loc: this.getLocationFromList(children),
|
||||
children: children
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.children(node);
|
||||
}
|
||||
export const name = 'Selector';
|
||||
export const structure = {
|
||||
children: [[
|
||||
'TypeSelector',
|
||||
'IdSelector',
|
||||
'ClassSelector',
|
||||
'AttributeSelector',
|
||||
'PseudoClassSelector',
|
||||
'PseudoElementSelector',
|
||||
'Combinator'
|
||||
]]
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
const children = this.readSequence(this.scope.Selector);
|
||||
|
||||
// nothing were consumed
|
||||
if (this.getFirstListNode(children) === null) {
|
||||
this.error('Selector is expected');
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Selector',
|
||||
loc: this.getLocationFromList(children),
|
||||
children
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.children(node);
|
||||
}
|
||||
|
||||
62
node_modules/css-tree/lib/syntax/node/SelectorList.js
generated
vendored
62
node_modules/css-tree/lib/syntax/node/SelectorList.js
generated
vendored
@@ -1,39 +1,35 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import { Comma } from '../../tokenizer/index.js';
|
||||
|
||||
var COMMA = TYPE.Comma;
|
||||
export const name = 'SelectorList';
|
||||
export const walkContext = 'selector';
|
||||
export const structure = {
|
||||
children: [[
|
||||
'Selector',
|
||||
'Raw'
|
||||
]]
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
name: 'SelectorList',
|
||||
structure: {
|
||||
children: [[
|
||||
'Selector',
|
||||
'Raw'
|
||||
]]
|
||||
},
|
||||
parse: function() {
|
||||
var children = this.createList();
|
||||
export function parse() {
|
||||
const children = this.createList();
|
||||
|
||||
while (!this.scanner.eof) {
|
||||
children.push(this.Selector());
|
||||
while (!this.eof) {
|
||||
children.push(this.Selector());
|
||||
|
||||
if (this.scanner.tokenType === COMMA) {
|
||||
this.scanner.next();
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
if (this.tokenType === Comma) {
|
||||
this.next();
|
||||
continue;
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'SelectorList',
|
||||
loc: this.getLocationFromList(children),
|
||||
children: children
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.children(node, function() {
|
||||
this.chunk(',');
|
||||
});
|
||||
},
|
||||
walkContext: 'selector'
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'SelectorList',
|
||||
loc: this.getLocationFromList(children),
|
||||
children
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.children(node, () => this.token(Comma, ','));
|
||||
}
|
||||
|
||||
33
node_modules/css-tree/lib/syntax/node/String.js
generated
vendored
33
node_modules/css-tree/lib/syntax/node/String.js
generated
vendored
@@ -1,18 +1,19 @@
|
||||
var STRING = require('../../tokenizer').TYPE.String;
|
||||
import { String as StringToken } from '../../tokenizer/index.js';
|
||||
import { decode, encode } from '../../utils/string.js';
|
||||
|
||||
module.exports = {
|
||||
name: 'String',
|
||||
structure: {
|
||||
value: String
|
||||
},
|
||||
parse: function() {
|
||||
return {
|
||||
type: 'String',
|
||||
loc: this.getLocation(this.scanner.tokenStart, this.scanner.tokenEnd),
|
||||
value: this.consume(STRING)
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk(node.value);
|
||||
}
|
||||
export const name = 'String';
|
||||
export const structure = {
|
||||
value: String
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
return {
|
||||
type: 'String',
|
||||
loc: this.getLocation(this.tokenStart, this.tokenEnd),
|
||||
value: decode(this.consume(StringToken))
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(StringToken, encode(node.value));
|
||||
}
|
||||
|
||||
137
node_modules/css-tree/lib/syntax/node/StyleSheet.js
generated
vendored
137
node_modules/css-tree/lib/syntax/node/StyleSheet.js
generated
vendored
@@ -1,81 +1,82 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import {
|
||||
WhiteSpace,
|
||||
Comment,
|
||||
AtKeyword,
|
||||
CDO,
|
||||
CDC
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
var WHITESPACE = TYPE.WhiteSpace;
|
||||
var COMMENT = TYPE.Comment;
|
||||
var ATKEYWORD = TYPE.AtKeyword;
|
||||
var CDO = TYPE.CDO;
|
||||
var CDC = TYPE.CDC;
|
||||
var EXCLAMATIONMARK = 0x0021; // U+0021 EXCLAMATION MARK (!)
|
||||
const EXCLAMATIONMARK = 0x0021; // U+0021 EXCLAMATION MARK (!)
|
||||
|
||||
function consumeRaw(startToken) {
|
||||
return this.Raw(startToken, null, false);
|
||||
function consumeRaw() {
|
||||
return this.Raw(null, false);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'StyleSheet',
|
||||
structure: {
|
||||
children: [[
|
||||
'Comment',
|
||||
'CDO',
|
||||
'CDC',
|
||||
'Atrule',
|
||||
'Rule',
|
||||
'Raw'
|
||||
]]
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
var children = this.createList();
|
||||
var child;
|
||||
export const name = 'StyleSheet';
|
||||
export const walkContext = 'stylesheet';
|
||||
export const structure = {
|
||||
children: [[
|
||||
'Comment',
|
||||
'CDO',
|
||||
'CDC',
|
||||
'Atrule',
|
||||
'Rule',
|
||||
'Raw'
|
||||
]]
|
||||
};
|
||||
|
||||
scan:
|
||||
while (!this.scanner.eof) {
|
||||
switch (this.scanner.tokenType) {
|
||||
case WHITESPACE:
|
||||
this.scanner.next();
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
const children = this.createList();
|
||||
let child;
|
||||
|
||||
scan:
|
||||
while (!this.eof) {
|
||||
switch (this.tokenType) {
|
||||
case WhiteSpace:
|
||||
this.next();
|
||||
continue;
|
||||
|
||||
case Comment:
|
||||
// ignore comments except exclamation comments (i.e. /*! .. */) on top level
|
||||
if (this.charCodeAt(this.tokenStart + 2) !== EXCLAMATIONMARK) {
|
||||
this.next();
|
||||
continue;
|
||||
}
|
||||
|
||||
case COMMENT:
|
||||
// ignore comments except exclamation comments (i.e. /*! .. */) on top level
|
||||
if (this.scanner.source.charCodeAt(this.scanner.tokenStart + 2) !== EXCLAMATIONMARK) {
|
||||
this.scanner.next();
|
||||
continue;
|
||||
}
|
||||
child = this.Comment();
|
||||
break;
|
||||
|
||||
child = this.Comment();
|
||||
break;
|
||||
case CDO: // <!--
|
||||
child = this.CDO();
|
||||
break;
|
||||
|
||||
case CDO: // <!--
|
||||
child = this.CDO();
|
||||
break;
|
||||
case CDC: // -->
|
||||
child = this.CDC();
|
||||
break;
|
||||
|
||||
case CDC: // -->
|
||||
child = this.CDC();
|
||||
break;
|
||||
// CSS Syntax Module Level 3
|
||||
// §2.2 Error handling
|
||||
// At the "top level" of a stylesheet, an <at-keyword-token> starts an at-rule.
|
||||
case AtKeyword:
|
||||
child = this.parseWithFallback(this.Atrule, consumeRaw);
|
||||
break;
|
||||
|
||||
// CSS Syntax Module Level 3
|
||||
// §2.2 Error handling
|
||||
// At the "top level" of a stylesheet, an <at-keyword-token> starts an at-rule.
|
||||
case ATKEYWORD:
|
||||
child = this.parseWithFallback(this.Atrule, consumeRaw);
|
||||
break;
|
||||
|
||||
// Anything else starts a qualified rule ...
|
||||
default:
|
||||
child = this.parseWithFallback(this.Rule, consumeRaw);
|
||||
}
|
||||
|
||||
children.push(child);
|
||||
// Anything else starts a qualified rule ...
|
||||
default:
|
||||
child = this.parseWithFallback(this.Rule, consumeRaw);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'StyleSheet',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
children: children
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.children(node);
|
||||
},
|
||||
walkContext: 'stylesheet'
|
||||
};
|
||||
children.push(child);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'StyleSheet',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
children
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.children(node);
|
||||
}
|
||||
|
||||
34
node_modules/css-tree/lib/syntax/node/SupportsDeclaration.js
generated
vendored
Normal file
34
node_modules/css-tree/lib/syntax/node/SupportsDeclaration.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import {
|
||||
LeftParenthesis,
|
||||
RightParenthesis
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
export const name = 'SupportsDeclaration';
|
||||
export const structure = {
|
||||
declaration: 'Declaration'
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
|
||||
this.eat(LeftParenthesis);
|
||||
this.skipSC();
|
||||
|
||||
const declaration = this.Declaration();
|
||||
|
||||
if (!this.eof) {
|
||||
this.eat(RightParenthesis);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'SupportsDeclaration',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
declaration
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(LeftParenthesis, '(');
|
||||
this.node(node.declaration);
|
||||
this.token(RightParenthesis, ')');
|
||||
}
|
||||
65
node_modules/css-tree/lib/syntax/node/TypeSelector.js
generated
vendored
65
node_modules/css-tree/lib/syntax/node/TypeSelector.js
generated
vendored
@@ -1,18 +1,22 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import { Ident } from '../../tokenizer/index.js';
|
||||
|
||||
var IDENT = TYPE.Ident;
|
||||
var ASTERISK = 0x002A; // U+002A ASTERISK (*)
|
||||
var VERTICALLINE = 0x007C; // U+007C VERTICAL LINE (|)
|
||||
const ASTERISK = 0x002A; // U+002A ASTERISK (*)
|
||||
const VERTICALLINE = 0x007C; // U+007C VERTICAL LINE (|)
|
||||
|
||||
function eatIdentifierOrAsterisk() {
|
||||
if (this.scanner.tokenType !== IDENT &&
|
||||
this.scanner.isDelim(ASTERISK) === false) {
|
||||
if (this.tokenType !== Ident &&
|
||||
this.isDelim(ASTERISK) === false) {
|
||||
this.error('Identifier or asterisk is expected');
|
||||
}
|
||||
|
||||
this.scanner.next();
|
||||
this.next();
|
||||
}
|
||||
|
||||
export const name = 'TypeSelector';
|
||||
export const structure = {
|
||||
name: String
|
||||
};
|
||||
|
||||
// ident
|
||||
// ident|ident
|
||||
// ident|*
|
||||
@@ -21,33 +25,28 @@ function eatIdentifierOrAsterisk() {
|
||||
// *|*
|
||||
// |ident
|
||||
// |*
|
||||
module.exports = {
|
||||
name: 'TypeSelector',
|
||||
structure: {
|
||||
name: String
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
|
||||
if (this.scanner.isDelim(VERTICALLINE)) {
|
||||
this.scanner.next();
|
||||
eatIdentifierOrAsterisk.call(this);
|
||||
} else {
|
||||
eatIdentifierOrAsterisk.call(this);
|
||||
if (this.isDelim(VERTICALLINE)) {
|
||||
this.next();
|
||||
eatIdentifierOrAsterisk.call(this);
|
||||
} else {
|
||||
eatIdentifierOrAsterisk.call(this);
|
||||
|
||||
if (this.scanner.isDelim(VERTICALLINE)) {
|
||||
this.scanner.next();
|
||||
eatIdentifierOrAsterisk.call(this);
|
||||
}
|
||||
if (this.isDelim(VERTICALLINE)) {
|
||||
this.next();
|
||||
eatIdentifierOrAsterisk.call(this);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'TypeSelector',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
name: this.scanner.substrToCursor(start)
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk(node.name);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
type: 'TypeSelector',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
name: this.substrToCursor(start)
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.tokenize(node.name);
|
||||
}
|
||||
|
||||
193
node_modules/css-tree/lib/syntax/node/UnicodeRange.js
generated
vendored
193
node_modules/css-tree/lib/syntax/node/UnicodeRange.js
generated
vendored
@@ -1,32 +1,29 @@
|
||||
var isHexDigit = require('../../tokenizer').isHexDigit;
|
||||
var cmpChar = require('../../tokenizer').cmpChar;
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
var NAME = require('../../tokenizer').NAME;
|
||||
import {
|
||||
isHexDigit,
|
||||
Ident,
|
||||
Number,
|
||||
Dimension
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
var IDENT = TYPE.Ident;
|
||||
var NUMBER = TYPE.Number;
|
||||
var DIMENSION = TYPE.Dimension;
|
||||
var PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
|
||||
var HYPHENMINUS = 0x002D; // U+002D HYPHEN-MINUS (-)
|
||||
var QUESTIONMARK = 0x003F; // U+003F QUESTION MARK (?)
|
||||
var U = 0x0075; // U+0075 LATIN SMALL LETTER U (u)
|
||||
const PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
|
||||
const HYPHENMINUS = 0x002D; // U+002D HYPHEN-MINUS (-)
|
||||
const QUESTIONMARK = 0x003F; // U+003F QUESTION MARK (?)
|
||||
|
||||
function eatHexSequence(offset, allowDash) {
|
||||
for (var pos = this.scanner.tokenStart + offset, len = 0; pos < this.scanner.tokenEnd; pos++) {
|
||||
var code = this.scanner.source.charCodeAt(pos);
|
||||
let len = 0;
|
||||
|
||||
for (let pos = this.tokenStart + offset; pos < this.tokenEnd; pos++) {
|
||||
const code = this.charCodeAt(pos);
|
||||
|
||||
if (code === HYPHENMINUS && allowDash && len !== 0) {
|
||||
if (eatHexSequence.call(this, offset + len + 1, false) === 0) {
|
||||
this.error();
|
||||
}
|
||||
|
||||
eatHexSequence.call(this, offset + len + 1, false);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!isHexDigit(code)) {
|
||||
this.error(
|
||||
allowDash && len !== 0
|
||||
? 'HyphenMinus' + (len < 6 ? ' or hex digit' : '') + ' is expected'
|
||||
? 'Hyphen minus' + (len < 6 ? ' or hex digit' : '') + ' is expected'
|
||||
: (len < 6 ? 'Hex digit is expected' : 'Unexpected input'),
|
||||
pos
|
||||
);
|
||||
@@ -37,25 +34,25 @@ function eatHexSequence(offset, allowDash) {
|
||||
};
|
||||
}
|
||||
|
||||
this.scanner.next();
|
||||
this.next();
|
||||
return len;
|
||||
}
|
||||
|
||||
function eatQuestionMarkSequence(max) {
|
||||
var count = 0;
|
||||
let count = 0;
|
||||
|
||||
while (this.scanner.isDelim(QUESTIONMARK)) {
|
||||
while (this.isDelim(QUESTIONMARK)) {
|
||||
if (++count > max) {
|
||||
this.error('Too many question marks');
|
||||
}
|
||||
|
||||
this.scanner.next();
|
||||
this.next();
|
||||
}
|
||||
}
|
||||
|
||||
function startsWith(code) {
|
||||
if (this.scanner.source.charCodeAt(this.scanner.tokenStart) !== code) {
|
||||
this.error(NAME[code] + ' is expected');
|
||||
if (this.charCodeAt(this.tokenStart) !== code) {
|
||||
this.error((code === PLUSSIGN ? 'Plus sign' : 'Hyphen minus') + ' is expected');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,95 +76,81 @@ function startsWith(code) {
|
||||
// u <number-token> <number-token> |
|
||||
// u '+' '?'+
|
||||
function scanUnicodeRange() {
|
||||
var hexLength = 0;
|
||||
let hexLength = 0;
|
||||
|
||||
// u '+' <ident-token> '?'*
|
||||
// u '+' '?'+
|
||||
if (this.scanner.isDelim(PLUSSIGN)) {
|
||||
this.scanner.next();
|
||||
switch (this.tokenType) {
|
||||
case Number:
|
||||
// u <number-token> '?'*
|
||||
// u <number-token> <dimension-token>
|
||||
// u <number-token> <number-token>
|
||||
hexLength = eatHexSequence.call(this, 1, true);
|
||||
|
||||
if (this.isDelim(QUESTIONMARK)) {
|
||||
eatQuestionMarkSequence.call(this, 6 - hexLength);
|
||||
break;
|
||||
}
|
||||
|
||||
if (this.tokenType === Dimension ||
|
||||
this.tokenType === Number) {
|
||||
startsWith.call(this, HYPHENMINUS);
|
||||
eatHexSequence.call(this, 1, false);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Dimension:
|
||||
// u <dimension-token> '?'*
|
||||
hexLength = eatHexSequence.call(this, 1, true);
|
||||
|
||||
if (this.scanner.tokenType === IDENT) {
|
||||
hexLength = eatHexSequence.call(this, 0, true);
|
||||
if (hexLength > 0) {
|
||||
eatQuestionMarkSequence.call(this, 6 - hexLength);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.scanner.isDelim(QUESTIONMARK)) {
|
||||
this.scanner.next();
|
||||
eatQuestionMarkSequence.call(this, 5);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
this.error('Hex digit or question mark is expected');
|
||||
return;
|
||||
default:
|
||||
// u '+' <ident-token> '?'*
|
||||
// u '+' '?'+
|
||||
this.eatDelim(PLUSSIGN);
|
||||
|
||||
if (this.tokenType === Ident) {
|
||||
hexLength = eatHexSequence.call(this, 0, true);
|
||||
if (hexLength > 0) {
|
||||
eatQuestionMarkSequence.call(this, 6 - hexLength);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (this.isDelim(QUESTIONMARK)) {
|
||||
this.next();
|
||||
eatQuestionMarkSequence.call(this, 5);
|
||||
break;
|
||||
}
|
||||
|
||||
this.error('Hex digit or question mark is expected');
|
||||
}
|
||||
|
||||
// u <number-token> '?'*
|
||||
// u <number-token> <dimension-token>
|
||||
// u <number-token> <number-token>
|
||||
if (this.scanner.tokenType === NUMBER) {
|
||||
startsWith.call(this, PLUSSIGN);
|
||||
hexLength = eatHexSequence.call(this, 1, true);
|
||||
|
||||
if (this.scanner.isDelim(QUESTIONMARK)) {
|
||||
eatQuestionMarkSequence.call(this, 6 - hexLength);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.scanner.tokenType === DIMENSION ||
|
||||
this.scanner.tokenType === NUMBER) {
|
||||
startsWith.call(this, HYPHENMINUS);
|
||||
eatHexSequence.call(this, 1, false);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// u <dimension-token> '?'*
|
||||
if (this.scanner.tokenType === DIMENSION) {
|
||||
startsWith.call(this, PLUSSIGN);
|
||||
hexLength = eatHexSequence.call(this, 1, true);
|
||||
|
||||
if (hexLength > 0) {
|
||||
eatQuestionMarkSequence.call(this, 6 - hexLength);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.error();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'UnicodeRange',
|
||||
structure: {
|
||||
value: String
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
|
||||
// U or u
|
||||
if (!cmpChar(this.scanner.source, start, U)) {
|
||||
this.error('U is expected');
|
||||
}
|
||||
|
||||
if (!cmpChar(this.scanner.source, start + 1, PLUSSIGN)) {
|
||||
this.error('Plus sign is expected');
|
||||
}
|
||||
|
||||
this.scanner.next();
|
||||
scanUnicodeRange.call(this);
|
||||
|
||||
return {
|
||||
type: 'UnicodeRange',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
value: this.scanner.substrToCursor(start)
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk(node.value);
|
||||
}
|
||||
export const name = 'UnicodeRange';
|
||||
export const structure = {
|
||||
value: String
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
|
||||
// U or u
|
||||
this.eatIdent('u');
|
||||
scanUnicodeRange.call(this);
|
||||
|
||||
return {
|
||||
type: 'UnicodeRange',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
value: this.substrToCursor(start)
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.tokenize(node.value);
|
||||
}
|
||||
|
||||
105
node_modules/css-tree/lib/syntax/node/Url.js
generated
vendored
105
node_modules/css-tree/lib/syntax/node/Url.js
generated
vendored
@@ -1,69 +1,52 @@
|
||||
var isWhiteSpace = require('../../tokenizer').isWhiteSpace;
|
||||
var cmpStr = require('../../tokenizer').cmpStr;
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
import * as url from '../../utils/url.js';
|
||||
import * as string from '../../utils/string.js';
|
||||
import {
|
||||
Function as FunctionToken,
|
||||
String as StringToken,
|
||||
Url,
|
||||
RightParenthesis
|
||||
} from '../../tokenizer/index.js';
|
||||
|
||||
var FUNCTION = TYPE.Function;
|
||||
var URL = TYPE.Url;
|
||||
var RIGHTPARENTHESIS = TYPE.RightParenthesis;
|
||||
export const name = 'Url';
|
||||
export const structure = {
|
||||
value: String
|
||||
};
|
||||
|
||||
// <url-token> | <function-token> <string> )
|
||||
module.exports = {
|
||||
name: 'Url',
|
||||
structure: {
|
||||
value: ['String', 'Raw']
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
var value;
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
let value;
|
||||
|
||||
switch (this.scanner.tokenType) {
|
||||
case URL:
|
||||
var rawStart = start + 4;
|
||||
var rawEnd = this.scanner.tokenEnd - 1;
|
||||
switch (this.tokenType) {
|
||||
case Url:
|
||||
value = url.decode(this.consume(Url));
|
||||
break;
|
||||
|
||||
while (rawStart < rawEnd && isWhiteSpace(this.scanner.source.charCodeAt(rawStart))) {
|
||||
rawStart++;
|
||||
}
|
||||
case FunctionToken:
|
||||
if (!this.cmpStr(this.tokenStart, this.tokenEnd, 'url(')) {
|
||||
this.error('Function name must be `url`');
|
||||
}
|
||||
|
||||
while (rawStart < rawEnd && isWhiteSpace(this.scanner.source.charCodeAt(rawEnd - 1))) {
|
||||
rawEnd--;
|
||||
}
|
||||
this.eat(FunctionToken);
|
||||
this.skipSC();
|
||||
value = string.decode(this.consume(StringToken));
|
||||
this.skipSC();
|
||||
if (!this.eof) {
|
||||
this.eat(RightParenthesis);
|
||||
}
|
||||
break;
|
||||
|
||||
value = {
|
||||
type: 'Raw',
|
||||
loc: this.getLocation(rawStart, rawEnd),
|
||||
value: this.scanner.source.substring(rawStart, rawEnd)
|
||||
};
|
||||
|
||||
this.eat(URL);
|
||||
break;
|
||||
|
||||
case FUNCTION:
|
||||
if (!cmpStr(this.scanner.source, this.scanner.tokenStart, this.scanner.tokenEnd, 'url(')) {
|
||||
this.error('Function name must be `url`');
|
||||
}
|
||||
|
||||
this.eat(FUNCTION);
|
||||
this.scanner.skipSC();
|
||||
value = this.String();
|
||||
this.scanner.skipSC();
|
||||
this.eat(RIGHTPARENTHESIS);
|
||||
break;
|
||||
|
||||
default:
|
||||
this.error('Url or Function is expected');
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'Url',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
value: value
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk('url');
|
||||
this.chunk('(');
|
||||
this.node(node.value);
|
||||
this.chunk(')');
|
||||
default:
|
||||
this.error('Url or Function is expected');
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
type: 'Url',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
value
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(Url, url.encode(node.value));
|
||||
}
|
||||
|
||||
36
node_modules/css-tree/lib/syntax/node/Value.js
generated
vendored
36
node_modules/css-tree/lib/syntax/node/Value.js
generated
vendored
@@ -1,19 +1,19 @@
|
||||
module.exports = {
|
||||
name: 'Value',
|
||||
structure: {
|
||||
children: [[]]
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
var children = this.readSequence(this.scope.Value);
|
||||
|
||||
return {
|
||||
type: 'Value',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
children: children
|
||||
};
|
||||
},
|
||||
generate: function(node) {
|
||||
this.children(node);
|
||||
}
|
||||
export const name = 'Value';
|
||||
export const structure = {
|
||||
children: [[]]
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
const start = this.tokenStart;
|
||||
const children = this.readSequence(this.scope.Value);
|
||||
|
||||
return {
|
||||
type: 'Value',
|
||||
loc: this.getLocation(start, this.tokenStart),
|
||||
children
|
||||
};
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.children(node);
|
||||
}
|
||||
|
||||
41
node_modules/css-tree/lib/syntax/node/WhiteSpace.js
generated
vendored
41
node_modules/css-tree/lib/syntax/node/WhiteSpace.js
generated
vendored
@@ -1,26 +1,27 @@
|
||||
var WHITESPACE = require('../../tokenizer').TYPE.WhiteSpace;
|
||||
var SPACE = Object.freeze({
|
||||
import { WhiteSpace } from '../../tokenizer/index.js';
|
||||
|
||||
const SPACE = Object.freeze({
|
||||
type: 'WhiteSpace',
|
||||
loc: null,
|
||||
value: ' '
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
name: 'WhiteSpace',
|
||||
structure: {
|
||||
value: String
|
||||
},
|
||||
parse: function() {
|
||||
this.eat(WHITESPACE);
|
||||
return SPACE;
|
||||
|
||||
// return {
|
||||
// type: 'WhiteSpace',
|
||||
// loc: this.getLocation(this.scanner.tokenStart, this.scanner.tokenEnd),
|
||||
// value: this.consume(WHITESPACE)
|
||||
// };
|
||||
},
|
||||
generate: function(node) {
|
||||
this.chunk(node.value);
|
||||
}
|
||||
export const name = 'WhiteSpace';
|
||||
export const structure = {
|
||||
value: String
|
||||
};
|
||||
|
||||
export function parse() {
|
||||
this.eat(WhiteSpace);
|
||||
return SPACE;
|
||||
|
||||
// return {
|
||||
// type: 'WhiteSpace',
|
||||
// loc: this.getLocation(this.tokenStart, this.tokenEnd),
|
||||
// value: this.consume(WHITESPACE)
|
||||
// };
|
||||
}
|
||||
|
||||
export function generate(node) {
|
||||
this.token(WhiteSpace, node.value);
|
||||
}
|
||||
|
||||
49
node_modules/css-tree/lib/syntax/node/index-generate.js
generated
vendored
Normal file
49
node_modules/css-tree/lib/syntax/node/index-generate.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
export { generate as AnPlusB } from './AnPlusB.js';
|
||||
export { generate as Atrule } from './Atrule.js';
|
||||
export { generate as AtrulePrelude } from './AtrulePrelude.js';
|
||||
export { generate as AttributeSelector } from './AttributeSelector.js';
|
||||
export { generate as Block } from './Block.js';
|
||||
export { generate as Brackets } from './Brackets.js';
|
||||
export { generate as CDC } from './CDC.js';
|
||||
export { generate as CDO } from './CDO.js';
|
||||
export { generate as ClassSelector } from './ClassSelector.js';
|
||||
export { generate as Combinator } from './Combinator.js';
|
||||
export { generate as Comment } from './Comment.js';
|
||||
export { generate as Condition } from './Condition.js';
|
||||
export { generate as Declaration } from './Declaration.js';
|
||||
export { generate as DeclarationList } from './DeclarationList.js';
|
||||
export { generate as Dimension } from './Dimension.js';
|
||||
export { generate as Feature } from './Feature.js';
|
||||
export { generate as FeatureFunction } from './FeatureFunction.js';
|
||||
export { generate as FeatureRange } from './FeatureRange.js';
|
||||
export { generate as Function } from './Function.js';
|
||||
export { generate as GeneralEnclosed } from './GeneralEnclosed.js';
|
||||
export { generate as Hash } from './Hash.js';
|
||||
export { generate as Identifier } from './Identifier.js';
|
||||
export { generate as IdSelector } from './IdSelector.js';
|
||||
export { generate as Layer } from './Layer.js';
|
||||
export { generate as LayerList } from './LayerList.js';
|
||||
export { generate as MediaQuery } from './MediaQuery.js';
|
||||
export { generate as MediaQueryList } from './MediaQueryList.js';
|
||||
export { generate as NestingSelector } from './NestingSelector.js';
|
||||
export { generate as Nth } from './Nth.js';
|
||||
export { generate as Number } from './Number.js';
|
||||
export { generate as Operator } from './Operator.js';
|
||||
export { generate as Parentheses } from './Parentheses.js';
|
||||
export { generate as Percentage } from './Percentage.js';
|
||||
export { generate as PseudoClassSelector } from './PseudoClassSelector.js';
|
||||
export { generate as PseudoElementSelector } from './PseudoElementSelector.js';
|
||||
export { generate as Ratio } from './Ratio.js';
|
||||
export { generate as Raw } from './Raw.js';
|
||||
export { generate as Rule } from './Rule.js';
|
||||
export { generate as Scope } from './Scope.js';
|
||||
export { generate as Selector } from './Selector.js';
|
||||
export { generate as SelectorList } from './SelectorList.js';
|
||||
export { generate as String } from './String.js';
|
||||
export { generate as StyleSheet } from './StyleSheet.js';
|
||||
export { generate as SupportsDeclaration } from './SupportsDeclaration.js';
|
||||
export { generate as TypeSelector } from './TypeSelector.js';
|
||||
export { generate as UnicodeRange } from './UnicodeRange.js';
|
||||
export { generate as Url } from './Url.js';
|
||||
export { generate as Value } from './Value.js';
|
||||
export { generate as WhiteSpace } from './WhiteSpace.js';
|
||||
17
node_modules/css-tree/lib/syntax/node/index-parse-selector.js
generated
vendored
Normal file
17
node_modules/css-tree/lib/syntax/node/index-parse-selector.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
export { parse as AnPlusB } from './AnPlusB.js';
|
||||
export { parse as AttributeSelector } from './AttributeSelector.js';
|
||||
export { parse as ClassSelector } from './ClassSelector.js';
|
||||
export { parse as Combinator } from './Combinator.js';
|
||||
export { parse as Identifier } from './Identifier.js';
|
||||
export { parse as IdSelector } from './IdSelector.js';
|
||||
export { parse as NestingSelector } from './NestingSelector.js';
|
||||
export { parse as Nth } from './Nth.js';
|
||||
export { parse as Operator } from './Operator.js';
|
||||
export { parse as Percentage } from './Percentage.js';
|
||||
export { parse as PseudoClassSelector } from './PseudoClassSelector.js';
|
||||
export { parse as PseudoElementSelector } from './PseudoElementSelector.js';
|
||||
export { parse as Raw } from './Raw.js';
|
||||
export { parse as Selector } from './Selector.js';
|
||||
export { parse as SelectorList } from './SelectorList.js';
|
||||
export { parse as String } from './String.js';
|
||||
export { parse as TypeSelector } from './TypeSelector.js';
|
||||
49
node_modules/css-tree/lib/syntax/node/index-parse.js
generated
vendored
Normal file
49
node_modules/css-tree/lib/syntax/node/index-parse.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
export { parse as AnPlusB } from './AnPlusB.js';
|
||||
export { parse as Atrule } from './Atrule.js';
|
||||
export { parse as AtrulePrelude } from './AtrulePrelude.js';
|
||||
export { parse as AttributeSelector } from './AttributeSelector.js';
|
||||
export { parse as Block } from './Block.js';
|
||||
export { parse as Brackets } from './Brackets.js';
|
||||
export { parse as CDC } from './CDC.js';
|
||||
export { parse as CDO } from './CDO.js';
|
||||
export { parse as ClassSelector } from './ClassSelector.js';
|
||||
export { parse as Combinator } from './Combinator.js';
|
||||
export { parse as Comment } from './Comment.js';
|
||||
export { parse as Condition } from './Condition.js';
|
||||
export { parse as Declaration } from './Declaration.js';
|
||||
export { parse as DeclarationList } from './DeclarationList.js';
|
||||
export { parse as Dimension } from './Dimension.js';
|
||||
export { parse as Feature } from './Feature.js';
|
||||
export { parse as FeatureFunction } from './FeatureFunction.js';
|
||||
export { parse as FeatureRange } from './FeatureRange.js';
|
||||
export { parse as Function } from './Function.js';
|
||||
export { parse as GeneralEnclosed } from './GeneralEnclosed.js';
|
||||
export { parse as Hash } from './Hash.js';
|
||||
export { parse as Identifier } from './Identifier.js';
|
||||
export { parse as IdSelector } from './IdSelector.js';
|
||||
export { parse as Layer } from './Layer.js';
|
||||
export { parse as LayerList } from './LayerList.js';
|
||||
export { parse as MediaQuery } from './MediaQuery.js';
|
||||
export { parse as MediaQueryList } from './MediaQueryList.js';
|
||||
export { parse as NestingSelector } from './NestingSelector.js';
|
||||
export { parse as Nth } from './Nth.js';
|
||||
export { parse as Number } from './Number.js';
|
||||
export { parse as Operator } from './Operator.js';
|
||||
export { parse as Parentheses } from './Parentheses.js';
|
||||
export { parse as Percentage } from './Percentage.js';
|
||||
export { parse as PseudoClassSelector } from './PseudoClassSelector.js';
|
||||
export { parse as PseudoElementSelector } from './PseudoElementSelector.js';
|
||||
export { parse as Ratio } from './Ratio.js';
|
||||
export { parse as Raw } from './Raw.js';
|
||||
export { parse as Rule } from './Rule.js';
|
||||
export { parse as Scope } from './Scope.js';
|
||||
export { parse as Selector } from './Selector.js';
|
||||
export { parse as SelectorList } from './SelectorList.js';
|
||||
export { parse as String } from './String.js';
|
||||
export { parse as StyleSheet } from './StyleSheet.js';
|
||||
export { parse as SupportsDeclaration } from './SupportsDeclaration.js';
|
||||
export { parse as TypeSelector } from './TypeSelector.js';
|
||||
export { parse as UnicodeRange } from './UnicodeRange.js';
|
||||
export { parse as Url } from './Url.js';
|
||||
export { parse as Value } from './Value.js';
|
||||
export { parse as WhiteSpace } from './WhiteSpace.js';
|
||||
91
node_modules/css-tree/lib/syntax/node/index.js
generated
vendored
91
node_modules/css-tree/lib/syntax/node/index.js
generated
vendored
@@ -1,42 +1,49 @@
|
||||
module.exports = {
|
||||
AnPlusB: require('./AnPlusB'),
|
||||
Atrule: require('./Atrule'),
|
||||
AtrulePrelude: require('./AtrulePrelude'),
|
||||
AttributeSelector: require('./AttributeSelector'),
|
||||
Block: require('./Block'),
|
||||
Brackets: require('./Brackets'),
|
||||
CDC: require('./CDC'),
|
||||
CDO: require('./CDO'),
|
||||
ClassSelector: require('./ClassSelector'),
|
||||
Combinator: require('./Combinator'),
|
||||
Comment: require('./Comment'),
|
||||
Declaration: require('./Declaration'),
|
||||
DeclarationList: require('./DeclarationList'),
|
||||
Dimension: require('./Dimension'),
|
||||
Function: require('./Function'),
|
||||
Hash: require('./Hash'),
|
||||
Identifier: require('./Identifier'),
|
||||
IdSelector: require('./IdSelector'),
|
||||
MediaFeature: require('./MediaFeature'),
|
||||
MediaQuery: require('./MediaQuery'),
|
||||
MediaQueryList: require('./MediaQueryList'),
|
||||
Nth: require('./Nth'),
|
||||
Number: require('./Number'),
|
||||
Operator: require('./Operator'),
|
||||
Parentheses: require('./Parentheses'),
|
||||
Percentage: require('./Percentage'),
|
||||
PseudoClassSelector: require('./PseudoClassSelector'),
|
||||
PseudoElementSelector: require('./PseudoElementSelector'),
|
||||
Ratio: require('./Ratio'),
|
||||
Raw: require('./Raw'),
|
||||
Rule: require('./Rule'),
|
||||
Selector: require('./Selector'),
|
||||
SelectorList: require('./SelectorList'),
|
||||
String: require('./String'),
|
||||
StyleSheet: require('./StyleSheet'),
|
||||
TypeSelector: require('./TypeSelector'),
|
||||
UnicodeRange: require('./UnicodeRange'),
|
||||
Url: require('./Url'),
|
||||
Value: require('./Value'),
|
||||
WhiteSpace: require('./WhiteSpace')
|
||||
};
|
||||
export * as AnPlusB from './AnPlusB.js';
|
||||
export * as Atrule from './Atrule.js';
|
||||
export * as AtrulePrelude from './AtrulePrelude.js';
|
||||
export * as AttributeSelector from './AttributeSelector.js';
|
||||
export * as Block from './Block.js';
|
||||
export * as Brackets from './Brackets.js';
|
||||
export * as CDC from './CDC.js';
|
||||
export * as CDO from './CDO.js';
|
||||
export * as ClassSelector from './ClassSelector.js';
|
||||
export * as Combinator from './Combinator.js';
|
||||
export * as Comment from './Comment.js';
|
||||
export * as Condition from './Condition.js';
|
||||
export * as Declaration from './Declaration.js';
|
||||
export * as DeclarationList from './DeclarationList.js';
|
||||
export * as Dimension from './Dimension.js';
|
||||
export * as Feature from './Feature.js';
|
||||
export * as FeatureFunction from './FeatureFunction.js';
|
||||
export * as FeatureRange from './FeatureRange.js';
|
||||
export * as Function from './Function.js';
|
||||
export * as GeneralEnclosed from './GeneralEnclosed.js';
|
||||
export * as Hash from './Hash.js';
|
||||
export * as Identifier from './Identifier.js';
|
||||
export * as IdSelector from './IdSelector.js';
|
||||
export * as Layer from './Layer.js';
|
||||
export * as LayerList from './LayerList.js';
|
||||
export * as MediaQuery from './MediaQuery.js';
|
||||
export * as MediaQueryList from './MediaQueryList.js';
|
||||
export * as NestingSelector from './NestingSelector.js';
|
||||
export * as Nth from './Nth.js';
|
||||
export * as Number from './Number.js';
|
||||
export * as Operator from './Operator.js';
|
||||
export * as Parentheses from './Parentheses.js';
|
||||
export * as Percentage from './Percentage.js';
|
||||
export * as PseudoClassSelector from './PseudoClassSelector.js';
|
||||
export * as PseudoElementSelector from './PseudoElementSelector.js';
|
||||
export * as Ratio from './Ratio.js';
|
||||
export * as Raw from './Raw.js';
|
||||
export * as Rule from './Rule.js';
|
||||
export * as Scope from './Scope.js';
|
||||
export * as Selector from './Selector.js';
|
||||
export * as SelectorList from './SelectorList.js';
|
||||
export * as String from './String.js';
|
||||
export * as StyleSheet from './StyleSheet.js';
|
||||
export * as SupportsDeclaration from './SupportsDeclaration.js';
|
||||
export * as TypeSelector from './TypeSelector.js';
|
||||
export * as UnicodeRange from './UnicodeRange.js';
|
||||
export * as Url from './Url.js';
|
||||
export * as Value from './Value.js';
|
||||
export * as WhiteSpace from './WhiteSpace.js';
|
||||
|
||||
Reference in New Issue
Block a user