This is an automated email from the ASF dual-hosted git repository.

ovilia pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/echarts-custom-series.git


The following commit(s) were added to refs/heads/main by this push:
     new a74ce26  chore: minify
a74ce26 is described below

commit a74ce26f185cd15362c27a35a3cfee4cad631c3e
Author: Ovilia <[email protected]>
AuthorDate: Wed Sep 4 12:04:24 2024 +0800

    chore: minify
---
 README.md                              |  16 +++
 custom-series/violin/dist/index.html   | 163 ++++++++++++++++++++++++++
 custom-series/violin/dist/index.js     | 206 +++++++++++++++++----------------
 custom-series/violin/dist/index.js.map |   2 +-
 custom-series/violin/dist/index.min.js |   1 +
 custom-series/violin/package-lock.json |   4 +-
 custom-series/violin/package.json      |   2 +-
 custom-series/violin/test/index.html   |  56 +++++++++
 package-lock.json                      | 120 +++++++++++++++++++
 package.json                           |   1 +
 scripts/build.js                       |  13 ++-
 scripts/template/package.json          |   2 +-
 12 files changed, 482 insertions(+), 104 deletions(-)

diff --git a/README.md b/README.md
index 1833d64..f6a059b 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,22 @@ This repo provides some custom series for [Apache 
ECharts](https://github.com/ap
 
 TODO
 
+## Setup
+
+```bash
+npm install
+```
+
+Note: Building requires the lib files of ECharts v6. So before ECharts v6 is 
released, you need to clone `apache/echarts` locally and use `npm link` to link 
it.
+
+```bash
+# Under the directory of echarts
+npm link
+
+# Under the directory of echarts-custom-series/custom-series/<series-name>
+npm link echarts
+```
+
 ## Create A New Custom Series
 
 ```bash
diff --git a/custom-series/violin/dist/index.html 
b/custom-series/violin/dist/index.html
new file mode 100644
index 0000000..c33a193
--- /dev/null
+++ b/custom-series/violin/dist/index.html
@@ -0,0 +1,163 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>SVG Path in Canvas</title>
+    <style>
+        body {
+            display: flex;
+            justify-content: center;
+            align-items: center;
+            height: 100vh;
+            margin: 0;
+            background-color: #f0f0f0;
+            flex-direction: row;
+        }
+
+        canvas {
+            border: 1px solid #000000;
+            margin-bottom: 20px;
+        }
+
+        svg {
+            border: 1px solid #000000;
+        }
+    </style>
+</head>
+
+<body>
+    <script src="../node_modules/dynamics.js/lib/dynamics.js"></script>
+    <canvas id="myCanvas" width="500" height="500"></canvas>
+    <svg id="mySVG" width="500" height="500"></svg>
+    <script>
+        const generator = ({ size = 400, growth = 16, edges = 6, seed = null } 
= {}) => {
+            var { destPoints, seedValue } = _createPoints(size, growth, edges, 
seed);
+            var path = _createSvgPath(destPoints);
+            return { path, seedValue };
+        };
+
+        const _toRad = (deg) => deg * (Math.PI / 180.0);
+
+        const _divide = (count) => {
+            var deg = 360 / count;
+
+            return Array(count)
+                .fill("a")
+                .map((_, i) => i * deg);
+        };
+
+        const _randomDoubleGenerator = (s) => {
+            var mask = 0xffffffff;
+            var m_w = (123456789 + s) & mask;
+            var m_z = (987654321 - s) & mask;
+
+            return function () {
+                m_z = (36969 * (m_z & 65535) + (m_z >>> 16)) & mask;
+                m_w = (18000 * (m_w & 65535) + (m_w >>> 16)) & mask;
+
+                var result = ((m_z << 16) + (m_w & 65535)) >>> 0;
+                result /= 4294967296;
+                return result;
+            };
+        };
+
+        const _magicPoint = (value, min, max) => {
+            let radius = min + value * (max - min);
+            if (radius > max) {
+                radius = radius - min;
+            } else if (radius < min) {
+                radius = radius + min;
+            }
+            return radius;
+        };
+
+        const _point = (origin, radius, degree) => {
+            var x = origin + radius * Math.cos(_toRad(degree));
+            var y = origin + radius * Math.sin(_toRad(degree));
+            return [Math.round(x), Math.round(y)];
+        };
+
+        const _shuffle = (array) => {
+            array.sort(() => Math.random() - 0.5);
+            return array;
+        };
+
+        const _createPoints = (size, minGrowth, edgesCount, seed) => {
+            let outerRad = size / 2;
+            let innerRad = minGrowth * (outerRad / 10);
+            let center = size / 2;
+
+            let slices = _divide(edgesCount);
+            let maxRandomValue = _shuffle([99, 999, 9999, 99999, 999999])[0];
+            let id = Math.floor(Math.random() * maxRandomValue);
+            let seedValue = seed || id;
+            let randVal = _randomDoubleGenerator(seedValue);
+            let destPoints = [];
+
+            slices.forEach((degree) => {
+                let O = _magicPoint(randVal(), innerRad, outerRad);
+                let end = _point(center, O, degree);
+                destPoints.push(end);
+            });
+            return { destPoints, seedValue };
+        };
+
+        const _createSvgPath = (points) => {
+            let svgPath = "";
+            var mid = [
+                (points[0][0] + points[1][0]) / 2,
+                (points[0][1] + points[1][1]) / 2,
+            ];
+            svgPath += "M" + mid[0] + "," + mid[1];
+
+            for (var i = 0; i < points.length; i++) {
+                var p1 = points[(i + 1) % points.length];
+                var p2 = points[(i + 2) % points.length];
+                mid = [(p1[0] + p2[0]) / 2, (p1[1] + p2[1]) / 2];
+                svgPath += "Q" + p1[0] + "," + p1[1] + "," + mid[0] + "," + 
mid[1];
+            }
+            svgPath += "Z";
+            return svgPath;
+        };
+
+        window.onload = function () {
+            const canvas = document.getElementById('myCanvas');
+            const context = canvas.getContext('2d');
+            const svg = document.getElementById('mySVG');
+
+            // Define the SVG path data
+            const svgPathData = generator({ size: 400, growth: 6, edges: 6, 
seed: null });
+            console.log(svgPathData);
+
+            // Draw on Canvas
+            const path = new Path2D(svgPathData.path);
+            context.strokeStyle = 'black';
+            context.lineWidth = 2;
+            context.stroke(path);
+
+            // Draw on SVG
+            const svgPath = 
document.createElementNS("http://www.w3.org/2000/svg";, "path");
+            svgPath.setAttribute("d", svgPathData.path);
+            svgPath.setAttribute("stroke", "black");
+            svgPath.setAttribute("stroke-width", "2");
+            svgPath.setAttribute("fill", "none");
+            svg.appendChild(svgPath);
+
+
+            dynamics.animate(svgPath, {
+                d: generator({ size: 400, growth: 6, edges: 6, seed: null 
}).path
+            }, {
+                type: dynamics.easeInOut,
+                duration: 2000,
+                friction: 100,
+                complete: function () {
+                    console.log('Animation completed');
+                }
+            });
+        };
+    </script>
+</body>
+
+</html>
\ No newline at end of file
diff --git a/custom-series/violin/dist/index.js 
b/custom-series/violin/dist/index.js
index 877879e..3d9264b 100644
--- a/custom-series/violin/dist/index.js
+++ b/custom-series/violin/dist/index.js
@@ -1,4 +1,3 @@
-"use strict";
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -17,109 +16,120 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-Object.defineProperty(exports, "__esModule", { value: true });
-var tslib_1 = require("tslib");
-var echarts_1 = tslib_1.__importDefault(require("echarts"));
-function epanechnikovKernel(u) {
-    return Math.abs(u) <= 1 ? 0.75 * (1 - u * u) : 0;
-}
-function kernelDensityEstimator(kernel, bandwidth, data) {
-    return function (x) {
-        var sum = 0;
-        for (var i = 0; i < data.length; i++) {
-            sum += kernel((x - data[i]) / bandwidth);
-        }
-        return sum / (data.length * bandwidth);
-    };
-}
-var renderItem = function (params, api) {
-    var violins = {};
-    if (params.context.violins == null) {
-        params.context.violins = [];
-        violins = params.context.violins;
-        var cnt = params.dataInsideLength;
-        for (var i_1 = 0; i_1 < cnt; ++i_1) {
-            var xIndex = api.value(0, i_1);
-            if (violins[xIndex] == null) {
-                violins[xIndex] = {
-                    firstDataIndex: i_1,
-                    data: [],
-                };
+(function (factory) {
+    if (typeof module === "object" && typeof module.exports === "object") {
+        var v = factory(require, exports);
+        if (v !== undefined) module.exports = v;
+    }
+    else if (typeof define === "function" && define.amd) {
+        define(["require", "exports", "tslib", "echarts"], factory);
+    }
+})(function (require, exports) {
+    "use strict";
+    Object.defineProperty(exports, "__esModule", { value: true });
+    var tslib_1 = require("tslib");
+    var echarts_1 = tslib_1.__importDefault(require("echarts"));
+    function epanechnikovKernel(u) {
+        return Math.abs(u) <= 1 ? 0.75 * (1 - u * u) : 0;
+    }
+    function kernelDensityEstimator(kernel, bandwidth, data) {
+        return function (x) {
+            var sum = 0;
+            for (var i = 0; i < data.length; i++) {
+                sum += kernel((x - data[i]) / bandwidth);
             }
-            violins[xIndex].data.push(api.value(1, i_1));
-        }
+            return sum / (data.length * bandwidth);
+        };
     }
-    var symbolSize = params.itemPayload.symbolSize;
-    var xValue = api.value(0);
-    var yValue = api.value(1);
-    var coord = api.coord([xValue, yValue]);
-    var bandWidthScale = params.itemPayload.bandWidthScale;
-    var bandWidth = (api.coord([1, 0])[0] - api.coord([0, 0])[0]) *
-        (bandWidthScale == null ? 1 : bandWidthScale);
-    var violin = violins[xValue];
-    var violinPath = null;
-    if (violin && violin.firstDataIndex === params.dataIndex) {
-        var kde_1 = kernelDensityEstimator(epanechnikovKernel, 1, violin.data);
-        var binCount = params.itemPayload.binCount || 100;
-        var xRange = [];
-        for (var i = 0; i < binCount; i++) {
-            xRange.push(i * (10 / (binCount - 1)));
-        }
-        var density = xRange.map(function (x) { return [x, kde_1(x)]; });
-        var epsilonDensity = 0.001;
-        var polylines_1 = [];
-        var points_1 = [];
-        var pushToPolylines = function () {
-            if (points_1.length > 1) {
-                for (var j = points_1.length - 1; j >= 0; --j) {
-                    points_1.push([coord[0] * 2 - points_1[j][0], 
points_1[j][1]]);
+    var renderItem = function (params, api) {
+        var violins = {};
+        if (params.context.violins == null) {
+            params.context.violins = [];
+            violins = params.context.violins;
+            var cnt = params.dataInsideLength;
+            for (var i_1 = 0; i_1 < cnt; ++i_1) {
+                var xIndex = api.value(0, i_1);
+                if (violins[xIndex] == null) {
+                    violins[xIndex] = {
+                        firstDataIndex: i_1,
+                        data: [],
+                    };
                 }
-                var areaOpacity = params.itemPayload.areaOpacity;
-                polylines_1.push({
-                    type: 'polygon',
-                    shape: {
-                        points: points_1.slice(),
-                    },
-                    style: {
-                        fill: api.visual('color'),
-                        opacity: areaOpacity == null ? 0.5 : areaOpacity,
-                    },
-                });
+                violins[xIndex].data.push(api.value(1, i_1));
             }
-            points_1.length = 0;
-        };
-        for (var i_2 = 0; i_2 < density.length; ++i_2) {
-            var coord_1 = api.coord([xValue, density[i_2][0]]);
-            if (density[i_2][1] < epsilonDensity) {
-                pushToPolylines();
-                continue;
+        }
+        var symbolSize = params.itemPayload.symbolSize;
+        var xValue = api.value(0);
+        var yValue = api.value(1);
+        var coord = api.coord([xValue, yValue]);
+        var bandWidthScale = params.itemPayload.bandWidthScale;
+        var bandWidth = (api.coord([1, 0])[0] - api.coord([0, 0])[0]) *
+            (bandWidthScale == null ? 1 : bandWidthScale);
+        var violin = violins[xValue];
+        var violinPath = null;
+        if (violin && violin.firstDataIndex === params.dataIndex) {
+            var kde_1 = kernelDensityEstimator(epanechnikovKernel, 1, 
violin.data);
+            var binCount = params.itemPayload.binCount || 100;
+            var xRange = [];
+            for (var i = 0; i < binCount; i++) {
+                xRange.push(i * (10 / (binCount - 1)));
+            }
+            var density = xRange.map(function (x) { return [x, kde_1(x)]; });
+            var epsilonDensity = 0.001;
+            var polylines_1 = [];
+            var points_1 = [];
+            var pushToPolylines = function () {
+                if (points_1.length > 1) {
+                    for (var j = points_1.length - 1; j >= 0; --j) {
+                        points_1.push([coord[0] * 2 - points_1[j][0], 
points_1[j][1]]);
+                    }
+                    var areaOpacity = params.itemPayload.areaOpacity;
+                    polylines_1.push({
+                        type: 'polygon',
+                        shape: {
+                            points: points_1.slice(),
+                        },
+                        style: {
+                            fill: api.visual('color'),
+                            opacity: areaOpacity == null ? 0.5 : areaOpacity,
+                        },
+                    });
+                }
+                points_1.length = 0;
+            };
+            for (var i_2 = 0; i_2 < density.length; ++i_2) {
+                var coord_1 = api.coord([xValue, density[i_2][0]]);
+                if (density[i_2][1] < epsilonDensity) {
+                    pushToPolylines();
+                    continue;
+                }
+                points_1.push([coord_1[0] + (bandWidth / 2) * density[i_2][1], 
coord_1[1]]);
             }
-            points_1.push([coord_1[0] + (bandWidth / 2) * density[i_2][1], 
coord_1[1]]);
+            pushToPolylines();
+            violinPath = {
+                type: 'group',
+                children: polylines_1,
+                silent: true,
+            };
         }
-        pushToPolylines();
-        violinPath = {
-            type: 'group',
-            children: polylines_1,
-            silent: true,
+        var scatter = {
+            type: 'circle',
+            shape: {
+                cx: coord[0],
+                cy: coord[1],
+                r: symbolSize == null ? 5 : symbolSize,
+            },
+            style: {
+                fill: api.visual('color'),
+            },
         };
-    }
-    var scatter = {
-        type: 'circle',
-        shape: {
-            cx: coord[0],
-            cy: coord[1],
-            r: symbolSize == null ? 5 : symbolSize,
-        },
-        style: {
-            fill: api.visual('color'),
-        },
+        return violinPath
+            ? {
+                type: 'group',
+                children: [scatter, violinPath],
+            }
+            : scatter;
     };
-    return violinPath
-        ? {
-            type: 'group',
-            children: [scatter, violinPath],
-        }
-        : scatter;
-};
-echarts_1.default.registerCustomSeries('violin', renderItem);
+    echarts_1.default.registerCustomSeries('violin', renderItem);
+});
 //# sourceMappingURL=index.js.map
\ No newline at end of file
diff --git a/custom-series/violin/dist/index.js.map 
b/custom-series/violin/dist/index.js.map
index 9423d4f..c4f9f0a 100644
--- a/custom-series/violin/dist/index.js.map
+++ b/custom-series/violin/dist/index.js.map
@@ -1 +1 @@
-{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAEH,4DAA0D;AAM1D,SAAS,kBAAkB,CAAC,CAAS;IACnC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,sBAAsB,CAC7B,MAA6B,EAC7B,SAAiB,EACjB,IAAc;IAEd,OAAO,UAAU,CAAS;QACxB,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EA
 [...]
\ No newline at end of file
+{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;IAEH,4DAA0D;IAM1D,SAAS,kBAAkB,CAAC,CAAS;QACnC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,SAAS,sBAAsB,CAC7B,MAA6B,EAC7B,SAAiB,EACjB,IAAc;QAEd,OAAO,UAAU,CAAS;YACxB,IAAI,GAAG,GAAG,CAAC,CAAC;YACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAA
 [...]
\ No newline at end of file
diff --git a/custom-series/violin/dist/index.min.js 
b/custom-series/violin/dist/index.min.js
new file mode 100644
index 0000000..8ebda3f
--- /dev/null
+++ b/custom-series/violin/dist/index.min.js
@@ -0,0 +1 @@
+!function(e){if("object"==typeof module&&"object"==typeof module.exports){var 
t=e(require,exports);void 0!==t&&(module.exports=t)}else"function"==typeof 
define&&define.amd&&define(["require","exports","tslib","echarts"],e)}((function(e,t){"use
 strict";function o(e){return 
Math.abs(e)<=1?.75*(1-e*e):0}Object.defineProperty(t,"__esModule",{value:!0});e("tslib").__importDefault(e("echarts")).default.registerCustomSeries("violin",(function(e,t){var
 l={};if(null==e.context.violins){e.context. [...]
\ No newline at end of file
diff --git a/custom-series/violin/package-lock.json 
b/custom-series/violin/package-lock.json
index aab4037..d24d97a 100644
--- a/custom-series/violin/package-lock.json
+++ b/custom-series/violin/package-lock.json
@@ -1,12 +1,12 @@
 {
   "name": "echarts-violin",
-  "version": "1.0.0",
+  "version": "0.0.1-beta",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "echarts-violin",
-      "version": "1.0.0",
+      "version": "0.0.1-beta",
       "license": "Apache-2.0",
       "dependencies": {
         "echarts": "github:apache/echarts#v6"
diff --git a/custom-series/violin/package.json 
b/custom-series/violin/package.json
index 6ea24d5..c856d37 100644
--- a/custom-series/violin/package.json
+++ b/custom-series/violin/package.json
@@ -2,7 +2,7 @@
   "name": "echarts-violin",
   "version": "0.0.1-beta",
   "description": "",
-  "main": "index.js",
+  "main": "dist/index.js",
   "scripts": {
     "build": "tsc"
   },
diff --git a/custom-series/violin/test/index.html 
b/custom-series/violin/test/index.html
new file mode 100644
index 0000000..3b460e4
--- /dev/null
+++ b/custom-series/violin/test/index.html
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Apache ECharts Custom Series Test</title>
+</head>
+
+<body>
+    <div id="main" style="width: 1000px;height:400px;border:1px solid 
#ccc"></div>
+
+    <script src="../node_modules/echarts/dist/echarts.js"></script>
+    <script src="../dist/index.js"></script>
+    <script>
+        const chart = echarts.init(document.getElementById('main'));
+
+        const xData = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
+        const dataSource = [['Day', 'value']];
+        for (let i = 0; i < xData.length; ++i) {
+            const dataCount = 10 * Math.round(Math.random() * 5) + 5;
+            for (let j = 0; j < dataCount; ++j) {
+                const value = Math.tan(i) / 2 + 3 * Math.random() + 2;
+                dataSource.push([xData[i], value]);
+            }
+        }
+
+        option = {
+            tooltip: {
+                show: true
+            },
+            xAxis: {
+                data: xData
+            },
+            yAxis: {},
+            dataset: {
+                source: dataSource
+            },
+            series: {
+                type: 'custom',
+                renderItem: 'violin',
+                colorBy: 'item',
+                itemPayload: {
+                    symbolSize: 4,
+                    areaOpacity: 0.6,
+                    bandWidthScale: 1.5
+                    // binCount: 20
+                }
+            }
+        };
+
+        chart.setOption(option);
+    </script>
+</body>
+
+</html>
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 02ab8c0..82ca5f3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,9 +9,129 @@
       "version": "1.0.0",
       "license": "Apache-2.0",
       "devDependencies": {
+        "terser": "^5.31.6",
         "typescript": "^5.5.4"
       }
     },
+    "node_modules/@jridgewell/gen-mapping": {
+      "version": "0.3.5",
+      "resolved": 
"https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz";,
+      "integrity": 
"sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==",
+      "dev": true,
+      "dependencies": {
+        "@jridgewell/set-array": "^1.2.1",
+        "@jridgewell/sourcemap-codec": "^1.4.10",
+        "@jridgewell/trace-mapping": "^0.3.24"
+      },
+      "engines": {
+        "node": ">=6.0.0"
+      }
+    },
+    "node_modules/@jridgewell/resolve-uri": {
+      "version": "3.1.2",
+      "resolved": 
"https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz";,
+      "integrity": 
"sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
+      "dev": true,
+      "engines": {
+        "node": ">=6.0.0"
+      }
+    },
+    "node_modules/@jridgewell/set-array": {
+      "version": "1.2.1",
+      "resolved": 
"https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz";,
+      "integrity": 
"sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==",
+      "dev": true,
+      "engines": {
+        "node": ">=6.0.0"
+      }
+    },
+    "node_modules/@jridgewell/source-map": {
+      "version": "0.3.6",
+      "resolved": 
"https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.6.tgz";,
+      "integrity": 
"sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ==",
+      "dev": true,
+      "dependencies": {
+        "@jridgewell/gen-mapping": "^0.3.5",
+        "@jridgewell/trace-mapping": "^0.3.25"
+      }
+    },
+    "node_modules/@jridgewell/sourcemap-codec": {
+      "version": "1.5.0",
+      "resolved": 
"https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz";,
+      "integrity": 
"sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==",
+      "dev": true
+    },
+    "node_modules/@jridgewell/trace-mapping": {
+      "version": "0.3.25",
+      "resolved": 
"https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz";,
+      "integrity": 
"sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==",
+      "dev": true,
+      "dependencies": {
+        "@jridgewell/resolve-uri": "^3.1.0",
+        "@jridgewell/sourcemap-codec": "^1.4.14"
+      }
+    },
+    "node_modules/acorn": {
+      "version": "8.12.1",
+      "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz";,
+      "integrity": 
"sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==",
+      "dev": true,
+      "bin": {
+        "acorn": "bin/acorn"
+      },
+      "engines": {
+        "node": ">=0.4.0"
+      }
+    },
+    "node_modules/buffer-from": {
+      "version": "1.1.2",
+      "resolved": 
"https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz";,
+      "integrity": 
"sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
+      "dev": true
+    },
+    "node_modules/commander": {
+      "version": "2.20.3",
+      "resolved": 
"https://registry.npmjs.org/commander/-/commander-2.20.3.tgz";,
+      "integrity": 
"sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
+      "dev": true
+    },
+    "node_modules/source-map": {
+      "version": "0.6.1",
+      "resolved": 
"https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz";,
+      "integrity": 
"sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/source-map-support": {
+      "version": "0.5.21",
+      "resolved": 
"https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz";,
+      "integrity": 
"sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
+      "dev": true,
+      "dependencies": {
+        "buffer-from": "^1.0.0",
+        "source-map": "^0.6.0"
+      }
+    },
+    "node_modules/terser": {
+      "version": "5.31.6",
+      "resolved": "https://registry.npmjs.org/terser/-/terser-5.31.6.tgz";,
+      "integrity": 
"sha512-PQ4DAriWzKj+qgehQ7LK5bQqCFNMmlhjR2PFFLuqGCpuCAauxemVBWwWOxo3UIwWQx8+Pr61Df++r76wDmkQBg==",
+      "dev": true,
+      "dependencies": {
+        "@jridgewell/source-map": "^0.3.3",
+        "acorn": "^8.8.2",
+        "commander": "^2.20.0",
+        "source-map-support": "~0.5.20"
+      },
+      "bin": {
+        "terser": "bin/terser"
+      },
+      "engines": {
+        "node": ">=10"
+      }
+    },
     "node_modules/typescript": {
       "version": "5.5.4",
       "resolved": 
"https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz";,
diff --git a/package.json b/package.json
index e7da31b..d6fa56f 100644
--- a/package.json
+++ b/package.json
@@ -17,6 +17,7 @@
   },
   "homepage": "https://github.com/apache/echarts-custom-series#readme";,
   "devDependencies": {
+    "terser": "^5.31.6",
     "typescript": "^5.5.4"
   }
 }
diff --git a/scripts/build.js b/scripts/build.js
index a02a4f1..dde4aa0 100644
--- a/scripts/build.js
+++ b/scripts/build.js
@@ -50,7 +50,18 @@ function buildCustomSeries(dirName) {
         --declarationMap false \
         --importHelpers \
         --pretty \
-        --ignoreDeprecations 5.0`
+        --ignoreDeprecations 5.0 \
+        --module umd`
+  );
+
+  // Minify using terser
+  const terserPath = path.join(__dirname, '../node_modules/.bin/terser');
+  execSync(
+    `${terserPath} ${seriesPath}/dist/index.js \
+        --compress \
+        --mangle \
+        --ecma 3 \
+        --output ${seriesPath}/dist/index.min.js`
   );
 }
 
diff --git a/scripts/template/package.json b/scripts/template/package.json
index cdcea7d..0e4c6f8 100644
--- a/scripts/template/package.json
+++ b/scripts/template/package.json
@@ -2,7 +2,7 @@
   "name": "echarts-$$$",
   "version": "0.0.1",
   "description": "",
-  "main": "index.js",
+  "main": "dist/index.js",
   "scripts": {
     "build": "tsc"
   },


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to