builderman verion 0.1.0, initial commit/release.

This commit is contained in:
2025-05-19 23:05:15 -04:00
parent 0578647c3f
commit ec0ffccdb2
1281 changed files with 218046 additions and 0 deletions

31
node_modules/minify/lib/css.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
/* сжимаем код через clean-css */
'use strict';
const assert = require('assert');
const Clean = require('clean-css');
/**
* minify css data.
*
* @param data
* @param userOptions - (optional) object that may contain a `css` key with an object of options
*/
module.exports = (data, userOptions) => {
assert(data);
const options = userOptions && userOptions.css || {};
const {
styles,
errors,
} = new Clean(options).minify(data);
const [error] = errors;
if (error)
throw error;
return styles;
};

47
node_modules/minify/lib/html.js generated vendored Normal file
View File

@@ -0,0 +1,47 @@
/* сжимаем код через htmlMinify */
'use strict';
const assert = require('assert');
const Minifier = require('html-minifier-terser');
const defaultOptions = {
removeComments: true,
removeCommentsFromCDATA: true,
removeCDATASectionsFromCDATA: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
/* оставляем, поскольку у нас
* в элемент fm генерируеться
* таблица файлов
*/
removeEmptyElements: false,
removeOptionalTags: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
minifyJS: true,
minifyCSS: true,
};
/**
* minify html data.
*
* @param data
* @param userOptions - (optional) object that may contain an `html` key with an object of options
*/
module.exports = (data, userOptions) => {
assert(data);
const options = {
...defaultOptions,
...userOptions && userOptions.html || {},
};
return Minifier.minify(data, options);
};

37
node_modules/minify/lib/img.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
'use strict';
const path = require('path');
const assert = require('assert');
const {promisify} = require('util');
const fromString = promisify(require('css-b64-images').fromString);
const ONE_KB = 2 ** 10;
const defaultOptions = {
maxSize: 100 * ONE_KB,
};
/**
* minify css data.
* if can not minify return data
*
* @param name
* @param data
* @param userOptions - (optional) object that may contain an `img` key with an object of options
*/
module.exports = async (name, data, userOptions) => {
const dir = path.dirname(name);
const dirRelative = dir + '/../';
const options = {
...defaultOptions,
...userOptions && userOptions.img || {},
};
assert(name);
assert(data);
return fromString(data, dir, dirRelative, options);
};

20
node_modules/minify/lib/js.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
'use strict';
const terser = require('terser');
const assert = require('assert');
/**
* minify js data.
*
* @param data
* @param userOptions - (optional) object that may contain a `js` key with an object of options
*/
module.exports = async (data, userOptions) => {
assert(data);
const options = userOptions && userOptions.js || {};
const {code} = await terser.minify(data, options);
return code;
};

84
node_modules/minify/lib/minify.js generated vendored Normal file
View File

@@ -0,0 +1,84 @@
'use strict';
const DIR = __dirname + '/';
const {readFile} = require('fs').promises;
const path = require('path');
const tryToCatch = require('try-to-catch');
const log = require('debug')('minify');
for (const name of ['js', 'html', 'css', 'img']) {
minify[name] = require(DIR + name);
}
module.exports = minify;
function check(name) {
if (!name)
throw Error('name could not be empty!');
}
async function minify(name, userOptions) {
const EXT = ['js', 'html', 'css'];
check(name);
const ext = path.extname(name).slice(1);
const is = EXT.includes(ext);
if (!is)
throw Error(`File type "${ext}" not supported.`);
log('optimizing ' + path.basename(name));
return await optimize(name, userOptions);
}
function getName(file) {
const notObj = typeof file !== 'object';
if (notObj)
return file;
return Object.keys(file)[0];
}
/**
* function minificate js,css and html files
*
* @param {string} file - js, css or html file path
* @param {object} userOptions - object with optional `html`, `css, `js`, and `img` keys, which each can contain options to be combined with defaults and passed to the respective minifier
*/
async function optimize(file, userOptions) {
check(file);
const name = getName(file);
log('reading file ' + path.basename(name));
const data = await readFile(name, 'utf8');
return await onDataRead(file, data, userOptions);
}
/**
* Processing of files
* @param {string} filename
* @param {string} data - the contents of the file
* @param {object} userOptions - object with optional `html`, `css, `js`, and `img` keys, which each can contain options to be combined with defaults and passed to the respective minifier
*/
async function onDataRead(filename, data, userOptions) {
log('file ' + path.basename(filename) + ' read');
const ext = path.extname(filename).replace(/^\./, '');
const optimizedData = await minify[ext](data, userOptions);
let b64Optimize;
if (ext === 'css')
[, b64Optimize] = await tryToCatch(minify.img, filename, optimizedData, userOptions);
return b64Optimize || optimizedData;
}