Skip to content

Commit 4f57156

Browse files
committed
update package json, clean unused dependencies
1 parent 515b5e2 commit 4f57156

File tree

4 files changed

+101
-89
lines changed

4 files changed

+101
-89
lines changed

package.json

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,25 @@
33
"version": "1.0.0",
44
"private": false,
55
"description": "Mindmap viewer for web",
6+
"main": "dist/js/mindtree.js",
67
"scripts": {
78
"watch": "webpack --watch --progress --mode development",
89
"start": "webpack-dev-server",
910
"dev": "webpack --mode development",
10-
"clean": "shx rm -rf build/static",
11+
"clean": "shx rm -rf dist",
1112
"build": "npm run clean && cross-env NODE_ENV=\"production\" webpack"
1213
},
1314
"devDependencies": {
1415
"@babel/core": "^7.11.0",
1516
"@babel/plugin-syntax-class-properties": "^7.10.4",
1617
"@babel/preset-env": "^7.11.0",
1718
"babel-loader": "^8.1.0",
18-
"copy-webpack-plugin": "^6.0.0",
1919
"cross-env": "^7.0.0",
20-
"css-loader": "^4.1.1",
21-
"file-loader": "^6.0.0",
22-
"mini-css-extract-plugin": "^0.9.0",
23-
"postcss-loader": "^3.0.0",
2420
"random-graph": "^0.0.3",
25-
"sass": "^1.26.10",
26-
"sass-loader": "^9.0.2",
2721
"shx": "^0.3.2",
2822
"stylelint": "^13.6.1",
2923
"stylelint-config-standard": "^20.0.0",
30-
"uglifyjs-webpack-plugin": "^2.2.0",
31-
"url-loader": "^4.0.1",
24+
"terser-webpack-plugin": "^4.1.0",
3225
"webpack": "^4.44.1",
3326
"webpack-cli": "^3.3.12",
3427
"webpack-dev-server": "^3.11.0"

src/js/algorithms/layout.js

Lines changed: 54 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,66 @@
1-
import { Tree, layout } from 'non-layered-tidy-tree-layout'
1+
import { Tree, layout } from "non-layered-tidy-tree-layout";
22

33
class Layout {
4-
constructor(boundingBox) {
5-
this.bb = boundingBox
6-
}
7-
8-
/**
9-
* Layout treeData.
10-
* Return modified treeData and the bounding box encompassing all the nodes.
11-
*
12-
* See getSize() for more explanation.
13-
*/
14-
layout(treeData) {
15-
const tree = this.convert(treeData)
16-
layout(tree)
17-
const { boundingBox, result } = this.assignLayout(tree, treeData)
4+
constructor(boundingBox) {
5+
this.bb = boundingBox;
6+
}
187

19-
return { result, boundingBox }
20-
}
8+
/**
9+
* Layout treeData.
10+
* Return modified treeData and the bounding box encompassing all the nodes.
11+
*
12+
* See getSize() for more explanation.
13+
*/
14+
layout(treeData) {
15+
const tree = this.convert(treeData);
16+
layout(tree);
17+
const { boundingBox, result } = this.assignLayout(tree, treeData);
2118

22-
/**
23-
* Returns Tree to layout, with bounding boxes added to each node.
24-
*/
25-
convert(treeData, y = 0) {
26-
if (treeData === null) return null
19+
return { result, boundingBox };
20+
}
2721

28-
const { width, height } = this.bb.addBoundingBox(
29-
treeData.width,
30-
treeData.height
31-
)
32-
let children = []
33-
if (treeData.children && treeData.children.length) {
34-
for (let i = 0; i < treeData.children.length; i++) {
35-
children[i] = this.convert(treeData.children[i], y + height)
36-
}
37-
}
22+
/**
23+
* Returns Tree to layout, with bounding boxes added to each node.
24+
*/
25+
convert(treeData, y = 0) {
26+
if (treeData === null) return null;
3827

39-
return new Tree(width, height, y, children)
28+
const { width, height } = this.bb.addBoundingBox(
29+
treeData.width,
30+
treeData.height
31+
);
32+
let children = [];
33+
if (treeData.children && treeData.children.length) {
34+
for (let i = 0; i < treeData.children.length; i++) {
35+
children[i] = this.convert(treeData.children[i], y + height);
36+
}
4037
}
4138

42-
/**
43-
* Assign layout tree x, y coordinates back to treeData,
44-
* with bounding boxes removed.
45-
*/
46-
assignCoordinates(tree, treeData) {
47-
const { x, y } = this.bb.removeBoundingBox(tree.x, tree.y)
48-
treeData.x = x
49-
treeData.y = y
50-
for (let i = 0; i < tree.c.length; i++) {
51-
this.assignCoordinates(tree.c[i], treeData.children[i])
52-
}
53-
return treeData
54-
}
39+
return new Tree(width, height, y, children);
40+
}
5541

56-
/**
57-
* This function does assignCoordinates and getSize in one pass.
58-
*/
59-
assignLayout(tree, treeData, box = null) {
60-
return {
61-
result: this.assignCoordinates(tree, treeData)
62-
}
42+
/**
43+
* Assign layout tree x, y coordinates back to treeData,
44+
* with bounding boxes removed.
45+
*/
46+
assignCoordinates(tree, treeData) {
47+
const { x, y } = this.bb.removeBoundingBox(tree.x, tree.y);
48+
treeData.x = x;
49+
treeData.y = y;
50+
for (let i = 0; i < tree.c.length; i++) {
51+
this.assignCoordinates(tree.c[i], treeData.children[i]);
6352
}
64-
}
53+
return treeData;
54+
}
6555

56+
/**
57+
* This function does assignCoordinates and getSize in one pass.
58+
*/
59+
assignLayout(tree, treeData, box = null) {
60+
return {
61+
result: this.assignCoordinates(tree, treeData),
62+
};
63+
}
64+
}
6665

67-
export default Layout
66+
export default Layout;

webpack/config.js

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const path = require("path"),
1717
manifest = require("./manifest"),
1818
rules = require("./rules"),
1919
plugins = [],
20-
UglifyJsPlugin = require("uglifyjs-webpack-plugin");
20+
TerserPlugin = require("terser-webpack-plugin");
2121

2222
// ------------------
2323
// @Entry Point Setup
@@ -49,26 +49,8 @@ var optimization = {
4949

5050
if (manifest.IS_PRODUCTION) {
5151
optimization.minimizer = [
52-
new UglifyJsPlugin({
52+
new TerserPlugin({
5353
parallel: true,
54-
uglifyOptions: {
55-
compress: {
56-
comparisons: true,
57-
conditionals: true,
58-
dead_code: true,
59-
drop_debugger: true,
60-
evaluate: true,
61-
if_return: true,
62-
join_vars: true,
63-
sequences: true,
64-
unused: true,
65-
warnings: false,
66-
},
67-
68-
output: {
69-
comments: false,
70-
},
71-
},
7254
}),
7355
];
7456
}

yarn.lock

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,7 @@ cacache@^12.0.2:
15871587
unique-filename "^1.1.1"
15881588
y18n "^4.0.0"
15891589

1590-
cacache@^15.0.4:
1590+
cacache@^15.0.4, cacache@^15.0.5:
15911591
version "15.0.5"
15921592
resolved "https://registry.yarnpkg.com/cacache/-/cacache-15.0.5.tgz#69162833da29170d6732334643c60e005f5f17d0"
15931593
integrity sha512-lloiL22n7sOjEEXdL8NAjTgv9a1u43xICE9/203qonkZUCj5X1UEWIdf2/Y0d6QcCtMzbKQyhrcDbdvlZTs/+A==
@@ -3640,6 +3640,15 @@ isobject@^3.0.0, isobject@^3.0.1:
36403640
resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
36413641
integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8=
36423642

3643+
jest-worker@^26.3.0:
3644+
version "26.3.0"
3645+
resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.3.0.tgz#7c8a97e4f4364b4f05ed8bca8ca0c24de091871f"
3646+
integrity sha512-Vmpn2F6IASefL+DVBhPzI2J9/GJUsqzomdeN+P+dK8/jKxbh8R3BtFnx3FIta7wYlPU62cpJMJQo4kuOowcMnw==
3647+
dependencies:
3648+
"@types/node" "*"
3649+
merge-stream "^2.0.0"
3650+
supports-color "^7.0.0"
3651+
36433652
"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0:
36443653
version "4.0.0"
36453654
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
@@ -3951,6 +3960,11 @@ merge-descriptors@1.0.1:
39513960
resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61"
39523961
integrity sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=
39533962

3963+
merge-stream@^2.0.0:
3964+
version "2.0.0"
3965+
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
3966+
integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==
3967+
39543968
merge2@^1.3.0:
39553969
version "1.4.1"
39563970
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
@@ -4422,7 +4436,7 @@ p-limit@^2.0.0, p-limit@^2.2.0:
44224436
dependencies:
44234437
p-try "^2.0.0"
44244438

4425-
p-limit@^3.0.1:
4439+
p-limit@^3.0.1, p-limit@^3.0.2:
44264440
version "3.0.2"
44274441
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.0.2.tgz#1664e010af3cadc681baafd3e2a437be7b0fb5fe"
44284442
integrity sha512-iwqZSOoWIW+Ew4kAGUlN16J4M7OB3ysMLSZtnhmqx7njIHFPlxWBX8xo3lVTyFVq6mI/lL9qt2IsN1sHwaxJkg==
@@ -5323,7 +5337,7 @@ schema-utils@^1.0.0:
53235337
ajv-errors "^1.0.0"
53245338
ajv-keywords "^3.1.0"
53255339

5326-
schema-utils@^2.6.5, schema-utils@^2.7.0:
5340+
schema-utils@^2.6.5, schema-utils@^2.6.6, schema-utils@^2.7.0:
53275341
version "2.7.0"
53285342
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.0.tgz#17151f76d8eae67fbbf77960c33c676ad9f4efc7"
53295343
integrity sha512-0ilKFI6QQF5nxDZLFn2dMjvc4hjg/Wkg7rHd3jK6/A4a1Hl9VFdQWvgB1UMGoU94pad1P/8N7fMcEnLnSiju8A==
@@ -5940,7 +5954,7 @@ supports-color@^6.1.0:
59405954
dependencies:
59415955
has-flag "^3.0.0"
59425956

5943-
supports-color@^7.1.0:
5957+
supports-color@^7.0.0, supports-color@^7.1.0:
59445958
version "7.1.0"
59455959
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.1.0.tgz#68e32591df73e25ad1c4b49108a2ec507962bfd1"
59465960
integrity sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==
@@ -5994,6 +6008,21 @@ terser-webpack-plugin@^1.4.3:
59946008
webpack-sources "^1.4.0"
59956009
worker-farm "^1.7.0"
59966010

6011+
terser-webpack-plugin@^4.1.0:
6012+
version "4.1.0"
6013+
resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-4.1.0.tgz#6e9d6ae4e1a900d88ddce8da6a47507ea61f44bc"
6014+
integrity sha512-0ZWDPIP8BtEDZdChbufcXUigOYk6dOX/P/X0hWxqDDcVAQLb8Yy/0FAaemSfax3PAA67+DJR778oz8qVbmy4hA==
6015+
dependencies:
6016+
cacache "^15.0.5"
6017+
find-cache-dir "^3.3.1"
6018+
jest-worker "^26.3.0"
6019+
p-limit "^3.0.2"
6020+
schema-utils "^2.6.6"
6021+
serialize-javascript "^4.0.0"
6022+
source-map "^0.6.1"
6023+
terser "^5.0.0"
6024+
webpack-sources "^1.4.3"
6025+
59976026
terser@^4.1.2:
59986027
version "4.8.0"
59996028
resolved "https://registry.yarnpkg.com/terser/-/terser-4.8.0.tgz#63056343d7c70bb29f3af665865a46fe03a0df17"
@@ -6003,6 +6032,15 @@ terser@^4.1.2:
60036032
source-map "~0.6.1"
60046033
source-map-support "~0.5.12"
60056034

6035+
terser@^5.0.0:
6036+
version "5.2.0"
6037+
resolved "https://registry.yarnpkg.com/terser/-/terser-5.2.0.tgz#e547d0b20926b321d3e524bf9e5bc1b10ba2f360"
6038+
integrity sha512-nZ9TWhBznZdlww3borgJyfQDrxzpgd0RlRNoxR63tMVry01lIH/zKQDTTiaWRMGowydfvSHMgyiGyn6A9PSkCQ==
6039+
dependencies:
6040+
commander "^2.20.0"
6041+
source-map "~0.6.1"
6042+
source-map-support "~0.5.12"
6043+
60066044
through2@^2.0.0:
60076045
version "2.0.5"
60086046
resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.5.tgz#01c1e39eb31d07cb7d03a96a70823260b23132cd"

0 commit comments

Comments
 (0)