first commit

This commit is contained in:
dhp
2026-04-23 17:03:40 +08:00
commit dfd77fe83b
1298 changed files with 163510 additions and 0 deletions

43
node_modules/less/lib/less-node/environment.js generated vendored Normal file
View File

@@ -0,0 +1,43 @@
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
class SourceMapGeneratorFallback {
addMapping(){}
setSourceContent(){}
toJSON(){
return null;
}
};
export default {
encodeBase64: function encodeBase64(str) {
// Avoid Buffer constructor on newer versions of Node.js.
const buffer = (Buffer.from ? Buffer.from(str) : (new Buffer(str)));
return buffer.toString('base64');
},
mimeLookup: function (filename) {
try {
const mimeModule = require('mime');
return mimeModule ? mimeModule.lookup(filename) : "application/octet-stream";
} catch (e) {
return "application/octet-stream";
}
},
charsetLookup: function (mime) {
try {
const mimeModule = require('mime');
return mimeModule ? mimeModule.charsets.lookup(mime) : undefined;
} catch (e) {
return undefined;
}
},
getSourceMapGenerator: function getSourceMapGenerator() {
try {
const sourceMapModule = require('source-map');
return sourceMapModule ? sourceMapModule.SourceMapGenerator : SourceMapGeneratorFallback;
} catch (e) {
return SourceMapGeneratorFallback;
}
}
};

156
node_modules/less/lib/less-node/file-manager.js generated vendored Normal file
View File

@@ -0,0 +1,156 @@
import path from 'path';
import { createRequire } from 'module';
import fs from './fs.js';
import AbstractFileManager from '../less/environment/abstract-file-manager.js';
const require = createRequire(import.meta.url);
const FileManager = function() {}
FileManager.prototype = Object.assign(new AbstractFileManager(), {
supports() {
return true;
},
supportsSync() {
return true;
},
loadFile(filename, currentDirectory, options, environment, callback) {
let fullFilename;
const isAbsoluteFilename = this.isPathAbsolute(filename);
const filenamesTried = [];
const self = this;
const prefix = filename.slice(0, 1);
const explicit = prefix === '.' || prefix === '/';
let result = null;
let isNodeModule = false;
const npmPrefix = 'npm://';
options = options || {};
const paths = isAbsoluteFilename ? [''] : [currentDirectory];
if (options.paths) { paths.push.apply(paths, options.paths); }
if (!isAbsoluteFilename && paths.indexOf('.') === -1) { paths.push('.'); }
const prefixes = options.prefixes || [''];
const fileParts = this.extractUrlParts(filename);
if (options.syncImport) {
getFileData(returnData, returnData);
if (callback) {
callback(result.error, result);
}
else {
return result;
}
}
else {
// promise is guaranteed to be asyncronous
// which helps as it allows the file handle
// to be closed before it continues with the next file
return new Promise(getFileData);
}
function returnData(data) {
if (!data.filename) {
result = { error: data };
}
else {
result = data;
}
}
function getFileData(fulfill, reject) {
(function tryPathIndex(i) {
function tryWithExtension() {
const extFilename = options.ext ? self.tryAppendExtension(fullFilename, options.ext) : fullFilename;
if (extFilename !== fullFilename && !explicit && paths[i] === '.') {
try {
fullFilename = require.resolve(extFilename);
isNodeModule = true;
}
catch (e) {
filenamesTried.push(npmPrefix + extFilename);
fullFilename = extFilename;
}
}
else {
fullFilename = extFilename;
}
}
if (i < paths.length) {
(function tryPrefix(j) {
if (j < prefixes.length) {
isNodeModule = false;
fullFilename = fileParts.rawPath + prefixes[j] + fileParts.filename;
if (paths[i]) {
if (paths[i].startsWith('#')) {
// Handling paths starting with '#'
fullFilename = paths[i].substr(1) + fullFilename;
}else{
fullFilename = path.join(paths[i], fullFilename);
}
}
if (!explicit && paths[i] === '.') {
try {
fullFilename = require.resolve(fullFilename);
isNodeModule = true;
}
catch (e) {
filenamesTried.push(npmPrefix + fullFilename);
tryWithExtension();
}
}
else {
tryWithExtension();
}
const readFileArgs = [fullFilename];
if (!options.rawBuffer) {
readFileArgs.push('utf-8');
}
if (options.syncImport) {
try {
const data = fs.readFileSync.apply(this, readFileArgs);
fulfill({ contents: data, filename: fullFilename});
}
catch (e) {
filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename);
return tryPrefix(j + 1);
}
}
else {
readFileArgs.push(function(e, data) {
if (e) {
filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename);
return tryPrefix(j + 1);
}
fulfill({ contents: data, filename: fullFilename});
});
fs.readFile.apply(this, readFileArgs);
}
}
else {
tryPathIndex(i + 1);
}
})(0);
} else {
reject({ type: 'File', message: `'${filename}' wasn't found. Tried - ${filenamesTried.join(',')}` });
}
}(0));
}
},
loadFileSync(filename, currentDirectory, options, environment) {
options.syncImport = true;
return this.loadFile(filename, currentDirectory, options, environment);
}
});
export default FileManager;

14
node_modules/less/lib/less-node/fs.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
/** @typedef {import('fs')} FS */
import nodeFs from 'fs';
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
/** @type {FS} */
let fs;
try {
fs = require('graceful-fs');
} catch (e) {
fs = nodeFs;
}
export default fs;

59
node_modules/less/lib/less-node/image-size.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
import { createRequire } from 'module';
import Dimension from '../less/tree/dimension.js';
import Expression from '../less/tree/expression.js';
import functionRegistry from './../less/functions/function-registry.js';
const require = createRequire(import.meta.url);
export default environment => {
function imageSize(functionContext, filePathNode) {
let filePath = filePathNode.value;
const currentFileInfo = functionContext.currentFileInfo;
const currentDirectory = currentFileInfo.rewriteUrls ?
currentFileInfo.currentDirectory : currentFileInfo.entryPath;
const fragmentStart = filePath.indexOf('#');
if (fragmentStart !== -1) {
filePath = filePath.slice(0, fragmentStart);
}
const fileManager = environment.getFileManager(filePath, currentDirectory, functionContext.context, environment, true);
if (!fileManager) {
throw {
type: 'File',
message: `Can not set up FileManager for ${filePathNode}`
};
}
const fileSync = fileManager.loadFileSync(filePath, currentDirectory, functionContext.context, environment);
if (fileSync.error) {
throw fileSync.error;
}
const sizeOf = require('image-size');
return sizeOf ? sizeOf(fileSync.filename) : {width: 0, height: 0};
}
const imageFunctions = {
'image-size': function(filePathNode) {
const size = imageSize(this, filePathNode);
return new Expression([
new Dimension(size.width, 'px'),
new Dimension(size.height, 'px')
]);
},
'image-width': function(filePathNode) {
const size = imageSize(this, filePathNode);
return new Dimension(size.width, 'px');
},
'image-height': function(filePathNode) {
const size = imageSize(this, filePathNode);
return new Dimension(size.height, 'px');
}
};
functionRegistry.addMultiple(imageFunctions);
};

31
node_modules/less/lib/less-node/index.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
import { createRequire } from 'module';
import environment from './environment.js';
import FileManager from './file-manager.js';
import UrlFileManager from './url-file-manager.js';
import createFromEnvironment from '../less/index.js';
import lesscHelper from './lessc-helper.js';
import PluginLoader from './plugin-loader.js';
import fs from './fs.js';
import defaultOptions from '../less/default-options.js';
import imageSize from './image-size.js';
const require = createRequire(import.meta.url);
const { version } = require('../../package.json');
const less = createFromEnvironment(environment, [new FileManager(), new UrlFileManager()], version);
// allow people to create less with their own environment
less.createFromEnvironment = createFromEnvironment;
less.lesscHelper = lesscHelper;
less.PluginLoader = PluginLoader;
less.fs = fs;
less.FileManager = FileManager;
less.UrlFileManager = UrlFileManager;
// Set up options
less.options = defaultOptions();
// provide image-size functionality
imageSize(less.environment);
export default less;

95
node_modules/less/lib/less-node/lessc-helper.js generated vendored Normal file
View File

@@ -0,0 +1,95 @@
// lessc_helper.js
//
// helper functions for lessc
const lessc_helper = {
// Stylize a string
stylize : function(str, style) {
const styles = {
'reset' : [0, 0],
'bold' : [1, 22],
'inverse' : [7, 27],
'underline' : [4, 24],
'yellow' : [33, 39],
'green' : [32, 39],
'red' : [31, 39],
'grey' : [90, 39]
};
return `\x1b[${styles[style][0]}m${str}\x1b[${styles[style][1]}m`;
},
// Print command line options
printUsage: function() {
console.log('usage: lessc [option option=parameter ...] <source> [destination]');
console.log('');
console.log('If source is set to `-\' (dash or hyphen-minus), input is read from stdin.');
console.log('');
console.log('options:');
console.log(' -h, --help Prints help (this message) and exit.');
console.log(' --include-path=PATHS Sets include paths. Separated by `:\'. `;\' also supported on windows.');
console.log(' -M, --depends Outputs a makefile import dependency list to stdout.');
console.log(' --no-color Disables colorized output.');
console.log(' --ie-compat Enables IE8 compatibility checks.');
console.log(' --js Enables inline JavaScript in less files');
console.log(' -l, --lint Syntax check only (lint).');
console.log(' -s, --silent Suppresses output of error messages.');
console.log(' --quiet Suppresses output of warnings.');
console.log(' --strict-imports (DEPRECATED) Ignores .less imports inside selector blocks. Has confusing behavior.');
console.log(' --insecure Allows imports from insecure https hosts.');
console.log(' -v, --version Prints version number and exit.');
console.log(' --verbose Be verbose.');
console.log(' --source-map[=FILENAME] Outputs a v3 sourcemap to the filename (or output filename.map).');
console.log(' --source-map-rootpath=X Adds this path onto the sourcemap filename and less file paths.');
console.log(' --source-map-basepath=X Sets sourcemap base path, defaults to current working directory.');
console.log(' --source-map-include-source Puts the less files into the map instead of referencing them.');
console.log(' --source-map-inline Puts the map (and any less files) as a base64 data uri into the output css file.');
console.log(' --source-map-url=URL Sets a custom URL to map file, for sourceMappingURL comment');
console.log(' in generated CSS file.');
console.log(' --source-map-no-annotation Excludes the sourceMappingURL comment from the output css file.');
console.log(' -rp, --rootpath=URL Sets rootpath for url rewriting in relative imports and urls');
console.log(' Works with or without the relative-urls option.');
console.log(' -ru=, --rewrite-urls= Rewrites URLs to make them relative to the base less file.');
console.log(' all|local|off \'all\' rewrites all URLs, \'local\' just those starting with a \'.\'');
console.log('');
console.log(' -m=, --math=');
console.log(' always Less will eagerly perform math operations always.');
console.log(' parens-division Math performed except for division (/) operator');
console.log(' parens | strict Math only performed inside parentheses');
console.log(' strict-legacy Parens required in very strict terms (legacy --strict-math)');
console.log('');
console.log(' -su=on|off Allows mixed units, e.g. 1px+1em or 1px*1px which have units');
console.log(' --strict-units=on|off that cannot be represented.');
console.log(' --global-var=\'VAR=VALUE\' Defines a variable that can be referenced by the file.');
console.log(' --modify-var=\'VAR=VALUE\' Modifies a variable already declared in the file.');
console.log(' --url-args=\'QUERYSTRING\' Adds params into url tokens (e.g. 42, cb=42 or \'a=1&b=2\')');
console.log(' --plugin=PLUGIN=OPTIONS Loads a plugin. You can also omit the --plugin= if the plugin begins');
console.log(' less-plugin. E.g. the clean css plugin is called less-plugin-clean-css');
console.log(' once installed (npm install less-plugin-clean-css), use either with');
console.log(' --plugin=less-plugin-clean-css or just --clean-css');
console.log(' specify options afterwards e.g. --plugin=less-plugin-clean-css="advanced"');
console.log(' or --clean-css="advanced"');
console.log(' --disable-plugin-rule Disallow @plugin statements');
console.log('');
console.log(' --quiet-deprecations Suppress deprecation warnings only (keeps other warnings).');
console.log('');
console.log('-------------------------- Deprecated ----------------');
console.log(' -sm=on|off Legacy parens-only math. Use --math');
console.log(' --strict-math=on|off ');
console.log('');
console.log(' --line-numbers=TYPE (DEPRECATED) Outputs filename and line numbers.');
console.log(' TYPE can be either \'comments\', \'mediaquery\', or \'all\'.');
console.log(' The entire dumpLineNumbers option is deprecated.');
console.log(' Use sourcemaps (--source-map) instead.');
console.log(' All modes will be removed in a future version.');
console.log(' Note: \'mediaquery\' and \'all\' modes generate @media -sass-debug-info');
console.log(' which had short-lived usage and is no longer recommended.');
console.log(' -x, --compress Compresses output by removing some whitespaces.');
console.log(' We recommend you use a dedicated minifer like less-plugin-clean-css');
console.log('');
console.log('Report bugs to: http://github.com/less/less.js/issues');
console.log('Home page: <http://lesscss.org/>');
}
};
export const { stylize, printUsage } = lessc_helper;
export default lessc_helper;

62
node_modules/less/lib/less-node/plugin-loader.js generated vendored Normal file
View File

@@ -0,0 +1,62 @@
import path from 'path';
import { createRequire } from 'module';
import AbstractPluginLoader from '../less/environment/abstract-plugin-loader.js';
const require = createRequire(import.meta.url);
/**
* Node Plugin Loader
*/
const PluginLoader = function(less) {
this.less = less;
this.require = prefix => {
prefix = path.dirname(prefix);
return id => {
const str = id.slice(0, 2);
if (str === '..' || str === './') {
return require(path.join(prefix, id));
}
else {
return require(id);
}
};
};
};
PluginLoader.prototype = Object.assign(new AbstractPluginLoader(), {
loadPlugin(filename, basePath, context, environment, fileManager) {
const prefix = filename.slice(0, 1);
const explicit = prefix === '.' || prefix === '/' || filename.slice(-3).toLowerCase() === '.js';
if (!explicit) {
context.prefixes = ['less-plugin-', ''];
}
if (context.syncImport) {
return fileManager.loadFileSync(filename, basePath, context, environment);
}
return new Promise((fulfill, reject) => {
fileManager.loadFile(filename, basePath, context, environment).then(
data => {
try {
fulfill(data);
}
catch (e) {
console.log(e);
reject(e);
}
}
).catch(err => {
reject(err);
});
});
},
loadPluginSync(filename, basePath, context, environment, fileManager) {
context.syncImport = true;
return this.loadPlugin(filename, basePath, context, environment, fileManager);
}
});
export default PluginLoader;

60
node_modules/less/lib/less-node/url-file-manager.js generated vendored Normal file
View File

@@ -0,0 +1,60 @@
/* eslint-disable no-unused-vars */
/**
* @todo - remove top eslint rule when FileManagers have JSDoc type
* and are TS-type-checked
*/
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const isUrlRe = /^(?:https?:)?\/\//i;
import url from 'url';
let request;
import AbstractFileManager from '../less/environment/abstract-file-manager.js';
import logger from '../less/logger.js';
const UrlFileManager = function() {}
UrlFileManager.prototype = Object.assign(new AbstractFileManager(), {
supports(filename, currentDirectory, options, environment) {
return isUrlRe.test( filename ) || isUrlRe.test(currentDirectory);
},
loadFile(filename, currentDirectory, options, environment) {
return new Promise((fulfill, reject) => {
if (request === undefined) {
try { request = require('needle'); }
catch (e) { request = null; }
}
if (!request) {
reject({ type: 'File', message: 'optional dependency \'needle\' required to import over http(s)\n' });
return;
}
let urlStr = isUrlRe.test( filename ) ? filename : url.resolve(currentDirectory, filename);
/** native-request currently has a bug */
const hackUrlStr = urlStr.indexOf('?') === -1 ? urlStr + '?' : urlStr
request.get(hackUrlStr, { follow_max: 5 }, (err, resp, body) => {
if (err || resp && resp.statusCode >= 400) {
const message = resp && resp.statusCode === 404
? `resource '${urlStr}' was not found\n`
: `resource '${urlStr}' gave this Error:\n ${err || resp.statusMessage || resp.statusCode}\n`;
reject({ type: 'File', message });
return;
}
if (resp.statusCode >= 300) {
reject({ type: 'File', message: `resource '${urlStr}' caused too many redirects` });
return;
}
body = body.toString('utf8');
if (!body) {
logger.warn(`Warning: Empty body (HTTP ${resp.statusCode}) returned by "${urlStr}"`);
}
fulfill({ contents: body || '', filename: urlStr });
});
});
}
});
export default UrlFileManager;