Fix code quality violations and exclude Manifest from checks

Document application modes (development/debug/production)
Add global file drop handler, order column normalization, SPA hash fix
Serve CDN assets via /_vendor/ URLs instead of merging into bundles
Add production minification with license preservation
Improve JSON formatting for debugging and production optimization
Add CDN asset caching with CSS URL inlining for production builds
Add three-mode system (development, debug, production)
Update Manifest CLAUDE.md to reflect helper class architecture
Refactor Manifest.php into helper classes for better organization
Pre-manifest-refactor checkpoint: Add app_mode documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2026-01-14 10:38:22 +00:00
parent bb9046af1b
commit d523f0f600
2355 changed files with 231384 additions and 32223 deletions

View File

@@ -1,20 +1,23 @@
var resolveProperty = require('css-tree').property;
var resolveKeyword = require('css-tree').keyword;
var walk = require('css-tree').walk;
var generate = require('css-tree').generate;
var fingerprintId = 1;
var dontRestructure = {
'src': 1 // https://github.com/afelix/csso/issues/50
};
import {
walk,
generate,
property as resolveProperty,
keyword as resolveKeyword
} from 'css-tree';
var DONT_MIX_VALUE = {
let fingerprintId = 1;
const dontRestructure = new Set([
'src' // https://github.com/afelix/csso/issues/50
]);
const DONT_MIX_VALUE = {
// https://developer.mozilla.org/en-US/docs/Web/CSS/display#Browser_compatibility
'display': /table|ruby|flex|-(flex)?box$|grid|contents|run-in/i,
// https://developer.mozilla.org/en/docs/Web/CSS/text-align
'text-align': /^(start|end|match-parent|justify-all)$/i
};
var SAFE_VALUES = {
const SAFE_VALUES = {
cursor: [
'auto', 'crosshair', 'default', 'move', 'text', 'wait', 'help',
'n-resize', 'e-resize', 's-resize', 'w-resize',
@@ -30,7 +33,7 @@ var SAFE_VALUES = {
]
};
var NEEDLESS_TABLE = {
const NEEDLESS_TABLE = {
'border-width': ['border'],
'border-style': ['border'],
'border-color': ['border'],
@@ -69,37 +72,37 @@ var NEEDLESS_TABLE = {
};
function getPropertyFingerprint(propertyName, declaration, fingerprints) {
var realName = resolveProperty(propertyName).basename;
const realName = resolveProperty(propertyName).basename;
if (realName === 'background') {
return propertyName + ':' + generate(declaration.value);
}
var declarationId = declaration.id;
var fingerprint = fingerprints[declarationId];
const declarationId = declaration.id;
let fingerprint = fingerprints[declarationId];
if (!fingerprint) {
switch (declaration.value.type) {
case 'Value':
var vendorId = '';
var iehack = '';
var special = {};
var raw = false;
const special = {};
let vendorId = '';
let iehack = '';
let raw = false;
declaration.value.children.each(function walk(node) {
declaration.value.children.forEach(function walk(node) {
switch (node.type) {
case 'Value':
case 'Brackets':
case 'Parentheses':
node.children.each(walk);
node.children.forEach(walk);
break;
case 'Raw':
raw = true;
break;
case 'Identifier':
var name = node.name;
case 'Identifier': {
const { name } = node;
if (!vendorId) {
vendorId = resolveKeyword(name).vendor;
@@ -120,9 +123,10 @@ function getPropertyFingerprint(propertyName, declaration, fingerprints) {
}
break;
}
case 'Function':
var name = node.name;
case 'Function': {
let { name } = node;
if (!vendorId) {
vendorId = resolveKeyword(name).vendor;
@@ -133,9 +137,10 @@ function getPropertyFingerprint(propertyName, declaration, fingerprints) {
// rect(<top>, <right>, <bottom>, <left>) - standart
// rect(<top> <right> <bottom> <left>) backwards compatible syntax
// only the same form values can be merged
var hasComma = node.children.some(function(node) {
return node.type === 'Operator' && node.value === ',';
});
const hasComma = node.children.some((node) =>
node.type === 'Operator' && node.value === ','
);
if (!hasComma) {
name = 'rect-backward';
}
@@ -144,12 +149,13 @@ function getPropertyFingerprint(propertyName, declaration, fingerprints) {
special[name + '()'] = true;
// check nested tokens too
node.children.each(walk);
node.children.forEach(walk);
break;
}
case 'Dimension':
var unit = node.unit;
case 'Dimension': {
const { unit } = node;
if (/\\[09]/.test(unit)) {
iehack = RegExp.lastMatch;
@@ -169,7 +175,9 @@ function getPropertyFingerprint(propertyName, declaration, fingerprints) {
special[unit] = true;
break;
}
break;
}
}
});
@@ -193,14 +201,14 @@ function getPropertyFingerprint(propertyName, declaration, fingerprints) {
}
function needless(props, declaration, fingerprints) {
var property = resolveProperty(declaration.property);
const property = resolveProperty(declaration.property);
if (NEEDLESS_TABLE.hasOwnProperty(property.basename)) {
var table = NEEDLESS_TABLE[property.basename];
const table = NEEDLESS_TABLE[property.basename];
for (var i = 0; i < table.length; i++) {
var ppre = getPropertyFingerprint(property.prefix + table[i], declaration, fingerprints);
var prev = props.hasOwnProperty(ppre) ? props[ppre] : null;
for (const entry of table) {
const ppre = getPropertyFingerprint(property.prefix + entry, declaration, fingerprints);
const prev = props.hasOwnProperty(ppre) ? props[ppre] : null;
if (prev && (!declaration.important || prev.item.data.important)) {
return prev;
@@ -210,14 +218,14 @@ function needless(props, declaration, fingerprints) {
}
function processRule(rule, item, list, props, fingerprints) {
var declarations = rule.block.children;
const declarations = rule.block.children;
declarations.eachRight(function(declaration, declarationItem) {
var property = declaration.property;
var fingerprint = getPropertyFingerprint(property, declaration, fingerprints);
var prev = props[fingerprint];
declarations.forEachRight(function(declaration, declarationItem) {
const { property } = declaration;
const fingerprint = getPropertyFingerprint(property, declaration, fingerprints);
const prev = props[fingerprint];
if (prev && !dontRestructure.hasOwnProperty(property)) {
if (prev && !dontRestructure.has(property)) {
if (declaration.important && !prev.item.data.important) {
props[fingerprint] = {
block: declarations,
@@ -241,7 +249,7 @@ function processRule(rule, item, list, props, fingerprints) {
// };
}
} else {
var prev = needless(props, declaration, fingerprints);
const prev = needless(props, declaration, fingerprints);
if (prev) {
declarations.remove(declarationItem);
@@ -262,23 +270,23 @@ function processRule(rule, item, list, props, fingerprints) {
}
});
if (declarations.isEmpty()) {
if (declarations.isEmpty) {
list.remove(item);
}
}
module.exports = function restructBlock(ast) {
var stylesheetMap = {};
var fingerprints = Object.create(null);
export default function restructBlock(ast) {
const stylesheetMap = {};
const fingerprints = Object.create(null);
walk(ast, {
visit: 'Rule',
reverse: true,
enter: function(node, item, list) {
var stylesheet = this.block || this.stylesheet;
var ruleId = (node.pseudoSignature || '') + '|' + node.prelude.children.first().id;
var ruleMap;
var props;
enter(node, item, list) {
const stylesheet = this.block || this.stylesheet;
const ruleId = (node.pseudoSignature || '') + '|' + node.prelude.children.first.id;
let ruleMap;
let props;
if (!stylesheetMap.hasOwnProperty(stylesheet.id)) {
ruleMap = {};