Changeset e29cc2e for trip-planner-front/node_modules/svgo/lib
- Timestamp:
- 11/25/21 22:08:24 (3 years ago)
- Branches:
- master
- Children:
- 8d391a1
- Parents:
- 59329aa
- Location:
- trip-planner-front/node_modules/svgo/lib
- Files:
-
- 1 added
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner-front/node_modules/svgo/lib/svgo-node.js
r59329aa re29cc2e 16 16 const importConfig = async (configFile) => { 17 17 let config; 18 try { 19 // dynamic import expects file url instead of path and may fail 20 // when windows path is provided 21 const { default: imported } = await import(pathToFileURL(configFile)); 22 config = imported; 23 } catch (importError) { 24 // TODO remove require in v3 18 // at the moment dynamic import may randomly fail with segfault 19 // to workaround this for some users .cjs extension is loaded 20 // exclusively with require 21 if (configFile.endsWith('.cjs')) { 22 config = require(configFile); 23 } else { 25 24 try { 26 config = require(configFile); 27 } catch (requireError) { 28 // throw original error if es module is detected 29 if (requireError.code === 'ERR_REQUIRE_ESM') { 30 throw importError; 31 } else { 32 throw requireError; 25 // dynamic import expects file url instead of path and may fail 26 // when windows path is provided 27 const { default: imported } = await import(pathToFileURL(configFile)); 28 config = imported; 29 } catch (importError) { 30 // TODO remove require in v3 31 try { 32 config = require(configFile); 33 } catch (requireError) { 34 // throw original error if es module is detected 35 if (requireError.code === 'ERR_REQUIRE_ESM') { 36 throw importError; 37 } else { 38 throw requireError; 39 } 33 40 } 34 41 } -
trip-planner-front/node_modules/svgo/lib/svgo.js
r59329aa re29cc2e 7 7 } = require('./svgo/config.js'); 8 8 const { parseSvg } = require('./parser.js'); 9 const js2svg = require('./svgo/js2svg.js');9 const { stringifySvg } = require('./stringifier.js'); 10 10 const { invokePlugins } = require('./svgo/plugins.js'); 11 11 const JSAPI = require('./svgo/jsAPI.js'); … … 54 54 } 55 55 svgjs = invokePlugins(svgjs, info, resolvedPlugins, null, globalOverrides); 56 svgjs = js2svg(svgjs, config.js2svg); 57 if (svgjs.error) { 58 throw Error(svgjs.error); 59 } 56 svgjs = stringifySvg(svgjs, config.js2svg); 60 57 if (svgjs.data.length < prevResultSize) { 61 58 input = svgjs.data; -
trip-planner-front/node_modules/svgo/lib/svgo/coa.js
r59329aa re29cc2e 1 1 'use strict'; 2 2 3 const FS= require('fs');4 const PATH= require('path');5 const { green, red } = require('nanocolors');3 const fs = require('fs'); 4 const path = require('path'); 5 const colors = require('picocolors'); 6 6 const { loadConfig, optimize } = require('../svgo-node.js'); 7 7 const pluginsMap = require('../../plugins/plugins.js'); … … 17 17 function checkIsDir(path) { 18 18 try { 19 return FS.lstatSync(path).isDirectory();19 return fs.lstatSync(path).isDirectory(); 20 20 } catch (e) { 21 21 return false; … … 74 74 ) 75 75 .option('--show-plugins', 'Show available plugins and exit') 76 // used by picocolors internally 77 .option('--no-color', 'Output plain text without color') 76 78 .action(action); 77 79 }; … … 219 221 output[i] = checkIsDir(input[i]) 220 222 ? input[i] 221 : PATH.resolve(dir, PATH.basename(input[i]));223 : path.resolve(dir, path.basename(input[i])); 222 224 } 223 225 } else if (output.length < input.length) { … … 284 286 console.log(`Processing directory '${dir}':\n`); 285 287 } 286 return FS.promises288 return fs.promises 287 289 .readdir(dir) 288 290 .then((files) => processDirectory(config, dir, files, output)); … … 332 334 ) 333 335 .map((name) => ({ 334 inputPath: PATH.resolve(dir, name),335 outputPath: PATH.resolve(output, name),336 inputPath: path.resolve(dir, name), 337 outputPath: path.resolve(output, name), 336 338 })); 337 339 … … 340 342 filesInThisFolder, 341 343 files 342 .filter((name) => checkIsDir( PATH.resolve(dir, name)))344 .filter((name) => checkIsDir(path.resolve(dir, name))) 343 345 .map((subFolderName) => { 344 const subFolderPath = PATH.resolve(dir, subFolderName);345 const subFolderFiles = FS.readdirSync(subFolderPath);346 const subFolderOutput = PATH.resolve(output, subFolderName);346 const subFolderPath = path.resolve(dir, subFolderName); 347 const subFolderFiles = fs.readdirSync(subFolderPath); 348 const subFolderOutput = path.resolve(output, subFolderName); 347 349 return getFilesDescriptions( 348 350 config, … … 365 367 */ 366 368 function optimizeFile(config, file, output) { 367 return FS.promises.readFile(file, 'utf8').then(369 return fs.promises.readFile(file, 'utf8').then( 368 370 (data) => 369 371 processSVGData(config, { input: 'file', path: file }, data, output, file), … … 386 388 const result = optimize(data, { ...config, ...info }); 387 389 if (result.modernError) { 388 console.error( red(result.modernError.toString()));390 console.error(colors.red(result.modernError.toString())); 389 391 process.exit(1); 390 392 } … … 399 401 if (!config.quiet && output != '-') { 400 402 if (input) { 401 console.log(`\n${ PATH.basename(input)}:`);403 console.log(`\n${path.basename(input)}:`); 402 404 } 403 405 printTimeInfo(processingTime); … … 429 431 } 430 432 431 FS.mkdirSync(PATH.dirname(output), { recursive: true });432 433 return FS.promises433 fs.mkdirSync(path.dirname(output), { recursive: true }); 434 435 return fs.promises 434 436 .writeFile(output, data, 'utf8') 435 437 .catch((error) => checkWriteFileError(input, output, data, error)); … … 456 458 ' KiB' + 457 459 (profitPercents < 0 ? ' + ' : ' - ') + 458 green(Math.abs(Math.round(profitPercents * 10) / 10) + '%') +460 colors.green(Math.abs(Math.round(profitPercents * 10) / 10) + '%') + 459 461 ' = ' + 460 462 Math.round((outBytes / 1024) * 1000) / 1000 + … … 492 494 function checkWriteFileError(input, output, data, error) { 493 495 if (error.code == 'EISDIR' && input) { 494 return FS.promises.writeFile(495 PATH.resolve(output, PATH.basename(input)),496 return fs.promises.writeFile( 497 path.resolve(output, path.basename(input)), 496 498 data, 497 499 'utf8' … … 508 510 const list = Object.entries(pluginsMap) 509 511 .sort(([a], [b]) => a.localeCompare(b)) 510 .map(([name, plugin]) => ` [ ${ green(name)} ] ${plugin.description}`)512 .map(([name, plugin]) => ` [ ${colors.green(name)} ] ${plugin.description}`) 511 513 .join('\n'); 512 514 console.log('Currently available plugins:\n' + list); -
trip-planner-front/node_modules/svgo/lib/svgo/plugins.js
r59329aa re29cc2e 87 87 globalOverrides.floatPrecision = floatPrecision; 88 88 } 89 if (overrides) { 90 for (const [pluginName, override] of Object.entries(overrides)) { 91 if (override === true) { 92 console.warn( 93 `You are trying to enable ${pluginName} which is not part of preset.\n` + 94 `Try to put it before or after preset, for example\n\n` + 95 `plugins: [\n` + 96 ` {\n` + 97 ` name: 'preset-default',\n` + 98 ` },\n` + 99 ` 'cleanupListOfValues'\n` + 100 `]\n` 101 ); 102 } 103 } 104 } 89 105 return invokePlugins(ast, info, plugins, overrides, globalOverrides); 90 106 }, -
trip-planner-front/node_modules/svgo/lib/types.ts
r59329aa re29cc2e 51 51 52 52 export type XastNode = XastRoot | XastChild; 53 54 export type StringifyOptions = { 55 doctypeStart?: string; 56 doctypeEnd?: string; 57 procInstStart?: string; 58 procInstEnd?: string; 59 tagOpenStart?: string; 60 tagOpenEnd?: string; 61 tagCloseStart?: string; 62 tagCloseEnd?: string; 63 tagShortStart?: string; 64 tagShortEnd?: string; 65 attrStart?: string; 66 attrEnd?: string; 67 commentStart?: string; 68 commentEnd?: string; 69 cdataStart?: string; 70 cdataEnd?: string; 71 textStart?: string; 72 textEnd?: string; 73 indent?: number | string; 74 regEntities?: RegExp; 75 regValEntities?: RegExp; 76 encodeEntity?: (char: string) => string; 77 pretty?: boolean; 78 useShortTags?: boolean; 79 eol?: 'lf' | 'crlf'; 80 finalNewline?: boolean; 81 }; 53 82 54 83 type VisitorNode<Node> = {
Note:
See TracChangeset
for help on using the changeset viewer.