diff options
author | sternenseemann <git@lukasepple.de> | 2020-07-22 16:17:11 +0200 |
---|---|---|
committer | sternenseemann <git@lukasepple.de> | 2020-07-22 16:17:11 +0200 |
commit | 11872a4da6ab14af0c67281075cec1f3f7a7acba (patch) | |
tree | 4c2cfa182e3b8564819d8e3f9ec087fcb0275a1f /web | |
parent | 834e875c11f30a44e89285cd07920ba9a67cb38d (diff) |
web: switch from legacy vis to vis-network
* main.js: remove dependency on DataSet * index.html: fix css path * default.nix: set NODE_PATH, so vis-network can find its peer dependency, ignore dist/ * package.json: add vis-network and vis-data (required for vis-network to compile
Diffstat (limited to 'web')
-rw-r--r-- | web/default.nix | 4 | ||||
-rw-r--r-- | web/package.json | 5 | ||||
-rw-r--r-- | web/source/index.html | 2 | ||||
-rw-r--r-- | web/source/main.js | 23 | ||||
-rw-r--r-- | web/yarn.lock | 112 |
5 files changed, 35 insertions, 111 deletions
diff --git a/web/default.nix b/web/default.nix index 26bd291..ab75d75 100644 --- a/web/default.nix +++ b/web/default.nix @@ -5,7 +5,7 @@ let target = if production then "prod" else "dev"; pkgInfo = stdenv.lib.importJSON ./package.json; - src = ./.; + src = yarn2nix-lib.removePrefixes [ "node_modules" "dist" ] ./.; # yarn2nixSrc = /home/lukas/src/nix/yarn2nix; yarn2nixSrc = fetchFromGitHub { owner = "sternenseemann"; @@ -43,6 +43,8 @@ stdenv.mkDerivation rec { --replace node_modules "${node_modules}" ''; + NODE_PATH = "${node_modules}"; + buildPhase = '' # temporary $HOME for yarn config export HOME=$(pwd)/yarn_home diff --git a/web/package.json b/web/package.json index b1738f2..e54fab5 100644 --- a/web/package.json +++ b/web/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "license": "AGPL-3.0-only", "scripts": { - "build:assets": "mkdir -p dist && cp -R node_modules/vis/dist/{vis.min.css,img} dist && cp source/custom.css dist && cp source/index.html dist;", + "build:assets": "mkdir -p dist && cp node_modules/vis-network/dist/dist/vis-network.min.css dist/ && cp -R node_modules/vis-network/dist/img dist/ && cp source/custom.css dist && cp source/index.html dist", "build:dev": "browserify source/main.js -t babelify -d -o dist/main.js", "build:prod": "env NODE_ENV=production browserify source/main.js -t babelify -o tmp.js && env NODE_ENV=production uglifyjs -c -m -o dist/main.js tmp.js && rm tmp.js" }, @@ -15,6 +15,7 @@ }, "dependencies": { "immutable": "^3.8.1", - "vis": "^4.20.1" + "vis-data": "^6.6.1", + "vis-network": "^7.10.0" } } diff --git a/web/source/index.html b/web/source/index.html index c620c64..09cdef0 100644 --- a/web/source/index.html +++ b/web/source/index.html @@ -26,7 +26,7 @@ <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>likely music</title> <link rel="stylesheet" type="text/css" href="custom.css"> - <link rel="stylesheet" type="text/css" href="vis.min.css"> + <link rel="stylesheet" type="text/css" href="vis-network.min.css"> <script src="main.js"></script> </head> <body> diff --git a/web/source/main.js b/web/source/main.js index 6f0ec7c..fe2ba2b 100644 --- a/web/source/main.js +++ b/web/source/main.js @@ -15,7 +15,7 @@ // You should have received a copy of the GNU Affero General Public License // along with likely music. If not, see <http://www.gnu.org/licenses/>. -import vis from 'vis'; +import { Network } from 'vis-network'; import { Map } from 'immutable'; // types / internals @@ -236,16 +236,16 @@ function collectGraphData(nodeData, edgeData) { function importGraphData(g) { nodeData = new Map(); edgeData = new Map(); - var nodeSet = new vis.DataSet({}); - var edgeSet = new vis.DataSet({}); - for(let node of g.nodes) { + + var nodeArr = g.nodes.map(function (node) { var music = Music.fromObject(node.music); var data = { id: node.id, label: music.nodeText() }; nodeData = nodeData.set(node.id, { nodeData: data, music: node.music }); - nodeSet.add(data); - } - for(let edge of g.edges) { + return data; + }); + + var edgeArr = g.edges.map(function (edge) { var data = { id: edge.id, from: edge.from, @@ -253,10 +253,11 @@ function importGraphData(g) { label: `${edge.prob * 100}%` }; edgeData = edgeData.set(edge.id, { edgeData: data, prob: edge.prob }); - edgeSet.add(data); - } - network.setData({ nodes: nodeSet, edges: edgeSet }); + return data; + }); + + network.setData({ nodes: nodeArr, edges: edgeArr }); } // helper @@ -624,7 +625,7 @@ function init() { } }; - network = new vis.Network(container, {}, options); + network = new Network(container, {}, options); try { const score = localStorage.getItem('score'); diff --git a/web/yarn.lock b/web/yarn.lock index 9e2203a..c08065d 100644 --- a/web/yarn.lock +++ b/web/yarn.lock @@ -783,9 +783,9 @@ cached-path-relative@^1.0.0: integrity sha512-5r2GqsoEb4qMTTN9J+WzXfjov+hjxT+j3u5K+kIVNIwAd99DLCJE9pBIMP1qVeybV6JiijL385Oz0DcYxfbOIg== caniuse-lite@^1.0.30000844: - version "1.0.30001104" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001104.tgz#4e3d5b3b1dd3c3529f10cb7f519c62ba3e579f5d" - integrity sha512-pkpCg7dmI/a7WcqM2yfdOiT4Xx5tzyoHAXWsX5/HxZ3TemwDZs0QXdqbE0UPLPVy/7BeK7693YfzfRYfu1YVpg== + version "1.0.30001105" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001105.tgz#d2cb0b31e5cf2f3ce845033b61c5c01566549abf" + integrity sha512-JupOe6+dGMr7E20siZHIZQwYqrllxotAhiaej96y6x00b/48rPt42o+SzOSCPbrpsDWvRja40Hwrj0g0q6LZJg== chalk@^1.1.3: version "1.1.3" @@ -903,24 +903,6 @@ create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7: safe-buffer "^5.0.1" sha.js "^2.4.8" -cross-env@^5.0.5: - version "5.2.1" - resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.2.1.tgz#b2c76c1ca7add66dc874d11798466094f551b34d" - integrity sha512-1yHhtcfAd1r4nwQgknowuUNfIT9E8dOMMspC36g45dN+iD1blloi7xp8X/xAIDnjHWyt1uQ8PHk2fkNaym7soQ== - dependencies: - cross-spawn "^6.0.5" - -cross-spawn@^6.0.5: - version "6.0.5" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" - integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== - dependencies: - nice-try "^1.0.4" - path-key "^2.0.1" - semver "^5.5.0" - shebang-command "^1.2.0" - which "^1.2.9" - crypto-browserify@^3.0.0: version "3.12.0" resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" @@ -1010,9 +992,9 @@ duplexer2@^0.1.2, duplexer2@~0.1.0, duplexer2@~0.1.2: readable-stream "^2.0.2" electron-to-chromium@^1.3.47: - version "1.3.502" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.502.tgz#6a55e993ef60a01fbdc2152ef5e47ee00c885c98" - integrity sha512-TIeXOaHAvfP7FemGUtAJxStmOc1YFGWFNqdey/4Nk41L9b1nMmDVDGNMIWhZJvOfJxix6Cv5FGEnBK+yvw3UTg== + version "1.3.504" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.504.tgz#54d6288202f8453053c006eb862e2e3b7bc867a5" + integrity sha512-yOXnuPaaLAIZUVuXHYDCo3EeaiEfbFgYWCPH1tBMp+jznCq/zQYKnf6HmkKBmLJ0VES81avl18JZO1lx/XAHOw== elliptic@^6.0.0, elliptic@^6.5.2: version "6.5.3" @@ -1027,11 +1009,6 @@ elliptic@^6.0.0, elliptic@^6.5.2: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.0" -emitter-component@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/emitter-component/-/emitter-component-1.1.1.tgz#065e2dbed6959bf470679edabeaf7981d1003ab6" - integrity sha1-Bl4tvtaVm/RwZ57avq95gdEAOrY= - escape-string-regexp@^1.0.2: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" @@ -1092,11 +1069,6 @@ globals@^9.18.0: resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" integrity sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ== -hammerjs@^2.0.8: - version "2.0.8" - resolved "https://registry.yarnpkg.com/hammerjs/-/hammerjs-2.0.8.tgz#04ef77862cff2bb79d30f7692095930222bf60f1" - integrity sha1-BO93hiz/K7edMPdpIJWTAiK/YPE= - has-ansi@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" @@ -1238,11 +1210,6 @@ isarray@~1.0.0: resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= - "js-tokens@^3.0.0 || ^4.0.0": version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -1285,11 +1252,6 @@ jsonparse@^1.2.0: resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" integrity sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA= -keycharm@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/keycharm/-/keycharm-0.2.0.tgz#fa6ea2e43b90a68028843d27f2075d35a8c3e6f9" - integrity sha1-+m6i5DuQpoAohD0n8gddNajD5vk= - labeled-stream-splicer@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/labeled-stream-splicer/-/labeled-stream-splicer-2.0.2.tgz#42a41a16abcd46fd046306cf4f2c3576fffb1c21" @@ -1382,21 +1344,11 @@ module-deps@^4.0.8: through2 "^2.0.0" xtend "^4.0.0" -moment@^2.18.1: - version "2.27.0" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.27.0.tgz#8bff4e3e26a236220dfe3e36de756b6ebaa0105d" - integrity sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ== - ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= -nice-try@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" - integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== - object-assign@^4.0.0, object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" @@ -1458,11 +1410,6 @@ path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= -path-key@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" - integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= - path-parse@^1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" @@ -1504,13 +1451,6 @@ process@~0.11.0: resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI= -propagating-hammerjs@^1.4.6: - version "1.4.7" - resolved "https://registry.yarnpkg.com/propagating-hammerjs/-/propagating-hammerjs-1.4.7.tgz#671ab1791a7f88b9dccce8fd8b14a9655950e7d6" - integrity sha512-oW9Wd+W2Tp5uOz6Fh4mEU7p+FoyU85smLH/mPga83Loh0pHa6AH4ZHGywvwMk3TWP31l7iUsvJyW265p4Ipwrg== - dependencies: - hammerjs "^2.0.8" - public-encrypt@^4.0.0: version "4.0.3" resolved "https://registry.yarnpkg.com/public-encrypt/-/public-encrypt-4.0.3.tgz#4fcc9d77a07e48ba7527e7cbe0de33d0701331e0" @@ -1676,7 +1616,7 @@ safe-buffer@~5.1.0, safe-buffer@~5.1.1: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -semver@^5.3.0, semver@^5.5.0: +semver@^5.3.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== @@ -1704,18 +1644,6 @@ shasum@^1.0.0: json-stable-stringify "~0.0.0" sha.js "~2.4.4" -shebang-command@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" - integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= - dependencies: - shebang-regex "^1.0.0" - -shebang-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" - integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= - shell-quote@^1.6.1: version "1.7.2" resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.2.tgz#67a7d02c76c9da24f99d20808fcaded0e0e04be2" @@ -1923,16 +1851,15 @@ util@~0.10.1: dependencies: inherits "2.0.3" -vis@^4.20.1: - version "4.21.0" - resolved "https://registry.yarnpkg.com/vis/-/vis-4.21.0.tgz#dd71638bff7f6495d00bc9f40c253526133ded6b" - integrity sha1-3XFji/9/ZJXQC8n0DCU1JhM97Ws= - dependencies: - emitter-component "^1.1.1" - hammerjs "^2.0.8" - keycharm "^0.2.0" - moment "^2.18.1" - propagating-hammerjs "^1.4.6" +vis-data@^6.6.1: + version "6.6.1" + resolved "https://registry.yarnpkg.com/vis-data/-/vis-data-6.6.1.tgz#2aa52e46c305ad46bb7abe6e7634e2eecd743b15" + integrity sha512-xmujDB2Dzf8T04rGFJ9OP4OA6zRVrz8R9hb0CVKryBrZRCljCga9JjSfgctA8S7wdZu7otDtUIwX4ZOgfV/57w== + +vis-network@^7.10.0: + version "7.10.0" + resolved "https://registry.yarnpkg.com/vis-network/-/vis-network-7.10.0.tgz#85f7721ace8de39de80faa17799f4ab5bdcf16a8" + integrity sha512-SYQ3y+cGqcFpPfaQbpGBXsaQjjbQq5xjt5dVztCD6x5ETQHlAYaFiYiWnVo0qoVI9lspfwoCfp4wOhW+rvId6Q== vm-browserify@~0.0.1: version "0.0.4" @@ -1941,13 +1868,6 @@ vm-browserify@~0.0.1: dependencies: indexof "0.0.1" -which@^1.2.9: - version "1.3.1" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" - integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== - dependencies: - isexe "^2.0.0" - wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" |