It appears you have a well-structured Git repository with various files, including SVG icons and HTML documents. Here's a brief overview:
This commit is contained in:
69
backend/node_modules/csso/lib/clean/Atrule.js
generated
vendored
Normal file
69
backend/node_modules/csso/lib/clean/Atrule.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
import { keyword as resolveKeyword } from 'css-tree';
|
||||
import { hasNoChildren } from './utils.js';
|
||||
|
||||
export default function cleanAtrule(node, item, list) {
|
||||
if (node.block) {
|
||||
// otherwise removed at-rule don't prevent @import for removal
|
||||
if (this.stylesheet !== null) {
|
||||
this.stylesheet.firstAtrulesAllowed = false;
|
||||
}
|
||||
|
||||
if (hasNoChildren(node.block)) {
|
||||
list.remove(item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (node.name) {
|
||||
case 'charset':
|
||||
if (hasNoChildren(node.prelude)) {
|
||||
list.remove(item);
|
||||
return;
|
||||
}
|
||||
|
||||
// if there is any rule before @charset -> remove it
|
||||
if (item.prev) {
|
||||
list.remove(item);
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'import':
|
||||
if (this.stylesheet === null || !this.stylesheet.firstAtrulesAllowed) {
|
||||
list.remove(item);
|
||||
return;
|
||||
}
|
||||
|
||||
// if there are some rules that not an @import or @charset before @import
|
||||
// remove it
|
||||
list.prevUntil(item.prev, function(rule) {
|
||||
if (rule.type === 'Atrule') {
|
||||
if (rule.name === 'import' || rule.name === 'charset') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.root.firstAtrulesAllowed = false;
|
||||
list.remove(item);
|
||||
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
break;
|
||||
|
||||
default: {
|
||||
const name = resolveKeyword(node.name).basename;
|
||||
|
||||
if (name === 'keyframes' ||
|
||||
name === 'media' ||
|
||||
name === 'supports') {
|
||||
|
||||
// drop at-rule with no prelude
|
||||
if (hasNoChildren(node.prelude) || hasNoChildren(node.block)) {
|
||||
list.remove(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
3
backend/node_modules/csso/lib/clean/Comment.js
generated
vendored
Normal file
3
backend/node_modules/csso/lib/clean/Comment.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function cleanComment(data, item, list) {
|
||||
list.remove(item);
|
||||
};
|
14
backend/node_modules/csso/lib/clean/Declaration.js
generated
vendored
Normal file
14
backend/node_modules/csso/lib/clean/Declaration.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { property } from 'css-tree';
|
||||
|
||||
export default function cleanDeclartion(node, item, list) {
|
||||
if (node.value.children && node.value.children.isEmpty) {
|
||||
list.remove(item);
|
||||
return;
|
||||
}
|
||||
|
||||
if (property(node.property).custom) {
|
||||
if (/\S/.test(node.value.value)) {
|
||||
node.value.value = node.value.value.trim();
|
||||
}
|
||||
}
|
||||
};
|
9
backend/node_modules/csso/lib/clean/Raw.js
generated
vendored
Normal file
9
backend/node_modules/csso/lib/clean/Raw.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { isNodeChildrenList } from './utils.js';
|
||||
|
||||
export default function cleanRaw(node, item, list) {
|
||||
// raw in stylesheet or block children
|
||||
if (isNodeChildrenList(this.stylesheet, list) ||
|
||||
isNodeChildrenList(this.block, list)) {
|
||||
list.remove(item);
|
||||
}
|
||||
};
|
100
backend/node_modules/csso/lib/clean/Rule.js
generated
vendored
Normal file
100
backend/node_modules/csso/lib/clean/Rule.js
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
import { walk, keyword } from 'css-tree';
|
||||
import { hasNoChildren } from './utils.js';
|
||||
|
||||
const { hasOwnProperty } = Object.prototype;
|
||||
const skipUsageFilteringAtrule = new Set(['keyframes']);
|
||||
|
||||
function cleanUnused(selectorList, usageData) {
|
||||
selectorList.children.forEach((selector, item, list) => {
|
||||
let shouldRemove = false;
|
||||
|
||||
walk(selector, function(node) {
|
||||
// ignore nodes in nested selectors
|
||||
if (this.selector === null || this.selector === selectorList) {
|
||||
switch (node.type) {
|
||||
case 'SelectorList':
|
||||
// TODO: remove toLowerCase when pseudo selectors will be normalized
|
||||
// ignore selectors inside :not()
|
||||
if (this.function === null || this.function.name.toLowerCase() !== 'not') {
|
||||
if (cleanUnused(node, usageData)) {
|
||||
shouldRemove = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'ClassSelector':
|
||||
if (usageData.whitelist !== null &&
|
||||
usageData.whitelist.classes !== null &&
|
||||
!hasOwnProperty.call(usageData.whitelist.classes, node.name)) {
|
||||
shouldRemove = true;
|
||||
}
|
||||
if (usageData.blacklist !== null &&
|
||||
usageData.blacklist.classes !== null &&
|
||||
hasOwnProperty.call(usageData.blacklist.classes, node.name)) {
|
||||
shouldRemove = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'IdSelector':
|
||||
if (usageData.whitelist !== null &&
|
||||
usageData.whitelist.ids !== null &&
|
||||
!hasOwnProperty.call(usageData.whitelist.ids, node.name)) {
|
||||
shouldRemove = true;
|
||||
}
|
||||
if (usageData.blacklist !== null &&
|
||||
usageData.blacklist.ids !== null &&
|
||||
hasOwnProperty.call(usageData.blacklist.ids, node.name)) {
|
||||
shouldRemove = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'TypeSelector':
|
||||
// TODO: remove toLowerCase when type selectors will be normalized
|
||||
// ignore universal selectors
|
||||
if (node.name.charAt(node.name.length - 1) !== '*') {
|
||||
if (usageData.whitelist !== null &&
|
||||
usageData.whitelist.tags !== null &&
|
||||
!hasOwnProperty.call(usageData.whitelist.tags, node.name.toLowerCase())) {
|
||||
shouldRemove = true;
|
||||
}
|
||||
if (usageData.blacklist !== null &&
|
||||
usageData.blacklist.tags !== null &&
|
||||
hasOwnProperty.call(usageData.blacklist.tags, node.name.toLowerCase())) {
|
||||
shouldRemove = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (shouldRemove) {
|
||||
list.remove(item);
|
||||
}
|
||||
});
|
||||
|
||||
return selectorList.children.isEmpty;
|
||||
}
|
||||
|
||||
export default function cleanRule(node, item, list, options) {
|
||||
if (hasNoChildren(node.prelude) || hasNoChildren(node.block)) {
|
||||
list.remove(item);
|
||||
return;
|
||||
}
|
||||
|
||||
// avoid usage filtering for some at-rules
|
||||
if (this.atrule && skipUsageFilteringAtrule.has(keyword(this.atrule.name).basename)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { usage } = options;
|
||||
|
||||
if (usage && (usage.whitelist !== null || usage.blacklist !== null)) {
|
||||
cleanUnused(node.prelude, usage);
|
||||
|
||||
if (hasNoChildren(node.prelude)) {
|
||||
list.remove(item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
19
backend/node_modules/csso/lib/clean/TypeSelector.js
generated
vendored
Normal file
19
backend/node_modules/csso/lib/clean/TypeSelector.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// remove useless universal selector
|
||||
export default function cleanTypeSelector(node, item, list) {
|
||||
const name = item.data.name;
|
||||
|
||||
// check it's a non-namespaced universal selector
|
||||
if (name !== '*') {
|
||||
return;
|
||||
}
|
||||
|
||||
// remove when universal selector before other selectors
|
||||
const nextType = item.next && item.next.data.type;
|
||||
if (nextType === 'IdSelector' ||
|
||||
nextType === 'ClassSelector' ||
|
||||
nextType === 'AttributeSelector' ||
|
||||
nextType === 'PseudoClassSelector' ||
|
||||
nextType === 'PseudoElementSelector') {
|
||||
list.remove(item);
|
||||
}
|
||||
};
|
3
backend/node_modules/csso/lib/clean/WhiteSpace.js
generated
vendored
Normal file
3
backend/node_modules/csso/lib/clean/WhiteSpace.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function cleanWhitespace(node, item, list) {
|
||||
list.remove(item);
|
||||
};
|
28
backend/node_modules/csso/lib/clean/index.js
generated
vendored
Normal file
28
backend/node_modules/csso/lib/clean/index.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { walk } from 'css-tree';
|
||||
import Atrule from './Atrule.js';
|
||||
import Comment from './Comment.js';
|
||||
import Declaration from './Declaration.js';
|
||||
import Raw from './Raw.js';
|
||||
import Rule from './Rule.js';
|
||||
import TypeSelector from './TypeSelector.js';
|
||||
import WhiteSpace from './WhiteSpace.js';
|
||||
|
||||
const handlers = {
|
||||
Atrule,
|
||||
Comment,
|
||||
Declaration,
|
||||
Raw,
|
||||
Rule,
|
||||
TypeSelector,
|
||||
WhiteSpace
|
||||
};
|
||||
|
||||
export default function(ast, options) {
|
||||
walk(ast, {
|
||||
leave(node, item, list) {
|
||||
if (handlers.hasOwnProperty(node.type)) {
|
||||
handlers[node.type].call(this, node, item, list, options);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
7
backend/node_modules/csso/lib/clean/utils.js
generated
vendored
Normal file
7
backend/node_modules/csso/lib/clean/utils.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export function hasNoChildren(node) {
|
||||
return !node || !node.children || node.children.isEmpty;
|
||||
}
|
||||
|
||||
export function isNodeChildrenList(node, list) {
|
||||
return node !== null && node.children === list;
|
||||
}
|
Reference in New Issue
Block a user