diff options
Diffstat (limited to 'vanilla/node_modules/css-tree/cjs/syntax/config')
6 files changed, 227 insertions, 0 deletions
diff --git a/vanilla/node_modules/css-tree/cjs/syntax/config/generator.cjs b/vanilla/node_modules/css-tree/cjs/syntax/config/generator.cjs new file mode 100644 index 0000000..c092458 --- /dev/null +++ b/vanilla/node_modules/css-tree/cjs/syntax/config/generator.cjs @@ -0,0 +1,9 @@ +'use strict'; + +const indexGenerate = require('../node/index-generate.cjs'); + +const config = { + node: indexGenerate +}; + +module.exports = config; diff --git a/vanilla/node_modules/css-tree/cjs/syntax/config/lexer.cjs b/vanilla/node_modules/css-tree/cjs/syntax/config/lexer.cjs new file mode 100644 index 0000000..9889262 --- /dev/null +++ b/vanilla/node_modules/css-tree/cjs/syntax/config/lexer.cjs @@ -0,0 +1,14 @@ +'use strict'; + +const genericConst = require('../../lexer/generic-const.cjs'); +const data = require('../../data.cjs'); +const index = require('../node/index.cjs'); + +const lexerConfig = { + generic: true, + cssWideKeywords: genericConst.cssWideKeywords, + ...data, + node: index +}; + +module.exports = lexerConfig; diff --git a/vanilla/node_modules/css-tree/cjs/syntax/config/mix.cjs b/vanilla/node_modules/css-tree/cjs/syntax/config/mix.cjs new file mode 100644 index 0000000..5ecf1bb --- /dev/null +++ b/vanilla/node_modules/css-tree/cjs/syntax/config/mix.cjs @@ -0,0 +1,127 @@ +'use strict'; + +function appendOrSet(a, b) { + if (typeof b === 'string' && /^\s*\|/.test(b)) { + return typeof a === 'string' + ? a + b + : b.replace(/^\s*\|\s*/, ''); + } + + return b || null; +} + +function sliceProps(obj, props) { + const result = Object.create(null); + + for (const [key, value] of Object.entries(obj)) { + if (value) { + result[key] = {}; + for (const prop of Object.keys(value)) { + if (props.includes(prop)) { + result[key][prop] = value[prop]; + } + } + } + } + + return result; +} + +function mix(dest, src) { + const result = { ...dest }; + + for (const [prop, value] of Object.entries(src)) { + switch (prop) { + case 'generic': + result[prop] = Boolean(value); + break; + + case 'cssWideKeywords': + result[prop] = dest[prop] + ? [...dest[prop], ...value] + : value || []; + break; + + case 'units': + result[prop] = { ...dest[prop] }; + for (const [name, patch] of Object.entries(value)) { + result[prop][name] = Array.isArray(patch) ? patch : []; + } + break; + + case 'atrules': + result[prop] = { ...dest[prop] }; + + for (const [name, atrule] of Object.entries(value)) { + const exists = result[prop][name] || {}; + const current = result[prop][name] = { + prelude: exists.prelude || null, + descriptors: { + ...exists.descriptors + } + }; + + if (!atrule) { + continue; + } + + current.prelude = atrule.prelude + ? appendOrSet(current.prelude, atrule.prelude) + : current.prelude || null; + + for (const [descriptorName, descriptorValue] of Object.entries(atrule.descriptors || {})) { + current.descriptors[descriptorName] = descriptorValue + ? appendOrSet(current.descriptors[descriptorName], descriptorValue) + : null; + } + + if (!Object.keys(current.descriptors).length) { + current.descriptors = null; + } + } + break; + + case 'types': + case 'properties': + result[prop] = { ...dest[prop] }; + for (const [name, syntax] of Object.entries(value)) { + result[prop][name] = appendOrSet(result[prop][name], syntax); + } + break; + + case 'scope': + case 'features': + result[prop] = { ...dest[prop] }; + for (const [name, props] of Object.entries(value)) { + result[prop][name] = { ...result[prop][name], ...props }; + } + break; + + case 'parseContext': + result[prop] = { + ...dest[prop], + ...value + }; + break; + + case 'atrule': + case 'pseudo': + result[prop] = { + ...dest[prop], + ...sliceProps(value, ['parse']) + }; + break; + + case 'node': + result[prop] = { + ...dest[prop], + ...sliceProps(value, ['name', 'structure', 'parse', 'generate', 'walkContext']) + }; + break; + } + } + + return result; +} + +module.exports = mix; diff --git a/vanilla/node_modules/css-tree/cjs/syntax/config/parser-selector.cjs b/vanilla/node_modules/css-tree/cjs/syntax/config/parser-selector.cjs new file mode 100644 index 0000000..03b1683 --- /dev/null +++ b/vanilla/node_modules/css-tree/cjs/syntax/config/parser-selector.cjs @@ -0,0 +1,19 @@ +'use strict'; + +const index = require('../pseudo/index.cjs'); +const indexParseSelector = require('../node/index-parse-selector.cjs'); +const selector = require('../scope/selector.cjs'); + +const config = { + parseContext: { + default: 'SelectorList', + selectorList: 'SelectorList', + selector: 'Selector' + }, + scope: { Selector: selector }, + atrule: {}, + pseudo: index, + node: indexParseSelector +}; + +module.exports = config; diff --git a/vanilla/node_modules/css-tree/cjs/syntax/config/parser.cjs b/vanilla/node_modules/css-tree/cjs/syntax/config/parser.cjs new file mode 100644 index 0000000..cd7114a --- /dev/null +++ b/vanilla/node_modules/css-tree/cjs/syntax/config/parser.cjs @@ -0,0 +1,49 @@ +'use strict'; + +const index = require('../scope/index.cjs'); +const index$1 = require('../atrule/index.cjs'); +const index$2 = require('../pseudo/index.cjs'); +const indexParse = require('../node/index-parse.cjs'); + +const config = { + parseContext: { + default: 'StyleSheet', + stylesheet: 'StyleSheet', + atrule: 'Atrule', + atrulePrelude(options) { + return this.AtrulePrelude(options.atrule ? String(options.atrule) : null); + }, + mediaQueryList: 'MediaQueryList', + mediaQuery: 'MediaQuery', + condition(options) { + return this.Condition(options.kind); + }, + rule: 'Rule', + selectorList: 'SelectorList', + selector: 'Selector', + block() { + return this.Block(true); + }, + declarationList: 'DeclarationList', + declaration: 'Declaration', + value: 'Value' + }, + features: { + supports: { + selector() { + return this.Selector(); + } + }, + container: { + style() { + return this.Declaration(); + } + } + }, + scope: index, + atrule: index$1, + pseudo: index$2, + node: indexParse +}; + +module.exports = config; diff --git a/vanilla/node_modules/css-tree/cjs/syntax/config/walker.cjs b/vanilla/node_modules/css-tree/cjs/syntax/config/walker.cjs new file mode 100644 index 0000000..95c8f7d --- /dev/null +++ b/vanilla/node_modules/css-tree/cjs/syntax/config/walker.cjs @@ -0,0 +1,9 @@ +'use strict'; + +const index = require('../node/index.cjs'); + +const config = { + node: index +}; + +module.exports = config; |
