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

assetviz

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assetviz - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

12

index.js

@@ -50,6 +50,14 @@ var Path = require('path'),

asset.idx = idx;
var size = 400;
if (asset.url && asset.isLoaded) {
size = asset.rawSrc.length;
}
data.assets.push({
path: asset.url ? Path.relative(assetGraph.root, asset.url) : '',
fileName: (asset.url ? Path.basename(asset.url) : 'i:' + asset).replace(/"/g, '\\"'),
type: asset.type.toLowerCase()
type: asset.type.toLowerCase(),
size: size,
r: 3 + Math.sqrt(size / 100),
outgoing: 0,
initial: asset.isInitial
});

@@ -66,2 +74,3 @@ idx += 1;

}
data.assets[relation.from.idx].outgoing += 1;
data.relations.push({

@@ -119,3 +128,2 @@ source: relation.from.idx,

.writeAssetsToDisc({url: /^file:/})
.writeStatsToStderr()
.run(function (err) {

@@ -122,0 +130,0 @@ if (err) {

2

package.json
{
"name": "assetviz",
"version": "0.1.1",
"version": "0.1.2",
"description": "A graph visualization of the assets and their relations in your web app",

@@ -5,0 +5,0 @@ "main": "index.js",

/*global d3, assetgraph*/
/*jshint onevar:false*/
window.onload = function () {
// Fallback to show nothing. This shoudl probably be improved
window.assetgraph = assetgraph || {
assets: [],
relations: []
};
// Data preperation for simpler d3 code
assetgraph.relations.forEach(function (relation) {
var distance = 10 +
assetgraph.assets[relation.source].r +
assetgraph.assets[relation.target].r +
assetgraph.assets[relation.source].outgoing * 2 +
relation.type.length * 6;
relation.distance = distance;
});
var svg = d3.select('.graph'),

@@ -10,6 +28,18 @@ force = d3.layout.force()

.gravity(.05)
.charge(-300)
.linkDistance(200);
.charge(function (d) {
var charge = -200;
// Big files repulse more
charge -= (d.size / 200);
// Initial files get extra bonus
if (d.initial) {
charge -= 1000;
}
return charge;
})
.linkDistance(function (d) {
return d.distance;
});
var edges = svg.append('g')

@@ -28,5 +58,8 @@ .attr('class', 'relations')

.append('text')
.attr('text-anchor', 'middle')
.attr('text-anchor', 'end')
.append('textPath')
.attr('startOffset', '50%')
.attr('startOffset', function (d) {
var offset = d.distance - assetgraph.assets[d.target].r - 5;
return offset;
})
.attr('xlink:href', function (d, i) { return '#p' + i; })

@@ -42,3 +75,3 @@ .text(function (d) { return d.type; });

nodes.append('circle')
.attr('r', 6)
.attr('r', function (d) { return d.r; })
.attr('class', function (d) { return d.type; })

@@ -49,3 +82,3 @@ .call(force.drag);

.attr('text-anchor', 'middle')
.attr('dy', function () { return -10; })
.attr('dy', function (d) { return -(5 + d.r); })
.text(function (d) { return d.fileName; });

@@ -52,0 +85,0 @@

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