From afa87af01c79a9baa539f2992d32154d2a4739bd Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Sat, 14 Feb 2026 14:46:37 -0800 Subject: task: delete vanilla js prototype\n\n- Removed vanilla/ directory and web/dist/vanilla directory\n- Updated Makefile, Dockerfile, and CI workflow to remove vanilla references\n- Cleaned up web/web.go to remove vanilla embed and routes\n- Verified build and tests pass\n\nCloses NK-2tcnmq --- vanilla/node_modules/css-tree/cjs/lexer/Lexer.cjs | 517 ----------------- vanilla/node_modules/css-tree/cjs/lexer/error.cjs | 128 ----- .../css-tree/cjs/lexer/generic-an-plus-b.cjs | 235 -------- .../css-tree/cjs/lexer/generic-const.cjs | 12 - .../css-tree/cjs/lexer/generic-urange.cjs | 149 ----- .../node_modules/css-tree/cjs/lexer/generic.cjs | 589 ------------------- vanilla/node_modules/css-tree/cjs/lexer/index.cjs | 7 - .../css-tree/cjs/lexer/match-graph.cjs | 530 ----------------- vanilla/node_modules/css-tree/cjs/lexer/match.cjs | 632 --------------------- .../css-tree/cjs/lexer/prepare-tokens.cjs | 54 -- vanilla/node_modules/css-tree/cjs/lexer/search.cjs | 65 --- .../node_modules/css-tree/cjs/lexer/structure.cjs | 173 ------ vanilla/node_modules/css-tree/cjs/lexer/trace.cjs | 73 --- vanilla/node_modules/css-tree/cjs/lexer/units.cjs | 38 -- 14 files changed, 3202 deletions(-) delete mode 100644 vanilla/node_modules/css-tree/cjs/lexer/Lexer.cjs delete mode 100644 vanilla/node_modules/css-tree/cjs/lexer/error.cjs delete mode 100644 vanilla/node_modules/css-tree/cjs/lexer/generic-an-plus-b.cjs delete mode 100644 vanilla/node_modules/css-tree/cjs/lexer/generic-const.cjs delete mode 100644 vanilla/node_modules/css-tree/cjs/lexer/generic-urange.cjs delete mode 100644 vanilla/node_modules/css-tree/cjs/lexer/generic.cjs delete mode 100644 vanilla/node_modules/css-tree/cjs/lexer/index.cjs delete mode 100644 vanilla/node_modules/css-tree/cjs/lexer/match-graph.cjs delete mode 100644 vanilla/node_modules/css-tree/cjs/lexer/match.cjs delete mode 100644 vanilla/node_modules/css-tree/cjs/lexer/prepare-tokens.cjs delete mode 100644 vanilla/node_modules/css-tree/cjs/lexer/search.cjs delete mode 100644 vanilla/node_modules/css-tree/cjs/lexer/structure.cjs delete mode 100644 vanilla/node_modules/css-tree/cjs/lexer/trace.cjs delete mode 100644 vanilla/node_modules/css-tree/cjs/lexer/units.cjs (limited to 'vanilla/node_modules/css-tree/cjs/lexer') diff --git a/vanilla/node_modules/css-tree/cjs/lexer/Lexer.cjs b/vanilla/node_modules/css-tree/cjs/lexer/Lexer.cjs deleted file mode 100644 index a6d1fcb..0000000 --- a/vanilla/node_modules/css-tree/cjs/lexer/Lexer.cjs +++ /dev/null @@ -1,517 +0,0 @@ -'use strict'; - -const error = require('./error.cjs'); -const names = require('../utils/names.cjs'); -const genericConst = require('./generic-const.cjs'); -const generic = require('./generic.cjs'); -const units = require('./units.cjs'); -const prepareTokens = require('./prepare-tokens.cjs'); -const matchGraph = require('./match-graph.cjs'); -const match = require('./match.cjs'); -const trace = require('./trace.cjs'); -const search = require('./search.cjs'); -const structure = require('./structure.cjs'); -const parse = require('../definition-syntax/parse.cjs'); -const generate = require('../definition-syntax/generate.cjs'); -const walk = require('../definition-syntax/walk.cjs'); - -function dumpMapSyntax(map, compact, syntaxAsAst) { - const result = {}; - - for (const name in map) { - if (map[name].syntax) { - result[name] = syntaxAsAst - ? map[name].syntax - : generate.generate(map[name].syntax, { compact }); - } - } - - return result; -} - -function dumpAtruleMapSyntax(map, compact, syntaxAsAst) { - const result = {}; - - for (const [name, atrule] of Object.entries(map)) { - result[name] = { - prelude: atrule.prelude && ( - syntaxAsAst - ? atrule.prelude.syntax - : generate.generate(atrule.prelude.syntax, { compact }) - ), - descriptors: atrule.descriptors && dumpMapSyntax(atrule.descriptors, compact, syntaxAsAst) - }; - } - - return result; -} - -function valueHasVar(tokens) { - for (let i = 0; i < tokens.length; i++) { - if (tokens[i].value.toLowerCase() === 'var(') { - return true; - } - } - - return false; -} - -function syntaxHasTopLevelCommaMultiplier(syntax) { - const singleTerm = syntax.terms[0]; - - return ( - syntax.explicit === false && - syntax.terms.length === 1 && - singleTerm.type === 'Multiplier' && - singleTerm.comma === true - ); -} - -function buildMatchResult(matched, error, iterations) { - return { - matched, - iterations, - error, - ...trace - }; -} - -function matchSyntax(lexer, syntax, value, useCssWideKeywords) { - const tokens = prepareTokens(value, lexer.syntax); - let result; - - if (valueHasVar(tokens)) { - return buildMatchResult(null, new Error('Matching for a tree with var() is not supported')); - } - - if (useCssWideKeywords) { - result = match.matchAsTree(tokens, lexer.cssWideKeywordsSyntax, lexer); - } - - if (!useCssWideKeywords || !result.match) { - result = match.matchAsTree(tokens, syntax.match, lexer); - if (!result.match) { - return buildMatchResult( - null, - new error.SyntaxMatchError(result.reason, syntax.syntax, value, result), - result.iterations - ); - } - } - - return buildMatchResult(result.match, null, result.iterations); -} - -class Lexer { - constructor(config, syntax, structure$1) { - this.cssWideKeywords = genericConst.cssWideKeywords; - this.syntax = syntax; - this.generic = false; - this.units = { ...units }; - this.atrules = Object.create(null); - this.properties = Object.create(null); - this.types = Object.create(null); - this.structure = structure$1 || structure.getStructureFromConfig(config); - - if (config) { - if (config.cssWideKeywords) { - this.cssWideKeywords = config.cssWideKeywords; - } - - if (config.units) { - for (const group of Object.keys(units)) { - if (Array.isArray(config.units[group])) { - this.units[group] = config.units[group]; - } - } - } - - if (config.types) { - for (const [name, type] of Object.entries(config.types)) { - this.addType_(name, type); - } - } - - if (config.generic) { - this.generic = true; - for (const [name, value] of Object.entries(generic.createGenericTypes(this.units))) { - this.addType_(name, value); - } - } - - if (config.atrules) { - for (const [name, atrule] of Object.entries(config.atrules)) { - this.addAtrule_(name, atrule); - } - } - - if (config.properties) { - for (const [name, property] of Object.entries(config.properties)) { - this.addProperty_(name, property); - } - } - } - - this.cssWideKeywordsSyntax = matchGraph.buildMatchGraph(this.cssWideKeywords.join(' | ')); - } - - checkStructure(ast) { - function collectWarning(node, message) { - warns.push({ node, message }); - } - - const structure = this.structure; - const warns = []; - - this.syntax.walk(ast, function(node) { - if (structure.hasOwnProperty(node.type)) { - structure[node.type].check(node, collectWarning); - } else { - collectWarning(node, 'Unknown node type `' + node.type + '`'); - } - }); - - return warns.length ? warns : false; - } - - createDescriptor(syntax, type, name, parent = null) { - const ref = { - type, - name - }; - const descriptor = { - type, - name, - parent, - serializable: typeof syntax === 'string' || (syntax && typeof syntax.type === 'string'), - syntax: null, - match: null, - matchRef: null // used for properties when a syntax referenced as <'property'> in other syntax definitions - }; - - if (typeof syntax === 'function') { - descriptor.match = matchGraph.buildMatchGraph(syntax, ref); - } else { - if (typeof syntax === 'string') { - // lazy parsing on first access - Object.defineProperty(descriptor, 'syntax', { - get() { - Object.defineProperty(descriptor, 'syntax', { - value: parse.parse(syntax) - }); - - return descriptor.syntax; - } - }); - } else { - descriptor.syntax = syntax; - } - - // lazy graph build on first access - Object.defineProperty(descriptor, 'match', { - get() { - Object.defineProperty(descriptor, 'match', { - value: matchGraph.buildMatchGraph(descriptor.syntax, ref) - }); - - return descriptor.match; - } - }); - - if (type === 'Property') { - Object.defineProperty(descriptor, 'matchRef', { - get() { - const syntax = descriptor.syntax; - const value = syntaxHasTopLevelCommaMultiplier(syntax) - ? matchGraph.buildMatchGraph({ - ...syntax, - terms: [syntax.terms[0].term] - }, ref) - : null; - - Object.defineProperty(descriptor, 'matchRef', { - value - }); - - return value; - } - }); - } - } - - return descriptor; - } - addAtrule_(name, syntax) { - if (!syntax) { - return; - } - - this.atrules[name] = { - type: 'Atrule', - name: name, - prelude: syntax.prelude ? this.createDescriptor(syntax.prelude, 'AtrulePrelude', name) : null, - descriptors: syntax.descriptors - ? Object.keys(syntax.descriptors).reduce( - (map, descName) => { - map[descName] = this.createDescriptor(syntax.descriptors[descName], 'AtruleDescriptor', descName, name); - return map; - }, - Object.create(null) - ) - : null - }; - } - addProperty_(name, syntax) { - if (!syntax) { - return; - } - - this.properties[name] = this.createDescriptor(syntax, 'Property', name); - } - addType_(name, syntax) { - if (!syntax) { - return; - } - - this.types[name] = this.createDescriptor(syntax, 'Type', name); - } - - checkAtruleName(atruleName) { - if (!this.getAtrule(atruleName)) { - return new error.SyntaxReferenceError('Unknown at-rule', '@' + atruleName); - } - } - checkAtrulePrelude(atruleName, prelude) { - const error = this.checkAtruleName(atruleName); - - if (error) { - return error; - } - - const atrule = this.getAtrule(atruleName); - - if (!atrule.prelude && prelude) { - return new SyntaxError('At-rule `@' + atruleName + '` should not contain a prelude'); - } - - if (atrule.prelude && !prelude) { - if (!matchSyntax(this, atrule.prelude, '', false).matched) { - return new SyntaxError('At-rule `@' + atruleName + '` should contain a prelude'); - } - } - } - checkAtruleDescriptorName(atruleName, descriptorName) { - const error$1 = this.checkAtruleName(atruleName); - - if (error$1) { - return error$1; - } - - const atrule = this.getAtrule(atruleName); - const descriptor = names.keyword(descriptorName); - - if (!atrule.descriptors) { - return new SyntaxError('At-rule `@' + atruleName + '` has no known descriptors'); - } - - if (!atrule.descriptors[descriptor.name] && - !atrule.descriptors[descriptor.basename]) { - return new error.SyntaxReferenceError('Unknown at-rule descriptor', descriptorName); - } - } - checkPropertyName(propertyName) { - if (!this.getProperty(propertyName)) { - return new error.SyntaxReferenceError('Unknown property', propertyName); - } - } - - matchAtrulePrelude(atruleName, prelude) { - const error = this.checkAtrulePrelude(atruleName, prelude); - - if (error) { - return buildMatchResult(null, error); - } - - const atrule = this.getAtrule(atruleName); - - if (!atrule.prelude) { - return buildMatchResult(null, null); - } - - return matchSyntax(this, atrule.prelude, prelude || '', false); - } - matchAtruleDescriptor(atruleName, descriptorName, value) { - const error = this.checkAtruleDescriptorName(atruleName, descriptorName); - - if (error) { - return buildMatchResult(null, error); - } - - const atrule = this.getAtrule(atruleName); - const descriptor = names.keyword(descriptorName); - - return matchSyntax(this, atrule.descriptors[descriptor.name] || atrule.descriptors[descriptor.basename], value, false); - } - matchDeclaration(node) { - if (node.type !== 'Declaration') { - return buildMatchResult(null, new Error('Not a Declaration node')); - } - - return this.matchProperty(node.property, node.value); - } - matchProperty(propertyName, value) { - // don't match syntax for a custom property at the moment - if (names.property(propertyName).custom) { - return buildMatchResult(null, new Error('Lexer matching doesn\'t applicable for custom properties')); - } - - const error = this.checkPropertyName(propertyName); - - if (error) { - return buildMatchResult(null, error); - } - - return matchSyntax(this, this.getProperty(propertyName), value, true); - } - matchType(typeName, value) { - const typeSyntax = this.getType(typeName); - - if (!typeSyntax) { - return buildMatchResult(null, new error.SyntaxReferenceError('Unknown type', typeName)); - } - - return matchSyntax(this, typeSyntax, value, false); - } - match(syntax, value) { - if (typeof syntax !== 'string' && (!syntax || !syntax.type)) { - return buildMatchResult(null, new error.SyntaxReferenceError('Bad syntax')); - } - - if (typeof syntax === 'string' || !syntax.match) { - syntax = this.createDescriptor(syntax, 'Type', 'anonymous'); - } - - return matchSyntax(this, syntax, value, false); - } - - findValueFragments(propertyName, value, type, name) { - return search.matchFragments(this, value, this.matchProperty(propertyName, value), type, name); - } - findDeclarationValueFragments(declaration, type, name) { - return search.matchFragments(this, declaration.value, this.matchDeclaration(declaration), type, name); - } - findAllFragments(ast, type, name) { - const result = []; - - this.syntax.walk(ast, { - visit: 'Declaration', - enter: (declaration) => { - result.push.apply(result, this.findDeclarationValueFragments(declaration, type, name)); - } - }); - - return result; - } - - getAtrule(atruleName, fallbackBasename = true) { - const atrule = names.keyword(atruleName); - const atruleEntry = atrule.vendor && fallbackBasename - ? this.atrules[atrule.name] || this.atrules[atrule.basename] - : this.atrules[atrule.name]; - - return atruleEntry || null; - } - getAtrulePrelude(atruleName, fallbackBasename = true) { - const atrule = this.getAtrule(atruleName, fallbackBasename); - - return atrule && atrule.prelude || null; - } - getAtruleDescriptor(atruleName, name) { - return this.atrules.hasOwnProperty(atruleName) && this.atrules.declarators - ? this.atrules[atruleName].declarators[name] || null - : null; - } - getProperty(propertyName, fallbackBasename = true) { - const property = names.property(propertyName); - const propertyEntry = property.vendor && fallbackBasename - ? this.properties[property.name] || this.properties[property.basename] - : this.properties[property.name]; - - return propertyEntry || null; - } - getType(name) { - return hasOwnProperty.call(this.types, name) ? this.types[name] : null; - } - - validate() { - function syntaxRef(name, isType) { - return isType ? `<${name}>` : `<'${name}'>`; - } - - function validate(syntax, name, broken, descriptor) { - if (broken.has(name)) { - return broken.get(name); - } - - broken.set(name, false); - if (descriptor.syntax !== null) { - walk.walk(descriptor.syntax, function(node) { - if (node.type !== 'Type' && node.type !== 'Property') { - return; - } - - const map = node.type === 'Type' ? syntax.types : syntax.properties; - const brokenMap = node.type === 'Type' ? brokenTypes : brokenProperties; - - if (!hasOwnProperty.call(map, node.name)) { - errors.push(`${syntaxRef(name, broken === brokenTypes)} used missed syntax definition ${syntaxRef(node.name, node.type === 'Type')}`); - broken.set(name, true); - } else if (validate(syntax, node.name, brokenMap, map[node.name])) { - errors.push(`${syntaxRef(name, broken === brokenTypes)} used broken syntax definition ${syntaxRef(node.name, node.type === 'Type')}`); - broken.set(name, true); - } - }, this); - } - } - - const errors = []; - let brokenTypes = new Map(); - let brokenProperties = new Map(); - - for (const key in this.types) { - validate(this, key, brokenTypes, this.types[key]); - } - - for (const key in this.properties) { - validate(this, key, brokenProperties, this.properties[key]); - } - - const brokenTypesArray = [...brokenTypes.keys()].filter(name => brokenTypes.get(name)); - const brokenPropertiesArray = [...brokenProperties.keys()].filter(name => brokenProperties.get(name)); - - if (brokenTypesArray.length || brokenPropertiesArray.length) { - return { - errors, - types: brokenTypesArray, - properties: brokenPropertiesArray - }; - } - - return null; - } - dump(syntaxAsAst, pretty) { - return { - generic: this.generic, - cssWideKeywords: this.cssWideKeywords, - units: this.units, - types: dumpMapSyntax(this.types, !pretty, syntaxAsAst), - properties: dumpMapSyntax(this.properties, !pretty, syntaxAsAst), - atrules: dumpAtruleMapSyntax(this.atrules, !pretty, syntaxAsAst) - }; - } - toString() { - return JSON.stringify(this.dump()); - } -} - -exports.Lexer = Lexer; diff --git a/vanilla/node_modules/css-tree/cjs/lexer/error.cjs b/vanilla/node_modules/css-tree/cjs/lexer/error.cjs deleted file mode 100644 index 8d252ee..0000000 --- a/vanilla/node_modules/css-tree/cjs/lexer/error.cjs +++ /dev/null @@ -1,128 +0,0 @@ -'use strict'; - -const createCustomError = require('../utils/create-custom-error.cjs'); -const generate = require('../definition-syntax/generate.cjs'); - -const defaultLoc = { offset: 0, line: 1, column: 1 }; - -function locateMismatch(matchResult, node) { - const tokens = matchResult.tokens; - const longestMatch = matchResult.longestMatch; - const mismatchNode = longestMatch < tokens.length ? tokens[longestMatch].node || null : null; - const badNode = mismatchNode !== node ? mismatchNode : null; - let mismatchOffset = 0; - let mismatchLength = 0; - let entries = 0; - let css = ''; - let start; - let end; - - for (let i = 0; i < tokens.length; i++) { - const token = tokens[i].value; - - if (i === longestMatch) { - mismatchLength = token.length; - mismatchOffset = css.length; - } - - if (badNode !== null && tokens[i].node === badNode) { - if (i <= longestMatch) { - entries++; - } else { - entries = 0; - } - } - - css += token; - } - - if (longestMatch === tokens.length || entries > 1) { // last - start = fromLoc(badNode || node, 'end') || buildLoc(defaultLoc, css); - end = buildLoc(start); - } else { - start = fromLoc(badNode, 'start') || - buildLoc(fromLoc(node, 'start') || defaultLoc, css.slice(0, mismatchOffset)); - end = fromLoc(badNode, 'end') || - buildLoc(start, css.substr(mismatchOffset, mismatchLength)); - } - - return { - css, - mismatchOffset, - mismatchLength, - start, - end - }; -} - -function fromLoc(node, point) { - const value = node && node.loc && node.loc[point]; - - if (value) { - return 'line' in value ? buildLoc(value) : value; - } - - return null; -} - -function buildLoc({ offset, line, column }, extra) { - const loc = { - offset, - line, - column - }; - - if (extra) { - const lines = extra.split(/\n|\r\n?|\f/); - - loc.offset += extra.length; - loc.line += lines.length - 1; - loc.column = lines.length === 1 ? loc.column + extra.length : lines.pop().length + 1; - } - - return loc; -} - -const SyntaxReferenceError = function(type, referenceName) { - const error = createCustomError.createCustomError( - 'SyntaxReferenceError', - type + (referenceName ? ' `' + referenceName + '`' : '') - ); - - error.reference = referenceName; - - return error; -}; - -const SyntaxMatchError = function(message, syntax, node, matchResult) { - const error = createCustomError.createCustomError('SyntaxMatchError', message); - const { - css, - mismatchOffset, - mismatchLength, - start, - end - } = locateMismatch(matchResult, node); - - error.rawMessage = message; - error.syntax = syntax ? generate.generate(syntax) : ''; - error.css = css; - error.mismatchOffset = mismatchOffset; - error.mismatchLength = mismatchLength; - error.message = message + '\n' + - ' syntax: ' + error.syntax + '\n' + - ' value: ' + (css || '') + '\n' + - ' --------' + new Array(error.mismatchOffset + 1).join('-') + '^'; - - Object.assign(error, start); - error.loc = { - source: (node && node.loc && node.loc.source) || '', - start, - end - }; - - return error; -}; - -exports.SyntaxMatchError = SyntaxMatchError; -exports.SyntaxReferenceError = SyntaxReferenceError; diff --git a/vanilla/node_modules/css-tree/cjs/lexer/generic-an-plus-b.cjs b/vanilla/node_modules/css-tree/cjs/lexer/generic-an-plus-b.cjs deleted file mode 100644 index a5dfba3..0000000 --- a/vanilla/node_modules/css-tree/cjs/lexer/generic-an-plus-b.cjs +++ /dev/null @@ -1,235 +0,0 @@ -'use strict'; - -const charCodeDefinitions = require('../tokenizer/char-code-definitions.cjs'); -const types = require('../tokenizer/types.cjs'); -const utils = require('../tokenizer/utils.cjs'); - -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 isDelim(token, code) { - return token !== null && token.type === types.Delim && token.value.charCodeAt(0) === code; -} - -function skipSC(token, offset, getNextToken) { - while (token !== null && (token.type === types.WhiteSpace || token.type === types.Comment)) { - token = getNextToken(++offset); - } - - return offset; -} - -function checkInteger(token, valueOffset, disallowSign, offset) { - if (!token) { - return 0; - } - - const code = token.value.charCodeAt(valueOffset); - - if (code === PLUSSIGN || code === HYPHENMINUS) { - if (disallowSign) { - // Number sign is not allowed - return 0; - } - valueOffset++; - } - - for (; valueOffset < token.value.length; valueOffset++) { - if (!charCodeDefinitions.isDigit(token.value.charCodeAt(valueOffset))) { - // Integer is expected - return 0; - } - } - - return offset + 1; -} - -// ... -// ... ['+' | '-'] -function consumeB(token, offset_, getNextToken) { - let sign = false; - let offset = skipSC(token, offset_, getNextToken); - - token = getNextToken(offset); - - if (token === null) { - return offset_; - } - - if (token.type !== types.Number) { - if (isDelim(token, PLUSSIGN) || isDelim(token, HYPHENMINUS)) { - sign = true; - offset = skipSC(getNextToken(++offset), offset, getNextToken); - token = getNextToken(offset); - - if (token === null || token.type !== types.Number) { - return 0; - } - } else { - return offset_; - } - } - - if (!sign) { - const code = token.value.charCodeAt(0); - if (code !== PLUSSIGN && code !== HYPHENMINUS) { - // Number sign is expected - return 0; - } - } - - return checkInteger(token, sign ? 0 : 1, sign, offset); -} - -// An+B microsyntax https://www.w3.org/TR/css-syntax-3/#anb -function anPlusB(token, getNextToken) { - /* eslint-disable brace-style*/ - let offset = 0; - - if (!token) { - return 0; - } - - // - if (token.type === types.Number) { - return checkInteger(token, 0, ALLOW_SIGN, offset); // b - } - - // -n - // -n - // -n ['+' | '-'] - // -n- - // - else if (token.type === types.Ident && token.value.charCodeAt(0) === HYPHENMINUS) { - // expect 1st char is N - if (!utils.cmpChar(token.value, 1, N)) { - return 0; - } - - switch (token.value.length) { - // -n - // -n - // -n ['+' | '-'] - case 2: - return consumeB(getNextToken(++offset), offset, getNextToken); - - // -n- - case 3: - if (token.value.charCodeAt(2) !== HYPHENMINUS) { - return 0; - } - - offset = skipSC(getNextToken(++offset), offset, getNextToken); - token = getNextToken(offset); - - return checkInteger(token, 0, DISALLOW_SIGN, offset); - - // - default: - if (token.value.charCodeAt(2) !== HYPHENMINUS) { - return 0; - } - - return checkInteger(token, 3, DISALLOW_SIGN, offset); - } - } - - // '+'? n - // '+'? n - // '+'? n ['+' | '-'] - // '+'? n- - // '+'? - else if (token.type === types.Ident || (isDelim(token, PLUSSIGN) && getNextToken(offset + 1).type === types.Ident)) { - // just ignore a plus - if (token.type !== types.Ident) { - token = getNextToken(++offset); - } - - if (token === null || !utils.cmpChar(token.value, 0, N)) { - return 0; - } - - switch (token.value.length) { - // '+'? n - // '+'? n - // '+'? n ['+' | '-'] - case 1: - return consumeB(getNextToken(++offset), offset, getNextToken); - - // '+'? n- - case 2: - if (token.value.charCodeAt(1) !== HYPHENMINUS) { - return 0; - } - - offset = skipSC(getNextToken(++offset), offset, getNextToken); - token = getNextToken(offset); - - return checkInteger(token, 0, DISALLOW_SIGN, offset); - - // '+'? - default: - if (token.value.charCodeAt(1) !== HYPHENMINUS) { - return 0; - } - - return checkInteger(token, 2, DISALLOW_SIGN, offset); - } - } - - // - // - // - // - // ['+' | '-'] - else if (token.type === types.Dimension) { - let code = token.value.charCodeAt(0); - let sign = code === PLUSSIGN || code === HYPHENMINUS ? 1 : 0; - let i = sign; - - for (; i < token.value.length; i++) { - if (!charCodeDefinitions.isDigit(token.value.charCodeAt(i))) { - break; - } - } - - if (i === sign) { - // Integer is expected - return 0; - } - - if (!utils.cmpChar(token.value, i, N)) { - return 0; - } - - // - // - // ['+' | '-'] - if (i + 1 === token.value.length) { - return consumeB(getNextToken(++offset), offset, getNextToken); - } else { - if (token.value.charCodeAt(i + 1) !== HYPHENMINUS) { - return 0; - } - - // - if (i + 2 === token.value.length) { - offset = skipSC(getNextToken(++offset), offset, getNextToken); - token = getNextToken(offset); - - return checkInteger(token, 0, DISALLOW_SIGN, offset); - } - // - else { - return checkInteger(token, i + 2, DISALLOW_SIGN, offset); - } - } - } - - return 0; -} - -module.exports = anPlusB; diff --git a/vanilla/node_modules/css-tree/cjs/lexer/generic-const.cjs b/vanilla/node_modules/css-tree/cjs/lexer/generic-const.cjs deleted file mode 100644 index 9b9f615..0000000 --- a/vanilla/node_modules/css-tree/cjs/lexer/generic-const.cjs +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -// https://drafts.csswg.org/css-cascade-5/ -const cssWideKeywords = [ - 'initial', - 'inherit', - 'unset', - 'revert', - 'revert-layer' -]; - -exports.cssWideKeywords = cssWideKeywords; diff --git a/vanilla/node_modules/css-tree/cjs/lexer/generic-urange.cjs b/vanilla/node_modules/css-tree/cjs/lexer/generic-urange.cjs deleted file mode 100644 index ce167bb..0000000 --- a/vanilla/node_modules/css-tree/cjs/lexer/generic-urange.cjs +++ /dev/null @@ -1,149 +0,0 @@ -'use strict'; - -const charCodeDefinitions = require('../tokenizer/char-code-definitions.cjs'); -const types = require('../tokenizer/types.cjs'); -const utils = require('../tokenizer/utils.cjs'); - -const PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+) -const HYPHENMINUS = 0x002D; // U+002D HYPHEN-MINUS (-) -const QUESTIONMARK = 0x003F; // U+003F QUESTION MARK (?) -const U = 0x0075; // U+0075 LATIN SMALL LETTER U (u) - -function isDelim(token, code) { - return token !== null && token.type === types.Delim && token.value.charCodeAt(0) === code; -} - -function startsWith(token, code) { - return token.value.charCodeAt(0) === code; -} - -function hexSequence(token, offset, allowDash) { - let hexlen = 0; - - for (let pos = offset; pos < token.value.length; pos++) { - const code = token.value.charCodeAt(pos); - - if (code === HYPHENMINUS && allowDash && hexlen !== 0) { - hexSequence(token, offset + hexlen + 1, false); - return 6; // dissallow following question marks - } - - if (!charCodeDefinitions.isHexDigit(code)) { - return 0; // not a hex digit - } - - if (++hexlen > 6) { - return 0; // too many hex digits - } } - - return hexlen; -} - -function withQuestionMarkSequence(consumed, length, getNextToken) { - if (!consumed) { - return 0; // nothing consumed - } - - while (isDelim(getNextToken(length), QUESTIONMARK)) { - if (++consumed > 6) { - return 0; // too many question marks - } - - length++; - } - - return length; -} - -// https://drafts.csswg.org/css-syntax/#urange -// Informally, the production has three forms: -// U+0001 -// Defines a range consisting of a single code point, in this case the code point "1". -// U+0001-00ff -// Defines a range of codepoints between the first and the second value, in this case -// the range between "1" and "ff" (255 in decimal) inclusive. -// U+00?? -// Defines a range of codepoints where the "?" characters range over all hex digits, -// in this case defining the same as the value U+0000-00ff. -// In each form, a maximum of 6 digits is allowed for each hexadecimal number (if you treat "?" as a hexadecimal digit). -// -// = -// u '+' '?'* | -// u '?'* | -// u '?'* | -// u | -// u | -// u '+' '?'+ -function urange(token, getNextToken) { - let length = 0; - - // should start with `u` or `U` - if (token === null || token.type !== types.Ident || !utils.cmpChar(token.value, 0, U)) { - return 0; - } - - token = getNextToken(++length); - if (token === null) { - return 0; - } - - // u '+' '?'* - // u '+' '?'+ - if (isDelim(token, PLUSSIGN)) { - token = getNextToken(++length); - if (token === null) { - return 0; - } - - if (token.type === types.Ident) { - // u '+' '?'* - return withQuestionMarkSequence(hexSequence(token, 0, true), ++length, getNextToken); - } - - if (isDelim(token, QUESTIONMARK)) { - // u '+' '?'+ - return withQuestionMarkSequence(1, ++length, getNextToken); - } - - // Hex digit or question mark is expected - return 0; - } - - // u '?'* - // u - // u - if (token.type === types.Number) { - const consumedHexLength = hexSequence(token, 1, true); - if (consumedHexLength === 0) { - return 0; - } - - token = getNextToken(++length); - if (token === null) { - // u - return length; - } - - if (token.type === types.Dimension || token.type === types.Number) { - // u - // u - if (!startsWith(token, HYPHENMINUS) || !hexSequence(token, 1, false)) { - return 0; - } - - return length + 1; - } - - // u '?'* - return withQuestionMarkSequence(consumedHexLength, length, getNextToken); - } - - // u '?'* - if (token.type === types.Dimension) { - return withQuestionMarkSequence(hexSequence(token, 1, true), ++length, getNextToken); - } - - return 0; -} - -module.exports = urange; diff --git a/vanilla/node_modules/css-tree/cjs/lexer/generic.cjs b/vanilla/node_modules/css-tree/cjs/lexer/generic.cjs deleted file mode 100644 index 8489911..0000000 --- a/vanilla/node_modules/css-tree/cjs/lexer/generic.cjs +++ /dev/null @@ -1,589 +0,0 @@ -'use strict'; - -const genericConst = require('./generic-const.cjs'); -const genericAnPlusB = require('./generic-an-plus-b.cjs'); -const genericUrange = require('./generic-urange.cjs'); -const charCodeDefinitions = require('../tokenizer/char-code-definitions.cjs'); -const types = require('../tokenizer/types.cjs'); -const utils = require('../tokenizer/utils.cjs'); - -const calcFunctionNames = ['calc(', '-moz-calc(', '-webkit-calc(']; -const balancePair = new Map([ - [types.Function, types.RightParenthesis], - [types.LeftParenthesis, types.RightParenthesis], - [types.LeftSquareBracket, types.RightSquareBracket], - [types.LeftCurlyBracket, types.RightCurlyBracket] -]); - -// safe char code getter -function charCodeAt(str, index) { - return index < str.length ? str.charCodeAt(index) : 0; -} - -function eqStr(actual, expected) { - return utils.cmpStr(actual, 0, actual.length, expected); -} - -function eqStrAny(actual, expected) { - for (let i = 0; i < expected.length; i++) { - if (eqStr(actual, expected[i])) { - return true; - } - } - - return false; -} - -// IE postfix hack, i.e. 123\0 or 123px\9 -function isPostfixIeHack(str, offset) { - if (offset !== str.length - 2) { - return false; - } - - return ( - charCodeAt(str, offset) === 0x005C && // U+005C REVERSE SOLIDUS (\) - charCodeDefinitions.isDigit(charCodeAt(str, offset + 1)) - ); -} - -function outOfRange(opts, value, numEnd) { - if (opts && opts.type === 'Range') { - const num = Number( - numEnd !== undefined && numEnd !== value.length - ? value.substr(0, numEnd) - : value - ); - - if (isNaN(num)) { - return true; - } - - // FIXME: when opts.min is a string it's a dimension, skip a range validation - // for now since it requires a type covertation which is not implmented yet - if (opts.min !== null && num < opts.min && typeof opts.min !== 'string') { - return true; - } - - // FIXME: when opts.max is a string it's a dimension, skip a range validation - // for now since it requires a type covertation which is not implmented yet - if (opts.max !== null && num > opts.max && typeof opts.max !== 'string') { - return true; - } - } - - return false; -} - -function consumeFunction(token, getNextToken) { - let balanceCloseType = 0; - let balanceStash = []; - let length = 0; - - // balanced token consuming - scan: - do { - switch (token.type) { - case types.RightCurlyBracket: - case types.RightParenthesis: - case types.RightSquareBracket: - if (token.type !== balanceCloseType) { - break scan; - } - - balanceCloseType = balanceStash.pop(); - - if (balanceStash.length === 0) { - length++; - break scan; - } - - break; - - case types.Function: - case types.LeftParenthesis: - case types.LeftSquareBracket: - case types.LeftCurlyBracket: - balanceStash.push(balanceCloseType); - balanceCloseType = balancePair.get(token.type); - break; - } - - length++; - } while (token = getNextToken(length)); - - return length; -} - -// TODO: implement -// can be used wherever , , ,