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>
93 lines
2.5 KiB
JavaScript
Executable File
93 lines
2.5 KiB
JavaScript
Executable File
import { SourceMapGenerator } from 'source-map-js/lib/source-map-generator.js';
|
|
|
|
const trackNodes = new Set(['Atrule', 'Selector', 'Declaration']);
|
|
|
|
export function generateSourceMap(handlers) {
|
|
const map = new SourceMapGenerator();
|
|
const generated = {
|
|
line: 1,
|
|
column: 0
|
|
};
|
|
const original = {
|
|
line: 0, // should be zero to add first mapping
|
|
column: 0
|
|
};
|
|
const activatedGenerated = {
|
|
line: 1,
|
|
column: 0
|
|
};
|
|
const activatedMapping = {
|
|
generated: activatedGenerated
|
|
};
|
|
let line = 1;
|
|
let column = 0;
|
|
let sourceMappingActive = false;
|
|
|
|
const origHandlersNode = handlers.node;
|
|
handlers.node = function(node) {
|
|
if (node.loc && node.loc.start && trackNodes.has(node.type)) {
|
|
const nodeLine = node.loc.start.line;
|
|
const nodeColumn = node.loc.start.column - 1;
|
|
|
|
if (original.line !== nodeLine ||
|
|
original.column !== nodeColumn) {
|
|
original.line = nodeLine;
|
|
original.column = nodeColumn;
|
|
|
|
generated.line = line;
|
|
generated.column = column;
|
|
|
|
if (sourceMappingActive) {
|
|
sourceMappingActive = false;
|
|
if (generated.line !== activatedGenerated.line ||
|
|
generated.column !== activatedGenerated.column) {
|
|
map.addMapping(activatedMapping);
|
|
}
|
|
}
|
|
|
|
sourceMappingActive = true;
|
|
map.addMapping({
|
|
source: node.loc.source,
|
|
original,
|
|
generated
|
|
});
|
|
}
|
|
}
|
|
|
|
origHandlersNode.call(this, node);
|
|
|
|
if (sourceMappingActive && trackNodes.has(node.type)) {
|
|
activatedGenerated.line = line;
|
|
activatedGenerated.column = column;
|
|
}
|
|
};
|
|
|
|
const origHandlersEmit = handlers.emit;
|
|
handlers.emit = function(value, type, auto) {
|
|
for (let i = 0; i < value.length; i++) {
|
|
if (value.charCodeAt(i) === 10) { // \n
|
|
line++;
|
|
column = 0;
|
|
} else {
|
|
column++;
|
|
}
|
|
}
|
|
|
|
origHandlersEmit(value, type, auto);
|
|
};
|
|
|
|
const origHandlersResult = handlers.result;
|
|
handlers.result = function() {
|
|
if (sourceMappingActive) {
|
|
map.addMapping(activatedMapping);
|
|
}
|
|
|
|
return {
|
|
css: origHandlersResult(),
|
|
map
|
|
};
|
|
};
|
|
|
|
return handlers;
|
|
};
|