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,40 +1,44 @@
'use strict';
const { visitSkip, detachNodeFromParent } = require('../lib/xast.js');
const { collectStylesheet, computeStyle } = require('../lib/style.js');
const {
elems,
import {
attrsGroups,
elemsGroups,
attrsGroupsDefaults,
elems,
elemsGroups,
presentationNonInheritableGroupAttrs,
} = require('./_collections');
} from './_collections.js';
import { detachNodeFromParent } from '../lib/xast.js';
import { visitSkip } from '../lib/util/visit.js';
import { collectStylesheet, computeStyle } from '../lib/style.js';
exports.type = 'visitor';
exports.name = 'removeUnknownsAndDefaults';
exports.active = true;
exports.description =
/**
* @typedef RemoveUnknownsAndDefaultsParams
* @property {boolean=} unknownContent
* @property {boolean=} unknownAttrs
* @property {boolean=} defaultAttrs
* @property {boolean=} defaultMarkupDeclarations
* If to remove XML declarations that are assigned their default value. XML
* declarations are the properties in the `<?xml … ?>` block at the top of the
* document.
* @property {boolean=} uselessOverrides
* @property {boolean=} keepDataAttrs
* @property {boolean=} keepAriaAttrs
* @property {boolean=} keepRoleAttr
*/
export const name = 'removeUnknownsAndDefaults';
export const description =
'removes unknown elements content and attributes, removes attrs with default values';
// resolve all groups references
/**
* @type {Map<string, Set<string>>}
*/
/** @type {Map<string, Set<string>>} */
const allowedChildrenPerElement = new Map();
/**
* @type {Map<string, Set<string>>}
*/
/** @type {Map<string, Set<string>>} */
const allowedAttributesPerElement = new Map();
/**
* @type {Map<string, Map<string, string>>}
*/
/** @type {Map<string, Map<string, string>>} */
const attributesDefaultsPerElement = new Map();
for (const [name, config] of Object.entries(elems)) {
/**
* @type {Set<string>}
*/
/** @type {Set<string>} */
const allowedChildren = new Set();
if (config.content) {
for (const elementName of config.content) {
@@ -51,18 +55,14 @@ for (const [name, config] of Object.entries(elems)) {
}
}
}
/**
* @type {Set<string>}
*/
/** @type {Set<string>} */
const allowedAttributes = new Set();
if (config.attrs) {
for (const attrName of config.attrs) {
allowedAttributes.add(attrName);
}
}
/**
* @type {Map<string, string>}
*/
/** @type {Map<string, string>} */
const attributesDefaults = new Map();
if (config.defaults) {
for (const [attrName, defaultValue] of Object.entries(config.defaults)) {
@@ -94,21 +94,14 @@ for (const [name, config] of Object.entries(elems)) {
*
* @author Kir Belevich
*
* @type {import('../lib/types').Plugin<{
* unknownContent?: boolean,
* unknownAttrs?: boolean,
* defaultAttrs?: boolean,
* uselessOverrides?: boolean,
* keepDataAttrs?: boolean,
* keepAriaAttrs?: boolean,
* keepRoleAttr?: boolean,
* }>}
* @type {import('../lib/types.js').Plugin<RemoveUnknownsAndDefaultsParams>}
*/
exports.fn = (root, params) => {
export const fn = (root, params) => {
const {
unknownContent = true,
unknownAttrs = true,
defaultAttrs = true,
defaultMarkupDeclarations = true,
uselessOverrides = true,
keepDataAttrs = true,
keepAriaAttrs = true,
@@ -117,6 +110,13 @@ exports.fn = (root, params) => {
const stylesheet = collectStylesheet(root);
return {
instruction: {
enter: (node) => {
if (defaultMarkupDeclarations) {
node.value = node.value.replace(/\s*standalone\s*=\s*(["'])no\1/, '');
}
},
},
element: {
enter: (node, parentNode) => {
// skip namespaced elements
@@ -131,7 +131,7 @@ exports.fn = (root, params) => {
// remove unknown element's content
if (unknownContent && parentNode.type === 'element') {
const allowedChildren = allowedChildrenPerElement.get(
parentNode.name
parentNode.name,
);
if (allowedChildren == null || allowedChildren.size === 0) {
// remove unknown elements
@@ -192,18 +192,14 @@ exports.fn = (root, params) => {
attributesDefaults.get(name) === value
) {
// keep defaults if parent has own or inherited style
if (
computedParentStyle == null ||
computedParentStyle[name] == null
) {
if (computedParentStyle?.[name] == null) {
delete node.attributes[name];
}
}
if (uselessOverrides && node.attributes.id == null) {
const style =
computedParentStyle == null ? null : computedParentStyle[name];
const style = computedParentStyle?.[name];
if (
presentationNonInheritableGroupAttrs.includes(name) === false &&
presentationNonInheritableGroupAttrs.has(name) === false &&
style != null &&
style.type === 'static' &&
style.value === value