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:
13
node_modules/postcss-discard-comments/package.json
generated
vendored
13
node_modules/postcss-discard-comments/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "postcss-discard-comments",
|
||||
"version": "5.1.2",
|
||||
"version": "7.0.5",
|
||||
"description": "Discard comments in your CSS files with PostCSS.",
|
||||
"main": "src/index.js",
|
||||
"types": "types/index.d.ts",
|
||||
@@ -23,16 +23,21 @@
|
||||
"url": "http://beneb.info"
|
||||
},
|
||||
"repository": "cssnano/cssnano",
|
||||
"dependencies": {
|
||||
"postcss-selector-parser": "^7.1.0"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/cssnano/cssnano/issues"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10 || ^12 || >=14.0"
|
||||
"node": "^18.12.0 || ^20.9.0 || >=22.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"postcss": "^8.2.15"
|
||||
"postcss": "^8.5.6",
|
||||
"postcss-scss": "^4.0.9",
|
||||
"postcss-simple-vars": "^7.0.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"postcss": "^8.2.15"
|
||||
"postcss": "^8.4.32"
|
||||
}
|
||||
}
|
||||
128
node_modules/postcss-discard-comments/src/index.js
generated
vendored
128
node_modules/postcss-discard-comments/src/index.js
generated
vendored
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
const CommentRemover = require('./lib/commentRemover');
|
||||
const commentParser = require('./lib/commentParser');
|
||||
const selectorParser = require('postcss-selector-parser');
|
||||
|
||||
/** @typedef {object} Options
|
||||
* @property {boolean=} removeAll
|
||||
@@ -15,8 +16,25 @@ const commentParser = require('./lib/commentParser');
|
||||
function pluginCreator(opts = {}) {
|
||||
const remover = new CommentRemover(opts);
|
||||
const matcherCache = new Map();
|
||||
const parserCache = new Map();
|
||||
const replacerCache = new Map();
|
||||
|
||||
/**
|
||||
* @param {string} source
|
||||
* @return {[number, number, number][]}
|
||||
*/
|
||||
function getTokens(source) {
|
||||
if (parserCache.has(source)) {
|
||||
return parserCache.get(source);
|
||||
}
|
||||
|
||||
const tokens = commentParser(source);
|
||||
|
||||
parserCache.set(source, tokens);
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} source
|
||||
* @return {[number, number, number][]}
|
||||
@@ -26,7 +44,7 @@ function pluginCreator(opts = {}) {
|
||||
return matcherCache.get(source);
|
||||
}
|
||||
|
||||
const result = commentParser(source).filter(([type]) => type);
|
||||
const result = getTokens(source).filter(([type]) => type);
|
||||
|
||||
matcherCache.set(source, result);
|
||||
|
||||
@@ -34,29 +52,46 @@ function pluginCreator(opts = {}) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} source
|
||||
* @param {string | undefined} rawSource
|
||||
* @param {(s: string) => string[]} space
|
||||
* @param {string=} separator
|
||||
* @return {string}
|
||||
*/
|
||||
function replaceComments(source, space, separator = ' ') {
|
||||
function replaceComments(rawSource, space, separator = ' ') {
|
||||
const source = rawSource || '';
|
||||
const key = source + '@|@' + separator;
|
||||
|
||||
if (replacerCache.has(key)) {
|
||||
return replacerCache.get(key);
|
||||
}
|
||||
const parsed = commentParser(source).reduce((value, [type, start, end]) => {
|
||||
|
||||
if (source.indexOf('/*') === -1) {
|
||||
const normalized = space(source).join(' ');
|
||||
|
||||
replacerCache.set(key, normalized);
|
||||
|
||||
return normalized;
|
||||
}
|
||||
|
||||
const parts = [];
|
||||
|
||||
for (const [type, start, end] of getTokens(source)) {
|
||||
if (!type) {
|
||||
parts.push(source.slice(start, end));
|
||||
continue;
|
||||
}
|
||||
|
||||
const contents = source.slice(start, end);
|
||||
|
||||
if (!type) {
|
||||
return value + contents;
|
||||
}
|
||||
|
||||
if (remover.canRemove(contents)) {
|
||||
return value + separator;
|
||||
parts.push(separator);
|
||||
continue;
|
||||
}
|
||||
|
||||
return `${value}/*${contents}*/`;
|
||||
}, '');
|
||||
parts.push('/*' + contents + '*/');
|
||||
}
|
||||
|
||||
const parsed = parts.join('');
|
||||
|
||||
const result = space(parsed).join(' ');
|
||||
|
||||
@@ -65,6 +100,53 @@ function pluginCreator(opts = {}) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string | undefined} rawSource
|
||||
* @param {(s: string) => string[]} space
|
||||
* @return {string}
|
||||
*/
|
||||
function replaceCommentsInSelector(rawSource, space) {
|
||||
const source = rawSource || '';
|
||||
const key = source + '@|@';
|
||||
|
||||
if (replacerCache.has(key)) {
|
||||
return replacerCache.get(key);
|
||||
}
|
||||
if (source.indexOf('/*') === -1) {
|
||||
const normalized = space(source).join(' ');
|
||||
|
||||
replacerCache.set(key, normalized);
|
||||
|
||||
return normalized;
|
||||
}
|
||||
const processed = selectorParser((ast) => {
|
||||
ast.walk((node) => {
|
||||
if (node.type === 'comment') {
|
||||
const contents = node.value.slice(2, -2);
|
||||
if (remover.canRemove(contents)) {
|
||||
node.remove();
|
||||
}
|
||||
}
|
||||
const rawSpaceAfter = replaceComments(node.rawSpaceAfter, space, '');
|
||||
const rawSpaceBefore = replaceComments(node.rawSpaceBefore, space, '');
|
||||
// If comments are not removed, the result of trim will be returned,
|
||||
// so if we compare and there are no changes, skip it.
|
||||
if (rawSpaceAfter !== node.rawSpaceAfter.trim()) {
|
||||
node.rawSpaceAfter = rawSpaceAfter;
|
||||
}
|
||||
if (rawSpaceBefore !== node.rawSpaceBefore.trim()) {
|
||||
node.rawSpaceBefore = rawSpaceBefore;
|
||||
}
|
||||
});
|
||||
}).processSync(source);
|
||||
|
||||
const result = space(processed).join(' ');
|
||||
|
||||
replacerCache.set(key, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return {
|
||||
postcssPlugin: 'postcss-discard-comments',
|
||||
|
||||
@@ -109,16 +191,18 @@ function pluginCreator(opts = {}) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
node.type === 'rule' &&
|
||||
node.raws.selector &&
|
||||
node.raws.selector.raw
|
||||
) {
|
||||
node.raws.selector.raw = replaceComments(
|
||||
node.raws.selector.raw,
|
||||
list.space,
|
||||
''
|
||||
);
|
||||
if (node.type === 'rule') {
|
||||
if (node.raws.selector && node.raws.selector.raw) {
|
||||
node.raws.selector.raw = replaceCommentsInSelector(
|
||||
node.raws.selector.raw,
|
||||
list.space
|
||||
);
|
||||
} else if (node.selector && node.selector.includes('/*')) {
|
||||
node.selector = replaceCommentsInSelector(
|
||||
node.selector,
|
||||
list.space
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -142,6 +226,8 @@ function pluginCreator(opts = {}) {
|
||||
node.raws.params.raw,
|
||||
list.space
|
||||
);
|
||||
} else if (node.params && node.params.includes('/*')) {
|
||||
node.params = replaceComments(node.params, list.space);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
96
node_modules/postcss-discard-comments/src/lib/commentParser.js
generated
vendored
96
node_modules/postcss-discard-comments/src/lib/commentParser.js
generated
vendored
@@ -1,31 +1,95 @@
|
||||
'use strict';
|
||||
|
||||
// State machine states reused between parses for better perf
|
||||
const STATES = {
|
||||
NORMAL: 0,
|
||||
IN_SINGLE_QUOTE: 1,
|
||||
IN_DOUBLE_QUOTE: 2,
|
||||
IN_COMMENT: 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* CSS Comment Parser with context awareness
|
||||
* Properly handles comments inside strings, URLs, and escaped characters
|
||||
*
|
||||
* @param {string} input
|
||||
* @return {[number, number, number][]}
|
||||
*/
|
||||
module.exports = function commentParser(input) {
|
||||
/** @type [number, number, number][] */
|
||||
/** @type {[number, number, number][]} */
|
||||
const tokens = [];
|
||||
const length = input.length;
|
||||
let pos = 0;
|
||||
let next;
|
||||
|
||||
|
||||
let state = STATES.NORMAL;
|
||||
let tokenStart = 0;
|
||||
let commentStart = 0;
|
||||
|
||||
while (pos < length) {
|
||||
next = input.indexOf('/*', pos);
|
||||
|
||||
if (~next) {
|
||||
tokens.push([0, pos, next]);
|
||||
pos = next;
|
||||
|
||||
next = input.indexOf('*/', pos + 2);
|
||||
tokens.push([1, pos + 2, next]);
|
||||
pos = next + 2;
|
||||
} else {
|
||||
tokens.push([0, pos, length]);
|
||||
pos = length;
|
||||
const char = input[pos];
|
||||
const nextChar = pos + 1 < length ? input[pos + 1] : '';
|
||||
|
||||
switch (state) {
|
||||
case STATES.NORMAL:
|
||||
if (char === '/' && nextChar === '*') {
|
||||
// Found comment start - add non-comment token if needed
|
||||
if (pos > tokenStart) {
|
||||
tokens.push([0, tokenStart, pos]);
|
||||
}
|
||||
commentStart = pos;
|
||||
state = STATES.IN_COMMENT;
|
||||
pos += 2; // Skip /*
|
||||
continue;
|
||||
} else if (char === '"') {
|
||||
state = STATES.IN_DOUBLE_QUOTE;
|
||||
} else if (char === "'") {
|
||||
state = STATES.IN_SINGLE_QUOTE;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATES.IN_SINGLE_QUOTE:
|
||||
if (char === '\\' && nextChar) {
|
||||
// Skip escaped character
|
||||
pos += 2;
|
||||
continue;
|
||||
} else if (char === "'") {
|
||||
state = STATES.NORMAL;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATES.IN_DOUBLE_QUOTE:
|
||||
if (char === '\\' && nextChar) {
|
||||
// Skip escaped character
|
||||
pos += 2;
|
||||
continue;
|
||||
} else if (char === '"') {
|
||||
state = STATES.NORMAL;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATES.IN_COMMENT:
|
||||
if (char === '*' && nextChar === '/') {
|
||||
// Found comment end
|
||||
tokens.push([1, commentStart + 2, pos]);
|
||||
tokenStart = pos + 2;
|
||||
state = STATES.NORMAL;
|
||||
pos += 2; // Skip */
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
pos++;
|
||||
}
|
||||
|
||||
|
||||
// Handle remaining content
|
||||
if (state === STATES.IN_COMMENT) {
|
||||
// Unclosed comment - treat as comment to end
|
||||
tokens.push([1, commentStart + 2, length]);
|
||||
} else if (tokenStart < length) {
|
||||
// Add final non-comment token
|
||||
tokens.push([0, tokenStart, length]);
|
||||
}
|
||||
|
||||
return tokens;
|
||||
};
|
||||
|
||||
5
node_modules/postcss-discard-comments/types/index.d.ts
generated
vendored
5
node_modules/postcss-discard-comments/types/index.d.ts
generated
vendored
@@ -9,13 +9,14 @@ export = pluginCreator;
|
||||
* @param {Options} opts
|
||||
* @return {import('postcss').Plugin}
|
||||
*/
|
||||
declare function pluginCreator(opts?: Options): import('postcss').Plugin;
|
||||
declare function pluginCreator(opts?: Options): import("postcss").Plugin;
|
||||
declare namespace pluginCreator {
|
||||
export { postcss, Options };
|
||||
}
|
||||
declare var postcss: true;
|
||||
type Options = {
|
||||
removeAll?: boolean | undefined;
|
||||
removeAllButFirst?: boolean | undefined;
|
||||
remove?: ((s: string) => boolean) | undefined;
|
||||
};
|
||||
declare var postcss: true;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/postcss-discard-comments/types/index.d.ts.map
generated
vendored
Normal file
1
node_modules/postcss-discard-comments/types/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";AAKA;;;;GAIG;AACH;;;;GAIG;AACH,sCAHW,OAAO,GACN,OAAO,SAAS,EAAE,MAAM,CA8NnC;;;;;;gBArOc,OAAO,YAAC;wBACR,OAAO,YAAC;aACR,CAAA,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,aAAC"}
|
||||
1
node_modules/postcss-discard-comments/types/lib/commentParser.d.ts
generated
vendored
1
node_modules/postcss-discard-comments/types/lib/commentParser.d.ts
generated
vendored
@@ -1,2 +1,3 @@
|
||||
declare function _exports(input: string): [number, number, number][];
|
||||
export = _exports;
|
||||
//# sourceMappingURL=commentParser.d.ts.map
|
||||
1
node_modules/postcss-discard-comments/types/lib/commentParser.d.ts.map
generated
vendored
Normal file
1
node_modules/postcss-discard-comments/types/lib/commentParser.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"commentParser.d.ts","sourceRoot":"","sources":["../../src/lib/commentParser.js"],"names":[],"mappings":"AAiBiB,iCAHN,MAAM,GACL,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CA+ErC"}
|
||||
5
node_modules/postcss-discard-comments/types/lib/commentRemover.d.ts
generated
vendored
5
node_modules/postcss-discard-comments/types/lib/commentRemover.d.ts
generated
vendored
@@ -1,9 +1,9 @@
|
||||
export = CommentRemover;
|
||||
/** @param {import('../index.js').Options} options */
|
||||
declare function CommentRemover(options: import('../index.js').Options): void;
|
||||
declare function CommentRemover(options: import("../index.js").Options): void;
|
||||
declare class CommentRemover {
|
||||
/** @param {import('../index.js').Options} options */
|
||||
constructor(options: import('../index.js').Options);
|
||||
constructor(options: import("../index.js").Options);
|
||||
options: import("../index.js").Options;
|
||||
/**
|
||||
* @param {string} comment
|
||||
@@ -12,3 +12,4 @@ declare class CommentRemover {
|
||||
canRemove(comment: string): boolean | undefined;
|
||||
_hasFirst: boolean | undefined;
|
||||
}
|
||||
//# sourceMappingURL=commentRemover.d.ts.map
|
||||
1
node_modules/postcss-discard-comments/types/lib/commentRemover.d.ts.map
generated
vendored
Normal file
1
node_modules/postcss-discard-comments/types/lib/commentRemover.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"commentRemover.d.ts","sourceRoot":"","sources":["../../src/lib/commentRemover.js"],"names":[],"mappings":";AAEA,qDAAqD;AACrD,yCADY,OAAO,aAAa,EAAE,OAAO,QAGxC;;IAHD,qDAAqD;IACrD,qBADY,OAAO,aAAa,EAAE,OAAO,EAGxC;IADC,uCAAsB;IAExB;;;OAGG;IACH,mBAHW,MAAM,GACL,OAAO,GAAG,SAAS,CAqB9B;IAJK,+BAAqB"}
|
||||
Reference in New Issue
Block a user