Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cytoscape-cose-bilkent

Package Overview
Dependencies
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cytoscape-cose-bilkent - npm Package Compare versions

Comparing version 1.3.8 to 1.4.0

src/Layout/Emitter.js

2

bower.json
{
"name": "cytoscape-cose-bilkent",
"version": "1.3.8",
"version": "1.4.0",
"description": "The CoSE layout for Cytoscape.js by Bilkent",

@@ -5,0 +5,0 @@ "main": "cytoscape-cose-bilkent.js",

var gulp = require('gulp');
var util = require('gulp-util');
var notifier = require('node-notifier');
var path = require('path');

@@ -13,30 +15,104 @@ var replace = require('gulp-replace');

var browserify = require('browserify');
var watchify = require('watchify');
var babelify = require('babelify');
var buffer = require('vinyl-buffer');
var source = require('vinyl-source-stream');
var gutil = require('gulp-util');
var notifier = require('node-notifier');
var derequire = require('gulp-derequire');
var server = require('http-server');
var livereload = require('gulp-livereload');
var pkg = require('./package.json');
var version;
var browserifyOpts = {
entries: './src/index.js',
debug: true,
standalone: 'cytoscape-cose-bilkent'
var logError = function( err ){
notifier.notify({ title: pkg.name, message: 'Error: ' + err.message });
util.log( util.colors.red(err) );
};
var logError = function( err ){
notifier.notify({ title: 'cose-bilkent', message: 'Error: ' + err.message });
gutil.log( gutil.colors.red('Error in watch:'), gutil.colors.red(err) );
var handleErr = function( err ){
logError( err );
if( this.emit ){
this.emit('end');
}
};
gulp.task('build', function(){
return browserify( browserifyOpts )
var getBrowserified = function( opts ){
opts = Object.assign({
debug: true,
cache: {},
packageCache: {},
fullPaths: true,
bundleExternal: true,
entries: [ './src' ]
}, opts );
return browserify( opts ).on( 'log', util.log );
};
var transform = function( b ){
return ( b
// can't use babel because cose-bilkent does just use pure functions in workers...
// .transform( babelify.configure({
// presets: ['es2015'],
// ignore: 'node_modules/**/*',
// sourceMaps: 'inline'
// }) )
) ;
};
var bundle = function( b ){
return ( b
.bundle()
.on( 'error', logError )
.on( 'error', handleErr )
.pipe( source('cytoscape-cose-bilkent.js') )
.pipe( buffer() )
.pipe( derequire() )
.pipe( gulp.dest('.') )
) ;
};
gulp.task('build', function(){
return bundle( transform( getBrowserified() ) )
.pipe( gulp.dest('./') )
;
});
gulp.task('watch', function(){
livereload.listen({
basePath: process.cwd()
});
server.createServer({
root: './',
cache: -1,
cors: true
}).listen( '9999', '0.0.0.0' );
util.log( util.colors.green('Demo hosted on local server at http://localhost:9999/demo.html') );
gulp.watch( ['./cytoscape-cose-bilkent.js'] )
.on('change', livereload.changed)
;
var update = function(){
util.log( util.colors.white('JS rebuilding via watch...') );
bundle( b )
.pipe( gulp.dest('./') )
.on('finish', function(){
util.log( util.colors.green('JS rebuild finished via watch') );
})
;
};
var b = getBrowserified();
transform( b );
b.plugin( watchify, { poll: true } );
b.on( 'update', update );
update();
});
gulp.task('default', ['build'], function( next ){

@@ -47,3 +123,3 @@ next();

gulp.task('publish', [], function( next ){
runSequence('confver', 'lint', 'build', 'pkgver', 'push', 'tag', 'npm', 'spm', next);
runSequence('confver', 'lint', 'build', 'pkgver', 'push', 'tag', 'npm', next);
});

@@ -105,6 +181,2 @@

gulp.task('spm', shell.task([
'spm publish'
]));
// http://www.jshint.com/docs/options/

@@ -111,0 +183,0 @@ gulp.task('lint', function(){

{
"name": "cytoscape-cose-bilkent",
"version": "1.3.8",
"version": "1.4.0",
"description": "The CoSE layout for Cytoscape.js by Bilkent",

@@ -26,15 +26,20 @@ "main": "cytoscape-cose-bilkent.js",

"devDependencies": {
"browserify": "^11.2.0",
"babel-preset-es2015": "^6.16.0",
"babelify": "^7.3.0",
"browserify": "^13.1.0",
"gulp": "^3.9.0",
"gulp-derequire": "^2.1.0",
"gulp-jshint": "^1.11.2",
"gulp-livereload": "^3.8.1",
"gulp-prompt": "^0.1.2",
"gulp-replace": "^0.5.4",
"gulp-shell": "^0.5.0",
"gulp-util": "^3.0.6",
"gulp-util": "^3.0.7",
"http-server": "^0.9.0",
"jshint-stylish": "^2.0.1",
"node-notifier": "^4.3.1",
"node-notifier": "^4.6.1",
"run-sequence": "^1.1.4",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"
"vinyl-source-stream": "^1.1.0",
"watchify": "^3.7.0"
},

@@ -41,0 +46,0 @@ "peerDependencies": {

@@ -6,2 +6,5 @@ var FDLayout = require('./FDLayout');

var CoSEEdge = require('./CoSEEdge');
var CoSEConstants = require('./CoSEConstants');
var FDLayoutConstants = require('./FDLayoutConstants');
var LayoutConstants = require('./LayoutConstants');

@@ -156,3 +159,3 @@ function CoSELayout() {

}
broadcast({pData: pData});
this.emit('iterate', pData);
}

@@ -159,0 +162,0 @@ }

var FDLayoutNode = require('./FDLayoutNode');
var IMath = require('./IMath');

@@ -3,0 +4,0 @@ function CoSENode(gm, loc, size, vNode) {

var Layout = require('./Layout');
var FDLayoutConstants = require('./FDLayoutConstants');
var LayoutConstants = require('./LayoutConstants');
var IGeometry = require('./IGeometry');
var IMath = require('./IMath');

@@ -4,0 +7,0 @@ function FDLayout() {

'use strict';
var Thread;
var DimensionD = require('./DimensionD');

@@ -67,2 +65,4 @@ var HashMap = require('./HashMap');

animate: 'end',
// Duration for animate:end
animationDuration: 500,
// Represents the amount of the vertical space to put between the zero degree members during the tiling operation(can also be a function)

@@ -121,3 +121,3 @@ tilingPaddingVertical: 10,

CoSEConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = options.gravityRangeCompound;
CoSEConstants.DEFAULT_INCREMENTAL = FDLayoutConstants.DEFAULT_INCREMENTAL = LayoutConstants.DEFAULT_INCREMENTAL =

@@ -168,39 +168,2 @@ !(options.randomize);

var t1 = layout.thread;
if (!t1 || t1.stopped()) { // try to reuse threads
t1 = layout.thread = Thread();
t1.require(DimensionD, 'DimensionD');
t1.require(HashMap, 'HashMap');
t1.require(HashSet, 'HashSet');
t1.require(IGeometry, 'IGeometry');
t1.require(IMath, 'IMath');
t1.require(Integer, 'Integer');
t1.require(Point, 'Point');
t1.require(PointD, 'PointD');
t1.require(RandomSeed, 'RandomSeed');
t1.require(RectangleD, 'RectangleD');
t1.require(Transform, 'Transform');
t1.require(UniqueIDGeneretor, 'UniqueIDGeneretor');
t1.require(LGraphObject, 'LGraphObject');
t1.require(LGraph, 'LGraph');
t1.require(LEdge, 'LEdge');
t1.require(LGraphManager, 'LGraphManager');
t1.require(LNode, 'LNode');
t1.require(Layout, 'Layout');
t1.require(LayoutConstants, 'LayoutConstants');
t1.require(FDLayout, 'FDLayout');
t1.require(FDLayoutConstants, 'FDLayoutConstants');
t1.require(FDLayoutEdge, 'FDLayoutEdge');
t1.require(FDLayoutNode, 'FDLayoutNode');
t1.require(CoSEConstants, 'CoSEConstants');
t1.require(CoSEEdge, 'CoSEEdge');
t1.require(CoSEGraph, 'CoSEGraph');
t1.require(CoSEGraphManager, 'CoSEGraphManager');
t1.require(CoSELayout, 'CoSELayout');
t1.require(CoSENode, 'CoSENode');
}
var nodes = this.options.eles.nodes();

@@ -217,3 +180,3 @@ var edges = this.options.eles.edges();

var nodeIdMap = {};
//Fill the map in linear time

@@ -229,6 +192,6 @@ for(var i = 0; i < nodes.length; i++){

var cyNode = this.options.cy.getElementById(nodeId);
var parentId = cyNode.data('parent');
parentId = nodeIdMap[parentId]?parentId:undefined;
var w = lnode.rect.width;

@@ -270,12 +233,6 @@ var posX = lnode.rect.x;

t1.pass(pData).run(function (pData) {
var log = function (msg) {
broadcast({log: msg});
};
var layout_t = new CoSELayout();
log("start thread");
//the layout will be run in the thread and the results are to be passed
//to the main thread with the result map
var layout_t = new CoSELayout();
var run = (function (pData) {
// the layout will be run and the results are to be returned with the result map
var gm_t = layout_t.newGraphManager();

@@ -289,3 +246,3 @@ var ngraph = gm_t.layout.newGraph();

//maps for inner usage of the thread
//maps for inner usage
var orphans_t = [];

@@ -296,6 +253,5 @@ var idToLNode_t = {};

//A map of node id to corresponding node position and sizes
//it is to be returned at the end of the thread function
//it is to be returned at the end of the function
var result = {};
//this function is similar to processChildrenList function in the main thread
//it is to process the nodes in correct order recursively

@@ -366,3 +322,3 @@ var processNodes = function (parent, children) {

//run the layout crated in this thread
//run the layout
layout_t.runLayout();

@@ -385,9 +341,13 @@

seeds.rsX = RandomSeed.x;
var pass = {
result: result,
seeds: seeds
}
};
//return the result map to pass it to the then function as parameter
return pass;
}).then(function (pass) {
});
var done = (function (pass) {
var result = pass.result;

@@ -428,6 +388,6 @@ var seeds = pass.seeds;

after.options.eles.nodes().positions(getPositions);
if (after.options.fit)
after.options.cy.fit(after.options.eles.nodes(), after.options.padding);
//trigger layoutready when each node has had its position set at least once

@@ -438,3 +398,3 @@ if (!ready) {

}
// trigger layoutstop when the layout stops (e.g. finishes)

@@ -444,15 +404,8 @@ after.cy.one('layoutstop', after.options.stop);

}
t1.stop();
after.options.eles.nodes().removeScratch('coseBilkent');
});
t1.on('message', function (e) {
var logMsg = e.message.log;
if (logMsg != null) {
console.log('Thread log: ' + logMsg);
return;
}
var pData = e.message.pData;
if (pData != null) {
layout_t.addListener('iterate', function (pData) {
if (pData != null && after.options.animate && after.options.animate !== 'end') {
after.options.eles.nodes().positions(function (i, ele) {

@@ -492,2 +445,4 @@ if (ele.scratch('coseBilkent') && ele.scratch('coseBilkent').dummy_parent_id) {

done( run( pData ) );
return this; // chaining

@@ -577,3 +532,3 @@ };

_CoSELayout.prototype.groupZeroDegreeMembers = function () {
// array of [parent_id x oneDegreeNode_id]
// array of [parent_id x oneDegreeNode_id]
var tempMemberGroups = [];

@@ -583,7 +538,7 @@ var memberGroups = [];

var parentMap = {};
for(var i = 0; i < this.options.eles.nodes().length; i++){
parentMap[this.options.eles.nodes()[i].id()] = true;
}
// Find all zero degree nodes which aren't covered by a compound

@@ -595,3 +550,3 @@ var zeroDegree = this.options.eles.nodes().filter(function (i, ele) {

}
if (self.getNodeDegreeWithChildren(ele) == 0 && (pid == undefined || (pid != undefined && !self.getToBeTiled(ele.parent()[0]))))

@@ -608,3 +563,3 @@ return true;

var p_id = node.parent().id();
if(p_id != undefined && !parentMap[p_id]){

@@ -646,3 +601,3 @@ p_id = undefined;

scratchObj = {};
node.scratch('coseBilkent', scratchObj);
node.scratch('coseBilkent', scratchObj);
}

@@ -702,3 +657,3 @@ scratchObj['dummy_parent_id'] = dummyCompoundId;

// Remove children of compounds
// Remove children of compounds
lCompoundNode.child = null;

@@ -745,3 +700,3 @@ }

var verticalMargin = parseInt(compound.css('padding-top'));
// Adjust the positions of nodes wrt its compound

@@ -761,3 +716,3 @@ this.adjustLocations(tiledPack[i], compoundNode.rect.x, compoundNode.rect.y, horizontalMargin, verticalMargin);

/**
* This method places each zero degree member wrt given (x,y) coordinates (top left).
* This method places each zero degree member wrt given (x,y) coordinates (top left).
*/

@@ -852,3 +807,3 @@ _CoSELayout.prototype.adjustLocations = function (organization, x, y, compoundHorizontalMargin, compoundVerticalMargin) {

var lNode = layoutNodes[i];
var cyNode = this.cy.getElementById(lNode.id).parent()[0];

@@ -859,3 +814,3 @@ var minWidth = 0;

}
if (organization.rows.length == 0) {

@@ -1051,6 +1006,2 @@ this.insertNodeToRow(organization, lNode, 0, minWidth);

if( this.thread ){
this.thread.stop();
}
this.trigger('layoutstop');

@@ -1099,5 +1050,3 @@

module.exports = function get(cytoscape) {
Thread = cytoscape.Thread;
return _CoSELayout;
};
var LayoutConstants = require('./LayoutConstants');
var HashMap = require('./HashMap');
var LGraphManager = require('./LGraphManager');
var LNode = require('./LNode');
var LEdge = require('./LEdge');
var LGraph = require('./LGraph');
var PointD = require('./PointD');
var Transform = require('./Transform');
var Emitter = require('./Emitter');
var HashSet = require('./HashSet');
function Layout(isRemoteUse) {
Emitter.call( this );
//Layout Quality: 0:proof, 1:default, 2:draft

@@ -45,2 +54,4 @@ this.layoutQuality = LayoutConstants.DEFAULT_QUALITY;

Layout.prototype = Object.create( Emitter.prototype );
Layout.prototype.getGraphManager = function () {

@@ -47,0 +58,0 @@ return this.graphManager;

var LGraphObject = require('./LGraphObject');
var IGeometry = require('./IGeometry');
var IMath = require('./IMath');

@@ -3,0 +5,0 @@ function LEdge(source, target, vEdge) {

@@ -6,2 +6,5 @@ var LGraphObject = require('./LGraphObject');

var LNode = require('./LNode');
var HashSet = require('./HashSet');
var RectangleD = require('./RectangleD');
var Point = require('./Point');

@@ -8,0 +11,0 @@ function LGraph(parent, obj2, vGraph) {

var LGraphObject = require('./LGraphObject');
var Integer = require('./Integer');
var RectangleD = require('./RectangleD');
var LayoutConstants = require('./LayoutConstants');
var RandomSeed = require('./RandomSeed');
var PointD = require('./PointD');

@@ -5,0 +8,0 @@ function LNode(gm, loc, size, vNode) {

@@ -0,1 +1,3 @@

var PointD = require('./PointD');
function Transform(x, y) {

@@ -2,0 +4,0 @@ this.lworldOrgX = 0.0;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc