first commit

This commit is contained in:
jefferyzhao
2025-07-31 17:44:12 +08:00
commit b9bdc8598b
42390 changed files with 4467935 additions and 0 deletions

BIN
node_modules/echarts/build/.DS_Store generated vendored Normal file

Binary file not shown.

77
node_modules/echarts/build/.jshintrc generated vendored Normal file
View File

@ -0,0 +1,77 @@
{
"bitwise": false,
"camelcase": true,
"curly": true,
"eqeqeq": false,
"forin": false,
"immed": true,
"latedef": false,
"newcap": true,
"noarg": false,
"noempty": true,
"nonew": true,
"plusplus": false,
"quotmark": "single",
"regexp": false,
"undef": true,
"unused": "vars",
"strict": false,
"trailing": false,
"maxparams": 20,
"maxdepth": 6,
"maxlen": 200,
"asi": false,
"boss": false,
"debug": false,
"eqnull": true,
"esversion": 6,
"evil": true,
"expr": true,
"funcscope": false,
"globalstrict": false,
"iterator": false,
"lastsemic": false,
"laxbreak": true,
"laxcomma": false,
"loopfunc": false,
"multistr": false,
"onecase": false,
"proto": false,
"regexdash": false,
"scripturl": false,
"smarttabs": false,
"shadow": true,
"sub": true,
"supernew": false,
"validthis": true,
"browser": true,
"couch": false,
"devel": true,
"dojo": false,
"jquery": true,
"mootools": false,
"node": false,
"nonstandard": false,
"prototypejs": false,
"rhino": false,
"wsh": false,
"nomen": false,
"onevar": false,
"passfail": false,
"white": false,
"varstmt": true,
"predef": [
"__DEV__",
"global",
"require",
"exports",
"Buffer",
"module",
"__dirname"
]
}

183
node_modules/echarts/build/addHeader.js generated vendored Normal file
View File

@ -0,0 +1,183 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
const fs = require('fs');
const preamble = require('./preamble');
const pathTool = require('path');
const {color} = require('zrender/build/helper');
// In the `.headerignore`, each line is a pattern in RegExp.
// all relative path (based on the echarts base directory) is tested.
// The pattern should match the relative path completely.
const excludesPath = pathTool.join(__dirname, '../.headerignore');
const ecBasePath = pathTool.join(__dirname, '../');
const isVerbose = process.argv[2] === '--verbose';
// const lists = [
// '../src/**/*.js',
// '../build/*.js',
// '../benchmark/src/*.js',
// '../benchmark/src/gulpfile.js',
// '../extension-src/**/*.js',
// '../extension/**/*.js',
// '../map/js/**/*.js',
// '../test/build/**/*.js',
// '../test/node/**/*.js',
// '../test/ut/core/*.js',
// '../test/ut/spe/*.js',
// '../test/ut/ut.js',
// '../test/*.js',
// '../theme/*.js',
// '../theme/tool/**/*.js',
// '../echarts.all.js',
// '../echarts.blank.js',
// '../echarts.common.js',
// '../echarts.simple.js',
// '../index.js',
// '../index.common.js',
// '../index.simple.js'
// ];
function run() {
const updatedFiles = [];
const passFiles = [];
const pendingFiles = [];
eachFile(function (absolutePath, fileExt) {
const fileStr = fs.readFileSync(absolutePath, 'utf-8');
const existLicense = preamble.extractLicense(fileStr, fileExt);
if (existLicense) {
passFiles.push(absolutePath);
return;
}
// Conside binary files, only add for files with known ext.
if (!preamble.hasPreamble(fileExt)) {
pendingFiles.push(absolutePath);
return;
}
fs.writeFileSync(absolutePath, preamble.addPreamble(fileStr, fileExt), 'utf-8');
updatedFiles.push(absolutePath);
});
console.log('\n');
console.log('----------------------------');
console.log(' Files that exists license: ');
console.log('----------------------------');
if (passFiles.length) {
if (isVerbose) {
passFiles.forEach(function (path) {
console.log(color('fgGreen', 'dim')(path));
});
}
else {
console.log(color('fgGreen', 'dim')(passFiles.length + ' files. (use argument "--verbose" see details)'));
}
}
else {
console.log('Nothing.');
}
console.log('\n');
console.log('--------------------');
console.log(' License added for: ');
console.log('--------------------');
if (updatedFiles.length) {
updatedFiles.forEach(function (path) {
console.log(color('fgGreen', 'bright')(path));
});
}
else {
console.log('Nothing.');
}
console.log('\n');
console.log('----------------');
console.log(' Pending files: ');
console.log('----------------');
if (pendingFiles.length) {
pendingFiles.forEach(function (path) {
console.log(color('fgRed', 'dim')(path));
});
}
else {
console.log('Nothing.');
}
console.log('\nDone.');
}
function eachFile(visit) {
const excludePatterns = [];
const extReg = /\.([a-zA-Z0-9_-]+)$/;
prepareExcludePatterns();
travel('./');
function travel(relativePath) {
if (isExclude(relativePath)) {
return;
}
const absolutePath = pathTool.join(ecBasePath, relativePath);
const stat = fs.statSync(absolutePath);
if (stat.isFile()) {
visit(absolutePath, getExt(absolutePath));
}
else if (stat.isDirectory()) {
fs.readdirSync(relativePath).forEach(function (file) {
travel(pathTool.join(relativePath, file));
});
}
}
function prepareExcludePatterns() {
const content = fs.readFileSync(excludesPath, {encoding: 'utf-8'});
content.replace(/\r/g, '\n').split('\n').forEach(function (line) {
line = line.trim();
if (line && line.charAt(0) !== '#') {
excludePatterns.push(new RegExp(line));
}
});
}
function isExclude(relativePath) {
for (let i = 0; i < excludePatterns.length; i++) {
if (excludePatterns[i].test(relativePath)) {
return true;
}
}
}
function getExt(path) {
if (path) {
const mathResult = path.match(extReg);
return mathResult && mathResult[1];
}
}
}
run();

182
node_modules/echarts/build/amd2common.js generated vendored Normal file
View File

@ -0,0 +1,182 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var glob = require('glob');
var fsExtra = require('fs-extra');
var esprima = require('esprima');
function run(cb) {
glob('**/*.js', {
cwd: __dirname + '/../src/'
}, function (err, files) {
files.forEach(function (filePath) {
var code = parse(fsExtra.readFileSync(
__dirname + '/../src/' + filePath, 'utf-8'));
code = code.replace(/require\(([\'"])zrender\//g, 'require($1zrender/lib/');
fsExtra.outputFileSync(
__dirname + '/../lib/' + filePath,
code, 'utf-8');
});
cb && cb();
});
}
if (require.main === module) {
run();
}
else {
module.exports = run;
}
var MAGIC_DEPS = {
'exports': true,
'module': true,
'require': true
};
var SIMPLIFIED_CJS = ['require', 'exports', 'module'];
// Convert AMD-style JavaScript string into node.js compatible module
function parse(raw) {
var output = '';
var ast = esprima.parse(raw, {
range: true,
raw: true
});
var defines = ast.body.filter(isDefine);
if (defines.length > 1) {
throw new Error('Each file can have only a single define call. Found "' + defines.length + '"');
}
else if (!defines.length) {
return raw;
}
var def = defines[0];
var args = def.expression['arguments'];
var factory = getFactory(args);
var useStrict = getUseStrict(factory);
// do replacements in-place to avoid modifying the code more than needed
if (useStrict) {
output += useStrict.expression.raw + ';\n';
}
output += raw.substring(0, def.range[0]); // anything before define
output += getRequires(args, factory); // add requires
output += getBody(raw, factory.body, useStrict); // module body
output += raw.substring(def.range[1], raw.length); // anything after define
return output;
}
function getRequires(args, factory) {
var requires = [];
var deps = getDependenciesNames(args);
var params = factory.params.map(function (param, i) {
return {
name: param.name,
// simplified cjs doesn't have deps
dep: (deps.length) ? deps[i] : SIMPLIFIED_CJS[i]
};
});
params.forEach(function (param) {
if (MAGIC_DEPS[param.dep] && !MAGIC_DEPS[param.name]) {
// if user remaped magic dependency we declare a var
requires.push('var ' + param.name + ' = ' + param.dep + ';');
}
else if (param.dep && !MAGIC_DEPS[param.dep]) {
// only do require for params that have a matching dependency also
// skip "magic" dependencies
requires.push('var ' + param.name + ' = require(\'' + param.dep + '\');');
}
});
return requires.join('\n');
}
function getDependenciesNames(args) {
var deps = [];
var arr = args.filter(function (arg) {
return arg.type === 'ArrayExpression';
})[0];
if (arr) {
deps = arr.elements.map(function (el) {
return el.value;
});
}
return deps;
}
function isDefine(node) {
return node.type === 'ExpressionStatement'
&& node.expression.type === 'CallExpression'
&& node.expression.callee.type === 'Identifier'
&& node.expression.callee.name === 'define';
}
function getFactory(args) {
return args.filter(function (arg) {
return arg.type === 'FunctionExpression';
})[0];
}
function getBody(raw, factoryBody, useStrict) {
var returnStatement = factoryBody.body.filter(function (node) {
return node.type === 'ReturnStatement';
})[0];
var body = '';
var bodyStart = useStrict ? useStrict.expression.range[1] + 1 : factoryBody.range[0] + 1;
if (returnStatement) {
body += raw.substring(bodyStart, returnStatement.range[0]);
// "return ".length === 7 so we add "6" to returnStatement start
body += 'module.exports =' + raw.substring(returnStatement.range[0] + 6, factoryBody.range[1] - 1);
}
else {
// if using exports or module.exports or just a private module we
// simply return the factoryBody content
body = raw.substring(bodyStart, factoryBody.range[1] - 1);
}
return body;
}
function getUseStrict(factory) {
return factory.body.body.filter(isUseStrict)[0];
}
function isUseStrict(node) {
return node.type === 'ExpressionStatement'
&& node.expression.type === 'Literal'
&& node.expression.value === 'use strict';
}

255
node_modules/echarts/build/build.js generated vendored Normal file
View File

@ -0,0 +1,255 @@
#!/usr/bin/env node
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
const fsExtra = require('fs-extra');
const fs = require('fs');
const {resolve} = require('path');
const config = require('./config.js');
const commander = require('commander');
const {build, watch, color} = require('zrender/build/helper');
const ecLangPlugin = require('./rollup-plugin-ec-lang');
const prePublish = require('./pre-publish');
const recheckDEV = require('zrender/build/babel-plugin-transform-remove-dev').recheckDEV;
function run() {
/**
* Tips for `commander`:
* (1) If arg xxx not specified, `commander.xxx` is undefined.
* Otherwise:
* If '-x, --xxx', `commander.xxx` can only be true/false, even if '--xxx yyy' input.
* If '-x, --xxx <some>', the 'some' string is required, or otherwise error will be thrown.
* If '-x, --xxx [some]', the 'some' string is optional, that is, `commander.xxx` can be boolean or string.
* (2) `node ./build/build.js --help` will print helper info and exit.
*/
let descIndent = ' ';
let egIndent = ' ';
commander
.usage('[options]')
.description([
'Build echarts and generate result files in directory `echarts/dist`.',
'',
' For example:',
'',
egIndent + 'node build/build.js --release'
+ '\n' + descIndent + '# Build all to `dist` folder.',
egIndent + 'node build/build.js --prepublish'
+ '\n' + descIndent + '# Only prepublish.',
egIndent + 'node build/build.js --removedev'
+ '\n' + descIndent + '# Remove __DEV__ code. If --min, __DEV__ always be removed.',
egIndent + 'node build/build.js --type ""'
+ '\n' + descIndent + '# Only generate `dist/echarts.js`.',
egIndent + 'node build/build.js --type common --min'
+ '\n' + descIndent + '# Only generate `dist/echarts.common.min.js`.',
egIndent + 'node build/build.js --type simple --min --lang en'
+ '\n' + descIndent + '# Only generate `dist/echarts-en.simple.min.js`.',
egIndent + 'node build/build.js --lang "my/lang.js" -i "my/index.js" -o "my/bundle.js"'
+ '\n' + descIndent + '# Take `<cwd>/my/index.js` as input and generate `<cwd>/my/bundle.js`,'
+ '\n' + descIndent + 'where `<cwd>/my/lang.js` is used as language file.',
].join('\n'))
.option(
'-w, --watch', [
'Watch modifications of files and auto-compile to dist file. For example,',
descIndent + '`echarts/dist/echarts.js`.'
].join('\n'))
.option(
'--lang <language file path or shortcut>', [
'Use the specified file instead of `echarts/src/lang.js`. For example:',
descIndent + '`--lang en` will use `echarts/src/langEN.js`.',
descIndent + '`--lang my/langDE.js` will use `<cwd>/my/langDE.js`. -o must be specified in this case.',
descIndent + '`--lang /my/indexSW.js` will use `/my/indexSW.js`. -o must be specified in this case.'
].join('\n'))
.option(
'--release',
'Build all for release'
)
.option(
'--prepublish',
'Build all for release'
)
.option(
'--removedev',
'Remove __DEV__ code. If --min, __DEV__ always be removed.'
)
.option(
'--min',
'Whether to compress the output file, and remove error-log-print code.'
)
.option(
'--type <type name>', [
'Can be "simple" or "common" or "" (default). For example,',
descIndent + '`--type ""` or `--type "common"`.'
].join('\n'))
.option(
'--sourcemap',
'Whether output sourcemap.'
)
.option(
'--format <format>',
'The format of output bundle. Can be "umd", "amd", "iife", "cjs", "es".'
)
.option(
'-i, --input <input file path>',
'If input file path is specified, output file path must be specified too.'
)
.option(
'-o, --output <output file path>',
'If output file path is specified, input file path must be specified too.'
)
.parse(process.argv);
let isWatch = !!commander.watch;
let isRelease = !!commander.release;
let isPrePublish = !!commander.prepublish;
let opt = {
lang: commander.lang,
min: commander.min,
type: commander.type || '',
input: commander.input,
output: commander.output,
format: commander.format,
sourcemap: commander.sourcemap,
removeDev: commander.removedev,
addBundleVersion: isWatch
};
validateIO(opt.input, opt.output);
validateLang(opt.lang, opt.output);
normalizeParams(opt);
// Clear `echarts/dist`
if (isRelease) {
fsExtra.removeSync(getPath('./dist'));
}
if (isWatch) {
watch(config.createECharts(opt));
}
else if (isPrePublish) {
prePublish();
}
else if (isRelease) {
let configs = [];
let configForCheck;
[
{min: false},
{min: true},
{min: false, lang: 'en'},
{min: true, lang: 'en'}
].forEach(function (opt) {
['', 'simple', 'common'].forEach(function (type) {
let singleOpt = Object.assign({type}, opt);
normalizeParams(singleOpt);
let singleConfig = config.createECharts(singleOpt);
configs.push(singleConfig);
if (singleOpt.min && singleOpt.type === '') {
configForCheck = singleConfig;
}
});
});
configs.push(
config.createBMap(false),
config.createBMap(true),
config.createDataTool(false),
config.createDataTool(true)
);
build(configs)
.then(function () {
checkCode(configForCheck);
prePublish();
}).catch(handleBuildError);
}
else {
let cfg = config.createECharts(opt);
build([cfg])
.then(function () {
if (opt.removeDev) {
checkCode(cfg);
}
})
.catch(handleBuildError);
}
}
function normalizeParams(opt) {
if (opt.sourcemap == null) {
opt.sourcemap = !(opt.min || opt.type);
}
if (opt.removeDev == null) {
opt.removeDev = !!opt.min;
}
}
function handleBuildError(err) {
console.log(err);
}
function checkCode(singleConfig) {
// Make sure __DEV__ is eliminated.
let code = fs.readFileSync(singleConfig.output.file, {encoding: 'utf-8'});
if (!code) {
throw new Error(`${singleConfig.output.file} is empty`);
}
recheckDEV(code);
console.log(color('fgGreen', 'dim')('Check code: correct.'));
}
function validateIO(input, output) {
if ((input != null && output == null)
|| (input == null && output != null)
) {
throw new Error('`input` and `output` must be both set.');
}
}
function validateLang(lang, output) {
if (!lang) {
return;
}
let langInfo = ecLangPlugin.getLangFileInfo(lang);
if (langInfo.isOuter && !output) {
throw new Error('`-o` or `--output` must be specified if using a file path in `--lang`.');
}
if (!langInfo.absolutePath || !fs.statSync(langInfo.absolutePath).isFile()) {
throw new Error(`File ${langInfo.absolutePath} does not exist yet. Contribution is welcome!`);
}
}
/**
* @param {string} relativePath Based on echarts directory.
* @return {string} Absolute path.
*/
function getPath(relativePath) {
return resolve(__dirname, '../', relativePath);
}
run();

178
node_modules/echarts/build/config.js generated vendored Normal file
View File

@ -0,0 +1,178 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
const nodeResolvePlugin = require('rollup-plugin-node-resolve');
const uglifyPlugin = require('rollup-plugin-uglify');
const ecRemoveDevPlugin = require('./rollup-plugin-ec-remove-dev');
const ecLangPlugin = require('./rollup-plugin-ec-lang');
const {resolve} = require('path');
const preamble = require('./preamble');
function getPathBasedOnECharts(path) {
return resolve(__dirname, '../', path);
}
function getPlugins({min, lang, sourcemap, removeDev, addBundleVersion}) {
let plugins = [];
removeDev && plugins.push(
ecRemoveDevPlugin({sourcemap})
);
lang && plugins.push(
ecLangPlugin({lang})
);
plugins.push(
nodeResolvePlugin()
);
addBundleVersion && plugins.push({
outro: function () {
return 'exports.bundleVersion = \'' + (+new Date()) + '\';';
}
});
min && plugins.push(uglifyPlugin({
compress: {
// Eliminate __DEV__ code.
// Currently, in uglify:
// `var vx; if(vx) {...}` can not be removed.
// `if (__DEV__) {...}` can be removed if `__DEV__` is defined as `false` in `global_defs`.
// 'global_defs': {
// __DEV__: false
// },
'dead_code': true
},
output: {
preamble: preamble.js
}
}));
return plugins;
}
/**
* @param {Object} [opt]
* @param {string} [opt.type=''] '' or 'simple' or 'common'
* @param {boolean} [opt.min=false]
* @param {string} [opt.lang=undefined] null/undefined/'' or 'en' or 'fi' or a file path.
* @param {string} [opt.input=undefined] If set, `opt.output` is required too, and `opt.type` is ignored.
* @param {string} [opt.output=undefined] If set, `opt.input` is required too, and `opt.type` is ignored.
* @param {boolean} [opt.sourcemap] If set, `opt.input` is required too, and `opt.type` is ignored.
* @param {boolean} [opt.removeDev]
* @param {string} [opt.format='umd'] If set, `opt.input` is required too, and `opt.type` is ignored.
* @param {boolean} [opt.addBundleVersion=false] Only for debug in watch, prompt that the two build is different.
*/
exports.createECharts = function (opt = {}) {
let min = opt.min;
let srcType = opt.type ? '.' + opt.type : '.all';
let postfixType = opt.type ? '.' + opt.type : '';
let postfixMin = min ? '.min' : '';
let postfixLang = opt.lang ? '-' + opt.lang.toLowerCase() : '';
let input = opt.input;
let output = opt.output;
let sourcemap = opt.sourcemap;
let format = opt.format || 'umd';
if (input != null || output != null) {
// Based on process.cwd();
input = resolve(input);
output = resolve(output);
}
else {
input = getPathBasedOnECharts(`./echarts${srcType}.js`);
output = getPathBasedOnECharts(`dist/echarts${postfixLang}${postfixType}${postfixMin}.js`);
}
return {
plugins: getPlugins(opt),
input: input,
legacy: true, // Support IE8-
output: {
name: 'echarts',
format: format,
sourcemap: sourcemap,
legacy: true, // Must be declared both in inputOptions and outputOptions.
file: output
},
watch: {
include: [
getPathBasedOnECharts('./src/**'),
getPathBasedOnECharts('./echarts*.js'),
getPathBasedOnECharts('../zrender/src/**')
]
}
};
};
/**
* @param {boolean} [min=false]
*/
exports.createBMap = function (min) {
let postfix = min ? '.min' : '';
return {
plugins: getPlugins({min}),
input: getPathBasedOnECharts(`./extension-src/bmap/bmap.js`),
legacy: true, // Support IE8-
external: ['echarts'],
output: {
name: 'bmap',
format: 'umd',
sourcemap: !min,
legacy: true, // Must be declared both in inputOptions and outputOptions.
globals: {
// For UMD `global.echarts`
echarts: 'echarts'
},
file: getPathBasedOnECharts(`dist/extension/bmap${postfix}.js`)
},
watch: {
include: [getPathBasedOnECharts('./extension-src/bmap/**')]
}
};
};
/**
* @param {boolean} [min=false]
*/
exports.createDataTool = function (min) {
let postfix = min ? '.min' : '';
return {
plugins: getPlugins({min}),
input: getPathBasedOnECharts(`./extension-src/dataTool/index.js`),
legacy: true, // Support IE8-
external: ['echarts'],
output: {
name: 'dataTool',
format: 'umd',
sourcemap: !min,
legacy: true, // Must be declared both in inputOptions and outputOptions.
globals: {
// For UMD `global.echarts`
echarts: 'echarts'
},
file: getPathBasedOnECharts(`dist/extension/dataTool${postfix}.js`)
},
watch: {
include: [getPathBasedOnECharts('./extension-src/dataTool/**')]
}
};
};

184
node_modules/echarts/build/mangleString.js generated vendored Normal file
View File

@ -0,0 +1,184 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var esprima = require('esprima');
var escodegen = require('escodegen');
var estraverse = require('estraverse');
var SYNTAX = estraverse.Syntax;
var STR_MIN_LENGTH = 5;
var STR_MIN_DIST = 1000;
var STR_MIN_COUNT = 2;
function createDeclaration(declarations) {
return {
type: SYNTAX.VariableDeclaration,
declarations: declarations,
kind: 'var'
};
}
function createDeclarator(id, init) {
return {
type: SYNTAX.VariableDeclarator,
id: {
type: SYNTAX.Identifier,
name: id
},
init: {
type: SYNTAX.Literal,
value: init
}
};
}
function base54Digits() {
return 'etnrisouaflchpdvmgybwESxTNCkLAOM_DPHBjFIqRUzWXV$JKQGYZ0516372984';
}
var base54 = (function(){
var DIGITS = base54Digits();
return function(num) {
var ret = '';
var base = 54;
do {
ret += DIGITS.charAt(num % base);
num = Math.floor(num / base);
base = 64;
} while (num > 0);
return ret;
};
})();
function mangleString(source) {
var ast = esprima.parse(source, {
loc: true
});
var stringVariables = {};
var stringRelaceCount = 0;
estraverse.traverse(ast, {
enter: function (node, parent) {
if (node.type === SYNTAX.Literal
&& typeof node.value === 'string'
) {
// Ignore if string is the key of property
if (parent.type === SYNTAX.Property) {
return;
}
var value = node.value;
if (value.length > STR_MIN_LENGTH) {
if (!stringVariables[value]) {
stringVariables[value] = {
count: 0,
lastLoc: node.loc.start.line,
name: '__echartsString__' + base54(stringRelaceCount++)
};
}
var diff = node.loc.start.line - stringVariables[value].lastLoc;
// GZIP ?
if (diff >= STR_MIN_DIST) {
stringVariables[value].lastLoc = node.loc.start.line;
stringVariables[value].count++;
}
}
}
if (node.type === SYNTAX.MemberExpression && !node.computed) {
if (node.property.type === SYNTAX.Identifier) {
var value = node.property.name;
if (value.length > STR_MIN_LENGTH) {
if (!stringVariables[value]) {
stringVariables[value] = {
count: 0,
lastLoc: node.loc.start.line,
name: '__echartsString__' + base54(stringRelaceCount++)
};
}
var diff = node.loc.start.line - stringVariables[value].lastLoc;
if (diff >= STR_MIN_DIST) {
stringVariables[value].lastLoc = node.loc.start.line;
stringVariables[value].count++;
}
}
}
}
}
});
estraverse.replace(ast, {
enter: function (node, parent) {
if ((node.type === SYNTAX.Literal
&& typeof node.value === 'string')
) {
// Ignore if string is the key of property
if (parent.type === SYNTAX.Property) {
return;
}
var str = node.value;
if (stringVariables[str] && stringVariables[str].count > STR_MIN_COUNT) {
return {
type: SYNTAX.Identifier,
name: stringVariables[str].name
};
}
}
if (node.type === SYNTAX.MemberExpression && !node.computed) {
if (node.property.type === SYNTAX.Identifier) {
var str = node.property.name;
if (stringVariables[str] && stringVariables[str].count > STR_MIN_COUNT) {
return {
type: SYNTAX.MemberExpression,
object: node.object,
property: {
type: SYNTAX.Identifier,
name: stringVariables[str].name
},
computed: true
};
}
}
}
}
});
// Add variables in the top
for (var str in stringVariables) {
// Used more than once
if (stringVariables[str].count > STR_MIN_COUNT) {
ast.body.unshift(createDeclaration([
createDeclarator(stringVariables[str].name, str)
]));
}
}
return escodegen.generate(
ast,
{
format: {escapeless: true},
comment: true
}
);
}
exports = module.exports = mangleString;

59
node_modules/echarts/build/optimize.js generated vendored Normal file
View File

@ -0,0 +1,59 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var UglifyJS = require('uglify-js');
var fs = require('fs');
var etpl = require('etpl');
var argv = require('optimist').argv;
etpl.config({
commandOpen: '/**',
commandClose: '*/'
});
var mode = argv.m || 'all';
var configPath = mode === 'all' ? 'config/echarts.js' : 'config/echarts.' + mode + '.js';
var outPath = mode === 'all' ? '../dist/echarts.js' : '../dist/echarts.' + mode + '.js';
var config = eval('(' + fs.readFileSync(configPath, 'utf-8') + ')');
var mainCode = fs.readFileSync(outPath, 'utf-8');
var startCode = fs.readFileSync('wrap/start.js', 'utf-8');
var nutCode = fs.readFileSync('wrap/nut.js', 'utf-8');
var endCode = fs.readFileSync('wrap/end.js', 'utf-8');
endCode = etpl.compile(endCode)({
parts: config.include
});
// FIXME
var sourceCode = [startCode, nutCode, require('./mangleString')(mainCode), endCode].join('\n');
var ast = UglifyJS.parse(sourceCode);
/* jshint camelcase: false */
// compressor needs figure_out_scope too
ast.figure_out_scope();
ast = ast.transform(UglifyJS.Compressor( {} ));
// need to figure out scope again so mangler works optimally
ast.figure_out_scope();
ast.compute_char_frequency();
ast.mangle_names();
fs.writeFileSync(outPath, [startCode, nutCode, mainCode, endCode].join('\n'), 'utf-8');
fs.writeFileSync(outPath.replace('.js', '.min.js'), ast.print_to_string(), 'utf-8');

97
node_modules/echarts/build/pre-publish.js generated vendored Normal file
View File

@ -0,0 +1,97 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Compatible with prevoius folder structure: `echarts/lib` exists in `node_modules`
* (1) Build all files to CommonJS to `echarts/lib`.
* (2) Remove __DEV__.
* (3) Mount `echarts/src/export.js` to `echarts/lib/echarts.js`.
*/
const path = require('path');
const fsExtra = require('fs-extra');
const {color, travelSrcDir, prePulishSrc} = require('zrender/build/helper');
const ecDir = path.resolve(__dirname, '..');
const srcDir = path.resolve(__dirname, '../src');
const extensionSrcDir = path.resolve(__dirname, '../extension-src');
const extensionDir = path.resolve(__dirname, '../extension');
const libDir = path.resolve(__dirname, '../lib');
const preamble = require('./preamble');
module.exports = function () {
fsExtra.removeSync(libDir);
fsExtra.ensureDirSync(libDir);
travelSrcDir(srcDir, ({fileName, relativePath, absolutePath}) => {
prePulishSrc({
inputPath: absolutePath,
outputPath: path.resolve(libDir, relativePath, fileName),
transform: transform,
preamble: preamble.js
});
});
travelSrcDir(extensionSrcDir, ({fileName, relativePath, absolutePath}) => {
prePulishSrc({
inputPath: absolutePath,
outputPath: path.resolve(extensionDir, relativePath, fileName),
transform: transform,
preamble: preamble.js
});
});
prePulishSrc({
inputPath: path.resolve(ecDir, 'echarts.all.js'),
outputPath: path.resolve(ecDir, 'index.js'),
preamble: preamble.js
});
prePulishSrc({
inputPath: path.resolve(ecDir, 'echarts.common.js'),
outputPath: path.resolve(ecDir, 'index.common.js'),
preamble: preamble.js
});
prePulishSrc({
inputPath: path.resolve(ecDir, 'echarts.simple.js'),
outputPath: path.resolve(ecDir, 'index.simple.js'),
preamble: preamble.js
});
function transform({code, inputPath, outputPath}) {
if (inputPath === path.resolve(ecDir, 'src/echarts.js')) {
// Using `echarts/echarts.blank.js` to overwrite `echarts/lib/echarts.js`
// for including exports API.
code += `
var ___ec_export = require("./export");
(function () {
for (var key in ___ec_export) {
if (___ec_export.hasOwnProperty(key)) {
exports[key] = ___ec_export[key];
}
}
})();`;
}
return code;
}
console.log(color('fgGreen', 'bright')('All done.'));
};

215
node_modules/echarts/build/preamble.js generated vendored Normal file
View File

@ -0,0 +1,215 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
const cStyleComment = `
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
`;
const hashComment = `
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
`;
const mlComment = `
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
`;
function hasPreamble(fileExt) {
return fileExt && preambleMap[fileExt];
}
function addPreamble(fileStr, fileExt) {
if (fileStr && fileExt) {
const addFn = addFns[fileExt];
const headStr = preambleMap[fileExt];
return addFn && headStr && addFn(headStr, fileStr);
}
}
const addFns = {
js: function (headStr, fileStr) {
return headStr + fileStr;
},
css: function (headStr, fileStr) {
return headStr + fileStr;
},
java: function (headStr, fileStr) {
return headStr + fileStr;
},
sh: function (headStr, fileStr) {
// Git diff enables manual check.
if (/^#\!/.test(fileStr)) {
const lines = fileStr.split('\n');
lines.splice(1, 0, headStr);
return lines.join('\n');
}
else {
return headStr + fileStr;
}
},
html: function (headStr, fileStr) {
// Git diff enables manual check.
let resultStr = fileStr.replace(/^\s*<!DOCTYPE\s[^<>]+>/i, '$&' + headStr);
// If no doctype
if (resultStr.length === fileStr.length) {
resultStr = headStr + fileStr;
}
return resultStr;
},
xml: xmlAddFn,
xsl: xmlAddFn
};
function xmlAddFn(headStr, fileStr) {
// Git diff enables manual check.
let resultStr = fileStr.replace(/^\s*<\?xml\s[^<>]+\?>/i, '$&' + headStr);
// If no <?xml version='1.0' ?>
if (resultStr.length === fileStr.length) {
resultStr = headStr + fileStr;
}
return resultStr;
}
const preambleMap = {
js: cStyleComment,
css: cStyleComment,
java: cStyleComment,
sh: hashComment,
html: mlComment,
xml: mlComment,
xsl: mlComment
};
const licenseReg = [
{name: 'Apache', reg: /apache (license|commons)/i},
{name: 'BSD', reg: /BSD/},
{name: 'LGPL', reg: /LGPL/},
{name: 'GPL', reg: /GPL/},
{name: 'Mozilla', reg: /mozilla public/i},
{name: 'MIT', reg: /mit license/i},
{name: 'BSD-d3', reg: /Copyright\s+\(c\)\s+2010-2015,\s+Michael\s+Bostock/i}
];
function extractLicense(fileStr, fileExt) {
let commentText = extractComment(fileStr.trim(), fileExt);
if (!commentText) {
return;
}
for (let i = 0; i < licenseReg.length; i++) {
if (licenseReg[i].reg.test(commentText)) {
return licenseReg[i].name;
}
}
}
const cStyleCommentReg = /\/\*[\S\s]*?\*\//;
const hashCommentReg = /^\s*#.*$/gm;
const mlCommentReg = /<\!\-\-[\S\s]*?\-\->/;
const commentReg = {
js: cStyleCommentReg,
css: cStyleCommentReg,
java: cStyleCommentReg,
sh: hashCommentReg,
html: mlCommentReg,
xml: mlCommentReg,
xsl: mlCommentReg
};
function extractComment(str, fileExt) {
const reg = commentReg[fileExt];
if (!fileExt || !reg || !str) {
return;
}
reg.lastIndex = 0;
if (fileExt === 'sh') {
let result = str.match(reg);
return result && result.join('\n');
}
else {
let result = reg.exec(str);
return result && result[0];
}
}
module.exports = Object.assign({
extractLicense,
hasPreamble,
addPreamble
}, preambleMap);

80
node_modules/echarts/build/rollup-plugin-ec-lang.js generated vendored Normal file
View File

@ -0,0 +1,80 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Find language definations.
*
* Usage:
*
* import ecLangPlugin from 'echarts/build/rollup-plugin-ec-lang';
* let rollupConfig = {
* plugins: [
* ecLangPlugin({lang: 'en'}),
* ...
* ]
* };
*/
const {resolve} = require('path');
const {readFileSync} = require('fs');
/**
* @param {Object} [opt]
* @param {string} [opt.lang=null] null/undefined/'' or 'en' or 'fi' or a file path.
*/
function getPlugin(opt) {
let lang = opt && opt.lang || '';
return {
load: function (absolutePath) {
if (/\/src\/lang\.js$/.test(absolutePath)) {
let langPath = getLangFileInfo(lang).absolutePath;
if (langPath) {
absolutePath = langPath;
}
}
return readFileSync(absolutePath, 'utf-8');
}
};
}
/**
* @param {string} lang null/undefined/'' or 'en' or 'fi' or a file path.
* @return {Object} {isOuter, absolutePath}
*/
let getLangFileInfo = getPlugin.getLangFileInfo = function (lang) {
let absolutePath;
let isOuter = false;
if (lang) {
if (/^[a-zA-Z]{2}$/.test(lang)) {
absolutePath = resolve(__dirname, '../', 'src/lang' + lang.toUpperCase() + '.js');
}
else {
isOuter = true;
// `lang` is an absolute path or a relative path based on process.cwd().
absolutePath = resolve(lang);
}
}
return {isOuter, absolutePath};
};
module.exports = getPlugin;

View File

@ -0,0 +1,54 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Remove the code of `if (__DEV__) { ... }`.
*
* Usage:
*
* import ecRemoveDevPlugin from 'echats/build/rollup-plugin-ec-remove-dev';
* let rollupConfig = {
* plugins: [
* ecRemoveDevPlugin(),
* ...
* ]
* };
*/
const babel = require('@babel/core');
const removeDEVPlugin = require('zrender/build/babel-plugin-transform-remove-dev');
/**
* @param {Object} [opt]
* @param {Object} [opt.sourcemap]
*/
module.exports = function ({sourcemap} = {}) {
return {
transform: function (sourceCode) {
let {code, map} = babel.transform(sourceCode, {
plugins: [removeDEVPlugin],
sourceMaps: sourcemap
});
return {code, map};
}
};
};