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:
166
node_modules/svgo/lib/svgo.js
generated
vendored
166
node_modules/svgo/lib/svgo.js
generated
vendored
@@ -1,19 +1,84 @@
|
||||
'use strict';
|
||||
import { builtinPlugins } from './builtin.js';
|
||||
import { encodeSVGDatauri } from './svgo/tools.js';
|
||||
import { invokePlugins } from './svgo/plugins.js';
|
||||
import { querySelector, querySelectorAll } from './xast.js';
|
||||
import { mapNodesToParents } from './util/map-nodes-to-parents.js';
|
||||
import { parseSvg } from './parser.js';
|
||||
import { stringifySvg } from './stringifier.js';
|
||||
import { VERSION } from './version.js';
|
||||
import * as _collections from '../plugins/_collections.js';
|
||||
|
||||
const {
|
||||
defaultPlugins,
|
||||
resolvePluginConfig,
|
||||
extendDefaultPlugins,
|
||||
} = require('./svgo/config.js');
|
||||
const { parseSvg } = require('./parser.js');
|
||||
const { stringifySvg } = require('./stringifier.js');
|
||||
const { invokePlugins } = require('./svgo/plugins.js');
|
||||
const JSAPI = require('./svgo/jsAPI.js');
|
||||
const { encodeSVGDatauri } = require('./svgo/tools.js');
|
||||
const pluginsMap = new Map();
|
||||
for (const plugin of builtinPlugins) {
|
||||
pluginsMap.set(plugin.name, plugin);
|
||||
}
|
||||
|
||||
exports.extendDefaultPlugins = extendDefaultPlugins;
|
||||
/**
|
||||
* @param {string} name
|
||||
* @returns {import('./types.js').BuiltinPluginOrPreset<?, ?>}
|
||||
*/
|
||||
function getPlugin(name) {
|
||||
if (name === 'removeScriptElement') {
|
||||
console.warn(
|
||||
'Warning: removeScriptElement has been renamed to removeScripts, please update your SVGO config',
|
||||
);
|
||||
return pluginsMap.get('removeScripts');
|
||||
}
|
||||
|
||||
const optimize = (input, config) => {
|
||||
return pluginsMap.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string | import('./types.js').PluginConfig} plugin
|
||||
* @returns {?import('./types.js').PluginConfig}
|
||||
*/
|
||||
const resolvePluginConfig = (plugin) => {
|
||||
if (typeof plugin === 'string') {
|
||||
// resolve builtin plugin specified as string
|
||||
const builtinPlugin = getPlugin(plugin);
|
||||
if (builtinPlugin == null) {
|
||||
throw Error(`Unknown builtin plugin "${plugin}" specified.`);
|
||||
}
|
||||
return {
|
||||
name: plugin,
|
||||
params: {},
|
||||
fn: builtinPlugin.fn,
|
||||
};
|
||||
}
|
||||
if (typeof plugin === 'object' && plugin != null) {
|
||||
if (plugin.name == null) {
|
||||
throw Error(`Plugin name must be specified`);
|
||||
}
|
||||
// use custom plugin implementation
|
||||
// @ts-expect-error Checking for CustomPlugin with the presence of fn
|
||||
let fn = plugin.fn;
|
||||
if (fn == null) {
|
||||
// resolve builtin plugin implementation
|
||||
const builtinPlugin = getPlugin(plugin.name);
|
||||
if (builtinPlugin == null) {
|
||||
throw Error(`Unknown builtin plugin "${plugin.name}" specified.`);
|
||||
}
|
||||
fn = builtinPlugin.fn;
|
||||
}
|
||||
return {
|
||||
name: plugin.name,
|
||||
params: plugin.params,
|
||||
fn,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
export * from './types.js';
|
||||
|
||||
/**
|
||||
* The core of SVGO.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {import('./types.js').Config=} config
|
||||
* @returns {import('./types.js').Output}
|
||||
*/
|
||||
export const optimize = (input, config) => {
|
||||
if (config == null) {
|
||||
config = {};
|
||||
}
|
||||
@@ -22,62 +87,57 @@ const optimize = (input, config) => {
|
||||
}
|
||||
const maxPassCount = config.multipass ? 10 : 1;
|
||||
let prevResultSize = Number.POSITIVE_INFINITY;
|
||||
let svgjs = null;
|
||||
let output = '';
|
||||
const info = {};
|
||||
if (config.path != null) {
|
||||
info.path = config.path;
|
||||
}
|
||||
for (let i = 0; i < maxPassCount; i += 1) {
|
||||
info.multipassCount = i;
|
||||
// TODO throw this error in v3
|
||||
try {
|
||||
svgjs = parseSvg(input, config.path);
|
||||
} catch (error) {
|
||||
return { error: error.toString(), modernError: error };
|
||||
}
|
||||
if (svgjs.error != null) {
|
||||
if (config.path != null) {
|
||||
svgjs.path = config.path;
|
||||
}
|
||||
return svgjs;
|
||||
}
|
||||
const plugins = config.plugins || defaultPlugins;
|
||||
if (Array.isArray(plugins) === false) {
|
||||
const ast = parseSvg(input, config.path);
|
||||
const plugins = config.plugins || ['preset-default'];
|
||||
if (!Array.isArray(plugins)) {
|
||||
throw Error(
|
||||
"Invalid plugins list. Provided 'plugins' in config should be an array."
|
||||
'malformed config, `plugins` property must be an array.\nSee more info here: https://github.com/svg/svgo#configuration',
|
||||
);
|
||||
}
|
||||
const resolvedPlugins = plugins.map(resolvePluginConfig);
|
||||
const resolvedPlugins = plugins
|
||||
.filter((plugin) => plugin != null)
|
||||
.map(resolvePluginConfig);
|
||||
|
||||
if (resolvedPlugins.length < plugins.length) {
|
||||
console.warn(
|
||||
'Warning: plugins list includes null or undefined elements, these will be ignored.',
|
||||
);
|
||||
}
|
||||
|
||||
/** @type {import('./types.js').Config} */
|
||||
const globalOverrides = {};
|
||||
if (config.floatPrecision != null) {
|
||||
globalOverrides.floatPrecision = config.floatPrecision;
|
||||
}
|
||||
svgjs = invokePlugins(svgjs, info, resolvedPlugins, null, globalOverrides);
|
||||
svgjs = stringifySvg(svgjs, config.js2svg);
|
||||
if (svgjs.data.length < prevResultSize) {
|
||||
input = svgjs.data;
|
||||
prevResultSize = svgjs.data.length;
|
||||
invokePlugins(ast, info, resolvedPlugins, null, globalOverrides);
|
||||
output = stringifySvg(ast, config.js2svg);
|
||||
if (output.length < prevResultSize) {
|
||||
input = output;
|
||||
prevResultSize = output.length;
|
||||
} else {
|
||||
if (config.datauri) {
|
||||
svgjs.data = encodeSVGDatauri(svgjs.data, config.datauri);
|
||||
}
|
||||
if (config.path != null) {
|
||||
svgjs.path = config.path;
|
||||
}
|
||||
return svgjs;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return svgjs;
|
||||
if (config.datauri) {
|
||||
output = encodeSVGDatauri(output, config.datauri);
|
||||
}
|
||||
return {
|
||||
data: output,
|
||||
};
|
||||
};
|
||||
exports.optimize = optimize;
|
||||
|
||||
/**
|
||||
* The factory that creates a content item with the helper methods.
|
||||
*
|
||||
* @param {Object} data which is passed to jsAPI constructor
|
||||
* @returns {JSAPI} content item
|
||||
*/
|
||||
const createContentItem = (data) => {
|
||||
return new JSAPI(data);
|
||||
export {
|
||||
VERSION,
|
||||
builtinPlugins,
|
||||
mapNodesToParents,
|
||||
querySelector,
|
||||
querySelectorAll,
|
||||
_collections,
|
||||
};
|
||||
exports.createContentItem = createContentItem;
|
||||
|
||||
Reference in New Issue
Block a user