Merge pull request #40 from kriffe/master

NPM 0.6.0
This commit is contained in:
Javi Agenjo
2018-06-08 18:22:37 +02:00
committed by GitHub
10 changed files with 9714 additions and 6136 deletions

1
.npmrc Normal file
View File

@@ -0,0 +1 @@
package-lock=false

File diff suppressed because it is too large Load Diff

7846
build/litegraph.min.js vendored

File diff suppressed because it is too large Load Diff

100
demo/js/code.js Executable file → Normal file
View File

@@ -1,50 +1,50 @@
LiteGraph.node_images_path = "../nodes_data/";
var editor = new LiteGraph.Editor("main");
window.graphcanvas = editor.graphcanvas;
window.graph = editor.graph;
window.addEventListener("resize", function() { editor.graphcanvas.resize(); } );
window.addEventListener("keydown", editor.graphcanvas.processKey.bind(editor.graphcanvas) );
//create scene selector
var elem = document.createElement("span");
elem.className = "selector";
elem.innerHTML = "Demo <select><option>Empty</option></select> <button id='save'>Save</button><button id='load'>Load</button>";
editor.tools.appendChild(elem);
var select = elem.querySelector("select");
select.addEventListener("change", function(e){
var option = this.options[this.selectedIndex];
var url = option.dataset["url"];
if(url)
graph.load( url );
else
graph.clear();
});
elem.querySelector("#save").addEventListener("click",function(){
console.log("saved");
localStorage.setItem( "graphdemo_save", JSON.stringify( graph.serialize() ) );
});
elem.querySelector("#load").addEventListener("click",function(){
var data = localStorage.getItem( "graphdemo_save" );
if(data)
graph.configure( JSON.parse( data ) );
console.log("loaded");
});
function addDemo( name, url )
{
var option = document.createElement("option");
option.dataset["url"] = url;
option.innerHTML = name;
select.appendChild( option );
}
//some examples
addDemo("Audio", "examples/audio.json");
addDemo("Audio Delay", "examples/audio_delay.json");
addDemo("Audio Reverb", "examples/audio_reverb.json");
LiteGraph.node_images_path = "../nodes_data/";
var editor = new LiteGraph.Editor("main");
window.graphcanvas = editor.graphcanvas;
window.graph = editor.graph;
window.addEventListener("resize", function() { editor.graphcanvas.resize(); } );
window.addEventListener("keydown", editor.graphcanvas.processKey.bind(editor.graphcanvas) );
//create scene selector
var elem = document.createElement("span");
elem.className = "selector";
elem.innerHTML = "Demo <select><option>Empty</option></select> <button id='save'>Save</button><button id='load'>Load</button>";
editor.tools.appendChild(elem);
var select = elem.querySelector("select");
select.addEventListener("change", function(e){
var option = this.options[this.selectedIndex];
var url = option.dataset["url"];
if(url)
graph.load( url );
else
graph.clear();
});
elem.querySelector("#save").addEventListener("click",function(){
console.log("saved");
localStorage.setItem( "graphdemo_save", JSON.stringify( graph.serialize() ) );
});
elem.querySelector("#load").addEventListener("click",function(){
var data = localStorage.getItem( "graphdemo_save" );
if(data)
graph.configure( JSON.parse( data ) );
console.log("loaded");
});
function addDemo( name, url )
{
var option = document.createElement("option");
option.dataset["url"] = url;
option.innerHTML = name;
select.appendChild( option );
}
//some examples
addDemo("Audio", "examples/audio.json");
addDemo("Audio Delay", "examples/audio_delay.json");
addDemo("Audio Reverb", "examples/audio_reverb.json");

158
demo/js/demos.js Executable file → Normal file
View File

@@ -1,80 +1,80 @@
function demo()
{
multiConnection();
}
function multiConnection()
{
var node_button = LiteGraph.createNode("widget/button");
node_button.pos = [100,400];
graph.add(node_button);
var node_console = LiteGraph.createNode("basic/console");
node_console.pos = [400,400];
graph.add(node_console);
node_button.connect(0, node_console );
var node_const_A = LiteGraph.createNode("basic/const");
node_const_A.pos = [200,200];
graph.add(node_const_A);
node_const_A.setValue(4.5);
var node_const_B = LiteGraph.createNode("basic/const");
node_const_B.pos = [200,300];
graph.add(node_const_B);
node_const_B.setValue(10);
var node_math = LiteGraph.createNode("math/operation");
node_math.pos = [400,200];
graph.add(node_math);
var node_watch = LiteGraph.createNode("basic/watch");
node_watch.pos = [700,200];
graph.add(node_watch);
var node_watch2 = LiteGraph.createNode("basic/watch");
node_watch2.pos = [700,300];
graph.add(node_watch2);
node_const_A.connect(0,node_math,0 );
node_const_B.connect(0,node_math,1 );
node_math.connect(0,node_watch,0 );
node_math.connect(0,node_watch2,0 );
}
function sortTest()
{
var rand = LiteGraph.createNode("math/rand",null, {pos: [10,100] });
graph.add(rand);
var nodes = [];
for(var i = 4; i >= 1; i--)
{
var n = LiteGraph.createNode("basic/watch",null, {pos: [i * 120,100] });
graph.add(n);
nodes[i-1] = n;
}
rand.connect(0, nodes[0], 0);
for(var i = 0; i < nodes.length - 1; i++)
nodes[i].connect(0,nodes[i+1], 0);
}
function benchmark()
{
var num_nodes = 200;
var nodes = [];
for(var i = 0; i < num_nodes; i++)
{
var n = LiteGraph.createNode("basic/watch",null, {pos: [(2000 * Math.random())|0, (2000 * Math.random())|0] });
graph.add(n);
nodes.push(n);
}
for(var i = 0; i < nodes.length; i++)
nodes[ (Math.random() * nodes.length)|0 ].connect(0, nodes[ (Math.random() * nodes.length)|0 ], 0 );
function demo()
{
multiConnection();
}
function multiConnection()
{
var node_button = LiteGraph.createNode("widget/button");
node_button.pos = [100,400];
graph.add(node_button);
var node_console = LiteGraph.createNode("basic/console");
node_console.pos = [400,400];
graph.add(node_console);
node_button.connect(0, node_console );
var node_const_A = LiteGraph.createNode("basic/const");
node_const_A.pos = [200,200];
graph.add(node_const_A);
node_const_A.setValue(4.5);
var node_const_B = LiteGraph.createNode("basic/const");
node_const_B.pos = [200,300];
graph.add(node_const_B);
node_const_B.setValue(10);
var node_math = LiteGraph.createNode("math/operation");
node_math.pos = [400,200];
graph.add(node_math);
var node_watch = LiteGraph.createNode("basic/watch");
node_watch.pos = [700,200];
graph.add(node_watch);
var node_watch2 = LiteGraph.createNode("basic/watch");
node_watch2.pos = [700,300];
graph.add(node_watch2);
node_const_A.connect(0,node_math,0 );
node_const_B.connect(0,node_math,1 );
node_math.connect(0,node_watch,0 );
node_math.connect(0,node_watch2,0 );
}
function sortTest()
{
var rand = LiteGraph.createNode("math/rand",null, {pos: [10,100] });
graph.add(rand);
var nodes = [];
for(var i = 4; i >= 1; i--)
{
var n = LiteGraph.createNode("basic/watch",null, {pos: [i * 120,100] });
graph.add(n);
nodes[i-1] = n;
}
rand.connect(0, nodes[0], 0);
for(var i = 0; i < nodes.length - 1; i++)
nodes[i].connect(0,nodes[i+1], 0);
}
function benchmark()
{
var num_nodes = 200;
var nodes = [];
for(var i = 0; i < num_nodes; i++)
{
var n = LiteGraph.createNode("basic/watch",null, {pos: [(2000 * Math.random())|0, (2000 * Math.random())|0] });
graph.add(n);
nodes.push(n);
}
for(var i = 0; i < nodes.length; i++)
nodes[ (Math.random() * nodes.length)|0 ].connect(0, nodes[ (Math.random() * nodes.length)|0 ], 0 );
}

View File

@@ -12,7 +12,8 @@ module.exports = function (grunt) {
'src/nodes/gltextures.js',
'src/nodes/glfx.js',
'src/nodes/midi.js',
'src/nodes/audio.js'
'src/nodes/audio.js',
'src/nodes/network.js'
],
concat: {
build: {
@@ -20,9 +21,6 @@ module.exports = function (grunt) {
dest: 'build/litegraph.js'
}
},
clean: {
build: {src: ['build/*']}
},
closureCompiler: {
options: {
@@ -42,28 +40,8 @@ module.exports = function (grunt) {
}
})
// grunt.registerTask('buildPackage', function () {
// var pkg = grunt.config.data.pkg
// var newPackage = {
// version: pkg.version,
// name: 'litegraph.js', //* Static name without ogranisation
// main: 'litegraph.js',
// description: pkg.description,
// dependencies: pkg.dependencies,
// author: pkg.author,
// license: 'MIT',
// scripts: {
// }
// }
// grunt.file.write('build/package.json', JSON.stringify(newPackage, undefined, 2))
// })
grunt.loadNpmTasks('grunt-contrib-concat')
grunt.loadNpmTasks('grunt-contrib-copy')
grunt.loadNpmTasks('grunt-closure-tools')
grunt.loadNpmTasks('grunt-contrib-clean')
grunt.registerTask('build', ['concat:build', 'closureCompiler'])
}

3367
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "litegraph.js",
"version": "0.3.0",
"version": "0.6.0",
"description": "A graph node editor similar to PD or UDK Blueprints, it works in a HTML5 Canvas and allow to exported graphs to be included in applications.",
"main": "build/litegraph.js",
"directories": {
@@ -8,9 +8,9 @@
},
"private": false,
"scripts": {
"prebuild": "grunt clean:build",
"prebuild": "rimraf build",
"build": "grunt build",
"start": "npx nodemon utils/server.js",
"start": "nodemon utils/server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
@@ -31,10 +31,10 @@
"express": "^4.16.2",
"google-closure-compiler": "^20171112.0.0",
"grunt": "^1.0.1",
"grunt-cli": "^1.2.0",
"grunt-closure-tools": "^1.0.0",
"grunt-contrib-clean": "^1.1.0",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-copy": "^1.0.0",
"nodemon": "^1.14.7"
"nodemon": "^1.14.7",
"rimraf": "^2.6.2"
}
}

View File

@@ -336,7 +336,10 @@ var LiteGraph = global.LiteGraph = {
!type_b || //generic input
type_a == type_b || //same type (is valid for triggers)
type_a == LiteGraph.EVENT && type_b == LiteGraph.ACTION )
return true;
return true;
type_a = String(type_a) //* Enforce string type to handle toLowerCase call (-1 number not ok)
type_b = String(type_b)
type_a = type_a.toLowerCase();
type_b = type_b.toLowerCase();

View File

@@ -1,8 +1,6 @@
const express = require('express')
const app = express()
// app.get('/hello', (req, res) => res.send('Hello World!'))
app.use('/css', express.static('css'))
app.use('/src', express.static('src'))
app.use('/external', express.static('external'))