first commit

This commit is contained in:
s.golasch
2023-08-01 13:49:46 +02:00
commit 1fc239fd54
20238 changed files with 3112246 additions and 0 deletions

180
build/node_modules/css-tree/lib/syntax/node/AnPlusB.js generated vendored Normal file
View File

@@ -0,0 +1,180 @@
var cmpChar = require('../../tokenizer').cmpChar;
var isNumber = require('../../tokenizer').isNumber;
var TYPE = require('../../tokenizer').TYPE;
var IDENTIFIER = TYPE.Identifier;
var NUMBER = TYPE.Number;
var PLUSSIGN = TYPE.PlusSign;
var HYPHENMINUS = TYPE.HyphenMinus;
var N = 110; // 'n'.charCodeAt(0)
var DISALLOW_SIGN = true;
var ALLOW_SIGN = false;
function checkTokenIsInteger(scanner, disallowSign) {
var pos = scanner.tokenStart;
if (scanner.source.charCodeAt(pos) === PLUSSIGN ||
scanner.source.charCodeAt(pos) === HYPHENMINUS) {
if (disallowSign) {
scanner.error();
}
pos++;
}
for (; pos < scanner.tokenEnd; pos++) {
if (!isNumber(scanner.source.charCodeAt(pos))) {
scanner.error('Unexpected input', pos);
}
}
}
// 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() {
var start = this.scanner.tokenStart;
var end = start;
var prefix = '';
var a = null;
var b = null;
if (this.scanner.tokenType === NUMBER ||
this.scanner.tokenType === PLUSSIGN) {
checkTokenIsInteger(this.scanner, ALLOW_SIGN);
prefix = this.scanner.getTokenValue();
this.scanner.next();
end = this.scanner.tokenStart;
}
if (this.scanner.tokenType === IDENTIFIER) {
var bStart = this.scanner.tokenStart;
if (cmpChar(this.scanner.source, bStart, HYPHENMINUS)) {
if (prefix === '') {
prefix = '-';
bStart++;
} else {
this.scanner.error('Unexpected hyphen minus');
}
}
if (!cmpChar(this.scanner.source, bStart, N)) {
this.scanner.error();
}
a = prefix === '' ? '1' :
prefix === '+' ? '+1' :
prefix === '-' ? '-1' :
prefix;
var len = this.scanner.tokenEnd - bStart;
if (len > 1) {
// ..n-..
if (this.scanner.source.charCodeAt(bStart + 1) !== HYPHENMINUS) {
this.scanner.error('Unexpected input', bStart + 1);
}
if (len > 2) {
// ..n-{number}..
this.scanner.tokenStart = bStart + 2;
} else {
// ..n- {number}
this.scanner.next();
this.scanner.skipSC();
}
checkTokenIsInteger(this.scanner, DISALLOW_SIGN);
b = '-' + this.scanner.getTokenValue();
this.scanner.next();
end = this.scanner.tokenStart;
} else {
prefix = '';
this.scanner.next();
end = this.scanner.tokenStart;
this.scanner.skipSC();
if (this.scanner.tokenType === HYPHENMINUS ||
this.scanner.tokenType === PLUSSIGN) {
prefix = this.scanner.getTokenValue();
this.scanner.next();
this.scanner.skipSC();
}
if (this.scanner.tokenType === NUMBER) {
checkTokenIsInteger(this.scanner, prefix !== '');
if (!isNumber(this.scanner.source.charCodeAt(this.scanner.tokenStart))) {
prefix = this.scanner.source.charAt(this.scanner.tokenStart);
this.scanner.tokenStart++;
}
if (prefix === '') {
// should be an operator before number
this.scanner.error();
} else if (prefix === '+') {
// plus is using by default
prefix = '';
}
b = prefix + this.scanner.getTokenValue();
this.scanner.next();
end = this.scanner.tokenStart;
} else {
if (prefix) {
this.scanner.eat(NUMBER);
}
}
}
} else {
if (prefix === '' || prefix === '+') { // no number
this.scanner.error(
'Number or identifier is expected',
this.scanner.tokenStart + (
this.scanner.tokenType === PLUSSIGN ||
this.scanner.tokenType === HYPHENMINUS
)
);
}
b = prefix;
}
return {
type: 'AnPlusB',
loc: this.getLocation(start, end),
a: a,
b: b
};
},
generate: function(processChunk, node) {
var a = node.a !== null && node.a !== undefined;
var b = node.b !== null && node.b !== undefined;
if (a) {
processChunk(
node.a === '+1' ? '+n' :
node.a === '1' ? 'n' :
node.a === '-1' ? '-n' :
node.a + 'n'
);
if (b) {
b = String(node.b);
if (b.charAt(0) === '-' || b.charAt(0) === '+') {
processChunk(b.charAt(0));
processChunk(b.substr(1));
} else {
processChunk('+');
processChunk(b);
}
}
} else {
processChunk(String(node.b));
}
}
};

134
build/node_modules/css-tree/lib/syntax/node/Atrule.js generated vendored Normal file
View File

@@ -0,0 +1,134 @@
var TYPE = require('../../tokenizer').TYPE;
var ATRULE = TYPE.Atrule;
var SEMICOLON = TYPE.Semicolon;
var LEFTCURLYBRACKET = TYPE.LeftCurlyBracket;
var RIGHTCURLYBRACKET = TYPE.RightCurlyBracket;
function consumeRaw(startToken) {
return this.Raw(startToken, SEMICOLON, LEFTCURLYBRACKET, false, true);
}
function isDeclarationBlockAtrule() {
for (var offset = 1, type; type = this.scanner.lookupType(offset); offset++) {
if (type === RIGHTCURLYBRACKET) {
return true;
}
if (type === LEFTCURLYBRACKET ||
type === ATRULE) {
return false;
}
}
if (this.tolerant) {
return false;
}
this.scanner.skip(offset);
this.scanner.eat(RIGHTCURLYBRACKET);
}
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.scanner.eat(ATRULE);
name = this.scanner.substrToCursor(start + 1);
nameLowerCase = name.toLowerCase();
this.scanner.skipSC();
// parse prelude
if (this.scanner.eof === false &&
this.scanner.tokenType !== LEFTCURLYBRACKET &&
this.scanner.tokenType !== SEMICOLON) {
if (this.parseAtrulePrelude) {
var preludeStartToken = this.scanner.currentToken;
prelude = this.tolerantParse(this.AtrulePrelude.bind(this, name), consumeRaw);
if (this.tolerant && !this.scanner.eof) {
if (prelude.type !== 'Raw' &&
this.scanner.tokenType !== LEFTCURLYBRACKET &&
this.scanner.tokenType !== SEMICOLON) {
prelude = consumeRaw.call(this, preludeStartToken);
}
}
// turn empty AtrulePrelude into null
if (prelude.type === 'AtrulePrelude' && prelude.children.head === null) {
prelude = null;
}
} else {
prelude = consumeRaw.call(this, this.scanner.currentToken);
}
this.scanner.skipSC();
}
if (this.atrule.hasOwnProperty(nameLowerCase)) {
if (typeof this.atrule[nameLowerCase].block === 'function') {
if (this.scanner.tokenType !== LEFTCURLYBRACKET) {
// FIXME: make tolerant
this.scanner.error('Curly bracket is expected');
}
block = this.atrule[nameLowerCase].block.call(this);
} else {
if (!this.tolerant || !this.scanner.eof) {
this.scanner.eat(SEMICOLON);
}
}
} else {
switch (this.scanner.tokenType) {
case SEMICOLON:
this.scanner.next();
break;
case LEFTCURLYBRACKET:
// TODO: should consume block content as Raw?
block = this.Block(isDeclarationBlockAtrule.call(this));
break;
default:
if (!this.tolerant) {
this.scanner.error('Semicolon or block is expected');
}
}
}
return {
type: 'Atrule',
loc: this.getLocation(start, this.scanner.tokenStart),
name: name,
prelude: prelude,
block: block
};
},
generate: function(processChunk, node) {
processChunk('@');
processChunk(node.name);
if (node.prelude !== null) {
processChunk(' ');
this.generate(processChunk, node.prelude);
}
if (node.block) {
this.generate(processChunk, node.block);
} else {
processChunk(';');
}
},
walkContext: 'atrule'
};

View File

@@ -0,0 +1,40 @@
var List = require('../../utils/list');
module.exports = {
name: 'AtrulePrelude',
structure: {
children: [[]]
},
parse: function(name) {
var children = null;
if (name !== null) {
name = name.toLowerCase();
}
if (this.atrule.hasOwnProperty(name)) {
// custom consumer
if (typeof this.atrule[name].prelude === 'function') {
children = this.atrule[name].prelude.call(this);
}
} else {
// default consumer
this.scanner.skipSC();
children = this.readSequence(this.scope.AtrulePrelude);
}
if (children === null) {
children = new List();
}
return {
type: 'AtrulePrelude',
loc: this.getLocationFromList(children),
children: children
};
},
generate: function(processChunk, node) {
this.each(processChunk, node);
},
walkContext: 'atrulePrelude'
};

View File

@@ -0,0 +1,162 @@
var TYPE = require('../../tokenizer').TYPE;
var IDENTIFIER = TYPE.Identifier;
var STRING = TYPE.String;
var DOLLARSIGN = TYPE.DollarSign;
var ASTERISK = TYPE.Asterisk;
var COLON = TYPE.Colon;
var EQUALSSIGN = TYPE.EqualsSign;
var LEFTSQUAREBRACKET = TYPE.LeftSquareBracket;
var RIGHTSQUAREBRACKET = TYPE.RightSquareBracket;
var CIRCUMFLEXACCENT = TYPE.CircumflexAccent;
var VERTICALLINE = TYPE.VerticalLine;
var TILDE = TYPE.Tilde;
function getAttributeName() {
if (this.scanner.eof) {
this.scanner.error('Unexpected end of input');
}
var start = this.scanner.tokenStart;
var expectIdentifier = false;
var checkColon = true;
if (this.scanner.tokenType === ASTERISK) {
expectIdentifier = true;
checkColon = false;
this.scanner.next();
} else if (this.scanner.tokenType !== VERTICALLINE) {
this.scanner.eat(IDENTIFIER);
}
if (this.scanner.tokenType === VERTICALLINE) {
if (this.scanner.lookupType(1) !== EQUALSSIGN) {
this.scanner.next();
this.scanner.eat(IDENTIFIER);
} else if (expectIdentifier) {
this.scanner.error('Identifier is expected', this.scanner.tokenEnd);
}
} else if (expectIdentifier) {
this.scanner.error('Vertical line is expected');
}
if (checkColon && this.scanner.tokenType === COLON) {
this.scanner.next();
this.scanner.eat(IDENTIFIER);
}
return {
type: 'Identifier',
loc: this.getLocation(start, this.scanner.tokenStart),
name: this.scanner.substrToCursor(start)
};
}
function getOperator() {
var start = this.scanner.tokenStart;
var tokenType = this.scanner.tokenType;
if (tokenType !== EQUALSSIGN && // =
tokenType !== TILDE && // ~=
tokenType !== CIRCUMFLEXACCENT && // ^=
tokenType !== DOLLARSIGN && // $=
tokenType !== ASTERISK && // *=
tokenType !== VERTICALLINE // |=
) {
this.scanner.error('Attribute selector (=, ~=, ^=, $=, *=, |=) is expected');
}
if (tokenType === EQUALSSIGN) {
this.scanner.next();
} else {
this.scanner.next();
this.scanner.eat(EQUALSSIGN);
}
return this.scanner.substrToCursor(start);
}
// '[' S* attrib_name ']'
// '[' S* attrib_name S* attrib_matcher S* [ IDENT | STRING ] S* attrib_flags? S* ']'
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.scanner.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 !== IDENTIFIER) {
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 === IDENTIFIER) {
flags = this.scanner.getTokenValue();
this.scanner.next();
this.scanner.skipSC();
}
}
this.scanner.eat(RIGHTSQUAREBRACKET);
return {
type: 'AttributeSelector',
loc: this.getLocation(start, this.scanner.tokenStart),
name: name,
matcher: matcher,
value: value,
flags: flags
};
},
generate: function(processChunk, node) {
var flagsPrefix = ' ';
processChunk('[');
this.generate(processChunk, node.name);
if (node.matcher !== null) {
processChunk(node.matcher);
if (node.value !== null) {
this.generate(processChunk, node.value);
// space between string and flags is not required
if (node.value.type === 'String') {
flagsPrefix = '';
}
}
}
if (node.flags !== null) {
processChunk(flagsPrefix);
processChunk(node.flags);
}
processChunk(']');
}
};

79
build/node_modules/css-tree/lib/syntax/node/Block.js generated vendored Normal file
View File

@@ -0,0 +1,79 @@
var List = require('../../utils/list');
var TYPE = require('../../tokenizer').TYPE;
var WHITESPACE = TYPE.WhiteSpace;
var COMMENT = TYPE.Comment;
var SEMICOLON = TYPE.Semicolon;
var ATRULE = TYPE.Atrule;
var LEFTCURLYBRACKET = TYPE.LeftCurlyBracket;
var RIGHTCURLYBRACKET = TYPE.RightCurlyBracket;
function consumeRaw(startToken) {
return this.Raw(startToken, 0, 0, false, true);
}
function consumeRule() {
return this.tolerantParse(this.Rule, consumeRaw);
}
function consumeRawDeclaration(startToken) {
return this.Raw(startToken, 0, SEMICOLON, true, true);
}
function consumeDeclaration() {
var node = this.tolerantParse(this.Declaration, consumeRawDeclaration);
if (this.scanner.tokenType === SEMICOLON) {
this.scanner.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 = new List();
this.scanner.eat(LEFTCURLYBRACKET);
scan:
while (!this.scanner.eof) {
switch (this.scanner.tokenType) {
case RIGHTCURLYBRACKET:
break scan;
case WHITESPACE:
case COMMENT:
this.scanner.next();
break;
case ATRULE:
children.appendData(this.tolerantParse(this.Atrule, consumeRaw));
break;
default:
children.appendData(consumer.call(this));
}
}
if (!this.tolerant || !this.scanner.eof) {
this.scanner.eat(RIGHTCURLYBRACKET);
}
return {
type: 'Block',
loc: this.getLocation(start, this.scanner.tokenStart),
children: children
};
},
generate: function(processChunk, node) {
processChunk('{');
this.each(processChunk, node);
processChunk('}');
},
walkContext: 'block'
};

View File

@@ -0,0 +1,32 @@
var TYPE = require('../../tokenizer').TYPE;
var LEFTSQUAREBRACKET = TYPE.LeftSquareBracket;
var RIGHTSQUAREBRACKET = TYPE.RightSquareBracket;
// currently only Grid Layout uses square brackets, but left it universal
// https://drafts.csswg.org/css-grid/#track-sizing
// [ ident* ]
module.exports = {
name: 'Brackets',
structure: {
children: [[]]
},
parse: function(readSequence, recognizer) {
var start = this.scanner.tokenStart;
var children = null;
this.scanner.eat(LEFTSQUAREBRACKET);
children = readSequence.call(this, recognizer);
this.scanner.eat(RIGHTSQUAREBRACKET);
return {
type: 'Brackets',
loc: this.getLocation(start, this.scanner.tokenStart),
children: children
};
},
generate: function(processChunk, node) {
processChunk('[');
this.each(processChunk, node);
processChunk(']');
}
};

19
build/node_modules/css-tree/lib/syntax/node/CDC.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
var CDC = require('../../tokenizer').TYPE.CDC;
module.exports = {
name: 'CDC',
structure: [],
parse: function() {
var start = this.scanner.tokenStart;
this.scanner.eat(CDC); // -->
return {
type: 'CDC',
loc: this.getLocation(start, this.scanner.tokenStart)
};
},
generate: function(processChunk) {
processChunk('-->');
}
};

19
build/node_modules/css-tree/lib/syntax/node/CDO.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
var CDO = require('../../tokenizer').TYPE.CDO;
module.exports = {
name: 'CDO',
structure: [],
parse: function() {
var start = this.scanner.tokenStart;
this.scanner.eat(CDO); // <!--
return {
type: 'CDO',
loc: this.getLocation(start, this.scanner.tokenStart)
};
},
generate: function(processChunk) {
processChunk('<!--');
}
};

View File

@@ -0,0 +1,24 @@
var TYPE = require('../../tokenizer').TYPE;
var IDENTIFIER = TYPE.Identifier;
var FULLSTOP = TYPE.FullStop;
// '.' ident
module.exports = {
name: 'ClassSelector',
structure: {
name: String
},
parse: function() {
this.scanner.eat(FULLSTOP);
return {
type: 'ClassSelector',
loc: this.getLocation(this.scanner.tokenStart - 1, this.scanner.tokenEnd),
name: this.scanner.consume(IDENTIFIER)
};
},
generate: function(processChunk, node) {
processChunk('.');
processChunk(node.name);
}
};

View File

@@ -0,0 +1,43 @@
var TYPE = require('../../tokenizer').TYPE;
var PLUSSIGN = TYPE.PlusSign;
var SOLIDUS = TYPE.Solidus;
var GREATERTHANSIGN = TYPE.GreaterThanSign;
var TILDE = TYPE.Tilde;
// + | > | ~ | /deep/
module.exports = {
name: 'Combinator',
structure: {
name: String
},
parse: function() {
var start = this.scanner.tokenStart;
switch (this.scanner.tokenType) {
case GREATERTHANSIGN:
case PLUSSIGN:
case TILDE:
this.scanner.next();
break;
case SOLIDUS:
this.scanner.next();
this.scanner.expectIdentifier('deep');
this.scanner.eat(SOLIDUS);
break;
default:
this.scanner.error('Combinator is expected');
}
return {
type: 'Combinator',
loc: this.getLocation(start, this.scanner.tokenStart),
name: this.scanner.substrToCursor(start)
};
},
generate: function(processChunk, node) {
processChunk(node.name);
}
};

35
build/node_modules/css-tree/lib/syntax/node/Comment.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
var TYPE = require('../../tokenizer').TYPE;
var ASTERISK = TYPE.Asterisk;
var SOLIDUS = TYPE.Solidus;
// '/*' .* '*/'
module.exports = {
name: 'Comment',
structure: {
value: String
},
parse: function() {
var start = this.scanner.tokenStart;
var end = this.scanner.tokenEnd;
if ((end - start + 2) >= 2 &&
this.scanner.source.charCodeAt(end - 2) === ASTERISK &&
this.scanner.source.charCodeAt(end - 1) === SOLIDUS) {
end -= 2;
}
this.scanner.next();
return {
type: 'Comment',
loc: this.getLocation(start, this.scanner.tokenStart),
value: this.scanner.source.substring(start + 2, end)
};
},
generate: function(processChunk, node) {
processChunk('/*');
processChunk(node.value);
processChunk('*/');
}
};

View File

@@ -0,0 +1,127 @@
var TYPE = require('../../tokenizer').TYPE;
var IDENTIFIER = TYPE.Identifier;
var COLON = TYPE.Colon;
var EXCLAMATIONMARK = TYPE.ExclamationMark;
var SOLIDUS = TYPE.Solidus;
var ASTERISK = TYPE.Asterisk;
var DOLLARSIGN = TYPE.DollarSign;
var HYPHENMINUS = TYPE.HyphenMinus;
var SEMICOLON = TYPE.Semicolon;
var RIGHTCURLYBRACKET = TYPE.RightCurlyBracket;
var RIGHTPARENTHESIS = TYPE.RightParenthesis;
var PLUSSIGN = TYPE.PlusSign;
var NUMBERSIGN = TYPE.NumberSign;
module.exports = {
name: 'Declaration',
structure: {
important: [Boolean, String],
property: String,
value: ['Value', 'Raw']
},
parse: function() {
var start = this.scanner.tokenStart;
var property = readProperty.call(this);
var important = false;
var value;
this.scanner.skipSC();
this.scanner.eat(COLON);
if (isCustomProperty(property) ? this.parseCustomProperty : this.parseValue) {
value = this.Value(property);
} else {
value = this.Raw(this.scanner.currentToken, EXCLAMATIONMARK, SEMICOLON, false, false);
}
if (this.scanner.tokenType === EXCLAMATIONMARK) {
important = getImportant(this.scanner);
this.scanner.skipSC();
}
// TODO: include or not to include semicolon to range?
// if (this.scanner.tokenType === SEMICOLON) {
// this.scanner.next();
// }
if (!this.scanner.eof &&
this.scanner.tokenType !== SEMICOLON &&
this.scanner.tokenType !== RIGHTPARENTHESIS &&
this.scanner.tokenType !== RIGHTCURLYBRACKET) {
this.scanner.error();
}
return {
type: 'Declaration',
loc: this.getLocation(start, this.scanner.tokenStart),
important: important,
property: property,
value: value
};
},
generate: function(processChunk, node, item) {
processChunk(node.property);
processChunk(':');
this.generate(processChunk, node.value);
if (node.important) {
processChunk(node.important === true ? '!important' : '!' + node.important);
}
if (item && item.next) {
processChunk(';');
}
},
walkContext: 'declaration'
};
function isCustomProperty(name) {
return name.length >= 2 &&
name.charCodeAt(0) === HYPHENMINUS &&
name.charCodeAt(1) === HYPHENMINUS;
}
function readProperty() {
var start = this.scanner.tokenStart;
var prefix = 0;
// hacks
switch (this.scanner.tokenType) {
case ASTERISK:
case DOLLARSIGN:
case PLUSSIGN:
case NUMBERSIGN:
prefix = 1;
break;
// TODO: not sure we should support this hack
case SOLIDUS:
prefix = this.scanner.lookupType(1) === SOLIDUS ? 2 : 1;
break;
}
if (this.scanner.lookupType(prefix) === HYPHENMINUS) {
prefix++;
}
if (prefix) {
this.scanner.skip(prefix);
}
this.scanner.eat(IDENTIFIER);
return this.scanner.substrToCursor(start);
}
// ! ws* important
function getImportant(scanner) {
scanner.eat(EXCLAMATIONMARK);
scanner.skipSC();
var important = scanner.consume(IDENTIFIER);
// store original value in case it differ from `important`
// for better original source restoring and hacks like `!ie` support
return important === 'important' ? true : important;
}

View File

@@ -0,0 +1,43 @@
var List = require('../../utils/list');
var TYPE = require('../../tokenizer').TYPE;
var WHITESPACE = TYPE.WhiteSpace;
var COMMENT = TYPE.Comment;
var SEMICOLON = TYPE.Semicolon;
function consumeRaw(startToken) {
return this.Raw(startToken, 0, SEMICOLON, true, true);
}
module.exports = {
name: 'DeclarationList',
structure: {
children: [['Declaration']]
},
parse: function() {
var children = new List();
scan:
while (!this.scanner.eof) {
switch (this.scanner.tokenType) {
case WHITESPACE:
case COMMENT:
case SEMICOLON:
this.scanner.next();
break;
default:
children.appendData(this.tolerantParse(this.Declaration, consumeRaw));
}
}
return {
type: 'DeclarationList',
loc: this.getLocationFromList(children),
children: children
};
},
generate: function(processChunk, node) {
this.each(processChunk, node);
}
};

View File

@@ -0,0 +1,45 @@
var NUMBER = require('../../tokenizer').TYPE.Number;
// special reader for units to avoid adjoined IE hacks (i.e. '1px\9')
function readUnit(scanner) {
var unit = scanner.getTokenValue();
var backSlashPos = unit.indexOf('\\');
if (backSlashPos > 0) {
// patch token offset
scanner.tokenStart += backSlashPos;
// return part before backslash
return unit.substring(0, backSlashPos);
}
// no backslash in unit name
scanner.next();
return unit;
}
// number ident
module.exports = {
name: 'Dimension',
structure: {
value: String,
unit: String
},
parse: function() {
var start = this.scanner.tokenStart;
var value = this.scanner.consume(NUMBER);
var unit = readUnit(this.scanner);
return {
type: 'Dimension',
loc: this.getLocation(start, this.scanner.tokenStart),
value: value,
unit: unit
};
},
generate: function(processChunk, node) {
processChunk(node.value);
processChunk(node.unit);
}
};

View File

@@ -0,0 +1,37 @@
var TYPE = require('../../tokenizer').TYPE;
var RIGHTPARENTHESIS = TYPE.RightParenthesis;
// <function-token> <sequence> ')'
module.exports = {
name: 'Function',
structure: {
name: String,
children: [[]]
},
parse: function(readSequence, recognizer) {
var start = this.scanner.tokenStart;
var name = this.scanner.consumeFunctionName();
var nameLowerCase = name.toLowerCase();
var children;
children = recognizer.hasOwnProperty(nameLowerCase)
? recognizer[nameLowerCase].call(this, recognizer)
: readSequence.call(this, recognizer);
this.scanner.eat(RIGHTPARENTHESIS);
return {
type: 'Function',
loc: this.getLocation(start, this.scanner.tokenStart),
name: name,
children: children
};
},
generate: function(processChunk, node) {
processChunk(node.name);
processChunk('(');
this.each(processChunk, node);
processChunk(')');
},
walkContext: 'function'
};

View File

@@ -0,0 +1,74 @@
var isHex = require('../../tokenizer').isHex;
var TYPE = require('../../tokenizer').TYPE;
var IDENTIFIER = TYPE.Identifier;
var NUMBER = TYPE.Number;
var NUMBERSIGN = TYPE.NumberSign;
function consumeHexSequence(scanner, required) {
if (!isHex(scanner.source.charCodeAt(scanner.tokenStart))) {
if (required) {
scanner.error('Unexpected input', scanner.tokenStart);
} else {
return;
}
}
for (var pos = scanner.tokenStart + 1; pos < scanner.tokenEnd; pos++) {
var code = scanner.source.charCodeAt(pos);
// break on non-hex char
if (!isHex(code)) {
// break token, exclude symbol
scanner.tokenStart = pos;
return;
}
}
// token is full hex sequence, go to next token
scanner.next();
}
// # ident
module.exports = {
name: 'HexColor',
structure: {
value: String
},
parse: function() {
var start = this.scanner.tokenStart;
this.scanner.eat(NUMBERSIGN);
scan:
switch (this.scanner.tokenType) {
case NUMBER:
consumeHexSequence(this.scanner, true);
// if token is identifier then number consists of hex only,
// try to add identifier to result
if (this.scanner.tokenType === IDENTIFIER) {
consumeHexSequence(this.scanner, false);
}
break;
case IDENTIFIER:
consumeHexSequence(this.scanner, true);
break;
default:
this.scanner.error('Number or identifier is expected');
}
return {
type: 'HexColor',
loc: this.getLocation(start, this.scanner.tokenStart),
value: this.scanner.substrToCursor(start + 1) // skip #
};
},
generate: function(processChunk, node) {
processChunk('#');
processChunk(node.value);
}
};

View File

@@ -0,0 +1,24 @@
var TYPE = require('../../tokenizer').TYPE;
var IDENTIFIER = TYPE.Identifier;
var NUMBERSIGN = TYPE.NumberSign;
// '#' ident
module.exports = {
name: 'IdSelector',
structure: {
name: String
},
parse: function() {
this.scanner.eat(NUMBERSIGN);
return {
type: 'IdSelector',
loc: this.getLocation(this.scanner.tokenStart - 1, this.scanner.tokenEnd),
name: this.scanner.consume(IDENTIFIER)
};
},
generate: function(processChunk, node) {
processChunk('#');
processChunk(node.name);
}
};

View File

@@ -0,0 +1,19 @@
var TYPE = require('../../tokenizer').TYPE;
var IDENTIFIER = TYPE.Identifier;
module.exports = {
name: 'Identifier',
structure: {
name: String
},
parse: function() {
return {
type: 'Identifier',
loc: this.getLocation(this.scanner.tokenStart, this.scanner.tokenEnd),
name: this.scanner.consume(IDENTIFIER)
};
},
generate: function(processChunk, node) {
processChunk(node.name);
}
};

View File

@@ -0,0 +1,73 @@
var TYPE = require('../../tokenizer').TYPE;
var IDENTIFIER = TYPE.Identifier;
var NUMBER = TYPE.Number;
var LEFTPARENTHESIS = TYPE.LeftParenthesis;
var RIGHTPARENTHESIS = TYPE.RightParenthesis;
var COLON = TYPE.Colon;
var SOLIDUS = TYPE.Solidus;
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.scanner.eat(LEFTPARENTHESIS);
this.scanner.skipSC();
name = this.scanner.consume(IDENTIFIER);
this.scanner.skipSC();
if (this.scanner.tokenType !== RIGHTPARENTHESIS) {
this.scanner.eat(COLON);
this.scanner.skipSC();
switch (this.scanner.tokenType) {
case NUMBER:
if (this.scanner.lookupType(1) === IDENTIFIER) {
value = this.Dimension();
} else if (this.scanner.lookupNonWSType(1) === SOLIDUS) {
value = this.Ratio();
} else {
value = this.Number();
}
break;
case IDENTIFIER:
value = this.Identifier();
break;
default:
this.scanner.error('Number, dimension, ratio or identifier is expected');
}
this.scanner.skipSC();
}
this.scanner.eat(RIGHTPARENTHESIS);
return {
type: 'MediaFeature',
loc: this.getLocation(start, this.scanner.tokenStart),
name: name,
value: value
};
},
generate: function(processChunk, node) {
processChunk('(');
processChunk(node.name);
if (node.value !== null) {
processChunk(':');
this.generate(processChunk, node.value);
}
processChunk(')');
}
};

View File

@@ -0,0 +1,65 @@
var List = require('../../utils/list');
var TYPE = require('../../tokenizer').TYPE;
var WHITESPACE = TYPE.WhiteSpace;
var COMMENT = TYPE.Comment;
var IDENTIFIER = TYPE.Identifier;
var LEFTPARENTHESIS = TYPE.LeftParenthesis;
module.exports = {
name: 'MediaQuery',
structure: {
children: [['Identifier', 'MediaFeature', 'WhiteSpace']]
},
parse: function() {
this.scanner.skipSC();
var children = new List();
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 IDENTIFIER:
child = this.Identifier();
break;
case LEFTPARENTHESIS:
child = this.MediaFeature();
break;
default:
break scan;
}
if (space !== null) {
children.appendData(space);
space = null;
}
children.appendData(child);
}
if (child === null) {
this.scanner.error('Identifier or parenthesis is expected');
}
return {
type: 'MediaQuery',
loc: this.getLocationFromList(children),
children: children
};
},
generate: function(processChunk, node) {
this.each(processChunk, node);
}
};

View File

@@ -0,0 +1,33 @@
var List = require('../../utils/list');
var COMMA = require('../../tokenizer').TYPE.Comma;
module.exports = {
name: 'MediaQueryList',
structure: {
children: [['MediaQuery']]
},
parse: function(relative) {
var children = new List();
this.scanner.skipSC();
while (!this.scanner.eof) {
children.appendData(this.MediaQuery(relative));
if (this.scanner.tokenType !== COMMA) {
break;
}
this.scanner.next();
}
return {
type: 'MediaQueryList',
loc: this.getLocationFromList(children),
children: children
};
},
generate: function(processChunk, node) {
this.eachComma(processChunk, node);
}
};

52
build/node_modules/css-tree/lib/syntax/node/Nth.js generated vendored Normal file
View File

@@ -0,0 +1,52 @@
// https://drafts.csswg.org/css-syntax-3/#the-anb-type
module.exports = {
name: 'Nth',
structure: {
nth: ['AnPlusB', 'Identifier'],
selector: ['SelectorList', null]
},
parse: function(allowOfClause) {
this.scanner.skipSC();
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 = selector.children.last().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(processChunk, node) {
this.generate(processChunk, node.nth);
if (node.selector !== null) {
processChunk(' of ');
this.generate(processChunk, node.selector);
}
}
};

18
build/node_modules/css-tree/lib/syntax/node/Number.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
var NUMBER = require('../../tokenizer').TYPE.Number;
module.exports = {
name: 'Number',
structure: {
value: String
},
parse: function() {
return {
type: 'Number',
loc: this.getLocation(this.scanner.tokenStart, this.scanner.tokenEnd),
value: this.scanner.consume(NUMBER)
};
},
generate: function(processChunk, node) {
processChunk(node.value);
}
};

View File

@@ -0,0 +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(processChunk, node) {
processChunk(node.value);
}
};

View File

@@ -0,0 +1,29 @@
var TYPE = require('../../tokenizer').TYPE;
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.scanner.eat(LEFTPARENTHESIS);
children = readSequence.call(this, recognizer);
this.scanner.eat(RIGHTPARENTHESIS);
return {
type: 'Parentheses',
loc: this.getLocation(start, this.scanner.tokenStart),
children: children
};
},
generate: function(processChunk, node) {
processChunk('(');
this.each(processChunk, node);
processChunk(')');
}
};

View File

@@ -0,0 +1,27 @@
var TYPE = require('../../tokenizer').TYPE;
var NUMBER = TYPE.Number;
var PERCENTSIGN = TYPE.PercentSign;
module.exports = {
name: 'Percentage',
structure: {
value: String
},
parse: function() {
var start = this.scanner.tokenStart;
var number = this.scanner.consume(NUMBER);
this.scanner.eat(PERCENTSIGN);
return {
type: 'Percentage',
loc: this.getLocation(start, this.scanner.tokenStart),
value: number
};
},
generate: function(processChunk, node) {
processChunk(node.value);
processChunk('%');
}
};

View File

@@ -0,0 +1,61 @@
var List = require('../../utils/list');
var TYPE = require('../../tokenizer').TYPE;
var IDENTIFIER = TYPE.Identifier;
var FUNCTION = TYPE.Function;
var COLON = TYPE.Colon;
var RIGHTPARENTHESIS = TYPE.RightParenthesis;
// : ident [ '(' .. ')' ]?
module.exports = {
name: 'PseudoClassSelector',
structure: {
name: String,
children: [['Raw'], null]
},
parse: function() {
var start = this.scanner.tokenStart;
var children = null;
var name;
var nameLowerCase;
this.scanner.eat(COLON);
if (this.scanner.tokenType === FUNCTION) {
name = this.scanner.consumeFunctionName();
nameLowerCase = name.toLowerCase();
if (this.pseudo.hasOwnProperty(nameLowerCase)) {
this.scanner.skipSC();
children = this.pseudo[nameLowerCase].call(this);
this.scanner.skipSC();
} else {
children = new List().appendData(
this.Raw(this.scanner.currentToken, 0, 0, false, false)
);
}
this.scanner.eat(RIGHTPARENTHESIS);
} else {
name = this.scanner.consume(IDENTIFIER);
}
return {
type: 'PseudoClassSelector',
loc: this.getLocation(start, this.scanner.tokenStart),
name: name,
children: children
};
},
generate: function(processChunk, node) {
processChunk(':');
processChunk(node.name);
if (node.children !== null) {
processChunk('(');
this.each(processChunk, node);
processChunk(')');
}
},
walkContext: 'function'
};

View File

@@ -0,0 +1,62 @@
var List = require('../../utils/list');
var TYPE = require('../../tokenizer').TYPE;
var IDENTIFIER = TYPE.Identifier;
var FUNCTION = TYPE.Function;
var COLON = TYPE.Colon;
var RIGHTPARENTHESIS = TYPE.RightParenthesis;
// :: ident [ '(' .. ')' ]?
module.exports = {
name: 'PseudoElementSelector',
structure: {
name: String,
children: [['Raw'], null]
},
parse: function() {
var start = this.scanner.tokenStart;
var children = null;
var name;
var nameLowerCase;
this.scanner.eat(COLON);
this.scanner.eat(COLON);
if (this.scanner.tokenType === FUNCTION) {
name = this.scanner.consumeFunctionName();
nameLowerCase = name.toLowerCase();
if (this.pseudo.hasOwnProperty(nameLowerCase)) {
this.scanner.skipSC();
children = this.pseudo[nameLowerCase].call(this);
this.scanner.skipSC();
} else {
children = new List().appendData(
this.Raw(this.scanner.currentToken, 0, 0, false, false)
);
}
this.scanner.eat(RIGHTPARENTHESIS);
} else {
name = this.scanner.consume(IDENTIFIER);
}
return {
type: 'PseudoElementSelector',
loc: this.getLocation(start, this.scanner.tokenStart),
name: name,
children: children
};
},
generate: function(processChunk, node) {
processChunk('::');
processChunk(node.name);
if (node.children !== null) {
processChunk('(');
this.each(processChunk, node);
processChunk(')');
}
},
walkContext: 'function'
};

57
build/node_modules/css-tree/lib/syntax/node/Ratio.js generated vendored Normal file
View File

@@ -0,0 +1,57 @@
var isNumber = require('../../tokenizer').isNumber;
var TYPE = require('../../tokenizer').TYPE;
var NUMBER = TYPE.Number;
var SOLIDUS = TYPE.Solidus;
var FULLSTOP = TYPE.FullStop;
// Terms of <ratio> should to be a positive number (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 exponent part.
// Additional checks may to be applied on lexer validation.
function consumeNumber(scanner) {
var value = scanner.consumeNonWS(NUMBER);
for (var i = 0; i < value.length; i++) {
var code = value.charCodeAt(i);
if (!isNumber(code) && code !== FULLSTOP) {
scanner.error('Unsigned number is expected', scanner.tokenStart - value.length + i);
}
}
if (Number(value) === 0) {
scanner.error('Zero number is not allowed', 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(this.scanner);
var right;
this.scanner.eatNonWS(SOLIDUS);
right = consumeNumber(this.scanner);
return {
type: 'Ratio',
loc: this.getLocation(start, this.scanner.tokenStart),
left: left,
right: right
};
},
generate: function(processChunk, node) {
processChunk(node.left);
processChunk('/');
processChunk(node.right);
}
};

34
build/node_modules/css-tree/lib/syntax/node/Raw.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
module.exports = {
name: 'Raw',
structure: {
value: String
},
parse: function(startToken, endTokenType1, endTokenType2, includeTokenType2, excludeWhiteSpace) {
var startOffset = this.scanner.getTokenStart(startToken);
var endOffset;
this.scanner.skip(
this.scanner.getRawLength(
startToken,
endTokenType1,
endTokenType2,
includeTokenType2
)
);
if (excludeWhiteSpace && this.scanner.tokenStart > startOffset) {
endOffset = this.scanner.getOffsetExcludeWS();
} else {
endOffset = this.scanner.tokenStart;
}
return {
type: 'Raw',
loc: this.getLocation(startOffset, endOffset),
value: this.scanner.source.substring(startOffset, endOffset)
};
},
generate: function(processChunk, node) {
processChunk(node.value);
}
};

47
build/node_modules/css-tree/lib/syntax/node/Rule.js generated vendored Normal file
View File

@@ -0,0 +1,47 @@
var TYPE = require('../../tokenizer').TYPE;
var LEFTCURLYBRACKET = TYPE.LeftCurlyBracket;
function consumeRaw(startToken) {
return this.Raw(startToken, LEFTCURLYBRACKET, 0, false, true);
}
module.exports = {
name: 'Rule',
structure: {
prelude: ['SelectorList', 'Raw'],
block: ['Block']
},
parse: function() {
var startToken = this.scanner.currentToken;
var startOffset = this.scanner.tokenStart;
var prelude;
var block;
if (this.parseRulePrelude) {
prelude = this.tolerantParse(this.SelectorList, consumeRaw);
if (this.tolerant && !this.scanner.eof) {
if (prelude.type !== 'Raw' && this.scanner.tokenType !== LEFTCURLYBRACKET) {
prelude = consumeRaw.call(this, startToken);
}
}
} 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(processChunk, node) {
this.generate(processChunk, node.prelude);
this.generate(processChunk, node.block);
},
walkContext: 'rule'
};

View File

@@ -0,0 +1,32 @@
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 (children.isEmpty()) {
this.scanner.error('Selector is expected');
}
return {
type: 'Selector',
loc: this.getLocationFromList(children),
children: children
};
},
generate: function(processChunk, node) {
this.each(processChunk, node);
}
};

View File

@@ -0,0 +1,35 @@
var List = require('../../utils/list');
var TYPE = require('../../tokenizer').TYPE;
var COMMA = TYPE.Comma;
module.exports = {
name: 'SelectorList',
structure: {
children: [['Selector', 'Raw']]
},
parse: function() {
var children = new List();
while (!this.scanner.eof) {
children.appendData(this.Selector());
if (this.scanner.tokenType === COMMA) {
this.scanner.next();
continue;
}
break;
}
return {
type: 'SelectorList',
loc: this.getLocationFromList(children),
children: children
};
},
generate: function(processChunk, node) {
this.eachComma(processChunk, node);
},
walkContext: 'selector'
};

18
build/node_modules/css-tree/lib/syntax/node/String.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
var STRING = require('../../tokenizer').TYPE.String;
module.exports = {
name: 'String',
structure: {
value: String
},
parse: function() {
return {
type: 'String',
loc: this.getLocation(this.scanner.tokenStart, this.scanner.tokenEnd),
value: this.scanner.consume(STRING)
};
},
generate: function(processChunk, node) {
processChunk(node.value);
}
};

View File

@@ -0,0 +1,75 @@
var List = require('../../utils/list');
var TYPE = require('../../tokenizer').TYPE;
var WHITESPACE = TYPE.WhiteSpace;
var COMMENT = TYPE.Comment;
var EXCLAMATIONMARK = TYPE.ExclamationMark;
var ATRULE = TYPE.Atrule;
var CDO = TYPE.CDO;
var CDC = TYPE.CDC;
function consumeRaw(startToken) {
return this.Raw(startToken, 0, 0, false, false);
}
module.exports = {
name: 'StyleSheet',
structure: {
children: [['Comment', 'Atrule', 'Rule', 'Raw']]
},
parse: function() {
var start = this.scanner.tokenStart;
var children = new List();
var child;
scan:
while (!this.scanner.eof) {
switch (this.scanner.tokenType) {
case WHITESPACE:
this.scanner.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;
case CDO: // <!--
child = this.CDO();
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 ATRULE:
child = this.Atrule();
break;
// Anything else starts a qualified rule ...
default:
child = this.tolerantParse(this.Rule, consumeRaw);
}
children.appendData(child);
}
return {
type: 'StyleSheet',
loc: this.getLocation(start, this.scanner.tokenStart),
children: children
};
},
generate: function(processChunk, node) {
this.each(processChunk, node);
},
walkContext: 'stylesheet'
};

View File

@@ -0,0 +1,53 @@
var TYPE = require('../../tokenizer').TYPE;
var IDENTIFIER = TYPE.Identifier;
var ASTERISK = TYPE.Asterisk;
var VERTICALLINE = TYPE.VerticalLine;
function eatIdentifierOrAsterisk() {
if (this.scanner.tokenType !== IDENTIFIER &&
this.scanner.tokenType !== ASTERISK) {
this.scanner.error('Identifier or asterisk is expected');
}
this.scanner.next();
}
// ident
// ident|ident
// ident|*
// *
// *|ident
// *|*
// |ident
// |*
module.exports = {
name: 'TypeSelector',
structure: {
name: String
},
parse: function() {
var start = this.scanner.tokenStart;
if (this.scanner.tokenType === VERTICALLINE) {
this.scanner.next();
eatIdentifierOrAsterisk.call(this);
} else {
eatIdentifierOrAsterisk.call(this);
if (this.scanner.tokenType === VERTICALLINE) {
this.scanner.next();
eatIdentifierOrAsterisk.call(this);
}
}
return {
type: 'TypeSelector',
loc: this.getLocation(start, this.scanner.tokenStart),
name: this.scanner.substrToCursor(start)
};
},
generate: function(processChunk, node) {
processChunk(node.name);
}
};

View File

@@ -0,0 +1,125 @@
var isHex = require('../../tokenizer').isHex;
var TYPE = require('../../tokenizer').TYPE;
var IDENTIFIER = TYPE.Identifier;
var NUMBER = TYPE.Number;
var PLUSSIGN = TYPE.PlusSign;
var HYPHENMINUS = TYPE.HyphenMinus;
var FULLSTOP = TYPE.FullStop;
var QUESTIONMARK = TYPE.QuestionMark;
function scanUnicodeNumber(scanner) {
for (var pos = scanner.tokenStart + 1; pos < scanner.tokenEnd; pos++) {
var code = scanner.source.charCodeAt(pos);
// break on fullstop or hyperminus/plussign after exponent
if (code === FULLSTOP || code === PLUSSIGN) {
// break token, exclude symbol
scanner.tokenStart = pos;
return false;
}
}
return true;
}
// https://drafts.csswg.org/css-syntax-3/#urange
function scanUnicodeRange(scanner) {
var hexStart = scanner.tokenStart + 1; // skip +
var hexLength = 0;
scan: {
if (scanner.tokenType === NUMBER) {
if (scanner.source.charCodeAt(scanner.tokenStart) !== FULLSTOP && scanUnicodeNumber(scanner)) {
scanner.next();
} else if (scanner.source.charCodeAt(scanner.tokenStart) !== HYPHENMINUS) {
break scan;
}
} else {
scanner.next(); // PLUSSIGN
}
if (scanner.tokenType === HYPHENMINUS) {
scanner.next();
}
if (scanner.tokenType === NUMBER) {
scanner.next();
}
if (scanner.tokenType === IDENTIFIER) {
scanner.next();
}
if (scanner.tokenStart === hexStart) {
scanner.error('Unexpected input', hexStart);
}
}
// validate for U+x{1,6} or U+x{1,6}-x{1,6}
// where x is [0-9a-fA-F]
for (var i = hexStart, wasHyphenMinus = false; i < scanner.tokenStart; i++) {
var code = scanner.source.charCodeAt(i);
if (isHex(code) === false && (code !== HYPHENMINUS || wasHyphenMinus)) {
scanner.error('Unexpected input', i);
}
if (code === HYPHENMINUS) {
// hex sequence shouldn't be an empty
if (hexLength === 0) {
scanner.error('Unexpected input', i);
}
wasHyphenMinus = true;
hexLength = 0;
} else {
hexLength++;
// too long hex sequence
if (hexLength > 6) {
scanner.error('Too long hex sequence', i);
}
}
}
// check we have a non-zero sequence
if (hexLength === 0) {
scanner.error('Unexpected input', i - 1);
}
// U+abc???
if (!wasHyphenMinus) {
// consume as many U+003F QUESTION MARK (?) code points as possible
for (; hexLength < 6 && !scanner.eof; scanner.next()) {
if (scanner.tokenType !== QUESTIONMARK) {
break;
}
hexLength++;
}
}
}
module.exports = {
name: 'UnicodeRange',
structure: {
value: String
},
parse: function() {
var start = this.scanner.tokenStart;
this.scanner.next(); // U or u
scanUnicodeRange(this.scanner);
return {
type: 'UnicodeRange',
loc: this.getLocation(start, this.scanner.tokenStart),
value: this.scanner.substrToCursor(start)
};
},
generate: function(processChunk, node) {
processChunk(node.value);
}
};

49
build/node_modules/css-tree/lib/syntax/node/Url.js generated vendored Normal file
View File

@@ -0,0 +1,49 @@
var TYPE = require('../../tokenizer').TYPE;
var STRING = TYPE.String;
var URL = TYPE.Url;
var RAW = TYPE.Raw;
var RIGHTPARENTHESIS = TYPE.RightParenthesis;
// url '(' S* (string | raw) S* ')'
module.exports = {
name: 'Url',
structure: {
value: ['String', 'Raw']
},
parse: function() {
var start = this.scanner.tokenStart;
var value;
this.scanner.eat(URL);
this.scanner.skipSC();
switch (this.scanner.tokenType) {
case STRING:
value = this.String();
break;
case RAW:
value = this.Raw(this.scanner.currentToken, 0, RAW, true, false);
break;
default:
this.scanner.error('String or Raw is expected');
}
this.scanner.skipSC();
this.scanner.eat(RIGHTPARENTHESIS);
return {
type: 'Url',
loc: this.getLocation(start, this.scanner.tokenStart),
value: value
};
},
generate: function(processChunk, node) {
processChunk('url');
processChunk('(');
this.generate(processChunk, node.value);
processChunk(')');
}
};

61
build/node_modules/css-tree/lib/syntax/node/Value.js generated vendored Normal file
View File

@@ -0,0 +1,61 @@
var endsWith = require('../../tokenizer').endsWith;
var TYPE = require('../../tokenizer').TYPE;
var WHITESPACE = TYPE.WhiteSpace;
var COMMENT = TYPE.Comment;
var FUNCTION = TYPE.Function;
var COLON = TYPE.Colon;
var SEMICOLON = TYPE.Semicolon;
var EXCLAMATIONMARK = TYPE.ExclamationMark;
// 'progid:' ws* 'DXImageTransform.Microsoft.' ident ws* '(' .* ')'
function checkProgid(scanner) {
var offset = 0;
for (var type; type = scanner.lookupType(offset); offset++) {
if (type !== WHITESPACE && type !== COMMENT) {
break;
}
}
if (scanner.lookupValue(offset, 'alpha(') ||
scanner.lookupValue(offset, 'chroma(') ||
scanner.lookupValue(offset, 'dropshadow(')) {
if (scanner.lookupType(offset) !== FUNCTION) {
return false;
}
} else {
if (scanner.lookupValue(offset, 'progid') === false ||
scanner.lookupType(offset + 1) !== COLON) {
return false;
}
}
return true;
}
module.exports = {
name: 'Value',
structure: {
children: [[]]
},
parse: function(property) {
// special parser for filter property since it can contains non-standart syntax for old IE
if (property !== null && endsWith(property, 'filter') && checkProgid(this.scanner)) {
this.scanner.skipSC();
return this.Raw(this.scanner.currentToken, EXCLAMATIONMARK, SEMICOLON, false, false);
}
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(processChunk, node) {
this.each(processChunk, node);
}
};

View File

@@ -0,0 +1,26 @@
var WHITESPACE = require('../../tokenizer').TYPE.WhiteSpace;
var SPACE = Object.freeze({
type: 'WhiteSpace',
loc: null,
value: ' '
});
module.exports = {
name: 'WhiteSpace',
structure: {
value: String
},
parse: function() {
this.scanner.eat(WHITESPACE);
return SPACE;
// return {
// type: 'WhiteSpace',
// loc: this.getLocation(this.scanner.tokenStart, this.scanner.tokenEnd),
// value: this.scanner.consume(WHITESPACE)
// };
},
generate: function(processChunk, node) {
processChunk(node.value);
}
};

42
build/node_modules/css-tree/lib/syntax/node/index.js generated vendored Normal file
View File

@@ -0,0 +1,42 @@
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'),
HexColor: require('./HexColor'),
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')
};