feat:node-modules

This commit is contained in:
houjunxiang
2025-11-24 10:26:18 +08:00
parent 753766893b
commit 8a3e48d856
8825 changed files with 567399 additions and 1 deletions

31
node_modules/mathjs/lib/cjs/core/config.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DEFAULT_CONFIG = void 0;
const DEFAULT_CONFIG = exports.DEFAULT_CONFIG = {
// minimum relative difference between two compared values,
// used by all comparison functions
relTol: 1e-12,
// minimum absolute difference between two compared values,
// used by all comparison functions
absTol: 1e-15,
// type of default matrix output. Choose 'matrix' (default) or 'array'
matrix: 'Matrix',
// type of default number output. Choose 'number' (default) 'BigNumber', 'bigint', or 'Fraction'
number: 'number',
// type of fallback used for config { number: 'bigint' } when a value cannot be represented
// in the configured numeric type. Choose 'number' (default) or 'BigNumber'.
numberFallback: 'number',
// number of significant digits in BigNumbers
precision: 64,
// predictable output type of functions. When true, output type depends only
// on the input types. When false (default), output type can vary depending
// on input values. For example `math.sqrt(-4)` returns `complex('2i')` when
// predictable is false, and returns `NaN` when true.
predictable: false,
// random seed for seeded pseudo random number generation
// null = randomly seed
randomSeed: null
};

213
node_modules/mathjs/lib/cjs/core/create.js generated vendored Normal file
View File

@@ -0,0 +1,213 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.create = create;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _typedFunction = _interopRequireDefault(require("typed-function"));
var _ArgumentsError = require("../error/ArgumentsError.js");
var _DimensionError = require("../error/DimensionError.js");
var _IndexError = require("../error/IndexError.js");
var _factory = require("../utils/factory.js");
var _is = require("../utils/is.js");
var _object = require("../utils/object.js");
var emitter = _interopRequireWildcard(require("./../utils/emitter.js"));
var _config = require("./config.js");
var _config2 = require("./function/config.js");
var _import = require("./function/import.js");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
/**
* Create a mathjs instance from given factory functions and optionally config
*
* Usage:
*
* const mathjs1 = create({ createAdd, createMultiply, ...})
* const config = { number: 'BigNumber' }
* const mathjs2 = create(all, config)
*
* @param {Object} [factories] An object with factory functions
* The object can contain nested objects,
* all nested objects will be flattened.
* @param {Object} [config] Available options:
* {number} relTol
* Minimum relative difference between two
* compared values, used by all comparison functions.
* {number} absTol
* Minimum absolute difference between two
* compared values, used by all comparison functions.
* {string} matrix
* A string 'Matrix' (default) or 'Array'.
* {string} number
* A string 'number' (default), 'BigNumber', or 'Fraction'
* {number} precision
* The number of significant digits for BigNumbers.
* Not applicable for Numbers.
* {boolean} predictable
* Predictable output type of functions. When true,
* output type depends only on the input types. When
* false (default), output type can vary depending
* on input values. For example `math.sqrt(-4)`
* returns `complex('2i')` when predictable is false, and
* returns `NaN` when true.
* {string} randomSeed
* Random seed for seeded pseudo random number generator.
* Set to null to randomly seed.
* @returns {Object} Returns a bare-bone math.js instance containing
* functions:
* - `import` to add new functions
* - `config` to change configuration
* - `on`, `off`, `once`, `emit` for events
*/
function create(factories, config) {
const configInternal = (0, _extends2.default)({}, _config.DEFAULT_CONFIG, config);
// simple test for ES5 support
if (typeof Object.create !== 'function') {
throw new Error('ES5 not supported by this JavaScript engine. ' + 'Please load the es5-shim and es5-sham library for compatibility.');
}
// create the mathjs instance
const math = emitter.mixin({
// only here for backward compatibility for legacy factory functions
isNumber: _is.isNumber,
isComplex: _is.isComplex,
isBigNumber: _is.isBigNumber,
isBigInt: _is.isBigInt,
isFraction: _is.isFraction,
isUnit: _is.isUnit,
isString: _is.isString,
isArray: _is.isArray,
isMatrix: _is.isMatrix,
isCollection: _is.isCollection,
isDenseMatrix: _is.isDenseMatrix,
isSparseMatrix: _is.isSparseMatrix,
isRange: _is.isRange,
isIndex: _is.isIndex,
isBoolean: _is.isBoolean,
isResultSet: _is.isResultSet,
isHelp: _is.isHelp,
isFunction: _is.isFunction,
isDate: _is.isDate,
isRegExp: _is.isRegExp,
isObject: _is.isObject,
isMap: _is.isMap,
isPartitionedMap: _is.isPartitionedMap,
isObjectWrappingMap: _is.isObjectWrappingMap,
isNull: _is.isNull,
isUndefined: _is.isUndefined,
isAccessorNode: _is.isAccessorNode,
isArrayNode: _is.isArrayNode,
isAssignmentNode: _is.isAssignmentNode,
isBlockNode: _is.isBlockNode,
isConditionalNode: _is.isConditionalNode,
isConstantNode: _is.isConstantNode,
isFunctionAssignmentNode: _is.isFunctionAssignmentNode,
isFunctionNode: _is.isFunctionNode,
isIndexNode: _is.isIndexNode,
isNode: _is.isNode,
isObjectNode: _is.isObjectNode,
isOperatorNode: _is.isOperatorNode,
isParenthesisNode: _is.isParenthesisNode,
isRangeNode: _is.isRangeNode,
isRelationalNode: _is.isRelationalNode,
isSymbolNode: _is.isSymbolNode,
isChain: _is.isChain
});
// load config function and apply provided config
math.config = (0, _config2.configFactory)(configInternal, math.emit);
math.expression = {
transform: {},
mathWithTransform: {
config: math.config
}
};
// cached factories and instances used by function load
const legacyFactories = [];
const legacyInstances = [];
/**
* Load a function or data type from a factory.
* If the function or data type already exists, the existing instance is
* returned.
* @param {Function} factory
* @returns {*}
*/
function load(factory) {
if ((0, _factory.isFactory)(factory)) {
return factory(math);
}
const firstProperty = factory[Object.keys(factory)[0]];
if ((0, _factory.isFactory)(firstProperty)) {
return firstProperty(math);
}
if (!(0, _object.isLegacyFactory)(factory)) {
console.warn('Factory object with properties `type`, `name`, and `factory` expected', factory);
throw new Error('Factory object with properties `type`, `name`, and `factory` expected');
}
const index = legacyFactories.indexOf(factory);
let instance;
if (index === -1) {
// doesn't yet exist
if (factory.math === true) {
// pass with math namespace
instance = factory.factory(math.type, configInternal, load, math.typed, math);
} else {
instance = factory.factory(math.type, configInternal, load, math.typed);
}
// append to the cache
legacyFactories.push(factory);
legacyInstances.push(instance);
} else {
// already existing function, return the cached instance
instance = legacyInstances[index];
}
return instance;
}
const importedFactories = {};
// load the import function
function lazyTyped() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return math.typed.apply(math.typed, args);
}
lazyTyped.isTypedFunction = _typedFunction.default.isTypedFunction;
const internalImport = (0, _import.importFactory)(lazyTyped, load, math, importedFactories);
math.import = internalImport;
// listen for changes in config, import all functions again when changed
// TODO: move this listener into the import function?
math.on('config', () => {
Object.values(importedFactories).forEach(factory => {
if (factory && factory.meta && factory.meta.recreateOnConfigChange) {
// FIXME: only re-create when the current instance is the same as was initially created
// FIXME: delete the functions/constants before importing them again?
internalImport(factory, {
override: true
});
}
});
});
// the create function exposed on the mathjs instance is bound to
// the factory functions passed before
math.create = create.bind(null, factories);
// export factory function
math.factory = _factory.factory;
// import the factory functions like createAdd as an array instead of object,
// else they will get a different naming (`createAdd` instead of `add`).
math.import(Object.values((0, _object.deepFlatten)(factories)));
math.ArgumentsError = _ArgumentsError.ArgumentsError;
math.DimensionError = _DimensionError.DimensionError;
math.IndexError = _IndexError.IndexError;
return math;
}

115
node_modules/mathjs/lib/cjs/core/function/config.js generated vendored Normal file
View File

@@ -0,0 +1,115 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.NUMBER_OPTIONS = exports.MATRIX_OPTIONS = void 0;
exports.configFactory = configFactory;
var _object = require("../../utils/object.js");
var _config2 = require("../config.js");
const MATRIX_OPTIONS = exports.MATRIX_OPTIONS = ['Matrix', 'Array']; // valid values for option matrix
const NUMBER_OPTIONS = exports.NUMBER_OPTIONS = ['number', 'BigNumber', 'Fraction']; // valid values for option number
function configFactory(config, emit) {
/**
* Set configuration options for math.js, and get current options.
* Will emit a 'config' event, with arguments (curr, prev, changes).
*
* This function is only available on a mathjs instance created using `create`.
*
* Syntax:
*
* math.config(config: Object): Object
*
* Examples:
*
*
* import { create, all } from 'mathjs'
*
* // create a mathjs instance
* const math = create(all)
*
* math.config().number // outputs 'number'
* math.evaluate('0.4') // outputs number 0.4
* math.config({number: 'Fraction'})
* math.evaluate('0.4') // outputs Fraction 2/5
*
* @param {Object} [options] Available options:
* {number} relTol
* Minimum relative difference between two
* compared values, used by all comparison functions.
* {number} absTol
* Minimum absolute difference between two
* compared values, used by all comparison functions.
* {string} matrix
* A string 'Matrix' (default) or 'Array'.
* {string} number
* A string 'number' (default), 'BigNumber', 'bigint', or 'Fraction'
* {number} precision
* The number of significant digits for BigNumbers.
* Not applicable for Numbers.
* {string} parenthesis
* How to display parentheses in LaTeX and string
* output.
* {string} randomSeed
* Random seed for seeded pseudo random number generator.
* Set to null to randomly seed.
* @return {Object} Returns the current configuration
*/
function _config(options) {
if (options) {
if (options.epsilon !== undefined) {
// this if is only for backwards compatibility, it can be removed in the future.
console.warn('Warning: The configuration option "epsilon" is deprecated. Use "relTol" and "absTol" instead.');
const optionsFix = (0, _object.clone)(options);
optionsFix.relTol = options.epsilon;
optionsFix.absTol = options.epsilon * 1e-3;
delete optionsFix.epsilon;
return _config(optionsFix);
}
const prev = (0, _object.clone)(config);
// validate some of the options
validateOption(options, 'matrix', MATRIX_OPTIONS);
validateOption(options, 'number', NUMBER_OPTIONS);
// merge options
(0, _object.deepExtend)(config, options);
const curr = (0, _object.clone)(config);
const changes = (0, _object.clone)(options);
// emit 'config' event
emit('config', curr, prev, changes);
return curr;
} else {
return (0, _object.clone)(config);
}
}
// attach the valid options to the function so they can be extended
_config.MATRIX_OPTIONS = MATRIX_OPTIONS;
_config.NUMBER_OPTIONS = NUMBER_OPTIONS;
// attach the config properties as readonly properties to the config function
Object.keys(_config2.DEFAULT_CONFIG).forEach(key => {
Object.defineProperty(_config, key, {
get: () => config[key],
enumerable: true,
configurable: true
});
});
return _config;
}
/**
* Validate an option
* @param {Object} options Object with options
* @param {string} name Name of the option to validate
* @param {Array.<string>} values Array with valid values for this option
*/
function validateOption(options, name, values) {
if (options[name] !== undefined && !values.includes(options[name])) {
// unknown value
console.warn('Warning: Unknown value "' + options[name] + '" for configuration option "' + name + '". ' + 'Available options: ' + values.map(value => JSON.stringify(value)).join(', ') + '.');
}
}

331
node_modules/mathjs/lib/cjs/core/function/import.js generated vendored Normal file
View File

@@ -0,0 +1,331 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.importFactory = importFactory;
var _is = require("../../utils/is.js");
var _factory = require("../../utils/factory.js");
var _object = require("../../utils/object.js");
var _ArgumentsError = require("../../error/ArgumentsError.js");
function importFactory(typed, load, math, importedFactories) {
/**
* Import functions from an object or a module.
*
* This function is only available on a mathjs instance created using `create`.
*
* Syntax:
*
* math.import(functions)
* math.import(functions, options)
*
* Where:
*
* - `functions: Object`
* An object with functions or factories to be imported.
* - `options: Object` An object with import options. Available options:
* - `override: boolean`
* If true, existing functions will be overwritten. False by default.
* - `silent: boolean`
* If true, the function will not throw errors on duplicates or invalid
* types. False by default.
* - `wrap: boolean`
* If true, the functions will be wrapped in a wrapper function
* which converts data types like Matrix to primitive data types like Array.
* The wrapper is needed when extending math.js with libraries which do not
* support these data type. False by default.
*
* Examples:
*
* import { create, all } from 'mathjs'
* import * as numbers from 'numbers'
*
* // create a mathjs instance
* const math = create(all)
*
* // define new functions and variables
* math.import({
* myvalue: 42,
* hello: function (name) {
* return 'hello, ' + name + '!'
* }
* })
*
* // use the imported function and variable
* math.myvalue * 2 // 84
* math.hello('user') // 'hello, user!'
*
* // import the npm module 'numbers'
* // (must be installed first with `npm install numbers`)
* math.import(numbers, {wrap: true})
*
* math.fibonacci(7) // returns 13
*
* @param {Object | Array} functions Object with functions to be imported.
* @param {Object} [options] Import options.
*/
function mathImport(functions, options) {
const num = arguments.length;
if (num !== 1 && num !== 2) {
throw new _ArgumentsError.ArgumentsError('import', num, 1, 2);
}
if (!options) {
options = {};
}
function flattenImports(flatValues, value, name) {
if (Array.isArray(value)) {
value.forEach(item => flattenImports(flatValues, item));
} else if (typeof value === 'object') {
for (const name in value) {
if ((0, _object.hasOwnProperty)(value, name)) {
flattenImports(flatValues, value[name], name);
}
}
} else if ((0, _factory.isFactory)(value) || name !== undefined) {
const flatName = (0, _factory.isFactory)(value) ? isTransformFunctionFactory(value) ? value.fn + '.transform' // TODO: this is ugly
: value.fn : name;
// we allow importing the same function twice if it points to the same implementation
if ((0, _object.hasOwnProperty)(flatValues, flatName) && flatValues[flatName] !== value && !options.silent) {
throw new Error('Cannot import "' + flatName + '" twice');
}
flatValues[flatName] = value;
} else {
if (!options.silent) {
throw new TypeError('Factory, Object, or Array expected');
}
}
}
const flatValues = {};
flattenImports(flatValues, functions);
for (const name in flatValues) {
if ((0, _object.hasOwnProperty)(flatValues, name)) {
// console.log('import', name)
const value = flatValues[name];
if ((0, _factory.isFactory)(value)) {
// we ignore name here and enforce the name of the factory
// maybe at some point we do want to allow overriding it
// in that case we can implement an option overrideFactoryNames: true
_importFactory(value, options);
} else if (isSupportedType(value)) {
_import(name, value, options);
} else {
if (!options.silent) {
throw new TypeError('Factory, Object, or Array expected');
}
}
}
}
}
/**
* Add a property to the math namespace
* @param {string} name
* @param {*} value
* @param {Object} options See import for a description of the options
* @private
*/
function _import(name, value, options) {
// TODO: refactor this function, it's to complicated and contains duplicate code
if (options.wrap && typeof value === 'function') {
// create a wrapper around the function
value = _wrap(value);
}
// turn a plain function with a typed-function signature into a typed-function
if (hasTypedFunctionSignature(value)) {
value = typed(name, {
[value.signature]: value
});
}
if (typed.isTypedFunction(math[name]) && typed.isTypedFunction(value)) {
if (options.override) {
// give the typed function the right name
value = typed(name, value.signatures);
} else {
// merge the existing and typed function
value = typed(math[name], value);
}
math[name] = value;
delete importedFactories[name];
_importTransform(name, value);
math.emit('import', name, function resolver() {
return value;
});
return;
}
if (math[name] === undefined || options.override) {
math[name] = value;
delete importedFactories[name];
_importTransform(name, value);
math.emit('import', name, function resolver() {
return value;
});
return;
}
if (!options.silent) {
throw new Error('Cannot import "' + name + '": already exists');
}
}
function _importTransform(name, value) {
if (value && typeof value.transform === 'function') {
math.expression.transform[name] = value.transform;
if (allowedInExpressions(name)) {
math.expression.mathWithTransform[name] = value.transform;
}
} else {
// remove existing transform
delete math.expression.transform[name];
if (allowedInExpressions(name)) {
math.expression.mathWithTransform[name] = value;
}
}
}
function _deleteTransform(name) {
delete math.expression.transform[name];
if (allowedInExpressions(name)) {
math.expression.mathWithTransform[name] = math[name];
} else {
delete math.expression.mathWithTransform[name];
}
}
/**
* Create a wrapper a round an function which converts the arguments
* to their primitive values (like convert a Matrix to Array)
* @param {Function} fn
* @return {Function} Returns the wrapped function
* @private
*/
function _wrap(fn) {
const wrapper = function wrapper() {
const args = [];
for (let i = 0, len = arguments.length; i < len; i++) {
const arg = arguments[i];
args[i] = arg && arg.valueOf();
}
return fn.apply(math, args);
};
if (fn.transform) {
wrapper.transform = fn.transform;
}
return wrapper;
}
/**
* Import an instance of a factory into math.js
* @param {function(scope: object)} factory
* @param {Object} options See import for a description of the options
* @param {string} [name=factory.name] Optional custom name
* @private
*/
function _importFactory(factory, options) {
let name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : factory.fn;
if (name.includes('.')) {
throw new Error('Factory name should not contain a nested path. ' + 'Name: ' + JSON.stringify(name));
}
const namespace = isTransformFunctionFactory(factory) ? math.expression.transform : math;
const existingTransform = name in math.expression.transform;
const existing = (0, _object.hasOwnProperty)(namespace, name) ? namespace[name] : undefined;
const resolver = function () {
// collect all dependencies, handle finding both functions and classes and other special cases
const dependencies = {};
factory.dependencies.map(_factory.stripOptionalNotation).forEach(dependency => {
if (dependency.includes('.')) {
throw new Error('Factory dependency should not contain a nested path. ' + 'Name: ' + JSON.stringify(dependency));
}
if (dependency === 'math') {
dependencies.math = math;
} else if (dependency === 'mathWithTransform') {
dependencies.mathWithTransform = math.expression.mathWithTransform;
} else if (dependency === 'classes') {
// special case for json reviver
dependencies.classes = math;
} else {
dependencies[dependency] = math[dependency];
}
});
const instance = /* #__PURE__ */factory(dependencies);
if (instance && typeof instance.transform === 'function') {
throw new Error('Transforms cannot be attached to factory functions. ' + 'Please create a separate function for it with export const path = "expression.transform"');
}
if (existing === undefined || options.override) {
return instance;
}
if (typed.isTypedFunction(existing) && typed.isTypedFunction(instance)) {
// merge the existing and new typed function
return typed(existing, instance);
}
if (options.silent) {
// keep existing, ignore imported function
return existing;
} else {
throw new Error('Cannot import "' + name + '": already exists');
}
};
// TODO: add unit test with non-lazy factory
if (!factory.meta || factory.meta.lazy !== false) {
(0, _object.lazy)(namespace, name, resolver);
// FIXME: remove the `if (existing &&` condition again. Can we make sure subset is loaded before subset.transform? (Name collision, and no dependencies between the two)
if (existing && existingTransform) {
_deleteTransform(name);
} else {
if (isTransformFunctionFactory(factory) || factoryAllowedInExpressions(factory)) {
(0, _object.lazy)(math.expression.mathWithTransform, name, () => namespace[name]);
}
}
} else {
namespace[name] = resolver();
// FIXME: remove the `if (existing &&` condition again. Can we make sure subset is loaded before subset.transform? (Name collision, and no dependencies between the two)
if (existing && existingTransform) {
_deleteTransform(name);
} else {
if (isTransformFunctionFactory(factory) || factoryAllowedInExpressions(factory)) {
(0, _object.lazy)(math.expression.mathWithTransform, name, () => namespace[name]);
}
}
}
// TODO: improve factories, store a list with imports instead which can be re-played
importedFactories[name] = factory;
math.emit('import', name, resolver);
}
/**
* Check whether given object is a type which can be imported
* @param {Function | number | string | boolean | null | Unit | Complex} object
* @return {boolean}
* @private
*/
function isSupportedType(object) {
return typeof object === 'function' || typeof object === 'number' || typeof object === 'string' || typeof object === 'boolean' || object === null || (0, _is.isUnit)(object) || (0, _is.isComplex)(object) || (0, _is.isBigNumber)(object) || (0, _is.isFraction)(object) || (0, _is.isMatrix)(object) || Array.isArray(object);
}
function hasTypedFunctionSignature(fn) {
return typeof fn === 'function' && typeof fn.signature === 'string';
}
function allowedInExpressions(name) {
return !(0, _object.hasOwnProperty)(unsafe, name);
}
function factoryAllowedInExpressions(factory) {
return !factory.fn.includes('.') &&
// FIXME: make checking on path redundant, check on meta data instead
!(0, _object.hasOwnProperty)(unsafe, factory.fn) && (!factory.meta || !factory.meta.isClass);
}
function isTransformFunctionFactory(factory) {
return factory !== undefined && factory.meta !== undefined && factory.meta.isTransformFunction === true || false;
}
// namespaces and functions not available in the parser for safety reasons
const unsafe = {
expression: true,
type: true,
docs: true,
error: true,
json: true,
chain: true // chain method not supported. Note that there is a unit chain too.
};
return mathImport;
}

461
node_modules/mathjs/lib/cjs/core/function/typed.js generated vendored Normal file

File diff suppressed because one or more lines are too long