cytoscape
Advanced tools
Comparing version 3.15.3 to 3.16.0
{ | ||
"build/cytoscape.umd.js": { | ||
"bundled": 933435, | ||
"minified": 346672, | ||
"gzipped": 107945 | ||
"bundled": 933288, | ||
"minified": 346908, | ||
"gzipped": 108032 | ||
}, | ||
"build/cytoscape.cjs.js": { | ||
"bundled": 860390, | ||
"minified": 366054, | ||
"gzipped": 110360 | ||
"bundled": 860281, | ||
"minified": 366257, | ||
"gzipped": 110421 | ||
}, | ||
"build/cytoscape.esm.js": { | ||
"bundled": 860217, | ||
"minified": 365911, | ||
"gzipped": 110324, | ||
"bundled": 860108, | ||
"minified": 366114, | ||
"gzipped": 110383, | ||
"treeshaked": { | ||
"rollup": { | ||
"code": 341320, | ||
"code": 341556, | ||
"import_statements": 51 | ||
}, | ||
"webpack": { | ||
"code": 342708 | ||
"code": 342944 | ||
} | ||
@@ -27,12 +27,12 @@ } | ||
"build/cytoscape.esm.min.js": { | ||
"bundled": 346477, | ||
"minified": 345974, | ||
"gzipped": 107763, | ||
"bundled": 346713, | ||
"minified": 346215, | ||
"gzipped": 107857, | ||
"treeshaked": { | ||
"rollup": { | ||
"code": 345464, | ||
"code": 345709, | ||
"import_statements": 0 | ||
}, | ||
"webpack": { | ||
"code": 346752 | ||
"code": 346997 | ||
} | ||
@@ -39,0 +39,0 @@ } |
{ | ||
"name": "cytoscape", | ||
"version": "3.15.3", | ||
"version": "3.16.0", | ||
"license": "MIT", | ||
@@ -121,4 +121,6 @@ "description": "Graph theory (a.k.a. network) library for analysis and visualisation", | ||
"test:js": "mocha -r esm --recursive", | ||
"test:js:debug": "mocha inspect -r esm --recursive", | ||
"test:build": "cross-env TEST_BUILD=true mocha", | ||
"test:modules": "mocha -r esm test/modules", | ||
"test:modules:debug": "mocha inspect -r esm test/modules", | ||
"travis": "run-s build test:build test:modules lint", | ||
@@ -125,0 +127,0 @@ "docs": "run-s docs:build docs:js", |
@@ -13,3 +13,3 @@ <img style="width: 200px; height: 200px;" src="https://raw.githubusercontent.com/cytoscape/cytoscape.js/unstable/documentation/img/cytoscape-logo.png" width="200" height="200"></img> | ||
[![Download](https://img.shields.io/npm/v/cytoscape.svg?label=Download)](https://github.com/cytoscape/cytoscape.js/tree/master/dist) | ||
[![Extensions](https://img.shields.io/badge/Extensions-53-blue.svg)](https://js.cytoscape.org/#extensions) | ||
[![Extensions](https://img.shields.io/badge/Extensions-58-blue.svg)](https://js.cytoscape.org/#extensions) | ||
[![npm installs](https://img.shields.io/npm/dm/cytoscape.svg?label=npm%20installs)](https://www.npmjs.com/package/cytoscape) | ||
@@ -16,0 +16,0 @@ [![master branch tests](https://img.shields.io/travis/cytoscape/cytoscape.js/master.svg?label=master%20branch)](https://travis-ci.org/cytoscape/cytoscape.js) |
@@ -113,6 +113,6 @@ import * as is from '../../is'; | ||
if( edge != null ){ | ||
connectedEles.merge( edge ); | ||
connectedEles.push( edge ); | ||
} | ||
connectedEles.merge( node ); | ||
connectedEles.push( node ); | ||
} | ||
@@ -119,0 +119,0 @@ |
@@ -131,3 +131,3 @@ import * as is from '../../is'; | ||
result.found = true; | ||
result.trail = this.spawn( trail ); | ||
result.trail = this.spawn( trail, true ); | ||
return result; | ||
@@ -134,0 +134,0 @@ }, |
@@ -24,3 +24,3 @@ import Set from '../set'; | ||
return this.spawn( parents, { unique: true } ).filter( selector ); | ||
return this.spawn( parents, true ).filter( selector ); | ||
}, | ||
@@ -41,3 +41,3 @@ | ||
return this.spawn( parents, { unique: true } ).filter( selector ); | ||
return this.spawn( parents, true ).filter( selector ); | ||
}, | ||
@@ -84,3 +84,3 @@ | ||
return this.spawn( children, { unique: true } ).filter( selector ); | ||
return this.spawn( children, true ).filter( selector ); | ||
}, 'children' ), | ||
@@ -141,3 +141,3 @@ | ||
return this.spawn( elements, { unique: true } ).filter( selector ); | ||
return this.spawn( elements, true ).filter( selector ); | ||
} | ||
@@ -144,0 +144,0 @@ }); |
@@ -6,5 +6,3 @@ import * as util from '../util'; | ||
// represents a node or an edge | ||
let Element = function( cy, params, restore ){ | ||
restore = (restore === undefined || restore ? true : false); | ||
let Element = function( cy, params, restore = true ){ | ||
if( cy === undefined || params === undefined || !is.core( cy ) ){ | ||
@@ -11,0 +9,0 @@ util.error( 'An element must have a core reference and parameters set' ); |
@@ -22,5 +22,5 @@ import * as is from '../is'; | ||
if( ele.isNode() ){ | ||
nodes.merge(ele); | ||
nodes.push(ele); | ||
} else { | ||
edges.merge(ele); | ||
edges.push(ele); | ||
} | ||
@@ -46,3 +46,3 @@ } | ||
if( include ){ | ||
filterEles.merge( ele ); | ||
filterEles.push( ele ); | ||
} | ||
@@ -66,4 +66,3 @@ } | ||
let elements = []; | ||
let rMap = toRemove._private.map; | ||
let elements = this.spawn(); | ||
@@ -73,3 +72,3 @@ for( let i = 0; i < this.length; i++ ){ | ||
let remove = rMap.has( element.id() ); | ||
let remove = toRemove.has(element); | ||
if( !remove ){ | ||
@@ -80,3 +79,3 @@ elements.push( element ); | ||
return this.spawn( elements ); | ||
return elements; | ||
} | ||
@@ -99,19 +98,18 @@ | ||
let elements = []; | ||
let elements = this.spawn(); | ||
let col1 = this; | ||
let col2 = other; | ||
let col1Smaller = this.length < other.length; | ||
let map2 = col1Smaller ? col2._private.map : col1._private.map; | ||
let col = col1Smaller ? col1 : col2; | ||
let colS = col1Smaller ? col1 : col2; | ||
let colL = col1Smaller ? col2 : col1; | ||
for( let i = 0; i < col.length; i++ ){ | ||
let id = col[ i ]._private.data.id; | ||
let entry = map2.get( id ); | ||
for( let i = 0; i < colS.length; i++ ){ | ||
let ele = colS[i]; | ||
if( entry ){ | ||
elements.push( entry.ele ); | ||
if( colL.has(ele) ){ | ||
elements.push(ele); | ||
} | ||
} | ||
return this.spawn( elements ); | ||
return elements; | ||
}, | ||
@@ -126,3 +124,3 @@ | ||
let elements = []; | ||
let elements = this.spawn(); | ||
let col1 = this; | ||
@@ -147,3 +145,3 @@ let col2 = other; | ||
return this.spawn( elements ); | ||
return elements; | ||
}, | ||
@@ -158,5 +156,5 @@ | ||
let left = []; | ||
let right = []; | ||
let both = []; | ||
let left = this.spawn(); | ||
let right = this.spawn(); | ||
let both = this.spawn(); | ||
let col1 = this; | ||
@@ -173,3 +171,3 @@ let col2 = other; | ||
if( inOther ){ | ||
both.push( ele ); | ||
both.merge( ele ); | ||
} else { | ||
@@ -185,7 +183,3 @@ retEles.push( ele ); | ||
return { | ||
left: this.spawn( left, { unique: true } ), | ||
right: this.spawn( right, { unique: true } ), | ||
both: this.spawn( both, { unique: true } ) | ||
}; | ||
return { left, right, both }; | ||
}, | ||
@@ -205,19 +199,14 @@ | ||
let elements = []; | ||
let elements = this.spawnSelf(); | ||
for( let i = 0; i < this.length; i++ ){ | ||
elements.push( this[ i ] ); | ||
} | ||
let map = this._private.map; | ||
for( let i = 0; i < toAdd.length; i++ ){ | ||
let ele = toAdd[i]; | ||
let add = !map.has( toAdd[ i ].id() ); | ||
let add = !this.has(ele); | ||
if( add ){ | ||
elements.push( toAdd[ i ] ); | ||
elements.push(ele); | ||
} | ||
} | ||
return this.spawn( elements ); | ||
return elements; | ||
}, | ||
@@ -252,7 +241,2 @@ | ||
map.set( id, { ele: toAddEle, index: index } ); | ||
} else { // replace | ||
let index = map.get( id ).index; | ||
this[ index ] = toAddEle; | ||
map.set( id, { ele: toAddEle, index: index } ); | ||
} | ||
@@ -259,0 +243,0 @@ } |
@@ -24,18 +24,5 @@ import * as util from '../util'; | ||
// factory for generating edge ids when no id is specified for a new element | ||
let idFactory = { | ||
generate: function( cy, element, tryThisId ){ | ||
let id = tryThisId != null ? tryThisId : util.uuid(); | ||
while( cy.hasElementWithId( id ) ){ | ||
id = util.uuid(); | ||
} | ||
return id; | ||
} | ||
}; | ||
// represents a set of nodes, edges, or both together | ||
let Collection = function( cy, elements, options ){ | ||
if( cy === undefined || !is.core( cy ) ){ | ||
let Collection = function( cy, elements, unique = false ){ | ||
if( cy === undefined ){ | ||
util.error( 'A collection must have a reference to the core' ); | ||
@@ -68,3 +55,3 @@ return; | ||
if( data.id == null ){ | ||
data.id = idFactory.generate( cy, json ); | ||
data.id = util.uuid(); | ||
} else if( cy.hasElementWithId( data.id ) || elesIds.has( data.id ) ){ | ||
@@ -90,7 +77,9 @@ continue; // can't create element if prior id already exists | ||
if( options == null || ( options.unique && !map.has(id) ) ){ | ||
map.set( id, { | ||
index: this.length, | ||
ele: element | ||
} ); | ||
if( !unique || !map.has(id) ){ | ||
if( unique ){ | ||
map.set( id, { | ||
index: this.length, | ||
ele: element | ||
} ); | ||
} | ||
@@ -103,6 +92,30 @@ this[ this.length ] = element; | ||
this._private = { | ||
eles: this, | ||
cy: cy, | ||
map: map | ||
get map(){ | ||
if( this.lazyMap == null ){ | ||
this.rebuildMap(); | ||
} | ||
return this.lazyMap; | ||
}, | ||
set map(m){ | ||
this.lazyMap = m; | ||
}, | ||
rebuildMap(){ | ||
const m = this.lazyMap = new Map(); | ||
const eles = this.eles; | ||
for( let i = 0; i < eles.length; i++ ){ | ||
const ele = eles[i]; | ||
m.set(ele.id(), { index: i, ele }); | ||
} | ||
} | ||
}; | ||
if( unique ){ | ||
this._private.map = map; | ||
} | ||
// restore the elements if we created them from json | ||
@@ -119,3 +132,3 @@ if( createdElements ){ | ||
// and use elefn and elesfn as shorthands to the prototypes | ||
let elesfn = Element.prototype = Collection.prototype; | ||
let elesfn = Element.prototype = Collection.prototype = Object.create(Array.prototype); | ||
@@ -126,10 +139,4 @@ elesfn.instanceString = function(){ | ||
elesfn.spawn = function( cy, eles, opts ){ | ||
if( !is.core( cy ) ){ // cy is optional | ||
opts = eles; | ||
eles = cy; | ||
cy = this.cy(); | ||
} | ||
return new Collection( cy, eles, opts ); | ||
elesfn.spawn = function( eles, unique ){ | ||
return new Collection( this.cy(), eles, unique ); | ||
}; | ||
@@ -162,3 +169,3 @@ | ||
elesfn.unique = function(){ | ||
return new Collection( this._private.cy, this, { unique: true } ); | ||
return new Collection( this._private.cy, this, true ); | ||
}; | ||
@@ -399,3 +406,3 @@ | ||
} else if( data.id === undefined ){ | ||
data.id = idFactory.generate( cy, ele ); | ||
data.id = util.uuid(); | ||
@@ -537,3 +544,3 @@ } else if( is.number( data.id ) ){ | ||
if( elements.length > 0 ){ | ||
let restored = new Collection( cy, elements ); | ||
let restored = elements.length === self.length ? self : new Collection( cy, elements ); | ||
@@ -540,0 +547,0 @@ for( let i = 0; i < restored.length; i++ ){ |
@@ -95,3 +95,2 @@ import * as is from '../is'; | ||
let hasCompounds = cy.hasCompoundNodes(); | ||
let style = cy.style(); | ||
let updatedEles = this; | ||
@@ -105,3 +104,4 @@ | ||
let changedEles = style.apply( updatedEles ); | ||
// let changedEles = style.apply( updatedEles ); | ||
let changedEles = updatedEles; | ||
@@ -114,2 +114,4 @@ if( notifyRenderer ){ | ||
updatedEles.forEach(ele => ele._private.styleDirty = true); | ||
return this; // chaining | ||
@@ -126,2 +128,9 @@ }, | ||
if( ele ){ | ||
if( ele._private.styleDirty ){ | ||
ele._private.styleDirty = false; | ||
cy.style().apply(ele); | ||
ele.emitAndNotify('style'); | ||
} | ||
let overriddenStyle = ele._private.style[ property ]; | ||
@@ -128,0 +137,0 @@ |
@@ -43,3 +43,3 @@ import * as util from '../util'; | ||
return this.spawn( ret, { unique: true } ).filter( selector ); | ||
return this.spawn( ret, true ).filter( selector ); | ||
}; | ||
@@ -74,3 +74,3 @@ }; | ||
return this.spawn( oEles, { unique: true } ).filter( selector ); | ||
return this.spawn( oEles, true ).filter( selector ); | ||
}; | ||
@@ -107,3 +107,3 @@ }; | ||
return this.spawn( sEles, { unique: true } ).filter( selector ); | ||
return this.spawn( sEles, true ).filter( selector ); | ||
}; | ||
@@ -171,3 +171,3 @@ }; | ||
return ( this.spawn( elements, { unique: true } ) ).filter( selector ); | ||
return ( this.spawn( elements, true ) ).filter( selector ); | ||
}, 'neighborhood'), | ||
@@ -237,3 +237,3 @@ | ||
return this.spawn( sources, { unique: true } ).filter( selector ); | ||
return this.spawn( sources, true ).filter( selector ); | ||
}; | ||
@@ -284,3 +284,3 @@ } | ||
return this.spawn( elements, { unique: true } ); | ||
return this.spawn( elements, true ); | ||
}; | ||
@@ -306,3 +306,3 @@ } | ||
return this.spawn( retEles, { unique: true } ).filter( selector ); | ||
return this.spawn( retEles, true ).filter( selector ); | ||
}, 'connectedEdges'), | ||
@@ -322,3 +322,3 @@ | ||
return this.spawn( retEles, { unique: true } ).filter( selector ); | ||
return this.spawn( retEles, true ).filter( selector ); | ||
}, 'connectedNodes'), | ||
@@ -369,3 +369,3 @@ | ||
return this.spawn( elements, { unique: true } ).filter( selector ); | ||
return this.spawn( elements, true ).filter( selector ); | ||
}; | ||
@@ -372,0 +372,0 @@ |
@@ -21,3 +21,3 @@ import * as util from '../../util'; | ||
}, | ||
levelWidth: function( nodes ){ // the letiation of concentric values in each level | ||
levelWidth: function( nodes ){ // the variation of concentric values in each level | ||
return nodes.maxDegree() / 4; | ||
@@ -24,0 +24,0 @@ }, |
@@ -5,2 +5,4 @@ import * as math from '../../../../math'; | ||
/* global document */ | ||
let BRp = {}; | ||
@@ -472,43 +474,46 @@ | ||
let sizeMult = 1; // increase the scale to increase accuracy w.r.t. zoomed text | ||
let padding = 6; // add padding around text dims, as the measurement isn't that accurate | ||
let fStyle = ele.pstyle('font-style').strValue; | ||
let size = (sizeMult * ele.pstyle('font-size').pfValue) + 'px'; | ||
let size = ele.pstyle('font-size').pfValue; | ||
let family = ele.pstyle('font-family').strValue; | ||
let weight = ele.pstyle('font-weight').strValue; | ||
let div = this.labelCalcDiv; | ||
let canvas = this.labelCalcCanvas; | ||
let c2d = this.labelCalcCanvasContext; | ||
if( !div ){ | ||
div = this.labelCalcDiv = document.createElement( 'div' ); // eslint-disable-line no-undef | ||
document.body.appendChild( div ); // eslint-disable-line no-undef | ||
if( !canvas ){ | ||
canvas = this.labelCalcCanvas = document.createElement('canvas'); | ||
c2d = this.labelCalcCanvasContext = canvas.getContext('2d'); | ||
let ds = canvas.style; | ||
ds.position = 'absolute'; | ||
ds.left = '-9999px'; | ||
ds.top = '-9999px'; | ||
ds.zIndex = '-1'; | ||
ds.visibility = 'hidden'; | ||
ds.pointerEvents = 'none'; | ||
} | ||
let ds = div.style; | ||
c2d.font = `${fStyle} ${weight} ${size}px ${family}`; | ||
// from ele style | ||
ds.fontFamily = family; | ||
ds.fontStyle = fStyle; | ||
ds.fontSize = size; | ||
ds.fontWeight = weight; | ||
let width = 0; | ||
let height = 0; | ||
let lines = text.split('\n'); | ||
// forced style | ||
ds.position = 'absolute'; | ||
ds.left = '-9999px'; | ||
ds.top = '-9999px'; | ||
ds.zIndex = '-1'; | ||
ds.visibility = 'hidden'; | ||
ds.pointerEvents = 'none'; | ||
ds.padding = '0'; | ||
ds.lineHeight = '1'; | ||
for( let i = 0; i < lines.length; i++ ){ | ||
let line = lines[i]; | ||
let metrics = c2d.measureText(line); | ||
let w = Math.ceil(metrics.width); | ||
let h = size; | ||
// - newlines must be taken into account for text-wrap:wrap | ||
// - since spaces are not collapsed, each space must be taken into account | ||
ds.whiteSpace = 'pre'; | ||
width = Math.max(w, width); | ||
height += h; | ||
} | ||
// put label content in div | ||
div.textContent = text; | ||
width += padding; | ||
height += padding; | ||
return ( cache[ cacheKey ] = { | ||
width: Math.ceil( div.clientWidth / sizeMult ), | ||
height: Math.ceil( div.clientHeight / sizeMult ) | ||
width, | ||
height | ||
} ); | ||
@@ -515,0 +520,0 @@ }; |
@@ -808,3 +808,3 @@ import * as is from '../../../is'; | ||
if( r.nodeIsDraggable( dEle ) && dEle.grabbed() ){ | ||
toTrigger.merge( dEle ); | ||
toTrigger.push( dEle ); | ||
} | ||
@@ -811,0 +811,0 @@ } |
@@ -27,3 +27,3 @@ /*global HTMLElement DocumentTouch */ | ||
export const array = obj => | ||
Array.isArray ? Array.isArray( obj ) : obj != null && obj instanceof Array; | ||
!(elementOrCollection(obj)) && (Array.isArray ? Array.isArray( obj ) : obj != null && obj instanceof Array); | ||
@@ -30,0 +30,0 @@ export const plainObject = obj => |
@@ -47,3 +47,3 @@ import * as util from '../util'; | ||
if( hintsDiff ){ | ||
updatedEles.merge( ele ); | ||
updatedEles.push( ele ); | ||
} | ||
@@ -375,3 +375,3 @@ | ||
let nodeKeys = [nodeBody, nodeBorder, backgroundImage, compound, pie ].reduce(util.hashArrays, [ | ||
let nodeKeys = [ nodeBody, nodeBorder, backgroundImage, compound, pie ].filter(k => k != null).reduce(util.hashArrays, [ | ||
util.DEFAULT_HASH_SEED, | ||
@@ -382,3 +382,3 @@ util.DEFAULT_HASH_SEED_ALT | ||
_p.hasPie = pie[0] !== util.DEFAULT_HASH_SEED && pie[1] !== util.DEFAULT_HASH_SEED_ALT; | ||
_p.hasPie = pie != null && pie[0] !== util.DEFAULT_HASH_SEED && pie[1] !== util.DEFAULT_HASH_SEED_ALT; | ||
} | ||
@@ -834,6 +834,3 @@ | ||
if( // only for beziers -- so performance of other edges isn't affected | ||
( ele.pstyle('curve-style').value === 'bezier' // already a bezier | ||
// was just now changed to or from a bezier: | ||
|| (name === 'curve-style' && (fromValue === 'bezier' || toValue === 'bezier')) | ||
) | ||
( name === 'curve-style' && (fromValue === 'bezier' || toValue === 'bezier') ) | ||
&& prop.triggersBoundsOfParallelBeziers | ||
@@ -840,0 +837,0 @@ ){ |
@@ -48,2 +48,6 @@ import * as util from '../util'; | ||
if( prop && (prop.name === 'width' || prop.name === 'height') && value === 'label' ){ | ||
util.warn('The style value of `label` is deprecated for `' + prop.name + '`'); | ||
} | ||
return prop; | ||
@@ -50,0 +54,0 @@ }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4240409
106981