{"name":"elkjs","version":"0.7.2-dev","keywords":["graph","layout","layered","ports","dataflow"],"author":{"name":"Ulf Rüegg","email":"uruurumail@gmail.com"},"license":"EPL-1.0","_id":"elkjs@0.7.2-dev","maintainers":[{"name":"uruuru","email":"uruurumail@gmail.com"},{"name":"spoenemann","email":"miro.spoenemann@typefox.io"}],"homepage":"https://github.com/kieler/elkjs#readme","bugs":{"url":"https://github.com/kieler/elkjs/issues"},"dist":{"shasum":"20bbbc3e43c266c2d351ae2a51c736f4d70d20ef","tarball":"http://registry-npm.ywwl.com/elkjs/download/elkjs-0.7.2-dev.tgz","fileCount":11,"integrity":"sha512-EmwFg1qAckTeSEeyDjGE/QSqp0Y8bOpEBGCgF2I58zOMMjVo9drcz2UXcMzyL2Op18Yjad2+sAu/BKlLx2bqYA==","signatures":[{"sig":"MEQCIAuc07Z13UW1CqMZW64+BARYIv+WfTSbW4r4GL/b6Hv0AiBGtRbu1fn16moFHbISqep4ewNVBtDZbBZT+GHOSZuAqw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":7441087,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg8IV5CRA9TVsSAnZWagAAN/wQAITO7BD5gy1RL51lFW5I\nhxv2VS5jtPQ14r1igC0qG2M2uezy2aINQq0fezKHILWqfE5VO6mTsqWnJquA\nLZT6LvlRwBz9z+ov6IXp2Nuj03ZMwJoHvyIKw+BighIa6KWvAgyKEbOJcDwk\nK2qzO3v4nkEdpFLczKhsBEtnIVavTCw+s6mxM+EdDcRlQCpa7mHsHWv+uFYG\nZf2HWn2dudD5mQAa/Ji36DaK1mGpUyjxf/mkE73aurV9MgeMP8YFRWnK6t7X\nYvEvW6/9qw8gfyRevRhVvaiYXbPU3b7bhJdxKIgG6OxW411wPH+FInRJDRwn\n3JVz1frPgbMro+ME4eB4v3QEsORhkEi5CqB7LhA3gxIiD13hV/ywkcVjZjpk\nma3Kh1sbrWb+j7wRtLLK7gFLacmtPvBSPiYvjGIcn+0+h0LXObrk54tEj47Q\nGGGS1nCIuTkCWjyGD4jZa6B0WhZIA0kL38OvW/HlB8os5MX6XSK6do6dZHCZ\npwGlAiDAi+OoVFF3vx+6N5rI0l17cxrDpHJvheeIZSnvZlfQu9fZpZ/6F8G3\nAntmzJNX4eB0bnenwT6MmcH/kpwuj3PMN7+l7Nfz6XuJTnym6lfLXScwysh0\n/JAqA/hj2RO2xpyI6udHbv4xL8zGpSWEla3+rUWJCQzyxQvwNal1ZAya48oG\n97yi\r\n=3Qov\r\n-----END PGP SIGNATURE-----\r\n","size":1576704,"noattachment":false,"key":"/elkjs/-/elkjs-0.7.2-dev.tgz"},"main":"lib/main","types":"lib/main","readme":"<p align=\"center\">\n  <img src=\"https://raw.githubusercontent.com/kieler/elkjs/master/doc/elk_logo_with_text.svg?sanitize=true\" height=\"100\"> \n</p>\n\nThe [Eclipse Layout Kernel (ELK)](https://www.eclipse.org/elk/) implements an infrastructure to connect diagram editors or viewers to automatic layout algorithms. This library takes the layout-relevant part of ELK and makes it available to the JavaScript world.\nELK's flagship is a layer-based layout algorithm that is particularly suited for node-link diagrams with an inherent direction and ports (explicit attachment points on a node's border). It is based on the ideas originally introduced by Sugiyama et al. An example can be seen in the screenshot below.\n\nNote that elkjs is not a diagramming framework itself - it computes positions for the elements of a diagram. \n\nelkjs is the successor of [klayjs](https://github.com/kieler/klayjs).\n\n#### Demonstrator\nYou can see elkjs [live in action](https://rtsys.informatik.uni-kiel.de/elklive/) in conjunction with TypeFox's [sprotty](https://github.com/eclipse/sprotty) diagramming framework.\n\n![](https://raw.githubusercontent.com/kieler/elkjs/master/doc/example_complexRouter.svg?sanitize=true)\n\n# Installation\nThe latest released version:\n```bash\nnpm install elkjs\n```\nDevelopment version based on ELK's `master` branch.\n```bash\nnpm install elkjs@next\n```\n\n# Releases and Versioning\n\nReleases are partly synchronized with ELK's versions: the minor version number is always the same but the revision number may diverge. For instance, elkjs 0.3.0 equals the functionality of ELK 0.3.0 but elkjs 0.3.2 may be different from ELK 0.3.2. This is necessary as there may be fixes that solely concern elkjs and should be released independently of ELK.\n\n#  Files\nThe library consists of two main files:\n* `elk-api.js`: Provides the API and only the API.\n* `elk-worker.js`: Provides the code that actually knows how to lay out a graph. This is the file that is generated from ELK's Java code base using GWT.\n\nTwo further files are provided:\n* `elk.bundled.js`: A bundled version of the two previous files, ready to be dropped into a browser's `<script>` tag. The file is processed by [browserify](http://browserify.org/) and the `ELK` is exposed as a global variable (if run in a browser).\n* `main.js`: Main file of the node.js module. Allows to conveniently write `require('elkjs')` instead of composing the files from above.\n\n# Example\nA small example using node.js,\nfor further use cases see the next section.\n```js\nconst ELK = require('elkjs')\nconst elk = new ELK()\n\nconst graph = {\n  id: \"root\",\n  layoutOptions: { 'elk.algorithm': 'layered' },\n  children: [\n    { id: \"n1\", width: 30, height: 30 },\n    { id: \"n2\", width: 30, height: 30 },\n    { id: \"n3\", width: 30, height: 30 }\n  ],\n  edges: [\n    { id: \"e1\", sources: [ \"n1\" ], targets: [ \"n2\" ] },\n    { id: \"e2\", sources: [ \"n1\" ], targets: [ \"n3\" ] }\n  ]\n}\n\nelk.layout(graph)\n   .then(console.log)\n   .catch(console.error)\n```\nNote that in case you get errors, you may want to switch to the non-minified version \nto get a proper stack trace.\n\n## Layout Options\n\nYou can use _layout options_ to configure the layout algorithm.\nFor that you attach a `layoutOptions` object\nto the graph element that holds key/value pairs\nrepresenting the desired layout options.\nSee, for instance, `root` in the example above.\nIt is possible to only use the suffix of a layout option:\n`algorithm` instead of `org.eclipse.elk.layered`.\nHowever, if the suffix is not unique the layout option\nmay be ignored. To be save, you should always start the\nlayout options with the `elk.` part.\nA list of all options and further details of their exact effects\nis available in [ELK's documentation](http://www.eclipse.org/elk/reference.html).\n\nIt is possible to pass global layout options\nas part of the `layout` method's second argument.\nThe options are then applied to every graph element\nunless the element specifies the option itself:\n```js\nelk.layout(graph, {\n  layoutOptions: { ... }\n})\n```\n\nAdditionally, `ELK`'s constructor accepts an object\nwith layout options that is used with every\n`layout` call that does not specify layout options:\n```js\nconst elk = new ELK({\n  defaultLayoutOptions: { ... }\n})\n```\n\n# Usage\n\nSince laying out diagrams can be a time-consuming job\n(even for the computer),\nand since we don't want to freeze your UI,\nWeb Workers are supported out of the box.\nThe following examples illustrate how the library can be used either\nwith and without a Web Worker.\n\n## node.js\n\n```js\nconst ELK = require('elkjs')\n// without web worker\nconst elk = new ELK()\n\nelk.layout(graph)\n   .then(console.log)\n```\n\n```js\nconst ELK = require('elkjs')\n// with web worker\nconst elk = new ELK({\n  workerUrl = './node_modules/elkjs/lib/elk-worker.min.js'\n})\n\nelk.layout(graph)\n   .then(console.log)\n```\n\nSince version 10.x, node.js comes with a worker threads implementation that is similar to,\nbut not equal to, a browser's `Worker` class.\nTo ease implementation on our side, we use a library, `web-worker`, \nthat provides a wrapper around node's `worker_threads`, which is API-compatible to a browser's `Worker.\nAny other library that provides the standard Web Worker methods should be fine though.\nThe package is not installed automatically to avoid\nthe unnecessary dependency for everyone who is not\ninterested in using a web worker.\nA warning is raised if one requests a web worker\nwithout having installed the package.\nelkjs falls back to the non-Web Worker version in that case.\n\n## Browser\n\n```html\n<html>\n  <script src=\"./elk.bundled.js\"></script>\n  <script type=\"text/javascript\">\n    const elk = new ELK()\n\n    elk.layout(graph)\n       .then(function(g) {\n         document.body.innerHTML = \"<pre>\" + JSON.stringify(g, null, \" \") + \"</pre>\"\n       })\n  </script>\n</html>\n```\n\n```html\n<html>\n  <script src=\"./elk-api.js\"></script> <!-- use elk-api.js here! -->\n  <script type=\"text/javascript\">\n    const elk = new ELK({\n      workerUrl: './elk-worker.js'\n    })\n\n    elk.layout(graph)\n       .then(function(g) {\n         document.body.innerHTML = \"<pre>\" + JSON.stringify(g, null, \" \") + \"</pre>\"\n       })\n  </script>\n</html>\n```\n\n## Typescript\n```ts\nimport ELK from 'elkjs/lib/elk.bundled.js'\nconst elk = new ELK()\n\n\nimport ELK from 'elkjs/lib/elk-api'\nconst elk = new ELK({\n  workerUrl: './elk-worker.min.js'\n})\n```\n\n## Debugging\nFor debugging purposes you may want to use the non-minified versions that are available as well.\nIn this case the non-minified webworker version can be configured like so:\n```js\nconst ELK = require('elkjs/lib/elk-api.js')\nconst elk = new ELK({\n    workerFactory: function(url) { // the value of 'url' is irrelevant here\n        const { Worker } = require('elkjs/lib/elk-worker.js') // non-minified\n        return new Worker(url)\n    }\n})\n```\n\n# API\n\nThe elkjs library provides a single object: the `ELK`. The `ELK` has a constructor that can be used\nto construct it:\n* `new ELK(options)` - the `ELK` can be fed with options, all of which are optional:\n  * `defaultLayoutOptions` - an object with default layout options specified as key/value pairs\n        that are used if no further layout options are passed to the `layout(graph, options)` method (see below). Default: `{}`.\n  * `algorithms` - an array of algorithm ids (only the suffix). Default: `[ 'layered', 'stress', 'mrtree', 'radial', 'force', 'disco' ]`. Note that the `box`, `fixed`, and `random` layouters are always included.\n  * `workerUrl` - a path to the  `elk-worker.js` script. As a consequence the `ELK` will use a Web Worker to execute the layout. Default: `undefined`.\n\nApart from that the `ELK` offers the following methods:\n* `layout(graph, options)`\n  * `graph` - the graph to be laid out in [ELK JSON](http://www.eclipse.org/elk/documentation/tooldevelopers/graphdatastructure/jsonformat.html). Mandatory!\n  * `options` - a configuration object. Optional.\n    * `layoutOptions`: its most important purpose is to pass _global_ layout options.\n      That is, layout options that are applied to every graph element unless the element specifies the option itself.\n    * `logging`: boolean (_since 0.6.0_). Whether logging information shall be passed back as part of the laid out graph. `false` by default.\n    * `measureExecutionTime`: boolean (_since 0.6.0_). Whether execution time (in seconds) information shall be passed back as part of the laid out graph. `false` by default.\n  * returns a `Promise`, which passes either the laid out graph on success or a (hopefully helpful) error on failure.\n* `knownLayoutOptions()`\n  * returns an array of of known layout options. For each option additional information\n    such as its `id` and `group` is given.\n* `knownLayoutAlgorithms()`\n  * returns an array of registered layout algorithms (see above)\n    alongside further information about each algorithm.\n* `knownLayoutCategories()`\n  * returns an array of registered layout categories.\n* `terminateWorker()` - in case a Web Worker is used, the worker's `terminate()` method is called.\n\nThe three methods starting with `known` basically return information\nthat, in the Java world, would be retrieved from the [`LayoutMetaDataService`](http://www.eclipse.org/elk/documentation/algorithmdevelopers/metadatalanguage.html).\n\n\n# Logging and Execution Times\n(_Since 0.6.0_)\n\nELK provides some means to log debug information during layout algorithm execution.\nThe details can be found in the [_Algorithm Debugging_](https://www.eclipse.org/elk/documentation/algorithmdevelopers/algorithmdebugging.html) section of ELK's documentation.\nNot all of it is available in elkjs though, for instance, it is not possible to save intermediate results of the laid out graphs.\nFurthermore, while internally execution time is measured in _nanoseconds_ on the Java side,\nin elkjs we have to resort to _milliseconds_.\nNote that the returned execution times are in seconds.\nFor small graphs this may often result in execution times being reported as `0`.\n\nSee below an example call and the example output.\n```js\nelk.layout(simpleGraph, {\n    layoutOptions: {\n        'algorithm': 'layered'\n    },\n    logging: true,\n    measureExecutionTime: true\n})\n```\n```js\n{\n  \"id\": \"root\",\n  \"children\": [ ... ],\n  \"edges\": [ ... ],\n  \"logging\": {\n    \"name\": \"Recursive Graph Layout\",\n    \"executionTime\": 0.000096,\n    \"children\": [ {\n      \"name\": \"Layered layout\",\n      \"logs\": [\n        \"ELK Layered uses the following 17 modules:\",\n        \"   Slot 01: org.eclipse.elk.alg.layered.p1cycles.GreedyCycleBreaker\",\n            [ ... ]\n        \"   Slot 16: org.eclipse.elk.alg.layered.intermediate.ReversedEdgeRestorer\"\n      ],\n      \"executionTime\": 0.000072,\n      \"children\": [ { \"name\": \"Greedy cycle removal\", \"executionTime\": 0.000002 },\n                      [ ... ]\n                    { \"name\": \"Restoring reversed edges\", \"executionTime\": 0 } ]\n    } ]\n  }\n}\n```\n\n# Building\n\n[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/kieler/elkjs)\n\nFor building, a checkout of the [ELK](https://github.com/eclipse/elk) repository is required\nand should be located in the same directory as the checkout of this repository. Like so:\n\n```\nsome_dir/\n ├── elkjs\n └── elk\n```\n\n```bash\nnpm install\nnpm run build\n```\n\nFor a new release, the following version numbers have to be changed:\n* `version` in `package.json`,\n* `melk` in `build.gradle`, and\n* don't forget to checkout the correct release tag of ELK's repository.\n\nAfterwards you can find the created files in the `lib` folder.\n\nCurrent procedure\n```bash\ngit checkout -b releases/0.x.x\n# Update versions and commit the changes\nnpm install\nnpm run build\nnpm run test\n# Add ./lib/ directory and commit\ngit tag 0.x.x\n# Push release branch an tags to remote\nnpm publish\n```\n\n# Links\nIn the following a list of asorted links to other projects and sites that may prove helpful:\n* [Execution time comparison to Java ELK](https://github.com/kieler/elk-speed) \n* Schematics\n  - [netlistsvg](https://github.com/nturley/netlistsvg) - electronic and gate level schematics as SVG\n  - [d3-hwschematic](https://github.com/Nic30/d3-hwschematic) - interactive digital circuit analysis and documentation, particularly for FPGA-based designs\n* Visualizing [npm dependencies](http://npm-dependencies.com) \n* How to specify [node label placement](http://kieler.github.io/klayjs-d3/examples/node_labels/)\n* How to enforce certain [node positioning](http://kieler.github.io/klayjs-d3/examples/interactive/) (topological)\n* Wrapping elkjs into a [docker-based microservice](https://github.com/elbosso/elkjsmicroservice)\n* Cytoscape [adapter](https://github.com/cytoscape/cytoscape.js-elk)\n* [reaflow](https://reaflow.dev) - Node-based editor built on elkjs in React\n\n# Thanks\n\n* [@automata](https://github.com/automata) for the very first `klayjs` version\n* [@aranega](https://github.com/aranega) for making emfgwt work for us\n* [@EyMaddis](https://github.com/EyMaddis) for valuable API discussions\n* The team working on the layout algorithms\n  * [@spoenemann](https://github.com/spoenemann)\n  * [@le-cds](https://github.com/le-cds)\n  * [@uruuru](https://github.com/uruuru)\n  * [@eNBeWe](https://github.com/eNBeWe)\n  * the vast number of students that contributed to ELK\n","gitHead":"1b188ef6f4b720da55077a68977124d72a640f9a","scripts":{"cp":"cp build/js/elk-worker*.js lib/ && cp build/js/main-node.js lib/main.js && cp typings/*.d.ts lib/","js":"npm run babel && npm run browserify && npm run cp","test":"mocha test/mocha","babel":"babel src/js/ -d build/js/","build":"npm run gradle && npm run js","clean":"./gradlew clean && rm -r lib","gradle":"./gradlew lib","browserify":"mkdirp lib && npm run browserifyApi && npm run browserifyBundle","browserifyApi":"browserify build/js/main-api.js -s ELK --outfile lib/elk-api.js","setDevVersion":"npm version --no-git-tag-version \"$(node -p \"require('./package.json').version\")-dev-$(date '+%Y%m%d')\"","browserifyBundle":"browserify build/js/main-node.js -s ELK --outfile lib/elk.bundled.js"},"_npmUser":{"name":"uruuru","email":"uruurumail@gmail.com"},"repository":{"url":"git+https://github.com/kieler/elkjs.git","type":"git"},"_npmVersion":"6.14.6","description":"Automatic graph layout based on Sugiyama's algorithm. Specialized for data flow diagrams and ports.","directories":{},"_nodeVersion":"14.6.0","publishConfig":{"tag":"next","access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.0.2","mocha":"^6.2.0","mkdirp":"^0.5.0","babel-cli":"^6.24.1","browserify":"^14.4.0","web-worker":"^1.0.0","babel-preset-env":"^1.6.0","chai-as-promised":"^7.1.1"},"_npmOperationalInternal":{"tmp":"tmp/elkjs_0.7.2-dev_1626375545018_0.20534377533687986","host":"s3://npm-registry-packages"},"publish_time":1626375545345,"_cnpm_publish_time":1626375545345,"dist-tags":{"latest":"0.12.1"}}